94 lines
3.9 KiB
TypeScript
94 lines
3.9 KiB
TypeScript
import { useLocalStorage } from "@/hooks/useLocalStorage"
|
|
import { PREF } from "@/utils/const"
|
|
import ChargedButton from "../ChargedButton";
|
|
import styles from "@/css/Outro.module.css";
|
|
import { ChangeEvent, InputEvent, MouseEvent, MouseEventHandler, PointerEvent, useRef, useState } from "react";
|
|
import Image from "next/image";
|
|
import StyledContainer from "../StyledContainer";
|
|
import OldButton from "../OldButton";
|
|
import OldTextInput from "../OldTextInput";
|
|
import clsx from "clsx";
|
|
|
|
export default function Outro() {
|
|
const [ resultPage, setResultPage ] = useState(0);
|
|
const [ stepStr, setStep ] = useLocalStorage(PREF.step, "0");
|
|
const [ , setPoints ] = useLocalStorage(PREF.points, "0");
|
|
const [ , setPlayers ] = useLocalStorage(PREF.players, "");
|
|
const [ , setWorthyWords ] = useLocalStorage(PREF.worthyWords, "");
|
|
const [ rewatchScreen, setRewatchScreen ] = useState(false);
|
|
const [ videoEnded, setVideoEnded ] = useState(false);
|
|
const [ videoPaused, setVideoPaused ] = useState(false);
|
|
const [ voiceOverState, setVoiceOverState ] = useLocalStorage(PREF.voiceover, "off");
|
|
const [ boughtHintsStr, setBoughtHints ] = useLocalStorage(PREF.boughtHints, "");
|
|
const outroVideoRef = useRef<HTMLVideoElement | null>(null);
|
|
|
|
const handleVideoClick = (e: PointerEvent<HTMLVideoElement>): boolean => {
|
|
e.currentTarget.play();
|
|
return true;
|
|
};
|
|
|
|
const pages = [
|
|
(
|
|
<div className={styles["outro-video-container"]} key={0}>
|
|
<video
|
|
ref={outroVideoRef}
|
|
disablePictureInPicture={true}
|
|
autoPlay={true}
|
|
loop={false}
|
|
autoFocus={true}
|
|
width={"100%"}
|
|
onEnded={() => setVideoEnded(true)}
|
|
onAbort={() => setVideoEnded(true)}
|
|
onError={() => setVideoEnded(true)}
|
|
onPause={() => setVideoPaused(true)}
|
|
onPlay={() => setVideoPaused(false)}
|
|
onClick={handleVideoClick}
|
|
onContextMenu={(e) => {
|
|
e.preventDefault();
|
|
return false;
|
|
}}
|
|
playsInline={true}
|
|
>
|
|
<source src="/res/outro/testoutro.webm" type="video/webm"/>
|
|
</video>
|
|
{ !videoEnded && videoPaused ?
|
|
<div className={styles["pause-screen"]}>
|
|
<Image src="/icons/pause.svg" alt="Pause Icon" width={48} height={48}/>
|
|
</div>
|
|
:
|
|
null
|
|
}
|
|
{ videoEnded ? <div className={styles["rewatch-controls"]}>
|
|
<ChargedButton holdDuration={500} onAction={() => {
|
|
if (outroVideoRef.current) {
|
|
outroVideoRef.current.pause();
|
|
outroVideoRef.current.currentTime = 0;
|
|
outroVideoRef.current.play();
|
|
setVideoEnded(false);
|
|
}
|
|
}} whiteText={true}>Video wiederholen?</ChargedButton>
|
|
<ChargedButton holdDuration={500} onAction={() => {
|
|
setResultPage(1);
|
|
}} whiteText={true}>Ergebnisse ansehen!</ChargedButton>
|
|
</div> : null }
|
|
</div>
|
|
)
|
|
];
|
|
|
|
return (
|
|
<div className="screen-container">
|
|
<img src={"/bg/Hintergrund_ohne_Verzierung.webp"} style={{
|
|
position: "absolute",
|
|
top: 0,
|
|
left: 0,
|
|
width: "100%",
|
|
height: "100%",
|
|
objectFit: "fill",
|
|
zIndex: 1
|
|
}} alt="Background" loading="eager"/>
|
|
<StyledContainer innerClassName={styles["container"]}>
|
|
{pages.length > resultPage && resultPage > -1 ? pages[resultPage] : <p>Invalid Page</p>}
|
|
</StyledContainer>
|
|
</div>
|
|
)
|
|
} |