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

This commit is contained in:
Davide Passoni 2024-11-06 17:33:01 +01:00
commit 6d551c51eb
3 changed files with 8 additions and 7 deletions

View File

@ -48,8 +48,8 @@ export class AppStateChangedEvent {
static dispatch(state: OlympusState, subState: OlympusSubState) {
const detail = { state, subState };
document.dispatchEvent(new CustomEvent(this.name, { detail }));
console.log(`Event ${this.name} dispatched with detail:`);
console.log(detail);
console.log(`Event ${this.name} dispatched`);
console.log(`State: ${state} Substate: ${subState}`);
}
}

View File

@ -5,7 +5,7 @@ import { faArrowRight } from "@fortawesome/free-solid-svg-icons";
import { Unit } from "../../unit/unit";
import { FaLock } from "react-icons/fa6";
export function ProtectionPrompt(props: {onContinue: (units: Unit[]) => void, onBack: () => void, units: Unit[] }) {
export function ProtectionPrompt(props: {onContinue: () => void, onBack: () => void }) {
return (
<Modal
className={`
@ -56,7 +56,7 @@ export function ProtectionPrompt(props: {onContinue: (units: Unit[]) => void, on
<div className="flex">
<button
type="button"
onClick={() => {props.onContinue(props.units);}}
onClick={() => {props.onContinue()}}
className={`
mb-2 me-2 ml-auto flex content-center items-center gap-2
rounded-sm bg-blue-700 px-5 py-2.5 text-sm font-medium text-white

View File

@ -40,6 +40,7 @@ import {
CONTEXT_ACTION_COLORS,
OlympusState,
JTACSubState,
UnitControlSubState,
} from "../constants/constants";
import { DataExtractor } from "../server/dataextractor";
import { Weapon } from "../weapon/weapon";
@ -877,7 +878,7 @@ export abstract class Unit extends CustomMarker {
faExplosion,
null,
(units: Unit[], _1, _2) => {
document.dispatchEvent(new CustomEvent("showUnitExplosionMenu", { detail: { units: units } }));
getApp().setState(OlympusState.UNIT_CONTROL, UnitControlSubState.UNIT_EXPLOSION_MENU)
},
{
executeImmediately: true,
@ -1401,7 +1402,7 @@ export abstract class Unit extends CustomMarker {
this.setSelected(!this.getSelected());
}
} else if (getApp().getState() === OlympusState.JTAC && getApp().getSubState() === JTACSubState.SELECT_TARGET) {
document.dispatchEvent(new CustomEvent("selectJTACTarget", { detail: { unit: this } }));
// TODO document.dispatchEvent(new CustomEvent("selectJTACTarget", { detail: { unit: this } }));
getApp().setState(OlympusState.IDLE);
}
}
@ -1410,7 +1411,7 @@ export abstract class Unit extends CustomMarker {
console.log(`Long press on ${this.getUnitName()}`);
if (e.originalEvent.button === 2) {
document.dispatchEvent(new CustomEvent("showUnitContextMenu", { detail: e }));
getApp().setState(OlympusState.UNIT_CONTROL, UnitControlSubState.UNIT_CONTEXT_MENU)
}
}