From 98ed3fe4e4821561ed2678a2b202d1df891b1a06 Mon Sep 17 00:00:00 2001 From: SpikeHD Date: Fri, 22 Apr 2022 20:39:12 -0700 Subject: [PATCH 1/9] add server image to build --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index b69abf2..a4c65e3 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,7 @@ "dev": "neu run", "build": "npm run clean_dist && neu build && npm run move_files && npm run move_bgs && npm run rename_exe", "move_files": "cp -r ./proxy ./dist/GrassClipper && cp -r ./scripts ./dist/GrassClipper", - "move_bgs": "mkdir dist\\GrassClipper\\resources\\bg\\private && cp -r ./resources/bg/private ./dist/GrassClipper/resources/bg", + "move_bgs": "mkdir dist\\GrassClipper\\resources\\bg\\private && cp -r ./resources/bg/private ./dist/GrassClipper/resources/bg && cp -r ./resources/bg/server ./dist/GrassClipper/resources/bg", "rename_exe": "mv ./dist/GrassClipper/GrassClipper-win_x64.exe ./dist/GrassClipper/GrassClipper.exe", "clean_dist": "rm -rf ./dist" } From 1f36a5a98f8d2d0f6c0b437203e2024b7df63eb9 Mon Sep 17 00:00:00 2001 From: SpikeHD Date: Fri, 22 Apr 2022 20:39:43 -0700 Subject: [PATCH 2/9] version bump --- manifest.json | 2 +- neutralino.config.json | 2 +- package.json | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/manifest.json b/manifest.json index 786e54e..fbc1103 100644 --- a/manifest.json +++ b/manifest.json @@ -1,5 +1,5 @@ { "applicationId": "js.grassclipper.app", - "version": "0.5.0", + "version": "0.5.1", "resourcesURL": "https://github.com/Grasscutters/GrassClipper/releases/latest/download/resources.neu" } \ No newline at end of file diff --git a/neutralino.config.json b/neutralino.config.json index b927513..bdb50ae 100644 --- a/neutralino.config.json +++ b/neutralino.config.json @@ -1,6 +1,6 @@ { "applicationId": "js.grassclipper.app", - "version": "0.5.0", + "version": "0.5.1", "defaultMode": "window", "port": 0, "documentRoot": "/resources/", diff --git a/package.json b/package.json index a4c65e3..7c4ca1f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "GrassClipper", - "version": "0.5.0", + "version": "0.5.1", "repository": "https://github.com/Grasscutters/GrassClipper.git", "author": "SpikeHD ", "license": "Apache-2.0", From 434227d9d5223474676974e89ff94de8f1f3a68d Mon Sep 17 00:00:00 2001 From: SpikeHD Date: Fri, 22 Apr 2022 21:10:49 -0700 Subject: [PATCH 3/9] presumably full english localization --- languages/en.json | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 languages/en.json diff --git a/languages/en.json b/languages/en.json new file mode 100644 index 0000000..e09f49b --- /dev/null +++ b/languages/en.json @@ -0,0 +1,33 @@ +{ + "appName": "GrassClipper", + + "officialPlay": "Play Official", + "privatePlay": "Play Private", + "launchLocalServer": "Launch Local Server", + + "genshinFolderSet": "Set \"Genshin Impact Game\" folder", + "grasscutterFileSet": "Set \"GrassCutter\" .jar file", + "folderNotSet": "Not set", + + "ipPlaceholder": "IP Address", + "noFavorites": "No favorites set", + + "settingsTitle": "Settings", + "killswitchOption": "Kill Switch", + "killswitchSubtitle": "Only for those very paranoid about bans. Kills the game process *and your internet* if something happens to the proxy.", + "installProxyOption": "Install the proxy server via the install script", + "updateOption": "Auto updating is temporarily disabled. Check GitHub for the newest releease.", + "enableServerLauncherOption": "Enable Server Launcher", + "enableServerLauncherSubtitle": "Enable to server launcher tile for launcher a local Grasscutter instance.", + + "introSen1": "Looks like this is your first time opening GrassClipper!", + "introSen2": "First of all, welcome, happy to see you here! :)", + "introSen3": "Would you like to run the proxy installer?", + "introSen4": "(required to connect to private servers)", + + "proxyInstallBtn": "Install", + "proxyInstallDeny": "No thanks", + + "genshinFolderDialog": "Select Genshin Impact Game folder", + "grasscutterFileDialog": "Select GrassCutter server jar file" +} \ No newline at end of file From f5506a4c853663431ab3369f478bc271e103b556 Mon Sep 17 00:00:00 2001 From: SpikeHD Date: Fri, 22 Apr 2022 21:57:02 -0700 Subject: [PATCH 4/9] fix english localization and functionally replace text --- languages/en.json | 11 ++++--- resources/index.html | 29 ++++++++--------- resources/js/index.js | 33 +++++++++++-------- resources/js/translation.js | 65 +++++++++++++++++++++++++++++++++++++ 4 files changed, 104 insertions(+), 34 deletions(-) create mode 100644 resources/js/translation.js diff --git a/languages/en.json b/languages/en.json index e09f49b..9dc3e9e 100644 --- a/languages/en.json +++ b/languages/en.json @@ -1,8 +1,8 @@ { "appName": "GrassClipper", - "officialPlay": "Play Official", - "privatePlay": "Play Private", + "playOfficial": "Play Official", + "playPrivate": "Play Private", "launchLocalServer": "Launch Local Server", "genshinFolderSet": "Set \"Genshin Impact Game\" folder", @@ -13,10 +13,13 @@ "noFavorites": "No favorites set", "settingsTitle": "Settings", + "scriptsSectionTitle": "Scripts", "killswitchOption": "Kill Switch", "killswitchSubtitle": "Only for those very paranoid about bans. Kills the game process *and your internet* if something happens to the proxy.", - "installProxyOption": "Install the proxy server via the install script", - "updateOption": "Auto updating is temporarily disabled. Check GitHub for the newest releease.", + "proxyOption": "Proxy", + "proxySubtitle": "Install the proxy server via the install script", + "updateOption": "Update", + "updateSubtitle": "Auto updating is temporarily disabled. Check GitHub for the newest releease.", "enableServerLauncherOption": "Enable Server Launcher", "enableServerLauncherSubtitle": "Enable to server launcher tile for launcher a local Grasscutter instance.", diff --git a/resources/index.html b/resources/index.html index e9637a5..9658db2 100644 --- a/resources/index.html +++ b/resources/index.html @@ -6,18 +6,15 @@ +
-
+
Scripts
- Kill Switch + Kill Switch
- + Only for those very paranoid about bans. Kills the game process *and your internet* if something happens to the proxy.
- Install Proxy Server - + Install Proxy Server +
- + Install the proxy server via the install script.
- Update + Update
@@ -58,7 +55,7 @@
- Enable Server Launcher + Enable Server Launcher
@@ -105,11 +102,11 @@
- +
- +
diff --git a/resources/js/index.js b/resources/js/index.js index 20f925b..00f9ccf 100644 --- a/resources/js/index.js +++ b/resources/js/index.js @@ -1,5 +1,6 @@ Neutralino.init(); +let localeObj; const filesystem = Neutralino.filesystem /** @@ -17,14 +18,6 @@ document.addEventListener('DOMContentLoaded', async () => { const config = await getCfg() const ipArr = await getFavIps() - if (!config.genshinImpactFolder) { - handleGenshinFolderNotSet() - } - - if (!config.serverFolder) { - handleServerNotSet() - } - if (config.serverLaunchPanel) { displayServerLaunchSection() } @@ -75,6 +68,17 @@ document.addEventListener('DOMContentLoaded', async () => { } } }); + + // Ensure we do the translation at the very end, after everything else has loaded + await doTranslation() + + if (!config.genshinImpactFolder) { + handleGenshinFolderNotSet() + } + + if (!config.serverFolder) { + handleServerNotSet() + } }) /** @@ -104,7 +108,8 @@ async function getCfg() { serverFolder: '', lastConnect: '', enableKillswitch: false, - serverLaunchPanel: false + serverLaunchPanel: false, + language: 'en' } const cfgStr = await Neutralino.storage.getData('config').catch(e => { // The data isn't set, so this is our first time opening @@ -151,7 +156,7 @@ async function enableButtons() { */ async function handleGenshinFolderNotSet() { // Set buttons to greyed out and disable - document.querySelector('#genshinPath').innerHTML = 'Not set' + document.querySelector('#genshinPath').innerHTML = localeObj.folderNotSet // Set official server background to default document.querySelector('#firstPanel').style.backgroundImage = `url("../bg/private/default.png")` @@ -170,7 +175,7 @@ async function handleGenshinFolderNotSet() { async function handleServerNotSet() { // Set buttons to greyed out and disable - document.querySelector('#serverPath').innerHTML = 'Not set' + document.querySelector('#serverPath').innerHTML = localeObj.folderNotSet // Set official server background to default // document.querySelector('#firstPanel').style.backgroundImage = `url("../bg/private/default.png")` @@ -339,7 +344,7 @@ async function handleFavoriteList() { document.createElement('li') ) - listItem.innerHTML = 'No favorites set' + listItem.innerHTML = localeObj.noFavorites } for (const ip of ipArr) { @@ -491,7 +496,7 @@ async function toggleServerLaunchSection() { * Set the game folder by opening a folder picker */ async function setGenshinImpactFolder() { - const folder = await Neutralino.os.showFolderDialog('Select Genshin Impact Game folder') + const folder = await Neutralino.os.showFolderDialog(localeObj.genshinFolderDialog) // Set the folder in our configuration const config = await getCfg() @@ -516,7 +521,7 @@ async function setGenshinImpactFolder() { } async function setGrassCutterFolder() { - const folder = await Neutralino.os.showOpenDialog('Select GrassCutter server jar', { + const folder = await Neutralino.os.showOpenDialog(localeObj.grasscutterFileDialog, { filters: [ { name: 'Jar files', extensions: ['jar'] } ] diff --git a/resources/js/translation.js b/resources/js/translation.js new file mode 100644 index 0000000..b02bf8f --- /dev/null +++ b/resources/js/translation.js @@ -0,0 +1,65 @@ +async function doTranslation() { + const config = await getCfg() + + // See if the localization file exists + const localizations = await filesystem.readDirectory(`${NL_CWD}/languages`) + + // Use english if the selected file does not exist + const selectedLanguage = localizations.find(f => f.entry === `${config.language}.json`) + + // Use english if the selected file does not exist + if (!selectedLanguage) { + config.language = 'en' + } + + const localization = await filesystem.readFile(`${NL_CWD}/languages/${config.language}.json`) + localeObj = JSON.parse(localization) + + const set = (id, localeString) => document.getElementById(id).innerHTML = localeString + + // Begin filling in values + set('titleSection', localeObj.appName) + + // Play buttons + set('playOfficial', localeObj.playOfficial) + set('playPrivate', localeObj.playPrivate) + set('serverLaunch', localeObj.launchLocalServer) + + // File select buttons + set('genshinFolderSet', localeObj.genshinFolderSet) + set('grasscutterFileSet', localeObj.grasscutterFileSet) + + // Private options + set('ip', localeObj.ipPlaceholder) + + // Settings + set('fullSettingsTitle', localeObj.settingsTitle) + set('scriptsTitle', localeObj.scriptsSectionTitle) + set('killswitchTitle', localeObj.killswitchOption) + set('killswitchSubtitle', localeObj.killswitchSubtitle) + set('proxyTitle', localeObj.proxyOption) + set('proxyInstall', localeObj.proxyInstallBtn) + set('proxySubtitle', localeObj.proxySubtitle) + set('updateBtn', localeObj.updateOption) + set('updateTitle', localeObj.updateOption) + set('updateSubtitle', localeObj.updateSubtitle) + set('serverLaunchTitle', localeObj.enableServerLauncherOption) + set('serverSubtitle', localeObj.enableServerLauncherSubtitle) + + // Intro popup + const popup = document.getElementById('firstTimeNotice') + const introSpan = popup.querySelector('span') + const boldIntroSpan = document.createElement('span') + + boldIntroSpan.innerHTML = localeObj.introSen1 + '\n' + boldIntroSpan.classList.add('boldTitle') + + introSpan.appendChild(boldIntroSpan) + + introSpan.innerHTML += localeObj.introSen2 + '
' + introSpan.innerHTML += localeObj.introSen3 + '
' + introSpan.innerHTML += localeObj.introSen4 + '
' + + set('firstTimeInstallBtn', localeObj.proxyInstallBtn) + set('firstTimeDenyBtn', localeObj.proxyInstallDeny) +} \ No newline at end of file From 7ddc39ad2c64a6bd8bd1e2d0f10784840efb5318 Mon Sep 17 00:00:00 2001 From: SpikeHD Date: Fri, 22 Apr 2022 22:10:09 -0700 Subject: [PATCH 5/9] language selector and localization fixes --- languages/en.json | 1 + resources/index.html | 10 ++++++++++ resources/js/index.js | 32 ++++++++++++++++++++++++++++++++ resources/js/translation.js | 2 +- resources/style/index.css | 2 +- 5 files changed, 45 insertions(+), 2 deletions(-) diff --git a/languages/en.json b/languages/en.json index 9dc3e9e..78ec32f 100644 --- a/languages/en.json +++ b/languages/en.json @@ -1,4 +1,5 @@ { + "fullLangName": "English", "appName": "GrassClipper", "playOfficial": "Play Official", diff --git a/resources/index.html b/resources/index.html index 9658db2..c4ecadc 100644 --- a/resources/index.html +++ b/resources/index.html @@ -62,6 +62,16 @@ Enable to server launcher tile for launcher a local Grasscutter instance.
+
+
+ Language + +
+ + Select your language! + +
diff --git a/resources/js/index.js b/resources/js/index.js index 00f9ccf..a3f9844 100644 --- a/resources/js/index.js +++ b/resources/js/index.js @@ -410,6 +410,9 @@ async function openSettings() { killSwitch.checked = config.enableKillswitch serverLaunch.checked = config.serverLaunchPanel + // Load languages + getLanguages() + // Check for updates //checkForUpdatesAndShow() } @@ -492,6 +495,35 @@ async function toggleServerLaunchSection() { Neutralino.storage.setData('config', JSON.stringify(config)) } +async function getLanguages() { + const languageFiles = (await filesystem.readDirectory(`${NL_CWD}/languages`)).filter(file => file.entry.endsWith('.json')) + + + // Load all languages as options + for (const file of languageFiles) { + const fullLanguageName = JSON.parse(await filesystem.readFile(`${NL_CWD}/languages/${file.entry}`)).fullLangName + const lang = file.entry.split('.json')[0] + + const option = document.createElement('option') + option.value = lang + option.innerHTML = fullLanguageName + + document.querySelector('#languageSelect').appendChild(option) + } +} + +async function handleLanguageChange(elm) { + const list = elm + const config = await getCfg() + + // Set language in config + config.language = list.value + Neutralino.storage.setData('config', JSON.stringify(config)) + + // Force refresh of application, no need for restart! + window.location.reload() +} + /** * Set the game folder by opening a folder picker */ diff --git a/resources/js/translation.js b/resources/js/translation.js index b02bf8f..bcf78ec 100644 --- a/resources/js/translation.js +++ b/resources/js/translation.js @@ -15,7 +15,7 @@ async function doTranslation() { const localization = await filesystem.readFile(`${NL_CWD}/languages/${config.language}.json`) localeObj = JSON.parse(localization) - const set = (id, localeString) => document.getElementById(id).innerHTML = localeString + const set = (id, localeString) => document.getElementById(id).innerHTML = localeString || 'UNKNOWN' // Begin filling in values set('titleSection', localeObj.appName) diff --git a/resources/style/index.css b/resources/style/index.css index bb8ab8d..1da6c9c 100644 --- a/resources/style/index.css +++ b/resources/style/index.css @@ -51,7 +51,7 @@ body { #settingsPanel { width: 35%; - height: 60%; + height: 70%; } #fullSettingsTitle { From 0cc72f1f46decd030ee8762730603d7719d26924 Mon Sep 17 00:00:00 2001 From: SpikeHD Date: Fri, 22 Apr 2022 22:12:01 -0700 Subject: [PATCH 6/9] add language settings to locale --- languages/en.json | 2 ++ resources/js/translation.js | 2 ++ 2 files changed, 4 insertions(+) diff --git a/languages/en.json b/languages/en.json index 78ec32f..6f051d4 100644 --- a/languages/en.json +++ b/languages/en.json @@ -21,6 +21,8 @@ "proxySubtitle": "Install the proxy server via the install script", "updateOption": "Update", "updateSubtitle": "Auto updating is temporarily disabled. Check GitHub for the newest releease.", + "languageOption": "Language", + "languageSubtitle": "Select your language!", "enableServerLauncherOption": "Enable Server Launcher", "enableServerLauncherSubtitle": "Enable to server launcher tile for launcher a local Grasscutter instance.", diff --git a/resources/js/translation.js b/resources/js/translation.js index bcf78ec..1d24191 100644 --- a/resources/js/translation.js +++ b/resources/js/translation.js @@ -43,6 +43,8 @@ async function doTranslation() { set('updateBtn', localeObj.updateOption) set('updateTitle', localeObj.updateOption) set('updateSubtitle', localeObj.updateSubtitle) + set('languageTitle', localeObj.languageOption) + set('languageSubtitle', localeObj.languageSubtitle) set('serverLaunchTitle', localeObj.enableServerLauncherOption) set('serverSubtitle', localeObj.enableServerLauncherSubtitle) From 632820e2778ccb54cb784a186ac5597dc5510cfc Mon Sep 17 00:00:00 2001 From: SpikeHD Date: Fri, 22 Apr 2022 22:14:15 -0700 Subject: [PATCH 7/9] Empty cn and jp languages for testing --- languages/cn.json | 3 +++ languages/jp.json | 3 +++ 2 files changed, 6 insertions(+) create mode 100644 languages/cn.json create mode 100644 languages/jp.json diff --git a/languages/cn.json b/languages/cn.json new file mode 100644 index 0000000..7e5ad12 --- /dev/null +++ b/languages/cn.json @@ -0,0 +1,3 @@ +{ + "fullLangName": "Chinese" +} \ No newline at end of file diff --git a/languages/jp.json b/languages/jp.json new file mode 100644 index 0000000..b6de281 --- /dev/null +++ b/languages/jp.json @@ -0,0 +1,3 @@ +{ + "fullLangName": "Japanese" +} \ No newline at end of file From 0d97307e9aa75d67b304c9492071d4bd11a474e2 Mon Sep 17 00:00:00 2001 From: SpikeHD Date: Fri, 22 Apr 2022 22:17:26 -0700 Subject: [PATCH 8/9] proper selection, fixes --- resources/index.html | 8 +++++--- resources/js/index.js | 8 +++++++- resources/style/index.css | 8 +++++++- 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/resources/index.html b/resources/index.html index c4ecadc..9766e00 100644 --- a/resources/index.html +++ b/resources/index.html @@ -18,9 +18,11 @@