Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

加入版本号检测 修复全屏报错 #5

Merged
merged 8 commits into from
Dec 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,889 changes: 969 additions & 920 deletions assets/launcher-ui/package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion assets/launcher-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"npm-run-all2": "^6.2.0",
"sass": "^1.77.8",
"typescript": "~5.4.0",
"vite": "^5.3.1",
"vite": "^5.4.6",
"vue-tsc": "^2.0.21"
}
}
17 changes: 15 additions & 2 deletions assets/launcher-ui/src/env.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,19 @@ interface DisplayMode {
hz: number;
}

interface GameMeta {
game_type: number;
game_name: string;
installed: boolean;
install_path: string;
resource_path: string;
game_module_path: string;
settings_module_path: string;
updater_module_path: string;
game_module_version: string;
game_module_target_version: string;
}

interface Window {
saucer: {
_idc: number;
Expand All @@ -31,7 +44,7 @@ interface Window {
minimize: () => void;
mounted: () => void;
shellExecute: (file: string, args?: string) => void;
detectGameInstall: (gameIndex: number) => Promise<string[]>;
detectGameInstall: (gameIndex: number) => Promise<GameMeta>;
readFile: (path: string) => Promise<string | undefined>;
writeFile: (path: string, content: string) => Promise<void>;
uuid: () => Promise<string>;
Expand All @@ -52,7 +65,7 @@ interface Window {
__cb: ((message: string, color: string, timeout: number) => void) | undefined;
},
ctx: {
gamePaths: Ref<string[][]>;
// gameInfos: Ref<GameMeta[]>;
},
},
chrome: any;
Expand Down
20 changes: 11 additions & 9 deletions assets/launcher-ui/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import router from './router'
import { launcher } from './modules/launcher';
import { iidx } from './modules/iidx';
import { sdvx } from './modules/sdvx';
import { parseJsonText } from 'typescript';
import { gitadora } from './modules/gitadora';

window.laochan = {
close() {
Expand All @@ -24,7 +26,7 @@ window.laochan = {
window.saucer.call('shellExecute', [file, args]);
},
async detectGameInstall(game: number) {
return await window.saucer.call<string[]>('detectGameInstall', [game]);
return JSON.parse(await window.saucer.call<string>('detectGameInstall', [game]));
},
async readFile(path: string) {
const result = await window.saucer.call<string>('readFile', [path]);
Expand Down Expand Up @@ -70,7 +72,7 @@ window.laochan = {
},
num: () => {},
ctx: {
gamePaths: ref<string[][]>([[], [], []]),
gameInfos: ref<GameMeta[]>(new Array<GameMeta>(3)),
},
alert: {
__cb: undefined,
Expand All @@ -85,15 +87,15 @@ window.laochan = {
};

(async () => {
for (let i = 0; i < 3; i++) {
window.laochan.ctx.gamePaths.value[i] = await window.laochan.detectGameInstall(i);
}

launcher.loadConfig();
iidx.loadConfig();
sdvx.loadConfig();
await launcher.loadConfig();
await iidx.loadConfig();
await sdvx.loadConfig();
await iidx.UpdateMeta();
await sdvx.UpdateMeta();
await gitadora.UpdateMeta();
})();

const app = createApp(App)
app.use(router)
app.mount('#app')
app.mount('#app')
38 changes: 32 additions & 6 deletions assets/launcher-ui/src/modules/gitadora.ts
Original file line number Diff line number Diff line change
@@ -1,28 +1,35 @@
import { ref, type Ref } from "vue";
import { launcher } from "./launcher";
import { launcher, VersionState } from "./launcher";
import type { RefSymbol } from "@vue/reactivity";
import { faL } from "@fortawesome/free-solid-svg-icons";

export interface GITADORAConfig {
}

export class GITADORA {
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 !!window.laochan.ctx.gamePaths.value[2].length;
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;
}

const [installPath] = window.laochan.ctx.gamePaths.value[2];
return installPath;
return this.GameMeta.value!.install_path;
}

get configPath() {
Expand All @@ -34,6 +41,25 @@ export class GITADORA {
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
47 changes: 41 additions & 6 deletions assets/launcher-ui/src/modules/iidx.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
import { ref, type Ref } from "vue";
import { launcher } from "./launcher";
import { launcher, VersionState } from "./launcher";
import dedent from "dedent";
import type { TupleType } from "typescript";

export enum GraphicsAPI {
Native = 0,
D3D9On12 = 1,
DXVK = 1,
}

export enum IIDXDisplayMode {
Fullscreen = 0,
Expand Down Expand Up @@ -29,27 +36,33 @@ export interface IIDXConfig {
asioDevice: string;
useGsm: boolean;
language: IIDXLanguage;
graphicsAPI: GraphicsAPI;
}

export class IIDX {
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 !!window.laochan.ctx.gamePaths.value[0].length;
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;
}

const [installPath] = window.laochan.ctx.gamePaths.value[0];
return installPath;
return this.GameMeta.value!.install_path;
}

get configPath() {
Expand All @@ -61,6 +74,25 @@ export class IIDX {
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 All @@ -71,6 +103,7 @@ export class IIDX {
asioDevice: devices[0],
useGsm: true,
language: IIDXLanguage.English,
graphicsAPI: GraphicsAPI.Native,
}

this._dirty = true;
Expand Down Expand Up @@ -105,7 +138,8 @@ export class IIDX {
this._config.value.resolution === undefined ||
this._config.value.soundMode === undefined ||
this._config.value.useGsm === undefined ||
this._config.value.language === undefined
this._config.value.language === undefined ||
this._config.value.graphicsAPI === undefined
) {
window.laochan.alert.show('IIDX 设置已被重置, 请前往额外设置重新设置', '#B64040', 2000);
await this.resetConfig();
Expand All @@ -131,6 +165,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)),
]);
}

Expand Down
7 changes: 7 additions & 0 deletions assets/launcher-ui/src/modules/launcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@ export interface LauncherConfig {
enableSteamOverlay: boolean;
}

export enum VersionState {
Unknown = -1,
Normal = 0,
Need2UpdateLauncher = 1,
Need2UpdateGame = 2,
}

export class Launcher {
private _config: Ref<LauncherConfig | undefined> = ref(undefined);
private _dirty: boolean = false;
Expand Down
36 changes: 30 additions & 6 deletions assets/launcher-ui/src/modules/sdvx.ts
Original file line number Diff line number Diff line change
@@ -1,28 +1,33 @@
import { ref, type Ref } from "vue";
import { launcher } from "./launcher";
import { launcher, VersionState } from "./launcher";

export interface SDVXConfig {
}

export class SDVX {
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 !!window.laochan.ctx.gamePaths.value[1].length;
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;
}

const [installPath] = window.laochan.ctx.gamePaths.value[1];
return installPath;
return this.GameMeta.value!.install_path;
}

get configPath() {
Expand All @@ -34,6 +39,25 @@ export class SDVX {
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
Loading
Loading