mirror of
https://github.com/an-anime-team/an-anime-game-launcher.git
synced 2025-01-01 22:47:19 +03:00
2.0.0 beta 4
- added Discord RPC feature - fixed `Cache.get()` hot cache debug output
This commit is contained in:
parent
66f852ddea
commit
34a48ed6a9
11 changed files with 143 additions and 67 deletions
|
@ -6,6 +6,10 @@ splash:
|
||||||
- Paimon am ärgern...
|
- Paimon am ärgern...
|
||||||
- Versuche Yae zu ziehen...
|
- Versuche Yae zu ziehen...
|
||||||
|
|
||||||
|
# Launcher window
|
||||||
|
launcher:
|
||||||
|
predownload: Pre-download the game
|
||||||
|
|
||||||
# Einstellungs Fenster
|
# Einstellungs Fenster
|
||||||
settings:
|
settings:
|
||||||
# General
|
# General
|
||||||
|
|
|
@ -6,6 +6,10 @@ splash:
|
||||||
- Bullying Paimon...
|
- Bullying Paimon...
|
||||||
- Pulling for Yae...
|
- Pulling for Yae...
|
||||||
|
|
||||||
|
# Launcher window
|
||||||
|
launcher:
|
||||||
|
predownload: Pre-download the game
|
||||||
|
|
||||||
# Settings window
|
# Settings window
|
||||||
settings:
|
settings:
|
||||||
# General
|
# General
|
||||||
|
|
|
@ -6,6 +6,10 @@ splash:
|
||||||
- Издеваемся над Паймон...
|
- Издеваемся над Паймон...
|
||||||
- Пытаемся получить Яэ...
|
- Пытаемся получить Яэ...
|
||||||
|
|
||||||
|
# Окна лаунчера
|
||||||
|
launcher:
|
||||||
|
predownload: Предзагрузить обновление
|
||||||
|
|
||||||
# Окно настроек
|
# Окно настроек
|
||||||
settings:
|
settings:
|
||||||
# Основное
|
# Основное
|
||||||
|
|
|
@ -77,9 +77,39 @@ promisify(async () => {
|
||||||
*/
|
*/
|
||||||
enabled: false,
|
enabled: false,
|
||||||
|
|
||||||
// todo
|
/**
|
||||||
texts: {
|
* RPC settings
|
||||||
idk: true
|
*/
|
||||||
|
fields: {
|
||||||
|
/**
|
||||||
|
* Launcher title
|
||||||
|
*/
|
||||||
|
title: 'An Anime Game Launcher',
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Small messages after title
|
||||||
|
*/
|
||||||
|
state: {
|
||||||
|
/**
|
||||||
|
* Message showed when you're in game
|
||||||
|
*/
|
||||||
|
'in-launcher': 'Playing the game',
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Message showed when you're in launcher
|
||||||
|
*/
|
||||||
|
'in-game': 'Preparing to launch'
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* RPC icon name
|
||||||
|
*/
|
||||||
|
icon: 'launcher',
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Should it display amount of spent time or not
|
||||||
|
*/
|
||||||
|
timer: true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { onMount } from 'svelte';
|
import { onMount } from 'svelte';
|
||||||
|
import { _, locale } from 'svelte-i18n';
|
||||||
|
|
||||||
import Window from './ts/neutralino/Window';
|
import Window from './ts/neutralino/Window';
|
||||||
|
|
||||||
|
@ -11,11 +12,21 @@
|
||||||
import constants from './ts/Constants';
|
import constants from './ts/Constants';
|
||||||
import Game from './ts/Game';
|
import Game from './ts/Game';
|
||||||
import Background from './ts/launcher/Background';
|
import Background from './ts/launcher/Background';
|
||||||
|
import Archive from './ts/core/Archive';
|
||||||
|
import Debug from './ts/core/Debug';
|
||||||
|
import Downloader from './ts/core/Downloader';
|
||||||
|
import IPC from './ts/core/IPC';
|
||||||
|
|
||||||
import Gear from './assets/images/gear.png';
|
import Gear from './assets/images/gear.png';
|
||||||
import GearActive from './assets/images/gear-active.png';
|
import GearActive from './assets/images/gear-active.png';
|
||||||
import Download from './assets/images/cloud-download.png';
|
import Download from './assets/images/cloud-download.png';
|
||||||
import DiscordRPC from './ts/core/DiscordRPC';
|
|
||||||
|
constants.paths.launcherDir.then((dir) => {
|
||||||
|
Neutralino.filesystem.getStats(dir)
|
||||||
|
.catch(() => Neutralino.filesystem.createDirectory(dir));
|
||||||
|
});
|
||||||
|
|
||||||
|
const launcher = new Launcher(onMount);
|
||||||
|
|
||||||
Neutralino.events.on('ready', () => {
|
Neutralino.events.on('ready', () => {
|
||||||
Window.open('splash', {
|
Window.open('splash', {
|
||||||
|
@ -27,12 +38,36 @@
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
constants.paths.launcherDir.then((dir) => {
|
Neutralino.events.on('windowClose', () => {
|
||||||
Neutralino.filesystem.getStats(dir)
|
Downloader.closeStreams(true);
|
||||||
.catch(() => Neutralino.filesystem.createDirectory(dir));
|
Archive.closeStreams(true);
|
||||||
});
|
|
||||||
|
|
||||||
const launcher = new Launcher(onMount);
|
constants.paths.launcherDir.then(async (path) => {
|
||||||
|
const time = new Date;
|
||||||
|
|
||||||
|
await IPC.purge();
|
||||||
|
|
||||||
|
if (launcher.rpc)
|
||||||
|
await launcher.rpc.stop(true);
|
||||||
|
|
||||||
|
Neutralino.filesystem.getStats(`${path}/logs`)
|
||||||
|
.then(() => saveLog())
|
||||||
|
.catch(async () => {
|
||||||
|
await Neutralino.filesystem.createDirectory(`${path}/logs`);
|
||||||
|
|
||||||
|
saveLog();
|
||||||
|
});
|
||||||
|
|
||||||
|
const saveLog = async () => {
|
||||||
|
const log = Debug.get().join("\r\n");
|
||||||
|
|
||||||
|
if (log != '')
|
||||||
|
await Neutralino.filesystem.writeFile(`${path}/logs/${time.getDate()}-${time.getMonth() + 1}-${time.getFullYear()}-${time.getHours()}-${time.getMinutes()}-${time.getSeconds()}.log`, log);
|
||||||
|
|
||||||
|
Neutralino.app.exit();
|
||||||
|
};
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
// Do some stuff when all the content will be loaded
|
// Do some stuff when all the content will be loaded
|
||||||
onMount(() => {
|
onMount(() => {
|
||||||
|
@ -40,25 +75,9 @@
|
||||||
* Update launcher's title
|
* Update launcher's title
|
||||||
*/
|
*/
|
||||||
Game.latest.then((game) => {
|
Game.latest.then((game) => {
|
||||||
Window.current.setTitle(`${constants.placeholders.uppercase.full} Linux Launcher - ${game.version}`);
|
Window.current.setTitle(`${constants.placeholders.uppercase.full} Linux Launcher - ${game.version} (beta revision)`);
|
||||||
});
|
});
|
||||||
|
|
||||||
/*const rpc = new DiscordRPC({
|
|
||||||
id: '901534333360304168',
|
|
||||||
details: 'Aboba',
|
|
||||||
state: 'Amogus',
|
|
||||||
icon: {
|
|
||||||
large: 'kleegame'
|
|
||||||
},
|
|
||||||
time: {
|
|
||||||
start: Math.round(Date.now() / 1000)
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
setTimeout(() => {
|
|
||||||
rpc.stop(true);
|
|
||||||
}, 10000);*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add some events to some elements
|
* Add some events to some elements
|
||||||
*/
|
*/
|
||||||
|
@ -105,7 +124,7 @@
|
||||||
<img src={GearActive} class="active" alt="Settings">
|
<img src={GearActive} class="active" alt="Settings">
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<button class="button hint--left hint--small" aria-label="Pre-download the game" id="predownload">
|
<button class="button hint--left hint--small" aria-label="{typeof $locale === 'string' ? $_('launcher.predownload') : ''}" id="predownload">
|
||||||
<img src={Download} alt="Download" />
|
<img src={Download} alt="Download" />
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,5 @@
|
||||||
import '../i18n';
|
import '../i18n';
|
||||||
import App from '../index.svelte';
|
import App from '../index.svelte';
|
||||||
import constants from '../ts/Constants';
|
|
||||||
import Archive from '../ts/core/Archive';
|
|
||||||
import Debug from '../ts/core/Debug';
|
|
||||||
import Downloader from '../ts/core/Downloader';
|
|
||||||
import IPC from '../ts/core/IPC';
|
|
||||||
|
|
||||||
declare const Neutralino;
|
declare const Neutralino;
|
||||||
|
|
||||||
|
@ -12,34 +7,6 @@ Neutralino.init();
|
||||||
|
|
||||||
Neutralino.events.on('ready', () => import('../defaultSettings'));
|
Neutralino.events.on('ready', () => import('../defaultSettings'));
|
||||||
|
|
||||||
Neutralino.events.on('windowClose', () => {
|
|
||||||
Downloader.closeStreams(true);
|
|
||||||
Archive.closeStreams(true);
|
|
||||||
|
|
||||||
constants.paths.launcherDir.then(async (path) => {
|
|
||||||
const time = new Date;
|
|
||||||
|
|
||||||
await IPC.purge();
|
|
||||||
|
|
||||||
Neutralino.filesystem.getStats(`${path}/logs`)
|
|
||||||
.then(() => saveLog())
|
|
||||||
.catch(async () => {
|
|
||||||
await Neutralino.filesystem.createDirectory(`${path}/logs`);
|
|
||||||
|
|
||||||
saveLog();
|
|
||||||
});
|
|
||||||
|
|
||||||
const saveLog = async () => {
|
|
||||||
const log = Debug.get().join("\r\n");
|
|
||||||
|
|
||||||
if (log != '')
|
|
||||||
await Neutralino.filesystem.writeFile(`${path}/logs/${time.getDate()}-${time.getMonth() + 1}-${time.getFullYear()}-${time.getHours()}-${time.getMinutes()}-${time.getSeconds()}.log`, log);
|
|
||||||
|
|
||||||
Neutralino.app.exit();
|
|
||||||
};
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
const app = new App({
|
const app = new App({
|
||||||
target: document.getElementById('app')!
|
target: document.getElementById('app')!
|
||||||
});
|
});
|
||||||
|
|
|
@ -8,16 +8,20 @@ import ProgressBar from './launcher/ProgressBar';
|
||||||
import State from './launcher/State';
|
import State from './launcher/State';
|
||||||
import Debug from './core/Debug';
|
import Debug from './core/Debug';
|
||||||
import IPC from './core/IPC';
|
import IPC from './core/IPC';
|
||||||
|
import DiscordRPC from './core/DiscordRPC';
|
||||||
|
|
||||||
export default class Launcher
|
export default class Launcher
|
||||||
{
|
{
|
||||||
public state?: State;
|
public state?: State;
|
||||||
public progressBar?: ProgressBar;
|
public progressBar?: ProgressBar;
|
||||||
|
public rpc?: DiscordRPC;
|
||||||
|
|
||||||
protected settingsMenu?: Process;
|
protected settingsMenu?: Process;
|
||||||
|
|
||||||
public constructor(onMount)
|
public constructor(onMount)
|
||||||
{
|
{
|
||||||
|
this.updateDiscordRPC('in-launcher');
|
||||||
|
|
||||||
onMount(() => {
|
onMount(() => {
|
||||||
this.progressBar = new ProgressBar(this);
|
this.progressBar = new ProgressBar(this);
|
||||||
this.state = new State(this);
|
this.state = new State(this);
|
||||||
|
@ -38,7 +42,7 @@ export default class Launcher
|
||||||
title: 'Settings',
|
title: 'Settings',
|
||||||
width: 900,
|
width: 900,
|
||||||
height: 600,
|
height: 600,
|
||||||
enableInspector: true,
|
// enableInspector: true,
|
||||||
exitProcessOnClose: false
|
exitProcessOnClose: false
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -83,4 +87,43 @@ export default class Launcher
|
||||||
resolve(`https://${constants.placeholders.lowercase.first}.${constants.placeholders.lowercase.company}.com/launcher/10/${await Configs.get('lang.launcher')}?api_url=https%3A%2F%2Fapi-os-takumi.${constants.placeholders.lowercase.company}.com%2Fhk4e_global&key=gcStgarh&prev=false`);
|
resolve(`https://${constants.placeholders.lowercase.first}.${constants.placeholders.lowercase.company}.com/launcher/10/${await Configs.get('lang.launcher')}?api_url=https%3A%2F%2Fapi-os-takumi.${constants.placeholders.lowercase.company}.com%2Fhk4e_global&key=gcStgarh&prev=false`);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update Discord RPC notification if it is enabled
|
||||||
|
*/
|
||||||
|
public updateDiscordRPC(state: 'in-launcher' | 'in-game'): Promise<void>
|
||||||
|
{
|
||||||
|
return new Promise((resolve) => {
|
||||||
|
Configs.get('discord').then((discord) => {
|
||||||
|
// @ts-expect-error
|
||||||
|
if (discord.enabled)
|
||||||
|
{
|
||||||
|
if (this.rpc)
|
||||||
|
this.rpc.stop(true);
|
||||||
|
|
||||||
|
this.rpc = new DiscordRPC({
|
||||||
|
id: '901534333360304168',
|
||||||
|
|
||||||
|
// @ts-expect-error
|
||||||
|
details: discord.fields.title,
|
||||||
|
|
||||||
|
// @ts-expect-error
|
||||||
|
state: discord.fields.state[state],
|
||||||
|
|
||||||
|
icon: {
|
||||||
|
// @ts-expect-error
|
||||||
|
large: discord.fields.icon
|
||||||
|
},
|
||||||
|
|
||||||
|
time: {
|
||||||
|
// @ts-expect-error
|
||||||
|
start: discord.fields.time ? Math.round(Date.now() / 1000) : 0
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
resolve();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -29,7 +29,7 @@ export default class Cache
|
||||||
message: [
|
message: [
|
||||||
`Resolved ${this.cache[name].expired ? 'expired' : 'unexpired'} hot cache record`,
|
`Resolved ${this.cache[name].expired ? 'expired' : 'unexpired'} hot cache record`,
|
||||||
`[name] ${name}`,
|
`[name] ${name}`,
|
||||||
`[value]: ${this.cache[name].value}`
|
`[value]: ${JSON.stringify(this.cache[name].value)}`
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import Process from '../neutralino/Process';
|
|
||||||
import type { Params } from '../types/DiscordRPC';
|
import type { Params } from '../types/DiscordRPC';
|
||||||
|
|
||||||
|
import Process from '../neutralino/Process';
|
||||||
|
|
||||||
declare const NL_CWD;
|
declare const NL_CWD;
|
||||||
|
|
||||||
export default class DiscordRPC
|
export default class DiscordRPC
|
||||||
|
@ -49,8 +50,6 @@ export default class DiscordRPC
|
||||||
*/
|
*/
|
||||||
public stop(forced: boolean = false): Promise<void>
|
public stop(forced: boolean = false): Promise<void>
|
||||||
{
|
{
|
||||||
console.log(this.process);
|
|
||||||
|
|
||||||
return this.process!.kill(forced);
|
return this.process!.kill(forced);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
import type Launcher from '../../Launcher';
|
||||||
|
|
||||||
import Configs from '../../Configs';
|
import Configs from '../../Configs';
|
||||||
import constants from '../../Constants';
|
import constants from '../../Constants';
|
||||||
import { DebugThread } from '../../core/Debug';
|
import { DebugThread } from '../../core/Debug';
|
||||||
|
@ -11,7 +13,7 @@ import Baal from '../../../assets/images/baal64-transparent.png';
|
||||||
|
|
||||||
declare const Neutralino;
|
declare const Neutralino;
|
||||||
|
|
||||||
export default (): Promise<void> => {
|
export default (launcher: Launcher): Promise<void> => {
|
||||||
return new Promise(async (resolve) => {
|
return new Promise(async (resolve) => {
|
||||||
const debugThread = new DebugThread('State/Launch', 'Starting the game');
|
const debugThread = new DebugThread('State/Launch', 'Starting the game');
|
||||||
|
|
||||||
|
@ -35,6 +37,8 @@ export default (): Promise<void> => {
|
||||||
{
|
{
|
||||||
Window.current.hide();
|
Window.current.hide();
|
||||||
|
|
||||||
|
launcher.updateDiscordRPC('in-game');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Selecting wine executable
|
* Selecting wine executable
|
||||||
*/
|
*/
|
||||||
|
@ -128,6 +132,8 @@ export default (): Promise<void> => {
|
||||||
|
|
||||||
Window.current.show();
|
Window.current.show();
|
||||||
|
|
||||||
|
launcher.updateDiscordRPC('in-launcher');
|
||||||
|
|
||||||
// TODO
|
// TODO
|
||||||
|
|
||||||
resolve();
|
resolve();
|
||||||
|
|
|
@ -191,7 +191,7 @@ class Process
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set output redirection to the temp file
|
// Set output redirection to the temp file
|
||||||
command = `${command} > "${this.addSlashes(tmpFile)}" 2>&1 </dev/null`;
|
command = `${command} > "${this.addSlashes(tmpFile)}" 2>&1 &`;
|
||||||
|
|
||||||
// Set current working directory
|
// Set current working directory
|
||||||
if (options.cwd)
|
if (options.cwd)
|
||||||
|
|
Loading…
Reference in a new issue