mirror of
https://github.com/an-anime-team/an-anime-game-launcher.git
synced 2024-12-24 18:48:14 +03:00
Merge branch 'main' of lane/an-anime-game-launcher into main
This commit is contained in:
commit
b8b79b0000
20 changed files with 122 additions and 0 deletions
|
@ -52,6 +52,7 @@
|
||||||
"cash-dom": "^8.1.0",
|
"cash-dom": "^8.1.0",
|
||||||
"command-exists": "^1.2.9",
|
"command-exists": "^1.2.9",
|
||||||
"discord-rpc": "^4.0.1",
|
"discord-rpc": "^4.0.1",
|
||||||
|
"dbus-next": "^0.10.2",
|
||||||
"electron-store": "^8.0.1",
|
"electron-store": "^8.0.1",
|
||||||
"follow-redirects": "^1.14.5",
|
"follow-redirects": "^1.14.5",
|
||||||
"get-pixels": "^3.3.3",
|
"get-pixels": "^3.3.3",
|
||||||
|
|
|
@ -118,6 +118,26 @@
|
||||||
<div class="checkbox-mark">
|
<div class="checkbox-mark">
|
||||||
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="45.701px" height="45.7px" viewBox="0 0 45.701 45.7" xml:space="preserve"><g><g><path d="M20.687,38.332c-2.072,2.072-5.434,2.072-7.505,0L1.554,26.704c-2.072-2.071-2.072-5.433,0-7.504 c2.071-2.072,5.433-2.072,7.505,0l6.928,6.927c0.523,0.522,1.372,0.522,1.896,0L36.642,7.368c2.071-2.072,5.433-2.072,7.505,0 c0.995,0.995,1.554,2.345,1.554,3.752c0,1.407-0.559,2.757-1.554,3.752L20.687,38.332z"/></g></g></svg>
|
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="45.701px" height="45.7px" viewBox="0 0 45.701 45.7" xml:space="preserve"><g><g><path d="M20.687,38.332c-2.072,2.072-5.434,2.072-7.505,0L1.554,26.704c-2.072-2.071-2.072-5.433,0-7.504 c2.071-2.072,5.433-2.072,7.505,0l6.928,6.927c0.523,0.522,1.372,0.522,1.896,0L36.642,7.368c2.071-2.072,5.433-2.072,7.505,0 c0.995,0.995,1.554,2.345,1.554,3.752c0,1.407-0.559,2.757-1.554,3.752L20.687,38.332z"/></g></g></svg>
|
||||||
</div>
|
</div>
|
||||||
|
</div><br>
|
||||||
|
|
||||||
|
<div class="select" id="gpu">
|
||||||
|
<span>GPU</span>
|
||||||
|
|
||||||
|
<div class="select-options">
|
||||||
|
<ul>
|
||||||
|
<li value="default">Default</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="selected-item">
|
||||||
|
<span>Default</span>
|
||||||
|
|
||||||
|
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
||||||
|
viewBox="0 0 330.002 330.002" xml:space="preserve">
|
||||||
|
<path id="XMLID_226_"
|
||||||
|
d="M233.252,155.997L120.752,6.001c-4.972-6.628-14.372-7.97-21-3c-6.628,4.971-7.971,14.373-3,21 l105.75,140.997L96.752,306.001c-4.971,6.627-3.627,16.03,3,21c2.698,2.024,5.856,3.001,8.988,3.001 c4.561,0,9.065-2.072,12.012-6.001l112.5-150.004C237.252,168.664,237.252,161.33,233.252,155.997z" />
|
||||||
|
</svg>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<br>
|
<br>
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
"Shaders": "Shadern",
|
"Shaders": "Shadern",
|
||||||
"ReshadeNotInstalled": "Sie haben vkBasalt und Reshade-Shader nicht installiert",
|
"ReshadeNotInstalled": "Sie haben vkBasalt und Reshade-Shader nicht installiert",
|
||||||
"GameModeNotInstalled": "Sie haben GameMode nicht installiert",
|
"GameModeNotInstalled": "Sie haben GameMode nicht installiert",
|
||||||
|
"SwitcherooNotInstalled": "Sie haben switcheroo-control nicht installiert",
|
||||||
"Author": "Autor",
|
"Author": "Autor",
|
||||||
"NoImages": "Bilder sind nicht verfügbar",
|
"NoImages": "Bilder sind nicht verfügbar",
|
||||||
"SettingsTitle": "Einstellungen",
|
"SettingsTitle": "Einstellungen",
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
"Shaders": "Shaders",
|
"Shaders": "Shaders",
|
||||||
"ReshadeNotInstalled": "You haven't installed vkBasalt and reshade-shaders library",
|
"ReshadeNotInstalled": "You haven't installed vkBasalt and reshade-shaders library",
|
||||||
"GameModeNotInstalled": "You don't have GameMode installed",
|
"GameModeNotInstalled": "You don't have GameMode installed",
|
||||||
|
"SwitcherooNotInstalled": "You don't have switcheroo-control installed",
|
||||||
"Author": "Author",
|
"Author": "Author",
|
||||||
"NoImages": "No images added",
|
"NoImages": "No images added",
|
||||||
"SettingsTitle": "Settings",
|
"SettingsTitle": "Settings",
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
"Shaders": "Shaders",
|
"Shaders": "Shaders",
|
||||||
"ReshadeNotInstalled": "You haven't installed vkBasalt and reshade-shaders library",
|
"ReshadeNotInstalled": "You haven't installed vkBasalt and reshade-shaders library",
|
||||||
"GameModeNotInstalled": "You don't have GameMode installed",
|
"GameModeNotInstalled": "You don't have GameMode installed",
|
||||||
|
"SwitcherooNotInstalled": "You don't have switcheroo-control installed",
|
||||||
"Author": "Author",
|
"Author": "Author",
|
||||||
"NoImages": "No images added",
|
"NoImages": "No images added",
|
||||||
"SettingsTitle": "Settings",
|
"SettingsTitle": "Settings",
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
"Shaders": "Shaders",
|
"Shaders": "Shaders",
|
||||||
"ReshadeNotInstalled": "You haven't installed vkBasalt and reshade-shaders library",
|
"ReshadeNotInstalled": "You haven't installed vkBasalt and reshade-shaders library",
|
||||||
"GameModeNotInstalled": "You don't have GameMode installed",
|
"GameModeNotInstalled": "You don't have GameMode installed",
|
||||||
|
"SwitcherooNotInstalled": "You don't have switcheroo-control installed",
|
||||||
"Author": "Author",
|
"Author": "Author",
|
||||||
"NoImages": "No images added",
|
"NoImages": "No images added",
|
||||||
"SettingsTitle": "Settings",
|
"SettingsTitle": "Settings",
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
"Shaders": "Shaders",
|
"Shaders": "Shaders",
|
||||||
"ReshadeNotInstalled": "You haven't installed vkBasalt and reshade-shaders library",
|
"ReshadeNotInstalled": "You haven't installed vkBasalt and reshade-shaders library",
|
||||||
"GameModeNotInstalled": "You don't have GameMode installed",
|
"GameModeNotInstalled": "You don't have GameMode installed",
|
||||||
|
"SwitcherooNotInstalled": "You don't have switcheroo-control installed",
|
||||||
"Author": "Author",
|
"Author": "Author",
|
||||||
"NoImages": "No images added",
|
"NoImages": "No images added",
|
||||||
"SettingsTitle": "Settings",
|
"SettingsTitle": "Settings",
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
"Shaders": "Shader",
|
"Shaders": "Shader",
|
||||||
"ReshadeNotInstalled": "Kamu belum memasang vkBasalt dan library reshade-shaders",
|
"ReshadeNotInstalled": "Kamu belum memasang vkBasalt dan library reshade-shaders",
|
||||||
"GameModeNotInstalled": "Kamu belum memasang GameMode",
|
"GameModeNotInstalled": "Kamu belum memasang GameMode",
|
||||||
|
"SwitcherooNotInstalled": "You don't have switcheroo-control installed",
|
||||||
"Author": "Pembuat",
|
"Author": "Pembuat",
|
||||||
"NoImages": "Tidak ada gambar ditambahkan",
|
"NoImages": "Tidak ada gambar ditambahkan",
|
||||||
"SettingsTitle": "Pengaturan",
|
"SettingsTitle": "Pengaturan",
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
"Shaders": "シェーダ",
|
"Shaders": "シェーダ",
|
||||||
"ReshadeNotInstalled": "vkBasaltとreshade-shadersライブラリをインストールしていません",
|
"ReshadeNotInstalled": "vkBasaltとreshade-shadersライブラリをインストールしていません",
|
||||||
"GameModeNotInstalled": "GameModeドがインストールされていません",
|
"GameModeNotInstalled": "GameModeドがインストールされていません",
|
||||||
|
"SwitcherooNotInstalled": "You don't have switcheroo-control installed",
|
||||||
"Author": "著者",
|
"Author": "著者",
|
||||||
"NoImages": "画像は追加されていません",
|
"NoImages": "画像は追加されていません",
|
||||||
"SettingsTitle": "設定",
|
"SettingsTitle": "設定",
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
"Shaders": "쉐이더",
|
"Shaders": "쉐이더",
|
||||||
"ReshadeNotInstalled": "vkBasalt 및 reshade-shaders 라이브러리를 설치하지 않았습니다",
|
"ReshadeNotInstalled": "vkBasalt 및 reshade-shaders 라이브러리를 설치하지 않았습니다",
|
||||||
"GameModeNotInstalled": "GameMode 가 설치되어 있지 않습니다",
|
"GameModeNotInstalled": "GameMode 가 설치되어 있지 않습니다",
|
||||||
|
"SwitcherooNotInstalled": "You don't have switcheroo-control installed",
|
||||||
"Author": "저자",
|
"Author": "저자",
|
||||||
"NoImages": "추가 된 이미지 없음",
|
"NoImages": "추가 된 이미지 없음",
|
||||||
"SettingsTitle": "설정",
|
"SettingsTitle": "설정",
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
"Shaders": "Shaders",
|
"Shaders": "Shaders",
|
||||||
"ReshadeNotInstalled": "You haven't installed vkBasalt and reshade-shaders library",
|
"ReshadeNotInstalled": "You haven't installed vkBasalt and reshade-shaders library",
|
||||||
"GameModeNotInstalled": "You don't have GameMode installed",
|
"GameModeNotInstalled": "You don't have GameMode installed",
|
||||||
|
"SwitcherooNotInstalled": "You don't have switcheroo-control installed",
|
||||||
"Author": "Author",
|
"Author": "Author",
|
||||||
"NoImages": "No images added",
|
"NoImages": "No images added",
|
||||||
"SettingsTitle": "Settings",
|
"SettingsTitle": "Settings",
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
"Shaders": "Шейдеры",
|
"Shaders": "Шейдеры",
|
||||||
"ReshadeNotInstalled": "Вы не установили vkBasalt и библиотеку reshade-shaders",
|
"ReshadeNotInstalled": "Вы не установили vkBasalt и библиотеку reshade-shaders",
|
||||||
"GameModeNotInstalled": "Вы не установили GameMode",
|
"GameModeNotInstalled": "Вы не установили GameMode",
|
||||||
|
"SwitcherooNotInstalled": "You don't have switcheroo-control installed",
|
||||||
"Author": "Автор",
|
"Author": "Автор",
|
||||||
"NoImages": "Изображения не добавлены",
|
"NoImages": "Изображения не добавлены",
|
||||||
"SettingsTitle": "Настройки",
|
"SettingsTitle": "Настройки",
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
"Shaders": "Shaders",
|
"Shaders": "Shaders",
|
||||||
"ReshadeNotInstalled": "You haven't installed vkBasalt and reshade-shaders library",
|
"ReshadeNotInstalled": "You haven't installed vkBasalt and reshade-shaders library",
|
||||||
"GameModeNotInstalled": "You don't have GameMode installed",
|
"GameModeNotInstalled": "You don't have GameMode installed",
|
||||||
|
"SwitcherooNotInstalled": "You don't have switcheroo-control installed",
|
||||||
"Author": "Author",
|
"Author": "Author",
|
||||||
"NoImages": "No images added",
|
"NoImages": "No images added",
|
||||||
"SettingsTitle": "Settings",
|
"SettingsTitle": "Settings",
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
"Shaders": "Shaders",
|
"Shaders": "Shaders",
|
||||||
"ReshadeNotInstalled": "You haven't installed vkBasalt and reshade-shaders library",
|
"ReshadeNotInstalled": "You haven't installed vkBasalt and reshade-shaders library",
|
||||||
"GameModeNotInstalled": "You don't have GameMode installed",
|
"GameModeNotInstalled": "You don't have GameMode installed",
|
||||||
|
"SwitcherooNotInstalled": "You don't have switcheroo-control installed",
|
||||||
"Author": "Author",
|
"Author": "Author",
|
||||||
"NoImages": "No images added",
|
"NoImages": "No images added",
|
||||||
"SettingsTitle": "Settings",
|
"SettingsTitle": "Settings",
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
"Shaders": "Shaders",
|
"Shaders": "Shaders",
|
||||||
"ReshadeNotInstalled": "You haven't installed vkBasalt and reshade-shaders library",
|
"ReshadeNotInstalled": "You haven't installed vkBasalt and reshade-shaders library",
|
||||||
"GameModeNotInstalled": "You don't have GameMode installed",
|
"GameModeNotInstalled": "You don't have GameMode installed",
|
||||||
|
"SwitcherooNotInstalled": "You don't have switcheroo-control installed",
|
||||||
"Author": "Author",
|
"Author": "Author",
|
||||||
"NoImages": "No images added",
|
"NoImages": "No images added",
|
||||||
"SettingsTitle": "设置",
|
"SettingsTitle": "设置",
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
"Shaders": "Shaders",
|
"Shaders": "Shaders",
|
||||||
"ReshadeNotInstalled": "You haven't installed vkBasalt and reshade-shaders library",
|
"ReshadeNotInstalled": "You haven't installed vkBasalt and reshade-shaders library",
|
||||||
"GameModeNotInstalled": "You don't have GameMode installed",
|
"GameModeNotInstalled": "You don't have GameMode installed",
|
||||||
|
"SwitcherooNotInstalled": "You don't have switcheroo-control installed",
|
||||||
"Author": "Author",
|
"Author": "Author",
|
||||||
"NoImages": "No images added",
|
"NoImages": "No images added",
|
||||||
"SettingsTitle": "設定",
|
"SettingsTitle": "設定",
|
||||||
|
|
|
@ -12,6 +12,7 @@ import LauncherLib from './lib/LauncherLib';
|
||||||
import LauncherUI from './lib/LauncherUI';
|
import LauncherUI from './lib/LauncherUI';
|
||||||
import Tools from './lib/Tools';
|
import Tools from './lib/Tools';
|
||||||
import DiscordRPC from './lib/DiscordRPC';
|
import DiscordRPC from './lib/DiscordRPC';
|
||||||
|
import SwitcherooControl from './lib/SwitcherooControl';
|
||||||
|
|
||||||
const launcher_version = require('../../package.json').version;
|
const launcher_version = require('../../package.json').version;
|
||||||
|
|
||||||
|
@ -186,6 +187,16 @@ $(() => {
|
||||||
if (LauncherLib.getConfig('gamemode'))
|
if (LauncherLib.getConfig('gamemode'))
|
||||||
command = `gamemoderun ${command}`;
|
command = `gamemoderun ${command}`;
|
||||||
|
|
||||||
|
// GPU
|
||||||
|
if (LauncherLib.getConfig('gpu') != 'default') {
|
||||||
|
const gpu = await SwitcherooControl.getGpuByName(LauncherLib.getConfig('gpu'));
|
||||||
|
if (gpu) {
|
||||||
|
env = { ...env, ...SwitcherooControl.getEnvAsObject(gpu) };
|
||||||
|
} else {
|
||||||
|
console.warn(`GPU ${LauncherLib.getConfig('gpu')} not found. Launching on the default GPU.`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Starting the game
|
// Starting the game
|
||||||
const startTime = Date.now();
|
const startTime = Date.now();
|
||||||
|
|
||||||
|
|
|
@ -33,6 +33,7 @@ const config = new store ({
|
||||||
hud: 'none', // none / dxvk / mangohud
|
hud: 'none', // none / dxvk / mangohud
|
||||||
shaders: 'none', // none / shader's folder
|
shaders: 'none', // none / shader's folder
|
||||||
gamemode: false,
|
gamemode: false,
|
||||||
|
gpu: 'default',
|
||||||
|
|
||||||
// Version of the game we asked about analytics last time,
|
// Version of the game we asked about analytics last time,
|
||||||
// or null if user said don't ask him again
|
// or null if user said don't ask him again
|
||||||
|
|
54
src/ts/lib/SwitcherooControl.ts
Normal file
54
src/ts/lib/SwitcherooControl.ts
Normal file
|
@ -0,0 +1,54 @@
|
||||||
|
import * as dbus from 'dbus-next';
|
||||||
|
const bus = dbus.systemBus();
|
||||||
|
|
||||||
|
let switcherooProxy: dbus.ProxyObject,
|
||||||
|
switcherooRunning: boolean;
|
||||||
|
|
||||||
|
bus.getProxyObject('net.hadess.SwitcherooControl', '/net/hadess/SwitcherooControl').then(proxy => {
|
||||||
|
switcherooProxy = proxy;
|
||||||
|
switcherooRunning = true;
|
||||||
|
}, () => switcherooRunning = false);
|
||||||
|
|
||||||
|
interface GPU {
|
||||||
|
Default: dbus.Variant<boolean>,
|
||||||
|
Environment: dbus.Variant<string[]>,
|
||||||
|
Name: dbus.Variant<string>
|
||||||
|
}
|
||||||
|
|
||||||
|
export default class SwitcherooControl {
|
||||||
|
public static waitReady() {
|
||||||
|
const poll = (resolve: () => void, reject: () => void) => {
|
||||||
|
if (switcherooRunning === false) reject();
|
||||||
|
if (switcherooProxy) resolve();
|
||||||
|
else setTimeout(poll, 100, resolve, reject);
|
||||||
|
};
|
||||||
|
|
||||||
|
return new Promise<void>(poll)
|
||||||
|
}
|
||||||
|
|
||||||
|
public static getGpus() {
|
||||||
|
if (!switcherooRunning) return null;
|
||||||
|
|
||||||
|
const properties = switcherooProxy.getInterface("org.freedesktop.DBus.Properties");
|
||||||
|
const gpus: Promise<dbus.Variant<GPU[]>> = properties.Get('net.hadess.SwitcherooControl', 'GPUs');
|
||||||
|
return gpus;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static async getGpuByName(name: string) {
|
||||||
|
const gpus = await SwitcherooControl.getGpus();
|
||||||
|
if (!gpus) return null;
|
||||||
|
|
||||||
|
return gpus.value.find(gpu => gpu.Name.value === name);
|
||||||
|
}
|
||||||
|
|
||||||
|
//switcheroo-control returns env vars as an array like this: ["NAME1", "VALUE1", "NAME2", "VALUE2"], but we want them as an object
|
||||||
|
public static getEnvAsObject(gpu: GPU) {
|
||||||
|
const env: any = {};
|
||||||
|
|
||||||
|
for (let i = 0; i < gpu.Environment.value.length; i += 2) {
|
||||||
|
env[gpu.Environment.value[i]] = gpu.Environment.value[i + 1];
|
||||||
|
}
|
||||||
|
|
||||||
|
return env;
|
||||||
|
}
|
||||||
|
}
|
|
@ -12,6 +12,8 @@ import LauncherLib from './lib/LauncherLib';
|
||||||
import LauncherUI from './lib/LauncherUI';
|
import LauncherUI from './lib/LauncherUI';
|
||||||
import Tools from './lib/Tools';
|
import Tools from './lib/Tools';
|
||||||
|
|
||||||
|
import SwitcherooControl from './lib/SwitcherooControl';
|
||||||
|
|
||||||
$(() => {
|
$(() => {
|
||||||
// Make sure settings is shown in correct language.
|
// Make sure settings is shown in correct language.
|
||||||
LauncherUI.updateLang(LauncherLib.getConfig('lang.launcher') ?? 'en-us');
|
LauncherUI.updateLang(LauncherLib.getConfig('lang.launcher') ?? 'en-us');
|
||||||
|
@ -130,6 +132,25 @@ $(() => {
|
||||||
LauncherLib.updateConfig('gamemode', $('#gamemode').hasClass('checkbox-active'));
|
LauncherLib.updateConfig('gamemode', $('#gamemode').hasClass('checkbox-active'));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
SwitcherooControl.waitReady().then(async () => {
|
||||||
|
const gpus = await SwitcherooControl.getGpus()
|
||||||
|
if (gpus) {
|
||||||
|
console.log(gpus);
|
||||||
|
for (const gpu of gpus.value) {
|
||||||
|
$(`<li value="${gpu.Name.value}">${gpu.Name.value}</li>`).appendTo("#gpu .select-options ul");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, () => {
|
||||||
|
console.log("switcheroo-control not running");
|
||||||
|
$("#gpu .selected-item")
|
||||||
|
.addClass("hint--top hint--medium")
|
||||||
|
.attr("data-hint", LauncherUI.i18n.translate("SwitcherooNotInstalled"));
|
||||||
|
});
|
||||||
|
|
||||||
|
$('#gpu').on('selectionChanged', (e, data: any) => {
|
||||||
|
LauncherLib.updateConfig('gpu', data.value);
|
||||||
|
})
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Shaders
|
* Shaders
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in a new issue