mirror of
https://git.srhtnin.garden/sarah/srhtnin.github.io.git
synced 2026-10-13 18:38:11 +02:00
Added admn QOL stuff andalso made shop a bit easier to navigate with
collapsible sections.
This commit is contained in:
1 parent
a055a74148
commit
afb9dae47a
5 files changed
+379
-17
No files matched your search
@@ -64,6 +64,13 @@ function BindAdminPlantEditor() {
|
||||
StartNewAdminPlant
|
||||
);
|
||||
|
||||
document.getElementById(
|
||||
"AdminPlantDuplicateButton"
|
||||
).addEventListener(
|
||||
"click",
|
||||
DuplicateAdminPlant
|
||||
);
|
||||
|
||||
document.getElementById(
|
||||
"AdminPlantForm"
|
||||
).addEventListener(
|
||||
@@ -279,6 +286,7 @@ async function LoadAdminPlants(
|
||||
AdminPlantMutationCatalogue;
|
||||
|
||||
RenderAdminPlantSelect();
|
||||
RenderAdminPlantDuplicateSelect();
|
||||
|
||||
const Keys =
|
||||
GetSortedAdminPlantKeys();
|
||||
@@ -376,6 +384,70 @@ function RenderAdminPlantSelect() {
|
||||
}
|
||||
|
||||
|
||||
function RenderAdminPlantDuplicateSelect() {
|
||||
const Select =
|
||||
document.getElementById(
|
||||
"AdminPlantDuplicateSelect"
|
||||
);
|
||||
|
||||
if (Select === null) {
|
||||
return;
|
||||
}
|
||||
|
||||
const PreviousValue =
|
||||
Select.value;
|
||||
|
||||
Select.replaceChildren();
|
||||
|
||||
for (
|
||||
const PlantKey
|
||||
of GetSortedAdminPlantKeys()
|
||||
) {
|
||||
const Plant =
|
||||
AdminPlantCatalogue[
|
||||
PlantKey
|
||||
];
|
||||
|
||||
const Option =
|
||||
document.createElement(
|
||||
"option"
|
||||
);
|
||||
|
||||
Option.value =
|
||||
PlantKey;
|
||||
|
||||
Option.textContent =
|
||||
String(
|
||||
Plant.Id
|
||||
).padStart(
|
||||
3,
|
||||
"0"
|
||||
) +
|
||||
" — " +
|
||||
Plant.Name +
|
||||
(
|
||||
Plant.Archived === true
|
||||
? " (archived)"
|
||||
: ""
|
||||
);
|
||||
|
||||
Select.appendChild(
|
||||
Option
|
||||
);
|
||||
}
|
||||
|
||||
if (
|
||||
PreviousValue !== "" &&
|
||||
AdminPlantCatalogue[
|
||||
PreviousValue
|
||||
] !== undefined
|
||||
) {
|
||||
Select.value =
|
||||
PreviousValue;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function LoadAdminPlantIntoForm(
|
||||
PlantKey
|
||||
) {
|
||||
@@ -475,6 +547,123 @@ function LoadAdminPlantIntoForm(
|
||||
}
|
||||
|
||||
|
||||
function DuplicateAdminPlant() {
|
||||
const SourcePlantKey =
|
||||
document.getElementById(
|
||||
"AdminPlantDuplicateSelect"
|
||||
).value;
|
||||
|
||||
const SourcePlant =
|
||||
AdminPlantCatalogue[
|
||||
SourcePlantKey
|
||||
];
|
||||
|
||||
if (SourcePlant === undefined) {
|
||||
SetAdminPlantMessage(
|
||||
"Choose a plant to duplicate."
|
||||
);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
AdminPlantEditingKey = null;
|
||||
|
||||
document.getElementById(
|
||||
"AdminPlantSelect"
|
||||
).value = "";
|
||||
|
||||
SetAdminPlantField(
|
||||
"AdminPlantId",
|
||||
GetNextAdminPlantId()
|
||||
);
|
||||
|
||||
SetAdminPlantField(
|
||||
"AdminPlantKey",
|
||||
""
|
||||
);
|
||||
|
||||
SetAdminPlantField(
|
||||
"AdminPlantName",
|
||||
""
|
||||
);
|
||||
|
||||
SetAdminPlantField(
|
||||
"AdminPlantDescription",
|
||||
SourcePlant.Description ?? ""
|
||||
);
|
||||
|
||||
SetAdminPlantField(
|
||||
"AdminPlantTags",
|
||||
Array.isArray(
|
||||
SourcePlant.Tags
|
||||
)
|
||||
? SourcePlant.Tags.join(
|
||||
", "
|
||||
)
|
||||
: ""
|
||||
);
|
||||
|
||||
SetAdminPlantDurationFields(
|
||||
Number(
|
||||
SourcePlant.GrowthTime ??
|
||||
0
|
||||
)
|
||||
);
|
||||
|
||||
SetAdminPlantField(
|
||||
"AdminPlantHarvestMultiplier",
|
||||
Number(
|
||||
SourcePlant.HarvestMultiplier ??
|
||||
1.5
|
||||
)
|
||||
);
|
||||
|
||||
document.getElementById(
|
||||
"AdminPlantShopPlant"
|
||||
).checked =
|
||||
SourcePlant.Shop?.ShopPlant === true;
|
||||
|
||||
SetAdminPlantField(
|
||||
"AdminPlantBaseCost",
|
||||
SourcePlant.Shop?.BaseCost ?? ""
|
||||
);
|
||||
|
||||
SetAdminPlantField(
|
||||
"AdminPlantEffects",
|
||||
JSON.stringify(
|
||||
SourcePlant.Effects ?? {},
|
||||
null,
|
||||
4
|
||||
)
|
||||
);
|
||||
|
||||
document.getElementById(
|
||||
"AdminPlantId"
|
||||
).readOnly = false;
|
||||
|
||||
document.getElementById(
|
||||
"AdminPlantKey"
|
||||
).readOnly = false;
|
||||
|
||||
document.getElementById(
|
||||
"AdminPlantArchiveNote"
|
||||
).hidden = true;
|
||||
|
||||
UpdateAdminPlantShopFields();
|
||||
RenderAdminPlantPreview();
|
||||
|
||||
document.getElementById(
|
||||
"AdminPlantName"
|
||||
).focus();
|
||||
|
||||
SetAdminPlantMessage(
|
||||
"Duplicated " +
|
||||
SourcePlant.Name +
|
||||
". Give the new plant a name and Plant Key before saving. Sprites are not copied."
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
function StartNewAdminPlant() {
|
||||
AdminPlantEditingKey = null;
|
||||
|
||||
|
||||
+83
-4
@@ -21,10 +21,69 @@ async function StartShop() {
|
||||
|
||||
ShopSave = await LoadGame();
|
||||
|
||||
BindShopSectionToggles();
|
||||
RenderShop();
|
||||
}
|
||||
|
||||
|
||||
function BindShopSectionToggles() {
|
||||
BindShopSectionToggle(
|
||||
"PermanentUpgradesToggle",
|
||||
"PermanentUpgradesContent"
|
||||
);
|
||||
|
||||
BindShopSectionToggle(
|
||||
"SeedsToggle",
|
||||
"SeedsContent"
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
function BindShopSectionToggle(
|
||||
ToggleId,
|
||||
ContentId
|
||||
) {
|
||||
const Toggle =
|
||||
document.getElementById(
|
||||
ToggleId
|
||||
);
|
||||
|
||||
const Content =
|
||||
document.getElementById(
|
||||
ContentId
|
||||
);
|
||||
|
||||
if (
|
||||
Toggle === null ||
|
||||
Content === null
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
Toggle.addEventListener(
|
||||
"click",
|
||||
() => {
|
||||
const IsExpanded =
|
||||
Toggle.getAttribute(
|
||||
"aria-expanded"
|
||||
) === "true";
|
||||
|
||||
const NewExpanded =
|
||||
!IsExpanded;
|
||||
|
||||
Toggle.setAttribute(
|
||||
"aria-expanded",
|
||||
String(NewExpanded)
|
||||
);
|
||||
|
||||
Content.hidden =
|
||||
!NewExpanded;
|
||||
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
function RenderShop() {
|
||||
RenderShopCurrency();
|
||||
RenderShopSeeds();
|
||||
@@ -413,7 +472,12 @@ function CreatePlantInformationUpgradeCard() {
|
||||
);
|
||||
|
||||
Header.className =
|
||||
"ShopItemHeader";
|
||||
"ShopItemHeader" +
|
||||
(
|
||||
IsOwned
|
||||
? " ShopItemHeaderOwned"
|
||||
: ""
|
||||
);
|
||||
|
||||
|
||||
const Name =
|
||||
@@ -529,7 +593,12 @@ function CreateGardenOverviewUpgradeCard() {
|
||||
);
|
||||
|
||||
Header.className =
|
||||
"ShopItemHeader";
|
||||
"ShopItemHeader" +
|
||||
(
|
||||
IsOwned
|
||||
? " ShopItemHeaderOwned"
|
||||
: ""
|
||||
);
|
||||
|
||||
|
||||
const Name =
|
||||
@@ -645,7 +714,12 @@ function CreateGardenEconomyUpgradeCard() {
|
||||
);
|
||||
|
||||
Header.className =
|
||||
"ShopItemHeader";
|
||||
"ShopItemHeader" +
|
||||
(
|
||||
IsOwned
|
||||
? " ShopItemHeaderOwned"
|
||||
: ""
|
||||
);
|
||||
|
||||
|
||||
const Name =
|
||||
@@ -759,7 +833,12 @@ function CreateMutationHintsUpgradeCard() {
|
||||
);
|
||||
|
||||
Header.className =
|
||||
"ShopItemHeader";
|
||||
"ShopItemHeader" +
|
||||
(
|
||||
IsOwned
|
||||
? " ShopItemHeaderOwned"
|
||||
: ""
|
||||
);
|
||||
|
||||
|
||||
const Name =
|
||||
|
||||
Reference in new issue
Block a user