another normal feature

This commit is contained in:
SpikeHD
2022-07-14 20:05:11 -07:00
parent ab0e05ffe1
commit fc5ffae1e2
3 changed files with 40 additions and 9 deletions

View File

Before

Width:  |  Height:  |  Size: 4.5 KiB

After

Width:  |  Height:  |  Size: 4.5 KiB

View File

@@ -62,20 +62,27 @@
display: flex; display: flex;
flex-direction: row; flex-direction: row;
justify-content: space-between; justify-content: space-between;
align-items: center; align-items: flex-start;
height: 100%; height: 100%;
max-height: 60px; max-height: 60px;
} }
#officialPlay { .ServerLaunchButtons .BigButton {
width: 60% margin-right: 8px;
} }
#officialPlay {
max-width: 60%;
flex-grow: 1;
}
#akebiLaunch,
#serverLaunch { #serverLaunch {
width: 5%; width: 5%;
} }
.AkebiIcon,
.ServerIcon { .ServerIcon {
height: 20px; height: 20px;
filter: invert(28%) sepia(28%) saturate(1141%) hue-rotate(352deg) brightness(96%) contrast(88%); filter: invert(28%) sepia(28%) saturate(1141%) hue-rotate(352deg) brightness(96%) contrast(88%);

View File

@@ -8,6 +8,8 @@ import { translate } from '../../utils/language'
import { invoke } from '@tauri-apps/api/tauri' import { invoke } from '@tauri-apps/api/tauri'
import Server from '../../resources/icons/server.svg' import Server from '../../resources/icons/server.svg'
import Akebi from '../../resources/icons/akebi.svg'
import './ServerLaunchSection.css' import './ServerLaunchSection.css'
import {dataDir} from '@tauri-apps/api/path' import {dataDir} from '@tauri-apps/api/path'
@@ -29,6 +31,8 @@ interface IState {
httpsLabel: string; httpsLabel: string;
httpsEnabled: boolean; httpsEnabled: boolean;
swag: boolean;
} }
export default class ServerLaunchSection extends React.Component<IProps, IState> { export default class ServerLaunchSection extends React.Component<IProps, IState> {
@@ -45,11 +49,13 @@ export default class ServerLaunchSection extends React.Component<IProps, IState>
portPlaceholder: '', portPlaceholder: '',
portHelpText: '', portHelpText: '',
httpsLabel: '', httpsLabel: '',
httpsEnabled: false httpsEnabled: false,
swag: false
} }
this.toggleGrasscutter = this.toggleGrasscutter.bind(this) this.toggleGrasscutter = this.toggleGrasscutter.bind(this)
this.playGame = this.playGame.bind(this) this.playGame = this.playGame.bind(this)
this.launchAkebi = this.launchAkebi.bind(this)
this.setIp = this.setIp.bind(this) this.setIp = this.setIp.bind(this)
this.setPort = this.setPort.bind(this) this.setPort = this.setPort.bind(this)
this.toggleHttps = this.toggleHttps.bind(this) this.toggleHttps = this.toggleHttps.bind(this)
@@ -69,6 +75,7 @@ export default class ServerLaunchSection extends React.Component<IProps, IState>
portHelpText: await translate('help.port_help_text'), portHelpText: await translate('help.port_help_text'),
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
}) })
} }
@@ -85,7 +92,7 @@ export default class ServerLaunchSection extends React.Component<IProps, IState>
await saveConfig(config) await saveConfig(config)
} }
async playGame() { async playGame(exe?: string, proc_name?: string) {
const config = await getConfig() const config = await getConfig()
if (!config.game_install_path) return alert('Game path not set!') if (!config.game_install_path) return alert('Game path not set!')
@@ -107,7 +114,7 @@ export default class ServerLaunchSection extends React.Component<IProps, IState>
// Set IP // Set IP
await invoke('set_proxy_addr', { addr: (this.state.httpsEnabled ? 'https':'http') + '://' + this.state.ip + ':' + this.state.port }) await invoke('set_proxy_addr', { addr: (this.state.httpsEnabled ? 'https':'http') + '://' + this.state.ip + ':' + this.state.port })
await invoke('enable_process_watcher', { await invoke('enable_process_watcher', {
process: game_exe process: proc_name || game_exe
}) })
// Connect to proxy // Connect to proxy
@@ -133,11 +140,11 @@ export default class ServerLaunchSection extends React.Component<IProps, IState>
// Launch the program // Launch the program
const gameExists = await invoke('dir_exists', { const gameExists = await invoke('dir_exists', {
path: config.game_install_path path: exe || config.game_install_path
}) })
if (gameExists) await invoke('run_program', { path: config.game_install_path }) if (gameExists) await invoke('run_program', { path: exe || config.game_install_path })
else alert('Game not found! At: ' + config.game_install_path) else alert('Game not found! At: ' + (exe || config.game_install_path))
} }
async launchServer() { async launchServer() {
@@ -161,6 +168,16 @@ export default class ServerLaunchSection extends React.Component<IProps, IState>
}) })
} }
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.playGame(config.akebi_path, gameExec)
}
setIp(text: string) { setIp(text: string) {
this.setState({ this.setState({
ip: text ip: text
@@ -211,6 +228,13 @@ export default class ServerLaunchSection extends React.Component<IProps, IState>
<div className="ServerLaunchButtons" id="serverLaunchContainer"> <div className="ServerLaunchButtons" id="serverLaunchContainer">
<BigButton onClick={this.playGame} id="officialPlay">{this.state.buttonLabel}</BigButton> <BigButton onClick={this.playGame} id="officialPlay">{this.state.buttonLabel}</BigButton>
{
this.state.swag && (
<BigButton onClick={this.launchAkebi} id="akebiLaunch">
<img className="AkebiIcon" id="akebiIcon" src={Akebi} />
</BigButton>
)
}
<BigButton onClick={this.launchServer} id="serverLaunch"> <BigButton onClick={this.launchServer} id="serverLaunch">
<img className="ServerIcon" id="serverLaunchIcon" src={Server} /> <img className="ServerIcon" id="serverLaunchIcon" src={Server} />
</BigButton> </BigButton>