diff --git a/entry.js b/entry.js
index 425f615..84f0f41 100644
--- a/entry.js
+++ b/entry.js
@@ -5,14 +5,15 @@ const {
Notification,
shell,
nativeImage,
- nativeTheme
+ nativeTheme,
+ dialog
} = require('electron');
const path = require('path');
require('electron-store').initRenderer();
-let mainWindow, analyticsWindow;
+let mainWindow, analyticsWindow, settingsWindow;
ipcMain.handle('hide-window', () => mainWindow.hide());
ipcMain.handle('show-window', () => mainWindow.show());
@@ -26,7 +27,7 @@ ipcMain.on('notification', (event, args) => {
ipcMain.on('is-window-dark', (e) => e.returnValue = nativeTheme.shouldUseDarkColors);
ipcMain.handle('open-settings', () => {
- const settingsWindow = new BrowserWindow ({
+ settingsWindow = new BrowserWindow ({
width: 900,
height: 600,
webPreferences: {
@@ -120,6 +121,20 @@ app.whenReady().then(() => {
mainWindow.webContents.send('change-voicepack');
});
+ ipcMain.on('prefix-con', async () => {
+ const result = await dialog.showOpenDialog({ properties: ['openDirectory'] });
+ if(result.filePaths.length == 0) return;
+ mainWindow.webContents.send('change-prefix', { 'type': 'change', 'dir': result.filePaths[0] });
+ });
+
+ ipcMain.on('prefix-reset', async () => {
+ mainWindow.webContents.send('change-prefix', { 'type': 'reset' });
+ });
+
+ ipcMain.on('prefix-changed', async () => {
+ settingsWindow.webContents.send('prefix-changed');
+ });
+
ipcMain.on('rpc-toggle', () => mainWindow.webContents.send('rpc-toggle'));
});
diff --git a/public/html/settings.html b/public/html/settings.html
index 91bac00..3983699 100644
--- a/public/html/settings.html
+++ b/public/html/settings.html
@@ -112,6 +112,7 @@
+
System
@@ -129,6 +130,17 @@
+
+
+
+ Prefix:
+
+ empty
+
+
+
+
+
diff --git a/public/locales/de.json b/public/locales/de.json
index 9a7da1b..b217a32 100644
--- a/public/locales/de.json
+++ b/public/locales/de.json
@@ -53,5 +53,7 @@
"SkipAndDontAsk": "Überspingen und nicht noch mal fragen",
"LauncherUpdateTitle": "Launcher update verfügbar: ",
"LauncherUpdateBody": "Sie können eine neue Version des Launchers aus dem Repository des Projekts unter {uri.launcher} herunterladen.",
- "TelemetryNotDisabled": "{placeholders.uppercase.company} Telemetrieserver sind nicht deaktiviert!"
+ "TelemetryNotDisabled": "{placeholders.uppercase.company} Telemetrieserver sind nicht deaktiviert!",
+ "DefPrefix": "Zurücksetzen zum Standard-Prefix",
+ "ChangePrefix": "Prefix ändern"
}
\ No newline at end of file
diff --git a/public/locales/en-us.json b/public/locales/en-us.json
index 507f966..6e1c2a9 100644
--- a/public/locales/en-us.json
+++ b/public/locales/en-us.json
@@ -53,5 +53,7 @@
"SkipAndDontAsk": "Skip and don't ask again",
"LauncherUpdateTitle": "Launcher update available: ",
"LauncherUpdateBody": "You can download a new version of the launcher from the project's repository at {uri.launcher}",
- "TelemetryNotDisabled": "{placeholders.uppercase.company}'s telemetry servers don't disabled!"
+ "TelemetryNotDisabled": "{placeholders.uppercase.company}'s telemetry servers don't disabled!",
+ "DefPrefix": "Reset to Default",
+ "ChangePrefix": "Change Prefix"
}
\ No newline at end of file
diff --git a/public/locales/en.json b/public/locales/en.json
index ce7be2d..d30d4ba 100644
--- a/public/locales/en.json
+++ b/public/locales/en.json
@@ -53,5 +53,7 @@
"SkipAndDontAsk": "Skip and don't ask again",
"LauncherUpdateTitle": "Launcher update available: ",
"LauncherUpdateBody": "You can download a new version of the launcher from the project's repository at {uri.launcher}",
- "TelemetryNotDisabled": "{placeholders.uppercase.company}'s telemetry servers don't disabled!"
+ "TelemetryNotDisabled": "{placeholders.uppercase.company}'s telemetry servers don't disabled!",
+ "DefPrefix": "Reset to Default",
+ "ChangePrefix": "Change Prefix"
}
\ No newline at end of file
diff --git a/public/locales/es.json b/public/locales/es.json
index ce7be2d..d30d4ba 100644
--- a/public/locales/es.json
+++ b/public/locales/es.json
@@ -53,5 +53,7 @@
"SkipAndDontAsk": "Skip and don't ask again",
"LauncherUpdateTitle": "Launcher update available: ",
"LauncherUpdateBody": "You can download a new version of the launcher from the project's repository at {uri.launcher}",
- "TelemetryNotDisabled": "{placeholders.uppercase.company}'s telemetry servers don't disabled!"
+ "TelemetryNotDisabled": "{placeholders.uppercase.company}'s telemetry servers don't disabled!",
+ "DefPrefix": "Reset to Default",
+ "ChangePrefix": "Change Prefix"
}
\ No newline at end of file
diff --git a/public/locales/fr.json b/public/locales/fr.json
index ce7be2d..d30d4ba 100644
--- a/public/locales/fr.json
+++ b/public/locales/fr.json
@@ -53,5 +53,7 @@
"SkipAndDontAsk": "Skip and don't ask again",
"LauncherUpdateTitle": "Launcher update available: ",
"LauncherUpdateBody": "You can download a new version of the launcher from the project's repository at {uri.launcher}",
- "TelemetryNotDisabled": "{placeholders.uppercase.company}'s telemetry servers don't disabled!"
+ "TelemetryNotDisabled": "{placeholders.uppercase.company}'s telemetry servers don't disabled!",
+ "DefPrefix": "Reset to Default",
+ "ChangePrefix": "Change Prefix"
}
\ No newline at end of file
diff --git a/public/locales/id.json b/public/locales/id.json
index 4c69165..1ea318d 100644
--- a/public/locales/id.json
+++ b/public/locales/id.json
@@ -53,5 +53,7 @@
"SkipAndDontAsk": "Lewati dan jangan tanya lagi",
"LauncherUpdateTitle": "Pembaruan Peluncur tersedia: ",
"LauncherUpdateBody": "Kamu dapat mengunduh versi baru peluncur dari repositori di {uri.launcher}",
- "TelemetryNotDisabled": "Peladen telemetri {placeholders.uppercase.company} tidak dimatikan!"
+ "TelemetryNotDisabled": "Peladen telemetri {placeholders.uppercase.company} tidak dimatikan!",
+ "DefPrefix": "Reset to Default",
+ "ChangePrefix": "Change Prefix"
}
\ No newline at end of file
diff --git a/public/locales/ja.json b/public/locales/ja.json
index 58b1de4..723256b 100644
--- a/public/locales/ja.json
+++ b/public/locales/ja.json
@@ -53,5 +53,7 @@
"SkipAndDontAsk": "スキップして二度と聞かない",
"LauncherUpdateTitle": "ランチャーのアップデートが可能 ",
"LauncherUpdateBody": "ランチャーの新バージョンは、プロジェクトのリポジトリ({uri.launcher})からダウンロードできます。",
- "TelemetryNotDisabled": "{placeholders.uppercase.company}のテレメトリサーバは無効になっていません!"
+ "TelemetryNotDisabled": "{placeholders.uppercase.company}のテレメトリサーバは無効になっていません!",
+ "DefPrefix": "デフォルトへのリセット",
+ "ChangePrefix": "プレフィックスを変更"
}
\ No newline at end of file
diff --git a/public/locales/ko.json b/public/locales/ko.json
index 49c245c..8ff12fa 100644
--- a/public/locales/ko.json
+++ b/public/locales/ko.json
@@ -53,5 +53,7 @@
"SkipAndDontAsk": "건너 뛰고 다시 묻지 마십시오",
"LauncherUpdateTitle": "실행기 업데이트 가능: ",
"LauncherUpdateBody": "에서 프로젝트의 저장소에서 실행기의 새 버전을 다운로드 할 수 있습니다 {uri.launcher}",
- "TelemetryNotDisabled": "{placeholders.uppercase.company} 의 원격 측정 서버가 비활성화되지 않음!"
+ "TelemetryNotDisabled": "{placeholders.uppercase.company} 의 원격 측정 서버가 비활성화되지 않음!",
+ "DefPrefix": "Reset to Default",
+ "ChangePrefix": "Change Prefix"
}
\ No newline at end of file
diff --git a/public/locales/pt.json b/public/locales/pt.json
index ce7be2d..d30d4ba 100644
--- a/public/locales/pt.json
+++ b/public/locales/pt.json
@@ -53,5 +53,7 @@
"SkipAndDontAsk": "Skip and don't ask again",
"LauncherUpdateTitle": "Launcher update available: ",
"LauncherUpdateBody": "You can download a new version of the launcher from the project's repository at {uri.launcher}",
- "TelemetryNotDisabled": "{placeholders.uppercase.company}'s telemetry servers don't disabled!"
+ "TelemetryNotDisabled": "{placeholders.uppercase.company}'s telemetry servers don't disabled!",
+ "DefPrefix": "Reset to Default",
+ "ChangePrefix": "Change Prefix"
}
\ No newline at end of file
diff --git a/public/locales/ru.json b/public/locales/ru.json
index 209e3aa..a7d2f75 100644
--- a/public/locales/ru.json
+++ b/public/locales/ru.json
@@ -53,5 +53,7 @@
"SkipAndDontAsk": "Пропустить и не спрашивать",
"LauncherUpdateTitle": "Доступно обновление лаунчера: ",
"LauncherUpdateBody": "Вы можете скачать новую версию лаунчера с репозитория проекта: {uri.launcher}",
- "TelemetryNotDisabled": "Серверы сбора телеметрии {placeholders.uppercase.company} не отключены!"
+ "TelemetryNotDisabled": "Серверы сбора телеметрии {placeholders.uppercase.company} не отключены!",
+ "DefPrefix": "Reset to Default",
+ "ChangePrefix": "Change Prefix"
}
\ No newline at end of file
diff --git a/public/locales/th.json b/public/locales/th.json
index ce7be2d..d30d4ba 100644
--- a/public/locales/th.json
+++ b/public/locales/th.json
@@ -53,5 +53,7 @@
"SkipAndDontAsk": "Skip and don't ask again",
"LauncherUpdateTitle": "Launcher update available: ",
"LauncherUpdateBody": "You can download a new version of the launcher from the project's repository at {uri.launcher}",
- "TelemetryNotDisabled": "{placeholders.uppercase.company}'s telemetry servers don't disabled!"
+ "TelemetryNotDisabled": "{placeholders.uppercase.company}'s telemetry servers don't disabled!",
+ "DefPrefix": "Reset to Default",
+ "ChangePrefix": "Change Prefix"
}
\ No newline at end of file
diff --git a/public/locales/vi.json b/public/locales/vi.json
index ce7be2d..d30d4ba 100644
--- a/public/locales/vi.json
+++ b/public/locales/vi.json
@@ -53,5 +53,7 @@
"SkipAndDontAsk": "Skip and don't ask again",
"LauncherUpdateTitle": "Launcher update available: ",
"LauncherUpdateBody": "You can download a new version of the launcher from the project's repository at {uri.launcher}",
- "TelemetryNotDisabled": "{placeholders.uppercase.company}'s telemetry servers don't disabled!"
+ "TelemetryNotDisabled": "{placeholders.uppercase.company}'s telemetry servers don't disabled!",
+ "DefPrefix": "Reset to Default",
+ "ChangePrefix": "Change Prefix"
}
\ No newline at end of file
diff --git a/public/locales/zh-cn.json b/public/locales/zh-cn.json
index 9bc346f..22c47c8 100644
--- a/public/locales/zh-cn.json
+++ b/public/locales/zh-cn.json
@@ -53,5 +53,7 @@
"SkipAndDontAsk": "跳过,不要再问",
"LauncherUpdateTitle": "启动器更新可用:",
"LauncherUpdateBody": "你可以从项目的资源库中下载新版本的启动器,网址是:{uri.launcher}",
- "TelemetryNotDisabled": "{placeholders.uppercase.company}'s telemetry servers don't disabled!"
+ "TelemetryNotDisabled": "{placeholders.uppercase.company}'s telemetry servers don't disabled!",
+ "DefPrefix": "Reset to Default",
+ "ChangePrefix": "Change Prefix"
}
\ No newline at end of file
diff --git a/public/locales/zh-tw.json b/public/locales/zh-tw.json
index 240d73e..aba8b3d 100644
--- a/public/locales/zh-tw.json
+++ b/public/locales/zh-tw.json
@@ -53,5 +53,7 @@
"SkipAndDontAsk": "跳過,不要再詢問我",
"LauncherUpdateTitle": "啟動器有新的更新可用:",
"LauncherUpdateBody": "您可以從此專案的資源庫中下載新版本的啟動器,網址是:{uri.launcher}",
- "TelemetryNotDisabled": "{placeholders.uppercase.company}'s telemetry servers don't disabled!"
+ "TelemetryNotDisabled": "{placeholders.uppercase.company}'s telemetry servers don't disabled!",
+ "DefPrefix": "Reset to Default",
+ "ChangePrefix": "Change Prefix"
}
\ No newline at end of file
diff --git a/src/ts/index.ts b/src/ts/index.ts
index 0f0909c..a9b3213 100644
--- a/src/ts/index.ts
+++ b/src/ts/index.ts
@@ -13,12 +13,13 @@ import LauncherLib from './lib/LauncherLib';
import LauncherUI from './lib/LauncherUI';
import Tools from './lib/Tools';
import DiscordRPC from './lib/DiscordRPC';
+import PrefixSelector from './lib/PrefixSelector';
import SwitcherooControl from './lib/SwitcherooControl';
const launcher_version = require('../../package.json').version;
-if (!fs.existsSync(constants.prefixDir))
- fs.mkdirSync(constants.prefixDir, { recursive: true });
+if (!fs.existsSync(LauncherLib.getConfig('prefix')))
+ fs.mkdirSync(LauncherLib.getConfig('prefix'), { recursive: true });
if (!fs.existsSync(constants.runnersDir))
fs.mkdirSync(constants.runnersDir, { recursive: true });
@@ -59,6 +60,13 @@ $(() => {
LauncherUI.updateLauncherState();
});
+ ipcRenderer.on('change-prefix', (event: void, data: any) => {
+ if(data.type == 'change') PrefixSelector.set(data.dir);
+ if(data.type == 'reset') PrefixSelector.Default();
+ LauncherUI.updateLauncherState();
+ ipcRenderer.send('prefix-changed');
+ });
+
Tools.getGitTags(constants.uri.launcher).then(tags => {
const latestVersion = tags[tags.length - 1].tag;
diff --git a/src/ts/lib/LauncherLib.ts b/src/ts/lib/LauncherLib.ts
index 46db0b3..4ec68e0 100644
--- a/src/ts/lib/LauncherLib.ts
+++ b/src/ts/lib/LauncherLib.ts
@@ -27,6 +27,7 @@ const config = new store ({
file: null
},
version: null, // Installed game version
+ prefix: path.join(os.homedir(), '.local', 'share', 'anime-game-launcher', 'game'), // Default Prefix
patch: null, // Installed patch info ({ version, state } - related game's version and patch's state)
runner: null, // Selected runner ({ folder, executable })
rpc: false, // Discord RPC
diff --git a/src/ts/lib/PrefixSelector.ts b/src/ts/lib/PrefixSelector.ts
new file mode 100644
index 0000000..f4cde0f
--- /dev/null
+++ b/src/ts/lib/PrefixSelector.ts
@@ -0,0 +1,71 @@
+const fs = require('fs');
+import LauncherLib from "./LauncherLib";
+import constants from "./constants";
+const path = require('path');
+const os = require('os');
+
+export default class PrefixSelector
+{
+ protected static prefix: string = LauncherLib.getConfig('prefix');
+
+ public static set(location: string) {
+ if (this.prefix == location) return console.log('Can\'t set already selected prefix as new prefix');
+
+ if (fs.existsSync(path.join(location, 'drive_c', 'Program Files', 'Genshin Impact', 'GenshinImpact_Data', 'Persistent'))) {
+ const version = fs.readFileSync(path.join(location, 'drive_c', 'Program Files', 'Genshin Impact', 'GenshinImpact_Data', 'Persistent', 'ScriptVersion'), { encoding: 'UTF-8' }).toString();
+
+ LauncherLib.updateConfig('version', version);
+ LauncherLib.updateConfig('prefix', location);
+ constants.prefixDir = location;
+ this.prefix = location;
+ } else if (fs.existsSync(path.join(location, 'drive_c', 'Program Files', 'Genshin Impact', 'GenshinImpact_Data', 'globalgamemanagers'))) {
+ const config = fs.readFileSync(path.join(location, 'drive_c', 'Program Files', 'Genshin Impact', 'GenshinImpact_Data', 'globalgamemanagers'), { encoding: 'ascii' });
+ const version = /([1-9]+\.[0-9]+\.[0-9]+)_[\d]+_[\d]+/.exec(config)![1];
+
+ LauncherLib.updateConfig('version', version);
+ LauncherLib.updateConfig('prefix', location);
+ constants.prefixDir = location;
+ this.prefix = location;
+ } else {
+ console.log('Game not found.');
+
+ // Unset version if game is not found.
+ LauncherLib.updateConfig('version', null);
+ LauncherLib.updateConfig('prefix', location);
+ constants.prefixDir = location;
+ this.prefix = location;
+ }
+ }
+
+ public static Default() {
+ const dp = path.join(os.homedir(), '.local', 'share', 'anime-game-launcher', 'game');
+
+ if (this.prefix == dp) return console.log('Can\'t set already selected prefix as new prefix');
+
+ if (fs.existsSync(path.join(dp, 'drive_c', 'Program Files', 'Genshin Impact', 'GenshinImpact_Data', 'Persistent'))) {
+ const version = fs.readFileSync(path.join(dp, 'drive_c', 'Program Files', 'Genshin Impact', 'GenshinImpact_Data', 'Persistent', 'ScriptVersion'), { encoding: 'UTF-8' }).toString();
+
+ LauncherLib.updateConfig('version', version);
+ LauncherLib.updateConfig('prefix', dp);
+ constants.prefixDir = dp;
+ this.prefix = dp;
+ } else if (fs.existsSync(path.join(dp, 'drive_c', 'Program Files', 'Genshin Impact', 'GenshinImpact_Data', 'globalgamemanagers'))) {
+ const config = fs.readFileSync(path.join(dp, 'drive_c', 'Program Files', 'Genshin Impact', 'GenshinImpact_Data', 'globalgamemanagers'), { encoding: 'ascii' });
+ const version = /([1-9]+\.[0-9]+\.[0-9]+)_[\d]+_[\d]+/.exec(config)![1];
+
+ LauncherLib.updateConfig('version', version);
+ LauncherLib.updateConfig('prefix', dp);
+ constants.prefixDir = dp;
+ this.prefix = dp;
+ } else {
+ console.log('Game not found.');
+
+ // Unset version if game is not found.
+ LauncherLib.updateConfig('version', null);
+ LauncherLib.updateConfig('prefix', dp);
+ constants.prefixDir = dp;
+ this.prefix = dp;
+ }
+ }
+
+}
\ No newline at end of file
diff --git a/src/ts/lib/constants.ts b/src/ts/lib/constants.ts
index 66ec63c..23cb4cc 100644
--- a/src/ts/lib/constants.ts
+++ b/src/ts/lib/constants.ts
@@ -1,5 +1,6 @@
const path = require('path');
const os = require('os');
+import LauncherLib from "./LauncherLib";
export default class constants
{
@@ -44,7 +45,7 @@ export default class constants
public static readonly launcherDir: string = path.join(os.homedir(), '.local', 'share', 'anime-game-launcher');
- public static readonly prefixDir: string = path.join(this.launcherDir, 'game');
+ public static prefixDir: string = LauncherLib.getConfig('prefix');
public static readonly gameDir: string = path.join(this.prefixDir, 'drive_c', 'Program Files', this.placeholders.uppercase.full);
public static readonly voiceDir: string = path.join(this.gameDir, `${this.placeholders.uppercase.first + this.placeholders.uppercase.second}_Data`, 'StreamingAssets', 'Audio', 'GeneratedSoundBanks', 'Windows');
diff --git a/src/ts/settings.ts b/src/ts/settings.ts
index 71104af..e95e705 100644
--- a/src/ts/settings.ts
+++ b/src/ts/settings.ts
@@ -54,6 +54,24 @@ $(() => {
}
});
+ /**
+ * Prefix
+ */
+
+ $('#prefixloc #currentprefix').text(LauncherLib.getConfig('prefix'));
+
+ ipcRenderer.on('prefix-changed', () => {
+ $('#prefixloc #currentprefix').text(LauncherLib.getConfig('prefix'));
+ })
+
+ $('#prefixloc #prefixdir').on('click', () => {
+ ipcRenderer.send('prefix-con');
+ })
+
+ $('#prefixloc #defprefix').on('click', () => {
+ ipcRenderer.send('prefix-reset');
+ })
+
/**
* Game voice language
*/