Implement semi-working custom backgrounds

This commit is contained in:
KingRainbow44 2022-06-01 17:28:07 -04:00
parent 2d77d74d3a
commit 2d2cf82751
No known key found for this signature in database
GPG Key ID: FC2CB64B00D257BE
2 changed files with 16 additions and 11 deletions

View File

@ -27,11 +27,11 @@ select:focus {
}
.App {
/*background: url("https://webstatic.hoyoverse.com/upload/event/2020/11/04/7fd661b5184e1734f91f628b6f89a31f_7367318474207189623.png") no-repeat center center fixed; */
background-repeat: no-repeat;
background-size: cover;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
.TopButton {

View File

@ -75,21 +75,24 @@ class App extends React.Component<IProps, IState> {
async componentDidMount() {
const cert_generated = await getConfigOption('cert_generated')
const game_exe = await getConfigOption('game_install_path')
const custom_bg = await getConfigOption('customBackground')
const game_path = game_exe.substring(0, game_exe.lastIndexOf('\\'))
const root_path = game_path.substring(0, game_path.lastIndexOf('\\'))
if (game_path) {
// Get the bg by invoking, then set the background to that bg
const bgLoc: string = await invoke('get_bg_file', {
bgPath: root_path,
})
if(!custom_bg) {
if(game_path) {
// Get the bg by invoking, then set the background to that bg.
const bgLoc: string = await invoke('get_bg_file', {
bgPath: root_path
})
if (bgLoc) {
this.setState({
bgLoc && this.setState({
bgFile: bgLoc
})
}
}
} else this.setState({
bgFile: custom_bg
})
if (!cert_generated) {
// Generate the certificate
@ -106,13 +109,15 @@ class App extends React.Component<IProps, IState> {
isDownloading: downloadHandler.getDownloads().filter(d => d.status !== 'finished')?.length > 0
})
}, 1000)
console.log('mounting app component with background: ' + this.state.bgFile)
}
render() {
return (
<div className="App" style={
this.state.bgFile ? {
background: `url(${this.state.bgFile}) no-repeat center center fixed`,
background: `url(${this.state.bgFile} fixed`,
} : {}
}>
<TopBar