diff --git a/components/home.js b/components/home.js index 4cd638d1..4ca9e56a 100644 --- a/components/home.js +++ b/components/home.js @@ -253,7 +253,16 @@ export default function Home({ }) { console.log("onboarding", onboardingCompletedd) if(onboardingCompletedd !== "done") startOnboarding(); else setOnboardingCompleted(true) - } + + if(window.location.search.includes("map=")) { + // get map slug map=slug from url + const params = new URLSearchParams(window.location.search); + const mapSlug = params.get("map"); + setScreen("singleplayer") + + openMap(mapSlug) + } + } if(window.location.search.includes("crazygames")) { setInCrazyGames(true); window.inCrazyGames = true; @@ -428,12 +437,13 @@ setShowCountryButtons(false) try { const onboarding = gameStorage.getItem("onboarding"); // check url + const cg = window.location.search.includes("crazygames"); const specifiedMapSlug = window.location.search.includes("map="); console.log("onboarding", onboarding, specifiedMapSlug) // make it false just for testing // gameStorage.setItem("onboarding", null) if(onboarding && onboarding === "done") setOnboardingCompleted(true) - else if(specifiedMapSlug) setOnboardingCompleted(true) + else if(specifiedMapSlug && !cg) setOnboardingCompleted(true) else setOnboardingCompleted(false) } catch(e) { console.error(e, "onboard"); @@ -531,7 +541,7 @@ setShowCountryButtons(false) setScreen("singleplayer") } // check if from map screen - if(window.location.search.includes("map=")) { + if(window.location.search.includes("map=") && !window.location.search.includes("crazygames")) { // get map slug map=slug from url const params = new URLSearchParams(window.location.search); const mapSlug = params.get("map"); @@ -1880,9 +1890,7 @@ setShowCountryButtons(false) )} */} - { !inCrazyGames && ( - )} > diff --git a/components/maps/mapsModal.js b/components/maps/mapsModal.js index 18bc1d75..642743f6 100644 --- a/components/maps/mapsModal.js +++ b/components/maps/mapsModal.js @@ -11,7 +11,7 @@ export default function MapsModal({ inLegacy, gameOptions, setGameOptions, shown if (customChooseMapCallback) { customChooseMapCallback(map); } else { - window.location.href = `/map?s=${map.slug}`; + window.location.href = `/map?s=${map.slug}${window.location.search.includes("crazygames") ? "&crazygames=true" : ""}`; } }; diff --git a/pages/map.js b/pages/map.js index cb5154d4..92175a29 100644 --- a/pages/map.js +++ b/pages/map.js @@ -138,7 +138,7 @@ export default function MapPage({ }) { }, [mapData.data]); const handlePlayButtonClick = () => { - window.location.href = `/?map=${mapData.countryCode || mapData.slug}`; + window.location.href = `/?map=${mapData.countryCode || mapData.slug}${window.location.search.includes('crazygames') ? '&crazygames=true' : ''}`; }; return ( @@ -184,7 +184,9 @@ export default function MapPage({ }) {