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