Working stuff!
This commit is contained in:
1 parent
9d69d13aa5
commit
5b73127836
9 files changed
+161
-31
No files matched your search
Binary file not shown.
@@ -19,17 +19,6 @@ export default function Main() {
|
|||||||
const [ players, setPlayers ] = useLocalStorage(PREF.players, "");
|
const [ players, setPlayers ] = useLocalStorage(PREF.players, "");
|
||||||
const [ tourCode, setTourCode ] = useLocalStorage(PREF.code, "");
|
const [ tourCode, setTourCode ] = useLocalStorage(PREF.code, "");
|
||||||
const step = Number.parseInt(stepStr) || 0;
|
const step = Number.parseInt(stepStr) || 0;
|
||||||
/*const [doTest, setDoTest] = useState(false);
|
|
||||||
<ChargedButton
|
|
||||||
onAction={() => {
|
|
||||||
console.log("Click!");
|
|
||||||
}}
|
|
||||||
holdDuration={2000}
|
|
||||||
>Hello</ChargedButton>
|
|
||||||
<button onClick={() => {
|
|
||||||
setDoTest(true);
|
|
||||||
}}>test</button>
|
|
||||||
{doTest && <MapView></MapView>}*/
|
|
||||||
|
|
||||||
console.log("STEP", step);
|
console.log("STEP", step);
|
||||||
console.log("PLAYERS", players, parsePlayerData(players));
|
console.log("PLAYERS", players, parsePlayerData(players));
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ export default function ChargedButton({
|
|||||||
children,
|
children,
|
||||||
style,
|
style,
|
||||||
className,
|
className,
|
||||||
holdDuration = 1000,
|
holdDuration = 500,
|
||||||
onAction,
|
onAction,
|
||||||
disabled = false,
|
disabled = false,
|
||||||
}: ChargedButtonProps) {
|
}: ChargedButtonProps) {
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ const TILE_CACHE_NAME = 'excalibur-offline-map-tiles-v1';
|
|||||||
const DEFAULT_TILE_URL = 'https://tile.openstreetmap.org/{z}/{x}/{y}.png';
|
const DEFAULT_TILE_URL = 'https://tile.openstreetmap.org/{z}/{x}/{y}.png';
|
||||||
|
|
||||||
export default function MapView({
|
export default function MapView({
|
||||||
initialCenter = [11.5761, 48.1371], // Munich default [lng, lat]
|
initialCenter = [9.281477, 49.088795],
|
||||||
initialZoom = 13,
|
initialZoom = 13,
|
||||||
markers = [],
|
markers = [],
|
||||||
onMarkerClick,
|
onMarkerClick,
|
||||||
@@ -55,6 +55,7 @@ export default function MapView({
|
|||||||
// 1. Initialize Map instance
|
// 1. Initialize Map instance
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!mapContainerRef.current) return;
|
if (!mapContainerRef.current) return;
|
||||||
|
if (mapRef.current) return;
|
||||||
|
|
||||||
// Standard OpenStreetMap raster style (can be swapped for MapTiler / custom PBF vector style)
|
// Standard OpenStreetMap raster style (can be swapped for MapTiler / custom PBF vector style)
|
||||||
const mapStyle: maplibregl.StyleSpecification = {
|
const mapStyle: maplibregl.StyleSpecification = {
|
||||||
@@ -85,10 +86,8 @@ export default function MapView({
|
|||||||
zoom: initialZoom,
|
zoom: initialZoom,
|
||||||
});
|
});
|
||||||
|
|
||||||
// Default Controls
|
map.addControl(new maplibregl.NavigationControl({ visualizePitch: true }), 'bottom-right');
|
||||||
map.addControl(new maplibregl.NavigationControl({ visualizePitch: true }), 'top-right');
|
|
||||||
|
|
||||||
// Offline Geolocation Control (Uses Native Device GPS)
|
|
||||||
const geolocate = new maplibregl.GeolocateControl({
|
const geolocate = new maplibregl.GeolocateControl({
|
||||||
positionOptions: {
|
positionOptions: {
|
||||||
enableHighAccuracy: true,
|
enableHighAccuracy: true,
|
||||||
@@ -97,17 +96,26 @@ export default function MapView({
|
|||||||
showUserLocation: true,
|
showUserLocation: true,
|
||||||
showAccuracyCircle: true,
|
showAccuracyCircle: true,
|
||||||
});
|
});
|
||||||
map.addControl(geolocate, 'top-right');
|
map.addControl(geolocate, 'bottom-right');
|
||||||
|
|
||||||
map.addControl(new maplibregl.ScaleControl({ unit: 'metric' }), 'bottom-left');
|
map.addControl(new maplibregl.ScaleControl({ unit: 'metric' }), 'bottom-left');
|
||||||
|
|
||||||
|
map.on('load', async () => {
|
||||||
|
navigator.geolocation.getCurrentPosition((pos) => {
|
||||||
|
map.setCenter([pos.coords.longitude, pos.coords.latitude]);
|
||||||
|
geolocate.trigger();
|
||||||
|
}, () => {
|
||||||
|
geolocate.trigger();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
mapRef.current = map;
|
mapRef.current = map;
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
map.remove();
|
map.remove();
|
||||||
mapRef.current = null;
|
mapRef.current = null;
|
||||||
};
|
};
|
||||||
}, [initialCenter, initialZoom, tileUrlTemplate]);
|
}, [/*initialCenter, initialZoom, tileUrlTemplate Create your own listeners*/]);
|
||||||
|
|
||||||
// 2. Manage Markers Sync
|
// 2. Manage Markers Sync
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -217,7 +225,7 @@ export default function MapView({
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={styles.mapWrapper}>
|
<div className={styles.mapWrapper}>
|
||||||
<div className={styles.controlOverlay}>
|
{/*<div className={styles.controlOverlay}>
|
||||||
<button
|
<button
|
||||||
className={styles.precacheButton}
|
className={styles.precacheButton}
|
||||||
onClick={precacheCurrentRegion}
|
onClick={precacheCurrentRegion}
|
||||||
@@ -241,7 +249,7 @@ export default function MapView({
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>*/}
|
||||||
|
|
||||||
<div ref={mapContainerRef} className={styles.mapContainer} />
|
<div ref={mapContainerRef} className={styles.mapContainer} />
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,21 +1,94 @@
|
|||||||
import { useLocalStorage } from "@/hooks/useLocalStorage"
|
import { useLocalStorage } from "@/hooks/useLocalStorage"
|
||||||
import { PREF } from "@/utils/const"
|
import { PREF } from "@/utils/const"
|
||||||
import ChargedButton from "../ChargedButton";
|
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";
|
||||||
|
|
||||||
export default function Intro() {
|
export default function Intro() {
|
||||||
const [ stepStr, setStep ] = useLocalStorage(PREF.step, "0");
|
const [ stepStr, setStep ] = useLocalStorage(PREF.step, "0");
|
||||||
|
const { gpsStatus, cameraStatus, refresh } = usePermissions();
|
||||||
|
const [ rewatchScreen, setRewatchScreen ] = useState(false);
|
||||||
|
const [ videoEnded, setVideoEnded ] = useState(false);
|
||||||
|
const introVideoRef = useRef<HTMLVideoElement | null>(null);
|
||||||
|
|
||||||
|
const requestGPSPermission = () => {
|
||||||
|
navigator.geolocation.getCurrentPosition(() => refresh, () => refresh);
|
||||||
|
}
|
||||||
|
const requestCamPermission = () => {
|
||||||
|
navigator.mediaDevices.getUserMedia({
|
||||||
|
"video": { facingMode: { ideal: "environment" } },
|
||||||
|
"audio": false,
|
||||||
|
}).then((stream) => {
|
||||||
|
refresh();
|
||||||
|
stream.getTracks().forEach(track => track.stop());
|
||||||
|
alert("Keine Sorge! Die Kamera ist wieder ausgeschalten. Der Gerät zeigt Ihnen nur, dass darauf kurz zugegriffen wurde.");
|
||||||
|
}).catch((e) => refresh);
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleVideoClick = (e: PointerEvent<HTMLVideoElement>): boolean => {
|
||||||
|
e.currentTarget.play();
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="screen-container">
|
<div className="screen-container">
|
||||||
|
{ !rewatchScreen ?
|
||||||
|
<div>
|
||||||
<p>CODE EINGELÖST</p>
|
<p>CODE EINGELÖST</p>
|
||||||
<p>TON AN</p>
|
<p>TON AN</p>
|
||||||
<p>Für diese Tour werden extra Berechtigungen gebraucht.</p>
|
<p>Für diese Tour werden extra Berechtigungen gebraucht.</p>
|
||||||
|
<p>Kamera: {cameraStatus}</p>
|
||||||
|
<p>GPS: {gpsStatus}</p>
|
||||||
|
<br></br>
|
||||||
|
<button onClick={requestGPSPermission} style={{marginBottom: "2rem", marginRight: "3rem"}}>GPS</button>
|
||||||
|
<button onClick={requestCamPermission} style={{marginBottom: "2rem", marginRight: "3rem"}}>Cam</button>
|
||||||
|
<button onClick={refresh} style={{marginBottom: "2rem", marginRight: "3rem"}}>Refresh</button>
|
||||||
<br></br>
|
<br></br>
|
||||||
<ChargedButton onAction={() => {
|
<ChargedButton onAction={() => {
|
||||||
setStep("2");
|
setRewatchScreen(true);
|
||||||
}} holdDuration={1200}>
|
}} holdDuration={500} disabled={gpsStatus !== "granted" || cameraStatus !== "granted"}>
|
||||||
Video ansehen
|
Video ansehen
|
||||||
</ChargedButton>
|
</ChargedButton>
|
||||||
|
<div className={styles["overlay-video"]}>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
:
|
||||||
|
<div className={styles["intro-video-container"]}>
|
||||||
|
<video
|
||||||
|
ref={introVideoRef}
|
||||||
|
disablePictureInPicture={true}
|
||||||
|
autoPlay={true}
|
||||||
|
loop={false}
|
||||||
|
autoFocus={true}
|
||||||
|
width={"100%"}
|
||||||
|
onEnded={() => setVideoEnded(true)}
|
||||||
|
onAbort={() => setVideoEnded(true)}
|
||||||
|
onError={() => setVideoEnded(true)}
|
||||||
|
onClick={handleVideoClick}
|
||||||
|
onContextMenu={(e) => {
|
||||||
|
e.preventDefault();
|
||||||
|
return false;
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<source src="/res/testvid.webm" type="video/webm"/>
|
||||||
|
</video>
|
||||||
|
{ videoEnded ? <div className={styles["rewatch-controls"]}>
|
||||||
|
<ChargedButton holdDuration={500} onAction={() => {
|
||||||
|
if (introVideoRef.current) {
|
||||||
|
introVideoRef.current.pause();
|
||||||
|
introVideoRef.current.currentTime = 0;
|
||||||
|
introVideoRef.current.play();
|
||||||
|
setVideoEnded(false);
|
||||||
|
}
|
||||||
|
}}>Video wiederholen?</ChargedButton>
|
||||||
|
<ChargedButton holdDuration={500} onAction={() => {
|
||||||
|
setStep("2");
|
||||||
|
}}>Wir sind bereit!</ChargedButton>
|
||||||
|
</div> : null }
|
||||||
|
</div>
|
||||||
|
}
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -2,6 +2,8 @@ import { useLocalStorage } from "@/hooks/useLocalStorage"
|
|||||||
import { PREF } from "@/utils/const"
|
import { PREF } from "@/utils/const"
|
||||||
import { parsePlayerData } from "@/utils/dataparser";
|
import { parsePlayerData } from "@/utils/dataparser";
|
||||||
import ChargedButton from "../ChargedButton";
|
import ChargedButton from "../ChargedButton";
|
||||||
|
import styles from "@/css/Tour.module.css";
|
||||||
|
import MapView from "../MapView";
|
||||||
|
|
||||||
export default function Tour() {
|
export default function Tour() {
|
||||||
const [ stepStr, setStep ] = useLocalStorage(PREF.step, "0");
|
const [ stepStr, setStep ] = useLocalStorage(PREF.step, "0");
|
||||||
@@ -16,7 +18,7 @@ export default function Tour() {
|
|||||||
return (
|
return (
|
||||||
<div className="screen-container">
|
<div className="screen-container">
|
||||||
<div>
|
<div>
|
||||||
<p>{"Points: " + points}</p>
|
<p>{"Ruf: " + points}</p>
|
||||||
<p>{"Players: " + playersStr}</p>
|
<p>{"Players: " + playersStr}</p>
|
||||||
<br></br>
|
<br></br>
|
||||||
<ChargedButton onAction={() => {
|
<ChargedButton onAction={() => {
|
||||||
@@ -30,12 +32,11 @@ export default function Tour() {
|
|||||||
Zurücksetzen
|
Zurücksetzen
|
||||||
</ChargedButton>
|
</ChargedButton>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div className={styles["main-content"]}>
|
||||||
Contains both
|
<div className={styles["map"]}>
|
||||||
<div>
|
<MapView></MapView>
|
||||||
Map
|
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div className={styles["riddle-overlay"]}>
|
||||||
Riddle Overlay
|
Riddle Overlay
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -27,6 +27,10 @@ export default function WelcomeScreen() {
|
|||||||
return tourCode.length === CODE_LENGTH;
|
return tourCode.length === CODE_LENGTH;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const cleanTourCode = (dirtyTourCode: string): string => {
|
||||||
|
return dirtyTourCode.toUpperCase().replaceAll(/\W/g, "").substring(0, 9);
|
||||||
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (checkCooldown()) {
|
if (checkCooldown()) {
|
||||||
setIsCooldown(true);
|
setIsCooldown(true);
|
||||||
@@ -41,7 +45,7 @@ export default function WelcomeScreen() {
|
|||||||
}, [lastSubmitTs]);
|
}, [lastSubmitTs]);
|
||||||
|
|
||||||
const submit = () => {
|
const submit = () => {
|
||||||
const value = tourCodeRef.current;
|
const value = cleanTourCode(tourCodeRef.current);
|
||||||
|
|
||||||
if (!isTourCodeValid() && checkCooldown()) {
|
if (!isTourCodeValid() && checkCooldown()) {
|
||||||
return;
|
return;
|
||||||
@@ -63,7 +67,7 @@ export default function WelcomeScreen() {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
tourCodeRef.current = value;
|
tourCodeRef.current = value;
|
||||||
setTourCode(value.toUpperCase().replaceAll(/\W/g, ""));
|
setTourCode(cleanTourCode(value));
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -83,7 +87,7 @@ export default function WelcomeScreen() {
|
|||||||
</label>
|
</label>
|
||||||
<br></br>
|
<br></br>
|
||||||
<ChargedButton
|
<ChargedButton
|
||||||
holdDuration={1000}
|
holdDuration={500}
|
||||||
onAction={submit}
|
onAction={submit}
|
||||||
className="screen-submit"
|
className="screen-submit"
|
||||||
disabled={buttonDisabled}
|
disabled={buttonDisabled}
|
||||||
|
|||||||
@@ -0,0 +1,37 @@
|
|||||||
|
.intro-video-container {
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
|
||||||
|
.intro-video-container video {
|
||||||
|
position: relative;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
-webkit-tap-highlight-color: transparent;
|
||||||
|
user-select: none;
|
||||||
|
-webkit-user-select: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes fadeIn {
|
||||||
|
0% {
|
||||||
|
opacity: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
100% {
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.rewatch-controls {
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
row-gap: 3rem;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
background-color: rgba(0, 0, 0, 0.75);
|
||||||
|
animation: fadeIn 0.5s ease-out 0s 1 normal forwards;
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
.main-content {
|
||||||
|
position: relative;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
}
|
||||||
|
|
||||||
|
.map {
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.riddle-overlay {
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
padding: 1rem;
|
||||||
|
background-color: #000000AA;
|
||||||
|
}
|
||||||
Reference in new issue
Block a user