import React from 'react' import { app } from '@tauri-apps/api' import { appWindow } from '@tauri-apps/api/window' import closeIcon from '../../resources/icons/close.svg' import minIcon from '../../resources/icons/min.svg' import cogBtn from '../../resources/icons/cog.svg' import downBtn from '../../resources/icons/download.svg' import Tr from '../../utils/language' import './TopBar.css' import { getConfig, setConfigOption } from '../../utils/configuration' interface IProps { optFunc: () => void downFunc: () => void gameFunc: () => void modFunc: () => void } interface IState { version: string clicks: number intv: NodeJS.Timeout | null } export default class TopBar extends React.Component { constructor(props: IProps) { super(props) this.state = { version: '0.0.0', clicks: 0, intv: null, } this.activateClick = this.activateClick.bind(this) } async componentDidMount() { const version = await app.getVersion() this.setState({ version }) } handleClose() { appWindow.close() } handleMinimize() { appWindow.minimize() } async activateClick() { const config = await getConfig() // They already got it, no need to reactivate if (config.swag_mode) return if (this.state.clicks === 2) { setTimeout(() => { // Gotta clear it so it goes back to regular colors this.setState({ clicks: 0, }) }, 600) // Activate... SWAG MODE await setConfigOption('swag_mode', true) // Reload the window window.location.reload() return } if (this.state.clicks < 3) { this.setState({ clicks: this.state.clicks + 1, intv: setTimeout(() => this.setState({ clicks: 0 }), 1500), }) return } } render() { return (
{this.state?.version}
{/** * HEY YOU * * If you're looking at the source code to find the swag mode thing, that's okay! If you're not, move along... * Just do me a favor and don't go telling everyone about how you found it. If you are just helping someone who * for some reason needs it, that's fine, but not EVERYONE needs it, which is why it exists in the first place. */}
?
close
minimize
settings
downloads
MODS
{/*
game
*/}
) } }