Skip to content

Commit

Permalink
target/flags autocopy
Browse files Browse the repository at this point in the history
  • Loading branch information
sh4rkman committed Jan 2, 2025
1 parent 2d375ff commit 683daf7
Show file tree
Hide file tree
Showing 15 changed files with 209 additions and 101 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "squadcalc",
"version": "35.0.0",
"version": "35.1.0",
"description": "A Complete Mortar Calculator and Map Lane Finder for Squad",
"author": "Maxime 'sharkman' Boussard",
"license": "MIT",
Expand Down
3 changes: 2 additions & 1 deletion public/locales/en/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,6 @@
"invalidTarget": "Invalid Target",
"invalidMortarTarget": "Invalid Weapon & Target",
"targetOutOfRange": "Target is out of range",
"layerPlaceholder": "Layer"
"layerPlaceholder": "Layer",
"nextFlags": "Next Flags"
}
2 changes: 2 additions & 0 deletions public/locales/en/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"showSpread": "Spread Radius",
"showDamage": "Damage Radiuses",
"showAnimations": "Use Large Icons",
"copyTarget": "Auto-copy Target to clipboard",
"showBearing": "Bearing",
"showDistance": "Distance",
"showTimeOfFlight": "Time of Flight",
Expand All @@ -33,6 +34,7 @@
"capZoneOnHover": "Only show capzones when hovering",
"revealLayerOnHover" : "Reveal layer when hovering a flag",
"circlesFlags": "Show flag as circles",
"copyNextFlags": "Auto-copy next flags to clipboard",
"shortcuts": "Shortcuts",
"enter": "Enter focus mode, hiding UI buttons",
"deleteLastTarget": "Delete last placed target on the map",
Expand Down
3 changes: 2 additions & 1 deletion public/locales/fr/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,6 @@
"invalidTarget": "Cible invalide",
"invalidMortarTarget": "Arme & Cible invalides",
"targetOutOfRange": "Cible hors de portée",
"layerPlaceholder": "Layer"
"layerPlaceholder": "Layer",
"nextFlags": "Prochains points"
}
4 changes: 2 additions & 2 deletions public/locales/ru/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,6 @@
"invalidTarget": "Неверная цель",
"invalidMortarTarget": "Инвалидное оружие и мишень",
"targetOutOfRange": "Цель находится вне зоны действия",

