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
3 changed files with 8 additions and 7 deletions

View File

@@ -48,8 +48,8 @@ export class AppStateChangedEvent {
static dispatch(state: OlympusState, subState: OlympusSubState) { static dispatch(state: OlympusState, subState: OlympusSubState) {
const detail = { state, subState }; const detail = { state, subState };
document.dispatchEvent(new CustomEvent(this.name, { detail })); document.dispatchEvent(new CustomEvent(this.name, { detail }));
console.log(`Event ${this.name} dispatched with detail:`); console.log(`Event ${this.name} dispatched`);
console.log(detail); 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 { Unit } from "../../unit/unit";
import { FaLock } from "react-icons/fa6"; 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 ( return (
<Modal <Modal
className={` className={`
@@ -56,7 +56,7 @@ export function ProtectionPrompt(props: {onContinue: (units: Unit[]) => void, on
<div className="flex"> <div className="flex">
<button <button
type="button" type="button"
onClick={() => {props.onContinue(props.units);}} onClick={() => {props.onContinue()}}
className={` className={`
mb-2 me-2 ml-auto flex content-center items-center gap-2 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 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, CONTEXT_ACTION_COLORS,
OlympusState, OlympusState,
JTACSubState, JTACSubState,
UnitControlSubState,
} from "../constants/constants"; } from "../constants/constants";
import { DataExtractor } from "../server/dataextractor"; import { DataExtractor } from "../server/dataextractor";
import { Weapon } from "../weapon/weapon"; import { Weapon } from "../weapon/weapon";
@@ -877,7 +878,7 @@ export abstract class Unit extends CustomMarker {
faExplosion, faExplosion,
null, null,
(units: Unit[], _1, _2) => { (units: Unit[], _1, _2) => {
document.dispatchEvent(new CustomEvent("showUnitExplosionMenu", { detail: { units: units } })); getApp().setState(OlympusState.UNIT_CONTROL, UnitControlSubState.UNIT_EXPLOSION_MENU)
}, },
{ {
executeImmediately: true, executeImmediately: true,
@@ -1401,7 +1402,7 @@ export abstract class Unit extends CustomMarker {
this.setSelected(!this.getSelected()); this.setSelected(!this.getSelected());
} }
} else if (getApp().getState() === OlympusState.JTAC && getApp().getSubState() === JTACSubState.SELECT_TARGET) { } 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); getApp().setState(OlympusState.IDLE);
} }
} }
@@ -1410,7 +1411,7 @@ export abstract class Unit extends CustomMarker {
console.log(`Long press on ${this.getUnitName()}`); console.log(`Long press on ${this.getUnitName()}`);
if (e.originalEvent.button === 2) { if (e.originalEvent.button === 2) {
document.dispatchEvent(new CustomEvent("showUnitContextMenu", { detail: e })); getApp().setState(OlympusState.UNIT_CONTROL, UnitControlSubState.UNIT_CONTEXT_MENU)
} }
} }