Added Patch section to the settings menu

- removed excess sass styles
- added `Patch.revert()` method
This commit is contained in:
Observer KRypt0n_ 2022-03-05 23:51:36 +02:00
parent 852d4a662c
commit 07b32adaae
No known key found for this signature in database
GPG key ID: 844DA47BA25FE1E2
16 changed files with 249 additions and 44 deletions

View file

@ -274,6 +274,17 @@ settings:
add: Hinzufügen
delete: Löschen
# Patch-related settings
patch:
title: Patch
items:
patch_version: 'Patch version:'
updating_info: 'Updating patch info...'
buttons:
revert_patch: revert patch
apply_patch: apply patch
reapply_patch: re-apply patch
# Notifications
notifications:
# Launcher update

View file

@ -273,6 +273,17 @@ settings:
add: Add
delete: Delete
# Patch-related settings
patch:
title: Patch
items:
patch_version: 'Patch version:'
updating_info: 'Updating patch info...'
buttons:
revert_patch: revert patch
apply_patch: apply patch
reapply_patch: re-apply patch
# Notifications
notifications:
# Launcher update

View file

@ -272,6 +272,17 @@ settings:
add: Añadir
delete: Borrar
# Patch-related settings
patch:
title: Patch
items:
patch_version: 'Patch version:'
updating_info: 'Updating patch info...'
buttons:
revert_patch: revert patch
apply_patch: apply patch
reapply_patch: re-apply patch
# Notifications
notifications:
# Actualización del Launcher

View file

@ -283,6 +283,17 @@ settings:
add: Ajouter
delete: Supprimer
# Patch-related settings
patch:
title: Patch
items:
patch_version: 'Patch version:'
updating_info: 'Updating patch info...'
buttons:
revert_patch: revert patch
apply_patch: apply patch
reapply_patch: re-apply patch
# Notifications
notifications:
# Launcher update

View file

@ -273,6 +273,17 @@ settings:
add: Hozzáadás
delete: Törlés
# Patch-related settings
patch:
title: Patch
items:
patch_version: 'Patch version:'
updating_info: 'Updating patch info...'
buttons:
revert_patch: revert patch
apply_patch: apply patch
reapply_patch: re-apply patch
# Notifications
notifications:
# Launcher update

View file

@ -273,6 +273,17 @@ settings:
add: Tambah
delete: Hapus
# Patch-related settings
patch:
title: Patch
items:
patch_version: 'Patch version:'
updating_info: 'Updating patch info...'
buttons:
revert_patch: revert patch
apply_patch: apply patch
reapply_patch: re-apply patch
# Notifications
notifications:
# Launcher update

View file

@ -271,6 +271,17 @@ settings:
add: Aggiungi
delete: Rimuovi
# Patch-related settings
patch:
title: Patch
items:
patch_version: 'Patch version:'
updating_info: 'Updating patch info...'
buttons:
revert_patch: revert patch
apply_patch: apply patch
reapply_patch: re-apply patch
# Notifications
notifications:
# Launcher update

View file

@ -273,6 +273,17 @@ settings:
add: 追加
delete: 削除
# Patch-related settings
patch:
title: Patch
items:
patch_version: 'Patch version:'
updating_info: 'Updating patch info...'
buttons:
revert_patch: revert patch
apply_patch: apply patch
reapply_patch: re-apply patch
# Notifications
notifications:
# Launcher update

View file

@ -273,6 +273,17 @@ settings:
add: Legg til
delete: Fjern
# Patch-related settings
patch:
title: Patch
items:
patch_version: 'Patch version:'
updating_info: 'Updating patch info...'
buttons:
revert_patch: revert patch
apply_patch: apply patch
reapply_patch: re-apply patch
# Notifications
notifications:
# Launcher update

View file

@ -272,6 +272,17 @@ settings:
add: Добавить
delete: Удалить
# Настроки патча
patch:
title: Патч
items:
patch_version: 'Версия патча:'
updating_info: 'Обновление информации о патче...'
buttons:
revert_patch: отменить патч
apply_patch: применить патч
reapply_patch: переприменить патч
# Уведомления
notifications:
# Обновление лаунчера

View file

@ -272,6 +272,17 @@ settings:
add: add
delete: dewete
# Patch-related settings
patch:
title: Patch
items:
patch_version: 'Patch version:'
updating_info: 'Updating patch info...'
buttons:
revert_patch: revert patch
apply_patch: apply patch
reapply_patch: re-apply patch
# Notifications
notifications:
# Launcher update

View file

@ -273,6 +273,17 @@ settings:
add: 添加
delete: 删除
# Patch-related settings
patch:
title: Patch
items:
patch_version: 'Patch version:'
updating_info: 'Updating patch info...'
buttons:
revert_patch: revert patch
apply_patch: apply patch
reapply_patch: re-apply patch
# Notifications
notifications:
# Launcher update

View file