"layerPlaceholder": "Layer"
"layerPlaceholder": "Layer",
"nextFlags": "Следующие флаги"
}
3 changes: 2 additions & 1 deletion public/locales/uk/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,6 @@
"invalidTarget": "Недійсна ціль",
"invalidMortarTarget": "Непридатна зброя та мішень",
"targetOutOfRange": "Ціль поза зоною досяжності",
"layerPlaceholder": "Layer"
"layerPlaceholder": "Layer",
"nextFlags": "Наступні прапори"
}
3 changes: 2 additions & 1 deletion public/locales/zh/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,6 @@
"invalidTarget": "无效的目标",
"invalidMortarTarget": "取消武器和目标",
"targetOutOfRange": "目标超出范围",
"layerPlaceholder": "Layer"
"layerPlaceholder": "",
"nextFlags": "下一个点"
}
4 changes: 4 additions & 0 deletions src/components/dialogs/dialogs.scss
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,10 @@ dialog {
h3 {
font-size: 1.3em;
}
h4 {
padding: 0 2.5em 0.5em;
font-size: 1.1em;
}
#fontSize {
width: 100%;
height: auto;
Expand Down
187 changes: 114 additions & 73 deletions src/components/dialogs/settings.html
Original file line number Diff line number Diff line change
Expand Up @@ -217,9 +217,9 @@ <h3 data-i18n="settings:preview">Preview</h3>


<table class="userSettings">
<caption data-i18n="settings:targetOptions"></caption>
<tbody>

<caption data-i18n="settings:targetOptions"></caption>
<tbody>
<tr class="targetAnimationSettings">
<td>
<label class="mcui-checkbox">
Expand All @@ -236,22 +236,39 @@ <h3 data-i18n="settings:preview">Preview</h3>
</td>
</tr>

<tr class="targetDragSetting">
<tr>
<td>
<label class="mcui-checkbox">
<input id="targetDragSetting" type="checkbox">
<span>
<svg class="mcui-check" viewBox="-2 -2 35 35" aria-hidden="true">
<polyline points="7.57 15.87 12.62 21.07 23.43 9.93" />
</svg>
</span>
</label>
<input id="targetDragSetting" type="checkbox">
<span>
<svg class="mcui-check" viewBox="-2 -2 35 35" aria-hidden="true">
<polyline points="7.57 15.87 12.62 21.07 23.43 9.93" />
</svg>
</span>
</label>
</td>
<td>
<span data-i18n="settings:targetDrag" class="toggleCheckbox"></span>
</td>
</tr>

<tr>
<td>
<label class="mcui-checkbox">
<input id="targetCopySetting" type="checkbox">
<span>
<svg class="mcui-check" viewBox="-2 -2 35 35" aria-hidden="true">
<polyline points="7.57 15.87 12.62 21.07 23.43 9.93" />
</svg>
</span>
</label>
</td>
<td>
<span data-i18n="settings:copyTarget" class="toggleCheckbox"></span>
<sup class="new">new</sup>
</td>
</tr>

<tr>
<td>
<label class="mcui-checkbox">
Expand Down Expand Up @@ -280,65 +297,72 @@ <h3 data-i18n="settings:preview">Preview</h3>
<td><span data-i18n="settings:showDamage" class="toggleCheckbox"></span></td>
</tr>

<tr>
<td>
<label class="mcui-checkbox">
<input id="bearingSetting" type="checkbox">
<span>
<svg class="mcui-check" viewBox="-2 -2 35 35" aria-hidden="true">
<polyline points="7.57 15.87 12.62 21.07 23.43 9.93" />
</svg>
</span>
</label>
</td>
<td><span data-i18n="settings:showBearing" class="toggleCheckbox"></span></td>
</tr>

<tr>
<td>
<label class="mcui-checkbox">
<input id="distanceSetting" type="checkbox">
<span>
<svg class="mcui-check" viewBox="-2 -2 35 35" aria-hidden="true">
<polyline points="7.57 15.87 12.62 21.07 23.43 9.93" />
</svg>
</span>
</label>
</td>
<td><span data-i18n="settings:showDistance" class="toggleCheckbox"></span></td>
</tr>

<tr>
<td>
<label class="mcui-checkbox">
<input id="timeOfFlightSetting" type="checkbox">
<span>
<svg class="mcui-check" viewBox="-2 -2 35 35" aria-hidden="true">
<polyline points="7.57 15.87 12.62 21.07 23.43 9.93" />
</svg>
</span>
</label>
</td>
<td><span data-i18n="settings:showTimeOfFlight" class="toggleCheckbox"></span></td>
</tr>

<tr>
<td>
<label class="mcui-checkbox">
<input id="heightSetting" type="checkbox">
<span>
<svg class="mcui-check" viewBox="-2 -2 35 35" aria-hidden="true">
<polyline points="7.57 15.87 12.62 21.07 23.43 9.93" />
</svg>
</span>
</label>
</td>
<td><span data-i18n="settings:showHeightDiff" class="toggleCheckbox"></span></td>
</tr>

</tbody>
</table>

<table class="userSettings">
<!-- <caption data-i18n="settings:weaponOptions"></caption> -->
<tbody>
<h4>Texts</h4>
<tr>
<td>
<label class="mcui-checkbox">
<input id="bearingSetting" type="checkbox">
<span>
<svg class="mcui-check" viewBox="-2 -2 35 35" aria-hidden="true">
<polyline points="7.57 15.87 12.62 21.07 23.43 9.93" />
</svg>
</span>
</label>
</td>
<td><span data-i18n="settings:showBearing" class="toggleCheckbox"></span></td>
</tr>

<tr>
<td>
<label class="mcui-checkbox">
<input id="distanceSetting" type="checkbox">
<span>
<svg class="mcui-check" viewBox="-2 -2 35 35" aria-hidden="true">
<polyline points="7.57 15.87 12.62 21.07 23.43 9.93" />
</svg>
</span>
</label>
</td>
<td><span data-i18n="settings:showDistance" class="toggleCheckbox"></span></td>
</tr>

<tr>
<td>
<label class="mcui-checkbox">
<input id="timeOfFlightSetting" type="checkbox">
<span>
<svg class="mcui-check" viewBox="-2 -2 35 35" aria-hidden="true">
<polyline points="7.57 15.87 12.62 21.07 23.43 9.93" />
</svg>
</span>
</label>
</td>
<td><span data-i18n="settings:showTimeOfFlight" class="toggleCheckbox"></span></td>
</tr>

<tr>
<td>
<label class="mcui-checkbox">
<input id="heightSetting" type="checkbox">
<span>
<svg class="mcui-check" viewBox="-2 -2 35 35" aria-hidden="true">
<polyline points="7.57 15.87 12.62 21.07 23.43 9.93" />
</svg>
</span>
</label>
</td>
<td><span data-i18n="settings:showHeightDiff" class="toggleCheckbox"></span></td>
</tr>

</tbody>
</table>

</div>

<div id="panel3" class="panel">
Expand Down Expand Up @@ -398,19 +422,36 @@ <h3 data-i18n="settings:preview">Preview</h3>
<tr class="circlesFlags">
<td>
<label class="mcui-checkbox">
<input id="circlesFlagsSettings" type="checkbox">
<span>
<svg class="mcui-check" viewBox="-2 -2 35 35" aria-hidden="true">
<polyline points="7.57 15.87 12.62 21.07 23.43 9.93" />
</svg>
</span>
</label>
<input id="circlesFlagsSettings" type="checkbox">
<span>
<svg class="mcui-check" viewBox="-2 -2 35 35" aria-hidden="true">
<polyline points="7.57 15.87 12.62 21.07 23.43 9.93" />
</svg>
</span>
</label>
</td>
<td>
<span data-i18n="settings:circlesFlags" class="toggleCheckbox"></span>
</td>
</tr>

<tr class="copyNextFlagsSettings">
<td>
<label class="mcui-checkbox">
<input id="copyNextFlagsSettings" type="checkbox">
<span>
<svg class="mcui-check" viewBox="-2 -2 35 35" aria-hidden="true">
<polyline points="7.57 15.87 12.62 21.07 23.43 9.93" />
</svg>
</span>
</label>
</td>
<td>
<span data-i18n="settings:copyNextFlags" class="toggleCheckbox"></span>
<sup class="new">new</sup>
</td>
</tr>

</tbody>
</table>
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/components/shared/_responsive.scss
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@
}
&#helpDialog {
font-size: 0.7em;
height: 530px;
height: 550px;
width: 600px;
table {
width: 90%;
Expand Down
20 changes: 19 additions & 1 deletion src/js/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,13 @@ export function loadSettings(){
dropdownParent: $("#helpDialog"),
minimumResultsForSearch: -1, // Disable search
});
$(".dropbtn6").val(fontSize).trigger("change");;
$(".dropbtn6").val(fontSize).trigger("change");

