Skip to content

Commit

Permalink
moved map style settings to a different script
Browse files Browse the repository at this point in the history
  • Loading branch information
FallBackITA27 committed Jun 9, 2024
1 parent a5a5267 commit 9f9970b
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 50 deletions.
4 changes: 4 additions & 0 deletions gtav-interactive-map/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,14 @@
<script defer src="./lib/path.js"></script>
<script defer src="./lib/gui.js"></script>
<script defer src="./lib/fetching.js"></script>

<script defer src="./menus/tools/timers.js"></script>
<script defer src="./menus/settings/mapStyle.js"></script>
<script defer src="./menus/settings/debug.js"></script>
<script defer src="./menus/settings/data.js"></script>
<script defer src="./menus/changelog.js"></script>
<script defer src="./menus/faq.js"></script>

<script defer src="./loadScripts/counties.js"></script>
<script defer src="./loadScripts/mapStyle.js"></script>
<script defer src="./loadScripts/figurines.js"></script>
Expand All @@ -67,6 +70,7 @@
<script defer src="./loadScripts/vincentHeistHitAndRun.js"></script>
<script defer src="./loadScripts/vincentHeistDisorganizedCrime.js"></script>
<script defer src="./loadScripts/vincentHeistSceneOfTheCrime.js"></script>

<script defer src="./script.js"></script>
</head>
<body>
Expand Down
43 changes: 43 additions & 0 deletions gtav-interactive-map/menus/settings/mapStyle.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
function mapStyleSettings() {
resetContentPart2();
const names = ["game", "render", "print"];
const namesDisp = ["In Game", "Satellite", "Game Manual"];

let optionDiv = document.createElement("div");
optionDiv.innerHTML = "Map Style";

let interactiveDiv = document.createElement("div");

let img1 = document.createElement("img");
img1.src = "./websiteIcons/small_arr_left.svg";
interactiveDiv.appendChild(img1);

interactiveDiv.innerHTML += `<p>${
namesDisp[names.indexOf(saveData.selectedTileLayer)]
}</p>`;

let img2 = document.createElement("img");
img2.src = "./websiteIcons/small_arr_right.svg";
interactiveDiv.appendChild(img2);

interactiveDiv.style = "display: flex; align-items: center;";
optionDiv.appendChild(interactiveDiv);

contentPart2.append(optionDiv);

function refreshMap(idx) {
interactiveDiv.children[1].innerHTML = namesDisp[idx];
constantData.tileLayers.mainMap[saveData.selectedTileLayer].remove();
saveData.selectedTileLayer = names[idx];
saveDataSave();
constantData.tileLayers.mainMap[saveData.selectedTileLayer].addTo(map);
document.getElementById("map").style.background =
constantData.oceanColors.mainMap[saveData.selectedTileLayer];
}

optionDiv.addEventListener("click", function () {
let idx = names.indexOf(saveData.selectedTileLayer) + 1;
if (idx === 3) idx = 0;
refreshMap(idx);
});
}
54 changes: 4 additions & 50 deletions gtav-interactive-map/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -233,56 +233,10 @@ Array.from(document.getElementById("menuScroll").children).forEach((r) =>
mainContent.classList.add("styleClassic");

/* Map Style Options */
let mapStyleButton = addToContentPart1List("Map Style");
mapStyleButton.addEventListener("click", function () {
resetContentPart2();
const names = ["game", "render", "print"];
const namesDisp = ["In Game", "Satellite", "Game Manual"];

let optionDiv = document.createElement("div");
optionDiv.innerHTML = "Map Style";

let interactiveDiv = document.createElement("div");

let img1 = document.createElement("img");
img1.src = "./websiteIcons/small_arr_left.svg";
interactiveDiv.appendChild(img1);

interactiveDiv.innerHTML += `<p>${
namesDisp[names.indexOf(saveData.selectedTileLayer)]
}</p>`;

let img2 = document.createElement("img");
img2.src = "./websiteIcons/small_arr_right.svg";
interactiveDiv.appendChild(img2);

interactiveDiv.style = "display: flex; align-items: center;";
optionDiv.appendChild(interactiveDiv);

contentPart2.append(optionDiv);

function refreshMap(idx) {
interactiveDiv.children[1].innerHTML = namesDisp[idx];
constantData.tileLayers.mainMap[
saveData.selectedTileLayer
].remove();
saveData.selectedTileLayer = names[idx];
saveDataSave();
constantData.tileLayers.mainMap[
saveData.selectedTileLayer
].addTo(map);
document.getElementById("map").style.background =
constantData.oceanColors.mainMap[
saveData.selectedTileLayer
];
}

optionDiv.addEventListener("click", function () {
let idx = names.indexOf(saveData.selectedTileLayer) + 1;
if (idx === 3) idx = 0;
refreshMap(idx);
});
});
addToContentPart1List("Map Style").addEventListener(
"click",
mapStyleSettings
);

/* Debug Options */
addToContentPart1List("Debug").addEventListener(
Expand Down

0 comments on commit 9f9970b

Please sign in to comment.