fix game navigation
Browse files
client/src/components/GameNavigation.jsx
CHANGED
|
@@ -21,10 +21,9 @@ export function GameNavigation() {
|
|
| 21 |
const handleBack = () => {
|
| 22 |
playSound("page");
|
| 23 |
if (location === "/game") {
|
| 24 |
-
|
| 25 |
-
window.location.reload();
|
| 26 |
} else {
|
| 27 |
-
|
| 28 |
}
|
| 29 |
};
|
| 30 |
|
|
|
|
| 21 |
const handleBack = () => {
|
| 22 |
playSound("page");
|
| 23 |
if (location === "/game") {
|
| 24 |
+
window.location.href = "/";
|
|
|
|
| 25 |
} else {
|
| 26 |
+
window.location.href = "/";
|
| 27 |
}
|
| 28 |
};
|
| 29 |
|
client/src/pages/Game.jsx
CHANGED
|
@@ -234,13 +234,21 @@ function GameContent() {
|
|
| 234 |
// Gérer la transition vers le jeu
|
| 235 |
useEffect(() => {
|
| 236 |
if (isTransitionLoading) {
|
| 237 |
-
//
|
| 238 |
-
const
|
| 239 |
-
|
| 240 |
-
|
| 241 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 242 |
}
|
| 243 |
-
}, [isTransitionLoading]);
|
| 244 |
|
| 245 |
// Effet pour gérer le scroll et la narration des nouveaux segments
|
| 246 |
useEffect(() => {
|
|
@@ -312,7 +320,8 @@ function GameContent() {
|
|
| 312 |
|
| 313 |
const handleBack = () => {
|
| 314 |
playSound("page");
|
| 315 |
-
|
|
|
|
| 316 |
};
|
| 317 |
|
| 318 |
const handleCaptureStory = async () => {
|
|
@@ -329,8 +338,8 @@ function GameContent() {
|
|
| 329 |
);
|
| 330 |
}
|
| 331 |
|
| 332 |
-
//
|
| 333 |
-
if (isSessionLoading
|
| 334 |
return (
|
| 335 |
<Box
|
| 336 |
sx={{
|
|
@@ -356,8 +365,8 @@ function GameContent() {
|
|
| 356 |
);
|
| 357 |
}
|
| 358 |
|
| 359 |
-
//
|
| 360 |
-
if (
|
| 361 |
return (
|
| 362 |
<Box sx={{ width: "100%", height: "100vh", backgroundColor: "#1a1a1a" }}>
|
| 363 |
<UniverseSlotMachine
|
|
@@ -374,8 +383,13 @@ function GameContent() {
|
|
| 374 |
);
|
| 375 |
}
|
| 376 |
|
| 377 |
-
//
|
| 378 |
-
if (
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 379 |
return (
|
| 380 |
<Box
|
| 381 |
sx={{
|
|
@@ -396,10 +410,7 @@ function GameContent() {
|
|
| 396 |
right: 0,
|
| 397 |
}}
|
| 398 |
/>
|
| 399 |
-
<RotatingMessage
|
| 400 |
-
messages={TRANSITION_MESSAGES}
|
| 401 |
-
isVisible={isTransitionLoading}
|
| 402 |
-
/>
|
| 403 |
</Box>
|
| 404 |
);
|
| 405 |
}
|
|
|
|
| 234 |
// Gérer la transition vers le jeu
|
| 235 |
useEffect(() => {
|
| 236 |
if (isTransitionLoading) {
|
| 237 |
+
// Vérifier si le jeu est prêt à être affiché
|
| 238 |
+
const isGameReady =
|
| 239 |
+
segments.length > 0 &&
|
| 240 |
+
segments[0].images &&
|
| 241 |
+
segments[0].images.length > 0;
|
| 242 |
+
|
| 243 |
+
if (isGameReady) {
|
| 244 |
+
// Attendre un peu pour la transition visuelle
|
| 245 |
+
const timer = setTimeout(() => {
|
| 246 |
+
setIsTransitionLoading(false);
|
| 247 |
+
}, 1000);
|
| 248 |
+
return () => clearTimeout(timer);
|
| 249 |
+
}
|
| 250 |
}
|
| 251 |
+
}, [isTransitionLoading, segments]);
|
| 252 |
|
| 253 |
// Effet pour gérer le scroll et la narration des nouveaux segments
|
| 254 |
useEffect(() => {
|
|
|
|
| 320 |
|
| 321 |
const handleBack = () => {
|
| 322 |
playSound("page");
|
| 323 |
+
localStorage.removeItem("slot_machine_shown");
|
| 324 |
+
window.location.href = "/tutorial";
|
| 325 |
};
|
| 326 |
|
| 327 |
const handleCaptureStory = async () => {
|
|
|
|
| 338 |
);
|
| 339 |
}
|
| 340 |
|
| 341 |
+
// Premier loading : en attendant la réponse de l'univers
|
| 342 |
+
if (isSessionLoading) {
|
| 343 |
return (
|
| 344 |
<Box
|
| 345 |
sx={{
|
|
|
|
| 365 |
);
|
| 366 |
}
|
| 367 |
|
| 368 |
+
// Slot machine : dès que l'univers est disponible
|
| 369 |
+
if (gameUniverse && slotMachineState.style && isInitialLoading) {
|
| 370 |
return (
|
| 371 |
<Box sx={{ width: "100%", height: "100vh", backgroundColor: "#1a1a1a" }}>
|
| 372 |
<UniverseSlotMachine
|
|
|
|
| 383 |
);
|
| 384 |
}
|
| 385 |
|
| 386 |
+
// Loading final : après la slot machine jusqu'à ce que le jeu soit prêt
|
| 387 |
+
if (
|
| 388 |
+
isTransitionLoading ||
|
| 389 |
+
!segments.length ||
|
| 390 |
+
!segments[0].images ||
|
| 391 |
+
segments[0].images.length === 0
|
| 392 |
+
) {
|
| 393 |
return (
|
| 394 |
<Box
|
| 395 |
sx={{
|
|
|
|
| 410 |
right: 0,
|
| 411 |
}}
|
| 412 |
/>
|
| 413 |
+
<RotatingMessage messages={TRANSITION_MESSAGES} isVisible={true} />
|
|
|
|
|
|
|
|
|
|
| 414 |
</Box>
|
| 415 |
);
|
| 416 |
}
|