mirror of
https://github.com/an-anime-team/an-anime-game-launcher.git
synced 2024-12-24 18:48:14 +03:00
Merge branch 'marie/prefixlocation' into 'main'
Wine Prefix location selection in settings See merge request KRypt0n_/an-anime-game-launcher!5
This commit is contained in:
commit
1cdc553c25
21 changed files with 174 additions and 20 deletions
21
entry.js
21
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'));
|
||||
});
|
||||
|
||||
|
|
|
@ -112,6 +112,7 @@
|
|||
</ul>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="selected-item">
|
||||
<span>System</span>
|
||||
|
||||
|
@ -129,6 +130,17 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<br>
|
||||
|
||||
<div id="prefixloc">
|
||||
<span>Prefix: </span>
|
||||
|
||||
<span id="currentprefix">empty</span>
|
||||
|
||||
<button class="button" id="prefixdir" i18id="ChangePrefix">Change Prefix</button>
|
||||
<button class="button" id="defprefix" i18id="DefPrefix">Reset</button>
|
||||
</div>
|
||||
|
||||
<br><br>
|
||||
|
||||
<div id="general-action-buttons">
|
||||
|
|
|
@ -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"
|
||||
}
|
|
@ -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"
|
||||
}
|
|
@ -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"
|
||||
}
|
|
@ -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"
|
||||
}
|
|
@ -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"
|
||||
}
|
|
@ -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"
|
||||
}
|
|
@ -53,5 +53,7 @@
|
|||
"SkipAndDontAsk": "スキップして二度と聞かない",
|
||||
"LauncherUpdateTitle": "ランチャーのアップデートが可能 ",
|
||||
"LauncherUpdateBody": "ランチャーの新バージョンは、プロジェクトのリポジトリ({uri.launcher})からダウンロードできます。",
|
||||
"TelemetryNotDisabled": "{placeholders.uppercase.company}のテレメトリサーバは無効になっていません!"
|
||||
"TelemetryNotDisabled": "{placeholders.uppercase.company}のテレメトリサーバは無効になっていません!",
|
||||
"DefPrefix": "デフォルトへのリセット",
|
||||
"ChangePrefix": "プレフィックスを変更"
|
||||
}
|
|
@ -53,5 +53,7 @@
|
|||
"SkipAndDontAsk": "건너 뛰고 다시 묻지 마십시오",
|
||||
"LauncherUpdateTitle": "실행기 업데이트 가능: ",
|
||||
"LauncherUpdateBody": "에서 프로젝트의 저장소에서 실행기의 새 버전을 다운로드 할 수 있습니다 {uri.launcher}",
|
||||
"TelemetryNotDisabled": "{placeholders.uppercase.company} 의 원격 측정 서버가 비활성화되지 않음!"
|
||||
"TelemetryNotDisabled": "{placeholders.uppercase.company} 의 원격 측정 서버가 비활성화되지 않음!",
|
||||
"DefPrefix": "Reset to Default",
|
||||
"ChangePrefix": "Change Prefix"
|
||||
}
|
|
@ -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"
|
||||
}
|
|
@ -53,5 +53,7 @@
|
|||
"SkipAndDontAsk": "Пропустить и не спрашивать",
|
||||
"LauncherUpdateTitle": "Доступно обновление лаунчера: ",
|
||||
"LauncherUpdateBody": "Вы можете скачать новую версию лаунчера с репозитория проекта: {uri.launcher}",
|
||||
"TelemetryNotDisabled": "Серверы сбора телеметрии {placeholders.uppercase.company} не отключены!"
|
||||
"TelemetryNotDisabled": "Серверы сбора телеметрии {placeholders.uppercase.company} не отключены!",
|
||||
"DefPrefix": "Reset to Default",
|
||||
"ChangePrefix": "Change Prefix"
|
||||
}
|
|
@ -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"
|
||||
}
|
|
@ -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"
|
||||
}
|
|
@ -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"
|
||||
}
|
|
@ -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"
|
||||
}
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
71
src/ts/lib/PrefixSelector.ts
Normal file
71
src/ts/lib/PrefixSelector.ts
Normal file
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -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');
|
||||
|
||||
|
|
|
@ -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
|
||||
*/
|
||||
|
|
Loading…
Reference in a new issue