PlayerCount
This commit is contained in:
1 parent
dfe4ab50f3
commit
9401ef3a9e
5 files changed
+85
-18
No files matched your search
@@ -91,3 +91,10 @@ a {
|
|||||||
width: 100%;
|
width: 100%;
|
||||||
height: 100dvh;
|
height: 100dvh;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.flex-center {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
@@ -3,6 +3,7 @@ import { ChangeEventHandler, CSSProperties } from "react";
|
|||||||
import styles from "@/css/OldTextInput.module.css";
|
import styles from "@/css/OldTextInput.module.css";
|
||||||
|
|
||||||
interface OldTextInput {
|
interface OldTextInput {
|
||||||
|
type?: string;
|
||||||
value?: string;
|
value?: string;
|
||||||
onChange?: ChangeEventHandler<HTMLInputElement, HTMLInputElement>;
|
onChange?: ChangeEventHandler<HTMLInputElement, HTMLInputElement>;
|
||||||
ariaLabel?: string;
|
ariaLabel?: string;
|
||||||
@@ -13,6 +14,7 @@ interface OldTextInput {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export default function OldTextInput({
|
export default function OldTextInput({
|
||||||
|
type = "text",
|
||||||
value,
|
value,
|
||||||
onChange,
|
onChange,
|
||||||
ariaLabel,
|
ariaLabel,
|
||||||
@@ -22,16 +24,14 @@ export default function OldTextInput({
|
|||||||
disabled = false,
|
disabled = false,
|
||||||
}: OldTextInput) {
|
}: OldTextInput) {
|
||||||
return (
|
return (
|
||||||
<label>
|
<input
|
||||||
<input
|
type={type}
|
||||||
type="text"
|
className={clsx(styles["input"], "lancelot-regular", className, disabled && styles["input-disabled"])}
|
||||||
className={clsx(styles["input"], "lancelot-regular", className, disabled && styles["input-disabled"])}
|
value={value}
|
||||||
value={value}
|
onChange={onChange}
|
||||||
onChange={onChange}
|
aria-label={ariaLabel}
|
||||||
aria-label={ariaLabel}
|
placeholder={placeholder}
|
||||||
placeholder={placeholder}
|
style={style}
|
||||||
style={style}
|
/>
|
||||||
/>
|
|
||||||
</label>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -3,21 +3,33 @@ import { PREF } from "@/utils/const"
|
|||||||
import ChargedButton from "../ChargedButton";
|
import ChargedButton from "../ChargedButton";
|
||||||
import { usePermissions } from "@/hooks/usePermission";
|
import { usePermissions } from "@/hooks/usePermission";
|
||||||
import styles from "@/css/Intro.module.css";
|
import styles from "@/css/Intro.module.css";
|
||||||
import { InputEvent, MouseEvent, MouseEventHandler, PointerEvent, useRef, useState } from "react";
|
import { ChangeEvent, InputEvent, MouseEvent, MouseEventHandler, PointerEvent, useRef, useState } from "react";
|
||||||
import Image from "next/image";
|
import Image from "next/image";
|
||||||
import PermissionCheck from "../PermissionCheck";
|
import PermissionCheck from "../PermissionCheck";
|
||||||
import { PermissionStateResult } from "@/utils/permissions";
|
import { PermissionStateResult } from "@/utils/permissions";
|
||||||
import StyledContainer from "../StyledContainer";
|
import StyledContainer from "../StyledContainer";
|
||||||
import OldButton from "../OldButton";
|
import OldButton from "../OldButton";
|
||||||
|
import OldTextInput from "../OldTextInput";
|
||||||
|
|
||||||
|
const MIN_PLAYERS = 2;
|
||||||
|
const MAX_PLAYERS = 8;
|
||||||
|
|
||||||
export default function Intro() {
|
export default function Intro() {
|
||||||
const [ stepStr, setStep ] = useLocalStorage(PREF.step, "0");
|
const [ stepStr, setStep ] = useLocalStorage(PREF.step, "0");
|
||||||
const [ rewatchScreen, setRewatchScreen ] = useState(false);
|
const [ rewatchScreen, setRewatchScreen ] = useState(false);
|
||||||
|
const [ enterPlayerCount, setEnterPlayerCount ] = useState(false);
|
||||||
const [ videoEnded, setVideoEnded ] = useState(false);
|
const [ videoEnded, setVideoEnded ] = useState(false);
|
||||||
const [ videoPaused, setVideoPaused ] = useState(false);
|
const [ videoPaused, setVideoPaused ] = useState(false);
|
||||||
const introVideoRef = useRef<HTMLVideoElement | null>(null);
|
const introVideoRef = useRef<HTMLVideoElement | null>(null);
|
||||||
const [ granted, setGranted ] = useState(false);
|
const [ granted, setGranted ] = useState(false);
|
||||||
|
|
||||||
|
const [ , setPlayerCount ] = useLocalStorage(PREF.playerCount, "");
|
||||||
|
const [ playerCountStr, setPlayerCountStr] = useState("");
|
||||||
|
|
||||||
|
const validPlayerCount = (number: number) => {
|
||||||
|
return !isNaN(number) && (number <= MAX_PLAYERS && number >= MIN_PLAYERS);
|
||||||
|
};
|
||||||
|
|
||||||
const handleVideoClick = (e: PointerEvent<HTMLVideoElement>): boolean => {
|
const handleVideoClick = (e: PointerEvent<HTMLVideoElement>): boolean => {
|
||||||
e.currentTarget.play();
|
e.currentTarget.play();
|
||||||
return true;
|
return true;
|
||||||
@@ -27,6 +39,22 @@ export default function Intro() {
|
|||||||
setGranted(gps === "granted" && cam === "granted");
|
setGranted(gps === "granted" && cam === "granted");
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleChange = (event: ChangeEvent<HTMLInputElement>): boolean => {
|
||||||
|
const value = event.target.value;
|
||||||
|
let parsedValue = Number.parseInt(value);
|
||||||
|
|
||||||
|
if (isNaN(parsedValue)) {
|
||||||
|
if (value.length > 0) {
|
||||||
|
event.preventDefault();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
parsedValue = Math.min(MAX_PLAYERS, Math.max(MIN_PLAYERS, parsedValue));
|
||||||
|
|
||||||
|
setPlayerCountStr(parsedValue.toString());
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="screen-container">
|
<div className="screen-container">
|
||||||
<img src={"/bg/Hintergrund_ohne_Verzierung.webp"} style={{
|
<img src={"/bg/Hintergrund_ohne_Verzierung.webp"} style={{
|
||||||
@@ -39,15 +67,41 @@ export default function Intro() {
|
|||||||
zIndex: 1
|
zIndex: 1
|
||||||
}} alt="Background" loading="eager"/>
|
}} alt="Background" loading="eager"/>
|
||||||
<StyledContainer innerClassName={styles["permission-container"]}>
|
<StyledContainer innerClassName={styles["permission-container"]}>
|
||||||
{ !rewatchScreen ?
|
{ !enterPlayerCount || !granted ?
|
||||||
<div>
|
<div>
|
||||||
<PermissionCheck onRefresh={handlePermissions}></PermissionCheck>
|
<PermissionCheck onRefresh={handlePermissions}></PermissionCheck>
|
||||||
<OldButton red={false} long={true} style={{margin: "auto", marginTop: "3rem"}}>WEITER</OldButton>
|
<OldButton
|
||||||
{ false && <ChargedButton onAction={() => {
|
red={false}
|
||||||
|
long={true}
|
||||||
|
onAction={() => {
|
||||||
|
setRewatchScreen(false);
|
||||||
|
setEnterPlayerCount(true);
|
||||||
|
}}
|
||||||
|
style={{margin: "auto", marginTop: "3rem"}}
|
||||||
|
disabled={!granted}
|
||||||
|
>WEITER</OldButton>
|
||||||
|
</div>
|
||||||
|
: !rewatchScreen ?
|
||||||
|
<div className="flex-center">
|
||||||
|
<p style={{color: "var(--blue)", fontSize: "2rem"}} className="eisenkraft-regular">Spieleranzahl</p>
|
||||||
|
<p>Wie viele Abenteurer seid ihr?</p>
|
||||||
|
<OldTextInput
|
||||||
|
type="number"
|
||||||
|
value={playerCountStr}
|
||||||
|
onChange={handleChange}
|
||||||
|
aria-label="Spieleranzahl"
|
||||||
|
placeholder=""
|
||||||
|
style={{
|
||||||
|
width: "200px",
|
||||||
|
textAlign: "center",
|
||||||
|
}}/>
|
||||||
|
<br></br>
|
||||||
|
<ChargedButton onAction={() => {
|
||||||
|
setPlayerCount(playerCountStr);
|
||||||
setRewatchScreen(true);
|
setRewatchScreen(true);
|
||||||
}} holdDuration={500} disabled={!granted}>
|
}} holdDuration={500} disabled={!validPlayerCount(Number.parseInt(playerCountStr))}>
|
||||||
Halten, um das Video ansehen
|
Halten, um das Video anzusehen!
|
||||||
</ChargedButton> }
|
</ChargedButton>
|
||||||
</div>
|
</div>
|
||||||
:
|
:
|
||||||
<div className={styles["intro-video-container"]}>
|
<div className={styles["intro-video-container"]}>
|
||||||
|
|||||||
@@ -69,6 +69,11 @@ export default function Tour() {
|
|||||||
}} holdDuration={500}>
|
}} holdDuration={500}>
|
||||||
Zurücksetzen
|
Zurücksetzen
|
||||||
</ChargedButton>
|
</ChargedButton>
|
||||||
|
<ChargedButton onAction={() => {
|
||||||
|
|
||||||
|
}} holdDuration={500}>
|
||||||
|
Test
|
||||||
|
</ChargedButton>
|
||||||
</div>
|
</div>
|
||||||
<div className={styles["main-content"]}>
|
<div className={styles["main-content"]}>
|
||||||
<div className={styles["map"]}>
|
<div className={styles["map"]}>
|
||||||
|
|||||||
@@ -4,4 +4,5 @@ export enum PREF {
|
|||||||
players = "PREF_PLAYERS",
|
players = "PREF_PLAYERS",
|
||||||
completed_riddles = "PREF_COMPLETED_RIDDLES",
|
completed_riddles = "PREF_COMPLETED_RIDDLES",
|
||||||
step = "PREF_APP_SCREEN_STEP",
|
step = "PREF_APP_SCREEN_STEP",
|
||||||
|
playerCount = "PREF_PLAYER_COUNT",
|
||||||
};
|
};
|
||||||
Reference in new issue
Block a user