help button explaining Game Rules

world_overviews
joneugster 1 year ago
parent 63a0d8d5f0
commit 06aa5d5339

@ -14,7 +14,8 @@ import { Button } from './button'
import { MobileContext } from './infoview/context'
import { InventoryPanel } from './inventory'
import Markdown from './markdown'
import {PrivacyPolicyPopup} from './privacy_policy'
import { PrivacyPolicyPopup } from './privacy_policy'
import { RulesHelpPopup } from './popup/rules_help'
import { WorldTreePanel, downloadFile } from './world_tree'
import './welcome.css'
@ -182,8 +183,11 @@ function Welcome() {
// impressum pop-up
const [impressum, setImpressum] = React.useState(false)
const [rulesHelp, setRulesHelp] = React.useState(false)
function closeImpressum() {setImpressum(false)}
function toggleImpressum() {setImpressum(!impressum)}
function closeRulesHelp() {setRulesHelp(false)}
const [info, setInfo] = React.useState(false)
function closeInfo() {setInfo(false)}
@ -219,7 +223,7 @@ function Welcome() {
{(pageNumber == 0 ?
<IntroductionPanel introduction={gameInfo.data?.introduction} />
: pageNumber == 1 ?
<WorldTreePanel worlds={gameInfo.data?.worlds} worldSize={gameInfo.data?.worldSize} />
<WorldTreePanel worlds={gameInfo.data?.worlds} worldSize={gameInfo.data?.worldSize} rulesHelp={rulesHelp} setRulesHelp={setRulesHelp} />
:
<InventoryPanel levelInfo={inventory?.data} />
)}
@ -227,12 +231,13 @@ function Welcome() {
:
<Split className="welcome" minSize={0} snapOffset={200} sizes={[25, 50, 25]}>
<IntroductionPanel introduction={gameInfo.data?.introduction} />
<WorldTreePanel worlds={gameInfo.data?.worlds} worldSize={gameInfo.data?.worldSize} />
<WorldTreePanel worlds={gameInfo.data?.worlds} worldSize={gameInfo.data?.worldSize} rulesHelp={rulesHelp} setRulesHelp={setRulesHelp} />
<InventoryPanel levelInfo={inventory?.data} />
</Split>
}
</div>
{impressum ? <PrivacyPolicyPopup handleClose={closeImpressum} /> : null}
{rulesHelp ? <RulesHelpPopup handleClose={closeRulesHelp} /> : null}
{eraseMenu? <ErasePopup handleClose={closeEraseMenu}/> : null}
{uploadMenu? <UploadPopup handleClose={closeUploadMenu}/> : null}
{info ? <InfoPopup info={gameInfo.data?.info} handleClose={closeInfo}/> : null}

@ -49,7 +49,6 @@ svg .disabled {
}
.world-selection-menu {
padding: .5em 1em;
position: absolute;
right: 1em;
top: 1em;
@ -75,7 +74,7 @@ svg .disabled {
/* width: 100%; */
height: 7em;
/* min-width: 16em; */
padding-bottom: .8em;
padding: .5em 1em 1.3em 1em;
margin-left: auto;
margin-right: auto;
}
@ -109,3 +108,10 @@ svg .disabled {
padding: .2em;
border-radius: .5em;
}
.world-selection-menu .helpButton {
position: absolute;
right: .5em;
top: .5em;
color: var(--clr-primary);
}

@ -8,7 +8,7 @@ import { Slider } from '@mui/material'
import cytoscape, { LayoutOptions } from 'cytoscape'
import klay from 'cytoscape-klay'
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
import { faDownload, faUpload, faEraser, faGlobe, faArrowLeft } from '@fortawesome/free-solid-svg-icons'
import { faDownload, faUpload, faEraser, faGlobe, faArrowLeft, faXmark, faCircleQuestion } from '@fortawesome/free-solid-svg-icons'
import { GameIdContext } from '../app'
import { useAppDispatch } from '../hooks'
@ -195,7 +195,7 @@ export const downloadFile = ({ data, fileName, fileType } :
}
/** The menu that is shown next to the world selection graph */
export function WorldSelectionMenu() {
export function WorldSelectionMenu({rulesHelp, setRulesHelp}) {
const gameId = React.useContext(GameIdContext)
const difficulty = useSelector(selectDifficulty(gameId))
const dispatch = useAppDispatch()
@ -204,12 +204,15 @@ export function WorldSelectionMenu() {
return x == 0 ? 'none' : x == 1 ? 'relaxed' : 'regular'
}
return <nav className="world-selection-menu">
<div className="slider-wrap">
<span className="difficulty-label">Game Rules</span>
<span className="difficulty-label">Rules
<FontAwesomeIcon icon={rulesHelp ? faXmark : faCircleQuestion} className='helpButton' onClick={() => (setRulesHelp(!rulesHelp))}/>
</span>
<Slider
orientation="vertical"
title="Game Rules:&#10;- regular: 🔐 levels, 🔐 tactics&#10;- relaxed: 🔓 levels, 🔐 tactics&#10;- none: 🔓 levels, 🔓 tactics"
title="Game Rules"
min={0} max={2}
aria-label="Game Rules"
defaultValue={difficulty}
@ -264,9 +267,12 @@ export function computeWorldLayout(worlds) {
}
export function WorldTreePanel({worlds, worldSize}:
export function WorldTreePanel({worlds, worldSize, rulesHelp, setRulesHelp}:
{ worlds: any,
worldSize: any}) {
worldSize: any,
rulesHelp: boolean,
setRulesHelp: any,
}) {
const gameId = React.useContext(GameIdContext)
const difficulty = useSelector(selectDifficulty(gameId))
const {nodes, bounds}: any = worlds ? computeWorldLayout(worlds) : {nodes: []}
@ -350,7 +356,7 @@ export function WorldTreePanel({worlds, worldSize}:
let dx = bounds ? s*(bounds.x2 - bounds.x1) + 2*padding : null
return <div className="column">
<WorldSelectionMenu />
<WorldSelectionMenu rulesHelp={rulesHelp} setRulesHelp={setRulesHelp} />
<svg xmlns="http://www.w3.org/2000/svg" xmlnsXlink="http://www.w3.org/1999/xlink"
width={bounds ? `${ds * dx}` : ''}
viewBox={bounds ? `${s*bounds.x1 - padding} ${s*bounds.y1 - padding} ${dx} ${s*(bounds.y2 - bounds.y1) + 2 * padding}` : ''}

Loading…
Cancel
Save