mirror of
https://github.com/Grasscutters/Cultivation.git
synced 2025-12-14 16:14:48 +01:00
cleanup
This commit is contained in:
@@ -1,45 +1,23 @@
|
|||||||
import React from 'react'
|
import React from 'react'
|
||||||
import { invoke } from '@tauri-apps/api/tauri'
|
|
||||||
import './App.css'
|
import './App.css'
|
||||||
import './custom.css'
|
import './custom.css'
|
||||||
|
|
||||||
/* FOR TESTING */
|
/* FOR TESTING */
|
||||||
import DownloadHandler from '../utils/download'
|
import DownloadHandler from '../utils/download'
|
||||||
|
|
||||||
// Config
|
|
||||||
import { getConfig, saveConfig } from '../utils/configuration'
|
|
||||||
|
|
||||||
// Major Components
|
// Major Components
|
||||||
import Topbar from './components/TopBar'
|
import Topbar from './components/TopBar'
|
||||||
import BigButton from './components/common/BigButton'
|
import ServerLaunchSection from './components/ServerLaunchSection'
|
||||||
import Checkbox from './components/common/Checkbox'
|
|
||||||
import ProgressBar from './components/common/ProgressBar'
|
import ProgressBar from './components/common/ProgressBar'
|
||||||
|
|
||||||
const downloadHandler = new DownloadHandler()
|
const downloadHandler = new DownloadHandler()
|
||||||
|
|
||||||
async function playGame() {
|
|
||||||
const config = await getConfig()
|
|
||||||
|
|
||||||
if (!config.game_path) return
|
|
||||||
|
|
||||||
// Launch the program
|
|
||||||
await invoke('run_program', { path: config.game_path })
|
|
||||||
}
|
|
||||||
|
|
||||||
async function download() {
|
async function download() {
|
||||||
const path = 'S:/Cultivation/grassclipper.zip'
|
const path = 'S:/Cultivation/grassclipper.zip'
|
||||||
const url = 'https://github.com/Grasscutters/GrassClipper/releases/download/v0.9.7/GrassClipper.zip'
|
const url = 'https://github.com/Grasscutters/GrassClipper/releases/download/v0.9.7/GrassClipper.zip'
|
||||||
downloadHandler.addDownload(url, path)
|
downloadHandler.addDownload(url, path)
|
||||||
}
|
}
|
||||||
|
|
||||||
async function toggleGrasscutter() {
|
|
||||||
const config = await getConfig()
|
|
||||||
|
|
||||||
config.toggle_grasscutter = !config.toggle_grasscutter
|
|
||||||
|
|
||||||
await saveConfig(config)
|
|
||||||
}
|
|
||||||
|
|
||||||
function App() {
|
function App() {
|
||||||
return (
|
return (
|
||||||
<div className="App">
|
<div className="App">
|
||||||
@@ -47,12 +25,7 @@ function App() {
|
|||||||
|
|
||||||
<button onClick={download}>download file test</button>
|
<button onClick={download}>download file test</button>
|
||||||
|
|
||||||
<div id="playButton">
|
<ServerLaunchSection />
|
||||||
<div id="serverControls">
|
|
||||||
<Checkbox label="Connect via Grasscutter" onChange={toggleGrasscutter} />
|
|
||||||
</div>
|
|
||||||
<BigButton text="PLAY DA GAME :D" onClick={playGame} id="officialPlay" />
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div id="downloadProgress" style={{
|
<div id="downloadProgress" style={{
|
||||||
position: 'absolute',
|
position: 'absolute',
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import React from 'react'
|
|||||||
|
|
||||||
interface IProps {
|
interface IProps {
|
||||||
label: string,
|
label: string,
|
||||||
|
checked: boolean,
|
||||||
onChange: () => void,
|
onChange: () => void,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -14,7 +15,7 @@ export default class Checkbox extends React.Component<IProps, IState> {
|
|||||||
super(props)
|
super(props)
|
||||||
|
|
||||||
this.state = {
|
this.state = {
|
||||||
checked: false
|
checked: props.checked
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -18,4 +18,8 @@
|
|||||||
.InnerProgress {
|
.InnerProgress {
|
||||||
height: 100%;
|
height: 100%;
|
||||||
background-color: #00a8ff;
|
background-color: #00a8ff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ProgressText {
|
||||||
|
color: #fff;
|
||||||
}
|
}
|
||||||
@@ -33,8 +33,6 @@ export default class ProgressBar extends React.Component<IProps, IState> {
|
|||||||
total: prog?.total || 0,
|
total: prog?.total || 0,
|
||||||
})
|
})
|
||||||
|
|
||||||
console.log(prog)
|
|
||||||
|
|
||||||
if (this.state.status === 'finished' /* || this.state.status === 'error' */) {
|
if (this.state.status === 'finished' /* || this.state.status === 'error' */) {
|
||||||
// Ensure progress is 100%
|
// Ensure progress is 100%
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user