Skip to content

Commit 0fb0ffe

Browse files
committed
Functionality-less Custom Dialog Windows
1 parent 815b71b commit 0fb0ffe

File tree

10 files changed

+168
-21
lines changed

10 files changed

+168
-21
lines changed

.nvmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
v18.14.2

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
"@typescript-eslint/eslint-plugin": "^5.0.0",
4343
"@typescript-eslint/parser": "^5.0.0",
4444
"@vercel/webpack-asset-relocator-loader": "1.7.3",
45+
"copy-webpack-plugin": "^12.0.2",
4546
"css-loader": "^6.0.0",
4647
"electron": "28.0.0",
4748
"eslint": "^8.0.1",

src/custom-dialogs.ts

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
import { BrowserWindow, BrowserWindowConstructorOptions } from "electron";
2+
import path from "path";
3+
4+
const WINDOW_OPTIONS: BrowserWindowConstructorOptions = {
5+
resizable: false,
6+
modal: true,
7+
autoHideMenuBar: true,
8+
minimizable: false,
9+
maximizable: false,
10+
alwaysOnTop: true,
11+
fullscreenable: false,
12+
darkTheme: true,
13+
webPreferences: {
14+
devTools: false
15+
}
16+
}
17+
18+
export function alert(
19+
parentWindow: BrowserWindow,
20+
options: {
21+
body: string,
22+
title?: string // ?
23+
}
24+
): void {
25+
const alertOptions: BrowserWindowConstructorOptions = {
26+
width: 360,
27+
height: 85, // 115, //TODO: Constant sizing wont work for windows with more than one line
28+
parent: parentWindow,
29+
};
30+
const customDialogWin: BrowserWindow = new BrowserWindow(
31+
Object.assign({}, WINDOW_OPTIONS, alertOptions)
32+
);
33+
customDialogWin.loadFile(path.join(
34+
__dirname,
35+
"custom-dialogs/alert.html"
36+
));
37+
console.log(options);
38+
}
39+
40+
export function confirm(
41+
parentWindow: BrowserWindow,
42+
options: {
43+
body: string,
44+
title?: string // ?
45+
callback?: ((result: boolean) => void),
46+
}
47+
): void {
48+
const alertOptions: BrowserWindowConstructorOptions = {
49+
width: 360,
50+
height: 85, // 115, //TODO: Constant sizing wont work for windows with more than one line
51+
parent: parentWindow,
52+
};
53+
const customDialogWin: BrowserWindow = new BrowserWindow(
54+
Object.assign({}, WINDOW_OPTIONS, alertOptions)
55+
);
56+
customDialogWin.loadFile(path.join(
57+
__dirname,
58+
"custom-dialogs/confirm.html"
59+
));
60+
console.log(options);
61+
}
62+
63+
export function prompt(
64+
parentWindow: BrowserWindow,
65+
options: {
66+
body: string,
67+
title?: string // ?
68+
placeholder?: string,
69+
callback?: ((result: string) => void),
70+
invalidCharacters?: RegExp,
71+
}
72+
): void {
73+
const alertOptions: BrowserWindowConstructorOptions = {
74+
width: 360,
75+
height: 107, //TODO: Constant sizing wont work for windows with more than one line
76+
parent: parentWindow,
77+
};
78+
const customDialogWin: BrowserWindow = new BrowserWindow(
79+
Object.assign({}, WINDOW_OPTIONS, alertOptions)
80+
);
81+
customDialogWin.loadFile(path.join(
82+
__dirname,
83+
"custom-dialogs/prompt.html"
84+
));
85+
console.log(options);
86+
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
<head>
44
<meta charset="UTF-8" />
55
<title>CMC Mod Manager</title>
6-
<link rel="stylesheet" href="./custom-dialog.css" type="text/css">
6+
<link rel="stylesheet" href="./custom-dialogs.css" type="text/css">
77
</head>
88
<body>
9-
<h1 id="title">Title</h1>
9+
<!-- <h1 id="title">Title</h1> -->
1010
<div class="center">
1111
<span id="body">Body</span>
1212
</div>
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
<head>
44
<meta charset="UTF-8" />
55
<title>CMC Mod Manager</title>
6-
<link rel="stylesheet" href="./custom-dialog.css" type="text/css">
6+
<link rel="stylesheet" href="./custom-dialogs.css" type="text/css">
77
</head>
88
<body>
9-
<h1 id="title">Title</h1>
9+
<!-- <h1 id="title">Title</h1> -->
1010
<div class="center">
1111
<span id="body">Body</span>
1212
</div>
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
<head>
44
<meta charset="UTF-8" />
55
<title>CMC Mod Manager</title>
6-
<link rel="stylesheet" href="./custom-dialog.css" type="text/css">
6+
<link rel="stylesheet" href="./custom-dialogs.css" type="text/css">
77
</head>
88
<body>
9-
<h1 id="title">Title</h1>
9+
<!-- <h1 id="title">Title</h1> -->
1010
<div class="center">
1111
<span id="body">Body</span>
1212
</div>

src/main.ts

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ global.downloads = [];
2626
import * as general from "./general";
2727
import * as characters from "./characters";
2828
import * as stages from "./stages";
29+
import * as customDialogs from "./custom-dialogs";
2930

3031
function createWindow(): void {
3132
global.win = new BrowserWindow({
@@ -37,6 +38,7 @@ function createWindow(): void {
3738
preload: MAIN_WINDOW_PRELOAD_WEBPACK_ENTRY,
3839
},
3940
autoHideMenuBar: true,
41+
darkTheme: true
4042
});
4143
global.win.loadURL(MAIN_WINDOW_WEBPACK_ENTRY);
4244

@@ -61,16 +63,9 @@ function createWindow(): void {
6163
});
6264

6365
general.checkForUpdates();
64-
65-
// const customDialogWin: BrowserWindow = new BrowserWindow({
66-
// width: 360,
67-
// height: 120,
68-
// parent: global.win,
69-
// modal: true,
70-
// title: "Title",
71-
// autoHideMenuBar: true,
72-
// });
73-
// customDialogWin.loadFile("./custom-dialog/alert.html");
66+
customDialogs.alert(global.win, { body: "Alert" });
67+
customDialogs.confirm(global.win, { body: "Confirm" });
68+
customDialogs.prompt(global.win, { body: "Prompt" });
7469
}
7570

