Changes from 1.2.1 - 1.5.1

Contains slightly modified commits from between 1.2.1 and 1.5.1.
This commit is contained in:
Thoronium
2024-10-30 13:18:07 -06:00
parent 31c60755af
commit f6f5eae31c
46 changed files with 2619 additions and 1669 deletions

View File

@@ -29,6 +29,8 @@ let defaultConfig: Configuration
un_elevated: false,
redirect_more: false,
launch_args: '',
offline_mode: false,
newer_game: false,
// Linux stuff
grasscutter_elevation: 'None',
@@ -64,6 +66,8 @@ export interface Configuration {
un_elevated: boolean
redirect_more: boolean
launch_args: string
offline_mode: boolean
newer_game: boolean
// Linux stuff
grasscutter_elevation: string
@@ -128,7 +132,7 @@ async function readConfigFile() {
await fs.createDir(local + 'cultivation').catch((e) => console.log(e))
}
const innerDirs = await fs.readDir(local + 'cultivation')
const innerDirs = await fs.readDir(local + '/cultivation')
// Create grasscutter dir for potential installation
if (!innerDirs.find((fileOrDir) => fileOrDir?.name === 'grasscutter')) {

View File

@@ -73,6 +73,11 @@ export default class DownloadHandler {
const index = this.downloads.findIndex((download) => download.path === errorData.path)
this.downloads[index].status = 'error'
this.downloads[index].error = errorData.error
// Remove GIMI from list as fallback will replace it
if (errorData.path.includes('GIMI.zip')) {
this.downloads.splice(index, 1)
}
})
// Extraction events
@@ -92,6 +97,9 @@ export default class DownloadHandler {
// Find the download that is not extracting and set it's status as such
const index = this.downloads.findIndex((download) => download.path === obj.file)
this.downloads[index].status = 'finished'
// Remove completed extraction from list
this.downloads.splice(index, 1)
})
}

View File

@@ -45,7 +45,7 @@ export async function getGameDataFolder() {
return null
}
return (await getGameFolder()) + '/' + gameExec.replace('.exe', '_Data')
return (await getGameFolder()) + '\\' + gameExec.replace('.exe', '_Data')
}
export async function getGameVersion() {
@@ -55,9 +55,33 @@ export async function getGameVersion() {
return null
}
const hasAsb = await invoke('dir_exists', {
path: GameData + '\\StreamingAssets\\asb_settings.json',
})
if (!hasAsb) {
// For games that cannot determine game version
const otherGameVer: string = await invoke('read_file', {
path: GameData + '\\StreamingAssets\\BinaryVersion.bytes',
})
const versionRaw = otherGameVer.split('.')
const version = {
major: parseInt(versionRaw[0]),
minor: parseInt(versionRaw[1]),
// This will probably never matter, just use major/minor. If needed, full version values are near EOF
release: 0,
}
if (otherGameVer == null || otherGameVer.length < 1) {
return null
}
return version
}
const settings = JSON.parse(
await invoke('read_file', {
path: GameData + '/StreamingAssets/asb_settings.json',
path: GameData + '\\StreamingAssets\\asb_settings.json',
})
)

View File

@@ -65,7 +65,7 @@ export default class Tr extends React.Component<IProps, IState> {
})
} else {
this.setState({
translated_text: translation_obj[text] || '',
translated_text: translation_obj[text] || text,
})
}
}

View File

@@ -1,8 +1,8 @@
import { invoke } from '@tauri-apps/api'
// Patch file from: https://github.com/34736384/RSAPatch/
export async function patchGame() {
return invoke('patch_game')
export async function patchGame(newerGame: boolean, version: string) {
return invoke('patch_game', { newerGame, version })
}
export async function unpatchGame() {

View File

@@ -40,5 +40,32 @@ export async function encryptionEnabled(path: string) {
return false
}
return serverConf.server.http.encryption.useEncryption
if ('server' in serverConf) {
return serverConf.server.http.encryption.useEncryption
}
return false
}
export async function changeResourcePath(path: string) {
let serverConf
try {
serverConf = JSON.parse(
await invoke('read_file', {
path,
})
)
} catch (e) {
console.log(`Server config at ${path} not found or invalid. Be sure to run the server at least once to generate it`)
return
}
serverConf.folderStructure.resources = './resources/'
// Write file
await invoke('write_file', {
path,
contents: JSON.stringify(serverConf, null, 2),
})
}

View File

@@ -40,7 +40,7 @@ const defaultTheme = {
export async function getThemeList() {
// Do some invoke to backend to get the theme list
const themes = (await invoke('get_theme_list', {
dataDir: `${await dataDir()}cultivation`,
dataDir: `${await dataDir()}/cultivation`,
})) as BackendThemeList[]
const list: ThemeList[] = [
// ALWAYS include default theme