Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions src/modules/leaflet-control-map-settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ L.Control.MapSettings = L.Control.extend({
activeTasksLabel: "Only show markers for active tasks",
expandMapLegendLabel: "Don't collapse layers control",
expandMapLegendChecked: false,
alwaysShowSnipers: true,
},
onAdd: function (map) {
const className = "leaflet-control-map-settings";
Expand Down Expand Up @@ -104,6 +105,24 @@ L.Control.MapSettings = L.Control.extend({
const activeQuestMarkersLabelContent = L.DomUtil.create("span", undefined, activeQuestMarkersLabel);
activeQuestMarkersLabelContent.textContent = this.options.activeTasksLabel;

// always show snipers setting
const alwaysShowSnipersDiv = L.DomUtil.create("div", `${className}-setting-container`, form);

const alwaysShowSnipersLabel = L.DomUtil.create("label", undefined, alwaysShowSnipersDiv);
alwaysShowSnipersLabel.setAttribute("for", "alwaysShowSnipers");

const alwaysShowSnipersCheckbox = L.DomUtil.create("input", undefined, alwaysShowSnipersLabel);
alwaysShowSnipersCheckbox.id = "alwaysShowSnipers";
alwaysShowSnipersCheckbox.setAttribute("type", "checkbox");
if (!!this.options.alwaysShowSnipers) {
alwaysShowSnipersCheckbox.setAttribute("checked", !!this.options.alwaysShowSnipers);
alwaysShowSnipersCheckbox.checked = true;
}
L.DomEvent.on(alwaysShowSnipersCheckbox, "click", this._onSettingChanged, this);

const alwaysShowSnipersLabelContent = L.DomUtil.create("span", undefined, alwaysShowSnipersLabel);
alwaysShowSnipersLabelContent.textContent = this.options.alwaysShowSnipersLabel;

L.DomUtil.create("div", `${className}-separator player-location-help-separator`, form);

// show location labels setting
Expand Down
72 changes: 39 additions & 33 deletions src/pages/map/index.css

Large diffs are not rendered by default.

78 changes: 52 additions & 26 deletions src/pages/map/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,7 @@ function Map() {
showOnlyActiveTasks: false,
expandMapLegend: false,
expandSearch: false,
alwaysShowSnipers: true,
});

const mapSettingsRef = useRef(savedMapSettings);
Expand Down Expand Up @@ -525,6 +526,8 @@ function Map() {
expandSearchChecked: mapSettingsRef.current.expandSearch,
expandSearchLabel: tMaps("Don't collapse search control"),
playerLocationLabel: tMaps("Use TarkovMonitor to show your position"),
alwaysShowSnipers: mapSettingsRef.current.alwaysShowSnipers ?? true,
alwaysShowSnipersLabel: tMaps("Always show snipers"),
collapsed: true,
})
.addTo(map);
Expand All @@ -542,6 +545,13 @@ function Map() {
if (e.settingName === "expandSearch") {
map.searchControl.setCollapse(!e.settingValue);
}
if (e.settingName === "alwaysShowSnipers") {
if (e.settingValue) {
map._container.classList.add("always-show-snipers");
} else {
map._container.classList.remove("always-show-snipers");
}
}
mapSettingsRef.current[e.settingName] = e.settingValue;
updateSavedMapSettings();
});
Expand Down Expand Up @@ -953,6 +963,7 @@ function Map() {
}
}
// if baseLayer._image is set, it's an svg map
// since we're adding a height layer, we set base layer to off level
if (baseLayer._image && !layer.show) {
baseLayer._image.classList.add("off-level");
} else if (baseLayer._container && !layer.show) {
Expand All @@ -962,36 +973,48 @@ function Map() {
// remove the hidden-layer class from the added layer
// we wrap it in the svg loading promsise to make sure the svg file has finished loading
svgLoaded.finally(() => {
const layerGroup = [...baseLayer._image.children[0]?.children].find(
(c) => c.id === layer.svgLayer,
);
layerGroup?.classList.remove("hidden-layer");
if (!baseLayer._image.children[0]?.children) {
return;
}
for (const layerGroup of baseLayer._image.children[0].children) {
if (layerGroup.id !== layer.svgLayer) {
// hide all layers that weren't just added
layerGroup?.classList.add("hidden-layer");
continue;
}
// un-hide added layer
layerGroup?.classList.remove("hidden-layer");
}
});
}
map.layerControl.updateBadge(tMaps(layer.name));
});
heightLayer.on("remove", () => {
const heightLayer = Object.values(map._layers).findLast((l) => l.options?.extents);
if (heightLayer) {
for (const marker of Object.values(map._layers)) {
checkMarkerForActiveLayers(marker);
}
const layers = Object.values(map._layers).filter((l) => l.options.type === "map-layer");
if (layers.length !== 1) {
return;
}
map.layerControl.updateBadge();
if (baseLayer._image) {
baseLayer._image.classList.remove("off-level");
} else if (baseLayer._container) {
baseLayer._container.classList.remove("off-level");
}
if (baseLayer._image?.children[0]) {
// add the hidden-layer class to the removed layer
const layerGroup = [...baseLayer._image.children[0].children].find(
(c) => c.id === layer.svgLayer,
);
layerGroup?.classList.add("hidden-layer");
/*const heightLayer = Object.values(map._layers).findLast((l) => l.options?.extents);
if (!heightLayer) {
return;
}*/
for (const marker of Object.values(map._layers)) {
checkMarkerForActiveLayers(marker);
}
const layers = Object.values(map._layers).filter((l) => l.options.type === "map-layer");
if (layers.length !== 1) {
return;
}
map.layerControl.updateBadge();
if (baseLayer._image) {
baseLayer._image.classList.remove("off-level");
} else if (baseLayer._container) {
baseLayer._container.classList.remove("off-level");
}
if (baseLayer._image?.children[0]) {
// add the hidden-layer class to the removed layer
for (const layerGroup of baseLayer._image.children[0].children) {
if (layerGroup.id !== layer.svgLayer) {
continue;
}
layerGroup.classList.add("hidden-layer");
break;
}
}
});
Expand Down Expand Up @@ -1175,6 +1198,7 @@ function Map() {
}
let spawnType = "";
let bosses = [];
let markerClass;

if (spawn.categories.includes("boss")) {
bosses = mapData.bosses.filter((boss) =>
Expand Down Expand Up @@ -1206,6 +1230,7 @@ function Map() {
}
} else if (spawn.categories.includes("sniper")) {
spawnType = "sniper_scav";
markerClass = "sniper-spawn";
} else if (spawn.sides.includes("scav")) {
if (spawn.categories.includes("bot") || spawn.categories.includes("all")) {
spawnType = "scav";
Expand All @@ -1222,6 +1247,7 @@ function Map() {
iconUrl: `${process.env.PUBLIC_URL}/maps/interactive/spawn_${spawnType}.png`,
iconSize: [24, 24],
popupAnchor: [0, -12],
className: markerClass,
});

if (spawnType === "pmc") {
Expand Down Expand Up @@ -2116,7 +2142,7 @@ function Map() {
key="seo-wrapper"
/>,
<div
className={`display-wrapper map-page${savedMapSettings.showOnlyActiveTasks ? " only-active-quest-markers" : ""}`}
className={`display-wrapper map-page${savedMapSettings.showOnlyActiveTasks ? " only-active-quest-markers" : ""}${savedMapSettings.alwaysShowSnipers ? " always-show-snipers" : ""}`}
key="map-wrapper"
>
{mapData.projection !== "interactive" && [
Expand Down
3 changes: 2 additions & 1 deletion src/translations/de/maps.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,6 @@
"Don't collapse search control": "Don't collapse search control",
"Required item": "Required item",
"BTR Stop": "BTR Stop",
"Player Position": "Player Position"
"Player Position": "Player Position",
"Always show snipers": "Always show snipers"
}
3 changes: 2 additions & 1 deletion src/translations/en/maps.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,6 @@
"Use TarkovMonitor to show your position": "Use TarkovMonitor to show your position",
"Required item": "Required item",
"BTR Stop": "BTR Stop",
"Player Position": "Player Position"
"Player Position": "Player Position",
"Always show snipers": "Always show snipers"
}
3 changes: 2 additions & 1 deletion src/translations/es/maps.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,6 @@
"Use TarkovMonitor to show your position": "Use TarkovMonitor to show your position",
"Required item": "Required item",
"BTR Stop": "BTR Stop",
"Player Position": "Player Position"
"Player Position": "Player Position",
"Always show snipers": "Always show snipers"
}
3 changes: 2 additions & 1 deletion src/translations/fr/maps.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,6 @@
"Use TarkovMonitor to show your position": "Utilisez TarkovMonitor pour afficher votre position",
"Required item": "Article requis",
"BTR Stop": "BTR Stop",
"Player Position": "Position du joueur"
"Player Position": "Position du joueur",
"Always show snipers": "Always show snipers"
}
3 changes: 2 additions & 1 deletion src/translations/it/maps.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,6 @@
"Use TarkovMonitor to show your position": "Use TarkovMonitor to show your position",
"Required item": "Required item",
"BTR Stop": "BTR Stop",
"Player Position": "Player Position"
"Player Position": "Player Position",
"Always show snipers": "Always show snipers"
}
3 changes: 2 additions & 1 deletion src/translations/ja/maps.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,6 @@
"Use TarkovMonitor to show your position": "Use TarkovMonitor to show your position",
"Required item": "Required item",
"BTR Stop": "BTR Stop",
"Player Position": "Player Position"
"Player Position": "Player Position",
"Always show snipers": "Always show snipers"
}
3 changes: 2 additions & 1 deletion src/translations/pl/maps.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,6 @@
"Use TarkovMonitor to show your position": "Use TarkovMonitor to show your position",
"Required item": "Required item",
"BTR Stop": "BTR Stop",
"Player Position": "Player Position"
"Player Position": "Player Position",
"Always show snipers": "Always show snipers"
}
3 changes: 2 additions & 1 deletion src/translations/pt/maps.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,6 @@
"Use TarkovMonitor to show your position": "Use TarkovMonitor to show your position",
"Required item": "Required item",
"BTR Stop": "BTR Stop",
"Player Position": "Player Position"
"Player Position": "Player Position",
"Always show snipers": "Always show snipers"
}
3 changes: 2 additions & 1 deletion src/translations/ru/maps.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,6 @@
"Use TarkovMonitor to show your position": "Use TarkovMonitor to show your position",
"Required item": "Required item",
"BTR Stop": "BTR Stop",
"Player Position": "Player Position"
"Player Position": "Player Position",
"Always show snipers": "Always show snipers"
}
4 changes: 3 additions & 1 deletion src/translations/zh/maps.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,7 @@
"Don't collapse search control": "Don't collapse search control",
"Use TarkovMonitor to show your position": "使用 TarkovMonitor 来显示你的位置",
"Required item": "所需物品",
"BTR Stop": "BTR 停车点"
"BTR Stop": "BTR 停车点",
"Player Position": "Player Position",
"Always show snipers": "Always show snipers"
}
1 change: 1 addition & 0 deletions stylelint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const config = {
"shorthand-property-no-redundant-values": null,
"font-family-name-quotes": "always-unless-keyword",
"selector-class-pattern": ".+",
"no-descending-specificity": null,
},
};

Expand Down