7671
if (require("electron-squirrel-startup")) {

webpack.plugins.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,18 @@
11
import type IForkTsCheckerWebpackPlugin from "fork-ts-checker-webpack-plugin";
22

3-
// eslint-disable-next-line @typescript-eslint/no-var-requires
4-
const ForkTsCheckerWebpackPlugin: typeof IForkTsCheckerWebpackPlugin = require("fork-ts-checker-webpack-plugin");
3+
/* eslint-disable @typescript-eslint/no-var-requires */
4+
const ForkTsCheckerWebpackPlugin: typeof IForkTsCheckerWebpackPlugin =
5+
require("fork-ts-checker-webpack-plugin");
6+
const CopyPlugin: any = require("copy-webpack-plugin");
7+
/* eslint-enable @typescript-eslint/no-var-requires */
58

69
export const plugins: IForkTsCheckerWebpackPlugin[] = [
710
new ForkTsCheckerWebpackPlugin({
811
logger: "webpack-infrastructure",
912
}),
13+
new CopyPlugin({
14+
patterns: [
15+
{ from: "src/custom-dialogs", to: "custom-dialogs" },
16+
],
17+
}),
1018
];

yarn.lock

Lines changed: 59 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -571,6 +571,11 @@
571571
resolved "https://registry.npmjs.org/@sindresorhus/is/-/is-4.6.0.tgz"
572572
integrity sha512-t09vSN3MdfsyCHoFcTRCH/iUtG7OJ0CsjzB8cjAmKc/va/kIgeDI/TxsigdncE/4be734m0cvIYwNaV4i2XqAw==
573573

574+
"@sindresorhus/merge-streams@^1.0.0":
575+
version "1.0.0"
576+
resolved "https://registry.yarnpkg.com/@sindresorhus/merge-streams/-/merge-streams-1.0.0.tgz#9cd84cc15bc865a5ca35fcaae198eb899f7b5c90"
577+
integrity sha512-rUV5WyJrJLoloD4NDN1V1+LDMDWOa4OTsT4yYJwQNpTU6FWxkxHpL7eu4w+DmiH8x/EAM1otkPE1+LaspIbplw==
578+
574579
"@stylistic/eslint-plugin-js@1.5.1", "@stylistic/eslint-plugin-js@^1.5.1":
575580
version "1.5.1"
576581
resolved "https://registry.yarnpkg.com/@stylistic/eslint-plugin-js/-/eslint-plugin-js-1.5.1.tgz#888a63128f95d4d2d6be6d67df077bb4823f6c24"
@@ -1986,6 +1991,18 @@ cookie@0.5.0:
19861991
resolved "https://registry.npmjs.org/cookie/-/cookie-0.5.0.tgz"
19871992
integrity sha512-YZ3GUyn/o8gfKJlnlX7g7xq4gyO6OSuhGPKaaGssGB2qgDUS0gPgtTvoyZLTt9Ab6dC4hfc9dV5arkvc/OCmrw==
19881993

1994+
copy-webpack-plugin@^12.0.2:
1995+
version "12.0.2"
1996+
resolved "https://registry.yarnpkg.com/copy-webpack-plugin/-/copy-webpack-plugin-12.0.2.tgz#935e57b8e6183c82f95bd937df658a59f6a2da28"
1997+
integrity sha512-SNwdBeHyII+rWvee/bTnAYyO8vfVdcSTud4EIb6jcZ8inLeWucJE0DnxXQBjlQ5zlteuuvooGQy3LIyGxhvlOA==
1998+
dependencies:
1999+
fast-glob "^3.3.2"
2000+
glob-parent "^6.0.1"
2001+
globby "^14.0.0"
2002+
normalize-path "^3.0.0"
2003+
schema-utils "^4.2.0"
2004+
serialize-javascript "^6.0.2"
2005+
19892006
core-util-is@1.0.2:
19902007
version "1.0.2"
19912008
resolved "https://registry.yarnpkg.com/core-util-is/-/core-util-is-1.0.2.tgz#b5fd54220aa2bc5ab57aab7140c940754503c1a7"
@@ -2819,7 +2836,7 @@ fast-deep-equal@^3.1.1, fast-deep-equal@^3.1.3:
28192836
resolved "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz"
28202837
integrity sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==
28212838

2822-
fast-glob@^3.2.7, fast-glob@^3.2.9:
2839+
fast-glob@^3.2.7, fast-glob@^3.2.9, fast-glob@^3.3.2:
28232840
version "3.3.2"
28242841
resolved "https://registry.npmjs.org/fast-glob/-/fast-glob-3.3.2.tgz"
28252842
integrity sha512-oX2ruAFQwf/Orj8m737Y5adxDQO0LAB7/S5MnxCdTNDd4p6BsyIVsv9JQsATbTSq8KHRpLwIHbVlUNatxd+1Ow==
@@ -3220,7 +3237,7 @@ glob-parent@^5.1.2, glob-parent@~5.1.2:
32203237
dependencies:
32213238
is-glob "^4.0.1"
32223239

3223-
glob-parent@^6.0.2:
3240+
glob-parent@^6.0.1, glob-parent@^6.0.2:
32243241
version "6.0.2"
32253242
resolved "https://registry.npmjs.org/glob-parent/-/glob-parent-6.0.2.tgz"
32263243
integrity sha512-XxwI8EOhVQgWp6iDL+3b0r86f4d6AX6zSU55HfB4ydCEuXLXc5FcYeOu+nnGftS4TEju/11rt4KJPTMgbfmv4A==
@@ -3313,6 +3330,18 @@ globby@^11.1.0:
33133330
merge2 "^1.4.1"
33143331
slash "^3.0.0"
33153332

3333+
globby@^14.0.0:
3334+
version "14.0.0"
3335+
resolved "https://registry.yarnpkg.com/globby/-/globby-14.0.0.tgz#ea9c062a3614e33f516804e778590fcf055256b9"
3336+
integrity sha512-/1WM/LNHRAOH9lZta77uGbq0dAEQM+XjNesWwhlERDVenqothRbnzTrL3/LrIoEPPjeUHC3vrS6TwoyxeHs7MQ==
3337+
dependencies:
3338+
"@sindresorhus/merge-streams" "^1.0.0"
3339+
fast-glob "^3.3.2"
3340+
ignore "^5.2.4"
3341+
path-type "^5.0.0"
3342+
slash "^5.1.0"
3343+
unicorn-magic "^0.1.0"
3344+
33163345
gopd@^1.0.1:
33173346
version "1.0.1"
33183347
resolved "https://registry.npmjs.org/gopd/-/gopd-1.0.1.tgz"
@@ -3613,6 +3642,11 @@ ignore@^5.2.0:
36133642
resolved "https://registry.npmjs.org/ignore/-/ignore-5.3.0.tgz"
36143643
integrity sha512-g7dmpshy+gD7mh88OC9NwSGTKoc3kyLAZQRU1mt53Aw/vnvfXnbC+F/7F7QoYVKbV+KNvJx8wArewKy1vXMtlg==
36153644

3645+
ignore@^5.2.4:
3646+
version "5.3.1"
3647+
resolved "https://registry.yarnpkg.com/ignore/-/ignore-5.3.1.tgz#5073e554cd42c5b33b394375f538b8593e34d4ef"
3648+
integrity sha512-5Fytz/IraMjqpwfd34ke28PTVMjZjJG2MPn5t7OE4eUCUNf8BAa7b5WUS9/Qvr6mwOQS7Mk6vdsMno5he+T8Xw==
3649+
36163650
import-fresh@^3.2.1:
36173651
version "3.3.0"
36183652
resolved "https://registry.npmjs.org/import-fresh/-/import-fresh-3.3.0.tgz"
@@ -4919,6 +4953,11 @@ path-type@^4.0.0:
49194953
resolved "https://registry.npmjs.org/path-type/-/path-type-4.0.0.tgz"
49204954
integrity sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw==
49214955

4956+
path-type@^5.0.0:
4957+
version "5.0.0"
4958+
resolved "https://registry.yarnpkg.com/path-type/-/path-type-5.0.0.tgz#14b01ed7aea7ddf9c7c3f46181d4d04f9c785bb8"
4959+
integrity sha512-5HviZNaZcfqP95rwpv+1HDgUamezbqdSYTyzjTvwtJSnIH+3vnbmWsItli8OFEndS984VT55M3jduxZbX351gg==
4960+
49224961
path@^0.12.7:
49234962
version "0.12.7"
49244963
resolved "https://registry.yarnpkg.com/path/-/path-0.12.7.tgz#d4dc2a506c4ce2197eb481ebfcd5b36c0140b10f"
@@ -5451,7 +5490,7 @@ schema-utils@^3.0.0, schema-utils@^3.1.1, schema-utils@^3.2.0:
54515490
ajv "^6.12.5"
54525491
ajv-keywords "^3.5.2"
54535492

5454-
schema-utils@^4.0.0:
5493+
schema-utils@^4.0.0, schema-utils@^4.2.0:
54555494
version "4.2.0"
54565495
resolved "https://registry.npmjs.org/schema-utils/-/schema-utils-4.2.0.tgz"
54575496
integrity sha512-L0jRsrPpjdckP3oPug3/VxNKt2trR8TcabrM6FOAAlvC/9Phcmm+cuAgTlxBqdBR1WJx7Naj9WHw+aOmheSVbw==
@@ -5529,6 +5568,13 @@ serialize-javascript@^6.0.1:
55295568
dependencies:
55305569
randombytes "^2.1.0"
55315570

5571+
serialize-javascript@^6.0.2:
5572+
version "6.0.2"
5573+
resolved "https://registry.yarnpkg.com/serialize-javascript/-/serialize-javascript-6.0.2.tgz#defa1e055c83bf6d59ea805d8da862254eb6a6c2"
5574+
integrity sha512-Saa1xPByTTq2gdeFZYLLo+RFE35NHZkAbqZeWNd3BpzppeVisAqpDjcp8dyf6uIvEqJRd46jemmyA4iFIeVk8g==
5575+
dependencies:
5576+
randombytes "^2.1.0"
5577+
55325578
serve-index@^1.9.1:
55335579
version "1.9.1"
55345580
resolved "https://registry.npmjs.org/serve-index/-/serve-index-1.9.1.tgz"
@@ -5641,6 +5687,11 @@ slash@^3.0.0:
56415687
resolved "https://registry.npmjs.org/slash/-/slash-3.0.0.tgz"
56425688
integrity sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==
56435689

5690+
slash@^5.1.0:
5691+
version "5.1.0"
5692+
resolved "https://registry.yarnpkg.com/slash/-/slash-5.1.0.tgz#be3adddcdf09ac38eebe8dcdc7b1a57a75b095ce"
5693+
integrity sha512-ZA6oR3T/pEyuqwMgAKT0/hAv8oAXckzbkmR0UkUosQ+Mc4RxGoJkRmwHgHufaenlyAgE1Mxgpdcrf75y6XcnDg==
5694+
56445695
slice-ansi@^3.0.0:
56455696
version "3.0.0"
56465697
resolved "https://registry.npmjs.org/slice-ansi/-/slice-ansi-3.0.0.tgz"
@@ -6201,6 +6252,11 @@ undici-types@~5.26.4:
62016252
resolved "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz"
62026253
integrity sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==
62036254

6255+
unicorn-magic@^0.1.0:
6256+
version "0.1.0"
6257+
resolved "https://registry.yarnpkg.com/unicorn-magic/-/unicorn-magic-0.1.0.tgz#1bb9a51c823aaf9d73a8bfcd3d1a23dde94b0ce4"
6258+
integrity sha512-lRfVq8fE8gz6QMBuDM6a+LO3IAzTi05H6gCVaUpir2E1Rwpo4ZUog45KpNXKC/Mn3Yb9UDuHumeFTo9iV/D9FQ==
6259+
62046260
unique-filename@^2.0.0:
62056261
version "2.0.1"
62066262
resolved "https://registry.npmjs.org/unique-filename/-/unique-filename-2.0.1.tgz"

0 commit comments

Comments
 (0)