mirror of
https://github.com/Pax1601/DCSOlympus.git
synced 2025-10-29 16:56:34 +00:00
More svg injection, removing stringed html from code
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
import { getUnitsManager } from "..";
|
||||
import { deg2rad } from "../other/utils";
|
||||
import { ContextMenu } from "./contextmenu";
|
||||
|
||||
@@ -10,21 +9,19 @@ export class UnitContextMenu extends ContextMenu {
|
||||
|
||||
document.addEventListener("applyCustomFormation", () => {
|
||||
var dialog = document.getElementById("custom-formation-dialog");
|
||||
if (dialog)
|
||||
{
|
||||
if (dialog) {
|
||||
dialog.classList.add("hide");
|
||||
var clock = 1;
|
||||
while (clock < 8)
|
||||
{
|
||||
if ((<HTMLInputElement> dialog.querySelector(`#formation-${clock}`)).checked)
|
||||
while (clock < 8) {
|
||||
if ((<HTMLInputElement>dialog.querySelector(`#formation-${clock}`)).checked)
|
||||
break
|
||||
clock++;
|
||||
}
|
||||
var angleDeg = 360 - (clock - 1) * 45;
|
||||
var angleRad = deg2rad(angleDeg);
|
||||
var distance = parseInt((<HTMLInputElement> dialog.querySelector(`#distance`)?.querySelector("input")).value) * 0.3048;
|
||||
var upDown = parseInt((<HTMLInputElement> dialog.querySelector(`#up-down`)?.querySelector("input")).value) * 0.3048;
|
||||
|
||||
var distance = parseInt((<HTMLInputElement>dialog.querySelector(`#distance`)?.querySelector("input")).value) * 0.3048;
|
||||
var upDown = parseInt((<HTMLInputElement>dialog.querySelector(`#up-down`)?.querySelector("input")).value) * 0.3048;
|
||||
|
||||
// X: front-rear, positive front
|
||||
// Y: top-bottom, positive top
|
||||
// Z: left-right, positive right
|
||||
@@ -34,7 +31,7 @@ export class UnitContextMenu extends ContextMenu {
|
||||
var z = distance * Math.sin(angleRad);
|
||||
|
||||
if (this.#customFormationCallback)
|
||||
this.#customFormationCallback({"x": x, "y": y, "z": z})
|
||||
this.#customFormationCallback({ "x": x, "y": y, "z": z })
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -43,10 +40,8 @@ export class UnitContextMenu extends ContextMenu {
|
||||
this.#customFormationCallback = callback;
|
||||
}
|
||||
|
||||
setOptions(options: {[key: string]: string}, callback: CallableFunction)
|
||||
{
|
||||
this.getContainer()?.replaceChildren(...Object.keys(options).map((option: string, idx: number) =>
|
||||
{
|
||||
setOptions(options: { [key: string]: string }, callback: CallableFunction) {
|
||||
this.getContainer()?.replaceChildren(...Object.keys(options).map((option: string, idx: number) => {
|
||||
var button = document.createElement("button");
|
||||
button.innerHTML = options[option];
|
||||
button.addEventListener("click", () => callback(option));
|
||||
|
||||
Reference in New Issue
Block a user