Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
94 changes: 68 additions & 26 deletions src/functions/layeringMenu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,34 +38,76 @@
if (defaultItemHide.length === 0) return ret;
const overrideItemHide = Layering.Item.Property.wceOverrideHide || defaultItemHide;
const root = document.getElementById(Layering.ID.root);
root.classList.add("scroll-box");
root.querySelector("#layering-layer-div")?.classList.remove("scroll-box");
ElementCreate({ tag: "h1", attributes: { id: "layering-hide-header" }, parent: root, children: [displayText("[WCE] Configure layer hiding")] });
ElementCreate({
tag: "form",
attributes: { id: "layering-wce-hide-div" },
classList: ["layering-layer-inner-grid"],
parent: root,
children: defaultItemHide.map(h => ({
tag: "div",
classList: ["layering-pair"],
// ToDo: remove once R130 is out

Check warning on line 41 in src/functions/layeringMenu.ts

View workflow job for this annotation

GitHub Actions / lint

eslint(no-warning-comments)

Unexpected 'todo' comment: ToDo: remove once R130 is out
if (GameVersion === "R129") {
root.classList.add("scroll-box");
root.querySelector("#layering-layer-div")?.classList.remove("scroll-box");
ElementCreate({ tag: "h1", attributes: { id: "layering-hide-header" }, parent: root, children: [displayText("[WCE] Configure layer hiding")] });
ElementCreate({
tag: "form",
attributes: { id: "layering-wce-hide-div" },
classList: ["layering-layer-inner-grid"],
parent: root,
children: defaultItemHide.map(h => ({
tag: "div",
classList: ["layering-pair"],
children: [
ElementCheckbox.Create(
`layering-wce-hide-cb-${h}`,
() => {
const hideForm: HTMLFormElement = document.getElementById("layering-wce-hide-div") as HTMLFormElement;
Layering.Item.Property.wceOverrideHide = new FormData(hideForm).getAll("checkbox-hide") as AssetGroupName[];
if (defaultItemHide.length === Layering.Item.Property.wceOverrideHide.length) delete Layering.Item.Property.wceOverrideHide;
// oxlint-disable-next-line no-underscore-dangle
Layering._CharacterRefresh(Layering.Character, false, false);
},
{ value: h, disabled: Layering.Readonly, checked: overrideItemHide.includes(h) },
{ checkbox: { attributes: { name: "checkbox-hide" } } }
),
{ tag: "span", classList: ["layering-pair-text"], children: [h] },
],
})),
});
} else {
// >= R130Beta1
console.log(root);
ElementCreate({
tag: "fieldset",
attributes: { name: "wce-hide", id: "layering-wce-hide-div", "aria-labelledby": "layering-hide-header", disabled: Layering.Readonly },
parent: root.querySelector(".screen-main"),
children: [
ElementCheckbox.Create(
`layering-wce-hide-cb-${h}`,
() => {
const hideForm: HTMLFormElement = document.getElementById("layering-wce-hide-div") as HTMLFormElement;
Layering.Item.Property.wceOverrideHide = new FormData(hideForm).getAll("checkbox-hide") as AssetGroupName[];
if (defaultItemHide.length === Layering.Item.Property.wceOverrideHide.length) delete Layering.Item.Property.wceOverrideHide;
// oxlint-disable-next-line no-underscore-dangle
Layering._CharacterRefresh(Layering.Character, false, false);
},
{ value: h, disabled: Layering.Readonly, checked: overrideItemHide.includes(h) },
{ checkbox: { attributes: { name: "checkbox-hide" } } }
),
{ tag: "span", classList: ["layering-pair-text"], children: [h] },
{ tag: "h2", attributes: { id: "layering-hide-header" }, children: [displayText("[WCE] Configure layer hiding")] },
{
tag: "fieldset",
classList: ["layering-layer-inner-grid"],
children: [
{ tag: "legend" as const, children: ["Layers"] },
...defaultItemHide.map(h => ({
tag: "div" as const,
classList: ["layering-pair"],
children: [
ElementCheckbox.Create(
`layering-wce-hide-cb-${h}`,
() => {
const hidingInputs = document
.getElementById("layering-wce-hide-div")
?.querySelectorAll<HTMLInputElement>("input[type='checkbox']:checked");
Layering.Item.Property.wceOverrideHide = Array.from(hidingInputs).map(inp => inp.value as AssetGroupName);
if (defaultItemHide.length === Layering.Item.Property.wceOverrideHide.length) delete Layering.Item.Property.wceOverrideHide;
// oxlint-disable-next-line no-underscore-dangle
Layering._CharacterRefresh(Layering.Character, false, false);
},
{ value: h, checked: overrideItemHide.includes(h) },
{ checkbox: { attributes: { name: "checkbox-hide" } } }
),
{ tag: "label" as const, classList: ["layering-pair-text"], children: [h], attributes: { for: `layering-wce-hide-cb-${h}` } },
],
})),
],
},
],
})),
});
});
}
return ret;
});

Expand Down
62 changes: 33 additions & 29 deletions src/functions/wceStyles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
const INPUT_WARN_CLASS = "bce-input-warn";

export default function wceStyles(): void {
const css = /* CSS */ `
let css = /* CSS */ `
.bce-beep-link {
text-decoration: none;
}
Expand Down Expand Up @@ -293,34 +293,6 @@
z-index: 100 !important;
}

#layering {
grid-template:
"asset-header button-grid" min-content
"asset-grid asset-grid" min-content
"layer-header layer-header" min-content
"layer-grid layer-grid" auto
"layer-hide-header layer-hide-header" min-content
"layer-hide-grid layer-hide-grid" auto
/ auto min-content
;
}
#layering-button-grid {
top: 0;
position: sticky;
}
#layering-hide-header {
grid-area: layer-hide-header;
}
#layering-wce-hide-div {
box-sizing: border-box;
grid-area: layer-hide-grid;
width: 100%;
height: calc(100% - min(2vh, 1vw));
padding-left: min(2vh, 1vw);
padding-right: min(2vh, 1vw);
align-self: self-start;
}

.wce-chat-room-select,
#wce-chat-garble-label {
font-size: 80%;
Expand Down Expand Up @@ -374,6 +346,38 @@
--button-color: #666;
}
`;
// ToDo: remove once R130 is out

Check warning on line 349 in src/functions/wceStyles.ts

View workflow job for this annotation

GitHub Actions / lint

eslint(no-warning-comments)

Unexpected 'todo' comment: ToDo: remove once R130 is out
if (GameVersion === "R129") {
css += `
#layering {
grid-template:
"asset-header button-grid" min-content
"asset-grid asset-grid" min-content
"layer-header layer-header" min-content
"layer-grid layer-grid" auto
"layer-hide-header layer-hide-header" min-content
"layer-hide-grid layer-hide-grid" auto
/ auto min-content
;
}
#layering-button-grid {
top: 0;
position: sticky;
}
#layering-hide-header {
grid-area: layer-hide-header;
}
#layering-wce-hide-div {
box-sizing: border-box;
grid-area: layer-hide-grid;
width: 100%;
height: calc(100% - min(2vh, 1vw));
padding-left: min(2vh, 1vw);
padding-right: min(2vh, 1vw);
align-self: self-start;
}
`;
}
const head = document.head || document.getElementsByTagName("head")[0];
const style = document.createElement("style");
style.appendChild(document.createTextNode(css));
Expand Down
Loading