zois-core 1.0.2

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Zoi
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,20 @@
1
+ interface ModData {
2
+ name: string;
3
+ fullName: string;
4
+ key: string;
5
+ version: string;
6
+ repository?: string;
7
+ chatMessageBackground?: string;
8
+ chatMessageColor?: string;
9
+ }
10
+ export declare let MOD_DATA: ModData;
11
+ export declare function registerCore(modData: ModData): void;
12
+ export declare function sleep(ms: number): Promise<() => {}>;
13
+ export declare function waitFor(func: () => boolean, cancelFunc?: () => boolean): Promise<boolean>;
14
+ export declare function getRandomNumber(min: number, max: number): number;
15
+ export declare function isVersionNewer(version1: string, version2: string): boolean;
16
+ export declare function colorsEqual(c1: string[] | string | null | undefined, c2: string[] | string | null | undefined): boolean;
17
+ export declare function getSizeInKbytes(b: any): number;
18
+ export declare function getPlayer(value: string | number): Character;
19
+ export declare function getNickname(target: Character): string;
20
+ export {};
package/dist/index.js ADDED
@@ -0,0 +1,79 @@
1
+ import styles from "./styles.css";
2
+ import { registerMod } from "./modsApi";
3
+ let MOD_DATA;
4
+ function registerCore(modData) {
5
+ if (!window.ZOISCORE_STYLES_LOADED) {
6
+ const style = document.createElement("style");
7
+ style.innerHTML = styles;
8
+ document.head.append(style);
9
+ window.ZOISCORE_STYLES_LOADED = true;
10
+ }
11
+ MOD_DATA = { ...modData };
12
+ registerMod();
13
+ }
14
+ function sleep(ms) {
15
+ return new Promise((resolve) => setTimeout(resolve, ms));
16
+ }
17
+ async function waitFor(func, cancelFunc = () => false) {
18
+ while (!func()) {
19
+ if (cancelFunc()) {
20
+ return false;
21
+ }
22
+ await sleep(10);
23
+ }
24
+ return true;
25
+ }
26
+ function getRandomNumber(min, max) {
27
+ min = Math.ceil(min);
28
+ max = Math.floor(max);
29
+ return Math.floor(Math.random() * (max - min + 1)) + min;
30
+ }
31
+ function isVersionNewer(version1, version2) {
32
+ const v1Parts = version1.split(".");
33
+ const v2Parts = version2.split(".");
34
+ for (let i = 0; i < Math.max(v1Parts.length, v2Parts.length); i++) {
35
+ const v1Part = parseInt(v1Parts[i] || "0", 10);
36
+ const v2Part = parseInt(v2Parts[i] || "0", 10);
37
+ if (v1Part > v2Part) {
38
+ return true;
39
+ } else if (v1Part < v2Part) {
40
+ return false;
41
+ }
42
+ }
43
+ return false;
44
+ }
45
+ function colorsEqual(c1, c2) {
46
+ if (!c1 && !c2) return true;
47
+ if (!c1 && c2 === "Default" || !c2 && c1 === "Default") return true;
48
+ if (c1 === "Default" && Array.isArray(c2) && c2.filter((d) => d === "Default").length === c2.length) return true;
49
+ if (c2 === "Default" && Array.isArray(c1) && c1.filter((d) => d === "Default").length === c1.length) return true;
50
+ return JSON.stringify(c1) === JSON.stringify(c2);
51
+ }
52
+ function getSizeInKbytes(b) {
53
+ if (typeof b === "string") {
54
+ return Math.round(new TextEncoder().encode(b).byteLength / 100) / 10;
55
+ } else {
56
+ return Math.round(new TextEncoder().encode(JSON.stringify(b)).byteLength / 100) / 10;
57
+ }
58
+ }
59
+ function getPlayer(value) {
60
+ if (!value) return;
61
+ return ChatRoomCharacter.find((Character) => {
62
+ return Character.MemberNumber == value || Character.Name.toLowerCase() === value || Character.Nickname?.toLowerCase() === value;
63
+ });
64
+ }
65
+ function getNickname(target) {
66
+ return CharacterNickname(target);
67
+ }
68
+ export {
69
+ MOD_DATA,
70
+ colorsEqual,
71
+ getNickname,
72
+ getPlayer,
73
+ getRandomNumber,
74
+ getSizeInKbytes,
75
+ isVersionNewer,
76
+ registerCore,
77
+ sleep,
78
+ waitFor
79
+ };
@@ -0,0 +1,5 @@
1
+ export declare function chatSendLocal(message: string | Node): void;
2
+ export declare function chatSendActionMessage(msg: string, target?: undefined | number, dictionary?: ChatMessageDictionaryEntry[]): void;
3
+ export declare function chatSendModMessage<T>(msg: string, _data?: T, targetNumber?: any): void;
4
+ export declare function chatSendBeep(data: any, targetId: number): void;
5
+ export declare function handleRequestResponse(requestId: number, data: any): void;
@@ -0,0 +1,73 @@
1
+ import { MOD_DATA } from "./index";
2
+ const pendingRequests = /* @__PURE__ */ new Map();
3
+ function chatSendLocal(message) {
4
+ if (!ServerPlayerIsInChatRoom()) return;
5
+ const div = document.createElement("div");
6
+ div.setAttribute("class", "ChatMessage ChatMessageLocalMessage");
7
+ div.setAttribute("data-time", ChatRoomCurrentTime());
8
+ div.setAttribute("data-sender", `${Player.MemberNumber}`);
9
+ div.style.background = MOD_DATA.chatMessageBackground ?? "#55edc095";
10
+ div.style.color = MOD_DATA.chatMessageColor ?? "black";
11
+ div.style.margin = "0.15em 0";
12
+ if (typeof message === "string") div.textContent = message;
13
+ else div.appendChild(message);
14
+ document.querySelector("#TextAreaChatLog").appendChild(div);
15
+ ElementScrollToEnd("TextAreaChatLog");
16
+ }
17
+ function chatSendActionMessage(msg, target = void 0, dictionary = []) {
18
+ if (!msg || !ServerPlayerIsInChatRoom()) return;
19
+ const isFemale = CharacterPronounDescription(Player) === "She/Her";
20
+ const capPossessive = isFemale ? "Her" : "His";
21
+ const capIntensive = isFemale ? "Her" : "Him";
22
+ const capSelfIntensive = isFemale ? "Herself" : "Himself";
23
+ const capPronoun = isFemale ? "She" : "He";
24
+ msg = msg.replaceAll("<Possessive>", capPossessive).replaceAll("<possessive>", capPossessive.toLocaleLowerCase()).replaceAll("<Intensive>", capIntensive).replaceAll("<intensive>", capIntensive.toLocaleLowerCase()).replaceAll("<SelfIntensive>", capSelfIntensive).replaceAll("<selfIntensive>", capSelfIntensive.toLocaleLowerCase()).replaceAll("<Pronoun>", capPronoun).replaceAll("<pronoun>", capPronoun.toLocaleLowerCase());
25
+ ServerSend("ChatRoomChat", {
26
+ Content: "LittlishClub_CUSTOM_ACTION",
27
+ Type: "Action",
28
+ Target: target ?? void 0,
29
+ Dictionary: [
30
+ { Tag: 'MISSING TEXT IN "Interface.csv": LittlishClub_CUSTOM_ACTION', Text: msg },
31
+ ...dictionary
32
+ ]
33
+ });
34
+ }
35
+ function chatSendModMessage(msg, _data = null, targetNumber = null) {
36
+ const data = {
37
+ Content: MOD_DATA.key,
38
+ Dictionary: {
39
+ // @ts-ignore
40
+ msg
41
+ },
42
+ Type: "Hidden"
43
+ };
44
+ if (_data) data.Dictionary.data = _data;
45
+ if (targetNumber) data.Target = targetNumber;
46
+ ServerSend("ChatRoomChat", data);
47
+ }
48
+ function chatSendBeep(data, targetId) {
49
+ const beep = {
50
+ IsSecret: true,
51
+ BeepType: "Leash",
52
+ MemberNumber: targetId,
53
+ Message: JSON.stringify({
54
+ type: MOD_DATA.key,
55
+ ...data
56
+ })
57
+ };
58
+ ServerSend("AccountBeep", beep);
59
+ }
60
+ function handleRequestResponse(requestId, data) {
61
+ const request = pendingRequests.get(requestId);
62
+ if (!request) return;
63
+ request.resolve({
64
+ data
65
+ });
66
+ }
67
+ export {
68
+ chatSendActionMessage,
69
+ chatSendBeep,
70
+ chatSendLocal,
71
+ chatSendModMessage,
72
+ handleRequestResponse
73
+ };
@@ -0,0 +1,14 @@
1
+ import { PatchHook, ModSDKModInfo, GetDotedPathType } from "bondage-club-mod-sdk";
2
+ export declare enum HookPriority {
3
+ OBSERVE = 0,
4
+ ADD_BEHAVIOR = 1,
5
+ MODIFY_BEHAVIOR = 5,
6
+ OVERRIDE_BEHAVIOR = 10,
7
+ TOP = 100
8
+ }
9
+ export declare function registerMod(): void;
10
+ export declare function hookFunction(functionName: string, priority: HookPriority, hook: PatchHook): () => void;
11
+ export declare function patchFunction(functionName: string, patches: Record<string, string | null>): void;
12
+ export declare function callOriginal<TFunctionName extends string>(target: TFunctionName, args: [...Parameters<GetDotedPathType<typeof globalThis, TFunctionName>>], context?: any): ReturnType<GetDotedPathType<typeof globalThis, TFunctionName>>;
13
+ export declare function getLoadedMods(): ModSDKModInfo[];
14
+ export declare function findModByName(name: string): boolean;
@@ -0,0 +1,51 @@
1
+ import bcModSdk from "bondage-club-mod-sdk";
2
+ import { MOD_DATA } from "./index";
3
+ import { getCurrentSubscreen } from "./ui";
4
+ var HookPriority = /* @__PURE__ */ ((HookPriority2) => {
5
+ HookPriority2[HookPriority2["OBSERVE"] = 0] = "OBSERVE";
6
+ HookPriority2[HookPriority2["ADD_BEHAVIOR"] = 1] = "ADD_BEHAVIOR";
7
+ HookPriority2[HookPriority2["MODIFY_BEHAVIOR"] = 5] = "MODIFY_BEHAVIOR";
8
+ HookPriority2[HookPriority2["OVERRIDE_BEHAVIOR"] = 10] = "OVERRIDE_BEHAVIOR";
9
+ HookPriority2[HookPriority2["TOP"] = 100] = "TOP";
10
+ return HookPriority2;
11
+ })(HookPriority || {});
12
+ let modSdk;
13
+ function registerMod() {
14
+ modSdk = bcModSdk.registerMod({
15
+ name: MOD_DATA.name,
16
+ fullName: MOD_DATA.fullName,
17
+ version: MOD_DATA.version,
18
+ repository: MOD_DATA.repository
19
+ });
20
+ hookFunction("GameKeyDown", 1 /* ADD_BEHAVIOR */, (args, next) => {
21
+ if (CommonKey.IsPressed(args[0], "Escape") && getCurrentSubscreen()) getCurrentSubscreen().exit();
22
+ return next(args);
23
+ });
24
+ }
25
+ function hookFunction(functionName, priority, hook) {
26
+ if (!modSdk) throw new Error("zois-core is not registered");
27
+ return modSdk.hookFunction(functionName, priority, hook);
28
+ }
29
+ function patchFunction(functionName, patches) {
30
+ if (!modSdk) throw new Error("zois-core is not registered");
31
+ modSdk.patchFunction(functionName, patches);
32
+ }
33
+ function callOriginal(target, args, context) {
34
+ if (!modSdk) throw new Error("zois-core is not registered");
35
+ return modSdk.callOriginal(target, args);
36
+ }
37
+ function getLoadedMods() {
38
+ return bcModSdk.getModsInfo();
39
+ }
40
+ function findModByName(name) {
41
+ return !!bcModSdk.getModsInfo().find((m) => m.name === name);
42
+ }
43
+ export {
44
+ HookPriority,
45
+ callOriginal,
46
+ findModByName,
47
+ getLoadedMods,
48
+ hookFunction,
49
+ patchFunction,
50
+ registerMod
51
+ };
@@ -0,0 +1,74 @@
1
+ @import "https://fonts.googleapis.com/css2?family=Emilys+Candy&display=swap";
2
+ * {
3
+ margin: 0;
4
+ padding: 0;
5
+ box-sizing: border-box;
6
+ }
7
+ .zcButton {
8
+ cursor: pointer;
9
+ background: var(--tmd-element, white);
10
+ font-family: "Emilys Candy";
11
+ color: var(--tmd-text, black);
12
+ border: 2px solid var(--tmd-accent, black);
13
+ border-radius: 4px;
14
+ }
15
+ .zcButton:hover {
16
+ background: var(--tmd-element-hover, #ebf7fe);
17
+ border-color: var(--tmd-accent-hover, #7dd3fc);
18
+ color: var(--tmd-accent-hover, #015a8c);
19
+ }
20
+ .zcButton[data-lc-style=green] {
21
+ background: rgb(124, 255, 124);
22
+ border-color: rgb(82, 204, 82);
23
+ color: black;
24
+ }
25
+ .zcButton[data-lc-style=green]:hover {
26
+ background: rgb(94, 197, 94);
27
+ color: black;
28
+ }
29
+ .zcButton[data-lc-style=inverted] {
30
+ background: var(--tmd-accent, #303030);
31
+ border: none;
32
+ color: var(--tmd-text, white);
33
+ }
34
+ .zcButton[data-lc-style=inverted]:hover {
35
+ background: var(--tmd-accent-hover, #474747);
36
+ }
37
+ .zcInput {
38
+ background: var(--tmd-element, white);
39
+ font-family: Emilys Candy;
40
+ color: var(--tmd-text, black);
41
+ padding: 2vw;
42
+ border: 2px solid var(--tmd-accent, black);
43
+ border-radius: 4px;
44
+ }
45
+ .zcInput::placeholder {
46
+ color: var(--tmd-text, black);
47
+ }
48
+ .zcBackNextButton {
49
+ display: flex;
50
+ column-gap: 2vw;
51
+ justify-content: center;
52
+ align-items: center;
53
+ background: var(--tmd-element, white);
54
+ font-family: Emilys Candy;
55
+ color: var(--tmd-text, black);
56
+ border: 2px solid var(--tmd-accent, black);
57
+ border-radius: 4px;
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
+ .zcDisabled {
72
+ pointer-events: none;
73
+ opacity: 0.6;
74
+ }
package/dist/ui.d.ts ADDED
@@ -0,0 +1,113 @@
1
+ interface CreateButtonArgs {
2
+ text?: string;
3
+ x?: number;
4
+ y?: number;
5
+ fontSize?: number | "auto";
6
+ width?: number;
7
+ height?: number;
8
+ padding?: number;
9
+ style?: "default" | "green" | "inverted";
10
+ anchor?: 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right';
11
+ place?: boolean;
12
+ icon?: string;
13
+ iconAbsolutePosition?: boolean;
14
+ iconWidth?: string;
15
+ }
16
+ interface CreateTextArgs {
17
+ text?: string;
18
+ color?: "string";
19
+ x?: number;
20
+ y?: number;
21
+ fontSize?: number | "auto";
22
+ withBackground?: boolean;
23
+ width?: number;
24
+ height?: number;
25
+ padding?: number;
26
+ anchor?: 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right';
27
+ place?: boolean;
28
+ }
29
+ interface CreateInputArgs {
30
+ value?: string;
31
+ placeholder?: string;
32
+ x?: number;
33
+ y?: number;
34
+ width: number;
35
+ height?: number;
36
+ textArea?: boolean;
37
+ fontSize?: number | "auto";
38
+ anchor?: 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right';
39
+ padding?: number;
40
+ place?: boolean;
41
+ }
42
+ interface CreateCheckboxArgs {
43
+ isChecked: boolean;
44
+ x?: number;
45
+ y?: number;
46
+ width?: number;
47
+ text: string;
48
+ anchor?: 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right';
49
+ place?: boolean;
50
+ }
51
+ interface CreateScrollViewArgs {
52
+ scroll: "x" | "y" | "all";
53
+ x: number;
54
+ y: number;
55
+ width: number;
56
+ height?: number;
57
+ anchor?: 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right';
58
+ }
59
+ interface CreateInputListArgs {
60
+ value?: string[] | number[];
61
+ title?: string;
62
+ x?: number;
63
+ y?: number;
64
+ width: number;
65
+ height?: number;
66
+ fontSize?: number | "auto";
67
+ anchor?: 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right';
68
+ padding?: number;
69
+ place?: boolean;
70
+ numbersOnly?: boolean;
71
+ }
72
+ interface CreateImageArgs {
73
+ src: string;
74
+ x: number;
75
+ y: number;
76
+ width: number;
77
+ }
78
+ interface CreateBackNextButtonArgs {
79
+ x: number;
80
+ y: number;
81
+ width: number;
82
+ height: number;
83
+ items: [string, any?][];
84
+ currentIndex: number;
85
+ onChange?: (value: any) => void;
86
+ }
87
+ export declare function setPreviousSubscreen(): void;
88
+ export declare function setSubscreen(subscreen: BaseSubscreen | null): void;
89
+ export declare function getCurrentSubscreen(): BaseSubscreen;
90
+ export declare abstract class BaseSubscreen {
91
+ private htmlElements;
92
+ private resizeEventListeners;
93
+ get currentSubscreen(): BaseSubscreen | null;
94
+ get name(): string;
95
+ run(): void;
96
+ load?(): void;
97
+ unload?(): void;
98
+ click?(): void;
99
+ exit?(): void;
100
+ update?(): void;
101
+ setPreviousSubscreen(): void;
102
+ setSubscreen(subscreen: BaseSubscreen | null): void;
103
+ createButton({ text, x, y, width, height, fontSize, anchor, padding, style, place, icon, iconAbsolutePosition, iconWidth }: CreateButtonArgs): HTMLButtonElement;
104
+ 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;
107
+ createScrollView({ scroll, x, y, width, height, anchor }: CreateScrollViewArgs): HTMLDivElement;
108
+ createInputList({ x, y, width, height, title, value, anchor, place, numbersOnly, }: CreateInputListArgs): [HTMLDivElement, () => (number[] | string[])];
109
+ createImage({ x, y, width, src, }: CreateImageArgs): HTMLImageElement;
110
+ createBackNextButton({ x, y, width, height, items, currentIndex, onChange }: CreateBackNextButtonArgs): HTMLDivElement;
111
+ }
112
+ export declare function hookSubscreen(subscreenName: string, hook: (subscreen: BaseSubscreen) => void): void;
113
+ export {};
package/dist/ui.js ADDED
@@ -0,0 +1,464 @@
1
+ function getRelativeHeight(height) {
2
+ return height * (MainCanvas.canvas.clientHeight / 1e3);
3
+ }
4
+ function getRelativeWidth(width) {
5
+ return width * (MainCanvas.canvas.clientWidth / 2e3);
6
+ }
7
+ function getRelativeY(yPos, anchorPosition = "top") {
8
+ const scaleY = MainCanvas.canvas.clientHeight / 1e3;
9
+ return anchorPosition === "top" ? MainCanvas.canvas.offsetTop + yPos * scaleY : MainCanvas.canvas.offsetTop + MainCanvas.canvas.clientHeight - yPos * scaleY;
10
+ }
11
+ function getRelativeX(xPos, anchorPosition = "left") {
12
+ const scaleX = MainCanvas.canvas.clientWidth / 2e3;
13
+ return anchorPosition === "left" ? MainCanvas.canvas.offsetLeft + xPos * scaleX : MainCanvas.canvas.offsetLeft + MainCanvas.canvas.clientWidth - xPos * scaleX;
14
+ }
15
+ function setPosition(element, xPos, yPos, anchorPosition = "top-left") {
16
+ const yAnchor = anchorPosition === "top-left" || anchorPosition === "top-right" ? "top" : "bottom";
17
+ const xAnchor = anchorPosition === "top-left" || anchorPosition === "bottom-left" ? "left" : "right";
18
+ const y = getRelativeY(yPos, yAnchor);
19
+ const x = getRelativeX(xPos, xAnchor);
20
+ Object.assign(element.style, {
21
+ position: "fixed",
22
+ [xAnchor]: x + "px",
23
+ [yAnchor]: y + "px"
24
+ });
25
+ }
26
+ function setSize(element, width, height) {
27
+ const w = getRelativeWidth(width);
28
+ const h = getRelativeHeight(height);
29
+ Object.assign(element.style, {
30
+ "width": w + "px",
31
+ "height": h + "px"
32
+ });
33
+ }
34
+ function setFontSize(element, targetFontSize) {
35
+ const canvasWidth = MainCanvas.canvas.clientWidth;
36
+ const canvasHeight = MainCanvas.canvas.clientHeight;
37
+ const scaleFactor = Math.min(canvasWidth, canvasHeight) / 100;
38
+ const fontSize = targetFontSize * scaleFactor;
39
+ Object.assign(element.style, {
40
+ fontSize: fontSize + "px"
41
+ });
42
+ }
43
+ function setPadding(element, targetPadding) {
44
+ const canvasWidth = MainCanvas.canvas.clientWidth;
45
+ const canvasHeight = MainCanvas.canvas.clientHeight;
46
+ const scaleFactor = Math.min(canvasWidth, canvasHeight) / 100;
47
+ const paddingValue = targetPadding * scaleFactor;
48
+ Object.assign(element.style, {
49
+ padding: paddingValue + "px"
50
+ });
51
+ }
52
+ function autosetFontSize(element) {
53
+ const Font = MainCanvas.canvas.clientWidth <= MainCanvas.canvas.clientHeight * 2 ? MainCanvas.canvas.clientWidth / 50 : MainCanvas.canvas.clientHeight / 25;
54
+ Object.assign(element.style, {
55
+ fontSize: Font + "px"
56
+ });
57
+ }
58
+ function loadSubscreen(subscreen) {
59
+ subscreen.createButton({
60
+ x: 1815,
61
+ y: 75,
62
+ width: 90,
63
+ height: 90,
64
+ icon: "Icons/Exit.png"
65
+ }).addEventListener("click", () => subscreen.exit());
66
+ CommonSetScreen("Character", "InformationSheet");
67
+ subscreen.load();
68
+ if (subscreenHooks[subscreen.name]) {
69
+ subscreenHooks[subscreen.name].forEach((hook) => hook(subscreen));
70
+ }
71
+ }
72
+ function setPreviousSubscreen() {
73
+ setSubscreen(previousSubscreen);
74
+ }
75
+ function setSubscreen(subscreen) {
76
+ previousSubscreen = currentSubscreen;
77
+ currentSubscreen = subscreen;
78
+ if (currentSubscreen) loadSubscreen(currentSubscreen);
79
+ if (previousSubscreen) previousSubscreen.unload();
80
+ }
81
+ function getCurrentSubscreen() {
82
+ return currentSubscreen;
83
+ }
84
+ let currentSubscreen;
85
+ let previousSubscreen = null;
86
+ class BaseSubscreen {
87
+ htmlElements = [];
88
+ resizeEventListeners = [];
89
+ get currentSubscreen() {
90
+ return currentSubscreen;
91
+ }
92
+ get name() {
93
+ return "";
94
+ }
95
+ run() {
96
+ }
97
+ load() {
98
+ }
99
+ unload() {
100
+ this.htmlElements.forEach((e) => {
101
+ e.remove();
102
+ });
103
+ this.resizeEventListeners.forEach((e) => {
104
+ removeEventListener("resize", e);
105
+ });
106
+ }
107
+ click() {
108
+ }
109
+ exit() {
110
+ setPreviousSubscreen();
111
+ }
112
+ update() {
113
+ }
114
+ setPreviousSubscreen() {
115
+ setPreviousSubscreen();
116
+ }
117
+ setSubscreen(subscreen) {
118
+ setSubscreen(subscreen);
119
+ }
120
+ createButton({
121
+ text,
122
+ x,
123
+ y,
124
+ width,
125
+ height,
126
+ fontSize = "auto",
127
+ anchor = "top-left",
128
+ padding,
129
+ style = "default",
130
+ place = true,
131
+ icon,
132
+ iconAbsolutePosition = true,
133
+ iconWidth
134
+ }) {
135
+ const btn = document.createElement("button");
136
+ btn.classList.add("zcButton");
137
+ btn.setAttribute("data-zc-style", style);
138
+ btn.style.display = "flex";
139
+ btn.style.alignItems = "center";
140
+ btn.style.justifyContent = "center";
141
+ btn.style.columnGap = "1.25vw";
142
+ if (icon) {
143
+ const img = document.createElement("img");
144
+ img.src = icon;
145
+ if (iconWidth) img.style.width = iconWidth;
146
+ else img.style.height = "80%";
147
+ if (text && iconAbsolutePosition) {
148
+ img.style.position = "absolute";
149
+ img.style.left = "1vw";
150
+ }
151
+ if (text && !iconAbsolutePosition) btn.style.justifyContent = "";
152
+ btn.append(img);
153
+ }
154
+ if (text) {
155
+ const span = document.createElement("span");
156
+ span.textContent = text;
157
+ if (icon && !iconAbsolutePosition && iconWidth) {
158
+ span.style.width = "100%";
159
+ span.style.marginRight = iconWidth;
160
+ }
161
+ btn.append(span);
162
+ }
163
+ const setProperties = () => {
164
+ if (x && y) setPosition(btn, x, y, anchor);
165
+ setSize(btn, width, height);
166
+ if (padding) setPadding(btn, padding);
167
+ if (fontSize === "auto") autosetFontSize(btn);
168
+ else setFontSize(btn, fontSize);
169
+ };
170
+ setProperties();
171
+ window.addEventListener("resize", setProperties);
172
+ if (place) document.body.append(btn);
173
+ this.resizeEventListeners.push(setProperties);
174
+ this.htmlElements.push(btn);
175
+ return btn;
176
+ }
177
+ createText({
178
+ text,
179
+ color,
180
+ x,
181
+ y,
182
+ width,
183
+ height,
184
+ withBackground = false,
185
+ fontSize = "auto",
186
+ anchor = "top-left",
187
+ padding,
188
+ place = true
189
+ }) {
190
+ const p = document.createElement("p");
191
+ p.innerHTML = text;
192
+ p.style.color = color ?? "var(--tmd-text, black)";
193
+ if (withBackground) p.style.background = "var(--tmd-element,rgb(239, 239, 239))";
194
+ p.style.fontFamily = "Emilys Candy";
195
+ const setProperties = () => {
196
+ if (x && y) setPosition(p, x, y, anchor);
197
+ setSize(p, width, height);
198
+ if (padding) setPadding(p, padding);
199
+ if (fontSize === "auto") autosetFontSize(p);
200
+ else setFontSize(p, fontSize);
201
+ };
202
+ setProperties();
203
+ window.addEventListener("resize", setProperties);
204
+ if (place) document.body.append(p);
205
+ this.resizeEventListeners.push(setProperties);
206
+ this.htmlElements.push(p);
207
+ return p;
208
+ }
209
+ createInput({
210
+ value,
211
+ placeholder,
212
+ x,
213
+ y,
214
+ width,
215
+ height,
216
+ textArea = false,
217
+ fontSize = "auto",
218
+ anchor = "top-left",
219
+ padding,
220
+ place = true
221
+ }) {
222
+ const input = document.createElement(textArea ? "textarea" : "input");
223
+ input.classList.add("zcInput");
224
+ if (placeholder) input.placeholder = placeholder;
225
+ if (value) input.value = value;
226
+ const setProperties = () => {
227
+ if (x && y) setPosition(input, x, y, anchor);
228
+ setSize(input, width, height);
229
+ if (padding) setPadding(input, padding);
230
+ if (fontSize === "auto") autosetFontSize(input);
231
+ else setFontSize(input, fontSize);
232
+ };
233
+ setProperties();
234
+ window.addEventListener("resize", setProperties);
235
+ if (place) document.body.append(input);
236
+ this.resizeEventListeners.push(setProperties);
237
+ this.htmlElements.push(input);
238
+ return input;
239
+ }
240
+ createCheckbox({
241
+ text,
242
+ x,
243
+ y,
244
+ isChecked,
245
+ width,
246
+ anchor = "top-left",
247
+ place = true
248
+ }) {
249
+ const checkbox = document.createElement("input");
250
+ checkbox.type = "checkbox";
251
+ checkbox.checked = isChecked;
252
+ checkbox.classList.add("zcCheckbox", "checkbox");
253
+ const p = document.createElement("p");
254
+ p.textContent = text;
255
+ p.style.color = "var(--tmd-text, black)";
256
+ p.style.fontFamily = "Emilys Candy";
257
+ const setProperties = () => {
258
+ if (x && y) setPosition(checkbox, x, y, anchor);
259
+ setPosition(p, x + 100, y, anchor);
260
+ setSize(checkbox, 65, 65);
261
+ if (width) setSize(p, width, null);
262
+ setFontSize(p, 5);
263
+ };
264
+ setProperties();
265
+ window.addEventListener("resize", setProperties);
266
+ if (place) document.body.append(checkbox, p);
267
+ this.resizeEventListeners.push(setProperties);
268
+ this.htmlElements.push(checkbox, p);
269
+ return checkbox;
270
+ }
271
+ createScrollView({
272
+ scroll,
273
+ x,
274
+ y,
275
+ width,
276
+ height,
277
+ anchor = "top-left"
278
+ }) {
279
+ const div = document.createElement("div");
280
+ if (scroll === "all") div.style.overflow = "scroll";
281
+ if (scroll === "x") div.style.overflowX = "scroll";
282
+ if (scroll === "y") div.style.overflowY = "scroll";
283
+ const setProperties = () => {
284
+ if (x && y) setPosition(div, x, y, anchor);
285
+ setSize(div, width, height);
286
+ };
287
+ setProperties();
288
+ window.addEventListener("resize", setProperties);
289
+ document.body.append(div);
290
+ this.resizeEventListeners.push(setProperties);
291
+ this.htmlElements.push(div);
292
+ return div;
293
+ }
294
+ createInputList({
295
+ x,
296
+ y,
297
+ width,
298
+ height,
299
+ title,
300
+ value,
301
+ anchor = "top-left",
302
+ place = true,
303
+ numbersOnly = false
304
+ }) {
305
+ const items = [];
306
+ const div = document.createElement("div");
307
+ div.style.cssText = `
308
+ display: flex; flex-direction: column; gap: 1vw; border: 2px solid var(--tmd-accent, black);
309
+ font-family: Emilys Candy; border-radius: 4px; padding: 0.75vw;
310
+ `;
311
+ const buttonsElement = document.createElement("div");
312
+ buttonsElement.style.cssText = "display: flex; justify-content: center; column-gap: 1vw; width: 100%;";
313
+ const titleElement = document.createElement("b");
314
+ titleElement.textContent = title + ":";
315
+ titleElement.style.cssText = "width: 100%; font-size: clamp(10px, 2.4vw, 24px); color: var(--tmd-text, black);";
316
+ const itemsElement = document.createElement("div");
317
+ itemsElement.style.cssText = `display: flex; gap: 1vw; flex-wrap: wrap; align-content: flex-start;
318
+ overflow-y: scroll;`;
319
+ const input = document.createElement("input");
320
+ input.style.cssText = "border: none; outline: none; background: none; height: fit-content; flex-grow: 1; padding: 0.8vw; width: 6vw; font-size: clamp(8px, 2vw, 20px);";
321
+ const addButton = (icon, onClick) => {
322
+ const b = document.createElement("button");
323
+ b.style.cssText = "cursor: pointer; display: grid; place-items: center; background: var(--tmd-element-hover, #e0e0e0); width: 10%; max-width: 40px; aspect-ratio: 1/1; border-radius: 8px; border: none;";
324
+ const img = DrawGetImage(icon);
325
+ img.style.cssText = "width: 90%;";
326
+ b.append(img);
327
+ buttonsElement.append(b);
328
+ b.addEventListener("click", onClick);
329
+ };
330
+ const addItem = (text) => {
331
+ const item = document.createElement("div");
332
+ 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
+ item.textContent = text;
334
+ itemsElement.insertBefore(item, input);
335
+ item.addEventListener("click", (e) => {
336
+ if (item.style.border === "") item.style.border = "2px solid red";
337
+ else item.style.border = "";
338
+ e.stopPropagation();
339
+ });
340
+ items.push(text);
341
+ };
342
+ const setProperties = () => {
343
+ if (x && y) setPosition(div, x, y, anchor);
344
+ setSize(div, width, height);
345
+ };
346
+ addButton("Icons/Cancel.png", () => {
347
+ itemsElement.innerHTML = "";
348
+ items.splice(0, items.length);
349
+ itemsElement.append(input);
350
+ value.forEach((v) => addItem(String(v)));
351
+ });
352
+ addButton("Icons/Trash.png", () => {
353
+ for (const c of [...itemsElement.children]) {
354
+ if (c.getAttribute("style").includes("border: 2px solid red;")) {
355
+ items.splice(items.indexOf(c.textContent), 1);
356
+ c.remove();
357
+ }
358
+ }
359
+ });
360
+ setProperties();
361
+ window.addEventListener("resize", setProperties);
362
+ input.addEventListener("keypress", (e) => {
363
+ if (document.activeElement === input) {
364
+ switch (e.key) {
365
+ case "Enter":
366
+ if (numbersOnly && Number.isNaN(parseInt(input.value))) return;
367
+ if (!numbersOnly && input.value.trim() === "") return;
368
+ addItem(input.value);
369
+ input.value = "";
370
+ break;
371
+ }
372
+ }
373
+ });
374
+ div.addEventListener("click", (e) => {
375
+ if (e.currentTarget == div) input.focus();
376
+ });
377
+ itemsElement.append(input);
378
+ div.append(buttonsElement, titleElement, itemsElement);
379
+ document.body.append(div);
380
+ this.resizeEventListeners.push(setProperties);
381
+ this.htmlElements.push(div);
382
+ value.forEach((v) => addItem(String(v)));
383
+ return [
384
+ div,
385
+ () => numbersOnly ? items.map((i) => parseInt(i)) : items
386
+ ];
387
+ }
388
+ createImage({
389
+ x,
390
+ y,
391
+ width,
392
+ src
393
+ }) {
394
+ const img = document.createElement("img");
395
+ img.src = src;
396
+ const setProperties = () => {
397
+ if (x && y) setPosition(img, x, y);
398
+ setSize(img, width, 0);
399
+ img.style.height = "auto";
400
+ };
401
+ setProperties();
402
+ window.addEventListener("resize", setProperties);
403
+ document.body.append(img);
404
+ this.resizeEventListeners.push(setProperties);
405
+ this.htmlElements.push(img);
406
+ return img;
407
+ }
408
+ createBackNextButton({
409
+ x,
410
+ y,
411
+ width,
412
+ height,
413
+ items,
414
+ currentIndex,
415
+ onChange
416
+ }) {
417
+ const div = document.createElement("div");
418
+ div.classList.add("zcBackNextButton");
419
+ const backBtn = document.createElement("button");
420
+ backBtn.style.cssText = "position: absolute; left: 1vw;";
421
+ backBtn.textContent = "\u{1F844}";
422
+ backBtn.addEventListener("click", () => {
423
+ if (currentIndex === 0) return;
424
+ currentIndex--;
425
+ text.textContent = items[currentIndex][0];
426
+ if (typeof onChange === "function") onChange(items[currentIndex][1]);
427
+ });
428
+ const nextBtn = document.createElement("button");
429
+ nextBtn.style.cssText = "position: absolute; right: 1vw;";
430
+ nextBtn.textContent = "\u{1F846}";
431
+ nextBtn.addEventListener("click", () => {
432
+ if (currentIndex === items.length - 1) return;
433
+ currentIndex++;
434
+ text.textContent = items[currentIndex][0];
435
+ if (typeof onChange === "function") onChange(items[currentIndex][1]);
436
+ });
437
+ const text = document.createElement("p");
438
+ text.textContent = items[currentIndex][0];
439
+ div.append(backBtn, text, nextBtn);
440
+ const setProperties = () => {
441
+ if (x && y) setPosition(div, x, y);
442
+ setSize(div, width, height);
443
+ autosetFontSize(text);
444
+ };
445
+ setProperties();
446
+ window.addEventListener("resize", setProperties);
447
+ document.body.append(div);
448
+ this.resizeEventListeners.push(setProperties);
449
+ this.htmlElements.push(div);
450
+ return div;
451
+ }
452
+ }
453
+ let subscreenHooks = {};
454
+ function hookSubscreen(subscreenName, hook) {
455
+ if (!subscreenHooks[subscreenName]) subscreenHooks[subscreenName] = [];
456
+ subscreenHooks[subscreenName].push(hook);
457
+ }
458
+ export {
459
+ BaseSubscreen,
460
+ getCurrentSubscreen,
461
+ hookSubscreen,
462
+ setPreviousSubscreen,
463
+ setSubscreen
464
+ };
@@ -0,0 +1,11 @@
1
+ export declare function smartGetAsset(item: Item | Asset): Asset;
2
+ export declare function smartGetAssetGroup(item: Item | Asset | AssetGroup): AssetGroup;
3
+ export declare function isAssetGroupName(name: string): name is AssetGroupName;
4
+ export declare function isCloth(item: Item | Asset | AssetGroup, allowCosplay?: boolean): boolean;
5
+ export declare function isCosplay(item: Item | Asset | AssetGroup): boolean;
6
+ export declare function isBody(item: Item | Asset | AssetGroup): boolean;
7
+ export declare function isBind(item: Item | Asset | AssetGroup, excludeSlots?: AssetGroupName[]): boolean;
8
+ export type IncludeType = "Cosplay" | "Binds" | "Collar" | "Locks";
9
+ export declare function importAppearance(C: Character, bundleToAttach: Item[], include?: IncludeType[], characterValidate?: Character, ignoreAccessValidation?: boolean): void;
10
+ export declare function validationCanAccessCheck(C: Character, group: AssetGroupName, asset: Asset): boolean;
11
+ export declare function serverAppearanceBundleToAppearance(assetFamily: IAssetFamily, serverAppearanceBundle: AppearanceBundle): Item[];
@@ -0,0 +1,100 @@
1
+ function smartGetAsset(item) {
2
+ const asset = Asset.includes(item) ? item : item.Asset;
3
+ if (!Asset.includes(asset)) {
4
+ throw new Error("Failed to convert item to asset");
5
+ }
6
+ return asset;
7
+ }
8
+ function smartGetAssetGroup(item) {
9
+ const group = AssetGroup.includes(item) ? item : Asset.includes(item) ? item.Group : item.Asset.Group;
10
+ if (!AssetGroup.includes(group)) {
11
+ throw new Error("Failed to convert item to group");
12
+ }
13
+ return group;
14
+ }
15
+ function isAssetGroupName(name) {
16
+ return AssetGroup.some((group) => group.Name === name);
17
+ }
18
+ function isCloth(item, allowCosplay = false) {
19
+ const group = smartGetAssetGroup(item);
20
+ return group.Category === "Appearance" && group.AllowNone && group.Clothing && (allowCosplay || !group.BodyCosplay);
21
+ }
22
+ function isCosplay(item) {
23
+ const group = smartGetAssetGroup(item);
24
+ return group.Category === "Appearance" && group.AllowNone && group.Clothing && group.BodyCosplay;
25
+ }
26
+ function isBody(item) {
27
+ const group = smartGetAssetGroup(item);
28
+ return group.Category === "Appearance" && !group.Clothing;
29
+ }
30
+ function isBind(item, excludeSlots = ["ItemNeck", "ItemNeckAccessories", "ItemNeckRestraints"]) {
31
+ const group = smartGetAssetGroup(item);
32
+ if (group.Category !== "Item" || group.BodyCosplay) return false;
33
+ return !excludeSlots.includes(group.Name);
34
+ }
35
+ function importAppearance(C, bundleToAttach, include = ["Cosplay", "Binds", "Collar", "Locks"], characterValidate = C, ignoreAccessValidation = false) {
36
+ bundleToAttach = bundleToAttach.filter((i) => !!i && !isBody(i));
37
+ if (!include.includes("Cosplay")) bundleToAttach = bundleToAttach.filter((i) => !isCosplay(i));
38
+ if (!include.includes("Binds")) bundleToAttach = bundleToAttach.filter((i) => !isBind(i));
39
+ if (!include.includes("Collar")) bundleToAttach = bundleToAttach.filter((i) => i.Asset.Group.Name !== "ItemNeck");
40
+ if (!include.includes("Locks")) bundleToAttach = bundleToAttach.map((i) => {
41
+ if (i.Property?.LockedBy) delete i.Property.LockedBy;
42
+ return i;
43
+ });
44
+ const blockedGroups = [];
45
+ if (ignoreAccessValidation) {
46
+ C.Appearance = C.Appearance.filter((a) => isBody(a));
47
+ } else {
48
+ const validationParams = ValidationCreateDiffParams(characterValidate, Player.MemberNumber);
49
+ C.Appearance = C.Appearance.filter((a) => {
50
+ if (isBody(a)) {
51
+ blockedGroups.push(a.Asset.Group.Name);
52
+ return true;
53
+ }
54
+ if (!ValidationCanRemoveItem(
55
+ a,
56
+ validationParams,
57
+ !!bundleToAttach.find((b) => b?.Asset?.Group?.Name === a?.Asset?.Group?.Name)
58
+ ) || a.Property?.LockedBy && !DialogCanUnlock(characterValidate, a) || a.Asset.Name === "SlaveCollar" && characterValidate.IsPlayer()) {
59
+ blockedGroups.push(a.Asset.Group.Name);
60
+ return true;
61
+ }
62
+ return false;
63
+ });
64
+ }
65
+ for (const item of bundleToAttach) {
66
+ if (!ignoreAccessValidation) {
67
+ if (!validationCanAccessCheck(characterValidate, item.Asset.Group.Name, item.Asset)) continue;
68
+ if (blockedGroups.includes(item.Asset.Group.Name)) continue;
69
+ }
70
+ CharacterAppearanceSetItem(C, item.Asset.Group.Name, item.Asset, item.Color);
71
+ const _item = InventoryGet(C, item.Asset.Group.Name);
72
+ if (item.Craft && CraftingValidate(item.Craft, item.Asset) !== CraftingStatusType.CRITICAL_ERROR) _item.Craft = item.Craft;
73
+ if (item.Property) {
74
+ ValidationSanitizeProperties(C, item);
75
+ _item.Property = item.Property;
76
+ }
77
+ }
78
+ CharacterRefresh(C);
79
+ if (!C.IsNpc()) ChatRoomCharacterUpdate(C);
80
+ }
81
+ function validationCanAccessCheck(C, group, asset) {
82
+ return !ValidationIsItemBlockedOrLimited(C, Player.MemberNumber, group, asset.Name) && ServerChatRoomGetAllowItem(Player, C);
83
+ }
84
+ function serverAppearanceBundleToAppearance(assetFamily, serverAppearanceBundle) {
85
+ return serverAppearanceBundle.map((t) => {
86
+ return ServerBundledItemToAppearanceItem(assetFamily, t);
87
+ });
88
+ }
89
+ export {
90
+ importAppearance,
91
+ isAssetGroupName,
92
+ isBind,
93
+ isBody,
94
+ isCloth,
95
+ isCosplay,
96
+ serverAppearanceBundleToAppearance,
97
+ smartGetAsset,
98
+ smartGetAssetGroup,
99
+ validationCanAccessCheck
100
+ };
package/package.json ADDED
@@ -0,0 +1,23 @@
1
+ {
2
+ "name": "zois-core",
3
+ "version": "1.0.2",
4
+ "description": "The core for the my mods, which contains a shared code reused in all my mods",
5
+ "author": "Zoi",
6
+ "license": "MIT",
7
+ "files": [
8
+ "dist"
9
+ ],
10
+ "type": "commonjs",
11
+ "dependencies": {
12
+ "bondage-club-mod-sdk": "^1.2.0"
13
+ },
14
+ "devDependencies": {
15
+ "bc-stubs": "116.0.0-Beta.1",
16
+ "esbuild": "^0.25.4",
17
+ "nodemon": "^3.1.10",
18
+ "typescript": "^5.8.3"
19
+ },
20
+ "scripts": {
21
+ "build": "node scripts/build.mjs"
22
+ }
23
+ }