reshade setting and enabling

This commit is contained in:
SpikeHD
2022-07-26 20:16:20 -07:00
parent c64cdababa
commit 203bd40e8f
5 changed files with 68 additions and 6 deletions

View File

@@ -66,7 +66,11 @@
"resources": "These are also required to run a Grasscutter server. This button will be grey if you have an existing resources folder with contents inside"
},
"swag": {
"akebi_name": "Akebi",
"migoto_name": "Migoto",
"reshade_name": "Reshade",
"akebi": "Set Akebi Executable",
"migoto": "Set 3DMigoto Executable"
"migoto": "Set 3DMigoto Executable",
"reshade": "Set Reshade Injector"
}
}

View File

@@ -19,7 +19,7 @@
.ExtraItem {
width: 80%;
padding: 10px;
padding: 6px;
display: flex;
flex-direction: row;

View File

@@ -17,9 +17,10 @@ interface IProps {
interface IState {
migoto?: string
akebi?: string
reshade?: string
launch_migoto: boolean
launch_akebi: boolean
reshade?: string
launch_reshade: boolean
}
export class ExtrasMenu extends React.Component<IProps, IState> {
@@ -29,11 +30,13 @@ export class ExtrasMenu extends React.Component<IProps, IState> {
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() {
@@ -42,9 +45,10 @@ export class ExtrasMenu extends React.Component<IProps, IState> {
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,
// TODO reshade
launch_reshade: config?.last_extras?.reshade ?? false,
})
}
@@ -54,6 +58,7 @@ export class ExtrasMenu extends React.Component<IProps, IState> {
config.last_extras = {
migoto: this.state.launch_migoto,
akebi: this.state.launch_akebi,
reshade: this.state.launch_reshade,
}
await saveConfig(config)
@@ -63,6 +68,11 @@ export class ExtrasMenu extends React.Component<IProps, IState> {
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()
@@ -93,6 +103,14 @@ export class ExtrasMenu extends React.Component<IProps, IState> {
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_program_relative', { path: config.reshade_path })
}
toggleMigoto() {
this.setState({
launch_migoto: !this.state.launch_migoto,
@@ -105,23 +123,42 @@ export class ExtrasMenu extends React.Component<IProps, IState> {
})
}
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">Migoto</div>
<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">Akebi</div>
<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}>

View File

@@ -38,6 +38,7 @@ interface IState {
// Swag stuff
akebi_path: string
migoto_path: string
reshade_path: string
}
export default class Options extends React.Component<IProps, IState> {
@@ -62,6 +63,7 @@ export default class Options extends React.Component<IProps, IState> {
// Swag stuff
akebi_path: '',
migoto_path: '',
reshade_path: '',
}
this.setGameExecutable = this.setGameExecutable.bind(this)
@@ -104,6 +106,7 @@ 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()
@@ -149,6 +152,14 @@ export default class Options extends React.Component<IProps, IState> {
})
}
setReshade(value: string) {
setConfigOption('reshade_path', value)
this.setState({
reshade_path: value,
})
}
async setLanguage(value: string) {
await setConfigOption('language', value)
window.location.reload()
@@ -331,6 +342,14 @@ export default class Options extends React.Component<IProps, IState> {
<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>
</>
)}

View File

@@ -51,9 +51,11 @@ export interface Configuration {
// Swag stuff
akebi_path?: string
migoto_path?: string
reshade_path?: string
last_extras?: {
migoto: boolean
akebi: boolean
reshade: boolean
}
}