bc-deeplib 1.0.3 → 1.0.4
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/dist/main.js +1894 -0
- package/dist/main.js.map +1 -0
- package/dist/public/styles/DeepLib.css +206 -0
- package/dist/public/styles/Gratitude.css +23 -0
- package/package.json +3 -3
- package/src/Base/BaseModule.ts +0 -45
- package/src/Base/BaseSubscreen.ts +0 -198
- package/src/Base/Initialization.ts +0 -83
- package/src/Base/Modules.ts +0 -16
- package/src/Base/SettingDefinitions.ts +0 -14
- package/src/Migrators/BaseMigrator.ts +0 -4
- package/src/Models/Base.ts +0 -4
- package/src/Models/Settings.ts +0 -7
- package/src/Modules/GUI.ts +0 -123
- package/src/Modules/Version.ts +0 -89
- package/src/Screens/Debug.ts +0 -99
- package/src/Screens/MainMenu.ts +0 -138
- package/src/Screens/Support.ts +0 -99
- package/src/Utilities/Data.ts +0 -40
- package/src/Utilities/Elements/.AdvancedElements.ts +0 -70
- package/src/Utilities/Elements/.ElementHelpers.ts +0 -100
- package/src/Utilities/Elements/Button.ts +0 -54
- package/src/Utilities/Elements/Checkbox.ts +0 -63
- package/src/Utilities/Elements/Input.ts +0 -72
- package/src/Utilities/Elements/Label.ts +0 -50
- package/src/Utilities/Elements/Tooltip.ts +0 -30
- package/src/Utilities/Logger.ts +0 -79
- package/src/Utilities/Messages.ts +0 -36
- package/src/Utilities/SDK.ts +0 -104
- package/src/Utilities/String.ts +0 -31
- package/src/Utilities/Style.ts +0 -24
- package/src/Utilities/Translation.ts +0 -59
package/src/Screens/MainMenu.ts
DELETED
|
@@ -1,138 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import { BaseSubscreen, GUI, GuiDebug, GuiSupport, elementAppendToMiscDiv, elementAppendToSettingsDiv, elementAppendToSubscreenDiv, elementCreateButton, elementCreateMiscDiv, elementSetPosSizeFont, getText } from '../DeepLib';
|
|
3
|
-
|
|
4
|
-
export class MainMenu extends BaseSubscreen {
|
|
5
|
-
subscreens: BaseSubscreen[] = [];
|
|
6
|
-
|
|
7
|
-
static wikiLink: string = '';
|
|
8
|
-
static resetSubscreen: BaseSubscreen | null = null;
|
|
9
|
-
|
|
10
|
-
get name(): string {
|
|
11
|
-
return 'mainmenu';
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
constructor(module: GUI) {
|
|
15
|
-
super(module);
|
|
16
|
-
|
|
17
|
-
this.subscreens = module.subscreens;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
load(): void {
|
|
21
|
-
if (!GUI.instance?.currentSubscreen) {
|
|
22
|
-
this.setSubscreen(this);
|
|
23
|
-
return;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
super.load();
|
|
27
|
-
|
|
28
|
-
const exitButton = elementCreateButton({
|
|
29
|
-
type: 'button',
|
|
30
|
-
id: 'exit',
|
|
31
|
-
position: [1815, 75],
|
|
32
|
-
size: [90, 90],
|
|
33
|
-
image: 'Icons/Exit.png',
|
|
34
|
-
onClick: () => {
|
|
35
|
-
this.exit();
|
|
36
|
-
},
|
|
37
|
-
tooltip: getText('settings.button.back_button_hint')
|
|
38
|
-
});
|
|
39
|
-
elementAppendToSubscreenDiv(exitButton);
|
|
40
|
-
|
|
41
|
-
for (const screen of this.subscreens) {
|
|
42
|
-
|
|
43
|
-
if (screen.name == 'mainmenu') continue;
|
|
44
|
-
|
|
45
|
-
const button = elementCreateButton({
|
|
46
|
-
type: 'button',
|
|
47
|
-
id: `${screen.name}-button`,
|
|
48
|
-
image: screen.icon,
|
|
49
|
-
label: getText(`mainmenu.button.${screen.name}`),
|
|
50
|
-
onClick: () => {
|
|
51
|
-
this.setSubscreen(screen);
|
|
52
|
-
},
|
|
53
|
-
size: [450, 90],
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
elementAppendToSettingsDiv(button);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
const miscDiv = elementCreateMiscDiv();
|
|
60
|
-
elementAppendToSubscreenDiv(miscDiv);
|
|
61
|
-
|
|
62
|
-
if (MainMenu.resetSubscreen) {
|
|
63
|
-
const resetButton = elementCreateButton({
|
|
64
|
-
type: 'button',
|
|
65
|
-
id: 'deeplib-reset-button',
|
|
66
|
-
image: 'Icons/ServiceBell.png',
|
|
67
|
-
label: 'Reset',
|
|
68
|
-
onClick: () => {
|
|
69
|
-
this.setSubscreen(MainMenu.resetSubscreen);
|
|
70
|
-
},
|
|
71
|
-
size: [405, 80],
|
|
72
|
-
});
|
|
73
|
-
elementAppendToMiscDiv(resetButton);
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
if (MainMenu.wikiLink) {
|
|
77
|
-
const wikiButton = elementCreateButton({
|
|
78
|
-
type: 'button',
|
|
79
|
-
id: 'deeplib-wiki-button',
|
|
80
|
-
image: 'Icons/Introduction.png',
|
|
81
|
-
label: 'Wiki',
|
|
82
|
-
onClick: () => {
|
|
83
|
-
window.open(MainMenu.wikiLink, '_blank');
|
|
84
|
-
},
|
|
85
|
-
size: [405, 80],
|
|
86
|
-
});
|
|
87
|
-
elementAppendToMiscDiv(wikiButton);
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
const supportButton = elementCreateButton({
|
|
91
|
-
type: 'button',
|
|
92
|
-
id: 'deeplib-support-button',
|
|
93
|
-
image: 'Assets/Female3DCG/Emoticon/Coffee/Icon.png',
|
|
94
|
-
label: 'Support',
|
|
95
|
-
onClick: () => {
|
|
96
|
-
this.setSubscreen(new GuiSupport());
|
|
97
|
-
},
|
|
98
|
-
size: [405, 80],
|
|
99
|
-
});
|
|
100
|
-
elementAppendToMiscDiv(supportButton);
|
|
101
|
-
elementSetPosSizeFont({ elementId: 'deeplib-misc' }, 1500, 670, 405, 260);
|
|
102
|
-
|
|
103
|
-
const debugButton = elementCreateButton({
|
|
104
|
-
type: 'button',
|
|
105
|
-
id: 'deeplib-debug-button',
|
|
106
|
-
image: 'Assets/Female3DCG/Emoticon/Coffee/Icon.png',
|
|
107
|
-
onClick: () => {
|
|
108
|
-
this.setSubscreen(new GuiDebug());
|
|
109
|
-
},
|
|
110
|
-
size: [90, 90],
|
|
111
|
-
position: [75, 75],
|
|
112
|
-
});
|
|
113
|
-
elementAppendToMiscDiv(debugButton);
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
run() {
|
|
117
|
-
super.run();
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
click() { }
|
|
121
|
-
|
|
122
|
-
exit(): void {
|
|
123
|
-
CharacterAppearanceForceUpCharacter = -1;
|
|
124
|
-
CharacterLoadCanvas(Player);
|
|
125
|
-
this.setSubscreen(null);
|
|
126
|
-
PreferenceSubscreenExtensionsClear();
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
resize(): void {
|
|
130
|
-
super.resize();
|
|
131
|
-
elementSetPosSizeFont({ elementId: 'deeplib-misc' }, 1500, 670, 405, 260);
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
export function setMainMenuOptions(wikiLink: string, resetSubscreen: BaseSubscreen | null) {
|
|
136
|
-
MainMenu.wikiLink = wikiLink;
|
|
137
|
-
MainMenu.resetSubscreen = resetSubscreen;
|
|
138
|
-
}
|
package/src/Screens/Support.ts
DELETED
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
import { Button, SettingElement } from '../../.types/elements';
|
|
2
|
-
import { BaseSubscreen, elementSetPosSizeFont, getText } from '../DeepLib';
|
|
3
|
-
|
|
4
|
-
export class SupportHelper {
|
|
5
|
-
private static thankYouList: string[] = ['Ellena', 'weboos', 'Jamie'];
|
|
6
|
-
private static thankYouNext = 0;
|
|
7
|
-
private static thankYou = '';
|
|
8
|
-
|
|
9
|
-
static getSupporter() {
|
|
10
|
-
if (SupportHelper.thankYouNext < CommonTime()) SupportHelper.doNextThankYou();
|
|
11
|
-
return `${getText('support.other.thankyou')}, ${SupportHelper.thankYou}`;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
static doNextThankYou() {
|
|
15
|
-
if (SupportHelper.thankYou && SupportHelper.thankYouList.length < 2) return;
|
|
16
|
-
SupportHelper.thankYou = CommonRandomItemFromList(SupportHelper.thankYou, SupportHelper.thankYouList);
|
|
17
|
-
SupportHelper.thankYouNext = CommonTime() + 5000;
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export class GuiSupport extends BaseSubscreen {
|
|
22
|
-
get name(): string {
|
|
23
|
-
return 'Support';
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
get currentPage(): SettingElement[] {
|
|
27
|
-
return [
|
|
28
|
-
<Button>{
|
|
29
|
-
type: 'button',
|
|
30
|
-
id: 'deeplib-support-kofi',
|
|
31
|
-
size: [405, 80],
|
|
32
|
-
label: getText('support.button.ko-fi'),
|
|
33
|
-
image: 'https://storage.ko-fi.com/cdn/nav-logo-stroke.png',
|
|
34
|
-
onClick() {
|
|
35
|
-
window.open('https://ko-fi.com/monikka_bc', '_blank');
|
|
36
|
-
}
|
|
37
|
-
},
|
|
38
|
-
<Button>{
|
|
39
|
-
type: 'button',
|
|
40
|
-
id: 'deeplib-support-patreon',
|
|
41
|
-
size: [405, 80],
|
|
42
|
-
label: getText('support.button.patreon'),
|
|
43
|
-
image: 'https://c5.patreon.com/external/favicon/rebrand/favicon-32.png?v=af5597c2ef',
|
|
44
|
-
onClick() {
|
|
45
|
-
window.open('https://patreon.com/monikka_bc', '_blank');
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
];
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
load() {
|
|
52
|
-
SupportHelper.doNextThankYou();
|
|
53
|
-
super.load();
|
|
54
|
-
ElementRemove('deeplib-settngs');
|
|
55
|
-
|
|
56
|
-
ElementCreateDiv('deeplib-gratitude');
|
|
57
|
-
const elm = document.getElementById('deeplib-gratitude') as HTMLElement;
|
|
58
|
-
ElementContent('deeplib-gratitude', gratitudeHtml);
|
|
59
|
-
elementSetPosSizeFont({ element: elm }, 1000, 250, 400, 400);
|
|
60
|
-
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
run() {
|
|
64
|
-
super.run();
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
click() {
|
|
68
|
-
super.click();
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
exit() {
|
|
72
|
-
ElementRemove('deeplib-gratitude');
|
|
73
|
-
super.exit();
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
resize(): void {
|
|
77
|
-
super.resize();
|
|
78
|
-
elementSetPosSizeFont({ elementId: 'deeplib-gratitude' }, 1000, 250, 400, 400);
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
const gratitudeHtml = /*html*/ `
|
|
83
|
-
<h1>Dear Supporters!</h1>
|
|
84
|
-
<p>
|
|
85
|
-
I want to take a moment to express my heartfelt gratitude for considering supporting me. Your willingness to stand by
|
|
86
|
-
my side in this creative journey means the world to me, and I am truly humbled by your generosity.
|
|
87
|
-
</p>
|
|
88
|
-
<p>
|
|
89
|
-
Your support goes far beyond the financial contributions; it represents belief in my work and a shared passion for
|
|
90
|
-
what I do. Your encouragement inspires me to continue developing.
|
|
91
|
-
</p>
|
|
92
|
-
<p>
|
|
93
|
-
Your support not only helps me sustain and grow as a developer, but also enables me to dedicate more time and
|
|
94
|
-
resources to producing high-quality mods. It allows me to explore new ideas, enhance my skills, and bring even more
|
|
95
|
-
meaningful and enjoyable content to you.
|
|
96
|
-
</p>
|
|
97
|
-
<p>Thank you all~</p>
|
|
98
|
-
<p>With love, Monikka♥</p>
|
|
99
|
-
`;
|
package/src/Utilities/Data.ts
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { SettingsModel, _String, bcSdkMod, modules } from '../DeepLib';
|
|
2
|
-
|
|
3
|
-
export const PlayerStorage = (): Readonly<SettingsModel> => (
|
|
4
|
-
typeof Player?.[bcSdkMod.ModInfo.name] === 'object' ?
|
|
5
|
-
CommonCloneDeep(Player?.[bcSdkMod.ModInfo.name]) :
|
|
6
|
-
undefined
|
|
7
|
-
);
|
|
8
|
-
export const ExtensionStorage = (): Readonly<string> => Player.ExtensionSettings[bcSdkMod.ModInfo.name];
|
|
9
|
-
|
|
10
|
-
export function dataTake(modName: string = bcSdkMod.ModInfo.name) {
|
|
11
|
-
if (ExtensionStorage()) {
|
|
12
|
-
const parsed = JSON.parse(LZString.decompressFromBase64(ExtensionStorage()) || '');
|
|
13
|
-
Player[modName] = Object.hasOwn(parsed, 'Version') ? parsed : undefined;
|
|
14
|
-
} else {
|
|
15
|
-
Player[modName] = {};
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export function dataStore() {
|
|
20
|
-
const modName = bcSdkMod.ModInfo.name;
|
|
21
|
-
const modVersion = bcSdkMod.ModInfo.version;
|
|
22
|
-
|
|
23
|
-
if (!ExtensionStorage()) Player.ExtensionSettings[modName] = '';
|
|
24
|
-
const Data: SettingsModel = {
|
|
25
|
-
GlobalModule: {
|
|
26
|
-
modEnabled: false,
|
|
27
|
-
doShowNewVersionMessage: false
|
|
28
|
-
},
|
|
29
|
-
Version: modVersion
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
for (const module of modules()) {
|
|
33
|
-
if (!module.settingsStorage) continue;
|
|
34
|
-
|
|
35
|
-
Data[module.settingsStorage] = PlayerStorage()[module.settingsStorage];
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
Player.ExtensionSettings[modName] = _String.encode(Data);
|
|
39
|
-
ServerPlayerExtensionSettingsSync(modName);
|
|
40
|
-
}
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
export function elementCreateSubscreenDiv() {
|
|
2
|
-
const subscreenDiv = elementGetSubscreenDiv();
|
|
3
|
-
if (subscreenDiv) {
|
|
4
|
-
console.error('Subscreen already exists');
|
|
5
|
-
return subscreenDiv;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
const div = document.createElement('div');
|
|
9
|
-
div.id = 'deeplib-subscreen';
|
|
10
|
-
div.classList.add('deeplib-subscreen', 'HideOnPopup');
|
|
11
|
-
|
|
12
|
-
return document.body.appendChild(div);
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export function elementGetSubscreenDiv() {
|
|
16
|
-
return document.getElementById('deeplib-subscreen') ?? undefined;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export function elementRemoveSubscreenDiv() {
|
|
20
|
-
return elementGetSubscreenDiv()?.remove();
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export function elementAppendToSubscreenDiv(element: HTMLElement) {
|
|
24
|
-
return elementGetSubscreenDiv()?.appendChild(element);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export function elementCreateSettingsDiv() {
|
|
28
|
-
const settingsDiv = elementGetSettingsDiv();
|
|
29
|
-
if (settingsDiv) {
|
|
30
|
-
console.error('Settings screen already exists');
|
|
31
|
-
return settingsDiv;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
const div = document.createElement('div');
|
|
35
|
-
div.id = 'deeplib-settings';
|
|
36
|
-
div.classList.add('deeplib-settings');
|
|
37
|
-
|
|
38
|
-
return div;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
export function elementGetSettingsDiv() {
|
|
42
|
-
return document.getElementById('deeplib-settings') ?? undefined;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
export function elementAppendToSettingsDiv(element: HTMLElement) {
|
|
46
|
-
return elementGetSettingsDiv()?.appendChild(element);
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
export function elementCreateMiscDiv() {
|
|
50
|
-
const miscDiv = elementGetMiscDiv();
|
|
51
|
-
if (miscDiv) {
|
|
52
|
-
console.error('Settings screen already exists');
|
|
53
|
-
return miscDiv;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
const div = document.createElement('div');
|
|
57
|
-
div.id = 'deeplib-misc';
|
|
58
|
-
div.classList.add('deeplib-misc');
|
|
59
|
-
|
|
60
|
-
return div;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
export function elementGetMiscDiv() {
|
|
64
|
-
return document.getElementById('deeplib-misc');
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
export function elementAppendToMiscDiv(element: HTMLElement) {
|
|
68
|
-
return elementGetMiscDiv()?.appendChild(element);
|
|
69
|
-
}
|
|
70
|
-
|
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
import { deepLibLogger } from '../../DeepLib';
|
|
2
|
-
|
|
3
|
-
type ElementOrId = { elementId?: string; element?: HTMLElement; };
|
|
4
|
-
|
|
5
|
-
const mainCanvasHeight = 1000;
|
|
6
|
-
const mainCanvasWidth = 2000;
|
|
7
|
-
|
|
8
|
-
export function getRelativeHeight(height: number) {
|
|
9
|
-
return height * (MainCanvas.canvas.clientHeight / mainCanvasHeight);
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export function getRelativeWidth(width: number) {
|
|
13
|
-
return width * (MainCanvas.canvas.clientWidth / mainCanvasWidth);
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export function getRelativeY(yPos: number) {
|
|
17
|
-
return MainCanvas.canvas.offsetTop + yPos * (MainCanvas.canvas.clientHeight / mainCanvasHeight);
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export function getRelativeX(xPos: number) {
|
|
21
|
-
return MainCanvas.canvas.offsetLeft + xPos * (MainCanvas.canvas.clientWidth / mainCanvasWidth);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export function elementSetPosition(_: ElementOrId, xPos: number, yPos: number) {
|
|
25
|
-
const element = elementGet(_, 'elementSetPosition');
|
|
26
|
-
if (!element) return;
|
|
27
|
-
|
|
28
|
-
const Top = getRelativeY(yPos);
|
|
29
|
-
const Left = getRelativeX(xPos);
|
|
30
|
-
|
|
31
|
-
Object.assign(element.style, {
|
|
32
|
-
position: 'fixed',
|
|
33
|
-
left: Left + 'px',
|
|
34
|
-
top: Top + 'px'
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export function elementSetSize(_: ElementOrId, width: number, height: number) {
|
|
39
|
-
const element = elementGet(_, 'elementSetSize');
|
|
40
|
-
if (!element) return;
|
|
41
|
-
|
|
42
|
-
const Height = getRelativeHeight(height);
|
|
43
|
-
const Width = getRelativeWidth(width);
|
|
44
|
-
|
|
45
|
-
Object.assign(element.style, {
|
|
46
|
-
width: Width + 'px',
|
|
47
|
-
height: Height + 'px',
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
export function elementAdjustFontSize(_: ElementOrId) {
|
|
52
|
-
const element = elementGet(_, 'elementAdjustFontSize');
|
|
53
|
-
if (!element) return;
|
|
54
|
-
|
|
55
|
-
const Font = MainCanvas.canvas.clientWidth <= MainCanvas.canvas.clientHeight * 2 ? MainCanvas.canvas.clientWidth / 50 : MainCanvas.canvas.clientHeight / 25;
|
|
56
|
-
|
|
57
|
-
Object.assign(element.style, {
|
|
58
|
-
fontSize: Font + 'px',
|
|
59
|
-
fontFamily: CommonGetFontName()
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
export function elementSetPosSizeFont(_: ElementOrId, xPos: number, yPos: number, width: number, height: number) {
|
|
64
|
-
if (elementGet(_, 'elementSetPosSizeFont') === null) return;
|
|
65
|
-
|
|
66
|
-
elementSetPosition(_, xPos, yPos);
|
|
67
|
-
elementSetSize(_, width, height);
|
|
68
|
-
elementAdjustFontSize(_);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
export function elementHide(_: ElementOrId) {
|
|
72
|
-
const element = elementGet(_, 'elementHide');
|
|
73
|
-
if (!element) return;
|
|
74
|
-
|
|
75
|
-
element.style.display = 'none';
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
export function elementUnhide(_: ElementOrId) {
|
|
79
|
-
const element = elementGet(_, 'elementUnhide');
|
|
80
|
-
if (!element) return;
|
|
81
|
-
|
|
82
|
-
element.style.display = '';
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
function elementGet(_: ElementOrId, funcName: string) {
|
|
86
|
-
if (!_) {
|
|
87
|
-
deepLibLogger.warn(`${funcName} called without an elementId or element`);
|
|
88
|
-
return null;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
const elementId = _.elementId ?? _.element?.id;
|
|
92
|
-
const element = _.element ?? document.getElementById(_.elementId!);
|
|
93
|
-
|
|
94
|
-
if (!element) {
|
|
95
|
-
deepLibLogger.warn(`A call to ${funcName} was made on non-existent element with id ${elementId}`);
|
|
96
|
-
return null;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
return element;
|
|
100
|
-
}
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { Button } from 'Types/elements';
|
|
2
|
-
import { BaseSubscreen, getRelativeHeight, getRelativeWidth, getRelativeX, getRelativeY } from '../../DeepLib';
|
|
3
|
-
|
|
4
|
-
export function elementCreateButton(options: Button) {
|
|
5
|
-
const width = options.size ? getRelativeWidth(options.size[0]) + 'px' : '';
|
|
6
|
-
const height = options.size ? getRelativeHeight(options.size[1]) + 'px' : '';
|
|
7
|
-
const left = options.position ? getRelativeX(options.position[0]) + 'px' : '';
|
|
8
|
-
const top = options.position ? getRelativeY(options.position[1]) + 'px' : '';
|
|
9
|
-
const position = options.position ? 'fixed' : '';
|
|
10
|
-
|
|
11
|
-
const button = ElementButton.Create(options.id, () => options.onClick(),
|
|
12
|
-
{
|
|
13
|
-
tooltip: options.tooltip,
|
|
14
|
-
label: options.label,
|
|
15
|
-
labelPosition: 'center',
|
|
16
|
-
},
|
|
17
|
-
{
|
|
18
|
-
button: {
|
|
19
|
-
classList: ['deeplib-button'],
|
|
20
|
-
children: [
|
|
21
|
-
{
|
|
22
|
-
tag: 'img',
|
|
23
|
-
attributes: {
|
|
24
|
-
id: `${options.id}-image`,
|
|
25
|
-
alt: '',
|
|
26
|
-
disabled: options.disabled,
|
|
27
|
-
decoding: 'async',
|
|
28
|
-
loading: 'lazy',
|
|
29
|
-
src: 'data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7' // 1x1 transparent image to get rid of broken image
|
|
30
|
-
},
|
|
31
|
-
dataAttributes: {
|
|
32
|
-
'size': options.size?.join('x'),
|
|
33
|
-
'position': options.position?.join('x'),
|
|
34
|
-
},
|
|
35
|
-
style: {
|
|
36
|
-
'--image': `url("${options.image}")`,
|
|
37
|
-
}
|
|
38
|
-
},
|
|
39
|
-
],
|
|
40
|
-
style: {
|
|
41
|
-
width: width,
|
|
42
|
-
height: height,
|
|
43
|
-
left: left,
|
|
44
|
-
top: top,
|
|
45
|
-
position: position,
|
|
46
|
-
}
|
|
47
|
-
},
|
|
48
|
-
}
|
|
49
|
-
);
|
|
50
|
-
|
|
51
|
-
BaseSubscreen.currentElements.push([button, options]);
|
|
52
|
-
|
|
53
|
-
return button;
|
|
54
|
-
}
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import { Checkbox } from 'Types/elements';
|
|
2
|
-
import { BaseSubscreen, elementSetTooltip, getRelativeHeight, getRelativeWidth, getRelativeX, getRelativeY } from '../../DeepLib';
|
|
3
|
-
|
|
4
|
-
export function elementCreateCheckbox(options: Checkbox) {
|
|
5
|
-
const elem = document.getElementById(options.id);
|
|
6
|
-
|
|
7
|
-
if (elem) return elem;
|
|
8
|
-
|
|
9
|
-
const width = options.size ? getRelativeWidth(options.size[0]) + 'px' : '';
|
|
10
|
-
const height = options.size ? getRelativeHeight(options.size[1]) + 'px' : '';
|
|
11
|
-
const left = options.position ? getRelativeX(options.position[0]) + 'px' : '';
|
|
12
|
-
const top = options.position ? getRelativeY(options.position[1]) + 'px' : '';
|
|
13
|
-
const position = options.position ? 'fixed' : '';
|
|
14
|
-
|
|
15
|
-
const retElem = ElementCreate({
|
|
16
|
-
tag: 'div',
|
|
17
|
-
classList: ['deeplib-checkbox-container'],
|
|
18
|
-
style: {
|
|
19
|
-
width: width,
|
|
20
|
-
height: height,
|
|
21
|
-
left: left,
|
|
22
|
-
top: top,
|
|
23
|
-
position: position,
|
|
24
|
-
},
|
|
25
|
-
dataAttributes: {
|
|
26
|
-
'size': options.size?.join('x'),
|
|
27
|
-
'position': options.position?.join('x'),
|
|
28
|
-
},
|
|
29
|
-
children: [
|
|
30
|
-
{
|
|
31
|
-
tag: 'input',
|
|
32
|
-
classList: ['deeplib-input'],
|
|
33
|
-
attributes: {
|
|
34
|
-
type: 'checkbox',
|
|
35
|
-
id: options.id,
|
|
36
|
-
checked: options.getSettingValue() || undefined,
|
|
37
|
-
},
|
|
38
|
-
},
|
|
39
|
-
{
|
|
40
|
-
tag: 'label',
|
|
41
|
-
classList: ['deeplib-text'],
|
|
42
|
-
attributes: {
|
|
43
|
-
for: options.id,
|
|
44
|
-
},
|
|
45
|
-
children: [options.label]
|
|
46
|
-
},
|
|
47
|
-
]
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
if (options.description) {
|
|
51
|
-
retElem.addEventListener('mouseover', () => {
|
|
52
|
-
elementSetTooltip(options.description);
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
retElem.addEventListener('mouseout', () => {
|
|
56
|
-
elementSetTooltip('');
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
BaseSubscreen.currentElements.push([retElem, options]);
|
|
61
|
-
|
|
62
|
-
return retElem;
|
|
63
|
-
}
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import { Input } from 'Types/elements';
|
|
2
|
-
import { BaseSubscreen, elementSetTooltip, getRelativeHeight, getRelativeWidth, getRelativeX, getRelativeY } from '../../DeepLib';
|
|
3
|
-
|
|
4
|
-
export function elementCreateInput(options: Input) {
|
|
5
|
-
const elem = document.getElementById(options.id);
|
|
6
|
-
|
|
7
|
-
if (elem) return elem;
|
|
8
|
-
|
|
9
|
-
const width = options.size ? getRelativeWidth(options.size[0]) + 'px' : '';
|
|
10
|
-
const height = options.size ? getRelativeHeight(options.size[1]) + 'px' : '';
|
|
11
|
-
const left = options.position ? getRelativeX(options.position[0]) + 'px' : '';
|
|
12
|
-
const top = options.position ? getRelativeY(options.position[1]) + 'px' : '';
|
|
13
|
-
const position = options.position ? 'fixed' : '';
|
|
14
|
-
|
|
15
|
-
const retElem = ElementCreate({
|
|
16
|
-
tag: 'div',
|
|
17
|
-
classList: ['deeplib-input-container'],
|
|
18
|
-
style: {
|
|
19
|
-
width: width,
|
|
20
|
-
height: height,
|
|
21
|
-
left: left,
|
|
22
|
-
top: top,
|
|
23
|
-
position: position,
|
|
24
|
-
},
|
|
25
|
-
dataAttributes: {
|
|
26
|
-
'size': options.size?.join('x'),
|
|
27
|
-
'position': options.position?.join('x'),
|
|
28
|
-
},
|
|
29
|
-
children: [
|
|
30
|
-
{
|
|
31
|
-
tag: 'input',
|
|
32
|
-
classList: ['deeplib-input'],
|
|
33
|
-
attributes: {
|
|
34
|
-
type: options.type,
|
|
35
|
-
id: options.id,
|
|
36
|
-
placeholder: ' ',
|
|
37
|
-
},
|
|
38
|
-
},
|
|
39
|
-
{
|
|
40
|
-
tag: 'label',
|
|
41
|
-
classList: ['deeplib-text'],
|
|
42
|
-
attributes: {
|
|
43
|
-
for: options.id,
|
|
44
|
-
},
|
|
45
|
-
children: [options.label]
|
|
46
|
-
},
|
|
47
|
-
{
|
|
48
|
-
tag: 'div',
|
|
49
|
-
classList: ['deeplib-underline'],
|
|
50
|
-
}
|
|
51
|
-
]
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
if (options.getElementValue?.()) {
|
|
55
|
-
const input = document.getElementById(options.id) as HTMLInputElement;
|
|
56
|
-
if (input) input.value = options.getElementValue();
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
if (options.description) {
|
|
60
|
-
retElem.addEventListener('mouseover', () => {
|
|
61
|
-
elementSetTooltip(options.description);
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
retElem.addEventListener('mouseout', () => {
|
|
65
|
-
elementSetTooltip('');
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
BaseSubscreen.currentElements.push([retElem, options]);
|
|
70
|
-
|
|
71
|
-
return retElem;
|
|
72
|
-
}
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { Label } from 'Types/elements';
|
|
2
|
-
import { BaseSubscreen, elementSetTooltip, getRelativeHeight, getRelativeWidth, getRelativeX, getRelativeY } from '../../DeepLib';
|
|
3
|
-
|
|
4
|
-
export function elementCreateLabel(options: Label) {
|
|
5
|
-
const elem = document.getElementById(options.id);
|
|
6
|
-
|
|
7
|
-
if (elem) return elem;
|
|
8
|
-
|
|
9
|
-
const width = options.size ? getRelativeWidth(options.size[0]) + 'px' : '';
|
|
10
|
-
const height = options.size ? getRelativeHeight(options.size[1]) + 'px' : '';
|
|
11
|
-
const left = options.position ? getRelativeX(options.position[0]) + 'px' : '';
|
|
12
|
-
const top = options.position ? getRelativeY(options.position[1]) + 'px' : '';
|
|
13
|
-
const position = options.position ? 'fixed' : '';
|
|
14
|
-
|
|
15
|
-
const retElem = ElementCreate({
|
|
16
|
-
tag: 'span',
|
|
17
|
-
classList: ['deeplib-label', 'deeplib-text'],
|
|
18
|
-
attributes: {
|
|
19
|
-
id: options.id
|
|
20
|
-
},
|
|
21
|
-
style: {
|
|
22
|
-
width: width,
|
|
23
|
-
height: height,
|
|
24
|
-
left: left,
|
|
25
|
-
top: top,
|
|
26
|
-
position: position,
|
|
27
|
-
},
|
|
28
|
-
dataAttributes: {
|
|
29
|
-
'size': options.size?.join('x'),
|
|
30
|
-
'position': options.position?.join('x'),
|
|
31
|
-
},
|
|
32
|
-
children: [
|
|
33
|
-
options.label,
|
|
34
|
-
],
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
if (options.description) {
|
|
38
|
-
retElem.addEventListener('mouseover', () => {
|
|
39
|
-
elementSetTooltip(options.description as string);
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
retElem.addEventListener('mouseout', () => {
|
|
43
|
-
elementSetTooltip('');
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
BaseSubscreen.currentElements.push([retElem, options]);
|
|
48
|
-
|
|
49
|
-
return retElem;
|
|
50
|
-
}
|