Merge branch 'marie/discordrpc' into 'main'

Discord RPC Customization

See merge request KRypt0n_/an-anime-game-launcher!10
This commit is contained in:
Observer KRypt0n_ 2021-12-11 12:43:47 +00:00
commit 99cfdf37d3
20 changed files with 104 additions and 31 deletions

View file

@ -25,6 +25,7 @@
<div class="menu-item" anchor="dxvks" i18id="DXVK">DXVK</div>
<div class="menu-item" anchor="shaders" i18id="Shaders">Shaders</div>
<div class="menu-item" anchor="environment" i18id="Environment">Environment</div>
<div class="menu-item" id="discord-rpc-conf-btn" anchor="discord-rpc-conf" i18id="DRPConf" style="display: none;">Discord RPC</div>
</div>
<div class="settings">
@ -310,6 +311,30 @@
</div>
</div>
</div>
<div class="settings-item" id="discord-rpc-conf" style="display: none;">
<h2 i18id="DRPConf">Discord RPC</h2>
<h3>Launcher</h3>
<h4>Details/Information</h4>
<input type="text" id="rpc-launch-details" class="text-field" placeholder="Preparing to launch" />
<h3>In-Game</h3>
<div class="checkbox" id="rpc-game-elapsed">
<span>Elapsed Time</span>
<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>
</div>
</div>
<h4>Details/Information</h4>
<input type="text" id="rpc-game-details" class="text-field" placeholder="In-Game" />
<h4>Extra Text</h4>
<input type="text" id="rpc-game-state" class="text-field" placeholder="" />
</div>
</div>
</body>
</html>

View file

@ -62,6 +62,5 @@
"TelemetryNotDisabled": "{placeholders.uppercase.company} Telemetrieserver sind nicht deaktiviert!",
"PatchRepoUnavailableTitle": "Patch's repository is not available",
"PatchRepoUnavailableBody": "Most likely notabug is under attack and is not responding",
"DefPrefix": "Zurücksetzen zum Standard-Prefix",
"ChangePrefix": "Prefix ändern"
"DRPConf": "Discord RPC"
}

View file

@ -62,6 +62,5 @@
"TelemetryNotDisabled": "{placeholders.uppercase.company}'s telemetry servers don't disabled!",
"PatchRepoUnavailableTitle": "Patch's repository is not available",
"PatchRepoUnavailableBody": "Most likely notabug is under attack and is not responding",
"DefPrefix": "Reset to Default",
"ChangePrefix": "Change Prefix"
"DRPConf": "Discord RPC"
}

View file

@ -62,6 +62,5 @@
"TelemetryNotDisabled": "{placeholders.uppercase.company}'s telemetry servers don't disabled!",
"PatchRepoUnavailableTitle": "Patch's repository is not available",
"PatchRepoUnavailableBody": "Most likely notabug is under attack and is not responding",
"DefPrefix": "Reset to Default",
"ChangePrefix": "Change Prefix"
"DRPConf": "Discord RPC"
}

View file

@ -62,6 +62,5 @@
"TelemetryNotDisabled": "{placeholders.uppercase.company}'s telemetry servers don't disabled!",
"PatchRepoUnavailableTitle": "Patch's repository is not available",
"PatchRepoUnavailableBody": "Most likely notabug is under attack and is not responding",
"DefPrefix": "Reset to Default",
"ChangePrefix": "Change Prefix"
"DRPConf": "Discord RPC"
}

View file

@ -62,6 +62,5 @@
"TelemetryNotDisabled": "{placeholders.uppercase.company}'s telemetry servers don't disabled!",
"PatchRepoUnavailableTitle": "Patch's repository is not available",
"PatchRepoUnavailableBody": "Most likely notabug is under attack and is not responding",
"DefPrefix": "Reset to Default",
"ChangePrefix": "Change Prefix"
"DRPConf": "Discord RPC"
}

View file

