zois-core 1.0.4 → 1.0.6
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 +2 -19
- package/dist/messaging.d.ts +2 -2
- package/dist/messaging.js +4 -4
- package/dist/modsApi.js +0 -1
- package/dist/styles.css +19 -0
- package/dist/ui.d.ts +16 -3
- package/dist/ui.js +78 -22
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,19 +1,2 @@
|
|
|
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
|
|
1
|
+
## The core for the my mods, which contains a shared code reused in all my mods
|
|
2
|
+

|
package/dist/messaging.d.ts
CHANGED
|
@@ -2,10 +2,10 @@ interface RequestResponse<T> {
|
|
|
2
2
|
data?: T;
|
|
3
3
|
isError: boolean;
|
|
4
4
|
}
|
|
5
|
-
export declare function
|
|
5
|
+
export declare function chatSendLocalMessage(message: string | Node): void;
|
|
6
6
|
export declare function chatSendActionMessage(msg: string, target?: undefined | number, dictionary?: ChatMessageDictionaryEntry[]): void;
|
|
7
7
|
export declare function chatSendModMessage<T>(msg: string, _data?: T, targetNumber?: any): void;
|
|
8
|
-
export declare function
|
|
8
|
+
export declare function chatSendBeepMessage(data: any, targetId: number): void;
|
|
9
9
|
export declare function sendRequest<T>(message: string, data: any, target: number): Promise<RequestResponse<T>>;
|
|
10
10
|
export declare function handleRequestResponse(requestId: number, data: any): void;
|
|
11
11
|
export declare function handleRequest(requestId: number, message: string, _data: any, sender: Character): void;
|
package/dist/messaging.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { getRandomNumber, MOD_DATA } from "./index";
|
|
2
2
|
const pendingRequests = /* @__PURE__ */ new Map();
|
|
3
3
|
const requestListeners = /* @__PURE__ */ new Map();
|
|
4
|
-
function
|
|
4
|
+
function chatSendLocalMessage(message) {
|
|
5
5
|
if (!ServerPlayerIsInChatRoom()) return;
|
|
6
6
|
const div = document.createElement("div");
|
|
7
7
|
div.setAttribute("class", "ChatMessage ChatMessageLocalMessage");
|
|
@@ -46,7 +46,7 @@ function chatSendModMessage(msg, _data = null, targetNumber = null) {
|
|
|
46
46
|
if (targetNumber) data.Target = targetNumber;
|
|
47
47
|
ServerSend("ChatRoomChat", data);
|
|
48
48
|
}
|
|
49
|
-
function
|
|
49
|
+
function chatSendBeepMessage(data, targetId) {
|
|
50
50
|
const beep = {
|
|
51
51
|
IsSecret: true,
|
|
52
52
|
BeepType: "Leash",
|
|
@@ -106,8 +106,8 @@ function addRequestListener(message, listener) {
|
|
|
106
106
|
export {
|
|
107
107
|
addRequestListener,
|
|
108
108
|
chatSendActionMessage,
|
|
109
|
-
|
|
110
|
-
|
|
109
|
+
chatSendBeepMessage,
|
|
110
|
+
chatSendLocalMessage,
|
|
111
111
|
chatSendModMessage,
|
|
112
112
|
handleRequest,
|
|
113
113
|
handleRequestResponse,
|
package/dist/modsApi.js
CHANGED
|
@@ -29,7 +29,6 @@ function registerMod() {
|
|
|
29
29
|
if (message.Content === MOD_DATA.key && !sender.IsPlayer()) {
|
|
30
30
|
const msg = message.Dictionary.msg;
|
|
31
31
|
const data = message.Dictionary.data;
|
|
32
|
-
console.log("message.Dictionary.data", data);
|
|
33
32
|
if (msg === "request") {
|
|
34
33
|
if (typeof data.requestId !== "number" || typeof data.message !== "string") return;
|
|
35
34
|
handleRequest(data.requestId, data.message, data.data, sender);
|
package/dist/styles.css
CHANGED
|
@@ -74,6 +74,25 @@
|
|
|
74
74
|
border: 2px solid var(--tmd-accent, black);
|
|
75
75
|
border-radius: 4px;
|
|
76
76
|
}
|
|
77
|
+
.zcTabs {
|
|
78
|
+
display: flex;
|
|
79
|
+
}
|
|
80
|
+
.zcTabs button {
|
|
81
|
+
cursor: pointer;
|
|
82
|
+
width: 100%;
|
|
83
|
+
color: var(--tmd-text, black);
|
|
84
|
+
background: none;
|
|
85
|
+
border: none;
|
|
86
|
+
border-bottom: 2px solid var(--tmd-element, rgb(214, 214, 214));
|
|
87
|
+
}
|
|
88
|
+
.zcTabs button[data-opened=true] {
|
|
89
|
+
font-weight: bold;
|
|
90
|
+
border-bottom: 2px solid var(--tmd-accent, rgb(81, 81, 231)) !important;
|
|
91
|
+
}
|
|
92
|
+
.zcTabs button:hover {
|
|
93
|
+
background: var(--tmd-element, rgb(235, 235, 235));
|
|
94
|
+
border-bottom: 2px solid var(--tmd-element-hover, rgb(149, 149, 149));
|
|
95
|
+
}
|
|
77
96
|
.zcDisabled {
|
|
78
97
|
pointer-events: none;
|
|
79
98
|
opacity: 0.6;
|
package/dist/ui.d.ts
CHANGED
|
@@ -22,7 +22,7 @@ interface CreateButtonArgs {
|
|
|
22
22
|
}
|
|
23
23
|
interface CreateTextArgs {
|
|
24
24
|
text?: string;
|
|
25
|
-
color?:
|
|
25
|
+
color?: string;
|
|
26
26
|
x?: number;
|
|
27
27
|
y?: number;
|
|
28
28
|
fontSize?: number | "auto";
|
|
@@ -97,10 +97,22 @@ interface CreateBackNextButtonArgs {
|
|
|
97
97
|
height: number;
|
|
98
98
|
items: [string, any?][];
|
|
99
99
|
currentIndex: number;
|
|
100
|
+
isBold?: boolean;
|
|
100
101
|
anchor?: Anchor;
|
|
101
102
|
onChange?: (value: any) => void;
|
|
102
103
|
isDisabled?: () => boolean;
|
|
103
104
|
}
|
|
105
|
+
interface CreateTabArgs {
|
|
106
|
+
x: number;
|
|
107
|
+
y: number;
|
|
108
|
+
width: number;
|
|
109
|
+
tabs: {
|
|
110
|
+
name: string;
|
|
111
|
+
load: () => void;
|
|
112
|
+
}[];
|
|
113
|
+
currentTabName: string;
|
|
114
|
+
anchor?: Anchor;
|
|
115
|
+
}
|
|
104
116
|
export declare function setPreviousSubscreen(): void;
|
|
105
117
|
export declare function setSubscreen(subscreen: BaseSubscreen | null): void;
|
|
106
118
|
export declare function getCurrentSubscreen(): BaseSubscreen;
|
|
@@ -120,11 +132,12 @@ export declare abstract class BaseSubscreen {
|
|
|
120
132
|
createButton({ text, x, y, width, height, fontSize, anchor, padding, style, place, icon, iconAbsolutePosition, iconWidth, tooltip, onClick, isDisabled }: CreateButtonArgs): HTMLButtonElement;
|
|
121
133
|
createText({ text, color, x, y, width, height, withBackground, fontSize, anchor, padding, place }: CreateTextArgs): HTMLParagraphElement;
|
|
122
134
|
createInput({ value, placeholder, x, y, width, height, textArea, fontSize, anchor, padding, place, onChange, onInput, isDisabled }: CreateInputArgs): HTMLInputElement | HTMLTextAreaElement;
|
|
123
|
-
createCheckbox({ text, x, y, isChecked, width, anchor, place, isDisabled, onChange }: CreateCheckboxArgs):
|
|
135
|
+
createCheckbox({ text, x, y, isChecked, width, anchor, place, isDisabled, onChange }: CreateCheckboxArgs): HTMLDivElement;
|
|
124
136
|
createScrollView({ scroll, x, y, width, height, anchor }: CreateScrollViewArgs): HTMLDivElement;
|
|
125
137
|
createInputList({ x, y, width, height, title, value, anchor, place, numbersOnly, isDisabled, onChange }: CreateInputListArgs): HTMLDivElement;
|
|
126
138
|
createImage({ x, y, width, src, }: CreateImageArgs): HTMLImageElement;
|
|
127
|
-
createBackNextButton({ x, y, width, height, items, currentIndex, onChange, isDisabled }: CreateBackNextButtonArgs): HTMLDivElement;
|
|
139
|
+
createBackNextButton({ x, y, width, height, items, currentIndex, isBold, onChange, isDisabled }: CreateBackNextButtonArgs): HTMLDivElement;
|
|
140
|
+
createTabs({ x, y, width, tabs, anchor, currentTabName }: CreateTabArgs): HTMLDivElement;
|
|
128
141
|
}
|
|
129
142
|
export declare function hookSubscreen(subscreenName: string, hook: (subscreen: BaseSubscreen) => void): void;
|
|
130
143
|
export {};
|
package/dist/ui.js
CHANGED
|
@@ -65,6 +65,14 @@ function loadSubscreen(subscreen) {
|
|
|
65
65
|
height: 90,
|
|
66
66
|
icon: "Icons/Exit.png"
|
|
67
67
|
}).addEventListener("click", () => subscreen.exit());
|
|
68
|
+
if (subscreen.name) {
|
|
69
|
+
subscreen.createText({
|
|
70
|
+
text: subscreen.name,
|
|
71
|
+
x: 100,
|
|
72
|
+
y: 60,
|
|
73
|
+
fontSize: 10
|
|
74
|
+
});
|
|
75
|
+
}
|
|
68
76
|
subscreen.load();
|
|
69
77
|
if (subscreenHooks[subscreen.name]) {
|
|
70
78
|
subscreenHooks[subscreen.name].forEach((hook) => hook(subscreen));
|
|
@@ -210,7 +218,7 @@ class BaseSubscreen {
|
|
|
210
218
|
p.innerHTML = text;
|
|
211
219
|
p.style.color = color ?? "var(--tmd-text, black)";
|
|
212
220
|
if (withBackground) p.style.background = "var(--tmd-element,rgb(239, 239, 239))";
|
|
213
|
-
setFontFamily(p);
|
|
221
|
+
setFontFamily(p, MOD_DATA.fontFamily);
|
|
214
222
|
const setProperties = () => {
|
|
215
223
|
if (typeof x === "number" && typeof y === "number") setPosition(p, x, y, anchor);
|
|
216
224
|
setSize(p, width, height);
|
|
@@ -256,16 +264,12 @@ class BaseSubscreen {
|
|
|
256
264
|
setProperties();
|
|
257
265
|
if (typeof isDisabled === "function" && isDisabled()) input.classList.add("zcDisabled");
|
|
258
266
|
input.addEventListener("change", () => {
|
|
259
|
-
if (typeof isDisabled === "function" &&
|
|
260
|
-
|
|
261
|
-
}
|
|
262
|
-
if (typeof isDisabled === "function" && isDisabled()) input.classList.add("zcDisabled");
|
|
267
|
+
if (typeof isDisabled === "function" && isDisabled()) return input.classList.add("zcDisabled");
|
|
268
|
+
if (typeof onChange === "function") onChange();
|
|
263
269
|
});
|
|
264
270
|
input.addEventListener("input", () => {
|
|
265
|
-
if (typeof isDisabled === "function" &&
|
|
266
|
-
|
|
267
|
-
}
|
|
268
|
-
if (typeof isDisabled === "function" && isDisabled()) input.classList.add("zcDisabled");
|
|
271
|
+
if (typeof isDisabled === "function" && isDisabled()) return input.classList.add("zcDisabled");
|
|
272
|
+
if (typeof onInput === "function") onInput();
|
|
269
273
|
});
|
|
270
274
|
window.addEventListener("resize", setProperties);
|
|
271
275
|
if (place) document.body.append(input);
|
|
@@ -284,31 +288,33 @@ class BaseSubscreen {
|
|
|
284
288
|
isDisabled,
|
|
285
289
|
onChange
|
|
286
290
|
}) {
|
|
287
|
-
const checkbox = document.createElement("
|
|
288
|
-
checkbox.
|
|
289
|
-
checkbox.
|
|
290
|
-
checkbox.
|
|
291
|
+
const checkbox = document.createElement("div");
|
|
292
|
+
checkbox.style.display = "flex";
|
|
293
|
+
checkbox.style.alignItems = "center";
|
|
294
|
+
checkbox.style.columnGap = "1vw";
|
|
295
|
+
const input = document.createElement("input");
|
|
296
|
+
input.type = "checkbox";
|
|
297
|
+
input.checked = isChecked;
|
|
298
|
+
input.style.borderRadius = "min(0.8dvh, 0.3dvw)";
|
|
299
|
+
input.classList.add("zcCheckbox", "checkbox");
|
|
291
300
|
const p = document.createElement("p");
|
|
292
301
|
p.textContent = text;
|
|
293
302
|
p.style.color = "var(--tmd-text, black)";
|
|
294
|
-
setFontFamily(p);
|
|
303
|
+
setFontFamily(p, MOD_DATA.fontFamily);
|
|
295
304
|
const setProperties = () => {
|
|
296
305
|
if (typeof x === "number" && typeof y === "number") setPosition(checkbox, x, y, anchor);
|
|
297
|
-
|
|
298
|
-
setSize(checkbox, 65, 65);
|
|
299
|
-
if (width) setSize(p, width, null);
|
|
306
|
+
if (width) checkbox.style.width = getRelativeWidth(width) + "px";
|
|
300
307
|
setFontSize(p, 5);
|
|
301
308
|
};
|
|
302
309
|
setProperties();
|
|
303
310
|
if (typeof isDisabled === "function" && isDisabled()) checkbox.classList.add("zcDisabled");
|
|
304
311
|
checkbox.addEventListener("change", () => {
|
|
305
|
-
if (typeof isDisabled === "function" &&
|
|
306
|
-
|
|
307
|
-
}
|
|
308
|
-
if (typeof isDisabled === "function" && isDisabled()) checkbox.classList.add("zcDisabled");
|
|
312
|
+
if (typeof isDisabled === "function" && isDisabled()) return checkbox.classList.add("zcDisabled");
|
|
313
|
+
if (typeof onChange === "function") onChange();
|
|
309
314
|
});
|
|
310
315
|
window.addEventListener("resize", setProperties);
|
|
311
|
-
|
|
316
|
+
checkbox.append(input, p);
|
|
317
|
+
if (place) document.body.append(checkbox);
|
|
312
318
|
this.resizeEventListeners.push(setProperties);
|
|
313
319
|
this.htmlElements.push(checkbox, p);
|
|
314
320
|
return checkbox;
|
|
@@ -462,6 +468,7 @@ class BaseSubscreen {
|
|
|
462
468
|
height,
|
|
463
469
|
items,
|
|
464
470
|
currentIndex,
|
|
471
|
+
isBold = false,
|
|
465
472
|
onChange,
|
|
466
473
|
isDisabled
|
|
467
474
|
}) {
|
|
@@ -491,6 +498,7 @@ class BaseSubscreen {
|
|
|
491
498
|
if (typeof onChange === "function") onChange(items[currentIndex][1]);
|
|
492
499
|
});
|
|
493
500
|
const text = document.createElement("p");
|
|
501
|
+
if (isBold) text.style.fontWeight = "bold";
|
|
494
502
|
text.textContent = items[currentIndex][0];
|
|
495
503
|
div.append(backBtn, text, nextBtn);
|
|
496
504
|
const setProperties = () => {
|
|
@@ -506,6 +514,54 @@ class BaseSubscreen {
|
|
|
506
514
|
this.htmlElements.push(div);
|
|
507
515
|
return div;
|
|
508
516
|
}
|
|
517
|
+
createTabs({
|
|
518
|
+
x,
|
|
519
|
+
y,
|
|
520
|
+
width,
|
|
521
|
+
tabs,
|
|
522
|
+
anchor = "top-left",
|
|
523
|
+
currentTabName
|
|
524
|
+
}) {
|
|
525
|
+
let tabElements = [];
|
|
526
|
+
const tabsEl = document.createElement("div");
|
|
527
|
+
tabsEl.classList.add("zcTabs");
|
|
528
|
+
setFontFamily(tabsEl, MOD_DATA.fontFamily);
|
|
529
|
+
tabs.forEach((tab) => {
|
|
530
|
+
const switchTab = () => {
|
|
531
|
+
for (const c of tabsEl.children) {
|
|
532
|
+
c.removeAttribute("data-opened");
|
|
533
|
+
}
|
|
534
|
+
for (const c of tabElements) {
|
|
535
|
+
if (c instanceof Node) document.body.removeChild(c);
|
|
536
|
+
}
|
|
537
|
+
tabElements = [];
|
|
538
|
+
tabEl.setAttribute("data-opened", "true");
|
|
539
|
+
const originalAppend = document.body.append.bind(document.body);
|
|
540
|
+
document.body.append = (...nodes) => {
|
|
541
|
+
tabElements.push(...nodes);
|
|
542
|
+
originalAppend(...nodes);
|
|
543
|
+
};
|
|
544
|
+
tab.load();
|
|
545
|
+
document.body.append = originalAppend;
|
|
546
|
+
};
|
|
547
|
+
const tabEl = document.createElement("button");
|
|
548
|
+
tabEl.textContent = tab.name;
|
|
549
|
+
if (tab.name === currentTabName) switchTab();
|
|
550
|
+
tabEl.addEventListener("click", switchTab);
|
|
551
|
+
tabsEl.append(tabEl);
|
|
552
|
+
});
|
|
553
|
+
const setProperties = () => {
|
|
554
|
+
if (typeof x === "number" && typeof y === "number") setPosition(tabsEl, x, y, anchor);
|
|
555
|
+
setSize(tabsEl, width, 80);
|
|
556
|
+
autosetFontSize(tabsEl);
|
|
557
|
+
};
|
|
558
|
+
setProperties();
|
|
559
|
+
window.addEventListener("resize", setProperties);
|
|
560
|
+
document.body.append(tabsEl);
|
|
561
|
+
this.resizeEventListeners.push(setProperties);
|
|
562
|
+
this.htmlElements.push(tabsEl);
|
|
563
|
+
return tabsEl;
|
|
564
|
+
}
|
|
509
565
|
}
|
|
510
566
|
let subscreenHooks = {};
|
|
511
567
|
function hookSubscreen(subscreenName, hook) {
|