-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
merge from RERASER/master, apply code cleanup
- Loading branch information
Showing
12 changed files
with
556 additions
and
718 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.