mirror of
https://github.com/Grasscutters/Cultivation.git
synced 2025-12-14 16:14:48 +01:00
better button management
This commit is contained in:
@@ -31,6 +31,8 @@ interface IState {
|
|||||||
httpsEnabled: boolean
|
httpsEnabled: boolean
|
||||||
|
|
||||||
swag: boolean
|
swag: boolean
|
||||||
|
akebiSet: boolean
|
||||||
|
migotoSet: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
export default class ServerLaunchSection extends React.Component<{}, IState> {
|
export default class ServerLaunchSection extends React.Component<{}, IState> {
|
||||||
@@ -49,6 +51,8 @@ export default class ServerLaunchSection extends React.Component<{}, IState> {
|
|||||||
httpsLabel: '',
|
httpsLabel: '',
|
||||||
httpsEnabled: false,
|
httpsEnabled: false,
|
||||||
swag: false,
|
swag: false,
|
||||||
|
akebiSet: false,
|
||||||
|
migotoSet: false,
|
||||||
}
|
}
|
||||||
|
|
||||||
this.toggleGrasscutter = this.toggleGrasscutter.bind(this)
|
this.toggleGrasscutter = this.toggleGrasscutter.bind(this)
|
||||||
@@ -74,6 +78,8 @@ export default class ServerLaunchSection extends React.Component<{}, IState> {
|
|||||||
httpsLabel: await translate('main.https_enable'),
|
httpsLabel: await translate('main.https_enable'),
|
||||||
httpsEnabled: config.https_enabled || false,
|
httpsEnabled: config.https_enabled || false,
|
||||||
swag: config.swag_mode || false,
|
swag: config.swag_mode || false,
|
||||||
|
akebiSet: config.akebi_path !== '',
|
||||||
|
migotoSet: config.migoto_path !== '',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -192,6 +198,16 @@ export default class ServerLaunchSection extends React.Component<{}, IState> {
|
|||||||
await this.playGame(config.akebi_path, gameExec)
|
await this.playGame(config.akebi_path, gameExec)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async launchMigoto() {
|
||||||
|
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.playGame(config.migoto_path, gameExec)
|
||||||
|
}
|
||||||
|
|
||||||
setIp(text: string) {
|
setIp(text: string) {
|
||||||
this.setState({
|
this.setState({
|
||||||
ip: text,
|
ip: text,
|
||||||
@@ -266,9 +282,17 @@ export default class ServerLaunchSection extends React.Component<{}, IState> {
|
|||||||
</BigButton>
|
</BigButton>
|
||||||
{this.state.swag && (
|
{this.state.swag && (
|
||||||
<>
|
<>
|
||||||
|
{this.state.akebiSet && (
|
||||||
<BigButton onClick={this.launchAkebi} id="akebiLaunch">
|
<BigButton onClick={this.launchAkebi} id="akebiLaunch">
|
||||||
<img className="AkebiIcon" id="akebiIcon" src={Akebi} />
|
<img className="AkebiIcon" id="akebiIcon" src={Akebi} />
|
||||||
</BigButton>
|
</BigButton>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{this.state.migotoSet && (
|
||||||
|
<BigButton onClick={this.launchMigoto} id="migotoLaunch">
|
||||||
|
3DM
|
||||||
|
</BigButton>
|
||||||
|
)}
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
<BigButton onClick={this.launchServer} id="serverLaunch">
|
<BigButton onClick={this.launchServer} id="serverLaunch">
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ interface IState {
|
|||||||
|
|
||||||
// Swag stuff
|
// Swag stuff
|
||||||
akebi_path: string
|
akebi_path: string
|
||||||
|
migoto_path: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export default class Options extends React.Component<IProps, IState> {
|
export default class Options extends React.Component<IProps, IState> {
|
||||||
@@ -60,6 +61,7 @@ export default class Options extends React.Component<IProps, IState> {
|
|||||||
|
|
||||||
// Swag stuff
|
// Swag stuff
|
||||||
akebi_path: '',
|
akebi_path: '',
|
||||||
|
migoto_path: '',
|
||||||
}
|
}
|
||||||
|
|
||||||
this.setGameExecutable = this.setGameExecutable.bind(this)
|
this.setGameExecutable = this.setGameExecutable.bind(this)
|
||||||
@@ -100,6 +102,7 @@ export default class Options extends React.Component<IProps, IState> {
|
|||||||
|
|
||||||
// Swag stuff
|
// Swag stuff
|
||||||
akebi_path: config.akebi_path || '',
|
akebi_path: config.akebi_path || '',
|
||||||
|
migoto_path: config.migoto_path || '',
|
||||||
})
|
})
|
||||||
|
|
||||||
this.forceUpdate()
|
this.forceUpdate()
|
||||||
@@ -137,6 +140,14 @@ export default class Options extends React.Component<IProps, IState> {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setMigoto(value: string) {
|
||||||
|
setConfigOption('migoto_path', value)
|
||||||
|
|
||||||
|
this.setState({
|
||||||
|
migoto_path: value,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
async setLanguage(value: string) {
|
async setLanguage(value: string) {
|
||||||
await setConfigOption('language', value)
|
await setConfigOption('language', value)
|
||||||
window.location.reload()
|
window.location.reload()
|
||||||
@@ -308,10 +319,18 @@ export default class Options extends React.Component<IProps, IState> {
|
|||||||
<div className="OptionLabel" id="menuOptionsLabelAkebi">
|
<div className="OptionLabel" id="menuOptionsLabelAkebi">
|
||||||
<Tr text="swag.akebi" />
|
<Tr text="swag.akebi" />
|
||||||
</div>
|
</div>
|
||||||
<div className="OptionValue" id="menuOptionsDirMigoto">
|
<div className="OptionValue" id="menuOptionsDirAkebi">
|
||||||
<DirInput onChange={this.setAkebi} value={this.state?.akebi_path} extensions={['exe']} />
|
<DirInput onChange={this.setAkebi} value={this.state?.akebi_path} extensions={['exe']} />
|
||||||
</div>
|
</div>
|
||||||
</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>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
|||||||
@@ -50,6 +50,7 @@ export interface Configuration {
|
|||||||
|
|
||||||
// Swag stuff
|
// Swag stuff
|
||||||
akebi_path?: string
|
akebi_path?: string
|
||||||
|
migoto_path?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function setConfigOption<K extends keyof Configuration>(key: K, value: Configuration[K]): Promise<void> {
|
export async function setConfigOption<K extends keyof Configuration>(key: K, value: Configuration[K]): Promise<void> {
|
||||||
|
|||||||
Reference in New Issue
Block a user