Skip to content

Commit

Permalink
merge from RERASER/master, apply code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
GEEKiDoS committed Dec 18, 2024
1 parent 5dc8afb commit 3758a2c
Show file tree
Hide file tree
Showing 12 changed files with 556 additions and 718 deletions.
73 changes: 73 additions & 0 deletions assets/launcher-ui/src/modules/gameClass.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
import { ref, type Ref } from "vue";
import { VersionState } from "./launcher";

export class GameClass {
public meta: Ref<GameMeta | undefined> = ref(undefined);
public versionState: Ref<VersionState> = ref(VersionState.Unknown);

get installed() {
return this.meta.value?.installed ?? false;
}

async updateMeta() {
this.meta.value = await window.laochan.detectGameInstall(0);
this.versionState.value = this.checkVersion();
}

get installPath() {
if (!this.installed) {
return;
}
return this.meta.value!.install_path;
}

get configPath() {
const installPath = this.installPath;
if (!installPath) {
return;
}

return installPath + 'laochan-config.json';
}

checkVersion(): VersionState {
if (!this.installed) {
return VersionState.Unknown;
}

const targetVersion = this.meta.value!.game_module_target_version;

if (targetVersion == 'ANY')
return VersionState.Normal;

const installVersion = this.meta.value!.game_module_version;
const installVersionNum = Number.parseInt(installVersion.split(":")[4]);
const targetVersionNum = Number.parseInt(targetVersion.split(":")[4]);

if (installVersionNum > targetVersionNum) {
return VersionState.Need2UpdateLauncher;
}

if (installVersionNum < targetVersionNum) {
return VersionState.Need2UpdateGame;
}

return VersionState.Normal
}

async settings() {
if (!this.installed) {
return;
}

window.laochan.shellExecute(this.meta.value!.settings_module_path);
}

async updater() {
if (!this.installed) {
return;
}

window.laochan.shellExecute(this.meta.value!.updater_module_path);
}
}
69 changes: 3 additions & 66 deletions assets/launcher-ui/src/modules/gitadora.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,64 +2,19 @@ import { ref, type Ref } from "vue";
import { launcher, VersionState } from "./launcher";
import type { RefSymbol } from "@vue/reactivity";
import { faL } from "@fortawesome/free-solid-svg-icons";
import { GameClass } from "./gameClass";

export interface GITADORAConfig {
}

