mirror of
https://github.com/Grasscutters/Cultivation.git
synced 2025-12-17 01:24:36 +01:00
Merge branch 'mod_management'
This commit is contained in:
@@ -111,8 +111,9 @@ export default class Downloads extends React.Component<IProps, IState> {
|
||||
|
||||
async downloadGrasscutterStableRepo() {
|
||||
const folder = await this.getGrasscutterFolder()
|
||||
this.props.downloadManager.addDownload(STABLE_REPO_DOWNLOAD, folder + '\\grasscutter_repo.zip', () => {
|
||||
unzip(folder + '\\grasscutter_repo.zip', folder + '\\', this.toggleButtons)
|
||||
this.props.downloadManager.addDownload(STABLE_REPO_DOWNLOAD, folder + '\\grasscutter_repo.zip', async () => {
|
||||
await unzip(folder + '\\grasscutter_repo.zip', folder + '\\', true)
|
||||
this.toggleButtons()
|
||||
})
|
||||
|
||||
this.toggleButtons()
|
||||
@@ -120,8 +121,9 @@ export default class Downloads extends React.Component<IProps, IState> {
|
||||
|
||||
async downloadGrasscutterDevRepo() {
|
||||
const folder = await this.getGrasscutterFolder()
|
||||
this.props.downloadManager.addDownload(DEV_REPO_DOWNLOAD, folder + '\\grasscutter_repo.zip', () => {
|
||||
unzip(folder + '\\grasscutter_repo.zip', folder + '\\', this.toggleButtons)
|
||||
this.props.downloadManager.addDownload(DEV_REPO_DOWNLOAD, folder + '\\grasscutter_repo.zip', async () => {
|
||||
await unzip(folder + '\\grasscutter_repo.zip', folder + '\\', true)
|
||||
this.toggleButtons()
|
||||
})
|
||||
|
||||
this.toggleButtons()
|
||||
@@ -129,8 +131,9 @@ export default class Downloads extends React.Component<IProps, IState> {
|
||||
|
||||
async downloadGrasscutterStable() {
|
||||
const folder = await this.getGrasscutterFolder()
|
||||
this.props.downloadManager.addDownload(STABLE_DOWNLOAD, folder + '\\grasscutter.zip', () => {
|
||||
unzip(folder + '\\grasscutter.zip', folder + '\\', this.toggleButtons)
|
||||
this.props.downloadManager.addDownload(STABLE_DOWNLOAD, folder + '\\grasscutter.zip', async () => {
|
||||
await unzip(folder + '\\grasscutter.zip', folder + '\\', true)
|
||||
this.toggleButtons
|
||||
})
|
||||
|
||||
// Also add repo download
|
||||
@@ -141,8 +144,9 @@ export default class Downloads extends React.Component<IProps, IState> {
|
||||
|
||||
async downloadGrasscutterLatest() {
|
||||
const folder = await this.getGrasscutterFolder()
|
||||
this.props.downloadManager.addDownload(DEV_DOWNLOAD, folder + '\\grasscutter.zip', () => {
|
||||
unzip(folder + '\\grasscutter.zip', folder + '\\', this.toggleButtons)
|
||||
this.props.downloadManager.addDownload(DEV_DOWNLOAD, folder + '\\grasscutter.zip', async () => {
|
||||
await unzip(folder + '\\grasscutter.zip', folder + '\\', true)
|
||||
this.toggleButtons()
|
||||
})
|
||||
|
||||
// Also add repo download
|
||||
@@ -165,15 +169,14 @@ export default class Downloads extends React.Component<IProps, IState> {
|
||||
})
|
||||
}
|
||||
|
||||
await unzip(folder + '\\resources.zip', folder + '\\', () => {
|
||||
// Rename folder to resources
|
||||
invoke('rename', {
|
||||
path: folder + '\\Resources',
|
||||
newName: 'resources',
|
||||
})
|
||||
|
||||
this.toggleButtons()
|
||||
await unzip(folder + '\\resources.zip', folder + '\\', true)
|
||||
// Rename folder to resources
|
||||
invoke('rename', {
|
||||
path: folder + '\\Resources',
|
||||
newName: 'resources',
|
||||
})
|
||||
|
||||
this.toggleButtons()
|
||||
})
|
||||
|
||||
this.toggleButtons()
|
||||
|
||||
32
src/ui/components/menu/ExtrasMenu.css
Normal file
32
src/ui/components/menu/ExtrasMenu.css
Normal file
@@ -0,0 +1,32 @@
|
||||
.ExtrasMenu {
|
||||
width: 20%;
|
||||
height: 40%;
|
||||
}
|
||||
|
||||
.ExtrasMenu .MenuInner {
|
||||
justify-content: space-between;
|
||||
height: 70%;
|
||||
}
|
||||
|
||||
.ExtrasMenuContent {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.ExtraItem {
|
||||
width: 80%;
|
||||
|
||||
padding: 6px;
|
||||
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.ExtraLaunch .BigButton {
|
||||
padding: 20px 50px;
|
||||
}
|
||||
178
src/ui/components/menu/ExtrasMenu.tsx
Normal file
178
src/ui/components/menu/ExtrasMenu.tsx
Normal file
@@ -0,0 +1,178 @@
|
||||
import React from 'react'
|
||||
import { getConfig, saveConfig } from '../../../utils/configuration'
|
||||
import Checkbox from '../common/Checkbox'
|
||||
import Menu from './Menu'
|
||||
|
||||
import './ExtrasMenu.css'
|
||||
import BigButton from '../common/BigButton'
|
||||
import { invoke } from '@tauri-apps/api'
|
||||
import Tr from '../../../utils/language'
|
||||
import { getGameExecutable } from '../../../utils/game'
|
||||
|
||||
interface IProps {
|
||||
children: React.ReactNode | React.ReactNode[]
|
||||
closeFn: () => void
|
||||
playGame: (exe?: string, proc_name?: string) => void
|
||||
}
|
||||
|
||||
interface IState {
|
||||
migoto?: string
|
||||
akebi?: string
|
||||
reshade?: string
|
||||
launch_migoto: boolean
|
||||
launch_akebi: boolean
|
||||
launch_reshade: boolean
|
||||
}
|
||||
|
||||
export class ExtrasMenu extends React.Component<IProps, IState> {
|
||||
constructor(props: IProps) {
|
||||
super(props)
|
||||
|
||||
this.state = {
|
||||
launch_migoto: false,
|
||||
launch_akebi: false,
|
||||
launch_reshade: false,
|
||||
}
|
||||
|
||||
this.launchPreprograms = this.launchPreprograms.bind(this)
|
||||
this.toggleMigoto = this.toggleMigoto.bind(this)
|
||||
this.toggleAkebi = this.toggleAkebi.bind(this)
|
||||
this.toggleReshade = this.toggleReshade.bind(this)
|
||||
}
|
||||
|
||||
async componentDidMount() {
|
||||
const config = await getConfig()
|
||||
|
||||
this.setState({
|
||||
migoto: config.migoto_path,
|
||||
akebi: config.akebi_path,
|
||||
reshade: config.reshade_path,
|
||||
launch_akebi: config?.last_extras?.akebi ?? false,
|
||||
launch_migoto: config?.last_extras?.migoto ?? false,
|
||||
launch_reshade: config?.last_extras?.reshade ?? false,
|
||||
})
|
||||
}
|
||||
|
||||
async launchPreprograms() {
|
||||
const config = await getConfig()
|
||||
|
||||
config.last_extras = {
|
||||
migoto: this.state.launch_migoto,
|
||||
akebi: this.state.launch_akebi,
|
||||
reshade: this.state.launch_reshade,
|
||||
}
|
||||
|
||||
await saveConfig(config)
|
||||
|
||||
// Close menu
|
||||
this.props.closeFn()
|
||||
|
||||
// This injects independent of the game
|
||||
if (this.state.launch_migoto) {
|
||||
await this.launchMigoto()
|
||||
}
|
||||
|
||||
// This injects independent of the game
|
||||
if (this.state.launch_reshade) {
|
||||
await this.launchReshade()
|
||||
}
|
||||
|
||||
// This will launch the game
|
||||
if (this.state.launch_akebi) {
|
||||
await this.launchAkebi()
|
||||
|
||||
// This already launches the game
|
||||
return
|
||||
}
|
||||
|
||||
// Launch the game
|
||||
await this.props.playGame()
|
||||
}
|
||||
|
||||
async launchAkebi() {
|
||||
const config = await getConfig()
|
||||
|
||||
// Get game exe from game path, so we can watch it
|
||||
const pathArr = config.game_install_path.replace(/\\/g, '/').split('/')
|
||||
const gameExec = pathArr[pathArr.length - 1]
|
||||
|
||||
await this.props.playGame(config.akebi_path, gameExec)
|
||||
}
|
||||
|
||||
async launchMigoto() {
|
||||
const config = await getConfig()
|
||||
|
||||
if (!config.migoto_path) return alert('Migoto not installed or set!')
|
||||
|
||||
await invoke('run_program_relative', { path: config.migoto_path })
|
||||
}
|
||||
|
||||
async launchReshade() {
|
||||
const config = await getConfig()
|
||||
|
||||
if (!config.reshade_path) return alert('Reshade not installed or set!')
|
||||
|
||||
await invoke('run_command', {
|
||||
program: config.reshade_path,
|
||||
args: [await getGameExecutable()],
|
||||
})
|
||||
}
|
||||
|
||||
toggleMigoto() {
|
||||
this.setState({
|
||||
launch_migoto: !this.state.launch_migoto,
|
||||
})
|
||||
}
|
||||
|
||||
toggleAkebi() {
|
||||
this.setState({
|
||||
launch_akebi: !this.state.launch_akebi,
|
||||
})
|
||||
}
|
||||
|
||||
toggleReshade() {
|
||||
this.setState({
|
||||
launch_reshade: !this.state.launch_reshade,
|
||||
})
|
||||
}
|
||||
|
||||
render() {
|
||||
return (
|
||||
<Menu closeFn={this.props.closeFn} heading="Extras" className="ExtrasMenu">
|
||||
<div className="ExtrasMenuContent">
|
||||
{this.state.migoto && (
|
||||
<div className="ExtraItem">
|
||||
<div className="ExtraItemLabel">
|
||||
<Tr text="swag.migoto_name" />
|
||||
</div>
|
||||
<Checkbox id="MigotoCheckbox" checked={this.state.launch_migoto} onChange={this.toggleMigoto} />
|
||||
</div>
|
||||
)}
|
||||
|
||||
{this.state.akebi && (
|
||||
<div className="ExtraItem">
|
||||
<div className="ExtraItemLabel">
|
||||
<Tr text="swag.akebi_name" />
|
||||
</div>
|
||||
<Checkbox id="AkebiCheckbox" checked={this.state.launch_akebi} onChange={this.toggleAkebi} />
|
||||
</div>
|
||||
)}
|
||||
|
||||
{this.state.reshade && (
|
||||
<div className="ExtraItem">
|
||||
<div className="ExtraItemLabel">
|
||||
<Tr text="swag.reshade_name" />
|
||||
</div>
|
||||
<Checkbox id="ReshadeCheckbox" checked={this.state.launch_reshade} onChange={this.toggleReshade} />
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
<div className="ExtraLaunch">
|
||||
<BigButton id="ExtraLaunch" onClick={this.launchPreprograms}>
|
||||
<Tr text="main.launch_button" />
|
||||
</BigButton>
|
||||
</div>
|
||||
</Menu>
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -45,11 +45,10 @@ export default class Downloads extends React.Component<IProps, IState> {
|
||||
|
||||
async downloadGame() {
|
||||
const folder = this.state.gameDownloadFolder
|
||||
this.props.downloadManager.addDownload(GAME_DOWNLOAD, folder + '\\game.zip', () => {
|
||||
unzip(folder + '\\game.zip', folder + '\\', () => {
|
||||
this.setState({
|
||||
gameDownloading: false,
|
||||
})
|
||||
this.props.downloadManager.addDownload(GAME_DOWNLOAD, folder + '\\game.zip', async () => {
|
||||
await unzip(folder + '\\game.zip', folder + '\\', true)
|
||||
this.setState({
|
||||
gameDownloading: false,
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
@@ -38,6 +38,8 @@ interface IState {
|
||||
|
||||
// Swag stuff
|
||||
akebi_path: string
|
||||
migoto_path: string
|
||||
reshade_path: string
|
||||
}
|
||||
|
||||
export default class Options extends React.Component<IProps, IState> {
|
||||
@@ -61,12 +63,15 @@ export default class Options extends React.Component<IProps, IState> {
|
||||
|
||||
// Swag stuff
|
||||
akebi_path: '',
|
||||
migoto_path: '',
|
||||
reshade_path: '',
|
||||
}
|
||||
|
||||
this.setGameExecutable = this.setGameExecutable.bind(this)
|
||||
this.setGrasscutterJar = this.setGrasscutterJar.bind(this)
|
||||
this.setJavaPath = this.setJavaPath.bind(this)
|
||||
this.setAkebi = this.setAkebi.bind(this)
|
||||
this.setMigoto = this.setMigoto.bind(this)
|
||||
this.toggleGrasscutterWithGame = this.toggleGrasscutterWithGame.bind(this)
|
||||
this.setCustomBackground = this.setCustomBackground.bind(this)
|
||||
this.toggleEncryption = this.toggleEncryption.bind(this)
|
||||
@@ -101,6 +106,8 @@ export default class Options extends React.Component<IProps, IState> {
|
||||
|
||||
// Swag stuff
|
||||
akebi_path: config.akebi_path || '',
|
||||
migoto_path: config.migoto_path || '',
|
||||
reshade_path: config.reshade_path || '',
|
||||
})
|
||||
|
||||
this.forceUpdate()
|
||||
@@ -138,6 +145,22 @@ export default class Options extends React.Component<IProps, IState> {
|
||||
})
|
||||
}
|
||||
|
||||
setMigoto(value: string) {
|
||||
setConfigOption('migoto_path', value)
|
||||
|
||||
this.setState({
|
||||
migoto_path: value,
|
||||
})
|
||||
}
|
||||
|
||||
setReshade(value: string) {
|
||||
setConfigOption('reshade_path', value)
|
||||
|
||||
this.setState({
|
||||
reshade_path: value,
|
||||
})
|
||||
}
|
||||
|
||||
async setLanguage(value: string) {
|
||||
await setConfigOption('language', value)
|
||||
window.location.reload()
|
||||
@@ -204,7 +227,6 @@ export default class Options extends React.Component<IProps, IState> {
|
||||
}
|
||||
|
||||
async restoreMetadata() {
|
||||
console.log(this.props)
|
||||
await meta.restoreMetadata(this.props.downloadManager)
|
||||
}
|
||||
|
||||
@@ -313,10 +335,26 @@ export default class Options extends React.Component<IProps, IState> {
|
||||
<div className="OptionLabel" id="menuOptionsLabelAkebi">
|
||||
<Tr text="swag.akebi" />
|
||||
</div>
|
||||
<div className="OptionValue" id="menuOptionsDirMigoto">
|
||||
<div className="OptionValue" id="menuOptionsDirAkebi">
|
||||
<DirInput onChange={this.setAkebi} value={this.state?.akebi_path} extensions={['exe']} />
|
||||
</div>
|
||||
</div>
|
||||
<div className="OptionSection" id="menuOptionsContainerMigoto">
|
||||
<div className="OptionLabel" id="menuOptionsLabelMigoto">
|
||||
<Tr text="swag.migoto" />
|
||||
</div>
|
||||
<div className="OptionValue" id="menuOptionsDirMigoto">
|
||||
<DirInput onChange={this.setMigoto} value={this.state?.migoto_path} extensions={['exe']} />
|
||||
</div>
|
||||
</div>
|
||||
<div className="OptionSection" id="menuOptionsContainerReshade">
|
||||
<div className="OptionLabel" id="menuOptionsLabelReshade">
|
||||
<Tr text="swag.reshade" />
|
||||
</div>
|
||||
<div className="OptionValue" id="menuOptionsDirReshade">
|
||||
<DirInput onChange={this.setReshade} value={this.state?.reshade_path} extensions={['exe']} />
|
||||
</div>
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user