Multiple improvements

- added action buttons (open launcher's folder, winecfg, winetricks)
- improved i18n.translate method which now can use user-provided placeholders
- disabled text selection ability
This commit is contained in:
Observer KRypt0n_ 2021-11-28 15:52:14 +02:00
parent 90030bf1ba
commit 7f9df4f66e
No known key found for this signature in database
GPG key ID: DC5D4EC1303465DA
19 changed files with 94 additions and 7 deletions

View file

@ -129,6 +129,14 @@
</div> </div>
</div> </div>
<br><br>
<div id="general-action-buttons">
<button class="button" id="launcher-folder">launcher folder</button>
<button class="button" id="winetricks">winetricks</button>
<button class="button" id="winecfg">winecfg</button>
</div>
<br> <br>
</div> </div>

View file

@ -11,6 +11,7 @@
"Light": "Hell", "Light": "Hell",
"Dark": "Dunkel", "Dark": "Dunkel",
"System": "System", "System": "System",
"HasNotInstalled": "{0} has not installed",
"PreInstallationRequired": "Vorinstallation erförderlich", "PreInstallationRequired": "Vorinstallation erförderlich",
"ToggleShadersText": "Verwenden Sie die Home-Taste (POS 1), um Shader im Spiel ein/aus-zuschalten", "ToggleShadersText": "Verwenden Sie die Home-Taste (POS 1), um Shader im Spiel ein/aus-zuschalten",
"Shaders": "Shadern", "Shaders": "Shadern",

View file

@ -11,6 +11,7 @@
"Light": "Light", "Light": "Light",
"Dark": "Dark", "Dark": "Dark",
"System": "System", "System": "System",
"HasNotInstalled": "{0} has not installed",
"PreInstallationRequired": "pre-installation required", "PreInstallationRequired": "pre-installation required",
"ToggleShadersText": "Use Home button to toggle shaders in the game", "ToggleShadersText": "Use Home button to toggle shaders in the game",
"Shaders": "Shaders", "Shaders": "Shaders",

View file

@ -11,6 +11,7 @@
"Light": "Light", "Light": "Light",
"Dark": "Dark", "Dark": "Dark",
"System": "System", "System": "System",
"HasNotInstalled": "{0} has not installed",
"PreInstallationRequired": "pre-installation required", "PreInstallationRequired": "pre-installation required",
"ToggleShadersText": "Use Home button to toggle shaders in the game", "ToggleShadersText": "Use Home button to toggle shaders in the game",
"Shaders": "Shaders", "Shaders": "Shaders",

View file

@ -11,6 +11,7 @@
"Light": "Light", "Light": "Light",
"Dark": "Dark", "Dark": "Dark",
"System": "System", "System": "System",
"HasNotInstalled": "{0} has not installed",
"PreInstallationRequired": "pre-installation required", "PreInstallationRequired": "pre-installation required",
"ToggleShadersText": "Use Home button to toggle shaders in the game", "ToggleShadersText": "Use Home button to toggle shaders in the game",
"Shaders": "Shaders", "Shaders": "Shaders",

View file

@ -11,6 +11,7 @@
"Light": "Light", "Light": "Light",
"Dark": "Dark", "Dark": "Dark",
"System": "System", "System": "System",
"HasNotInstalled": "{0} has not installed",
"PreInstallationRequired": "pre-installation required", "PreInstallationRequired": "pre-installation required",
"ToggleShadersText": "Use Home button to toggle shaders in the game", "ToggleShadersText": "Use Home button to toggle shaders in the game",
"Shaders": "Shaders", "Shaders": "Shaders",

View file

@ -11,6 +11,7 @@
"Light": "Terang", "Light": "Terang",
"Dark": "Gelap", "Dark": "Gelap",
"System": "Sistem", "System": "Sistem",
"HasNotInstalled": "{0} has not installed",
"PreInstallationRequired": "pra-pemasangan dibutuhkan", "PreInstallationRequired": "pra-pemasangan dibutuhkan",
"ToggleShadersText": "Gunakan tombol Home untuk menyalakan/mematikan shader di dalam Game", "ToggleShadersText": "Gunakan tombol Home untuk menyalakan/mematikan shader di dalam Game",
"Shaders": "Shader", "Shaders": "Shader",

View file

@ -11,6 +11,7 @@
"Light": "ライト", "Light": "ライト",
"Dark": "暗い", "Dark": "暗い",
"System": "システム", "System": "システム",
"HasNotInstalled": "{0} has not installed",
"PreInstallationRequired": "事前インストールが必要", "PreInstallationRequired": "事前インストールが必要",
"ToggleShadersText": "ホームボタンを使用してゲーム内のシェーダを切り替えます", "ToggleShadersText": "ホームボタンを使用してゲーム内のシェーダを切り替えます",
"Shaders": "シェーダ", "Shaders": "シェーダ",

View file

@ -11,6 +11,7 @@
"Light": "빛", "Light": "빛",
"Dark": "어두운", "Dark": "어두운",
"System": "시스템", "System": "시스템",
"HasNotInstalled": "{0} has not installed",
"PreInstallationRequired": "사전 설치 필요", "PreInstallationRequired": "사전 설치 필요",
"ToggleShadersText": "홈 버튼을 사용하여 게임에서 쉐이더를 전환하십시오", "ToggleShadersText": "홈 버튼을 사용하여 게임에서 쉐이더를 전환하십시오",
"Shaders": "쉐이더", "Shaders": "쉐이더",

View file

@ -11,6 +11,7 @@
"Light": "Light", "Light": "Light",
"Dark": "Dark", "Dark": "Dark",
"System": "System", "System": "System",
"HasNotInstalled": "{0} has not installed",
"PreInstallationRequired": "pre-installation required", "PreInstallationRequired": "pre-installation required",
"ToggleShadersText": "Use Home button to toggle shaders in the game", "ToggleShadersText": "Use Home button to toggle shaders in the game",
"Shaders": "Shaders", "Shaders": "Shaders",

View file

@ -11,6 +11,7 @@
"Light": "Светлая", "Light": "Светлая",
"Dark": "Тёмная", "Dark": "Тёмная",
"System": "Системная", "System": "Системная",
"HasNotInstalled": "{0} не установлен",
"PreInstallationRequired": "требуется предустановка", "PreInstallationRequired": "требуется предустановка",
"ToggleShadersText": "Используйте кнопку Home для переключения шейдеров в игре", "ToggleShadersText": "Используйте кнопку Home для переключения шейдеров в игре",
"Shaders": "Шейдеры", "Shaders": "Шейдеры",

View file

@ -11,6 +11,7 @@
"Light": "Light", "Light": "Light",
"Dark": "Dark", "Dark": "Dark",
"System": "System", "System": "System",
"HasNotInstalled": "{0} has not installed",
"PreInstallationRequired": "pre-installation required", "PreInstallationRequired": "pre-installation required",
"ToggleShadersText": "Use Home button to toggle shaders in the game", "ToggleShadersText": "Use Home button to toggle shaders in the game",
"Shaders": "Shaders", "Shaders": "Shaders",

View file

@ -11,6 +11,7 @@
"Light": "Light", "Light": "Light",
"Dark": "Dark", "Dark": "Dark",
"System": "System", "System": "System",
"HasNotInstalled": "{0} has not installed",
"PreInstallationRequired": "pre-installation required", "PreInstallationRequired": "pre-installation required",
"ToggleShadersText": "Use Home button to toggle shaders in the game", "ToggleShadersText": "Use Home button to toggle shaders in the game",
"Shaders": "Shaders", "Shaders": "Shaders",

View file

@ -11,6 +11,7 @@
"Light": "Light", "Light": "Light",
"Dark": "Dark", "Dark": "Dark",
"System": "System", "System": "System",
"HasNotInstalled": "{0} has not installed",
"PreInstallationRequired": "pre-installation required", "PreInstallationRequired": "pre-installation required",
"ToggleShadersText": "Use Home button to toggle shaders in the game", "ToggleShadersText": "Use Home button to toggle shaders in the game",
"Shaders": "Shaders", "Shaders": "Shaders",

View file

@ -11,6 +11,7 @@
"Light": "Light", "Light": "Light",
"Dark": "Dark", "Dark": "Dark",
"System": "System", "System": "System",
"HasNotInstalled": "{0} has not installed",
"PreInstallationRequired": "pre-installation required", "PreInstallationRequired": "pre-installation required",
"ToggleShadersText": "Use Home button to toggle shaders in the game", "ToggleShadersText": "Use Home button to toggle shaders in the game",
"Shaders": "Shaders", "Shaders": "Shaders",

View file

@ -4,6 +4,8 @@ body
margin: 0 margin: 0
padding: 0 padding: 0
user-select: none
img.background img.background
position: absolute position: absolute

View file

@ -358,9 +358,12 @@
color: map.get($theme-map, "text") color: map.get($theme-map, "text")
&:hover &:hover:not([disabled])
background-color: map.get($theme-map, "background2") background-color: map.get($theme-map, "background2")
&[disabled]
cursor: default
.button-primary .button-primary
background-color: map.get($theme-map, "background2") background-color: map.get($theme-map, "background2")

View file

@ -16,7 +16,7 @@ export default class i18n
public static loadedLanguage: any; public static loadedLanguage: any;
public static translate (phrase: string): string public static translate (phrase: string, placeholders: string[] = []): string
{ {
if (i18n.loadedLanguage === undefined) if (i18n.loadedLanguage === undefined)
this.setLang(navigator.language); this.setLang(navigator.language);
@ -24,7 +24,12 @@ export default class i18n
let translation = i18n.loadedLanguage[phrase] ?? phrase; let translation = i18n.loadedLanguage[phrase] ?? phrase;
let item; let item;
while ((item = /\{([a-zA-Z\.]+)\}/g.exec(translation)) !== null) while ((item = /\{([a-zA-Z0-9\.]+)\}/g.exec(translation)) !== null)
{
if (/^-?\d+$/.test(item[1]))
translation = translation.replace(item[0], placeholders[parseInt(item[1])]);
else
{ {
let value: any = constants; let value: any = constants;
@ -32,6 +37,7 @@ export default class i18n
translation = translation.replace(item[0], value); translation = translation.replace(item[0], value);
} }
}
return translation; return translation;
} }

View file

@ -1,7 +1,7 @@
const fs = require('fs'); const fs = require('fs');
const path = require('path'); const path = require('path');
const { ipcRenderer } = require('electron'); const { ipcRenderer } = require('electron');
const { exec } = require('child_process'); const { exec, spawn } = require('child_process');
const commandExists = require('command-exists').sync; const commandExists = require('command-exists').sync;
@ -92,6 +92,60 @@ $(() => {
} }
}); });
/**
* Action buttons
*/
$('#general-action-buttons #launcher-folder').on('click', () => {
spawn('xdg-open', [constants.launcherDir]);
});
/**
* winetricks button
*/
if (!commandExists('winetricks'))
{
$('#general-action-buttons #winetricks').on('click', () => {
exec('winetricks', {
env: {
...process.env,
WINEPREFIX: constants.prefixDir
}
});
});
}
else
{
$('#general-action-buttons #winetricks')
.addClass('hint--top hint--small')
.attr('data-hint', LauncherUI.i18n.translate('HasNotInstalled', ['winetricks']))
.attr('disabled', 'disabled');
}
/**
* winecfg button
*/
if (!commandExists('winecfg'))
{
$('#general-action-buttons #winecfg').on('click', () => {
exec('winecfg', {
env: {
...process.env,
WINEPREFIX: constants.prefixDir
}
});
});
}
else
{
$('#general-action-buttons #winecfg')
.addClass('hint--top hint--small')
.attr('data-hint', LauncherUI.i18n.translate('HasNotInstalled', ['winecfg']))
.attr('disabled', 'disabled');
}
/** /**
* HUD * HUD
*/ */