export class GITADORA {
export class GITADORA extends GameClass {
private _config: Ref<GITADORAConfig | undefined> = ref(undefined);
private _dirty: boolean = false;
public GameMeta: Ref<GameMeta | undefined> = ref(undefined);
public GameVersionState: Ref<VersionState> = ref(VersionState.Unknown);


get config() {
return this._config;
}

installed() {
return this.GameMeta.value?.installed ?? false;
}

async UpdateMeta() {
this.GameMeta.value = await window.laochan.detectGameInstall(2);
this.GameVersionState.value = this.checkVersion();
}

get installPath() {
if (!this.installed()) {
return;
}
return this.GameMeta.value!.install_path;
}

get configPath() {
const installPath = this.installPath;
if (!installPath) {
return;
}

return installPath + 'laochan-config.json';
}

checkVersion(): VersionState {
if (!this.installed()) {
return VersionState.Unknown;
}
const installVersion = this.GameMeta.value!.game_module_version;
const targetVersion = this.GameMeta.value!.game_module_target_version;
const installVersionNum = Number.parseInt(installVersion.split(":")[4]);
const targetVersionNum = Number.parseInt(targetVersion.split(":")[4]);
if (installVersionNum > targetVersionNum) {
return VersionState.Need2UpdateLauncher;
}
else if (installVersionNum < targetVersionNum) {
return VersionState.Need2UpdateGame;
}
else {
return VersionState.Normal
}
}

async resetConfig() {
this._config.value = {}
this._dirty = true;
Expand Down Expand Up @@ -113,24 +68,6 @@ export class GITADORA {

window.laochan.close();
}

async settings() {
const installPath = this.installPath;
if (!installPath) {
return;
}

window.laochan.shellExecute(installPath + '\\launcher\\modules\\settings.exe');
}

async updater() {
const installPath = this.installPath;
if (!installPath) {
return;
}

window.laochan.shellExecute(installPath + '\\launcher\\modules\\updater.exe', '-t DUMMY');
}
};

export const gitadora = new GITADORA();
72 changes: 4 additions & 68 deletions assets/launcher-ui/src/modules/iidx.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ref, type Ref } from "vue";
import { launcher, VersionState } from "./launcher";
import dedent from "dedent";
import type { TupleType } from "typescript";
import { GameClass } from "./gameClass";
import { launcher } from "./launcher";

export enum GraphicsAPI {
Native = 0,
Expand Down Expand Up @@ -39,60 +39,14 @@ export interface IIDXConfig {
graphicsAPI: GraphicsAPI;
}

export class IIDX {
export class IIDX extends GameClass {
private _config: Ref<IIDXConfig | undefined> = ref(undefined);
private _dirty: boolean = false;
public GameMeta: Ref<GameMeta | undefined> = ref(undefined);
public GameVersionState: Ref<VersionState> = ref(VersionState.Unknown);

get config() {
return this._config;
}

installed() {
return this.GameMeta.value?.installed ?? false;
}

async UpdateMeta() {
this.GameMeta.value = await window.laochan.detectGameInstall(0);
this.GameVersionState.value = this.checkVersion();
}

get installPath() {
if (!this.installed()) {
return;
}
return this.GameMeta.value!.install_path;
}

get configPath() {
const installPath = this.installPath;
if (!installPath) {
return;
}

return installPath + 'laochan-config.json';
}

checkVersion(): VersionState {
if (!this.installed()) {
return VersionState.Unknown;
}
const installVersion = this.GameMeta.value!.game_module_version;
const targetVersion = this.GameMeta.value!.game_module_target_version;
const installVersionNum = Number.parseInt(installVersion.split(":")[4]);
const targetVersionNum = Number.parseInt(targetVersion.split(":")[4]);
if (installVersionNum > targetVersionNum) {
return VersionState.Need2UpdateLauncher;
}
else if (installVersionNum < targetVersionNum) {
return VersionState.Need2UpdateGame;
}
else {
return VersionState.Normal
}
}

async resetConfig() {
const { devices } = await window.laochan.getAsioDeviceList();

Expand Down Expand Up @@ -165,7 +119,7 @@ export class IIDX {

window.laochan.setParam('IIDX_RESOLTION_W', JSON.stringify(config.resolution.w)),
window.laochan.setParam('IIDX_RESOLTION_H', JSON.stringify(config.resolution.h)),
window.laochan.setParam('IIDX_GRAPHICS_API',JSON.stringify(config.graphicsAPI)),
window.laochan.setParam('IIDX_GRAPHICS_API', JSON.stringify(config.graphicsAPI)),
]);
}

Expand All @@ -183,24 +137,6 @@ export class IIDX {
window.laochan.close();
}

async settings() {
const installPath = this.installPath;
if (!installPath) {
return;
}

window.laochan.shellExecute(installPath + '\\launcher\\modules\\bm2dx_settings.exe');
}

async updater() {
const installPath = this.installPath;
if (!installPath) {
return;
}

window.laochan.shellExecute(installPath + '\\launcher\\modules\\bm2dx_updater.exe');
}

async generateBat() {
const config = this._config.value;
if (!config) {
Expand Down
69 changes: 3 additions & 66 deletions assets/launcher-ui/src/modules/sdvx.ts
Original file line number Diff line number Diff line change
@@ -1,63 +1,18 @@
import { ref, type Ref } from "vue";
import { launcher, VersionState } from "./launcher";
import { GameClass } from "./gameClass";

export interface SDVXConfig {
}

export class SDVX {
export class SDVX extends GameClass {
private _config: Ref<SDVXConfig | undefined> = ref(undefined);
private _dirty: boolean = false;
public GameMeta: Ref<GameMeta | undefined> = ref(undefined);
public GameVersionState: Ref<VersionState> = ref(VersionState.Unknown);


get config() {
return this._config;
}

installed() {
return this.GameMeta.value?.installed??false;
}

async UpdateMeta() {
this.GameMeta.value = await window.laochan.detectGameInstall(1);
this.GameVersionState.value = this.checkVersion();
}

get installPath() {
if (!this.installed()) {
return;
}
return this.GameMeta.value!.install_path;
}

get configPath() {
const installPath = this.installPath;
if (!installPath) {
return;
}

return installPath + 'laochan-config.json';
}

checkVersion(): VersionState {
if (!this.installed()) {
return VersionState.Unknown;
}
const installVersion = this.GameMeta.value!.game_module_version;
const targetVersion = this.GameMeta.value!.game_module_target_version;
const installVersionNum = Number.parseInt(installVersion.split(":")[4]);
const targetVersionNum = Number.parseInt(targetVersion.split(":")[4]);
if (installVersionNum > targetVersionNum) {
return VersionState.Need2UpdateLauncher;
}
else if (installVersionNum < targetVersionNum) {
return VersionState.Need2UpdateGame;
}
else {
return VersionState.Normal
}
}

async resetConfig() {
this._config.value = {}
this._dirty = true;
Expand Down Expand Up @@ -111,24 +66,6 @@ export class SDVX {

window.laochan.close();
}

async settings() {
const installPath = this.installPath;
if (!installPath) {
return;
}

window.laochan.shellExecute(installPath + '\\launcher\\modules\\settings.exe');
}

async updater() {
const installPath = this.installPath;
if (!installPath) {
return;
}

window.laochan.shellExecute(installPath + '\\launcher\\modules\\updater.exe', '-t DUMMY');
}
};

export const sdvx = new SDVX();
Loading

0 comments on commit 3758a2c

Please sign in to comment.