visuals for enabling/disableing

This commit is contained in:
SpikeHD
2022-07-25 19:23:05 -07:00
parent 95282a3f36
commit 9fa3351747
7 changed files with 67 additions and 17 deletions

View File

@@ -5,7 +5,6 @@ use std::fs::read_dir;
use std::io::Read; use std::io::Read;
use std::path::PathBuf; use std::path::PathBuf;
static API_URL: &str = "https://api.gamebanana.com";
static SITE_URL: &str = "https://gamebanana.com"; static SITE_URL: &str = "https://gamebanana.com";
#[tauri::command] #[tauri::command]

View File

@@ -10,6 +10,7 @@ import { ModList } from './components/mods/ModList'
import TopBar from './components/TopBar' import TopBar from './components/TopBar'
import './Mods.css' import './Mods.css'
import Back from '../resources/icons/back.svg'
interface IProps { interface IProps {
downloadHandler: DownloadHandler downloadHandler: DownloadHandler
@@ -85,7 +86,19 @@ export class Mods extends React.Component<IProps, IState> {
render() { render() {
return ( return (
<div className="Mods"> <div className="Mods">
<TopBar /> <TopBar>
<div
id="backbtn"
className="TopButton"
onClick={() => {
// Create and dispatch a custom "openMods" event
const event = new CustomEvent('changePage', { detail: 'main' })
window.dispatchEvent(event)
}}
>
<img src={Back} alt="back" />
</div>
</TopBar>
<div className="TopDownloads"> <div className="TopDownloads">
<ProgressBar downloadManager={this.props.downloadHandler} /> <ProgressBar downloadManager={this.props.downloadHandler} />

View File

@@ -9,7 +9,7 @@ import closeIcon from '../../resources/icons/close.svg'
import minIcon from '../../resources/icons/min.svg' import minIcon from '../../resources/icons/min.svg'
interface IProps { interface IProps {
children?: React.ReactNode[] children?: React.ReactNode | React.ReactNode[]
} }
interface IState { interface IState {

View File

@@ -16,7 +16,7 @@
} }
.CheckboxDisplay img { .CheckboxDisplay img {
height: 100%; height: 100% !important;
filter: invert(99%) sepia(0%) saturate(1188%) hue-rotate(186deg) brightness(97%) contrast(67%); filter: invert(99%) sepia(0%) saturate(1188%) hue-rotate(186deg) brightness(97%) contrast(67%);
} }

View File

@@ -7,7 +7,7 @@ interface IProps {
label?: string label?: string
checked: boolean checked: boolean
onChange: () => void onChange: () => void
id: string id?: string
} }
interface IState { interface IState {
@@ -35,6 +35,7 @@ export default class Checkbox extends React.Component<IProps, IState> {
handleChange = () => { handleChange = () => {
this.setState({ checked: !this.state.checked }) this.setState({ checked: !this.state.checked })
console.log(this.props.onChange)
this.props.onChange() this.props.onChange()
} }

View File

@@ -36,13 +36,30 @@
padding: 0 0 0 10px; padding: 0 0 0 10px;
} }
.ModTileOpen {
display: flex;
flex-direction: row;
align-items: center;
justify-content: center;
}
.Checkbox {
filter: invert(100%) sepia(2%) saturate(201%) hue-rotate(47deg) brightness(117%) contrast(100%);
}
.ModTileOpen .ModTileFolder {
width: 40px !important;
height: 40px !important;
margin: 20px;
}
.ModTileOpen, .ModTileOpen,
.ModTileDownload { .ModTileDownload {
position: absolute; position: absolute;
object-fit: contain; object-fit: contain;
left: 37.5%; left: 37.5%;
top: 40%; top: 45%;
z-index: 999; z-index: 999;
@@ -61,7 +78,7 @@
justify-content: center; justify-content: center;
} }
.ModImage img { .ModImage .ModImageInner {
object-fit: cover; object-fit: cover;
width: 100%; width: 100%;
height: 150px; height: 150px;

View File

@@ -7,6 +7,7 @@ import Eye from '../../../resources/icons/eye.svg'
import Download from '../../../resources/icons/download.svg' import Download from '../../../resources/icons/download.svg'
import Folder from '../../../resources/icons/folder.svg' import Folder from '../../../resources/icons/folder.svg'
import { shell } from '@tauri-apps/api' import { shell } from '@tauri-apps/api'
import Checkbox from '../common/Checkbox'
interface IProps { interface IProps {
mod: ModData | PartialModData mod: ModData | PartialModData
@@ -16,6 +17,7 @@ interface IProps {
interface IState { interface IState {
hover: boolean hover: boolean
modEnabled: boolean
} }
export class ModTile extends React.Component<IProps, IState> { export class ModTile extends React.Component<IProps, IState> {
@@ -23,14 +25,25 @@ export class ModTile extends React.Component<IProps, IState> {
super(props) super(props)
this.state = { this.state = {
hover: false, hover: true,
modEnabled: false,
} }
this.openInExplorer = this.openInExplorer.bind(this)
this.toggleMod = this.toggleMod.bind(this)
} }
async openInExplorer() { async openInExplorer() {
if (this.props.path) shell.open(this.props.path) if (this.props.path) shell.open(this.props.path)
} }
toggleMod() {
console.log('Mod toggled')
this.setState({
modEnabled: !this.state.modEnabled,
})
}
render() { render() {
const { mod } = this.props const { mod } = this.props
@@ -38,14 +51,14 @@ export class ModTile extends React.Component<IProps, IState> {
<div <div
className="ModListItem" className="ModListItem"
onMouseEnter={() => this.setState({ hover: true })} onMouseEnter={() => this.setState({ hover: true })}
onMouseLeave={() => this.setState({ hover: false })} onMouseLeave={() => this.setState({ hover: true })}
onClick={() => { {...(!this.props.path && {
// Disable downloading installed mods onClick: () => {
if (this.props.path) return this.openInExplorer() if (!('id' in mod)) return
if (!('id' in mod)) return
this.props.onClick(mod) this.props.onClick(mod)
}} },
})}
> >
<span className="ModName">{mod.name}</span> <span className="ModName">{mod.name}</span>
<span className="ModAuthor">{mod.submitter.name}</span> <span className="ModAuthor">{mod.submitter.name}</span>
@@ -54,11 +67,18 @@ export class ModTile extends React.Component<IProps, IState> {
(!this.props.path ? ( (!this.props.path ? (
<img src={Download} className="ModTileDownload" alt="Download" /> <img src={Download} className="ModTileDownload" alt="Download" />
) : ( ) : (
<img src={Folder} className="ModTileOpen" alt="Open" /> <div className="ModTileOpen">
<img src={Folder} className="ModTileFolder" alt="Open" onClick={this.openInExplorer} />
<Checkbox
checked={/* TODO GET INSTALL STATUS */ this.state.modEnabled}
id={this.props.mod.name}
onChange={this.toggleMod}
/>
</div>
))} ))}
<img <img
src={mod.images[0]} src={mod.images[0]}
className={`${'id' in mod && mod.nsfw ? 'nsfw' : ''} ${this.state.hover ? 'blur' : ''}`} className={`ModImageInner ${'id' in mod && mod.nsfw ? 'nsfw' : ''} ${this.state.hover ? 'blur' : ''}`}
/> />
</div> </div>
<div className="ModInner"> <div className="ModInner">