bc-deeplib 1.0.1 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.types/declarations.d.ts +15 -0
- package/.types/elements.d.ts +38 -0
- package/.types/type-override.d.ts +3 -0
- package/README.md +1 -1
- package/package.json +28 -12
- package/public/styles/DeepLib.css +206 -0
- package/public/styles/Gratitude.css +23 -0
- package/src/Base/BaseModule.ts +45 -0
- package/src/Base/BaseSubscreen.ts +198 -0
- package/src/Base/Initialization.ts +83 -0
- package/src/Base/Modules.ts +16 -0
- package/src/Base/SettingDefinitions.ts +14 -0
- package/src/DeepLib.ts +33 -0
- package/src/Migrators/BaseMigrator.ts +4 -0
- package/src/Models/Base.ts +4 -0
- package/src/Models/Settings.ts +7 -0
- package/src/Modules/GUI.ts +123 -0
- package/src/Modules/Version.ts +89 -0
- package/src/Screens/Debug.ts +99 -0
- package/src/Screens/MainMenu.ts +138 -0
- package/src/Screens/Support.ts +99 -0
- package/src/Utilities/Data.ts +40 -0
- package/src/Utilities/Elements/.AdvancedElements.ts +70 -0
- package/src/Utilities/Elements/.ElementHelpers.ts +100 -0
- package/src/Utilities/Elements/Button.ts +54 -0
- package/src/Utilities/Elements/Checkbox.ts +63 -0
- package/src/Utilities/Elements/Input.ts +72 -0
- package/src/Utilities/Elements/Label.ts +50 -0
- package/src/Utilities/Elements/Tooltip.ts +30 -0
- package/src/Utilities/Logger.ts +79 -0
- package/src/Utilities/Messages.ts +36 -0
- package/src/Utilities/SDK.ts +104 -0
- package/src/Utilities/String.ts +31 -0
- package/src/Utilities/Style.ts +24 -0
- package/src/Utilities/Translation.ts +59 -0
- package/dist/Base/BaseModule.d.ts +0 -13
- package/dist/Base/BaseModule.js +0 -41
- package/dist/Base/BaseSetting.d.ts +0 -29
- package/dist/Base/BaseSetting.js +0 -152
- package/dist/Base/Modules.d.ts +0 -5
- package/dist/Base/Modules.js +0 -17
- package/dist/Base/SettingDefinitions.d.ts +0 -8
- package/dist/Base/SettingDefinitions.js +0 -19
- package/dist/Base/SettingUtils.d.ts +0 -17
- package/dist/Base/SettingUtils.js +0 -68
- package/dist/DeepLib.d.ts +0 -5
- package/dist/DeepLib.js +0 -21
- package/dist/Models/Base.d.ts +0 -4
- package/dist/Models/Base.js +0 -2
- package/dist/Models/Settings.d.ts +0 -6
- package/dist/Models/Settings.js +0 -2
- package/dist/Modules/Version.d.ts +0 -14
- package/dist/Modules/Version.js +0 -62
- package/dist/Screens/MainMenu.d.ts +0 -11
- package/dist/Screens/MainMenu.js +0 -80
- package/dist/Screens/Support.d.ts +0 -14
- package/dist/Screens/Support.js +0 -99
- package/dist/Utils/Data.d.ts +0 -5
- package/dist/Utils/Data.js +0 -42
- package/dist/Utils/Logger.d.ts +0 -4
- package/dist/Utils/Logger.js +0 -6
- package/dist/Utils/Messages.d.ts +0 -2
- package/dist/Utils/Messages.js +0 -32
- package/dist/Utils/RibbonMenu.d.ts +0 -9
- package/dist/Utils/RibbonMenu.js +0 -32
- package/dist/Utils/SDK.d.ts +0 -21
- package/dist/Utils/SDK.js +0 -75
- package/dist/Utils/String.d.ts +0 -5
- package/dist/Utils/String.js +0 -30
- package/dist/Utils/Translation.d.ts +0 -10
- package/dist/Utils/Translation.js +0 -43
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
export type SettingElement = Button | Checkbox | Input | Label;
|
|
2
|
+
|
|
3
|
+
export type BaseElementModel = {
|
|
4
|
+
id: string;
|
|
5
|
+
size?: [width: number, height: number];
|
|
6
|
+
position?: [x: number, y: number];
|
|
7
|
+
disabled?: boolean;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export type Button = BaseElementModel & {
|
|
11
|
+
type: 'button';
|
|
12
|
+
image?: string;
|
|
13
|
+
label?: string;
|
|
14
|
+
tooltip?: string;
|
|
15
|
+
onClick: () => void;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export type Checkbox = BaseElementModel & {
|
|
19
|
+
type: 'checkbox';
|
|
20
|
+
label: string;
|
|
21
|
+
description: string;
|
|
22
|
+
getSettingValue: () => boolean;
|
|
23
|
+
setSettingValue: (val: boolean) => void;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export type Input = BaseElementModel & {
|
|
27
|
+
type: 'text' | 'number';
|
|
28
|
+
label: string;
|
|
29
|
+
description: string;
|
|
30
|
+
getElementValue: () => string;
|
|
31
|
+
setSettingValue: (val: string) => void;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export type Label = BaseElementModel & {
|
|
35
|
+
type: 'label';
|
|
36
|
+
label: string;
|
|
37
|
+
description?: string;
|
|
38
|
+
};
|
package/README.md
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
## Deep Lib
|
|
2
|
-
Package for easier development of BC mods
|
|
2
|
+
Package for easier development of BC mods.
|
package/package.json
CHANGED
|
@@ -1,24 +1,40 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bc-deeplib",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"author": "dDeepLb",
|
|
5
5
|
"description": "Package for easier development of BC mods without need to repeat myself in every mod",
|
|
6
6
|
"license": "MIT",
|
|
7
|
+
"type": "module",
|
|
7
8
|
"files": [
|
|
8
|
-
"/
|
|
9
|
+
"/src",
|
|
10
|
+
".types",
|
|
11
|
+
"public"
|
|
9
12
|
],
|
|
10
|
-
"main": "./
|
|
11
|
-
"
|
|
12
|
-
|
|
13
|
-
"
|
|
13
|
+
"main": "./src/DeepLib.ts",
|
|
14
|
+
"devDependencies": {
|
|
15
|
+
"@eslint/js": "^9.16.0",
|
|
16
|
+
"@stylistic/eslint-plugin": "^2.11.0",
|
|
17
|
+
"@types/node": "^22.5.4",
|
|
18
|
+
"bc-stubs": "^110.0.0",
|
|
19
|
+
"copy-webpack-plugin": "^12.0.2",
|
|
20
|
+
"cross-env": "^7.0.3",
|
|
21
|
+
"css-loader": "^7.1.2",
|
|
22
|
+
"eslint": "^9.16.0",
|
|
23
|
+
"globals": "^15.13.0",
|
|
24
|
+
"terser-webpack-plugin": "^5.3.10",
|
|
25
|
+
"ts-loader": "^9.5.1",
|
|
26
|
+
"typescript": "^5.7.2",
|
|
27
|
+
"typescript-eslint": "^8.17.0",
|
|
28
|
+
"webpack": "^5.97.1",
|
|
29
|
+
"webpack-cli": "^5.1.4",
|
|
30
|
+
"webpack-dev-server": "^5.1.0"
|
|
14
31
|
},
|
|
15
32
|
"dependencies": {
|
|
16
33
|
"bondage-club-mod-sdk": "^1.2.0"
|
|
17
34
|
},
|
|
18
|
-
"
|
|
19
|
-
"
|
|
20
|
-
"
|
|
21
|
-
"
|
|
22
|
-
"bc-stubs": "github:bananarama92/BC-stubs"
|
|
35
|
+
"scripts": {
|
|
36
|
+
"lint": "eslint src/",
|
|
37
|
+
"build": "cross-env TS_NODE_PROJECT=\"tsconfig.webpack.json\" webpack --env prod --fail-on-warnings",
|
|
38
|
+
"dev": "cross-env TS_NODE_PROJECT=\"tsconfig.webpack.json\" webpack serve --progress"
|
|
23
39
|
}
|
|
24
|
-
}
|
|
40
|
+
}
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
.deeplib-subscreen {
|
|
2
|
+
--deeplib-background-color: var(--main, white);
|
|
3
|
+
--deeplib-element-color: var(--element, white);
|
|
4
|
+
--deeplib-element-hover-color: var(--accentHover, cyan);
|
|
5
|
+
--deeplib-text-color: var(--text, black);
|
|
6
|
+
--deeplib-icon-color: var(--accent, white);
|
|
7
|
+
--deeplib-border-color: var(--accent, black);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
/************/
|
|
11
|
+
/* ELEMENTS */
|
|
12
|
+
/************/
|
|
13
|
+
|
|
14
|
+
.deeplib-text {
|
|
15
|
+
color: var(--deeplib-text-color);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.deeplib-subscreen {
|
|
19
|
+
padding: 0;
|
|
20
|
+
margin: 0;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.deeplib-subscreen * {
|
|
24
|
+
box-sizing: border-box;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.deeplib-settings {
|
|
28
|
+
display: flex;
|
|
29
|
+
flex-direction: column;
|
|
30
|
+
padding: min(1.0dvh, 0.5dvw);
|
|
31
|
+
gap: 0.3em;
|
|
32
|
+
overflow-y: auto;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.deeplib-misc {
|
|
36
|
+
display: flex;
|
|
37
|
+
align-items: center;
|
|
38
|
+
justify-content: space-between;
|
|
39
|
+
flex-direction: column-reverse;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.deeplib-button.button-styling {
|
|
43
|
+
border-radius: min(1.0dvh, 0.5dvw);
|
|
44
|
+
color: var(--deeplib-text-color);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.deeplib-button.button-styling img {
|
|
48
|
+
position: absolute;
|
|
49
|
+
top: 0%;
|
|
50
|
+
left: 0%;
|
|
51
|
+
width: 100%;
|
|
52
|
+
height: 100%;
|
|
53
|
+
background-position: left;
|
|
54
|
+
background-color: var(--deeplib-icon-color);
|
|
55
|
+
background-blend-mode: multiply;
|
|
56
|
+
background-size: contain;
|
|
57
|
+
mask-position: left;
|
|
58
|
+
mask-size: contain;
|
|
59
|
+
background-repeat: no-repeat;
|
|
60
|
+
mask-repeat: no-repeat;
|
|
61
|
+
color: transparent;
|
|
62
|
+
|
|
63
|
+
background-image: var(--image);
|
|
64
|
+
mask-image: var(--image);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
.deeplib-button.button-styling .button-label {
|
|
68
|
+
width: 100%;
|
|
69
|
+
background-color: transparent;
|
|
70
|
+
color: var(--deeplib-text-color);
|
|
71
|
+
font-size: min(3.6dvh, 1.8dvw);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
#deeplib-subscreen-title {
|
|
75
|
+
text-align: center;
|
|
76
|
+
color: var(--deeplib-text-color);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
#deeplib-reset-button {
|
|
80
|
+
background-color: indianred;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
#deeplib-wiki-button {
|
|
84
|
+
background-color: #BDA203;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
#deeplib-support-button {
|
|
88
|
+
background-color: #5e4969;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
.deeplib-checkbox-container {
|
|
92
|
+
display: flex;
|
|
93
|
+
flex-direction: row;
|
|
94
|
+
align-items: center;
|
|
95
|
+
gap: 0.3em;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
.deeplib-input {
|
|
99
|
+
border-radius: min(1.0dvh, 0.5dvw);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
.deeplib-input-container {
|
|
103
|
+
position: relative;
|
|
104
|
+
margin-top: min(1vh, 0.5vw);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
.deeplib-input-container input.deeplib-input {
|
|
108
|
+
font-size: 20px;
|
|
109
|
+
width: 100%;
|
|
110
|
+
padding: 5px 0;
|
|
111
|
+
background-color: transparent;
|
|
112
|
+
outline: none;
|
|
113
|
+
padding-left: min(1vh, 0.5vw);
|
|
114
|
+
padding-right: min(1vh, 0.5vw);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
.deeplib-input-container label.deeplib-text {
|
|
118
|
+
position: absolute;
|
|
119
|
+
top: min(0.6vh, 0.3vw);
|
|
120
|
+
left: min(0.6vh, 0.3vw);
|
|
121
|
+
transition: all 0.3s ease;
|
|
122
|
+
pointer-events: none;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
.deeplib-input-container input.deeplib-input:focus~label,
|
|
126
|
+
.deeplib-input-container input.deeplib-input:not(:placeholder-shown)~label {
|
|
127
|
+
font-size: 0.7em;
|
|
128
|
+
transform: translate(20%, -70%);
|
|
129
|
+
background-color: var(--deeplib-background-color);
|
|
130
|
+
padding: 0px min(1vh, 0.5vw);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
.deeplib-input-container .deeplib-underline {
|
|
134
|
+
position: absolute;
|
|
135
|
+
bottom: 0;
|
|
136
|
+
left: 0;
|
|
137
|
+
height: 2px;
|
|
138
|
+
width: 100%;
|
|
139
|
+
background-color: var(--deeplib-element-hover-color);
|
|
140
|
+
transform: scaleX(0);
|
|
141
|
+
transition: all 0.3s ease;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
.deeplib-input-container input.deeplib-input:focus~.deeplib-underline,
|
|
145
|
+
.deeplib-input-container input.deeplib-input:not(:placeholder-shown)~.deeplib-underline {
|
|
146
|
+
transform: scaleX(0.98);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
.deeplib-tooltip {
|
|
150
|
+
background-color: var(--deeplib-element-color);
|
|
151
|
+
color: var(--deeplib-text-color);
|
|
152
|
+
display: flex;
|
|
153
|
+
align-items: center;
|
|
154
|
+
justify-content: center;
|
|
155
|
+
border-radius: min(1.0dvh, 0.5dvw);
|
|
156
|
+
padding: min(1vh, 0.5vw);
|
|
157
|
+
font-size: 0.8em;
|
|
158
|
+
border: min(0.2vh, 0.1vw) solid var(--deeplib-border-color);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
input::-webkit-outer-spin-button,
|
|
162
|
+
input::-webkit-inner-spin-button {
|
|
163
|
+
-webkit-appearance: none;
|
|
164
|
+
margin: 0;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
input[type=number] {
|
|
168
|
+
appearance: textfield;
|
|
169
|
+
-moz-appearance: textfield;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
/*************/
|
|
173
|
+
/* MESSAGES */
|
|
174
|
+
/*************/
|
|
175
|
+
|
|
176
|
+
.deeplib-highlight-text {
|
|
177
|
+
font-weight: bold;
|
|
178
|
+
color: rgb(203, 185, 23);
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
#TextAreaChatLog[data-colortheme='dark'] div.ChatMessage.deeplib-message,
|
|
182
|
+
#TextAreaChatLog[data-colortheme='dark2'] div.ChatMessage.deeplib-message {
|
|
183
|
+
background-color: var(--deeplib-element-color);
|
|
184
|
+
border: min(0.2dvh, 0.1dvw) solid var(--deeplib-border-color);
|
|
185
|
+
color: var(--deeplib-text-color);
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
#TextAreaChatLog div.ChatMessage.deeplib-message {
|
|
189
|
+
background-color: #eee;
|
|
190
|
+
border: min(0.2dvh, 0.1dvw) solid #440171;
|
|
191
|
+
color: #111;
|
|
192
|
+
padding-left: min(0.6dvh, 0.3dvw);
|
|
193
|
+
display: block;
|
|
194
|
+
white-space: normal;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
#TextAreaChatLog[data-colortheme='dark'] div.ChatMessage.deeplib-message a,
|
|
198
|
+
#TextAreaChatLog[data-colortheme='dark2'] div.ChatMessage.deeplib-message a {
|
|
199
|
+
color: var(--deeplib-text-color);
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
#TextAreaChatLog div.ChatMessage.deeplib-message a {
|
|
203
|
+
cursor: pointer;
|
|
204
|
+
font-weight: bold;
|
|
205
|
+
color: #111;
|
|
206
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
#deeplib-gratitude {
|
|
2
|
+
position: fixed;
|
|
3
|
+
width: 25%;
|
|
4
|
+
height: 50%;
|
|
5
|
+
top: 15%;
|
|
6
|
+
left: 50%;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
#deeplib-gratitude h1 {
|
|
10
|
+
font-size: 1em;
|
|
11
|
+
color: var(--text, #333);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
#deeplib-gratitude p {
|
|
15
|
+
font-size: 0.6em;
|
|
16
|
+
color: var(--text, #555);
|
|
17
|
+
line-height: 1.5;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
#deeplib-gratitude p:last-child {
|
|
21
|
+
font-size: 0.8em;
|
|
22
|
+
color: var(--text, #ff69b4);
|
|
23
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { BaseSettingsModel, BaseSubscreen, PlayerStorage, SettingsModel, bcSdkMod } from '../DeepLib';
|
|
2
|
+
|
|
3
|
+
export type Subscreen = new (module?: BaseModule) => BaseSubscreen;
|
|
4
|
+
|
|
5
|
+
export abstract class BaseModule {
|
|
6
|
+
get settingsScreen(): Subscreen | null {
|
|
7
|
+
return null;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
get settingsStorage(): string | null {
|
|
11
|
+
return this.constructor.name;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
get settings(): BaseSettingsModel {
|
|
15
|
+
const modName = bcSdkMod.ModInfo.name;
|
|
16
|
+
if (!this.settingsStorage) return {} as BaseSettingsModel;
|
|
17
|
+
if (!PlayerStorage()) {
|
|
18
|
+
Player[modName] = <SettingsModel>{};
|
|
19
|
+
this.registerDefaultSettings();
|
|
20
|
+
} else if (!PlayerStorage()[this.settingsStorage]) this.registerDefaultSettings();
|
|
21
|
+
return PlayerStorage()[this.settingsStorage];
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
init() {
|
|
25
|
+
this.registerDefaultSettings();
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
registerDefaultSettings(): void {
|
|
29
|
+
const storage = this.settingsStorage;
|
|
30
|
+
const defaults = this.defaultSettings;
|
|
31
|
+
if (!storage || !defaults) return;
|
|
32
|
+
|
|
33
|
+
Player[bcSdkMod.ModInfo.name][storage] = Object.assign(defaults, Player[bcSdkMod.ModInfo.name][storage] ?? {});
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
get defaultSettings(): BaseSettingsModel | null {
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
load() { }
|
|
41
|
+
|
|
42
|
+
run() { }
|
|
43
|
+
|
|
44
|
+
unload() { }
|
|
45
|
+
}
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
import { SettingElement } from '../../.types/elements';
|
|
2
|
+
import { BaseModule, BaseSettingsModel, SupportHelper, bcSdkMod, dataStore, elementAdjustFontSize, elementAppendToSettingsDiv, elementAppendToSubscreenDiv, elementCreateButton, elementCreateCheckbox, elementCreateInput, elementCreateLabel, elementCreateSettingsDiv, elementCreateSubscreenDiv, elementCreateTooltip, elementGetSettingsDiv, elementGetSubscreenDiv, elementGetTooltip, elementHide, elementRemoveSubscreenDiv, elementSetPosSizeFont, elementSetPosition, elementSetSize, getText, modules, setSubscreen } from '../DeepLib';
|
|
3
|
+
|
|
4
|
+
export abstract class BaseSubscreen {
|
|
5
|
+
static currentElements: [HTMLElement, SettingElement][] = [];
|
|
6
|
+
static currentPage: number = 1;
|
|
7
|
+
readonly module!: BaseModule;
|
|
8
|
+
|
|
9
|
+
constructor(module?: BaseModule) {
|
|
10
|
+
if (module) this.module = module;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
get name(): string {
|
|
14
|
+
return 'UNKNOWN';
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
get icon(): string {
|
|
18
|
+
return '';
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
get subscreenName(): string {
|
|
22
|
+
return this.constructor.name;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
setSubscreen(screen: BaseSubscreen | string | null) {
|
|
26
|
+
return setSubscreen(screen);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
get settings(): BaseSettingsModel {
|
|
30
|
+
return this.module.settings as BaseSettingsModel;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
get pageStructure(): SettingElement[][] {
|
|
34
|
+
return [[]];
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
get currentPage(): SettingElement[] {
|
|
38
|
+
return this.pageStructure[Math.min(PreferencePageCurrent - 1, this.pageStructure.length - 1)];
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
hideElements() {
|
|
42
|
+
this.pageStructure.forEach((item, ix) => {
|
|
43
|
+
if (ix != PreferencePageCurrent - 1) {
|
|
44
|
+
item.forEach((setting) => {
|
|
45
|
+
elementHide({ elementId: setting.id });
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
load() {
|
|
52
|
+
for (const module of modules()) {
|
|
53
|
+
if (!module.settingsScreen) continue;
|
|
54
|
+
if (!module.settings || !Object.keys(module.settings).length) module.registerDefaultSettings();
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
elementCreateSubscreenDiv();
|
|
58
|
+
const settingsElement = elementCreateSettingsDiv();
|
|
59
|
+
elementAppendToSubscreenDiv(settingsElement);
|
|
60
|
+
|
|
61
|
+
const subscreenTitle = elementCreateLabel({
|
|
62
|
+
type: 'label',
|
|
63
|
+
id: 'deeplib-subscreen-title',
|
|
64
|
+
label: getText('mainmenu.title').replace('$ModVersion', bcSdkMod.ModInfo.version) + ' ' + SupportHelper.getSupporter(),
|
|
65
|
+
});
|
|
66
|
+
elementAppendToSubscreenDiv(subscreenTitle);
|
|
67
|
+
|
|
68
|
+
if (this.name !== 'mainmenu') {
|
|
69
|
+
const exitButton = elementCreateButton({
|
|
70
|
+
type: 'button',
|
|
71
|
+
id: 'deeplib-exit',
|
|
72
|
+
position: [1815, 75],
|
|
73
|
+
size: [90, 90],
|
|
74
|
+
image: 'Icons/Exit.png',
|
|
75
|
+
onClick: () => {
|
|
76
|
+
setSubscreen('mainmenu');
|
|
77
|
+
},
|
|
78
|
+
tooltip: getText('settings.button.back_button_hint')
|
|
79
|
+
});
|
|
80
|
+
elementAppendToSubscreenDiv(exitButton);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
const tooltip = elementCreateTooltip();
|
|
84
|
+
elementAppendToSubscreenDiv(tooltip);
|
|
85
|
+
|
|
86
|
+
this.pageStructure.forEach((s) =>
|
|
87
|
+
s.forEach((item) => {
|
|
88
|
+
let element: HTMLElement;
|
|
89
|
+
switch (item.type) {
|
|
90
|
+
case 'text':
|
|
91
|
+
case 'number':
|
|
92
|
+
element = elementCreateInput(item);
|
|
93
|
+
break;
|
|
94
|
+
case 'checkbox':
|
|
95
|
+
element = elementCreateCheckbox(item);
|
|
96
|
+
break;
|
|
97
|
+
case 'button':
|
|
98
|
+
element = elementCreateButton(item);
|
|
99
|
+
break;
|
|
100
|
+
case 'label':
|
|
101
|
+
element = elementCreateLabel(item);
|
|
102
|
+
break;
|
|
103
|
+
}
|
|
104
|
+
elementAppendToSettingsDiv(element);
|
|
105
|
+
})
|
|
106
|
+
);
|
|
107
|
+
|
|
108
|
+
CharacterAppearanceForceUpCharacter = Player.MemberNumber ?? -1;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
run() {
|
|
112
|
+
const newTitle = getText('mainmenu.title').replace('$ModVersion', bcSdkMod.ModInfo.version) + ' ' + SupportHelper.getSupporter();
|
|
113
|
+
const oldTitle = ElementContent('deeplib-subscreen-title');
|
|
114
|
+
if (newTitle !== oldTitle) {
|
|
115
|
+
ElementContent('deeplib-subscreen-title', newTitle);
|
|
116
|
+
}
|
|
117
|
+
DrawCharacter(Player, 50, 50, 0.9, false);
|
|
118
|
+
|
|
119
|
+
if (this.pageStructure.length > 1) {
|
|
120
|
+
MainCanvas.textAlign = 'center';
|
|
121
|
+
PreferencePageChangeDraw(1595, 75, this.pageStructure.length);
|
|
122
|
+
MainCanvas.textAlign = 'left';
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
this.hideElements();
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
click() {
|
|
129
|
+
if (this.pageStructure.length > 1) PreferencePageChangeClick(1595, 75, this.pageStructure.length);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
exit() {
|
|
133
|
+
CharacterAppearanceForceUpCharacter = -1;
|
|
134
|
+
CharacterLoadCanvas(Player);
|
|
135
|
+
|
|
136
|
+
setSubscreen('mainmenu');
|
|
137
|
+
dataStore();
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
resize(onLoad: boolean = false) {
|
|
141
|
+
elementSetPosSizeFont({ element: elementGetSubscreenDiv() }, 0, 0, 2000, 1000);
|
|
142
|
+
if (this.name === 'mainmenu') {
|
|
143
|
+
elementSetPosSizeFont({ element: elementGetSettingsDiv() }, 530, 170, 800, 660);
|
|
144
|
+
} else {
|
|
145
|
+
elementSetPosSizeFont({ element: elementGetSettingsDiv() }, 530, 170, 1000, 660);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
elementSetPosSizeFont({ elementId: 'deeplib-subscreen-title' }, 530, 75, 800, 60);
|
|
149
|
+
|
|
150
|
+
elementSetPosition({ element: elementGetTooltip() }, 250, 850);
|
|
151
|
+
elementSetSize({ element: elementGetTooltip() }, 1500, 60);
|
|
152
|
+
|
|
153
|
+
BaseSubscreen.currentElements.forEach((item) => {
|
|
154
|
+
const options = item[1];
|
|
155
|
+
const elementDataAttrs = item[0].dataset;
|
|
156
|
+
|
|
157
|
+
if (options.position || elementDataAttrs.position) {
|
|
158
|
+
const position = elementDataAttrs?.position?.split('x');
|
|
159
|
+
const xPos = options?.position?.[0] || parseInt(position?.[0] || 0);
|
|
160
|
+
const yPos = options?.position?.[1] || parseInt(position?.[1] || 0);
|
|
161
|
+
|
|
162
|
+
elementSetPosition({ elementId: options.id }, xPos, yPos);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
if (options.size || elementDataAttrs.size) {
|
|
166
|
+
const size = elementDataAttrs?.size?.split('x');
|
|
167
|
+
const width = options?.size?.[0] || parseInt(size?.[0] || 0);
|
|
168
|
+
const height = options?.size?.[1] || parseInt(size?.[1] || 0);
|
|
169
|
+
|
|
170
|
+
elementSetSize({ elementId: options.id }, width, height);
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
elementAdjustFontSize({ elementId: options.id });
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
unload() {
|
|
178
|
+
this.pageStructure.forEach((s) =>
|
|
179
|
+
s.forEach((item) => {
|
|
180
|
+
switch (item.type) {
|
|
181
|
+
case 'text':
|
|
182
|
+
item.setSettingValue(ElementValue(item.id));
|
|
183
|
+
break;
|
|
184
|
+
case 'checkbox': {
|
|
185
|
+
const elem = document.getElementById(item.id) as HTMLInputElement;
|
|
186
|
+
const checked = elem.checked;
|
|
187
|
+
item.setSettingValue(checked);
|
|
188
|
+
break;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
})
|
|
192
|
+
);
|
|
193
|
+
BaseSubscreen.currentElements = [];
|
|
194
|
+
|
|
195
|
+
elementRemoveSubscreenDiv();
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { BaseModule, bcSdkMod, dataTake, deepLibLogger, Localization, modules, registerModule, VersionModule } from '../DeepLib';
|
|
2
|
+
|
|
3
|
+
export function initMod(initFunction: (() => void) | (() => Promise<void>), modules: BaseModule[], pathToTranslationsFolder: string) {
|
|
4
|
+
const MOD_NAME = bcSdkMod.ModInfo.name;
|
|
5
|
+
deepLibLogger.debug(`Init wait for ${MOD_NAME}`);
|
|
6
|
+
if (CurrentScreen == null || CurrentScreen === 'Login') {
|
|
7
|
+
bcSdkMod.prototype.hookFunction('LoginResponse', 0, (args, next) => {
|
|
8
|
+
deepLibLogger.debug(`Init for ${MOD_NAME}! LoginResponse caught: `, args);
|
|
9
|
+
next(args);
|
|
10
|
+
const response = args[0];
|
|
11
|
+
if (response === 'InvalidNamePassword') return next(args);
|
|
12
|
+
if (response && typeof response.Name === 'string' && typeof response.AccountName === 'string') {
|
|
13
|
+
init(initFunction, modules, pathToTranslationsFolder);
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
} else {
|
|
17
|
+
deepLibLogger.debug(`Already logged in, initing ${MOD_NAME}`);
|
|
18
|
+
init(initFunction, modules, pathToTranslationsFolder);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export async function init(initFunction: (() => void) | (() => Promise<void>), modules: BaseModule[], pathToTranslationsFolder: string) {
|
|
23
|
+
const MOD_NAME = bcSdkMod.ModInfo.name;
|
|
24
|
+
const MOD_VERSION = bcSdkMod.ModInfo.version;
|
|
25
|
+
|
|
26
|
+
if ((window as any)[MOD_NAME + 'Loaded']) return;
|
|
27
|
+
|
|
28
|
+
dataTake();
|
|
29
|
+
|
|
30
|
+
new Localization({ pathToTranslationsFolder: pathToTranslationsFolder });
|
|
31
|
+
await Localization.init();
|
|
32
|
+
|
|
33
|
+
if (!initModules(modules)) {
|
|
34
|
+
unloadMod();
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
await initFunction();
|
|
39
|
+
|
|
40
|
+
VersionModule.checkVersionUpdate();
|
|
41
|
+
VersionModule.checkVersionMigration();
|
|
42
|
+
|
|
43
|
+
(window as any)[MOD_NAME + 'Loaded'] = true;
|
|
44
|
+
deepLibLogger.log(`Loaded ${MOD_NAME}! Version: ${MOD_VERSION}`);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function initModules(modulesToRegister: BaseModule[]): boolean {
|
|
48
|
+
const MOD_NAME = bcSdkMod.ModInfo.name;
|
|
49
|
+
|
|
50
|
+
for (const module of modulesToRegister) {
|
|
51
|
+
registerModule(module);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
for (const module of modules()) {
|
|
55
|
+
module.init();
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
for (const module of modules()) {
|
|
59
|
+
module.load();
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
for (const module of modules()) {
|
|
63
|
+
module.run();
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
deepLibLogger.debug(`Modules Loaded for ${MOD_NAME}.`);
|
|
67
|
+
return true;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export function unloadMod(): true {
|
|
71
|
+
const MOD_NAME = bcSdkMod.ModInfo.name;
|
|
72
|
+
unloadModules();
|
|
73
|
+
|
|
74
|
+
delete (window as any)[MOD_NAME + 'Loaded'];
|
|
75
|
+
deepLibLogger.debug(`Unloaded ${MOD_NAME}.`);
|
|
76
|
+
return true;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function unloadModules() {
|
|
80
|
+
for (const module of modules()) {
|
|
81
|
+
module.unload();
|
|
82
|
+
}
|
|
83
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { BaseModule } from '../DeepLib';
|
|
2
|
+
|
|
3
|
+
export const modulesMap: Map<string, BaseModule> = new Map<string, BaseModule>();
|
|
4
|
+
|
|
5
|
+
export function modules(): BaseModule[] {
|
|
6
|
+
return [...modulesMap.values()];
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export function registerModule<T extends BaseModule>(module: T): T {
|
|
10
|
+
modulesMap.set(module.constructor.name, module);
|
|
11
|
+
return module;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export function getModule<T extends BaseModule>(moduleType: string): T {
|
|
15
|
+
return modulesMap.get(moduleType) as T;
|
|
16
|
+
}
|