Added cycling images for mutations that allow immature plants, too.

Works with lists!
This commit is contained in:
sarah committed 2026-09-07 16:38:57 +02:00
1 parent ea50b76e26
commit 7f9284c5e2
4 files changed
+242 -34

No files matched your search

+30 -10
View File
@@ -2638,7 +2638,8 @@ function CreateAdminTransferMutationRecipe(
"Pattern",
PlantCatalogue,
Mutation.Lists,
ListOffsets.Pattern
ListOffsets.Pattern,
Mutation.AllowImmature === true
),
Arrow,
CreateAdminTransferMutationRecipePanel(
@@ -2647,7 +2648,8 @@ function CreateAdminTransferMutationRecipe(
"Result",
PlantCatalogue,
Mutation.Lists,
ListOffsets.Result
ListOffsets.Result,
false
)
);
@@ -2762,7 +2764,8 @@ function CreateAdminTransferMutationRecipePanel(
Mode,
PlantCatalogue,
Lists,
ListOffsets
ListOffsets,
CyclePlantStages = false
) {
const Panel =
document.createElement(
@@ -2810,7 +2813,8 @@ function CreateAdminTransferMutationRecipePanel(
CreateAdminTransferMutationCell(
Value,
Mode,
PlantCatalogue
PlantCatalogue,
CyclePlantStages
);
const ListNumber =
@@ -2824,7 +2828,10 @@ function CreateAdminTransferMutationRecipePanel(
Lists?.[ListNumber - 1],
ListNumber,
ListOffsets?.[Y]?.[X],
PlantCatalogue
PlantCatalogue,
"MutationRecipeText",
Mode === "Pattern" &&
CyclePlantStages
);
}
@@ -2844,7 +2851,8 @@ function CreateAdminTransferMutationRecipePanel(
function CreateAdminTransferMutationCell(
Value,
Mode,
PlantCatalogue
PlantCatalogue,
CyclePlantStages = false
) {
if (Mode === "Result") {
if (
@@ -2903,7 +2911,8 @@ function CreateAdminTransferMutationCell(
return CreateAdminTransferPlantCell(
PlantValue,
PlantCatalogue
PlantCatalogue,
CyclePlantStages
);
}
@@ -2939,7 +2948,8 @@ function CreateAdminTransferMutationCell(
return CreateAdminTransferPlantCell(
Value,
PlantCatalogue
PlantCatalogue,
CyclePlantStages
);
}
@@ -2953,7 +2963,8 @@ function CreateAdminTransferMutationCell(
if (typeof Value.Plant === "string") {
return CreateAdminTransferPlantCell(
Value.Plant,
PlantCatalogue
PlantCatalogue,
CyclePlantStages
);
}
@@ -3004,7 +3015,8 @@ function CreateAdminTransferMutationCell(
function CreateAdminTransferPlantCell(
PlantKey,
PlantCatalogue
PlantCatalogue,
CyclePlantStages = false
) {
const Plant =
PlantCatalogue[PlantKey];
@@ -3054,6 +3066,14 @@ function CreateAdminTransferPlantCell(
PlantKey;
Element.appendChild(Label);
if (CyclePlantStages === true) {
RegisterMutationRecipePreviewPlantStageCell(
Element,
Plant
);
}
return Element;
}
+51 -6
View File
@@ -121,6 +121,13 @@ function BindAdminMutationEditor() {
AddAdminMutationList
);
document.getElementById(
"AdminMutationAllowImmature"
).addEventListener(
"change",
RenderAdminMutationGrids
);
document.getElementById(
"AdminMutationForm"
).addEventListener(
@@ -2038,18 +2045,25 @@ function RenderAdminMutationGrids() {
AdminMutationResult
);
const AllowImmature =
document.getElementById(
"AdminMutationAllowImmature"
).checked;
RenderAdminMutationGrid(
"AdminMutationPatternGrid",
"Pattern",
AdminMutationPattern,
ListOffsets.Pattern
ListOffsets.Pattern,
AllowImmature
);
RenderAdminMutationGrid(
"AdminMutationResultGrid",
"Result",
AdminMutationResult,
ListOffsets.Result
ListOffsets.Result,
false
);
}
@@ -2058,7 +2072,8 @@ function RenderAdminMutationGrid(
ContainerId,
Mode,
Matrix,
ListOffsets
ListOffsets,
CyclePlantStages = false
) {
const Grid =
document.getElementById(
@@ -2090,7 +2105,8 @@ function RenderAdminMutationGrid(
X,
Y,
Matrix[Y][X],
ListOffsets?.[Y]?.[X]
ListOffsets?.[Y]?.[X],
CyclePlantStages
)
);
}
@@ -2103,7 +2119,8 @@ function CreateAdminMutationGridCell(
X,
Y,
Value,
ListOffset
ListOffset,
CyclePlantStages = false
) {
const Button =
document.createElement(
@@ -2192,8 +2209,36 @@ function CreateAdminMutationGridCell(
ListNumber,
ListOffset,
AdminMutationPlantCatalogue,
"GuideRecipeLabel"
"GuideRecipeLabel",
Mode === "Pattern" &&
CyclePlantStages
);
} else if (
Mode === "Pattern" &&
CyclePlantStages === true
) {
const PlantKey =
typeof Value === "string"
? Value
: Value !== null &&
typeof Value === "object" &&
typeof Value.Plant === "string"
? Value.Plant
: null;
if (
PlantKey !== null &&
AdminMutationPlantCatalogue[
PlantKey
] !== undefined
) {
RegisterMutationRecipePreviewPlantStageCell(
Button,
AdminMutationPlantCatalogue[
PlantKey
]
);
}
}
Button.addEventListener(
+31 -11
View File
@@ -1152,7 +1152,8 @@ function CreateMutationRecipeFlow(
Pattern,
"Pattern",
Mutation.Lists,
ListOffsets.Pattern
ListOffsets.Pattern,
Mutation.AllowImmature === true
);
const Arrow =
@@ -1178,7 +1179,8 @@ function CreateMutationRecipeFlow(
Success,
"Result",
Mutation.Lists,
ListOffsets.Result
ListOffsets.Result,
false
);
@@ -1300,7 +1302,8 @@ function CreateMutationRecipePanel(
Matrix,
Mode,
Lists,
ListOffsets
ListOffsets,
CyclePlantStages = false
) {
const Panel =
document.createElement(
@@ -1357,7 +1360,8 @@ function CreateMutationRecipePanel(
Value,
Mode,
Lists,
ListOffsets?.[Y]?.[X]
ListOffsets?.[Y]?.[X],
CyclePlantStages
);
Grid.appendChild(
@@ -1393,7 +1397,8 @@ function CreateMutationRecipeCell(
Value,
Mode,
Lists,
ListOffset
ListOffset,
CyclePlantStages = false
) {
if (Mode === "Result") {
return CreateMutationResultCell(
@@ -1406,7 +1411,8 @@ function CreateMutationRecipeCell(
return CreateMutationPatternCell(
Value,
Lists,
ListOffset
ListOffset,
CyclePlantStages
);
}
@@ -1414,7 +1420,8 @@ function CreateMutationRecipeCell(
function CreateMutationPatternCell(
Matcher,
Lists,
ListOffset
ListOffset,
CyclePlantStages = false
) {
if (
Matcher === null ||
@@ -1456,14 +1463,17 @@ function CreateMutationPatternCell(
Lists?.[ListNumber - 1],
ListNumber,
ListOffset,
Plants
Plants,
"MutationRecipeText",
CyclePlantStages
);
return Cell;
}
return CreateMutationPlantCell(
Matcher
Matcher,
CyclePlantStages
);
}
@@ -1485,7 +1495,8 @@ function CreateMutationPatternCell(
"string"
) {
return CreateMutationPlantCell(
Matcher.Plant
Matcher.Plant,
CyclePlantStages
);
}
@@ -1677,7 +1688,8 @@ function CreateMutationResultCell(
function CreateMutationPlantCell(
PlantKey
PlantKey,
CyclePlantStages = false
) {
const Plant =
Plants[PlantKey];
@@ -1744,6 +1756,14 @@ function CreateMutationPlantCell(
);
if (CyclePlantStages === true) {
RegisterMutationRecipePreviewPlantStageCell(
Element,
Plant
);
}
return {
Element: Element,
Label: Plant.Name
+130 -7
View File
@@ -4,6 +4,7 @@ let MutationRecipePreviewFrame = 0;
let MutationRecipePreviewTimer = null;
const MutationRecipePreviewCells = new Set();
const MutationRecipePreviewPlantStageCells = new Set();
const MutationRecipePreviewPermutations = new Map();
@@ -261,7 +262,8 @@ function RegisterMutationRecipePreviewListCell(
ListNumber,
Offset,
PlantCatalogue,
TextClassName = "MutationRecipeText"
TextClassName = "MutationRecipeText",
CyclePlantStages = false
) {
const Entry = {
Element: Element,
@@ -273,7 +275,9 @@ function RegisterMutationRecipePreviewListCell(
: 0,
PlantCatalogue:
PlantCatalogue ?? {},
TextClassName: TextClassName
TextClassName: TextClassName,
CyclePlantStages:
CyclePlantStages === true
};
MutationRecipePreviewCells.add(
@@ -289,10 +293,44 @@ function RegisterMutationRecipePreviewListCell(
}
function RegisterMutationRecipePreviewPlantStageCell(
Element,
PlantOrKey
) {
const Images =
GetMutationRecipePreviewPlantStageImages(
PlantOrKey
);
if (Images.length <= 1) {
return;
}
const Entry = {
Element: Element,
Images: Images
};
MutationRecipePreviewPlantStageCells.add(
Entry
);
RenderMutationRecipePreviewPlantStageCell(
Entry,
MutationRecipePreviewFrame
);
StartMutationRecipePreviewTimer();
}
function StartMutationRecipePreviewTimer() {
if (
MutationRecipePreviewTimer !== null ||
MutationRecipePreviewCells.size === 0
(
MutationRecipePreviewCells.size === 0 &&
MutationRecipePreviewPlantStageCells.size === 0
)
) {
return;
}
@@ -335,8 +373,28 @@ function AdvanceMutationRecipePreviewFrame() {
);
}
for (
const Entry
of Array.from(
MutationRecipePreviewPlantStageCells
)
) {
if (!Entry.Element.isConnected) {
MutationRecipePreviewPlantStageCells.delete(
Entry
);
continue;
}
RenderMutationRecipePreviewPlantStageCell(
Entry,
MutationRecipePreviewFrame
);
}
if (
MutationRecipePreviewCells.size === 0 &&
MutationRecipePreviewPlantStageCells.size === 0 &&
MutationRecipePreviewTimer !== null
) {
window.clearInterval(
@@ -384,7 +442,9 @@ function RenderMutationRecipePreviewListCell(
Entry,
GetMutationRecipePreviewItemDisplay(
Items[ItemIndex],
Entry.PlantCatalogue
Entry.PlantCatalogue,
Entry.CyclePlantStages,
Frame
)
);
}
@@ -514,7 +574,9 @@ function CreateMutationRecipePreviewPermutation(
function GetMutationRecipePreviewItemDisplay(
Item,
PlantCatalogue
PlantCatalogue,
CyclePlantStages = false,
Frame = 0
) {
if (Item?.Type === "Plant") {
const Plant =
@@ -538,8 +600,10 @@ function GetMutationRecipePreviewItemDisplay(
Plant.Name ??
Item.Value,
Image:
GetPlantMatureImageSource(
Plant
GetMutationRecipePreviewPlantImageSource(
Plant,
CyclePlantStages,
Frame
),
ClassName:
"GuideRecipePlant"
@@ -574,6 +638,65 @@ function GetMutationRecipePreviewItemDisplay(
}
function GetMutationRecipePreviewPlantStageImages(
PlantOrKey
) {
return GetPlantImageSources(
PlantOrKey
).filter(
Image =>
typeof Image === "string" &&
Image.length > 0
);
}
function GetMutationRecipePreviewPlantImageSource(
PlantOrKey,
CyclePlantStages,
Frame
) {
if (CyclePlantStages !== true) {
return GetPlantMatureImageSource(
PlantOrKey
);
}
const Images =
GetMutationRecipePreviewPlantStageImages(
PlantOrKey
);
if (Images.length === 0) {
return null;
}
return Images[
Frame % Images.length
];
}
function RenderMutationRecipePreviewPlantStageCell(
Entry,
Frame
) {
const Image =
Entry.Element.querySelector(
"img.GuideRecipeImage"
);
if (Image === null) {
return;
}
Image.src =
Entry.Images[
Frame % Entry.Images.length
];
}
function ApplyMutationRecipePreviewCellDisplay(
Entry,
Display