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

@@ -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() {