Update Grasscutter versions

Add auto MongoDB option
This commit is contained in:
Thoronium 2023-03-31 19:40:14 -06:00
parent 90b86b42d0
commit ef3ba2a045
24 changed files with 219 additions and 39 deletions

View File

@ -1,6 +1,6 @@
{
"name": "cultivation",
"version": "1.0.10",
"version": "1.0.23",
"private": true,
"dependencies": {
"@tauri-apps/api": "^1.0.0-rc.5",

94
src-tauri/Cargo.lock generated
View File

@ -768,6 +768,7 @@ dependencies = [
"tokio-tungstenite 0.17.2",
"tracing",
"unrar",
"windows-service",
"zip 0.6.2",
"zip-extract",
]
@ -1058,7 +1059,7 @@ dependencies = [
"cfg-if",
"libc",
"redox_syscall",
"windows-sys",
"windows-sys 0.36.1",
]
[[package]]
@ -2111,7 +2112,7 @@ dependencies = [
"libc",
"log",
"wasi 0.11.0+wasi-snapshot-preview1",
"windows-sys",
"windows-sys 0.36.1",
]
[[package]]
@ -2465,7 +2466,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f23a407004a1033f53e93f9b45580d14de23928faad187384f891507c9b0c045"
dependencies = [
"pathdiff",
"windows-sys",
"windows-sys 0.36.1",
]
[[package]]
@ -2630,7 +2631,7 @@ dependencies = [
"libc",
"redox_syscall",
"smallvec",
"windows-sys",
"windows-sys 0.36.1",
]
[[package]]
@ -3406,7 +3407,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "88d6731146462ea25d9244b2ed5fd1d716d25c52e4d54aa4fb0f3c4e9854dbe2"
dependencies = [
"lazy_static",
"windows-sys",
"windows-sys 0.36.1",
]
[[package]]
@ -4888,6 +4889,12 @@ dependencies = [
"cc",
]
[[package]]
name = "widestring"
version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "653f141f39ec16bba3c5abe400a0c60da7468261cc2cbf36805022876bc721a8"
[[package]]
name = "wildmatch"
version = "2.1.1"
@ -4990,6 +4997,17 @@ version = "0.37.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4f33f2b90a6664e369c41ab5ff262d06f048fc9685d9bf8a0e99a47750bb0463"
[[package]]
name = "windows-service"
version = "0.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cd9db37ecb5b13762d95468a2fc6009d4b2c62801243223aabd44fca13ad13c8"
dependencies = [
"bitflags",
"widestring",
"windows-sys 0.45.0",
]
[[package]]
name = "windows-sys"
version = "0.36.1"
@ -5003,12 +5021,42 @@ dependencies = [
"windows_x86_64_msvc 0.36.1",
]
[[package]]
name = "windows-sys"
version = "0.45.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0"
dependencies = [
"windows-targets",
]
[[package]]
name = "windows-targets"
version = "0.42.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8e5180c00cd44c9b1c88adb3693291f1cd93605ded80c250a75d472756b4d071"
dependencies = [
"windows_aarch64_gnullvm",
"windows_aarch64_msvc 0.42.2",
"windows_i686_gnu 0.42.2",
"windows_i686_msvc 0.42.2",
"windows_x86_64_gnu 0.42.2",
"windows_x86_64_gnullvm",
"windows_x86_64_msvc 0.42.2",
]
[[package]]
name = "windows-tokens"
version = "0.37.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3263d25f1170419995b78ff10c06b949e8a986c35c208dc24333c64753a87169"
[[package]]
name = "windows_aarch64_gnullvm"
version = "0.42.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8"
[[package]]
name = "windows_aarch64_msvc"
version = "0.32.0"
@ -5027,6 +5075,12 @@ version = "0.37.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2623277cb2d1c216ba3b578c0f3cf9cdebeddb6e66b1b218bb33596ea7769c3a"
[[package]]
name = "windows_aarch64_msvc"
version = "0.42.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43"
[[package]]
name = "windows_i686_gnu"
version = "0.24.0"
@ -5051,6 +5105,12 @@ version = "0.37.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d3925fd0b0b804730d44d4b6278c50f9699703ec49bcd628020f46f4ba07d9e1"
[[package]]
name = "windows_i686_gnu"
version = "0.42.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f"
[[package]]
name = "windows_i686_msvc"
version = "0.24.0"
@ -5075,6 +5135,12 @@ version = "0.37.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ce907ac74fe331b524c1298683efbf598bb031bc84d5e274db2083696d07c57c"
[[package]]
name = "windows_i686_msvc"
version = "0.42.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060"
[[package]]
name = "windows_x86_64_gnu"
version = "0.24.0"
@ -5099,6 +5165,18 @@ version = "0.37.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2babfba0828f2e6b32457d5341427dcbb577ceef556273229959ac23a10af33d"
[[package]]
name = "windows_x86_64_gnu"
version = "0.42.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36"
[[package]]
name = "windows_x86_64_gnullvm"
version = "0.42.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3"
[[package]]
name = "windows_x86_64_msvc"
version = "0.24.0"
@ -5123,6 +5201,12 @@ version = "0.37.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f4dd6dc7df2d84cf7b33822ed5b86318fb1781948e9663bacd047fc9dd52259d"
[[package]]
name = "windows_x86_64_msvc"
version = "0.42.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0"
[[package]]
name = "winreg"
version = "0.10.1"

View File

@ -41,6 +41,9 @@ once_cell = "1.13.0"
open = "3.0.2"
duct = "0.13.5"
# Services
windows-service = "0.6.0"
# Serialization.
serde_json = "1"

View File

@ -28,7 +28,8 @@
"patch_rsa": "自动修改RSA",
"use_proxy": "使用内置代理",
"wipe_login": "清除登录缓存",
"horny_mode": "Horny 模式"
"horny_mode": "Horny 模式",
"auto_mongodb": "Automatically Start MongoDB"
},
"downloads": {
"grasscutter_fullbuild": "下载 Grasscutter 一体化",

View File

@ -28,7 +28,8 @@
"patch_rsa": "自動修補RSA",
"use_proxy": "使用內建代理伺服器",
"wipe_login": "擦除登錄緩存",
"horny_mode": "Horny模式"
"horny_mode": "Horny模式",
"auto_mongodb": "Automatically Start MongoDB"
},
"downloads": {
"grasscutter_fullbuild": "下載Grasscutter多合一下載",

View File

@ -27,7 +27,8 @@
"patch_rsa": "RSA automatisch patchen",
"use_proxy": "Gebruik interne proxy",
"wipe_login": "Wis de inlogcache",
"horny_mode": "Geile modus"
"horny_mode": "Geile modus",
"auto_mongodb": "Automatically Start MongoDB"
},
"downloads": {
"grasscutter_fullbuild": "Alles in Einem Grasscutter Daten herunterladen",

View File

@ -28,7 +28,8 @@
"patch_rsa": "Automatically Patch RSA",
"use_proxy": "Use Internal Proxy",
"wipe_login": "Wipe Login Cache",
"horny_mode": "Horny Mode"
"horny_mode": "Horny Mode",
"auto_mongodb": "Automatically Start MongoDB"
},
"downloads": {
"grasscutter_fullbuild": "Download Grasscutter All-in-One",

View File

@ -28,7 +28,8 @@
"theme": "Establecer Tema",
"use_proxy": "Use Internal Proxy",
"wipe_login": "Wipe Login Cache",
"horny_mode": "Horny Mode"
"horny_mode": "Horny Mode",
"auto_mongodb": "Automatically Start MongoDB"
},
"downloads": {
"grasscutter_fullbuild": "Descargar Datos todo en uno de Grasscutter",

View File

@ -28,7 +28,8 @@
"patch_rsa": "Corriger automatiquement les RSA",
"use_proxy": "Utiliser un proxy interne",
"wipe_login": "Effacer le cache de connexion",
"horny_mode": "Mode excitation"
"horny_mode": "Mode excitation",
"auto_mongodb": "Automatically Start MongoDB"
},
"downloads": {
"grasscutter_fullbuild": "Telecharger Grasscutter tout-en-un",

View File

@ -27,7 +27,8 @@
"patch_rsa": "Automatically Patch RSA",
"use_proxy": "Gunakan Proxy Internal",
"wipe_login": "Menghapus Cache Login",
"horny_mode": "Mode Terangsang"
"horny_mode": "Mode Terangsang",
"auto_mongodb": "Automatically Start MongoDB"
},
"downloads": {
"grasscutter_fullbuild": "Sedang Mendownload Grasscutter Semua Dalam Satu",

View File

@ -28,7 +28,8 @@
"patch_rsa": "RSA 패치 자동 적용",
"use_proxy": "내부 프록시 사용",
"wipe_login": "로그인 캐시 지우기",
"horny_mode": "Horny 모드"
"horny_mode": "Horny 모드",
"auto_mongodb": "Automatically Start MongoDB"
},
"downloads": {
"grasscutter_fullbuild": "올인원 Grasscutter 다운로드",

View File

@ -26,7 +26,8 @@
"patch_rsa": "Automātiski ielāpot RSA",
"use_proxy": "Izmantot iekšējo starpniekserveri",
"wipe_login": "Noslaucīt pieteikšanās kešatmiņu",
"horny_mode": "Uzbudināts režīms"
"horny_mode": "Uzbudināts režīms",
"auto_mongodb": "Automatically Start MongoDB"
},
"downloads": {
"grasscutter_fullbuild": "Lejupielādējiet Grasscutter viss vienā",

View File

@ -27,7 +27,8 @@
"patch_rsa": "RSA Automatisch Bijwerken",
"use_proxy": "Gebruik Interne Proxy",
"wipe_login": "Login cache wissen",
"horny_mode": "Geile modus"
"horny_mode": "Geile modus",
"auto_mongodb": "Automatically Start MongoDB"
},
"downloads": {
"grasscutter_fullbuild": "Grasscutter Alles-in-één Downloaden",

View File

@ -27,7 +27,8 @@
"patch_rsa": "Автоматическое исправление RSA",
"use_proxy": "Использовать встроенный Прокси",
"wipe_login": "Очистить кэш входа в систему",
"horny_mode": "роговой режим"
"horny_mode": "роговой режим",
"auto_mongodb": "Automatically Start MongoDB"
},
"downloads": {
"grasscutter_fullbuild": "Скачать все в одном Grasscutter",

View File

@ -28,7 +28,8 @@
"patch_rsa": "Tự động vá RSA",
"use_proxy": "Sử dụng proxy nội bộ",
"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": "Automatically Start MongoDB"
},
"downloads": {
"grasscutter_fullbuild": "Tải Grasscutter tất cả trong một",

View File

@ -89,6 +89,9 @@ fn main() {
system_helpers::run_command,
system_helpers::run_program,
system_helpers::run_program_relative,
system_helpers::start_service,
system_helpers::service_status,
system_helpers::stop_service,
system_helpers::run_jar,
system_helpers::open_in_browser,
system_helpers::install_location,

View File

@ -1,6 +1,9 @@
use duct::cmd;
use ini::Ini;
use std::ffi::OsStr;
use std::path::PathBuf;
use windows_service::service::{ServiceAccess, ServiceState::Stopped};
use windows_service::service_manager::{ServiceManager, ServiceManagerAccess};
#[cfg(windows)]
use registry::{Data, Hive, Security};
@ -152,6 +155,66 @@ pub fn wipe_registry(exec_name: String) {
}
}
#[tauri::command]
pub fn service_status(service: String) -> bool {
let manager = match ServiceManager::local_computer(None::<&str>, ServiceManagerAccess::CONNECT) {
Ok(manager) => manager,
Err(_e) => return false,
};
let my_service = match manager.open_service(service.clone(), ServiceAccess::QUERY_STATUS) {
Ok(my_service) => my_service,
Err(_e) => return false,
};
let status_result = my_service.query_status();
if status_result.is_ok() {
let status = status_result.unwrap();
println!("{} service status: {:?}", service, status.current_state);
if status.current_state == Stopped {
// Start the service if it is stopped
start_service(service);
}
true
} else {
false
}
}
#[tauri::command]
pub fn start_service(service: String) -> bool {
println!("Starting service: {}", service);
let manager = match ServiceManager::local_computer(None::<&str>, ServiceManagerAccess::CONNECT) {
Ok(manager) => manager,
Err(_e) => return false,
};
let my_service = match manager.open_service(service, ServiceAccess::START) {
Ok(my_service) => my_service,
Err(_e) => return false,
};
match my_service.start(&[OsStr::new("Started service!")]) {
Ok(_s) => true,
Err(_e) => return false,
};
true
}
#[tauri::command]
pub fn stop_service(service: String) -> bool {
println!("Stopping service: {}", service);
let manager = match ServiceManager::local_computer(None::<&str>, ServiceManagerAccess::CONNECT) {
Ok(manager) => manager,
Err(_e) => return false,
};
let my_service = match manager.open_service(service, ServiceAccess::STOP) {
Ok(my_service) => my_service,
Err(_e) => return false,
};
match my_service.stop() {
Ok(_s) => true,
Err(_e) => return false,
};
true
}
#[cfg(unix)]
#[tauri::command]
pub fn wipe_registry(_exec_name: String) {}

View File

@ -97,7 +97,7 @@ pub fn unzip(
}
// If downloading full build, emit that the jar was extracted with it
if zipfile.ends_with("Culti3.4.zip") {
if zipfile.contains("GrasscutterCulti") {
window
.emit("jar_extracted", destpath.to_string() + "grasscutter.jar")
.unwrap();

View File

@ -68,6 +68,7 @@ export class Main extends React.Component<IProps, IState> {
// Emitted for rsa replacing-purposes
listen('game_closed', async () => {
const wasPatched = await getConfigOption('patch_rsa')
const autoService = await getConfigOption('auto_mongodb')
if (wasPatched) {
const unpatched = await unpatchGame()
@ -76,6 +77,10 @@ export class Main extends React.Component<IProps, IState> {
alert(`Could not unpatch game! (Delete version.dll in your game folder)`)
}
}
if (autoService) {
await invoke('stop_service', { service: 'MongoDB' })
}
})
let min = false

View File

@ -159,16 +159,7 @@ export default class ServerLaunchSection extends React.Component<IProps, IState>
// Open server as well if the options are set
if (config.grasscutter_with_game) {
const jarFolderArr = config.grasscutter_path.replace(/\\/g, '/').split('/')
jarFolderArr.pop()
const jarFolder = jarFolderArr.join('/')
await invoke('run_jar', {
path: config.grasscutter_path,
executeIn: jarFolder,
javaPath: config.java_path || '',
})
this.launchServer()
}
} else {
await unpatchGame()
@ -196,6 +187,11 @@ export default class ServerLaunchSection extends React.Component<IProps, IState>
if (!config.grasscutter_path) return alert('Grasscutter not installed or set!')
if (config.auto_mongodb) {
// Check if MongoDB is running and start it if not
await invoke('service_status', { service: 'MongoDB' })
}
let jarFolder = config.grasscutter_path
if (jarFolder.includes('/')) {

View File

@ -13,12 +13,13 @@ import { invoke } from '@tauri-apps/api'
import { listen } from '@tauri-apps/api/event'
import HelpButton from '../common/HelpButton'
const FULL_BUILD_DOWNLOAD = 'https://cdn.discordapp.com/attachments/615655311960965130/1079203157294460958/GrasscutterCulti3.4.zip'
const FULL_BUILD_DOWNLOAD =
'https://cdn.discordapp.com/attachments/615655311960965130/1091457240373919814/GrasscutterCulti3.5.zip'
const STABLE_REPO_DOWNLOAD = 'https://github.com/Grasscutters/Grasscutter/archive/refs/heads/stable.zip'
const DEV_REPO_DOWNLOAD = 'https://github.com/Grasscutters/Grasscutter/archive/refs/heads/development.zip'
const STABLE_DOWNLOAD = 'https://nightly.link/Grasscutters/Grasscutter/workflows/build/stable/Grasscutter.zip'
const DEV_DOWNLOAD = 'https://nightly.link/Grasscutters/Grasscutter/workflows/build/development/Grasscutter.zip'
const RESOURCES_DOWNLOAD = 'https://gitlab.com/YuukiPS/GC-Resources/-/archive/3.4/GC-Resources-3.4.zip' // Use Yuuki res as grasscutter crepe res are broken
const RESOURCES_DOWNLOAD = 'https://gitlab.com/YuukiPS/GC-Resources/-/archive/3.5/GC-Resources-3.5.zip' // Use Yuuki res as grasscutter crepe res are broken
interface IProps {
closeFn: () => void
@ -115,8 +116,8 @@ export default class Downloads extends React.Component<IProps, IState> {
async downloadGrasscutterFullBuild() {
const folder = await this.getGrasscutterFolder()
this.props.downloadManager.addDownload(FULL_BUILD_DOWNLOAD, folder + '\\GrasscutterCulti3.4.zip', async () => {
await unzip(folder + '\\GrasscutterCulti3.4.zip', folder + '\\', true)
this.props.downloadManager.addDownload(FULL_BUILD_DOWNLOAD, folder + '\\GrasscutterCulti3.5.zip', async () => {
await unzip(folder + '\\GrasscutterCulti3.5.zip', folder + '\\', true)
this.toggleButtons()
})
@ -172,7 +173,6 @@ export default class Downloads extends React.Component<IProps, IState> {
async downloadResources() {
const folder = await this.getGrasscutterFolder()
this.props.downloadManager.addDownload(RESOURCES_DOWNLOAD, folder + '\\resources.zip', async () => {
// Tell the user this takes some time
alert(
'Extracting resources can take time! If your resources appear to be "stuck" extracting for less than 15-20 mins, they likely still are extracting.'
@ -218,7 +218,6 @@ export default class Downloads extends React.Component<IProps, IState> {
render() {
return (
<Menu closeFn={this.props.closeFn} className="Downloads" heading="Downloads">
<Divider />
<div className="HeaderText" id="downloadMenuAIOHeader">
@ -226,9 +225,7 @@ export default class Downloads extends React.Component<IProps, IState> {
</div>
<div className="DownloadMenuSection" id="downloadMenuContainerGCFullBuild">
<div className="DownloadLabel" id="downloadMenuLabelGCFullBuild">
<Tr
text={'downloads.grasscutter_fullbuild'}
/>
<Tr text={'downloads.grasscutter_fullbuild'} />
<HelpButton contents="help.gc_fullbuild" />
</div>
<div className="DownloadValue" id="downloadMenuButtonGCFullBuild">

View File

@ -37,6 +37,7 @@ interface IState {
use_internal_proxy: boolean
wipe_login: boolean
horny_mode: boolean
auto_mongodb: boolean
swag: boolean
platform: string
@ -66,6 +67,7 @@ export default class Options extends React.Component<IProps, IState> {
wipe_login: false,
horny_mode: false,
swag: false,
auto_mongodb: false,
platform: '',
// Swag stuff
@ -113,6 +115,7 @@ export default class Options extends React.Component<IProps, IState> {
wipe_login: config.wipe_login || false,
horny_mode: config.horny_mode || false,
swag: config.swag_mode || false,
auto_mongodb: config.auto_mongodb || false,
platform,
// Swag stuff
@ -356,6 +359,18 @@ export default class Options extends React.Component<IProps, IState> {
/>
</div>
</div>
<div className="OptionSection" id="menuOptionsContainerAutoMongodb">
<div className="OptionLabel" id="menuOptionsLabelAutoMongodb">
<Tr text="options.auto_mongodb" />
</div>
<div className="OptionValue" id="menuOptionsCheckboxAutoMongodb">
<Checkbox
onChange={() => this.toggleOption('auto_mongodb')}
checked={this.state?.auto_mongodb}
id="autoMongodb"
/>
</div>
</div>
<Divider />

View File

@ -24,6 +24,7 @@ let defaultConfig: Configuration
use_internal_proxy: true,
wipe_login: false,
horny_mode: false,
auto_mongodb: false,
}
})()
@ -51,6 +52,7 @@ export interface Configuration {
wipe_login: boolean
horny_mode: boolean
swag_mode?: boolean
auto_mongodb: boolean
// Swag stuff
akebi_path?: string

View File

@ -106,7 +106,7 @@ export default class DownloadHandler {
downloadingFullBuild() {
// Kinda hacky but it works
return this.downloads.some((d) => d.path.includes('GrasscutterCulti3.4.zip'))
return this.downloads.some((d) => d.path.includes('GrasscutterCulti'))
}
downloadingResources() {