mirror of
https://github.com/Grasscutters/Cultivation.git
synced 2025-12-13 23:54:48 +01:00
Merge pull request #148 from NotThorny/NonElevated
Non-elevated option & bugfix
This commit is contained in:
@@ -29,7 +29,8 @@
|
|||||||
"use_proxy": "使用内置代理",
|
"use_proxy": "使用内置代理",
|
||||||
"wipe_login": "清除登录缓存",
|
"wipe_login": "清除登录缓存",
|
||||||
"horny_mode": "Horny 模式",
|
"horny_mode": "Horny 模式",
|
||||||
"auto_mongodb": "自动启动 MongoDB"
|
"auto_mongodb": "自动启动 MongoDB",
|
||||||
|
"un_elevated": "非提升运行游戏(无管理员)"
|
||||||
},
|
},
|
||||||
"downloads": {
|
"downloads": {
|
||||||
"grasscutter_fullbuild": "下载 Grasscutter 一体化",
|
"grasscutter_fullbuild": "下载 Grasscutter 一体化",
|
||||||
|
|||||||
@@ -29,7 +29,8 @@
|
|||||||
"use_proxy": "使用內建代理伺服器",
|
"use_proxy": "使用內建代理伺服器",
|
||||||
"wipe_login": "擦除登錄緩存",
|
"wipe_login": "擦除登錄緩存",
|
||||||
"horny_mode": "Horny模式",
|
"horny_mode": "Horny模式",
|
||||||
"auto_mongodb": "自動啟動 MongoDB"
|
"auto_mongodb": "自動啟動 MongoDB",
|
||||||
|
"un_elevated": "在不升高的情况下运行游戏(没有管理员)。"
|
||||||
},
|
},
|
||||||
"downloads": {
|
"downloads": {
|
||||||
"grasscutter_fullbuild": "下載Grasscutter多合一下載",
|
"grasscutter_fullbuild": "下載Grasscutter多合一下載",
|
||||||
|
|||||||
@@ -28,7 +28,8 @@
|
|||||||
"use_proxy": "Gebruik interne proxy",
|
"use_proxy": "Gebruik interne proxy",
|
||||||
"wipe_login": "Wis de inlogcache",
|
"wipe_login": "Wis de inlogcache",
|
||||||
"horny_mode": "Geile modus",
|
"horny_mode": "Geile modus",
|
||||||
"auto_mongodb": "Start automatisch MongoDB"
|
"auto_mongodb": "Start automatisch MongoDB",
|
||||||
|
"un_elevated": "Führen Sie das Spiel nicht erhöht aus (kein Admin)"
|
||||||
},
|
},
|
||||||
"downloads": {
|
"downloads": {
|
||||||
"grasscutter_fullbuild": "Alles in Einem Grasscutter Daten herunterladen",
|
"grasscutter_fullbuild": "Alles in Einem Grasscutter Daten herunterladen",
|
||||||
|
|||||||
@@ -29,7 +29,8 @@
|
|||||||
"use_proxy": "Use Internal Proxy",
|
"use_proxy": "Use Internal Proxy",
|
||||||
"wipe_login": "Wipe Login Cache",
|
"wipe_login": "Wipe Login Cache",
|
||||||
"horny_mode": "Horny Mode",
|
"horny_mode": "Horny Mode",
|
||||||
"auto_mongodb": "Automatically Start MongoDB"
|
"auto_mongodb": "Automatically Start MongoDB",
|
||||||
|
"un_elevated": "Run the game non-elevated (no admin)"
|
||||||
},
|
},
|
||||||
"downloads": {
|
"downloads": {
|
||||||
"grasscutter_fullbuild": "Download Grasscutter All-in-One",
|
"grasscutter_fullbuild": "Download Grasscutter All-in-One",
|
||||||
|
|||||||
@@ -29,7 +29,8 @@
|
|||||||
"use_proxy": "Usar proxy interno",
|
"use_proxy": "Usar proxy interno",
|
||||||
"wipe_login": "Borrar caché de inicio de sesión",
|
"wipe_login": "Borrar caché de inicio de sesión",
|
||||||
"horny_mode": "Modo cachondo",
|
"horny_mode": "Modo cachondo",
|
||||||
"auto_mongodb": "Iniciar automáticamente MongoDB"
|
"auto_mongodb": "Iniciar automáticamente MongoDB",
|
||||||
|
"un_elevated": "Ejecutar el juego no elevado (no admin)"
|
||||||
},
|
},
|
||||||
"downloads": {
|
"downloads": {
|
||||||
"grasscutter_fullbuild": "Descargar Datos todo en uno de Grasscutter",
|
"grasscutter_fullbuild": "Descargar Datos todo en uno de Grasscutter",
|
||||||
|
|||||||
@@ -29,7 +29,8 @@
|
|||||||
"use_proxy": "Utiliser un proxy interne",
|
"use_proxy": "Utiliser un proxy interne",
|
||||||
"wipe_login": "Effacer le cache de connexion",
|
"wipe_login": "Effacer le cache de connexion",
|
||||||
"horny_mode": "Mode excitation",
|
"horny_mode": "Mode excitation",
|
||||||
"auto_mongodb": "Démarrer automatiquement MongoDB"
|
"auto_mongodb": "Démarrer automatiquement MongoDB",
|
||||||
|
"un_elevated": "Exécuter le jeu sans élévation (pas d'administrateur)"
|
||||||
},
|
},
|
||||||
"downloads": {
|
"downloads": {
|
||||||
"grasscutter_fullbuild": "Telecharger Grasscutter tout-en-un",
|
"grasscutter_fullbuild": "Telecharger Grasscutter tout-en-un",
|
||||||
|
|||||||
@@ -28,7 +28,8 @@
|
|||||||
"use_proxy": "Gunakan Proxy Internal",
|
"use_proxy": "Gunakan Proxy Internal",
|
||||||
"wipe_login": "Menghapus Cache Login",
|
"wipe_login": "Menghapus Cache Login",
|
||||||
"horny_mode": "Mode Terangsang",
|
"horny_mode": "Mode Terangsang",
|
||||||
"auto_mongodb": "Mulai MongoDB secara otomatis"
|
"auto_mongodb": "Mulai MongoDB secara otomatis",
|
||||||
|
"un_elevated": "Jalankan game yang tidak ditinggikan (tanpa admin)"
|
||||||
},
|
},
|
||||||
"downloads": {
|
"downloads": {
|
||||||
"grasscutter_fullbuild": "Sedang Mendownload Grasscutter Semua Dalam Satu",
|
"grasscutter_fullbuild": "Sedang Mendownload Grasscutter Semua Dalam Satu",
|
||||||
|
|||||||
@@ -29,7 +29,8 @@
|
|||||||
"use_proxy": "내부 프록시 사용",
|
"use_proxy": "내부 프록시 사용",
|
||||||
"wipe_login": "로그인 캐시 지우기",
|
"wipe_login": "로그인 캐시 지우기",
|
||||||
"horny_mode": "Horny 모드",
|
"horny_mode": "Horny 모드",
|
||||||
"auto_mongodb": "MongoDB 자동 시작"
|
"auto_mongodb": "MongoDB 자동 시작",
|
||||||
|
"un_elevated": "게임 비상승 실행(관리자 없음)"
|
||||||
},
|
},
|
||||||
"downloads": {
|
"downloads": {
|
||||||
"grasscutter_fullbuild": "올인원 Grasscutter 다운로드",
|
"grasscutter_fullbuild": "올인원 Grasscutter 다운로드",
|
||||||
|
|||||||
@@ -27,7 +27,8 @@
|
|||||||
"use_proxy": "Izmantot iekšējo starpniekserveri",
|
"use_proxy": "Izmantot iekšējo starpniekserveri",
|
||||||
"wipe_login": "Noslaucīt pieteikšanās kešatmiņu",
|
"wipe_login": "Noslaucīt pieteikšanās kešatmiņu",
|
||||||
"horny_mode": "Uzbudināts režīms",
|
"horny_mode": "Uzbudināts režīms",
|
||||||
"auto_mongodb": "Automātiski startējiet MongoDB"
|
"auto_mongodb": "Automātiski startējiet MongoDB",
|
||||||
|
"un_elevated": "Palaist spēli bez paaugstinājuma (bez administratora)"
|
||||||
},
|
},
|
||||||
"downloads": {
|
"downloads": {
|
||||||
"grasscutter_fullbuild": "Lejupielādējiet Grasscutter viss vienā",
|
"grasscutter_fullbuild": "Lejupielādējiet Grasscutter viss vienā",
|
||||||
|
|||||||
@@ -28,7 +28,8 @@
|
|||||||
"use_proxy": "Gebruik Interne Proxy",
|
"use_proxy": "Gebruik Interne Proxy",
|
||||||
"wipe_login": "Login cache wissen",
|
"wipe_login": "Login cache wissen",
|
||||||
"horny_mode": "Geile modus",
|
"horny_mode": "Geile modus",
|
||||||
"auto_mongodb": "Start automatisch MongoDB"
|
"auto_mongodb": "Start automatisch MongoDB",
|
||||||
|
"un_elevated": "Voer het spel uit zonder hoogtevrees (geen admin)"
|
||||||
},
|
},
|
||||||
"downloads": {
|
"downloads": {
|
||||||
"grasscutter_fullbuild": "Grasscutter Alles-in-één Downloaden",
|
"grasscutter_fullbuild": "Grasscutter Alles-in-één Downloaden",
|
||||||
|
|||||||
@@ -29,7 +29,8 @@
|
|||||||
"use_proxy": "Usar Proxy Interno",
|
"use_proxy": "Usar Proxy Interno",
|
||||||
"wipe_login": "Limpar Cache de Login",
|
"wipe_login": "Limpar Cache de Login",
|
||||||
"horny_mode": "Modo com tesão",
|
"horny_mode": "Modo com tesão",
|
||||||
"auto_mongodb": "Iniciar MongoDB Automaticamente"
|
"auto_mongodb": "Iniciar MongoDB Automaticamente",
|
||||||
|
"un_elevated": "Executar o jogo não-elevated (sem admin)"
|
||||||
},
|
},
|
||||||
"downloads": {
|
"downloads": {
|
||||||
"grasscutter_fullbuild": "Baixar o Grasscutter Tudo-em-Um",
|
"grasscutter_fullbuild": "Baixar o Grasscutter Tudo-em-Um",
|
||||||
|
|||||||
@@ -28,7 +28,8 @@
|
|||||||
"use_proxy": "Использовать встроенный Прокси",
|
"use_proxy": "Использовать встроенный Прокси",
|
||||||
"wipe_login": "Очистить кэш входа в систему",
|
"wipe_login": "Очистить кэш входа в систему",
|
||||||
"horny_mode": "роговой режим",
|
"horny_mode": "роговой режим",
|
||||||
"auto_mongodb": "Автоматически запускать MongoDB"
|
"auto_mongodb": "Автоматически запускать MongoDB",
|
||||||
|
"un_elevated": "Запустите игру в неэлегантном режиме (без администратора)"
|
||||||
},
|
},
|
||||||
"downloads": {
|
"downloads": {
|
||||||
"grasscutter_fullbuild": "Скачать все в одном Grasscutter",
|
"grasscutter_fullbuild": "Скачать все в одном Grasscutter",
|
||||||
|
|||||||
@@ -29,7 +29,8 @@
|
|||||||
"use_proxy": "Sử dụng proxy nội bộ",
|
"use_proxy": "Sử dụng proxy nội bộ",
|
||||||
"wipe_login": "Tẩy sạch cache đăng nhập",
|
"wipe_login": "Tẩy sạch cache đăng nhập",
|
||||||
"horny_mode": "Chế độ hứng tình",
|
"horny_mode": "Chế độ hứng tình",
|
||||||
"auto_mongodb": "Tự động khởi động MongoDB"
|
"auto_mongodb": "Tự động khởi động MongoDB",
|
||||||
|
"un_elevated": "Chạy trò chơi không nâng cao (không có quản trị viên)"
|
||||||
},
|
},
|
||||||
"downloads": {
|
"downloads": {
|
||||||
"grasscutter_fullbuild": "Tải Grasscutter tất cả trong một",
|
"grasscutter_fullbuild": "Tải Grasscutter tất cả trong một",
|
||||||
|
|||||||
@@ -105,6 +105,7 @@ fn main() {
|
|||||||
system_helpers::set_migoto_delay,
|
system_helpers::set_migoto_delay,
|
||||||
system_helpers::wipe_registry,
|
system_helpers::wipe_registry,
|
||||||
system_helpers::get_platform,
|
system_helpers::get_platform,
|
||||||
|
system_helpers::run_un_elevated,
|
||||||
proxy::set_proxy_addr,
|
proxy::set_proxy_addr,
|
||||||
proxy::generate_ca_files,
|
proxy::generate_ca_files,
|
||||||
unzip::unzip,
|
unzip::unzip,
|
||||||
|
|||||||
@@ -41,7 +41,13 @@ struct ProxyHandler;
|
|||||||
|
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
pub fn set_proxy_addr(addr: String) {
|
pub fn set_proxy_addr(addr: String) {
|
||||||
|
if addr.contains(" ") {
|
||||||
|
let addr2 = addr.replace(" ", "");
|
||||||
|
*SERVER.lock().unwrap() = addr2;
|
||||||
|
} else {
|
||||||
*SERVER.lock().unwrap() = addr;
|
*SERVER.lock().unwrap() = addr;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
|
|||||||
@@ -77,6 +77,18 @@ pub fn run_jar(path: String, execute_in: String, java_path: String) {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[tauri::command]
|
||||||
|
pub fn run_un_elevated(path: String) {
|
||||||
|
// Open the program non-elevated.
|
||||||
|
match open::with(
|
||||||
|
format!("cmd /min /C \"set __COMPAT_LAYER=RUNASINVOKER && start \"\" \"{}\"\"", path),
|
||||||
|
"C:\\Windows\\System32\\cmd.exe",
|
||||||
|
) {
|
||||||
|
Ok(_) => (),
|
||||||
|
Err(e) => println!("Failed to open program ({}): {}", &path, e),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
pub fn open_in_browser(url: String) {
|
pub fn open_in_browser(url: String) {
|
||||||
// Open the URL in the default browser.
|
// Open the URL in the default browser.
|
||||||
|
|||||||
@@ -39,6 +39,8 @@ interface IState {
|
|||||||
swag: boolean
|
swag: boolean
|
||||||
akebiSet: boolean
|
akebiSet: boolean
|
||||||
migotoSet: boolean
|
migotoSet: boolean
|
||||||
|
|
||||||
|
unElevated: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
export default class ServerLaunchSection extends React.Component<IProps, IState> {
|
export default class ServerLaunchSection extends React.Component<IProps, IState> {
|
||||||
@@ -62,6 +64,7 @@ export default class ServerLaunchSection extends React.Component<IProps, IState>
|
|||||||
swag: false,
|
swag: false,
|
||||||
akebiSet: false,
|
akebiSet: false,
|
||||||
migotoSet: false,
|
migotoSet: false,
|
||||||
|
unElevated: false,
|
||||||
}
|
}
|
||||||
|
|
||||||
this.toggleGrasscutter = this.toggleGrasscutter.bind(this)
|
this.toggleGrasscutter = this.toggleGrasscutter.bind(this)
|
||||||
@@ -93,6 +96,7 @@ export default class ServerLaunchSection extends React.Component<IProps, IState>
|
|||||||
swag: config.swag_mode || false,
|
swag: config.swag_mode || false,
|
||||||
akebiSet: config.akebi_path !== '',
|
akebiSet: config.akebi_path !== '',
|
||||||
migotoSet: config.migoto_path !== '',
|
migotoSet: config.migoto_path !== '',
|
||||||
|
unElevated: config.un_elevated || false,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -188,7 +192,14 @@ export default class ServerLaunchSection extends React.Component<IProps, IState>
|
|||||||
path: exe || config.game_install_path,
|
path: exe || config.game_install_path,
|
||||||
})
|
})
|
||||||
|
|
||||||
if (gameExists) await invoke('run_program_relative', { path: exe || config.game_install_path })
|
if (gameExists)
|
||||||
|
if (config.un_elevated) {
|
||||||
|
await invoke('run_un_elevated', {
|
||||||
|
path: config.game_install_path,
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
await invoke('run_program_relative', { path: exe || config.game_install_path })
|
||||||
|
}
|
||||||
else alert('Game not found! At: ' + (exe || config.game_install_path))
|
else alert('Game not found! At: ' + (exe || config.game_install_path))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ interface IState {
|
|||||||
auto_mongodb: boolean
|
auto_mongodb: boolean
|
||||||
swag: boolean
|
swag: boolean
|
||||||
platform: string
|
platform: string
|
||||||
|
un_elevated: boolean
|
||||||
|
|
||||||
// Swag stuff
|
// Swag stuff
|
||||||
akebi_path: string
|
akebi_path: string
|
||||||
@@ -70,6 +71,7 @@ export default class Options extends React.Component<IProps, IState> {
|
|||||||
swag: false,
|
swag: false,
|
||||||
auto_mongodb: false,
|
auto_mongodb: false,
|
||||||
platform: '',
|
platform: '',
|
||||||
|
un_elevated: false,
|
||||||
|
|
||||||
// Swag stuff
|
// Swag stuff
|
||||||
akebi_path: '',
|
akebi_path: '',
|
||||||
@@ -87,6 +89,7 @@ export default class Options extends React.Component<IProps, IState> {
|
|||||||
this.toggleEncryption = this.toggleEncryption.bind(this)
|
this.toggleEncryption = this.toggleEncryption.bind(this)
|
||||||
this.removeRSA = this.removeRSA.bind(this)
|
this.removeRSA = this.removeRSA.bind(this)
|
||||||
this.addMigotoDelay = this.addMigotoDelay.bind(this)
|
this.addMigotoDelay = this.addMigotoDelay.bind(this)
|
||||||
|
this.toggleUnElevatedGame = this.toggleUnElevatedGame.bind(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
async componentDidMount() {
|
async componentDidMount() {
|
||||||
@@ -119,6 +122,7 @@ export default class Options extends React.Component<IProps, IState> {
|
|||||||
swag: config.swag_mode || false,
|
swag: config.swag_mode || false,
|
||||||
auto_mongodb: config.auto_mongodb || false,
|
auto_mongodb: config.auto_mongodb || false,
|
||||||
platform,
|
platform,
|
||||||
|
un_elevated: config.un_elevated || false,
|
||||||
|
|
||||||
// Swag stuff
|
// Swag stuff
|
||||||
akebi_path: config.akebi_path || '',
|
akebi_path: config.akebi_path || '',
|
||||||
@@ -274,6 +278,15 @@ export default class Options extends React.Component<IProps, IState> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async toggleUnElevatedGame() {
|
||||||
|
const changedVal = !(await getConfigOption('un_elevated'))
|
||||||
|
setConfigOption('un_elevated', changedVal)
|
||||||
|
|
||||||
|
this.setState({
|
||||||
|
un_elevated: changedVal,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
async removeRSA() {
|
async removeRSA() {
|
||||||
await meta.unpatchGame()
|
await meta.unpatchGame()
|
||||||
}
|
}
|
||||||
@@ -455,6 +468,18 @@ export default class Options extends React.Component<IProps, IState> {
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div className="OptionSection" id="menuOptionsContainerUEGame">
|
||||||
|
<div className="OptionLabel" id="menuOptionsLabelUEGame">
|
||||||
|
<Tr text="options.un_elevated" />
|
||||||
|
</div>
|
||||||
|
<div className="OptionValue" id="menuOptionsCheckboxUEGame">
|
||||||
|
<Checkbox
|
||||||
|
onChange={() => this.toggleOption('un_elevated')}
|
||||||
|
checked={this.state?.un_elevated}
|
||||||
|
id="unElevatedGame"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
{this.state.swag ? (
|
{this.state.swag ? (
|
||||||
<div className="OptionSection" id="menuOptionsContainerHorny">
|
<div className="OptionSection" id="menuOptionsContainerHorny">
|
||||||
<div className="OptionLabel" id="menuOptionsLabelHorny">
|
<div className="OptionLabel" id="menuOptionsLabelHorny">
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ let defaultConfig: Configuration
|
|||||||
wipe_login: false,
|
wipe_login: false,
|
||||||
horny_mode: false,
|
horny_mode: false,
|
||||||
auto_mongodb: false,
|
auto_mongodb: false,
|
||||||
|
un_elevated: false,
|
||||||
}
|
}
|
||||||
})()
|
})()
|
||||||
|
|
||||||
@@ -53,6 +54,7 @@ export interface Configuration {
|
|||||||
horny_mode: boolean
|
horny_mode: boolean
|
||||||
swag_mode?: boolean
|
swag_mode?: boolean
|
||||||
auto_mongodb: boolean
|
auto_mongodb: boolean
|
||||||
|
un_elevated: boolean
|
||||||
|
|
||||||
// Swag stuff
|
// Swag stuff
|
||||||
akebi_path?: string
|
akebi_path?: string
|
||||||
|
|||||||
@@ -90,7 +90,7 @@ export default class DownloadHandler {
|
|||||||
} = payload
|
} = payload
|
||||||
|
|
||||||
// Find the download that is not extracting and set it's status as such
|
// Find the download that is not extracting and set it's status as such
|
||||||
const index = this.downloads.findIndex((download) => download.path === obj.file || obj.new_folder)
|
const index = this.downloads.findIndex((download) => download.path === obj.file)
|
||||||
this.downloads[index].status = 'finished'
|
this.downloads[index].status = 'finished'
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -101,25 +101,25 @@ export default class DownloadHandler {
|
|||||||
|
|
||||||
downloadingJar() {
|
downloadingJar() {
|
||||||
// Kinda hacky but it works
|
// Kinda hacky but it works
|
||||||
return this.downloads.some((d) => d.path.includes('grasscutter.zip'))
|
return this.downloads.some((d) => d.path.includes('grasscutter.zip') && d.status != ('finished' || 'error'))
|
||||||
}
|
}
|
||||||
|
|
||||||
downloadingFullBuild() {
|
downloadingFullBuild() {
|
||||||
// Kinda hacky but it works
|
// Kinda hacky but it works
|
||||||
return this.downloads.some((d) => d.path.includes('GrasscutterCulti'))
|
return this.downloads.some((d) => d.path.includes('GrasscutterCulti') && d.status != ('finished' || 'error'))
|
||||||
}
|
}
|
||||||
|
|
||||||
downloadingResources() {
|
downloadingResources() {
|
||||||
// Kinda hacky but it works
|
// Kinda hacky but it works
|
||||||
return this.downloads.some((d) => d.path.includes('resources'))
|
return this.downloads.some((d) => d.path.includes('resources') && d.status != ('finished' || 'error'))
|
||||||
}
|
}
|
||||||
|
|
||||||
downloadingRepo() {
|
downloadingRepo() {
|
||||||
return this.downloads.some((d) => d.path.includes('grasscutter_repo.zip'))
|
return this.downloads.some((d) => d.path.includes('grasscutter_repo.zip') && d.status != ('finished' || 'error'))
|
||||||
}
|
}
|
||||||
|
|
||||||
downloadingMigoto() {
|
downloadingMigoto() {
|
||||||
return this.downloads.some((d) => d.path.includes('3dmigoto'))
|
return this.downloads.some((d) => d.path.includes('3dmigoto') && d.status != ('finished' || 'error'))
|
||||||
}
|
}
|
||||||
|
|
||||||
addDownload(url: string, path: string, onFinish?: () => void) {
|
addDownload(url: string, path: string, onFinish?: () => void) {
|
||||||
|
|||||||
@@ -1,25 +1,12 @@
|
|||||||
import { invoke } from '@tauri-apps/api'
|
import { invoke } from '@tauri-apps/api'
|
||||||
import { dataDir } from '@tauri-apps/api/path'
|
|
||||||
import { getGameFolder } from './game'
|
import { getGameFolder } from './game'
|
||||||
|
// Patch file from: https://github.com/34736384/RSAPatch/
|
||||||
|
|
||||||
export async function patchGame() {
|
export async function patchGame() {
|
||||||
// Do we have a patch already?
|
const patchPath = (await invoke('install_location')) + '\\patch\\version.dll'
|
||||||
const patchedExists = await invoke('dir_exists', {
|
|
||||||
path: (await getBackupRSAPath()) + '\\version.dll',
|
|
||||||
})
|
|
||||||
|
|
||||||
if (!patchedExists) {
|
|
||||||
// No patch found? Patching creates one
|
|
||||||
const patched = await downloadRSA()
|
|
||||||
|
|
||||||
if (!patched) {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Are we already patched with mhypbase? If so, that's fine, just continue as normal
|
// Are we already patched with mhypbase? If so, that's fine, just continue as normal
|
||||||
const gameIsPatched = await invoke('are_files_identical', {
|
const gameIsPatched = await invoke('are_files_identical', {
|
||||||
path1: (await getBackupRSAPath()) + '\\version.dll',
|
path1: patchPath,
|
||||||
path2: (await getGameRSAPath()) + '\\mhypbase.dll',
|
path2: (await getGameRSAPath()) + '\\mhypbase.dll',
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -31,7 +18,7 @@ export async function patchGame() {
|
|||||||
|
|
||||||
// Copy the patch to game files
|
// Copy the patch to game files
|
||||||
const replaced = await invoke('copy_file_with_new_name', {
|
const replaced = await invoke('copy_file_with_new_name', {
|
||||||
path: (await getBackupRSAPath()) + '\\version.dll',
|
path: patchPath,
|
||||||
newPath: await getGameRSAPath(),
|
newPath: await getGameRSAPath(),
|
||||||
newName: 'version.dll',
|
newName: 'version.dll',
|
||||||
})
|
})
|
||||||
@@ -61,25 +48,3 @@ export async function getGameRSAPath() {
|
|||||||
|
|
||||||
return (gameData + '\\').replace(/\\/g, '/')
|
return (gameData + '\\').replace(/\\/g, '/')
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getBackupRSAPath() {
|
|
||||||
return (await dataDir()) + 'cultivation\\rsa'
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function downloadRSA() {
|
|
||||||
// Patch file from: https://github.com/34736384/RSAPatch/
|
|
||||||
|
|
||||||
// Should make sure rsa path exists
|
|
||||||
await invoke('dir_create', {
|
|
||||||
path: await getBackupRSAPath(),
|
|
||||||
})
|
|
||||||
|
|
||||||
// Copy patch from local for offline compatibility
|
|
||||||
await invoke('copy_file_with_new_name', {
|
|
||||||
path: (await invoke('install_location')) + '\\patch\\version.dll',
|
|
||||||
newPath: await getBackupRSAPath(),
|
|
||||||
newName: 'version.dll',
|
|
||||||
})
|
|
||||||
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user