PlayerCount

This commit is contained in:
LionTion committed 2026-09-17 21:47:29 +02:00
1 parent dfe4ab50f3
commit 9401ef3a9e
5 files changed
+77 -10

No files matched your search

+7
View File
@@ -91,3 +91,10 @@ a {
width: 100%;
height: 100dvh;
}
.flex-center {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
+3 -3
View File
@@ -3,6 +3,7 @@ import { ChangeEventHandler, CSSProperties } from "react";
import styles from "@/css/OldTextInput.module.css";
interface OldTextInput {
type?: string;
value?: string;
onChange?: ChangeEventHandler<HTMLInputElement, HTMLInputElement>;
ariaLabel?: string;
@@ -13,6 +14,7 @@ interface OldTextInput {
};
export default function OldTextInput({
type = "text",
value,
onChange,
ariaLabel,
@@ -22,9 +24,8 @@ export default function OldTextInput({
disabled = false,
}: OldTextInput) {
return (
<label>
<input
type="text"
type={type}
className={clsx(styles["input"], "lancelot-regular", className, disabled && styles["input-disabled"])}
value={value}
onChange={onChange}
@@ -32,6 +33,5 @@ export default function OldTextInput({
placeholder={placeholder}
style={style}
/>
</label>
);
}
+61 -7
View File
@@ -3,21 +3,33 @@ import { PREF } from "@/utils/const"
import ChargedButton from "../ChargedButton";
import { usePermissions } from "@/hooks/usePermission";
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 PermissionCheck from "../PermissionCheck";
import { PermissionStateResult } from "@/utils/permissions";
import StyledContainer from "../StyledContainer";
import OldButton from "../OldButton";
import OldTextInput from "../OldTextInput";
const MIN_PLAYERS = 2;
const MAX_PLAYERS = 8;
export default function Intro() {
const [ stepStr, setStep ] = useLocalStorage(PREF.step, "0");
const [ rewatchScreen, setRewatchScreen ] = useState(false);
const [ enterPlayerCount, setEnterPlayerCount ] = useState(false);
const [ videoEnded, setVideoEnded ] = useState(false);
const [ videoPaused, setVideoPaused ] = useState(false);
const introVideoRef = useRef<HTMLVideoElement | null>(null);
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 => {
e.currentTarget.play();
return true;
@@ -27,6 +39,22 @@ export default function Intro() {
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 (
<div className="screen-container">
<img src={"/bg/Hintergrund_ohne_Verzierung.webp"} style={{
@@ -39,15 +67,41 @@ export default function Intro() {
zIndex: 1
}} alt="Background" loading="eager"/>
<StyledContainer innerClassName={styles["permission-container"]}>
{ !rewatchScreen ?
{ !enterPlayerCount || !granted ?
<div>
<PermissionCheck onRefresh={handlePermissions}></PermissionCheck>
<OldButton red={false} long={true} style={{margin: "auto", marginTop: "3rem"}}>WEITER</OldButton>
{ false && <ChargedButton onAction={() => {
<OldButton
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);
}} holdDuration={500} disabled={!granted}>
Halten, um das Video ansehen
</ChargedButton> }
}} holdDuration={500} disabled={!validPlayerCount(Number.parseInt(playerCountStr))}>
Halten, um das Video anzusehen!
</ChargedButton>
</div>
:
<div className={styles["intro-video-container"]}>
+5
View File
@@ -69,6 +69,11 @@ export default function Tour() {
}} holdDuration={500}>
Zurücksetzen
</ChargedButton>
<ChargedButton onAction={() => {
}} holdDuration={500}>
Test
</ChargedButton>
</div>
<div className={styles["main-content"]}>
<div className={styles["map"]}>
+1
View File
@@ -4,4 +4,5 @@ export enum PREF {
players = "PREF_PLAYERS",
completed_riddles = "PREF_COMPLETED_RIDDLES",
step = "PREF_APP_SCREEN_STEP",
playerCount = "PREF_PLAYER_COUNT",
};