@ -62,6 +62,5 @@
"TelemetryNotDisabled": "Peladen telemetri {placeholders.uppercase.company} tidak dimatikan!",
"PatchRepoUnavailableTitle": "Repositori patch tidak tersedia",
"PatchRepoUnavailableBody": "Sepertinya notabug sedang dalam serangan dan tidak merespon",
"DefPrefix": "Setel ulang ke bawaan",
"ChangePrefix": "Ganti Prefix"
"DRPConf": "Discord RPC"
}

View file

@ -62,6 +62,5 @@
"TelemetryNotDisabled": "{placeholders.uppercase.company}のテレメトリサーバは無効になっていません!",
"PatchRepoUnavailableTitle": "Patch's repository is not available",
"PatchRepoUnavailableBody": "Most likely notabug is under attack and is not responding",
"DefPrefix": "デフォルトへのリセット",
"ChangePrefix": "プレフィックスを変更"
"DRPConf": "Discord RPC"
}

View file

@ -62,6 +62,5 @@
"TelemetryNotDisabled": "{placeholders.uppercase.company} 의 원격 측정 서버가 비활성화되지 않음!",
"PatchRepoUnavailableTitle": "Patch's repository is not available",
"PatchRepoUnavailableBody": "Most likely notabug is under attack and is not responding",
"DefPrefix": "Reset to Default",
"ChangePrefix": "Change Prefix"
"DRPConf": "Discord RPC"
}

View file

@ -62,6 +62,5 @@
"TelemetryNotDisabled": "{placeholders.uppercase.company}'s telemetry servers don't disabled!",
"PatchRepoUnavailableTitle": "Patch's repository is not available",
"PatchRepoUnavailableBody": "Most likely notabug is under attack and is not responding",
"DefPrefix": "Reset to Default",
"ChangePrefix": "Change Prefix"
"DRPConf": "Discord RPC"
}

View file

@ -62,6 +62,5 @@
"TelemetryNotDisabled": "Серверы сбора телеметрии {placeholders.uppercase.company} не отключены!",
"PatchRepoUnavailableTitle": "Репозиторий патча недоступен",
"PatchRepoUnavailableBody": "Скорее всего notabug находится под атакой и не отвечает",
"DefPrefix": "Сбросить до умолчания",
"ChangePrefix": "Изменить префикс"
"DRPConf": "Discord RPC"
}

View file

@ -62,6 +62,5 @@
"TelemetryNotDisabled": "{placeholders.uppercase.company}'s telemetry servers don't disabled!",
"PatchRepoUnavailableTitle": "Patch's repository is not available",
"PatchRepoUnavailableBody": "Most likely notabug is under attack and is not responding",
"DefPrefix": "Reset to Default",
"ChangePrefix": "Change Prefix"
"DRPConf": "Discord RPC"
}

View file

@ -62,6 +62,5 @@
"TelemetryNotDisabled": "{placeholders.uppercase.company}'s telemetry servers don't disabled!",
"PatchRepoUnavailableTitle": "Patch's repository is not available",
"PatchRepoUnavailableBody": "Most likely notabug is under attack and is not responding",
"DefPrefix": "Reset to Default",
"ChangePrefix": "Change Prefix"
"DRPConf": "Discord RPC"
}

View file

@ -62,6 +62,5 @@
"TelemetryNotDisabled": "{placeholders.uppercase.company}'s telemetry servers don't disabled!",
"PatchRepoUnavailableTitle": "Patch's repository is not available",
"PatchRepoUnavailableBody": "Most likely notabug is under attack and is not responding",
"DefPrefix": "Reset to Default",
"ChangePrefix": "Change Prefix"
"DRPConf": "Discord RPC"
}

View file

@ -62,6 +62,5 @@
"TelemetryNotDisabled": "{placeholders.uppercase.company}'s telemetry servers don't disabled!",
"PatchRepoUnavailableTitle": "Patch's repository is not available",
"PatchRepoUnavailableBody": "Most likely notabug is under attack and is not responding",
"DefPrefix": "Reset to Default",
"ChangePrefix": "Change Prefix"
"DRPConf": "Discord RPC"
}

View file

