zois-core 1.0.6 → 1.0.8

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.
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><path d="M12 22C6.47715 22 2 17.5228 2 12C2 6.47715 6.47715 2 12 2C17.5228 2 22 6.47715 22 12C22 17.5228 17.5228 22 12 22ZM11 15V17H13V15H11ZM11 7V13H13V7H11Z"></path></svg>
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><path d="M12 22C6.47715 22 2 17.5228 2 12C2 6.47715 6.47715 2 12 2C17.5228 2 22 6.47715 22 12C22 17.5228 17.5228 22 12 22ZM11 11V17H13V11H11ZM11 7V9H13V7H11Z"></path></svg>
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><path d="M12 22C17.5228 22 22 17.5228 22 12C22 6.47715 17.5228 2 12 2C6.47715 2 2 6.47715 2 12C2 17.5228 6.47715 22 12 22ZM17.4571 9.45711L11 15.9142L6.79289 11.7071L8.20711 10.2929L11 13.0858L16.0429 8.04289L17.4571 9.45711Z"></path></svg>
package/dist/index.d.ts CHANGED
@@ -18,4 +18,5 @@ export declare function colorsEqual(c1: string[] | string | null | undefined, c2
18
18
  export declare function getSizeInKbytes(b: any): number;
19
19
  export declare function getPlayer(value: string | number): Character;
20
20
  export declare function getNickname(target: Character): string;
21
+ export declare function getThemedColorsModule(): any;
21
22
  export {};
package/dist/index.js CHANGED
@@ -1,79 +1 @@
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
- };
1
+ import s from"./styles.css";import{findModByName as u,registerMod as l}from"./modsApi";import{initVirtualDOM as f}from"./popups";let g;function c(e){if(!window.ZOISCORE){const t=document.createElement("style");t.innerHTML=s,document.head.append(t),f(),window.ZOISCORE=!0}g={...e},l()}function d(e){return new Promise(t=>setTimeout(t,e))}async function y(e,t=()=>!1){for(;!e();){if(t())return!1;await d(10)}return!0}function M(e,t){return e=Math.ceil(e),t=Math.floor(t),Math.floor(Math.random()*(t-e+1))+e}function b(e,t){const r=e.split("."),o=t.split(".");for(let n=0;n<Math.max(r.length,o.length);n++){const i=parseInt(r[n]||"0",10),a=parseInt(o[n]||"0",10);if(i>a)return!0;if(i<a)return!1}return!1}function w(e,t){return!e&&!t||!e&&t==="Default"||!t&&e==="Default"||e==="Default"&&Array.isArray(t)&&t.filter(r=>r==="Default").length===t.length||t==="Default"&&Array.isArray(e)&&e.filter(r=>r==="Default").length===e.length?!0:JSON.stringify(e)===JSON.stringify(t)}function x(e){return typeof e=="string"?Math.round(new TextEncoder().encode(e).byteLength/100)/10:Math.round(new TextEncoder().encode(JSON.stringify(e)).byteLength/100)/10}function D(e){if(e)return ChatRoomCharacter.find(t=>t.MemberNumber==e||t.Name.toLowerCase()===e||t.Nickname?.toLowerCase()===e)}function N(e){return CharacterNickname(e)}function C(){if(!u("Themed"))return null;const e=JSON.parse(LZString.decompressFromBase64(Player.ExtensionSettings.Themed??""));return!e?.GlobalModule?.themedEnabled||!e?.GlobalModule?.doVanillaGuiOverhaul?null:e.ColorsModule}export{g as MOD_DATA,w as colorsEqual,N as getNickname,D as getPlayer,M as getRandomNumber,x as getSizeInKbytes,C as getThemedColorsModule,b as isVersionNewer,c as registerCore,d as sleep,y as waitFor};
package/dist/messaging.js CHANGED
@@ -1,115 +1 @@
1
- import { getRandomNumber, MOD_DATA } from "./index";
2
- const pendingRequests = /* @__PURE__ */ new Map();
3
- const requestListeners = /* @__PURE__ */ new Map();
4
- function chatSendLocalMessage(message) {
5
- if (!ServerPlayerIsInChatRoom()) return;
6
- const div = document.createElement("div");
7
- div.setAttribute("class", "ChatMessage ChatMessageLocalMessage");
8
- div.setAttribute("data-time", ChatRoomCurrentTime());
9
- div.setAttribute("data-sender", `${Player.MemberNumber}`);
10
- div.style.background = MOD_DATA.chatMessageBackground ?? "#55edc095";
11
- div.style.color = MOD_DATA.chatMessageColor ?? "black";
12
- div.style.margin = "0.15em 0";
13
- if (typeof message === "string") div.textContent = message;
14
- else div.appendChild(message);
15
- document.querySelector("#TextAreaChatLog").appendChild(div);
16
- ElementScrollToEnd("TextAreaChatLog");
17
- }
18
- function chatSendActionMessage(msg, target = void 0, dictionary = []) {
19
- if (!msg || !ServerPlayerIsInChatRoom()) return;
20
- const isFemale = CharacterPronounDescription(Player) === "She/Her";
21
- const capPossessive = isFemale ? "Her" : "His";
22
- const capIntensive = isFemale ? "Her" : "Him";
23
- const capSelfIntensive = isFemale ? "Herself" : "Himself";
24
- const capPronoun = isFemale ? "She" : "He";
25
- 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());
26
- ServerSend("ChatRoomChat", {
27
- Content: "LittlishClub_CUSTOM_ACTION",
28
- Type: "Action",
29
- Target: target ?? void 0,
30
- Dictionary: [
31
- { Tag: 'MISSING TEXT IN "Interface.csv": LittlishClub_CUSTOM_ACTION', Text: msg },
32
- ...dictionary
33
- ]
34
- });
35
- }
36
- function chatSendModMessage(msg, _data = null, targetNumber = null) {
37
- const data = {
38
- Content: MOD_DATA.key,
39
- Dictionary: {
40
- // @ts-ignore
41
- msg
42
- },
43
- Type: "Hidden"
44
- };
45
- if (_data) data.Dictionary.data = _data;
46
- if (targetNumber) data.Target = targetNumber;
47
- ServerSend("ChatRoomChat", data);
48
- }
49
- function chatSendBeepMessage(data, targetId) {
50
- const beep = {
51
- IsSecret: true,
52
- BeepType: "Leash",
53
- MemberNumber: targetId,
54
- Message: JSON.stringify({
55
- type: MOD_DATA.key,
56
- ...data
57
- })
58
- };
59
- ServerSend("AccountBeep", beep);
60
- }
61
- function sendRequest(message, data, target) {
62
- return new Promise((resolve, reject) => {
63
- const requestId = parseInt(`${Date.now()}${getRandomNumber(1e3, 1e4)}`);
64
- pendingRequests.set(requestId, {
65
- message,
66
- data,
67
- target,
68
- resolve,
69
- reject
70
- });
71
- chatSendModMessage("request", {
72
- requestId,
73
- message,
74
- data
75
- }, target);
76
- setTimeout(() => {
77
- pendingRequests.delete(requestId);
78
- resolve({
79
- isError: true
80
- });
81
- }, 6e3);
82
- });
83
- }
84
- function handleRequestResponse(requestId, data) {
85
- const request = pendingRequests.get(requestId);
86
- if (!request) return;
87
- request.resolve({
88
- data
89
- });
90
- }
91
- function handleRequest(requestId, message, _data, sender) {
92
- const listener = requestListeners.get(message);
93
- if (!listener) return;
94
- const data = listener(_data, sender);
95
- if (data !== void 0) {
96
- chatSendModMessage("requestResponse", {
97
- requestId,
98
- message,
99
- data
100
- }, sender.MemberNumber);
101
- }
102
- }
103
- function addRequestListener(message, listener) {
104
- requestListeners.set(message, listener);
105
- }
106
- export {
107
- addRequestListener,
108
- chatSendActionMessage,
109
- chatSendBeepMessage,
110
- chatSendLocalMessage,
111
- chatSendModMessage,
112
- handleRequest,
113
- handleRequestResponse,
114
- sendRequest
115
- };
1
+ import{getRandomNumber as p,MOD_DATA as o}from"./index";const i=new Map,u=new Map;function y(t){if(!ServerPlayerIsInChatRoom())return;const e=document.createElement("div");e.setAttribute("class","ChatMessage ChatMessageLocalMessage"),e.setAttribute("data-time",ChatRoomCurrentTime()),e.setAttribute("data-sender",`${Player.MemberNumber}`),e.style.background=o.chatMessageBackground??"#55edc095",e.style.color=o.chatMessageColor??"black",e.style.margin="0.15em 0",typeof t=="string"?e.textContent=t:e.appendChild(t),document.querySelector("#TextAreaChatLog").appendChild(e),ElementScrollToEnd("TextAreaChatLog")}function C(t,e=void 0,n=[]){if(!t||!ServerPlayerIsInChatRoom())return;const s=CharacterPronounDescription(Player)==="She/Her",r=s?"Her":"His",a=s?"Her":"Him",c=s?"Herself":"Himself",l=s?"She":"He";t=t.replaceAll("<Possessive>",r).replaceAll("<possessive>",r.toLocaleLowerCase()).replaceAll("<Intensive>",a).replaceAll("<intensive>",a.toLocaleLowerCase()).replaceAll("<SelfIntensive>",c).replaceAll("<selfIntensive>",c.toLocaleLowerCase()).replaceAll("<Pronoun>",l).replaceAll("<pronoun>",l.toLocaleLowerCase()),ServerSend("ChatRoomChat",{Content:"LittlishClub_CUSTOM_ACTION",Type:"Action",Target:e??void 0,Dictionary:[{Tag:'MISSING TEXT IN "Interface.csv": LittlishClub_CUSTOM_ACTION',Text:t},...n]})}function d(t,e=null,n=null){const s={Content:o.key,Dictionary:{msg:t},Type:"Hidden"};e&&(s.Dictionary.data=e),n&&(s.Target=n),ServerSend("ChatRoomChat",s)}function f(t,e){const n={IsSecret:!0,BeepType:"Leash",MemberNumber:e,Message:JSON.stringify({type:o.key,...t})};ServerSend("AccountBeep",n)}function h(t,e,n){return new Promise((s,r)=>{const a=parseInt(`${Date.now()}${p(1e3,1e4)}`);i.set(a,{message:t,data:e,target:n,resolve:s,reject:r}),d("request",{requestId:a,message:t,data:e},n),setTimeout(()=>{i.delete(a),s({isError:!0})},6e3)})}function m(t,e){const n=i.get(t);n&&n.resolve({data:e})}function M(t,e,n,s){const r=u.get(e);if(!r)return;const a=r(n,s);a!==void 0&&d("requestResponse",{requestId:t,message:e,data:a},s.MemberNumber)}function T(t,e){u.set(t,e)}export{T as addRequestListener,C as chatSendActionMessage,f as chatSendBeepMessage,y as chatSendLocalMessage,d as chatSendModMessage,M as handleRequest,m as handleRequestResponse,h as sendRequest};
package/dist/modsApi.js CHANGED
@@ -1,69 +1 @@
1
- import bcModSdk from "bondage-club-mod-sdk";
2
- import { getPlayer, MOD_DATA } from "./index";
3
- import { getCurrentSubscreen } from "./ui";
4
- import { handleRequest, handleRequestResponse } from "./messaging";
5
- var HookPriority = /* @__PURE__ */ ((HookPriority2) => {
6
- HookPriority2[HookPriority2["OBSERVE"] = 0] = "OBSERVE";
7
- HookPriority2[HookPriority2["ADD_BEHAVIOR"] = 1] = "ADD_BEHAVIOR";
8
- HookPriority2[HookPriority2["MODIFY_BEHAVIOR"] = 5] = "MODIFY_BEHAVIOR";
9
- HookPriority2[HookPriority2["OVERRIDE_BEHAVIOR"] = 10] = "OVERRIDE_BEHAVIOR";
10
- HookPriority2[HookPriority2["TOP"] = 100] = "TOP";
11
- return HookPriority2;
12
- })(HookPriority || {});
13
- let modSdk;
14
- function registerMod() {
15
- modSdk = bcModSdk.registerMod({
16
- name: MOD_DATA.name,
17
- fullName: MOD_DATA.fullName,
18
- version: MOD_DATA.version,
19
- repository: MOD_DATA.repository
20
- });
21
- hookFunction("GameKeyDown", 1 /* ADD_BEHAVIOR */, (args, next) => {
22
- if (CommonKey.IsPressed(args[0], "Escape") && getCurrentSubscreen()) getCurrentSubscreen().exit();
23
- return next(args);
24
- });
25
- hookFunction("ChatRoomMessage", 1 /* ADD_BEHAVIOR */, (args, next) => {
26
- const message = args[0];
27
- const sender = getPlayer(message.Sender);
28
- if (!sender) return next(args);
29
- if (message.Content === MOD_DATA.key && !sender.IsPlayer()) {
30
- const msg = message.Dictionary.msg;
31
- const data = message.Dictionary.data;
32
- if (msg === "request") {
33
- if (typeof data.requestId !== "number" || typeof data.message !== "string") return;
34
- handleRequest(data.requestId, data.message, data.data, sender);
35
- }
36
- if (msg === "requestResponse") {
37
- if (typeof data.requestId !== "number") return;
38
- handleRequestResponse(data.requestId, data.data);
39
- }
40
- }
41
- });
42
- }
43
- function hookFunction(functionName, priority, hook) {
44
- if (!modSdk) throw new Error("zois-core is not registered");
45
- return modSdk.hookFunction(functionName, priority, hook);
46
- }
47
- function patchFunction(functionName, patches) {
48
- if (!modSdk) throw new Error("zois-core is not registered");
49
- modSdk.patchFunction(functionName, patches);
50
- }
51
- function callOriginal(target, args, context) {
52
- if (!modSdk) throw new Error("zois-core is not registered");
53
- return modSdk.callOriginal(target, args);
54
- }
55
- function getLoadedMods() {
56
- return bcModSdk.getModsInfo();
57
- }
58
- function findModByName(name) {
59
- return !!bcModSdk.getModsInfo().find((m) => m.name === name);
60
- }
61
- export {
62
- HookPriority,
63
- callOriginal,
64
- findModByName,
65
- getLoadedMods,
66
- hookFunction,
67
- patchFunction,
68
- registerMod
69
- };
1
+ import a from"bondage-club-mod-sdk";import{getPlayer as f,MOD_DATA as s}from"./index";import{getCurrentSubscreen as u}from"./ui";import{handleRequest as m,handleRequestResponse as p}from"./messaging";var g=(e=>(e[e.OBSERVE=0]="OBSERVE",e[e.ADD_BEHAVIOR=1]="ADD_BEHAVIOR",e[e.MODIFY_BEHAVIOR=5]="MODIFY_BEHAVIOR",e[e.OVERRIDE_BEHAVIOR=10]="OVERRIDE_BEHAVIOR",e[e.TOP=100]="TOP",e))(g||{});let r;function A(){r=a.registerMod({name:s.name,fullName:s.fullName,version:s.version,repository:s.repository}),c("GameKeyDown",1,(t,n)=>(CommonKey.IsPressed(t[0],"Escape")&&u()&&u().exit(),n(t))),c("ChatRoomMessage",1,(t,n)=>{const o=t[0],i=f(o.Sender);if(!i)return n(t);if(o.Content===s.key&&!i.IsPlayer()){const d=o.Dictionary.msg,e=o.Dictionary.data;if(d==="request"){if(typeof e.requestId!="number"||typeof e.message!="string")return;m(e.requestId,e.message,e.data,i)}if(d==="requestResponse"){if(typeof e.requestId!="number")return;p(e.requestId,e.data)}}return n(t)})}function c(t,n,o){if(!r)throw new Error("zois-core is not registered");return r.hookFunction(t,n,o)}function O(t,n){if(!r)throw new Error("zois-core is not registered");r.patchFunction(t,n)}function T(t,n,o){if(!r)throw new Error("zois-core is not registered");return r.callOriginal(t,n)}function x(){return a.getModsInfo()}function F(t){return!!a.getModsInfo().find(n=>n.name===t)}export{g as HookPriority,T as callOriginal,F as findModByName,x as getLoadedMods,c as hookFunction,O as patchFunction,A as registerMod};
@@ -0,0 +1,39 @@
1
+ interface ToastProps {
2
+ id: string;
3
+ title?: string;
4
+ message: string;
5
+ type: "info" | "warning" | "error" | "success";
6
+ duration: number;
7
+ }
8
+ interface DialogProps {
9
+ width: number;
10
+ type: "choice_one" | "choice_multiple";
11
+ title?: string;
12
+ body: string;
13
+ buttons: {
14
+ direction: "row" | "column";
15
+ list: {
16
+ text: string;
17
+ value?: unknown;
18
+ }[];
19
+ };
20
+ promise: {
21
+ resolve: (data: any) => void;
22
+ reject: (data: any) => void;
23
+ };
24
+ }
25
+ declare class ToastsManager {
26
+ generateToastId(): string;
27
+ process({ title, message, duration, type, id }: ToastProps): void;
28
+ info({ title, message, duration }: Omit<ToastProps, "type" | "id">): void;
29
+ success({ title, message, duration }: Omit<ToastProps, "type" | "id">): void;
30
+ warn({ title, message, duration }: Omit<ToastProps, "type" | "id">): void;
31
+ error({ title, message, duration }: Omit<ToastProps, "type" | "id">): void;
32
+ }
33
+ declare class DialogsManager {
34
+ showDialog({ type, title, body, buttons, width }: Omit<DialogProps, "promise">): Promise<unknown>;
35
+ }
36
+ export declare function initVirtualDOM(): void;
37
+ export declare const toastsManager: ToastsManager;
38
+ export declare const dialogsManager: DialogsManager;
39
+ export {};
package/dist/popups.js ADDED
@@ -0,0 +1 @@
1
+ import{getRelativeWidth as D,getRelativeX as x,getRelativeY as z}from"./ui";import{MOD_DATA as T}from"./index";import{useState as m,useEffect as g}from"react";import P from"react-dom/client";import{create as y}from"zustand";import C from"./assets/errorWarningIcon.svg";import E from"./assets/infoIcon.svg";import M from"./assets/successIcon.svg";import{Fragment as h,jsx as n,jsxs as d}from"react/jsx-runtime";const u=y(t=>({toasts:[],addToast:e=>t(o=>({toasts:[...o.toasts,e]})),removeToast:e=>t(o=>({toasts:o.toasts.filter(i=>i.id!==e)})),clearToasts:()=>t({toasts:[]})})),v=y(t=>({dialog:null,setDialog:e=>t({dialog:e}),clearDialog:()=>t({dialog:null})}));function k({children:t}){const[e,o]=m({}),i=u(s=>s.clearToasts);return g(()=>{const s=()=>{o({fontFamily:T.fontFamily??"sans-serif",top:z(5)+"px",left:x(5)+"px"})};return window.addEventListener("resize",s),s(),()=>{window.removeEventListener("resize",s)}},[]),n("div",{className:"zcToastsContainer",style:e,onClick:()=>{document.querySelectorAll(".zcToast").forEach(s=>{s.classList.add("exiting")}),setTimeout(i,300)},children:t})}function I({title:t,message:e,type:o,duration:i,id:s}){const[c,a]=m({}),[r,l]=m(!1);return g(()=>{const p=()=>{const S=MainCanvas.canvas.clientWidth,b=MainCanvas.canvas.clientHeight,f=Math.min(S,b)/100;a({position:"relative",width:"100%",borderRadius:"0.1em",fontSize:3*f+"px",padding:1.5*f+"px"})};window.addEventListener("resize",p),p();const w=setTimeout(()=>l(!0),i);return()=>{clearTimeout(w),window.removeEventListener("resize",p)}},[]),d("div",{className:`zcToast ${r&&"exiting"}`,"data-zc-toast-type":o,style:c,children:[d("div",{style:{display:"flex",gap:"1vw",position:"relative",zIndex:5},children:[n("img",{src:o==="info"?E:o==="success"?M:C,style:{width:"2vw",gap:"0.5em"}}),d("div",{children:[t&&e&&d(h,{children:[n("p",{children:t}),n("p",{style:{color:o==="info"?"#b8b8ff":o==="success"?"#c7f9c7":o==="error"?"#f8bcbc":"#ffeec5",fontSize:"70%"},children:e})]}),(!t&&e||t&&!e)&&n("p",{style:{position:"relative",zIndex:5},children:t||e})]})]}),n("div",{className:"zcToast-ProgressBar",style:{animation:`zcToast-progress ${i}ms linear 0s 1 alternate none`,position:"absolute",top:0,left:0,height:"100%"}})]})}function O({dialog:t}){const e=v(a=>a.clearDialog),[o,i]=m({}),[s,c]=m([]);return g(()=>{const a=()=>{const r=MainCanvas.canvas.clientWidth,l=MainCanvas.canvas.clientHeight,p=Math.min(r,l)/100;i({width:D(t.width),position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",background:"rgba(36, 36, 36, 0.96)",zIndex:20,fontFamily:T.fontFamily??"sans-serif",border:"none",padding:2*p})};return window.addEventListener("resize",a),a(),()=>{window.removeEventListener("resize",a)}},[]),d("dialog",{open:Object.keys(o).length>0,"data-zc-dialog-type":t.type,style:o,children:[t.title&&n("p",{style:{position:"absolute",top:0,left:0,fontWeight:"bold",color:"white",fontSize:"clamp(6px, 2vw, 24px)",padding:"0.25em",background:"#2d2d2d",width:"100%"},children:t.title}),n("p",{style:{padding:"1em",marginTop:"2vw",fontSize:"clamp(6px, 2vw, 24px)",color:"white"},children:t.body}),n("div",{style:{display:"flex",flexDirection:t.buttons.direction,justifyContent:"center",gap:"0.5vw"},children:t.buttons?.list?.map((a,r)=>n("button",{className:"zcDialogBtn","data-zc-picked":s.includes(r),style:{width:"100%",position:"relative"},onClick:()=>{t.type==="choice_one"?(e(),t.promise.resolve(a.value)):s.includes(r)?c(s.filter(l=>l!==r)):c([...s,r])},children:a.text}))}),t.type==="choice_multiple"&&n("button",{style:{cursor:"pointer",color:"white",background:"#4d4d4d",border:"none",marginTop:"1vw",fontSize:"clamp(8px,2.5vw,28px)",padding:"0.2em",borderRadius:"4px"},onClick:()=>{e(),t.promise.resolve(t.buttons.list.filter((a,r)=>s.includes(r)).map(a=>a.value))},children:"Confirm"})]})}class R{generateToastId(){const{toasts:e}=u.getState();return`${Date.now()}:${e.length+1}`}process({title:e,message:o,duration:i,type:s,id:c}){const{addToast:a,removeToast:r}=u.getState();a({id:c,title:e,message:o,duration:i,type:s}),setTimeout(()=>r(c),i+300)}info({title:e,message:o,duration:i}){const s=this.generateToastId();this.process({title:e,message:o,duration:i,type:"info",id:s})}success({title:e,message:o,duration:i}){const s=this.generateToastId();this.process({title:e,message:o,duration:i,type:"success",id:s})}warn({title:e,message:o,duration:i}){const s=this.generateToastId();this.process({title:e,message:o,duration:i,type:"warning",id:s})}error({title:e,message:o,duration:i}){const s=this.generateToastId();this.process({title:e,message:o,duration:i,type:"error",id:s})}}class L{showDialog({type:e,title:o,body:i,buttons:s,width:c}){const{setDialog:a}=v.getState();return new Promise((r,l)=>{a({width:c,type:e,title:o,body:i,buttons:s,promise:{resolve:r,reject:l}})})}}function N(){const t=u(o=>o.toasts),e=v(o=>o.dialog);return d(h,{children:[n(k,{children:t.map(({title:o,message:i,type:s,duration:c,id:a})=>n(I,{id:a,title:o,message:i,type:s,duration:c},a))}),e&&n(O,{dialog:e})]})}class W extends HTMLElement{disconnectedCallback(){ServerShowBeep("VirtualDOM was removed, chaos is coming...",4e3)}}function G(){customElements.define("zc-virtual-dom",W);const t=document.createElement("zc-virtual-dom");document.body.append(t),P.createRoot(document.getElementsByTagName("zc-virtual-dom")[0]).render(n(N,{}))}const K=new R,Q=new L;export{Q as dialogsManager,G as initVirtualDOM,K as toastsManager};
package/dist/styles.css CHANGED
@@ -1,99 +1 @@
1
- * {
2
- margin: 0;
3
- padding: 0;
4
- box-sizing: border-box;
5
- }
6
- .zcButton {
7
- cursor: pointer;
8
- background: var(--tmd-element, white);
9
- color: var(--tmd-text, black);
10
- border: 2px solid var(--tmd-accent, black);
11
- border-radius: 4px;
12
- }
13
- .zcButton:hover {
14
- background: var(--tmd-element-hover, #ebf7fe);
15
- border-color: var(--tmd-accent-hover, #7dd3fc);
16
- color: var(--tmd-accent-hover, #015a8c);
17
- }
18
- .zcButton .tooltip {
19
- position: absolute;
20
- color: black;
21
- text-align: center;
22
- padding: 4px;
23
- border-radius: 4px;
24
- background: #FFFF88;
25
- border: 2px solid #e7e787;
26
- width: max-content;
27
- min-height: 100%;
28
- visibility: hidden;
29
- z-index: 10;
30
- }
31
- .zcButton .tooltip[position=left] {
32
- right: calc(100% + 1vw);
33
- }
34
- .zcButton .tooltip[position=right] {
35
- left: calc(100% + 1vw);
36
- }
37
- .zcButton:hover .tooltip {
38
- visibility: visible;
39
- }
40
- .zcButton[data-zc-style=green] {
41
- background: rgb(124, 255, 124);
42
- border-color: rgb(82, 204, 82);
43
- color: black;
44
- }
45
- .zcButton[data-zc-style=green]:hover {
46
- background: rgb(94, 197, 94);
47
- color: black;
48
- }
49
- .zcButton[data-zc-style=inverted] {
50
- background: var(--tmd-accent, #303030);
51
- border: none;
52
- color: var(--tmd-text, white);
53
- }
54
- .zcButton[data-zc-style=inverted]:hover {
55
- background: var(--tmd-accent-hover, #474747);
56
- }
57
- .zcInput {
58
- background: var(--tmd-element, white);
59
- color: var(--tmd-text, black);
60
- padding: 2vw;
61
- border: 2px solid var(--tmd-accent, black);
62
- border-radius: 4px;
63
- }
64
- .zcInput::placeholder {
65
- color: var(--tmd-text, black);
66
- }
67
- .zcBackNextButton {
68
- display: flex;
69
- column-gap: 2vw;
70
- justify-content: center;
71
- align-items: center;
72
- background: var(--tmd-element, white);
73
- color: var(--tmd-text, black);
74
- border: 2px solid var(--tmd-accent, black);
75
- border-radius: 4px;
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
- }
96
- .zcDisabled {
97
- pointer-events: none;
98
- opacity: 0.6;
99
- }
1
+ *{margin:0;padding:0;box-sizing:border-box}.zcButton{cursor:pointer;background:var(--tmd-element, white);color:var(--tmd-text, black);border:2px solid var(--tmd-accent, black);border-radius:4px}.zcButton:hover{background:var(--tmd-element-hover, #ebf7fe);border-color:var(--tmd-accent-hover, #7dd3fc);color:var(--tmd-accent-hover, #015a8c)}.zcButton .tooltip{position:absolute;color:#000;text-align:center;padding:4px;border-radius:4px;background:#ff8;border:2px solid #e7e787;width:max-content;min-height:100%;visibility:hidden;z-index:10}.zcButton .tooltip[position=left]{right:calc(100% + 1vw)}.zcButton .tooltip[position=right]{left:calc(100% + 1vw)}.zcButton:hover .tooltip{visibility:visible}.zcButton[data-zc-style=green]{background:#7cff7c;border-color:#52cc52;color:#000}.zcButton[data-zc-style=green]:hover{background:#5ec55e;color:#000}.zcButton[data-zc-style=inverted]{background:var(--tmd-accent, #303030);border:none;color:var(--tmd-text, white)}.zcButton[data-zc-style=inverted]:hover{background:var(--tmd-accent-hover, #474747)}.zcInput{background:var(--tmd-element, white);color:var(--tmd-text, black);padding:2vw;border:2px solid var(--tmd-accent, black);border-radius:4px}.zcInput::placeholder{color:var(--tmd-text, black)}.zcBackNextButton{display:flex;column-gap:2vw;justify-content:center;align-items:center;background:var(--tmd-element, white);color:var(--tmd-text, black);border:2px solid var(--tmd-accent, black);border-radius:4px}.zcTabs{display:flex}.zcTabs button{cursor:pointer;width:100%;color:var(--tmd-text, black);background:none;border:none;border-bottom:2px solid var(--tmd-element, rgb(214, 214, 214));padding:.25em}.zcTabs button[data-opened=true]{font-weight:700;border-bottom:2px solid var(--tmd-accent, rgb(81, 81, 231))!important}.zcTabs button:hover{background:var(--tmd-element, rgb(235, 235, 235));border-bottom:2px solid var(--tmd-element-hover, rgb(149, 149, 149))}.zcToastsContainer{display:flex;flex-direction:column;gap:.25vw;cursor:pointer;position:fixed;z-index:10}.zcToast[data-zc-toast-type=info]{background:#5050df}.zcToast[data-zc-toast-type=success]{background:#42f08f}.zcToast[data-zc-toast-type=warning]{background:#ffdb82}.zcToast[data-zc-toast-type=error]{background:#d42e6b}@keyframes zcToast-progress{0%{width:0}to{width:100%}}@keyframes zcSlideInFromLeft{0%{transform:translate(-100%);opacity:0}to{transform:translate(0);opacity:1}}@keyframes zcSlideOutToLeft{0%{transform:translate(0);opacity:1}to{transform:translate(-100%);opacity:0}}.zcToast{animation:zcSlideInFromLeft .3s ease-out forwards}.zcToast.exiting{animation:zcSlideOutToLeft .3s ease-out forwards}.zcToast[data-zc-toast-type=info] .zcToast-ProgressBar{background:#6767ea}.zcToast[data-zc-toast-type=success] .zcToast-ProgressBar{background:#2fd178}.zcToast[data-zc-toast-type=warning] .zcToast-ProgressBar{background:#e1bd62}.zcToast[data-zc-toast-type=error] .zcToast-ProgressBar{background:#b7285c}.zcToast p{color:#fff}dialog[data-zc-dialog-type=choice_multiple] .zcDialogBtn:before{content:"";position:absolute;left:1vw;top:50%;transform:translateY(-50%);border:2px solid white;width:.5em;aspect-ratio:1/1;border-radius:50%}dialog[data-zc-dialog-type=choice_multiple] .zcDialogBtn[data-zc-picked=true]:before{background:#fff}.zcDialogBtn{cursor:pointer;background:#ffffff17;border:none;font-size:clamp(6px,2vw,24px);color:#fff;padding:.2em;border-radius:.5em}.zcDialogBtn:hover{background:#ffffff24}.zcDisabled{pointer-events:none;opacity:.6}
package/dist/ui.d.ts CHANGED
@@ -108,17 +108,40 @@ interface CreateTabArgs {
108
108
  width: number;
109
109
  tabs: {
110
110
  name: string;
111
- load: () => void;
111
+ load?: () => void;
112
+ run?: () => void;
112
113
  }[];
113
114
  currentTabName: string;
114
115
  anchor?: Anchor;
115
116
  }
117
+ interface DrawPolylineArrowArgs {
118
+ points: {
119
+ x: number;
120
+ y: number;
121
+ }[];
122
+ strokeColor?: string;
123
+ lineWidth?: number;
124
+ circleRadius?: number;
125
+ circleColor?: string;
126
+ }
127
+ export declare function getRelativeHeight(height: number): number;
128
+ export declare function getRelativeWidth(width: number): number;
129
+ export declare function getRelativeY(yPos: number, anchorPosition?: 'top' | 'bottom'): number;
130
+ export declare function getRelativeX(xPos: number, anchorPosition?: 'left' | 'right'): number;
131
+ export declare function setPosition(element: HTMLElement, xPos: number, yPos: number, anchor?: Anchor): void;
132
+ export declare function setSize(element: HTMLElement, width: number, height: number): void;
133
+ export declare function setFontSize(element: HTMLElement, targetFontSize: number): void;
134
+ export declare function setFontFamily(element: HTMLElement, fontFamily?: string): void;
135
+ export declare function setPadding(element: HTMLElement, targetPadding: number): void;
136
+ export declare function autosetFontSize(element: HTMLElement): void;
137
+ export declare function loadSubscreen(subscreen: BaseSubscreen): void;
116
138
  export declare function setPreviousSubscreen(): void;
117
139
  export declare function setSubscreen(subscreen: BaseSubscreen | null): void;
118
140
  export declare function getCurrentSubscreen(): BaseSubscreen;
119
141
  export declare abstract class BaseSubscreen {
120
142
  private htmlElements;
121
143
  private resizeEventListeners;
144
+ private tabRunHandler;
122
145
  get currentSubscreen(): BaseSubscreen | null;
123
146
  get name(): string;
124
147
  run(): void;
@@ -138,6 +161,7 @@ export declare abstract class BaseSubscreen {
138
161
  createImage({ x, y, width, src, }: CreateImageArgs): HTMLImageElement;
139
162
  createBackNextButton({ x, y, width, height, items, currentIndex, isBold, onChange, isDisabled }: CreateBackNextButtonArgs): HTMLDivElement;
140
163
  createTabs({ x, y, width, tabs, anchor, currentTabName }: CreateTabArgs): HTMLDivElement;
164
+ drawPolylineArrow({ points, strokeColor, lineWidth, circleRadius, circleColor }: DrawPolylineArrowArgs): void;
141
165
  }
142
166
  export declare function hookSubscreen(subscreenName: string, hook: (subscreen: BaseSubscreen) => void): void;
143
167
  export {};
package/dist/ui.js CHANGED
@@ -1,577 +1,5 @@
1
- import { MOD_DATA } from "./index";
2
- function getRelativeHeight(height) {
3
- return height * (MainCanvas.canvas.clientHeight / 1e3);
4
- }
5
- function getRelativeWidth(width) {
6
- return width * (MainCanvas.canvas.clientWidth / 2e3);
7
- }
8
- function getRelativeY(yPos, anchorPosition = "top") {
9
- const scaleY = MainCanvas.canvas.clientHeight / 1e3;
10
- return anchorPosition === "top" ? MainCanvas.canvas.offsetTop + yPos * scaleY : window.innerHeight - (MainCanvas.canvas.offsetTop + MainCanvas.canvas.clientHeight) + yPos * scaleY;
11
- }
12
- function getRelativeX(xPos, anchorPosition = "left") {
13
- const scaleX = MainCanvas.canvas.clientWidth / 2e3;
14
- return anchorPosition === "left" ? MainCanvas.canvas.offsetLeft + xPos * scaleX : window.innerWidth - (MainCanvas.canvas.offsetLeft + MainCanvas.canvas.clientWidth) + xPos * scaleX;
15
- }
16
- function setPosition(element, xPos, yPos, anchor = "top-left") {
17
- const yAnchor = anchor === "top-left" || anchor === "top-right" ? "top" : "bottom";
18
- const xAnchor = anchor === "top-left" || anchor === "bottom-left" ? "left" : "right";
19
- const y = getRelativeY(yPos, yAnchor);
20
- const x = getRelativeX(xPos, xAnchor);
21
- Object.assign(element.style, {
22
- position: "fixed",
23
- [xAnchor]: x + "px",
24
- [yAnchor]: y + "px"
25
- });
26
- }
27
- function setSize(element, width, height) {
28
- Object.assign(element.style, {
29
- width: getRelativeWidth(width) + "px",
30
- height: getRelativeHeight(height) + "px"
31
- });
32
- }
33
- function setFontSize(element, targetFontSize) {
34
- const canvasWidth = MainCanvas.canvas.clientWidth;
35
- const canvasHeight = MainCanvas.canvas.clientHeight;
36
- const scaleFactor = Math.min(canvasWidth, canvasHeight) / 100;
37
- const fontSize = targetFontSize * scaleFactor;
38
- Object.assign(element.style, {
39
- fontSize: fontSize + "px"
40
- });
41
- }
42
- function setFontFamily(element, fontFamily) {
43
- element.style.fontFamily = fontFamily ?? "sans-serif";
44
- }
45
- function setPadding(element, targetPadding) {
46
- const canvasWidth = MainCanvas.canvas.clientWidth;
47
- const canvasHeight = MainCanvas.canvas.clientHeight;
48
- const scaleFactor = Math.min(canvasWidth, canvasHeight) / 100;
49
- const paddingValue = targetPadding * scaleFactor;
50
- Object.assign(element.style, {
51
- padding: paddingValue + "px"
52
- });
53
- }
54
- function autosetFontSize(element) {
55
- const Font = MainCanvas.canvas.clientWidth <= MainCanvas.canvas.clientHeight * 2 ? MainCanvas.canvas.clientWidth / 50 : MainCanvas.canvas.clientHeight / 25;
56
- Object.assign(element.style, {
57
- fontSize: Font + "px"
58
- });
59
- }
60
- function loadSubscreen(subscreen) {
61
- subscreen.createButton({
62
- x: 1815,
63
- y: 75,
64
- width: 90,
65
- height: 90,
66
- icon: "Icons/Exit.png"
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
- }
76
- subscreen.load();
77
- if (subscreenHooks[subscreen.name]) {
78
- subscreenHooks[subscreen.name].forEach((hook) => hook(subscreen));
79
- }
80
- }
81
- function setPreviousSubscreen() {
82
- setSubscreen(previousSubscreen);
83
- }
84
- function setSubscreen(subscreen) {
85
- previousSubscreen = currentSubscreen;
86
- currentSubscreen = subscreen;
87
- if (currentSubscreen) loadSubscreen(currentSubscreen);
88
- if (previousSubscreen) previousSubscreen.unload();
89
- }
90
- function getCurrentSubscreen() {
91
- return currentSubscreen;
92
- }
93
- let currentSubscreen;
94
- let previousSubscreen = null;
95
- class BaseSubscreen {
96
- htmlElements = [];
97
- resizeEventListeners = [];
98
- get currentSubscreen() {
99
- return currentSubscreen;
100
- }
101
- get name() {
102
- return "";
103
- }
104
- run() {
105
- }
106
- load() {
107
- }
108
- unload() {
109
- this.htmlElements.forEach((e) => {
110
- e.remove();
111
- });
112
- this.resizeEventListeners.forEach((e) => {
113
- removeEventListener("resize", e);
114
- });
115
- }
116
- click() {
117
- }
118
- exit() {
119
- setPreviousSubscreen();
120
- }
121
- update() {
122
- }
123
- setPreviousSubscreen() {
124
- setPreviousSubscreen();
125
- }
126
- setSubscreen(subscreen) {
127
- setSubscreen(subscreen);
128
- }
129
- createButton({
130
- text,
131
- x,
132
- y,
133
- width,
134
- height,
135
- fontSize = "auto",
136
- anchor = "top-left",
137
- padding,
138
- style = "default",
139
- place = true,
140
- icon,
141
- iconAbsolutePosition = true,
142
- iconWidth,
143
- tooltip,
144
- onClick,
145
- isDisabled
146
- }) {
147
- const btn = document.createElement("button");
148
- btn.classList.add("zcButton");
149
- btn.setAttribute("data-zc-style", style);
150
- btn.style.display = "flex";
151
- btn.style.alignItems = "center";
152
- btn.style.justifyContent = "center";
153
- btn.style.columnGap = "1.25vw";
154
- setFontFamily(btn, MOD_DATA.fontFamily);
155
- if (icon) {
156
- const img = document.createElement("img");
157
- img.src = icon;
158
- if (iconWidth) img.style.width = iconWidth;
159
- else img.style.height = "80%";
160
- if (text && iconAbsolutePosition) {
161
- img.style.position = "absolute";
162
- img.style.left = "1vw";
163
- }
164
- if (text && !iconAbsolutePosition) btn.style.justifyContent = "";
165
- btn.append(img);
166
- }
167
- if (text) {
168
- const span = document.createElement("span");
169
- span.textContent = text;
170
- if (icon && !iconAbsolutePosition && iconWidth) {
171
- span.style.width = "100%";
172
- span.style.marginRight = iconWidth;
173
- }
174
- btn.append(span);
175
- }
176
- if (tooltip) {
177
- const tooltipEl = document.createElement("span");
178
- tooltipEl.classList.add("tooltip");
179
- tooltipEl.setAttribute("position", tooltip.position);
180
- tooltipEl.textContent = tooltip.text;
181
- btn.append(tooltipEl);
182
- }
183
- const setProperties = () => {
184
- if (typeof x === "number" && typeof y === "number") setPosition(btn, x, y, anchor);
185
- setSize(btn, width, height);
186
- if (padding) setPadding(btn, padding);
187
- if (fontSize === "auto") autosetFontSize(btn);
188
- else setFontSize(btn, fontSize);
189
- };
190
- setProperties();
191
- if (typeof isDisabled === "function" && isDisabled()) btn.classList.add("zcDisabled");
192
- btn.addEventListener("click", () => {
193
- if (typeof isDisabled === "function" && !isDisabled() && typeof onClick === "function") {
194
- onClick();
195
- }
196
- if (typeof isDisabled === "function" && isDisabled()) btn.classList.add("zcDisabled");
197
- });
198
- window.addEventListener("resize", setProperties);
199
- if (place) document.body.append(btn);
200
- this.resizeEventListeners.push(setProperties);
201
- this.htmlElements.push(btn);
202
- return btn;
203
- }
204
- createText({
205
- text,
206
- color,
207
- x,
208
- y,
209
- width,
210
- height,
211
- withBackground = false,
212
- fontSize = "auto",
213
- anchor = "top-left",
214
- padding,
215
- place = true
216
- }) {
217
- const p = document.createElement("p");
218
- p.innerHTML = text;
219
- p.style.color = color ?? "var(--tmd-text, black)";
220
- if (withBackground) p.style.background = "var(--tmd-element,rgb(239, 239, 239))";
221
- setFontFamily(p, MOD_DATA.fontFamily);
222
- const setProperties = () => {
223
- if (typeof x === "number" && typeof y === "number") setPosition(p, x, y, anchor);
224
- setSize(p, width, height);
225
- if (padding) setPadding(p, padding);
226
- if (fontSize === "auto") autosetFontSize(p);
227
- else setFontSize(p, fontSize);
228
- };
229
- setProperties();
230
- window.addEventListener("resize", setProperties);
231
- if (place) document.body.append(p);
232
- this.resizeEventListeners.push(setProperties);
233
- this.htmlElements.push(p);
234
- return p;
235
- }
236
- createInput({
237
- value,
238
- placeholder,
239
- x,
240
- y,
241
- width,
242
- height,
243
- textArea = false,
244
- fontSize = "auto",
245
- anchor = "top-left",
246
- padding,
247
- place = true,
248
- onChange,
249
- onInput,
250
- isDisabled
251
- }) {
252
- const input = document.createElement(textArea ? "textarea" : "input");
253
- input.classList.add("zcInput");
254
- if (placeholder) input.placeholder = placeholder;
255
- if (value) input.value = value;
256
- setFontFamily(input, MOD_DATA.fontFamily);
257
- const setProperties = () => {
258
- if (typeof x === "number" && typeof y === "number") setPosition(input, x, y, anchor);
259
- setSize(input, width, height);
260
- if (padding) setPadding(input, padding);
261
- if (fontSize === "auto") autosetFontSize(input);
262
- else setFontSize(input, fontSize);
263
- };
264
- setProperties();
265
- if (typeof isDisabled === "function" && isDisabled()) input.classList.add("zcDisabled");
266
- input.addEventListener("change", () => {
267
- if (typeof isDisabled === "function" && isDisabled()) return input.classList.add("zcDisabled");
268
- if (typeof onChange === "function") onChange();
269
- });
270
- input.addEventListener("input", () => {
271
- if (typeof isDisabled === "function" && isDisabled()) return input.classList.add("zcDisabled");
272
- if (typeof onInput === "function") onInput();
273
- });
274
- window.addEventListener("resize", setProperties);
275
- if (place) document.body.append(input);
276
- this.resizeEventListeners.push(setProperties);
277
- this.htmlElements.push(input);
278
- return input;
279
- }
280
- createCheckbox({
281
- text,
282
- x,
283
- y,
284
- isChecked,
285
- width,
286
- anchor = "top-left",
287
- place = true,
288
- isDisabled,
289
- onChange
290
- }) {
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");
300
- const p = document.createElement("p");
301
- p.textContent = text;
302
- p.style.color = "var(--tmd-text, black)";
303
- setFontFamily(p, MOD_DATA.fontFamily);
304
- const setProperties = () => {
305
- if (typeof x === "number" && typeof y === "number") setPosition(checkbox, x, y, anchor);
306
- if (width) checkbox.style.width = getRelativeWidth(width) + "px";
307
- setFontSize(p, 5);
308
- };
309
- setProperties();
310
- if (typeof isDisabled === "function" && isDisabled()) checkbox.classList.add("zcDisabled");
311
- checkbox.addEventListener("change", () => {
312
- if (typeof isDisabled === "function" && isDisabled()) return checkbox.classList.add("zcDisabled");
313
- if (typeof onChange === "function") onChange();
314
- });
315
- window.addEventListener("resize", setProperties);
316
- checkbox.append(input, p);
317
- if (place) document.body.append(checkbox);
318
- this.resizeEventListeners.push(setProperties);
319
- this.htmlElements.push(checkbox, p);
320
- return checkbox;
321
- }
322
- createScrollView({
323
- scroll,
324
- x,
325
- y,
326
- width,
327
- height,
328
- anchor = "top-left"
329
- }) {
330
- const div = document.createElement("div");
331
- if (scroll === "all") div.style.overflow = "scroll";
332
- if (scroll === "x") div.style.overflowX = "scroll";
333
- if (scroll === "y") div.style.overflowY = "scroll";
334
- const setProperties = () => {
335
- if (typeof x === "number" && typeof y === "number") setPosition(div, x, y, anchor);
336
- setSize(div, width, height);
337
- };
338
- setProperties();
339
- window.addEventListener("resize", setProperties);
340
- document.body.append(div);
341
- this.resizeEventListeners.push(setProperties);
342
- this.htmlElements.push(div);
343
- return div;
344
- }
345
- createInputList({
346
- x,
347
- y,
348
- width,
349
- height,
350
- title,
351
- value,
352
- anchor = "top-left",
353
- place = true,
354
- numbersOnly = false,
355
- isDisabled,
356
- onChange
357
- }) {
358
- const items = [];
359
- const div = document.createElement("div");
360
- div.style.cssText = `
1
+ import{getThemedColorsModule as W,MOD_DATA as L}from"./index";function j(s){return s*(MainCanvas.canvas.clientHeight/1e3)}function I(s){return s*(MainCanvas.canvas.clientWidth/2e3)}function D(s,e="top"){const o=MainCanvas.canvas.clientHeight/1e3;return e==="top"?MainCanvas.canvas.offsetTop+s*o:window.innerHeight-(MainCanvas.canvas.offsetTop+MainCanvas.canvas.clientHeight)+s*o}function O(s,e="left"){const o=MainCanvas.canvas.clientWidth/2e3;return e==="left"?MainCanvas.canvas.offsetLeft+s*o:window.innerWidth-(MainCanvas.canvas.offsetLeft+MainCanvas.canvas.clientWidth)+s*o}function E(s,e,o,c="top-left"){const f=c==="top-left"||c==="top-right"?"top":"bottom",a=c==="top-left"||c==="bottom-left"?"left":"right",t=D(o,f),d=O(e,a);Object.assign(s.style,{position:"fixed",[a]:d+"px",[f]:t+"px"})}function C(s,e,o){Object.assign(s.style,{width:I(e)+"px",height:j(o)+"px"})}function H(s,e){const o=MainCanvas.canvas.clientWidth,c=MainCanvas.canvas.clientHeight,f=Math.min(o,c)/100,a=e*f;Object.assign(s.style,{fontSize:a+"px"})}function z(s,e){s.style.fontFamily=e??"sans-serif"}function P(s,e){const o=MainCanvas.canvas.clientWidth,c=MainCanvas.canvas.clientHeight,f=Math.min(o,c)/100,a=e*f;Object.assign(s.style,{padding:a+"px"})}function k(s){const e=MainCanvas.canvas.clientWidth<=MainCanvas.canvas.clientHeight*2?MainCanvas.canvas.clientWidth/50:MainCanvas.canvas.clientHeight/25;Object.assign(s.style,{fontSize:e+"px"})}function V(s){s.createButton({x:1815,y:75,width:90,height:90,icon:"Icons/Exit.png"}).addEventListener("click",()=>s.exit()),s.name&&s.createText({text:s.name,x:100,y:60,fontSize:10}),s.load(),M[s.name]&&M[s.name].forEach(e=>e(s))}function R(){N(S)}function N(s){S=A,A=s,A&&V(A),S&&S.unload()}function X(){return A}let A,S=null;class Y{htmlElements=[];resizeEventListeners=[];tabRunHandler;get currentSubscreen(){return A}get name(){return""}run(){this.tabRunHandler&&this.tabRunHandler()}load(){}unload(){this.htmlElements.forEach(e=>{e.remove()}),this.resizeEventListeners.forEach(e=>{removeEventListener("resize",e)})}click(){}exit(){R()}update(){}setPreviousSubscreen(){R()}setSubscreen(e){N(e)}createButton({text:e,x:o,y:c,width:f,height:a,fontSize:t="auto",anchor:d="top-left",padding:l,style:h="default",place:n=!0,icon:p,iconAbsolutePosition:r=!0,iconWidth:i,tooltip:m,onClick:b,isDisabled:g}){const u=document.createElement("button");if(u.classList.add("zcButton"),u.setAttribute("data-zc-style",h),u.style.display="flex",u.style.alignItems="center",u.style.justifyContent="center",u.style.columnGap="1.25vw",z(u,L.fontFamily),p){const v=document.createElement("img");v.src=p,i?v.style.width=i:v.style.height="80%",e&&r&&(v.style.position="absolute",v.style.left="1vw"),e&&!r&&(u.style.justifyContent=""),u.append(v)}if(e){const v=document.createElement("span");v.textContent=e,p&&!r&&i&&(v.style.width="100%",v.style.marginRight=i),u.append(v)}if(m){const v=document.createElement("span");v.classList.add("tooltip"),v.setAttribute("position",m.position),v.textContent=m.text,u.append(v)}const T=()=>{typeof o=="number"&&typeof c=="number"&&E(u,o,c,d),C(u,f,a),l&&P(u,l),t==="auto"?k(u):H(u,t)};return T(),typeof g=="function"&&g()&&u.classList.add("zcDisabled"),u.addEventListener("click",()=>{if(typeof g=="function"&&g())return u.classList.add("zcDisabled");typeof b=="function"&&b()}),window.addEventListener("resize",T),n&&document.body.append(u),this.resizeEventListeners.push(T),this.htmlElements.push(u),u}createText({text:e,color:o,x:c,y:f,width:a,height:t,withBackground:d=!1,fontSize:l="auto",anchor:h="top-left",padding:n,place:p=!0}){const r=document.createElement("p");r.innerHTML=e,r.style.color=o??"var(--tmd-text, black)",d&&(r.style.background="var(--tmd-element,rgb(239, 239, 239))"),z(r,L.fontFamily);const i=()=>{typeof c=="number"&&typeof f=="number"&&E(r,c,f,h),C(r,a,t),n&&P(r,n),l==="auto"?k(r):H(r,l)};return i(),window.addEventListener("resize",i),p&&document.body.append(r),this.resizeEventListeners.push(i),this.htmlElements.push(r),r}createInput({value:e,placeholder:o,x:c,y:f,width:a,height:t,textArea:d=!1,fontSize:l="auto",anchor:h="top-left",padding:n,place:p=!0,onChange:r,onInput:i,isDisabled:m}){const b=document.createElement(d?"textarea":"input");b.classList.add("zcInput"),o&&(b.placeholder=o),e&&(b.value=e),z(b,L.fontFamily);const g=()=>{typeof c=="number"&&typeof f=="number"&&E(b,c,f,h),C(b,a,t),n&&P(b,n),l==="auto"?k(b):H(b,l)};return g(),typeof m=="function"&&m()&&b.classList.add("zcDisabled"),b.addEventListener("change",()=>{if(typeof m=="function"&&m())return b.classList.add("zcDisabled");typeof r=="function"&&r()}),b.addEventListener("input",()=>{if(typeof m=="function"&&m())return b.classList.add("zcDisabled");typeof i=="function"&&i()}),window.addEventListener("resize",g),p&&document.body.append(b),this.resizeEventListeners.push(g),this.htmlElements.push(b),b}createCheckbox({text:e,x:o,y:c,isChecked:f,width:a,anchor:t="top-left",place:d=!0,isDisabled:l,onChange:h}){const n=document.createElement("div");n.style.display="flex",n.style.alignItems="center",n.style.columnGap="1vw";const p=document.createElement("input");p.type="checkbox",p.checked=f,p.style.borderRadius="min(0.8dvh, 0.3dvw)",p.classList.add("zcCheckbox","checkbox");const r=document.createElement("p");r.textContent=e,r.style.color="var(--tmd-text, black)",z(r,L.fontFamily);const i=()=>{typeof o=="number"&&typeof c=="number"&&E(n,o,c,t),a&&(n.style.width=I(a)+"px"),H(r,5)};return i(),typeof l=="function"&&l()&&n.classList.add("zcDisabled"),n.addEventListener("change",()=>{if(typeof l=="function"&&l())return n.classList.add("zcDisabled");typeof h=="function"&&h()}),window.addEventListener("resize",i),n.append(p,r),d&&document.body.append(n),this.resizeEventListeners.push(i),this.htmlElements.push(n,r),n}createScrollView({scroll:e,x:o,y:c,width:f,height:a,anchor:t="top-left"}){const d=document.createElement("div");e==="all"&&(d.style.overflow="scroll"),e==="x"&&(d.style.overflowX="scroll"),e==="y"&&(d.style.overflowY="scroll");const l=()=>{typeof o=="number"&&typeof c=="number"&&E(d,o,c,t),C(d,f,a)};return l(),window.addEventListener("resize",l),document.body.append(d),this.resizeEventListeners.push(l),this.htmlElements.push(d),d}createInputList({x:e,y:o,width:c,height:f,title:a,value:t,anchor:d="top-left",place:l=!0,numbersOnly:h=!1,isDisabled:n,onChange:p}){const r=[],i=document.createElement("div");i.style.cssText=`
361
2
  display: flex; flex-direction: column; gap: 1vw; border: 2px solid var(--tmd-accent, black);
362
- border-radius: 4px; padding: 0.75vw;
363
- `;
364
- setFontFamily(div, MOD_DATA.fontFamily);
365
- const buttonsElement = document.createElement("div");
366
- buttonsElement.style.cssText = "display: flex; justify-content: center; column-gap: 1vw; width: 100%;";
367
- const titleElement = document.createElement("b");
368
- titleElement.textContent = title + ":";
369
- titleElement.style.cssText = "width: 100%; font-size: clamp(10px, 2.4vw, 24px); color: var(--tmd-text, black);";
370
- const itemsElement = document.createElement("div");
371
- itemsElement.style.cssText = `display: flex; gap: 1vw; flex-wrap: wrap; align-content: flex-start;
372
- overflow-y: scroll;`;
373
- const input = document.createElement("input");
374
- 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);";
375
- const addButton = (icon, onClick) => {
376
- const b = document.createElement("button");
377
- 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;";
378
- const img = DrawGetImage(icon);
379
- img.style.cssText = "width: 90%;";
380
- b.append(img);
381
- buttonsElement.append(b);
382
- b.addEventListener("click", onClick);
383
- };
384
- const addItem = (text) => {
385
- if (typeof isDisabled === "function" && isDisabled()) return div.classList.add("zcDisabled");
386
- const item = document.createElement("div");
387
- 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);";
388
- item.textContent = text;
389
- itemsElement.insertBefore(item, input);
390
- item.addEventListener("click", (e) => {
391
- if (item.style.border === "") item.style.border = "2px solid red";
392
- else item.style.border = "";
393
- e.stopPropagation();
394
- });
395
- items.push(text);
396
- onChange(numbersOnly ? items.map((i) => parseInt(i)) : items);
397
- };
398
- const setProperties = () => {
399
- if (typeof x === "number" && typeof y === "number") setPosition(div, x, y, anchor);
400
- setSize(div, width, height);
401
- };
402
- addButton("Icons/Cancel.png", () => {
403
- if (typeof isDisabled === "function" && isDisabled()) return div.classList.add("zcDisabled");
404
- itemsElement.innerHTML = "";
405
- items.splice(0, items.length);
406
- itemsElement.append(input);
407
- value.forEach((v) => addItem(String(v)));
408
- });
409
- addButton("Icons/Trash.png", () => {
410
- if (typeof isDisabled === "function" && isDisabled()) div.classList.add("zcDisabled");
411
- for (const c of [...itemsElement.children]) {
412
- if (c.getAttribute("style").includes("border: 2px solid red;")) {
413
- items.splice(items.indexOf(c.textContent), 1);
414
- c.remove();
415
- }
416
- }
417
- });
418
- setProperties();
419
- if (typeof isDisabled === "function" && isDisabled()) div.classList.add("zcDisabled");
420
- window.addEventListener("resize", setProperties);
421
- input.addEventListener("keypress", (e) => {
422
- if (document.activeElement === input) {
423
- switch (e.key) {
424
- case "Enter":
425
- if (numbersOnly && Number.isNaN(parseInt(input.value))) return;
426
- if (!numbersOnly && input.value.trim() === "") return;
427
- addItem(input.value);
428
- input.value = "";
429
- break;
430
- }
431
- }
432
- });
433
- div.addEventListener("click", (e) => {
434
- if (e.currentTarget == div) input.focus();
435
- });
436
- itemsElement.append(input);
437
- div.append(buttonsElement, titleElement, itemsElement);
438
- document.body.append(div);
439
- this.resizeEventListeners.push(setProperties);
440
- this.htmlElements.push(div);
441
- value.forEach((v) => addItem(String(v)));
442
- return div;
443
- }
444
- createImage({
445
- x,
446
- y,
447
- width,
448
- src
449
- }) {
450
- const img = document.createElement("img");
451
- img.src = src;
452
- const setProperties = () => {
453
- if (typeof x === "number" && typeof y === "number") setPosition(img, x, y);
454
- setSize(img, width, 0);
455
- img.style.height = "auto";
456
- };
457
- setProperties();
458
- window.addEventListener("resize", setProperties);
459
- document.body.append(img);
460
- this.resizeEventListeners.push(setProperties);
461
- this.htmlElements.push(img);
462
- return img;
463
- }
464
- createBackNextButton({
465
- x,
466
- y,
467
- width,
468
- height,
469
- items,
470
- currentIndex,
471
- isBold = false,
472
- onChange,
473
- isDisabled
474
- }) {
475
- const div = document.createElement("div");
476
- div.classList.add("zcBackNextButton");
477
- setFontFamily(div, MOD_DATA.fontFamily);
478
- const backBtn = document.createElement("button");
479
- backBtn.style.cssText = "position: absolute; left: 1vw; font-size: 3.5vw; aspect-ratio: 1/1; height: 140%;";
480
- backBtn.classList.add("zcButton");
481
- backBtn.textContent = "\u{1F844}";
482
- backBtn.addEventListener("click", () => {
483
- if (typeof isDisabled === "function" && isDisabled()) return div.classList.add("zcDisabled");
484
- if (currentIndex === 0) return;
485
- currentIndex--;
486
- text.textContent = items[currentIndex][0];
487
- if (typeof onChange === "function") onChange(items[currentIndex][1]);
488
- });
489
- const nextBtn = document.createElement("button");
490
- nextBtn.style.cssText = "position: absolute; right: 1vw; font-size: 3.5vw; aspect-ratio: 1/1; height: 140%;";
491
- nextBtn.classList.add("zcButton");
492
- nextBtn.textContent = "\u{1F846}";
493
- nextBtn.addEventListener("click", () => {
494
- if (typeof isDisabled === "function" && isDisabled()) return div.classList.add("zcDisabled");
495
- if (currentIndex === items.length - 1) return;
496
- currentIndex++;
497
- text.textContent = items[currentIndex][0];
498
- if (typeof onChange === "function") onChange(items[currentIndex][1]);
499
- });
500
- const text = document.createElement("p");
501
- if (isBold) text.style.fontWeight = "bold";
502
- text.textContent = items[currentIndex][0];
503
- div.append(backBtn, text, nextBtn);
504
- const setProperties = () => {
505
- if (typeof x === "number" && typeof y === "number") setPosition(div, x, y);
506
- setSize(div, width, height);
507
- autosetFontSize(text);
508
- };
509
- setProperties();
510
- if (typeof isDisabled === "function" && isDisabled()) div.classList.add("zcDisabled");
511
- window.addEventListener("resize", setProperties);
512
- document.body.append(div);
513
- this.resizeEventListeners.push(setProperties);
514
- this.htmlElements.push(div);
515
- return div;
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
- }
565
- }
566
- let subscreenHooks = {};
567
- function hookSubscreen(subscreenName, hook) {
568
- if (!subscreenHooks[subscreenName]) subscreenHooks[subscreenName] = [];
569
- subscreenHooks[subscreenName].push(hook);
570
- }
571
- export {
572
- BaseSubscreen,
573
- getCurrentSubscreen,
574
- hookSubscreen,
575
- setPreviousSubscreen,
576
- setSubscreen
577
- };
3
+ border-radius: 4px; padding: 0.75vw; background: var(--tmd-element, none);
4
+ `,z(i,L.fontFamily);const m=document.createElement("div");m.style.cssText="display: flex; justify-content: center; column-gap: 1vw; width: 100%;";const b=document.createElement("b");b.textContent=a+":",b.style.cssText="width: 100%; font-size: clamp(10px, 2.4vw, 24px); color: var(--tmd-text, black);";const g=document.createElement("div");g.style.cssText=`display: flex; gap: 1vw; flex-wrap: wrap; align-content: flex-start;
5
+ overflow-y: scroll;`;const u=document.createElement("input");u.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);";const T=(y,x)=>{const w=document.createElement("button");w.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;";const F=DrawGetImage(y);F.style.cssText="width: 90%;",w.append(F),m.append(w),w.addEventListener("click",x)},v=y=>{if(typeof n=="function"&&n())return i.classList.add("zcDisabled");const x=document.createElement("div");x.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);",x.textContent=y,g.insertBefore(x,u),x.addEventListener("click",w=>{x.style.border===""?x.style.border="2px solid red":x.style.border="",w.stopPropagation()}),r.push(y),typeof p=="function"&&p(h?r.map(w=>parseInt(w)):r)},B=()=>{typeof e=="number"&&typeof o=="number"&&E(i,e,o,d),C(i,c,f)};return T("Icons/Cancel.png",()=>{if(typeof n=="function"&&n())return i.classList.add("zcDisabled");g.innerHTML="",r.splice(0,r.length),g.append(u),t.forEach(y=>v(String(y)))}),T("Icons/Trash.png",()=>{typeof n=="function"&&n()&&i.classList.add("zcDisabled");for(const y of[...g.children])y.getAttribute("style").includes("border: 2px solid red;")&&(r.splice(r.indexOf(y.textContent),1),y.remove())}),B(),typeof n=="function"&&n()&&i.classList.add("zcDisabled"),window.addEventListener("resize",B),u.addEventListener("keypress",y=>{if(document.activeElement===u)switch(y.key){case"Enter":if(h&&Number.isNaN(parseInt(u.value))||!h&&u.value.trim()==="")return;v(u.value),u.value="";break}}),i.addEventListener("click",y=>{y.currentTarget==i&&u.focus()}),g.append(u),i.append(m,b,g),document.body.append(i),this.resizeEventListeners.push(B),this.htmlElements.push(i),t.forEach(y=>v(String(y))),i}createImage({x:e,y:o,width:c,src:f}){const a=document.createElement("img");a.src=f;const t=()=>{typeof e=="number"&&typeof o=="number"&&E(a,e,o),C(a,c,0),a.style.height="auto"};return t(),window.addEventListener("resize",t),document.body.append(a),this.resizeEventListeners.push(t),this.htmlElements.push(a),a}createBackNextButton({x:e,y:o,width:c,height:f,items:a,currentIndex:t,isBold:d=!1,onChange:l,isDisabled:h}){const n=document.createElement("div");n.classList.add("zcBackNextButton"),z(n,L.fontFamily);const p=document.createElement("button");p.style.cssText="position: absolute; left: 1vw; font-size: 3.5vw; aspect-ratio: 1/1; height: 140%;",p.classList.add("zcButton"),p.textContent="\u{1F844}",p.addEventListener("click",()=>{if(typeof h=="function"&&h())return n.classList.add("zcDisabled");t!==0&&(t--,i.textContent=a[t][0],typeof l=="function"&&l(a[t][1]))});const r=document.createElement("button");r.style.cssText="position: absolute; right: 1vw; font-size: 3.5vw; aspect-ratio: 1/1; height: 140%;",r.classList.add("zcButton"),r.textContent="\u{1F846}",r.addEventListener("click",()=>{if(typeof h=="function"&&h())return n.classList.add("zcDisabled");t!==a.length-1&&(t++,i.textContent=a[t][0],typeof l=="function"&&l(a[t][1]))});const i=document.createElement("p");d&&(i.style.fontWeight="bold"),i.textContent=a[t][0],n.append(p,i,r);const m=()=>{typeof e=="number"&&typeof o=="number"&&E(n,e,o),C(n,c,f),k(i)};return m(),typeof h=="function"&&h()&&n.classList.add("zcDisabled"),window.addEventListener("resize",m),document.body.append(n),this.resizeEventListeners.push(m),this.htmlElements.push(n),n}createTabs({x:e,y:o,width:c,tabs:f,anchor:a="top-left",currentTabName:t}){let d=[];const l=document.createElement("div");l.classList.add("zcTabs"),z(l,L.fontFamily),f.forEach(n=>{const p=()=>{for(const m of l.children)m.removeAttribute("data-opened");for(const m of d)m instanceof Node&&document.body.removeChild(m);d=[],r.setAttribute("data-opened","true");const i=document.body.append.bind(document.body);document.body.append=(...m)=>{d.push(...m),i(...m)},n.load(),this.tabRunHandler=n.run,document.body.append=i},r=document.createElement("button");r.textContent=n.name,n.name===t&&p(),r.addEventListener("click",p),l.append(r)});const h=()=>{typeof e=="number"&&typeof o=="number"&&E(l,e,o,a),c&&(l.style.width=I(c)+"px"),k(l)};return h(),window.addEventListener("resize",h),document.body.append(l),this.resizeEventListeners.push(h),this.htmlElements.push(l),l}drawPolylineArrow({points:e,strokeColor:o=W()?.base?.text??"black",lineWidth:c=2,circleRadius:f=5,circleColor:a=W()?.base?.text??"black"}){if(e.length<2)return;const t=MainCanvas.canvas.getContext("2d");t.save(),t.strokeStyle=o,t.lineWidth=c,t.fillStyle=a,t.beginPath(),t.moveTo(e[0].x,e[0].y);for(let d=1;d<e.length;d++)t.lineTo(e[d].x,e[d].y);t.stroke(),t.beginPath(),t.arc(e[0].x,e[0].y,f,0,Math.PI*2),t.fill(),t.beginPath(),t.arc(e[e.length-1].x,e[e.length-1].y,f,0,Math.PI*2),t.fill(),t.restore()}}const M={};function _(s,e){M[s]||(M[s]=[]),M[s].push(e)}export{Y as BaseSubscreen,k as autosetFontSize,X as getCurrentSubscreen,j as getRelativeHeight,I as getRelativeWidth,O as getRelativeX,D as getRelativeY,_ as hookSubscreen,V as loadSubscreen,z as setFontFamily,H as setFontSize,P as setPadding,E as setPosition,R as setPreviousSubscreen,C as setSize,N as setSubscreen};
package/dist/wardrobe.js CHANGED
@@ -1,100 +1 @@
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
- };
1
+ function f(e){const s=Asset.includes(e)?e:e.Asset;if(!Asset.includes(s))throw new Error("Failed to convert item to asset");return s}function n(e){const s=AssetGroup.includes(e)?e:Asset.includes(e)?e.Group:e.Asset.Group;if(!AssetGroup.includes(s))throw new Error("Failed to convert item to group");return s}function y(e){return AssetGroup.some(s=>s.Name===e)}function G(e,s=!1){const t=n(e);return t.Category==="Appearance"&&t.AllowNone&&t.Clothing&&(s||!t.BodyCosplay)}function A(e){const s=n(e);return s.Category==="Appearance"&&s.AllowNone&&s.Clothing&&s.BodyCosplay}function i(e){const s=n(e);return s.Category==="Appearance"&&!s.Clothing}function m(e,s=["ItemNeck","ItemNeckAccessories","ItemNeckRestraints"]){const t=n(e);return t.Category!=="Item"||t.BodyCosplay?!1:!s.includes(t.Name)}function C(e,s,t=["Cosplay","Binds","Collar","Locks"],a=e,u=!1){s=s.filter(r=>!!r&&!i(r)),t.includes("Cosplay")||(s=s.filter(r=>!A(r))),t.includes("Binds")||(s=s.filter(r=>!m(r))),t.includes("Collar")||(s=s.filter(r=>r.Asset.Group.Name!=="ItemNeck")),t.includes("Locks")||(s=s.map(r=>(r.Property?.LockedBy&&delete r.Property.LockedBy,r)));const p=[];if(u)e.Appearance=e.Appearance.filter(r=>i(r));else{const r=ValidationCreateDiffParams(a,Player.MemberNumber);e.Appearance=e.Appearance.filter(o=>i(o)||!ValidationCanRemoveItem(o,r,!!s.find(l=>l?.Asset?.Group?.Name===o?.Asset?.Group?.Name))||o.Property?.LockedBy&&!DialogCanUnlock(a,o)||o.Asset.Name==="SlaveCollar"&&a.IsPlayer()?(p.push(o.Asset.Group.Name),!0):!1)}for(const r of s){if(!u&&(!c(a,r.Asset.Group.Name,r.Asset)||p.includes(r.Asset.Group.Name)))continue;CharacterAppearanceSetItem(e,r.Asset.Group.Name,r.Asset,r.Color);const o=InventoryGet(e,r.Asset.Group.Name);r.Craft&&CraftingValidate(r.Craft,r.Asset)!==CraftingStatusType.CRITICAL_ERROR&&(o.Craft=r.Craft),r.Property&&(ValidationSanitizeProperties(e,r),o.Property=r.Property)}CharacterRefresh(e),e.IsNpc()||ChatRoomCharacterUpdate(e)}function c(e,s,t){return!ValidationIsItemBlockedOrLimited(e,Player.MemberNumber,s,t.Name)&&ServerChatRoomGetAllowItem(Player,e)}function I(e,s){return s.map(t=>ServerBundledItemToAppearanceItem(e,t))}export{C as importAppearance,y as isAssetGroupName,m as isBind,i as isBody,G as isCloth,A as isCosplay,I as serverAppearanceBundleToAppearance,f as smartGetAsset,n as smartGetAssetGroup,c as validationCanAccessCheck};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zois-core",
3
- "version": "1.0.6",
3
+ "version": "1.0.8",
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",
@@ -27,14 +27,23 @@
27
27
  "./wardrobe": {
28
28
  "import": "./dist/wardrobe.js",
29
29
  "types": "./dist/wardrobe.d.ts"
30
+ },
31
+ "./popups": {
32
+ "import": "./dist/popups.js",
33
+ "types": "./dist/popups.d.ts"
30
34
  }
31
35
  },
32
36
  "dependencies": {
33
- "bondage-club-mod-sdk": "^1.2.0"
37
+ "bondage-club-mod-sdk": "^1.2.0",
38
+ "react": "^19.1.0",
39
+ "react-dom": "^19.1.0",
40
+ "zustand": "^5.0.5"
34
41
  },
35
42
  "devDependencies": {
36
- "bc-stubs": "116.0.0-Beta.1",
37
- "esbuild": "^0.25.4",
43
+ "@types/react": "^19.1.8",
44
+ "@types/react-dom": "^19.1.6",
45
+ "bc-stubs": "117.0.0-Beta.1",
46
+ "esbuild": "^0.25.5",
38
47
  "nodemon": "^3.1.10",
39
48
  "typescript": "^5.8.3"
40
49
  },