@ -89,6 +89,18 @@
&:hover
background: #e5e9f0
.settings-item#patch
.patch-version
font-size: 18px
span
margin-left: 8px
color: map.get($theme-map, "primary")
span.warning
color: #d82148
.settings-footer
margin: 24px 0
@ -104,45 +116,6 @@
color: map.get($theme-map, "primary")
.launcher-stats
display: inline-flex
margin-bottom: 16px
> img
width: 96px
height: 96px
.level
position: absolute
width: 96px
top: 105px
text-align: center
font-size: 20px
color: #71b71b
.stats
margin-left: 32px
align-self: center
> p
font-size: 20px
font-weight: 600
margin: 0
.time-spent
font-size: 18px
margin: 8px 0 16px 0
.badges
margin-bottom: 16px
img
width: 24px
height: 24px
margin-right: 4px
@import "themes/light"
@import "themes/dark"

View file

@ -12,6 +12,9 @@
import Launcher from './ts/Launcher';
import FPSUnlock from './ts/FPSUnlock';
import Runners from './ts/core/Runners';
import Patch from './ts/Patch';
import type { PatchInfo } from './ts/types/Patch';
import Button from './components/Button.svelte';
import Checkbox from './components/Checkbox.svelte';
@ -115,7 +118,14 @@
gamemode.tooltip = 'settings.enhancements.game.items.gamemode.tooltip.disabled';
});
let borderless_active = Configs.get('borderless_window').then((val) => borderless_active = val);
let borderless_active = Configs.get('borderless_window').then((value) => borderless_active = value);
/**
* Patch info
*/
let patchInfo: PatchInfo|null = null;
Patch.latest.then((value) => patchInfo = value);
/**
* Menu items changing
@ -185,7 +195,7 @@
});
if (voiceUpdateRequired)
await IPC.write('voice-update-required');
await IPC.write('update-state');
Neutralino.app.exit();
});
@ -194,7 +204,7 @@
{#if typeof $locale === 'string'}
<main>
<div class="menu">
{#each ['general', 'enhancements', 'runners', 'dxvks', 'shaders', 'environment'] as item}
{#each ['general', 'enhancements', 'runners', 'dxvks', 'shaders', 'environment', 'patch'] as item}
<div
class="menu-item"
class:menu-item-active={selectedItem === item}
@ -467,6 +477,74 @@
<EnvironmentManager />
</div>
<div class="settings-item" id="patch">
<h1>{$_('settings.patch.title')}</h1>
{#if patchInfo !== null}
<div class="patch-version">
{$_('settings.patch.items.patch_version')}
<span class:warning={!patchInfo.applied}>
{ `${patchInfo.version} ${patchInfo.state}` }
</span>
</div>
<div style="margin-top: 24px">
{#if patchInfo.applied}
<!-- svelte-ignore missing-declaration -->
<Button
lang="settings.patch.items.buttons.revert_patch"
click={async () => {
if (patchInfo)
{
const prevPatchInfo = patchInfo;
patchInfo = null;
patchInfo = await Patch.revert(prevPatchInfo) ?
await Patch.latest : prevPatchInfo;
}
}}
/>
<!-- svelte-ignore missing-declaration -->
<Button
lang="settings.patch.items.buttons.reapply_patch"
click={async () => {
if (patchInfo)
{
const prevPatchInfo = patchInfo;
patchInfo = null;
if (await Patch.revert(prevPatchInfo))
{
await IPC.write('update-state');
Neutralino.app.exit();
}
else patchInfo = prevPatchInfo;
}
}}
/>
{:else}
<!-- svelte-ignore missing-declaration -->
<Button
lang="settings.patch.items.buttons.apply_patch"
click={async () => {
await IPC.write('update-state');
Neutralino.app.exit();
}}
/>
{/if}
</div>
{:else}
<p>Updating patch info...</p>
{/if}
</div>
<div class="settings-footer">
<span>An Anime Game Launcher {Launcher.version}</span>

View file

@ -122,9 +122,9 @@ export default class Launcher
}
}
else if (record.data === 'voice-update-required')
else if (record.data === 'update-state')
{
this.state!.set('game-voice-update-required');
this.state?.update();
record.pop();
}

View file

@ -450,6 +450,28 @@ export default class Patch
.catch((err) => reject(err));
});
}
/**
* Try to revert applied patch
*
* @returns false if the locally installed patch repository is not available or the patch is not applied
*/
public static revert(patch: PatchInfo): Promise<boolean>
{
return new Promise(async (resolve) => {
const patchRevertFile = `${await constants.paths.launcherDir}/patch/${patch.version.replaceAll('.', '')}/patch_revert.sh`;
if (!await fs.exists(patchRevertFile))
resolve(false);
else
{
const result = await Neutralino.os.execCommand(`chmod +x "${path.addSlashes(patchRevertFile)}" && cd "${path.addSlashes(await constants.paths.gameDir)}" && yes yes yes | bash "${path.addSlashes(patchRevertFile)}"`);
resolve(result.stdOut.includes('==> Patch reverted'));
}
});
}
}
export { Stream };