@ -12,6 +12,18 @@
p, span, div
color: map.get($theme-map, "text")
/* Text Field
.text-field
width: calc(100% - 28px)
border-radius: 16px
padding: 8px
background-color: map.get($theme-map, "background2")
color: map.get($theme-map, "text")
border: unset
outline: none
font-size: 15px
/* Directory selector
.directory-selector

View file

@ -203,10 +203,11 @@ $(() => {
if (DiscordRPC.isActive())
{
DiscordRPC.setActivity({
details: 'In-Game',
details: LauncherLib.getConfig('rpcsettings.ingame.details'),
state: LauncherLib.getConfig('rpcsettings.ingame.state') ? LauncherLib.getConfig('rpcsettings.ingame.state') : undefined,
largeImageKey: 'game',
largeImageText: 'An Anime Game',
startTimestamp: Date.now()
startTimestamp: LauncherLib.getConfig('rpcsettings.ingame.elapsed') ? Date.now() : undefined
});
}

View file

@ -1,4 +1,5 @@
import discordRpc, { Client, Presence } from 'discord-rpc';
import LauncherLib from './LauncherLib';
export default class DiscordRPC
{
@ -14,7 +15,7 @@ export default class DiscordRPC
this.rpc.on('ready', () => {
this.rpc.setActivity({
details: 'Preparing to launch',
details: LauncherLib.getConfig('rpcsettings.launcher'),
largeImageKey: 'launcher',
largeImageText: 'An Anime Game'
});

View file

@ -34,6 +34,14 @@ const config = new store ({
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
rpcsettings: {
launcher: 'Preparing to launch',
ingame: {
details: 'In-Game',
state: null,
elapsed: true
}
},
playtime: 0, // Number of seconds user spent in game
hud: 'none', // none / dxvk / mangohud
shaders: 'none', // none / shader's folder

View file

@ -208,12 +208,52 @@ $(() => {
if (LauncherLib.getConfig('rpc'))
$('#discord-rpc').addClass('checkbox-active');
// Unhides the settings for discord rpc
$('#discord-rpc-conf').toggle();
$('#discord-rpc-conf-btn').toggle();
if (LauncherLib.getConfig('rpcsettings.ingame.elapsed'))
$('#rpc-game-elapsed').addClass('checkbox-active');
$('#rpc-game-state').attr('placeholder', LauncherLib.getConfig('rpcsettings.ingame.state'));
$('#rpc-game-details').attr('placeholder', LauncherLib.getConfig('rpcsettings.ingame.details'));
$('#rpc-launch-details').attr('placeholder', LauncherLib.getConfig('rpcsettings.launcher'));
$('#discord-rpc').on('classChange', () => {
LauncherLib.updateConfig('rpc', $('#discord-rpc').hasClass('checkbox-active'));
// Toggles the RPC Settings (hide/show)
$('#discord-rpc-conf').toggle();
$('#discord-rpc-conf-btn').toggle();
ipcRenderer.send('rpc-toggle');
});
$('#rpc-launch-details').on('change', () => {
if ($('#rpc-launch-details').val() == " ")
LauncherLib.updateConfig('rpcsettings.launcher', 'Preparing to launch');
else
LauncherLib.updateConfig('rpcsettings.launcher', $('#rpc-launch-details').val() as string);
});
$('#rpc-game-details').on('change', () => {
if ($('#rpc-game-details').val() == " ")
LauncherLib.updateConfig('rpcsettings.ingame.details', 'In-Game');
else
LauncherLib.updateConfig('rpcsettings.ingame.details', $('#rpc-game-details').val() as string);
});
$('#rpc-game-state').on('change', () => {
if ($('#rpc-game-state').val() == " ")
LauncherLib.updateConfig('rpcsettings.ingame.state', null);
else
LauncherLib.updateConfig('rpcsettings.ingame.state', $('#rpc-game-state').val() as string);
});
$('#rpc-game-elapsed').on('classChange', () => {
LauncherLib.updateConfig('rpcsettings.ingame.elapsed', $('#rpc-game-elapsed').hasClass('checkbox-active'));
});
/**
* Auto-delete DXVK logs
*/