Skip to content

Commit

Permalink
Community map display
Browse files Browse the repository at this point in the history
  • Loading branch information
codergautam committed Oct 23, 2024
1 parent 2e9a7d1 commit 026059b
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 17 deletions.
18 changes: 13 additions & 5 deletions components/home.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -1880,9 +1890,7 @@ setShowCountryButtons(false)
)}
<button className="home__squarebtn gameBtn" aria-label="Settings" onClick={() => setSettingsModal(true)}><FaGear className="home__squarebtnicon" /></button>
*/}
{ !inCrazyGames && (
<button className="homeBtn" aria-label="Community Maps" onClick={()=>setMapModal(true)}>{text("communityMaps")}</button>
)}
</div>

</>
Expand Down
2 changes: 1 addition & 1 deletion components/maps/mapsModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -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" : ""}`;
}
};

Expand Down
6 changes: 4 additions & 2 deletions pages/map.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -184,7 +184,9 @@ export default function MapPage({ }) {
<div className={styles.branding}>
<h1>WorldGuessr</h1>
<center>
<button onClick={() => window.location.href="/"} className={styles.backButton}>
<button onClick={() => window.location.href=`/${
window.location.search.includes('crazygames') ? '?crazygames=true' : ''
}`} className={styles.backButton}>
{text('backToGame')}
</button>
</center>
Expand Down
15 changes: 6 additions & 9 deletions ws/ws.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,9 @@ console.log = function () {
}

console.error = function () {
// if (dev) {
// return;
// }
if (dev) {
return;
}
if(process.env.DISCORD_WEBHOOK_WS) {

const args = Array.from(arguments);
Expand All @@ -162,22 +162,19 @@ function stop(reason) {

process.on('SIGTERM', () => {
stop('SIGTERM');
process.exit(0);
});

process.on('SIGINT', () => {
stop('SIGINT');
process.exit(0);
});

/// other stop codes

process.on('exit', (code) => {

stop('exit');
});

process.on('uncaughtException', (err) => {
console.error('Uncaught exception', err);
stop('uncaughtException');
process.exit(1);
});

process.on('unhandledRejection', (reason, promise) => {
Expand Down

0 comments on commit 026059b

Please sign in to comment.