working theming

This commit is contained in:
SpikeHD
2022-06-02 19:03:32 -07:00
parent e3aade7955
commit 8d8b617198
7 changed files with 144 additions and 16 deletions

View File

@@ -18,9 +18,10 @@ import Game from './components/menu/Game'
import RightBar from './components/RightBar'
import { getConfigOption, setConfigOption } from '../utils/configuration'
import { invoke } from '@tauri-apps/api'
import { dataDir } from '@tauri-apps/api/path'
import { appDir, dataDir } from '@tauri-apps/api/path'
import { appWindow } from '@tauri-apps/api/window'
import { convertFileSrc } from '@tauri-apps/api/tauri'
import { getTheme, loadTheme } from '../utils/themes'
interface IProps {
[key: string]: never;
@@ -82,6 +83,13 @@ class App extends React.Component<IProps, IState> {
const game_path = game_exe.substring(0, game_exe.replace(/\\/g, '/').lastIndexOf('/'))
const root_path = game_path.substring(0, game_path.replace(/\\/g, '/').lastIndexOf('/'))
// Load a theme if it exists
const theme = await getConfigOption('theme')
if (theme) {
const themeObj = await getTheme(theme)
loadTheme(themeObj, document)
}
if(!custom_bg || !/png|jpg|jpeg$/.test(custom_bg)) {
if(game_path) {
// Get the bg by invoking, then set the background to that bg.