zois-core 1.0.2 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +19 -0
- package/dist/styles.css +4 -16
- package/dist/ui.d.ts +24 -11
- package/dist/ui.js +70 -29
- package/package.json +23 -2
package/README.md
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
⠀⠀⠀⠀⠀⢀⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣀⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
|
|
2
|
+
⠀⠀⠀⠀⠀⡟⠈⠛⢦⣄⠀⠀⠀⠀⠀⣀⡴⠚⠩⠘⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀
|
|
3
|
+
⠀⠀⠀⠀⠀⣧⠀⡀⠄⠈⠛⠛⠛⠛⢛⠁⠌⠀⠀⠀⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀
|
|
4
|
+
⠀⠀⠀⠀⠀⣿⠞⠁⠀⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣧⠀⠀⠀⠀⠀⠀⠀⠀⠀
|
|
5
|
+
⠀⠀⠀⠀⣼⠃⢠⠤⢤⠀⠀⠀⠀⢀⡤⢤⡀⠀⠀⠀⠘⣧⠀⠀⠀⠀⠀⠀⠀⠀
|
|
6
|
+
⠀⢀⣤⣤⣧⡄⠀⠀⠀⠀⣤⡀⠀⠀⠀⠀⠁⣤⣤⣤⣤⣼⣦⡄⠀⠀⠀⠀⠀⠀
|
|
7
|
+
⠀⢀⣠⡤⣷⠶⠀⠀⠀⠦⠜⠤⠄⠀⠀⠀⠰⠦⣤⣄⣀⣸⠃⠀⠀⠀⠀⠀⠀⠀
|
|
8
|
+
⠀⠀⠀⠀⠘⢧⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣀⣽⣋⠁⠀⠀⠀⠀⠀
|
|
9
|
+
⠀⠀⠀⠀⠀⠀⠈⠙⢳⡶⠶⠶⠶⠶⠶⠶⠖⠛⠛⠍⠀⠉⠛⣷⣤⡀⠀⠀⠀⠀
|
|
10
|
+
⠀⠀⠀⠀⠀⠀⠀⢠⡏⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠙⣦⡀⠀⠀
|
|
11
|
+
⠀⠀⠀⠀⠀⠀⠀⣾⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⢷⡀⠀
|
|
12
|
+
⠀⠀⠀⠀⠀⠀⠀⣏⠀⠀⠀⠀⢠⠆⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⡇⠀
|
|
13
|
+
⠀⠀⠀⠀⠀⠀⠀⢻⡀⠀⠀⠀⣿⠀⠀⠀⠀⢠⡾⠋⠁⠀⠀⠀⠀⠀⠀⢸⡇⠀
|
|
14
|
+
⠀⠀⠀⠀⠀⠀⠀⠈⢷⡀⠀⠀⣿⠀⠀⠀⠀⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⣼⠃⠀
|
|
15
|
+
⠀⠀⠀⠀⠀⠀⠀⠀⠈⢧⣀⣠⣼⣧⣀⣀⣰⣟⡀⠀⠀⠀⠀⠀⢀⣀⣼⢿⡀⠀
|
|
16
|
+
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⣟⠁⠀⠉⠉⠉⠉⠙⠛⠛⠛⠻⠿⠛⠛⠉⠁⣼⠁⠀
|
|
17
|
+
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠙⢦⣤⣤⣤⣤⣤⣤⣤⣤⣤⣤⣤⣤⣤⡴⠞⠁⠀⠀
|
|
18
|
+
|
|
19
|
+
## The core for the my mods, which contains a shared code reused in all my mods
|
package/dist/styles.css
CHANGED
|
@@ -17,21 +17,21 @@
|
|
|
17
17
|
border-color: var(--tmd-accent-hover, #7dd3fc);
|
|
18
18
|
color: var(--tmd-accent-hover, #015a8c);
|
|
19
19
|
}
|
|
20
|
-
.zcButton[data-
|
|
20
|
+
.zcButton[data-zc-style=green] {
|
|
21
21
|
background: rgb(124, 255, 124);
|
|
22
22
|
border-color: rgb(82, 204, 82);
|
|
23
23
|
color: black;
|
|
24
24
|
}
|
|
25
|
-
.zcButton[data-
|
|
25
|
+
.zcButton[data-zc-style=green]:hover {
|
|
26
26
|
background: rgb(94, 197, 94);
|
|
27
27
|
color: black;
|
|
28
28
|
}
|
|
29
|
-
.zcButton[data-
|
|
29
|
+
.zcButton[data-zc-style=inverted] {
|
|
30
30
|
background: var(--tmd-accent, #303030);
|
|
31
31
|
border: none;
|
|
32
32
|
color: var(--tmd-text, white);
|
|
33
33
|
}
|
|
34
|
-
.zcButton[data-
|
|
34
|
+
.zcButton[data-zc-style=inverted]:hover {
|
|
35
35
|
background: var(--tmd-accent-hover, #474747);
|
|
36
36
|
}
|
|
37
37
|
.zcInput {
|
|
@@ -56,18 +56,6 @@
|
|
|
56
56
|
border: 2px solid var(--tmd-accent, black);
|
|
57
57
|
border-radius: 4px;
|
|
58
58
|
}
|
|
59
|
-
.zcBackNextButton button {
|
|
60
|
-
cursor: pointer;
|
|
61
|
-
background: var(--tmd-element, rgb(240, 240, 240));
|
|
62
|
-
border-radius: 4px;
|
|
63
|
-
height: 140%;
|
|
64
|
-
aspect-ratio: 1/1;
|
|
65
|
-
border: 2px solid var(--tmd-accent, black);
|
|
66
|
-
font-size: 3.5vw;
|
|
67
|
-
}
|
|
68
|
-
.zcBackNextButton button:hover {
|
|
69
|
-
background: var(--tmd-element-hover, rgb(222, 222, 222));
|
|
70
|
-
}
|
|
71
59
|
.zcDisabled {
|
|
72
60
|
pointer-events: none;
|
|
73
61
|
opacity: 0.6;
|
package/dist/ui.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
type Anchor = "top-left" | "top-right" | "bottom-left" | "bottom-right";
|
|
1
2
|
interface CreateButtonArgs {
|
|
2
3
|
text?: string;
|
|
3
4
|
x?: number;
|
|
@@ -7,11 +8,13 @@ interface CreateButtonArgs {
|
|
|
7
8
|
height?: number;
|
|
8
9
|
padding?: number;
|
|
9
10
|
style?: "default" | "green" | "inverted";
|
|
10
|
-
anchor?:
|
|
11
|
+
anchor?: Anchor;
|
|
11
12
|
place?: boolean;
|
|
12
13
|
icon?: string;
|
|
13
14
|
iconAbsolutePosition?: boolean;
|
|
14
15
|
iconWidth?: string;
|
|
16
|
+
onClick?: () => void;
|
|
17
|
+
isDisabled?: () => boolean;
|
|
15
18
|
}
|
|
16
19
|
interface CreateTextArgs {
|
|
17
20
|
text?: string;
|
|
@@ -23,7 +26,7 @@ interface CreateTextArgs {
|
|
|
23
26
|
width?: number;
|
|
24
27
|
height?: number;
|
|
25
28
|
padding?: number;
|
|
26
|
-
anchor?:
|
|
29
|
+
anchor?: Anchor;
|
|
27
30
|
place?: boolean;
|
|
28
31
|
}
|
|
29
32
|
interface CreateInputArgs {
|
|
@@ -35,9 +38,12 @@ interface CreateInputArgs {
|
|
|
35
38
|
height?: number;
|
|
36
39
|
textArea?: boolean;
|
|
37
40
|
fontSize?: number | "auto";
|
|
38
|
-
anchor?:
|
|
41
|
+
anchor?: Anchor;
|
|
39
42
|
padding?: number;
|
|
40
43
|
place?: boolean;
|
|
44
|
+
onChange?: () => void;
|
|
45
|
+
onInput?: () => void;
|
|
46
|
+
isDisabled?: () => boolean;
|
|
41
47
|
}
|
|
42
48
|
interface CreateCheckboxArgs {
|
|
43
49
|
isChecked: boolean;
|
|
@@ -45,8 +51,10 @@ interface CreateCheckboxArgs {
|
|
|
45
51
|
y?: number;
|
|
46
52
|
width?: number;
|
|
47
53
|
text: string;
|
|
48
|
-
anchor?:
|
|
54
|
+
anchor?: Anchor;
|
|
49
55
|
place?: boolean;
|
|
56
|
+
onChange?: () => void;
|
|
57
|
+
isDisabled?: () => boolean;
|
|
50
58
|
}
|
|
51
59
|
interface CreateScrollViewArgs {
|
|
52
60
|
scroll: "x" | "y" | "all";
|
|
@@ -54,7 +62,7 @@ interface CreateScrollViewArgs {
|
|
|
54
62
|
y: number;
|
|
55
63
|
width: number;
|
|
56
64
|
height?: number;
|
|
57
|
-
anchor?:
|
|
65
|
+
anchor?: Anchor;
|
|
58
66
|
}
|
|
59
67
|
interface CreateInputListArgs {
|
|
60
68
|
value?: string[] | number[];
|
|
@@ -64,16 +72,19 @@ interface CreateInputListArgs {
|
|
|
64
72
|
width: number;
|
|
65
73
|
height?: number;
|
|
66
74
|
fontSize?: number | "auto";
|
|
67
|
-
anchor?:
|
|
75
|
+
anchor?: Anchor;
|
|
68
76
|
padding?: number;
|
|
69
77
|
place?: boolean;
|
|
70
78
|
numbersOnly?: boolean;
|
|
79
|
+
onChange?: (value: string[] | number[]) => void;
|
|
80
|
+
isDisabled?: () => boolean;
|
|
71
81
|
}
|
|
72
82
|
interface CreateImageArgs {
|
|
73
83
|
src: string;
|
|
74
84
|
x: number;
|
|
75
85
|
y: number;
|
|
76
86
|
width: number;
|
|
87
|
+
anchor?: Anchor;
|
|
77
88
|
}
|
|
78
89
|
interface CreateBackNextButtonArgs {
|
|
79
90
|
x: number;
|
|
@@ -82,7 +93,9 @@ interface CreateBackNextButtonArgs {
|
|
|
82
93
|
height: number;
|
|
83
94
|
items: [string, any?][];
|
|
84
95
|
currentIndex: number;
|
|
96
|
+
anchor?: Anchor;
|
|
85
97
|
onChange?: (value: any) => void;
|
|
98
|
+
isDisabled?: () => boolean;
|
|
86
99
|
}
|
|
87
100
|
export declare function setPreviousSubscreen(): void;
|
|
88
101
|
export declare function setSubscreen(subscreen: BaseSubscreen | null): void;
|
|
@@ -100,14 +113,14 @@ export declare abstract class BaseSubscreen {
|
|
|
100
113
|
update?(): void;
|
|
101
114
|
setPreviousSubscreen(): void;
|
|
102
115
|
setSubscreen(subscreen: BaseSubscreen | null): void;
|
|
103
|
-
createButton({ text, x, y, width, height, fontSize, anchor, padding, style, place, icon, iconAbsolutePosition, iconWidth }: CreateButtonArgs): HTMLButtonElement;
|
|
116
|
+
createButton({ text, x, y, width, height, fontSize, anchor, padding, style, place, icon, iconAbsolutePosition, iconWidth, onClick, isDisabled }: CreateButtonArgs): HTMLButtonElement;
|
|
104
117
|
createText({ text, color, x, y, width, height, withBackground, fontSize, anchor, padding, place }: CreateTextArgs): HTMLParagraphElement;
|
|
105
|
-
createInput({ value, placeholder, x, y, width, height, textArea, fontSize, anchor, padding, place }: CreateInputArgs): HTMLInputElement | HTMLTextAreaElement;
|
|
106
|
-
createCheckbox({ text, x, y, isChecked, width, anchor, place }: CreateCheckboxArgs): HTMLInputElement;
|
|
118
|
+
createInput({ value, placeholder, x, y, width, height, textArea, fontSize, anchor, padding, place, onChange, onInput, isDisabled }: CreateInputArgs): HTMLInputElement | HTMLTextAreaElement;
|
|
119
|
+
createCheckbox({ text, x, y, isChecked, width, anchor, place, isDisabled, onChange }: CreateCheckboxArgs): HTMLInputElement;
|
|
107
120
|
createScrollView({ scroll, x, y, width, height, anchor }: CreateScrollViewArgs): HTMLDivElement;
|
|
108
|
-
createInputList({ x, y, width, height, title, value, anchor, place, numbersOnly, }: CreateInputListArgs):
|
|
121
|
+
createInputList({ x, y, width, height, title, value, anchor, place, numbersOnly, isDisabled, onChange }: CreateInputListArgs): HTMLDivElement;
|
|
109
122
|
createImage({ x, y, width, src, }: CreateImageArgs): HTMLImageElement;
|
|
110
|
-
createBackNextButton({ x, y, width, height, items, currentIndex, onChange }: CreateBackNextButtonArgs): HTMLDivElement;
|
|
123
|
+
createBackNextButton({ x, y, width, height, items, currentIndex, onChange, isDisabled }: CreateBackNextButtonArgs): HTMLDivElement;
|
|
111
124
|
}
|
|
112
125
|
export declare function hookSubscreen(subscreenName: string, hook: (subscreen: BaseSubscreen) => void): void;
|
|
113
126
|
export {};
|
package/dist/ui.js
CHANGED
|
@@ -6,15 +6,15 @@ function getRelativeWidth(width) {
|
|
|
6
6
|
}
|
|
7
7
|
function getRelativeY(yPos, anchorPosition = "top") {
|
|
8
8
|
const scaleY = MainCanvas.canvas.clientHeight / 1e3;
|
|
9
|
-
return anchorPosition === "top" ? MainCanvas.canvas.offsetTop + yPos * scaleY : MainCanvas.canvas.offsetTop + MainCanvas.canvas.clientHeight
|
|
9
|
+
return anchorPosition === "top" ? MainCanvas.canvas.offsetTop + yPos * scaleY : window.innerHeight - (MainCanvas.canvas.offsetTop + MainCanvas.canvas.clientHeight) + yPos * scaleY;
|
|
10
10
|
}
|
|
11
11
|
function getRelativeX(xPos, anchorPosition = "left") {
|
|
12
12
|
const scaleX = MainCanvas.canvas.clientWidth / 2e3;
|
|
13
|
-
return anchorPosition === "left" ? MainCanvas.canvas.offsetLeft + xPos * scaleX : MainCanvas.canvas.offsetLeft + MainCanvas.canvas.clientWidth
|
|
13
|
+
return anchorPosition === "left" ? MainCanvas.canvas.offsetLeft + xPos * scaleX : window.innerWidth - (MainCanvas.canvas.offsetLeft + MainCanvas.canvas.clientWidth) + xPos * scaleX;
|
|
14
14
|
}
|
|
15
|
-
function setPosition(element, xPos, yPos,
|
|
16
|
-
const yAnchor =
|
|
17
|
-
const xAnchor =
|
|
15
|
+
function setPosition(element, xPos, yPos, anchor = "top-left") {
|
|
16
|
+
const yAnchor = anchor === "top-left" || anchor === "top-right" ? "top" : "bottom";
|
|
17
|
+
const xAnchor = anchor === "top-left" || anchor === "bottom-left" ? "left" : "right";
|
|
18
18
|
const y = getRelativeY(yPos, yAnchor);
|
|
19
19
|
const x = getRelativeX(xPos, xAnchor);
|
|
20
20
|
Object.assign(element.style, {
|
|
@@ -24,11 +24,9 @@ function setPosition(element, xPos, yPos, anchorPosition = "top-left") {
|
|
|
24
24
|
});
|
|
25
25
|
}
|
|
26
26
|
function setSize(element, width, height) {
|
|
27
|
-
const w = getRelativeWidth(width);
|
|
28
|
-
const h = getRelativeHeight(height);
|
|
29
27
|
Object.assign(element.style, {
|
|
30
|
-
|
|
31
|
-
|
|
28
|
+
width: getRelativeWidth(width) + "px",
|
|
29
|
+
height: getRelativeHeight(height) + "px"
|
|
32
30
|
});
|
|
33
31
|
}
|
|
34
32
|
function setFontSize(element, targetFontSize) {
|
|
@@ -63,7 +61,6 @@ function loadSubscreen(subscreen) {
|
|
|
63
61
|
height: 90,
|
|
64
62
|
icon: "Icons/Exit.png"
|
|
65
63
|
}).addEventListener("click", () => subscreen.exit());
|
|
66
|
-
CommonSetScreen("Character", "InformationSheet");
|
|
67
64
|
subscreen.load();
|
|
68
65
|
if (subscreenHooks[subscreen.name]) {
|
|
69
66
|
subscreenHooks[subscreen.name].forEach((hook) => hook(subscreen));
|
|
@@ -130,7 +127,9 @@ class BaseSubscreen {
|
|
|
130
127
|
place = true,
|
|
131
128
|
icon,
|
|
132
129
|
iconAbsolutePosition = true,
|
|
133
|
-
iconWidth
|
|
130
|
+
iconWidth,
|
|
131
|
+
onClick,
|
|
132
|
+
isDisabled
|
|
134
133
|
}) {
|
|
135
134
|
const btn = document.createElement("button");
|
|
136
135
|
btn.classList.add("zcButton");
|
|
@@ -161,13 +160,20 @@ class BaseSubscreen {
|
|
|
161
160
|
btn.append(span);
|
|
162
161
|
}
|
|
163
162
|
const setProperties = () => {
|
|
164
|
-
if (x && y) setPosition(btn, x, y, anchor);
|
|
163
|
+
if (typeof x === "number" && typeof y === "number") setPosition(btn, x, y, anchor);
|
|
165
164
|
setSize(btn, width, height);
|
|
166
165
|
if (padding) setPadding(btn, padding);
|
|
167
166
|
if (fontSize === "auto") autosetFontSize(btn);
|
|
168
167
|
else setFontSize(btn, fontSize);
|
|
169
168
|
};
|
|
170
169
|
setProperties();
|
|
170
|
+
if (typeof isDisabled === "function" && isDisabled()) btn.classList.add("zcDisabled");
|
|
171
|
+
btn.addEventListener("click", () => {
|
|
172
|
+
if (typeof isDisabled === "function" && !isDisabled() && typeof onClick === "function") {
|
|
173
|
+
onClick();
|
|
174
|
+
}
|
|
175
|
+
if (isDisabled() && !btn.classList.contains("zcDisabled")) btn.classList.add("zcDisabled");
|
|
176
|
+
});
|
|
171
177
|
window.addEventListener("resize", setProperties);
|
|
172
178
|
if (place) document.body.append(btn);
|
|
173
179
|
this.resizeEventListeners.push(setProperties);
|
|
@@ -193,7 +199,7 @@ class BaseSubscreen {
|
|
|
193
199
|
if (withBackground) p.style.background = "var(--tmd-element,rgb(239, 239, 239))";
|
|
194
200
|
p.style.fontFamily = "Emilys Candy";
|
|
195
201
|
const setProperties = () => {
|
|
196
|
-
if (x && y) setPosition(p, x, y, anchor);
|
|
202
|
+
if (typeof x === "number" && typeof y === "number") setPosition(p, x, y, anchor);
|
|
197
203
|
setSize(p, width, height);
|
|
198
204
|
if (padding) setPadding(p, padding);
|
|
199
205
|
if (fontSize === "auto") autosetFontSize(p);
|
|
@@ -217,20 +223,36 @@ class BaseSubscreen {
|
|
|
217
223
|
fontSize = "auto",
|
|
218
224
|
anchor = "top-left",
|
|
219
225
|
padding,
|
|
220
|
-
place = true
|
|
226
|
+
place = true,
|
|
227
|
+
onChange,
|
|
228
|
+
onInput,
|
|
229
|
+
isDisabled
|
|
221
230
|
}) {
|
|
222
231
|
const input = document.createElement(textArea ? "textarea" : "input");
|
|
223
232
|
input.classList.add("zcInput");
|
|
224
233
|
if (placeholder) input.placeholder = placeholder;
|
|
225
234
|
if (value) input.value = value;
|
|
226
235
|
const setProperties = () => {
|
|
227
|
-
if (x && y) setPosition(input, x, y, anchor);
|
|
236
|
+
if (typeof x === "number" && typeof y === "number") setPosition(input, x, y, anchor);
|
|
228
237
|
setSize(input, width, height);
|
|
229
238
|
if (padding) setPadding(input, padding);
|
|
230
239
|
if (fontSize === "auto") autosetFontSize(input);
|
|
231
240
|
else setFontSize(input, fontSize);
|
|
232
241
|
};
|
|
233
242
|
setProperties();
|
|
243
|
+
if (typeof isDisabled === "function" && isDisabled()) input.classList.add("zcDisabled");
|
|
244
|
+
input.addEventListener("change", () => {
|
|
245
|
+
if (typeof isDisabled === "function" && !isDisabled() && typeof onChange === "function") {
|
|
246
|
+
onChange();
|
|
247
|
+
}
|
|
248
|
+
if (isDisabled() && !input.classList.contains("zcDisabled")) input.classList.add("zcDisabled");
|
|
249
|
+
});
|
|
250
|
+
input.addEventListener("input", () => {
|
|
251
|
+
if (typeof isDisabled === "function" && !isDisabled() && typeof onInput === "function") {
|
|
252
|
+
onInput();
|
|
253
|
+
}
|
|
254
|
+
if (isDisabled() && !input.classList.contains("zcDisabled")) input.classList.add("zcDisabled");
|
|
255
|
+
});
|
|
234
256
|
window.addEventListener("resize", setProperties);
|
|
235
257
|
if (place) document.body.append(input);
|
|
236
258
|
this.resizeEventListeners.push(setProperties);
|
|
@@ -244,7 +266,9 @@ class BaseSubscreen {
|
|
|
244
266
|
isChecked,
|
|
245
267
|
width,
|
|
246
268
|
anchor = "top-left",
|
|
247
|
-
place = true
|
|
269
|
+
place = true,
|
|
270
|
+
isDisabled,
|
|
271
|
+
onChange
|
|
248
272
|
}) {
|
|
249
273
|
const checkbox = document.createElement("input");
|
|
250
274
|
checkbox.type = "checkbox";
|
|
@@ -255,13 +279,20 @@ class BaseSubscreen {
|
|
|
255
279
|
p.style.color = "var(--tmd-text, black)";
|
|
256
280
|
p.style.fontFamily = "Emilys Candy";
|
|
257
281
|
const setProperties = () => {
|
|
258
|
-
if (x && y) setPosition(checkbox, x, y, anchor);
|
|
282
|
+
if (typeof x === "number" && typeof y === "number") setPosition(checkbox, x, y, anchor);
|
|
259
283
|
setPosition(p, x + 100, y, anchor);
|
|
260
284
|
setSize(checkbox, 65, 65);
|
|
261
285
|
if (width) setSize(p, width, null);
|
|
262
286
|
setFontSize(p, 5);
|
|
263
287
|
};
|
|
264
288
|
setProperties();
|
|
289
|
+
if (typeof isDisabled === "function" && isDisabled()) checkbox.classList.add("zcDisabled");
|
|
290
|
+
checkbox.addEventListener("change", () => {
|
|
291
|
+
if (typeof isDisabled === "function" && !isDisabled() && typeof onChange === "function") {
|
|
292
|
+
onChange();
|
|
293
|
+
}
|
|
294
|
+
if (isDisabled() && !checkbox.classList.contains("zcDisabled")) checkbox.classList.add("zcDisabled");
|
|
295
|
+
});
|
|
265
296
|
window.addEventListener("resize", setProperties);
|
|
266
297
|
if (place) document.body.append(checkbox, p);
|
|
267
298
|
this.resizeEventListeners.push(setProperties);
|
|
@@ -281,7 +312,7 @@ class BaseSubscreen {
|
|
|
281
312
|
if (scroll === "x") div.style.overflowX = "scroll";
|
|
282
313
|
if (scroll === "y") div.style.overflowY = "scroll";
|
|
283
314
|
const setProperties = () => {
|
|
284
|
-
if (x && y) setPosition(div, x, y, anchor);
|
|
315
|
+
if (typeof x === "number" && typeof y === "number") setPosition(div, x, y, anchor);
|
|
285
316
|
setSize(div, width, height);
|
|
286
317
|
};
|
|
287
318
|
setProperties();
|
|
@@ -300,7 +331,9 @@ class BaseSubscreen {
|
|
|
300
331
|
value,
|
|
301
332
|
anchor = "top-left",
|
|
302
333
|
place = true,
|
|
303
|
-
numbersOnly = false
|
|
334
|
+
numbersOnly = false,
|
|
335
|
+
isDisabled,
|
|
336
|
+
onChange
|
|
304
337
|
}) {
|
|
305
338
|
const items = [];
|
|
306
339
|
const div = document.createElement("div");
|
|
@@ -328,6 +361,7 @@ class BaseSubscreen {
|
|
|
328
361
|
b.addEventListener("click", onClick);
|
|
329
362
|
};
|
|
330
363
|
const addItem = (text) => {
|
|
364
|
+
if (isDisabled() && !input.classList.contains("zcDisabled")) return input.classList.add("zcDisabled");
|
|
331
365
|
const item = document.createElement("div");
|
|
332
366
|
item.style.cssText = "cursor: pointer; background: var(--tmd-element-hover, rgb(206, 206, 206)); color: var(--tmd-text, black); height: fit-content; padding: 0.8vw; border-radius: 0.8vw; font-size: clamp(8px, 2vw, 20px);";
|
|
333
367
|
item.textContent = text;
|
|
@@ -338,18 +372,21 @@ class BaseSubscreen {
|
|
|
338
372
|
e.stopPropagation();
|
|
339
373
|
});
|
|
340
374
|
items.push(text);
|
|
375
|
+
onChange(numbersOnly ? items.map((i) => parseInt(i)) : items);
|
|
341
376
|
};
|
|
342
377
|
const setProperties = () => {
|
|
343
|
-
if (x && y) setPosition(div, x, y, anchor);
|
|
378
|
+
if (typeof x === "number" && typeof y === "number") setPosition(div, x, y, anchor);
|
|
344
379
|
setSize(div, width, height);
|
|
345
380
|
};
|
|
346
381
|
addButton("Icons/Cancel.png", () => {
|
|
382
|
+
if (isDisabled() && !input.classList.contains("zcDisabled")) return input.classList.add("zcDisabled");
|
|
347
383
|
itemsElement.innerHTML = "";
|
|
348
384
|
items.splice(0, items.length);
|
|
349
385
|
itemsElement.append(input);
|
|
350
386
|
value.forEach((v) => addItem(String(v)));
|
|
351
387
|
});
|
|
352
388
|
addButton("Icons/Trash.png", () => {
|
|
389
|
+
if (isDisabled() && !input.classList.contains("zcDisabled")) return input.classList.add("zcDisabled");
|
|
353
390
|
for (const c of [...itemsElement.children]) {
|
|
354
391
|
if (c.getAttribute("style").includes("border: 2px solid red;")) {
|
|
355
392
|
items.splice(items.indexOf(c.textContent), 1);
|
|
@@ -358,6 +395,7 @@ class BaseSubscreen {
|
|
|
358
395
|
}
|
|
359
396
|
});
|
|
360
397
|
setProperties();
|
|
398
|
+
if (typeof isDisabled === "function" && isDisabled()) div.classList.add("zcDisabled");
|
|
361
399
|
window.addEventListener("resize", setProperties);
|
|
362
400
|
input.addEventListener("keypress", (e) => {
|
|
363
401
|
if (document.activeElement === input) {
|
|
@@ -380,10 +418,7 @@ class BaseSubscreen {
|
|
|
380
418
|
this.resizeEventListeners.push(setProperties);
|
|
381
419
|
this.htmlElements.push(div);
|
|
382
420
|
value.forEach((v) => addItem(String(v)));
|
|
383
|
-
return
|
|
384
|
-
div,
|
|
385
|
-
() => numbersOnly ? items.map((i) => parseInt(i)) : items
|
|
386
|
-
];
|
|
421
|
+
return div;
|
|
387
422
|
}
|
|
388
423
|
createImage({
|
|
389
424
|
x,
|
|
@@ -394,7 +429,7 @@ class BaseSubscreen {
|
|
|
394
429
|
const img = document.createElement("img");
|
|
395
430
|
img.src = src;
|
|
396
431
|
const setProperties = () => {
|
|
397
|
-
if (x && y) setPosition(img, x, y);
|
|
432
|
+
if (typeof x === "number" && typeof y === "number") setPosition(img, x, y);
|
|
398
433
|
setSize(img, width, 0);
|
|
399
434
|
img.style.height = "auto";
|
|
400
435
|
};
|
|
@@ -412,23 +447,28 @@ class BaseSubscreen {
|
|
|
412
447
|
height,
|
|
413
448
|
items,
|
|
414
449
|
currentIndex,
|
|
415
|
-
onChange
|
|
450
|
+
onChange,
|
|
451
|
+
isDisabled
|
|
416
452
|
}) {
|
|
417
453
|
const div = document.createElement("div");
|
|
418
454
|
div.classList.add("zcBackNextButton");
|
|
419
455
|
const backBtn = document.createElement("button");
|
|
420
|
-
backBtn.style.cssText = "position: absolute; left: 1vw;";
|
|
456
|
+
backBtn.style.cssText = "position: absolute; left: 1vw; font-size: 3.5vw; aspect-ratio: 1/1; height: 140%;";
|
|
457
|
+
backBtn.classList.add("zcButton");
|
|
421
458
|
backBtn.textContent = "\u{1F844}";
|
|
422
459
|
backBtn.addEventListener("click", () => {
|
|
460
|
+
if (typeof isDisabled === "function" && isDisabled()) return div.classList.add("zcDisabled");
|
|
423
461
|
if (currentIndex === 0) return;
|
|
424
462
|
currentIndex--;
|
|
425
463
|
text.textContent = items[currentIndex][0];
|
|
426
464
|
if (typeof onChange === "function") onChange(items[currentIndex][1]);
|
|
427
465
|
});
|
|
428
466
|
const nextBtn = document.createElement("button");
|
|
429
|
-
nextBtn.style.cssText = "position: absolute; right: 1vw;";
|
|
467
|
+
nextBtn.style.cssText = "position: absolute; right: 1vw; font-size: 3.5vw; aspect-ratio: 1/1; height: 140%;";
|
|
468
|
+
nextBtn.classList.add("zcButton");
|
|
430
469
|
nextBtn.textContent = "\u{1F846}";
|
|
431
470
|
nextBtn.addEventListener("click", () => {
|
|
471
|
+
if (typeof isDisabled === "function" && isDisabled()) return div.classList.add("zcDisabled");
|
|
432
472
|
if (currentIndex === items.length - 1) return;
|
|
433
473
|
currentIndex++;
|
|
434
474
|
text.textContent = items[currentIndex][0];
|
|
@@ -438,11 +478,12 @@ class BaseSubscreen {
|
|
|
438
478
|
text.textContent = items[currentIndex][0];
|
|
439
479
|
div.append(backBtn, text, nextBtn);
|
|
440
480
|
const setProperties = () => {
|
|
441
|
-
if (x && y) setPosition(div, x, y);
|
|
481
|
+
if (typeof x === "number" && typeof y === "number") setPosition(div, x, y);
|
|
442
482
|
setSize(div, width, height);
|
|
443
483
|
autosetFontSize(text);
|
|
444
484
|
};
|
|
445
485
|
setProperties();
|
|
486
|
+
if (typeof isDisabled === "function" && isDisabled()) div.classList.add("zcDisabled");
|
|
446
487
|
window.addEventListener("resize", setProperties);
|
|
447
488
|
document.body.append(div);
|
|
448
489
|
this.resizeEventListeners.push(setProperties);
|
package/package.json
CHANGED
|
@@ -1,13 +1,34 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "zois-core",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"description": "The core for the my mods, which contains a shared code reused in all my mods",
|
|
5
5
|
"author": "Zoi",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"files": [
|
|
8
8
|
"dist"
|
|
9
9
|
],
|
|
10
|
-
"
|
|
10
|
+
"exports": {
|
|
11
|
+
".": {
|
|
12
|
+
"import": "./dist/index.js",
|
|
13
|
+
"types": "./dist/index.d.ts"
|
|
14
|
+
},
|
|
15
|
+
"./messaging": {
|
|
16
|
+
"import": "./dist/messaging.js",
|
|
17
|
+
"types": "./dist/messaging.d.ts"
|
|
18
|
+
},
|
|
19
|
+
"./modsApi": {
|
|
20
|
+
"import": "./dist/modsApi.js",
|
|
21
|
+
"types": "./dist/modsApi.d.ts"
|
|
22
|
+
},
|
|
23
|
+
"./ui": {
|
|
24
|
+
"import": "./dist/ui.js",
|
|
25
|
+
"types": "./dist/ui.d.ts"
|
|
26
|
+
},
|
|
27
|
+
"./wardrobe": {
|
|
28
|
+
"import": "./dist/wardrobe.js",
|
|
29
|
+
"types": "./dist/wardrobe.d.ts"
|
|
30
|
+
}
|
|
31
|
+
},
|
|
11
32
|
"dependencies": {
|
|
12
33
|
"bondage-club-mod-sdk": "^1.2.0"
|
|
13
34
|
},
|