App.userSettings.copyNextFlags = loadLocalSetting("settings-copy-next-flags", 0);
$("#copyNextFlagsSettings").prop("checked", App.userSettings.copyNextFlags);

App.userSettings.copyTarget = loadLocalSetting("settings-copy-target", 0);
$("#targetCopySetting").prop("checked", App.userSettings.copyTarget);

App.userSettings.circlesFlags = loadLocalSetting("settings-circles-flags");
$("#circlesFlagsSettings").prop("checked", App.userSettings.circlesFlags);
Expand Down Expand Up @@ -331,6 +337,18 @@ $("#realMaxRangeSettings").on("change", function() {
App.minimap.updateWeapons();
});

$("#targetCopySetting").on("change", function() {
var val = $("#targetCopySetting").is(":checked");
App.userSettings.copyTarget = val;
localStorage.setItem("settings-copy-target", +val);
});

$("#copyNextFlagsSettings").on("change", function() {
var val = $("#copyNextFlagsSettings").is(":checked");
App.userSettings.copyNextFlags = val;
localStorage.setItem("settings-copy-next-flags", +val);
});

$("#cursorChoiceSettings").on("change", function() {
var val = $("#cursorChoiceSettings").is(":checked");
App.userSettings.cursor = val;
Expand Down
13 changes: 11 additions & 2 deletions src/js/squadLayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import { DivIcon, Marker, Circle, LayerGroup, Polyline, Polygon, Rectangle, FeatureGroup } from "leaflet";
import { SquadObjective } from "./squadObjective.js";
import { App } from "../app.js";
import i18next from "i18next";

export class SquadLayer {

Expand Down Expand Up @@ -703,21 +704,29 @@ export class SquadLayer {

console.debug("Flags next step :", nextFlags);


let nextFlagsNamesArray = [];

// Highlight the next flags with a proper class
nextFlags.forEach((flag) => {
flag.flag._icon.classList.add("next");
flag.flag.options.icon.options.className = "flag flag" + flag.position + " next";
flag.isNext = true;
nextFlagsNamesArray.push(flag.name);
});

// Copy the next flags names to the clipboard
if (App.userSettings.copyNextFlags) {
App.copy(i18next.t("common:nextFlags") + " : " + nextFlagsNamesArray.join("/"));
}


// Only one flag in front ? Click it
if (nextFlags.length === 1 && !backward && App.userSettings.autoLane){
this._handleFlagClick(nextFlags[0]);
}

}


/**
* Remove clusters that were not reachable from the previous position
* @param {Set} reachableClusters - Set of reachable clusters
Expand Down
Loading

0 comments on commit 683daf7

Please sign in to comment.