diff options
author | 0neGal <mail@0negal.com> | 2021-12-29 22:59:47 +0100 |
---|---|---|
committer | 0neGal <mail@0negal.com> | 2021-12-29 22:59:47 +0100 |
commit | 474f2ae54000463a0a2dfc84ad678a7620cc3d44 (patch) | |
tree | 3ead3d9fb078daefed14392db88c1cb3a4af8a7e | |
parent | 4abe10aebdfa06c9b9c31c98f084d511e3e2e319 (diff) | |
download | Viper-474f2ae54000463a0a2dfc84ad678a7620cc3d44.tar.gz Viper-474f2ae54000463a0a2dfc84ad678a7620cc3d44.zip |
proper responsiveness for all languages
This should more or less ensure everything remains responsive even if
the language is one with very long strings.
-rw-r--r-- | src/app/index.html | 2 | ||||
-rw-r--r-- | src/app/lang.js | 16 | ||||
-rw-r--r-- | src/app/main.css | 5 | ||||
-rw-r--r-- | src/app/main.js | 5 | ||||
-rw-r--r-- | src/index.js | 12 |
5 files changed, 29 insertions, 11 deletions
diff --git a/src/app/index.html b/src/app/index.html index 1c34360..426b4c5 100644 --- a/src/app/index.html +++ b/src/app/index.html @@ -22,7 +22,7 @@ </div> </div> - <script src="main.js"></script> <script src="lang.js"></script> + <script src="main.js"></script> </body> </html> diff --git a/src/app/lang.js b/src/app/lang.js index 8cf3d4b..5cc9708 100644 --- a/src/app/lang.js +++ b/src/app/lang.js @@ -1,10 +1,12 @@ -html = document.body.innerHTML.split("%%"); +function setlang() { + html = document.body.innerHTML.split("%%"); -for (let i = 0; i < html.length; i++) { - if (html[i][0] != " " && - html[i][html[i].length - 1] != " ") { - html[i] = lang(html[i]) + for (let i = 0; i < html.length; i++) { + if (html[i][0] != " " && + html[i][html[i].length - 1] != " ") { + html[i] = lang(html[i]) + } } -} -document.body.innerHTML = html.join(""); + document.body.innerHTML = html.join(""); +} diff --git a/src/app/main.css b/src/app/main.css index 854c47a..c9c62fb 100644 --- a/src/app/main.css +++ b/src/app/main.css @@ -34,10 +34,14 @@ body, button, input { } .buttons { + text-align: right; margin-left: auto; margin-right: 7px; } +.text {max-width: 38vw} +.buttons {max-width: 55vw} + button, .text { border: none; outline: none; @@ -47,6 +51,7 @@ button, .text { } button { + margin-bottom: 10px; color: var(--btnforeground); -webkit-app-region: no-drag; } diff --git a/src/app/main.js b/src/app/main.js index 579f785..0118b0c 100644 --- a/src/app/main.js +++ b/src/app/main.js @@ -34,3 +34,8 @@ function launchVanilla() {ipcRenderer.send("launchVanilla")} ipcRenderer.on("newpath", (event, newpath) => { settings.gamepath = newpath; }) + +setlang(); +setInterval(() => { + ipcRenderer.send("setsize", document.querySelector(".lines").offsetHeight + 25); +}, 150) diff --git a/src/index.js b/src/index.js index fead15b..74f776c 100644 --- a/src/index.js +++ b/src/index.js @@ -9,9 +9,10 @@ const utils = require("./utils"); const cli = require("./cli"); function start() { + let width = 115; win = new BrowserWindow({ width: 600, - height: 115, + height: width, show: false, title: "Viper", resizable: false, @@ -26,10 +27,15 @@ function start() { win.removeMenu(); win.loadFile(__dirname + "/app/index.html"); - win.webContents.once("dom-ready", () => {win.show()}); - ipcMain.on("setpath", (event) => {utils.setpath(win)}) ipcMain.on("exit", (event) => {process.exit(0)}) + ipcMain.on("setpath", (event) => {utils.setpath(win)}) + ipcMain.on("setsize", (event, height) => { + win.setSize(width, height); + if (! win.isVisible()) { + win.show(); + } + }) } ipcMain.on("launch", (event) => {utils.launch()}) |