Merge branch 'v0.1.0' of https://github.com/Pax1601/DCSOlympus into v0.1.0

This commit is contained in:
dpassoni
2023-03-10 17:44:00 +01:00
9 changed files with 199 additions and 29 deletions

View File

@@ -75,11 +75,12 @@ function setup() {
if ( triggerElement instanceof HTMLElement ) {
const eventName:string = triggerElement.dataset.onClick || "";
const params:string = triggerElement.dataset.onClickParams || "{}";
let params = JSON.parse( triggerElement.dataset.onClickParams || "{}" );
params._element = triggerElement;
if ( eventName ) {
document.dispatchEvent( new CustomEvent( eventName, {
detail: JSON.parse( params )
detail: params
} ) );
}
@@ -130,6 +131,7 @@ function setup() {
document.addEventListener( "toggleCoalitionVisibility", ( ev:CustomEventInit ) => {
ev.detail._element.classList.toggle( "off" );
document.body.toggleAttribute( "data-hide-" + ev.detail.coalition );
});

View File

@@ -124,7 +124,13 @@ export class MouseInfoPanel extends Panel {
const bng = zeroAppend(Math.floor(bear), 3);
const reciprocal = zeroAppend( reciprocalHeading( parseInt( bng ) ), 3 );
this.#measureBox.innerText = `${bng}° | ${Math.floor(dist*0.000539957)}nm | ${reciprocal}°`;
let data = [ `${bng}°`, `${Math.floor(dist*0.000539957)}nm`, `${reciprocal}°` ];
if ( bear < 180 ) {
data = data.reverse();
}
this.#measureBox.innerText = data.join( " | " );
this.#measureBox.style.left = (getMap().getMousePosition().x + startXY.x) / 2 - this.#measureBox.offsetWidth / 2 + "px";
this.#measureBox.style.top = (getMap().getMousePosition().y + startXY.y) / 2 - this.#measureBox.offsetHeight / 2 + "px";
this.#measureBox.style.rotate = angle + "rad";

View File

@@ -23,19 +23,34 @@ export class UnitControlPanel extends Panel {
this.#airspeedSlider = new Slider("airspeed-slider", 0, 100, "kts", (value: number) => getUnitsManager().selectedUnitsSetSpeed(value / 1.94384));
/* Option buttons */
this.#optionButtons["ROE"] = ROEs.map((option: string) => {
this.#optionButtons["ROE"] = ROEs.map((option: string, index:number) => {
var button = document.createElement("button");
button.title = option;
button.addEventListener("click", () => getUnitsManager().selectedUnitsSetROE(button.title));
if ( index === 0 ) {
button.classList.add( "selected" );
}
button.addEventListener("click", () => {
this.getElement().querySelector("#roe-buttons-container button.selected")?.classList.remove( "selected" );
button.classList.add( "selected" );
getUnitsManager().selectedUnitsSetROE(button.title);
});
return button;
})
});
this.#optionButtons["reactionToThreat"] = reactionsToThreat.map((option: string) => {
this.#optionButtons["reactionToThreat"] = reactionsToThreat.map((option: string, index:number) => {
var button = document.createElement("button");
button.title = option;
button.addEventListener("click", () => getUnitsManager().selectedUnitsSetROE(button.title));
if ( index === 0 ) {
button.classList.add( "selected" );
}
button.addEventListener("click", () => {
this.getElement().querySelector("#reaction-to-threat-buttons-container button.selected")?.classList.remove( "selected" );
button.classList.add( "selected" );
getUnitsManager().selectedUnitsSetROE(button.title);
});
return button;
})
});
this.getElement().querySelector("#roe-buttons-container")?.append(...this.#optionButtons["ROE"]);
this.getElement().querySelector("#reaction-to-threat-buttons-container")?.append(...this.#optionButtons["reactionToThreat"]);