mirror of
https://github.com/Pax1601/DCSOlympus.git
synced 2025-10-29 16:56:34 +00:00
Switched to using constants for colors
This commit is contained in:
parent
7fa39561e3
commit
4946807d88
@ -367,3 +367,13 @@ export enum AudioMessageType {
|
||||
audio,
|
||||
settings,
|
||||
}
|
||||
|
||||
export const CONTEXT_ACTION_COLORS = [null, "white", "green", "purple", "blue", "red"];
|
||||
export enum ContextActionColors {
|
||||
NO_COLOR,
|
||||
MOVE,
|
||||
OTHER,
|
||||
ADMIN,
|
||||
ENGAGE,
|
||||
DELETE
|
||||
}
|
||||
@ -4,7 +4,7 @@ import { ContextActionSet } from "../../unit/contextactionset";
|
||||
import { OlStateButton } from "../components/olstatebutton";
|
||||
import { getApp } from "../../olympusapp";
|
||||
import { ContextAction } from "../../unit/contextaction";
|
||||
import { CONTEXT_ACTION } from "../../constants/constants";
|
||||
import { CONTEXT_ACTION, CONTEXT_ACTION_COLORS } from "../../constants/constants";
|
||||
import { OlDropdownItem } from "../components/oldropdown";
|
||||
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
||||
import { LatLng } from "leaflet";
|
||||
@ -93,9 +93,8 @@ export function MapContextMenu(props: {}) {
|
||||
return newContextActionSet;
|
||||
}
|
||||
|
||||
let colors = [null, "white", "green", "purple", "blue", "red"];
|
||||
let reorderedActions: ContextAction[] = [];
|
||||
colors.forEach((color) => {
|
||||
CONTEXT_ACTION_COLORS.forEach((color) => {
|
||||
Object.values(contextActionsSet.getContextActions()).forEach((contextAction: ContextAction) => {
|
||||
if (color === null && contextAction.getOptions().buttonColor === undefined) reorderedActions.push(contextAction);
|
||||
else if (color === contextAction.getOptions().buttonColor) reorderedActions.push(contextAction);
|
||||
|
||||
@ -4,7 +4,7 @@ import { ContextActionSet } from "../../unit/contextactionset";
|
||||
import { OlStateButton } from "../components/olstatebutton";
|
||||
import { getApp } from "../../olympusapp";
|
||||
import { ContextAction } from "../../unit/contextaction";
|
||||
import { CONTEXT_ACTION } from "../../constants/constants";
|
||||
import { CONTEXT_ACTION, CONTEXT_ACTION_COLORS } from "../../constants/constants";
|
||||
import { FaInfoCircle } from "react-icons/fa";
|
||||
import { FaChevronLeft, FaChevronRight } from "react-icons/fa6";
|
||||
|
||||
@ -72,9 +72,8 @@ export function UnitMouseControlBar(props: {}) {
|
||||
sr > 1 && scrolledRight && setScrolledRight(false);
|
||||
}
|
||||
|
||||
let colors = [null, "white", "green", "purple", "blue", "red"];
|
||||
let reorderedActions: ContextAction[] = [];
|
||||
colors.forEach((color) => {
|
||||
CONTEXT_ACTION_COLORS.forEach((color) => {
|
||||
Object.values(contextActionsSet.getContextActions()).forEach((contextAction: ContextAction) => {
|
||||
if (color === null && contextAction.getOptions().buttonColor === undefined) reorderedActions.push(contextAction);
|
||||
else if (color === contextAction.getOptions().buttonColor) reorderedActions.push(contextAction);
|
||||
|
||||
@ -4,7 +4,7 @@ import { LatLng } from "leaflet";
|
||||
|
||||
export interface ContextActionOptions {
|
||||
executeImmediately?: boolean;
|
||||
buttonColor?: string;
|
||||
buttonColor?: string | null;
|
||||
}
|
||||
|
||||
export type ContextActionCallback = (units: Unit[], targetUnit: Unit | null, targetPosition: LatLng | null) => void;
|
||||
|
||||
@ -40,6 +40,8 @@ import {
|
||||
SHOTS_SCATTER_DEGREES,
|
||||
CONTEXT_ACTION,
|
||||
SELECT_JTAC_TARGET,
|
||||
ContextActionColors,
|
||||
CONTEXT_ACTION_COLORS,
|
||||
} from "../constants/constants";
|
||||
import { DataExtractor } from "../server/dataextractor";
|
||||
import { groundUnitDatabase } from "./databases/groundunitdatabase";
|
||||
@ -828,7 +830,7 @@ export abstract class Unit extends CustomMarker {
|
||||
getApp().getUnitsManager().clearDestinations(units);
|
||||
if (targetPosition) getApp().getUnitsManager().addDestination(targetPosition, false, 0, units);
|
||||
},
|
||||
{ buttonColor: "white" }
|
||||
{ buttonColor: CONTEXT_ACTION_COLORS[ContextActionColors.MOVE] }
|
||||
);
|
||||
|
||||
contextActionSet.addContextAction(
|
||||
@ -841,7 +843,7 @@ export abstract class Unit extends CustomMarker {
|
||||
(units: Unit[], _, targetPosition) => {
|
||||
if (targetPosition) getApp().getUnitsManager().addDestination(targetPosition, false, 0, units);
|
||||
},
|
||||
{ buttonColor: "white" }
|
||||
{ buttonColor: CONTEXT_ACTION_COLORS[ContextActionColors.MOVE] }
|
||||
);
|
||||
|
||||
contextActionSet.addContextAction(
|
||||
@ -856,7 +858,7 @@ export abstract class Unit extends CustomMarker {
|
||||
},
|
||||
{
|
||||
executeImmediately: true,
|
||||
buttonColor: "red",
|
||||
buttonColor: CONTEXT_ACTION_COLORS[ContextActionColors.DELETE],
|
||||
}
|
||||
);
|
||||
|
||||
@ -872,7 +874,7 @@ export abstract class Unit extends CustomMarker {
|
||||
},
|
||||
{
|
||||
executeImmediately: true,
|
||||
buttonColor: "red",
|
||||
buttonColor: CONTEXT_ACTION_COLORS[ContextActionColors.DELETE],
|
||||
}
|
||||
);
|
||||
|
||||
@ -1826,7 +1828,7 @@ export abstract class AirUnit extends Unit {
|
||||
(units: Unit[]) => {
|
||||
getApp().getUnitsManager().refuel(units);
|
||||
},
|
||||
{ executeImmediately: true, buttonColor: "purple" }
|
||||
{ executeImmediately: true, buttonColor: CONTEXT_ACTION_COLORS[ContextActionColors.ADMIN] }
|
||||
);
|
||||
contextActionSet.addContextAction(
|
||||
this,
|
||||
@ -1838,7 +1840,7 @@ export abstract class AirUnit extends Unit {
|
||||
(units: Unit[]) => {
|
||||
getApp().getMap().centerOnUnit(units[0]);
|
||||
},
|
||||
{ executeImmediately: true, buttonColor: "green" }
|
||||
{ executeImmediately: true, buttonColor: CONTEXT_ACTION_COLORS[ContextActionColors.OTHER] }
|
||||
);
|
||||
|
||||
/* Context actions that require a target unit */
|
||||
@ -1852,8 +1854,9 @@ export abstract class AirUnit extends Unit {
|
||||
(units: Unit[], targetUnit: Unit | null, _) => {
|
||||
if (targetUnit) getApp().getUnitsManager().attackUnit(targetUnit.ID, units);
|
||||
},
|
||||
{ buttonColor: "blue" }
|
||||
{ buttonColor: CONTEXT_ACTION_COLORS[ContextActionColors.ENGAGE] }
|
||||
);
|
||||
|
||||
contextActionSet.addContextAction(
|
||||
this,
|
||||
"follow",
|
||||
@ -1873,34 +1876,37 @@ export abstract class AirUnit extends Unit {
|
||||
);
|
||||
}
|
||||
},
|
||||
{ buttonColor: "purple" }
|
||||
{ buttonColor: CONTEXT_ACTION_COLORS[ContextActionColors.ADMIN] }
|
||||
);
|
||||
|
||||
/* Context actions that require a target position */
|
||||
contextActionSet.addContextAction(
|
||||
this,
|
||||
"bomb",
|
||||
"Precision bomb location",
|
||||
"Click on a point to execute a precision bombing attack",
|
||||
faLocationCrosshairs,
|
||||
"position",
|
||||
(units: Unit[], _, targetPosition: LatLng | null) => {
|
||||
if (targetPosition) getApp().getUnitsManager().bombPoint(targetPosition, units);
|
||||
},
|
||||
{ buttonColor: "blue" }
|
||||
);
|
||||
contextActionSet.addContextAction(
|
||||
this,
|
||||
"carpet-bomb",
|
||||
"Carpet bomb location",
|
||||
"Click on a point to execute a carpet bombing attack",
|
||||
faXmarksLines,
|
||||
"position",
|
||||
(units: Unit[], _, targetPosition: LatLng | null) => {
|
||||
if (targetPosition) getApp().getUnitsManager().carpetBomb(targetPosition, units);
|
||||
},
|
||||
{ buttonColor: "blue" }
|
||||
);
|
||||
if (this.canTargetPoint()) {
|
||||
/* Context actions that require a target position */
|
||||
contextActionSet.addContextAction(
|
||||
this,
|
||||
"bomb",
|
||||
"Precision bomb location",
|
||||
"Click on a point to execute a precision bombing attack",
|
||||
faLocationCrosshairs,
|
||||
"position",
|
||||
(units: Unit[], _, targetPosition: LatLng | null) => {
|
||||
if (targetPosition) getApp().getUnitsManager().bombPoint(targetPosition, units);
|
||||
},
|
||||
{ buttonColor: CONTEXT_ACTION_COLORS[ContextActionColors.ENGAGE] }
|
||||
);
|
||||
|
||||
contextActionSet.addContextAction(
|
||||
this,
|
||||
"carpet-bomb",
|
||||
"Carpet bomb location",
|
||||
"Click on a point to execute a carpet bombing attack",
|
||||
faXmarksLines,
|
||||
"position",
|
||||
(units: Unit[], _, targetPosition: LatLng | null) => {
|
||||
if (targetPosition) getApp().getUnitsManager().carpetBomb(targetPosition, units);
|
||||
},
|
||||
{ buttonColor: CONTEXT_ACTION_COLORS[ContextActionColors.ENGAGE] }
|
||||
);
|
||||
}
|
||||
|
||||
contextActionSet.addContextAction(
|
||||
this,
|
||||
@ -1912,7 +1918,7 @@ export abstract class AirUnit extends Unit {
|
||||
(units: Unit[], _, targetPosition: LatLng | null) => {
|
||||
if (targetPosition) getApp().getUnitsManager().landAt(targetPosition, units);
|
||||
},
|
||||
{ buttonColor: "purple" }
|
||||
{ buttonColor: CONTEXT_ACTION_COLORS[ContextActionColors.ADMIN] }
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -1960,7 +1966,7 @@ export class Helicopter extends AirUnit {
|
||||
(units: Unit[], _, targetPosition: LatLng | null) => {
|
||||
if (targetPosition) getApp().getUnitsManager().landAtPoint(targetPosition, units);
|
||||
},
|
||||
{ buttonColor: "purple" }
|
||||
{ buttonColor: CONTEXT_ACTION_COLORS[ContextActionColors.ADMIN] }
|
||||
);
|
||||
}
|
||||
|
||||
@ -2009,7 +2015,7 @@ export class GroundUnit extends Unit {
|
||||
(units: Unit[], _1, _2) => {
|
||||
getApp().getUnitsManager().createGroup(units);
|
||||
},
|
||||
{ executeImmediately: true, buttonColor: "green" }
|
||||
{ executeImmediately: true, buttonColor: CONTEXT_ACTION_COLORS[ContextActionColors.OTHER] }
|
||||
);
|
||||
contextActionSet.addContextAction(
|
||||
this,
|
||||
@ -2021,7 +2027,7 @@ export class GroundUnit extends Unit {
|
||||
(units: Unit[]) => {
|
||||
getApp().getMap().centerOnUnit(units[0]);
|
||||
},
|
||||
{ executeImmediately: true, buttonColor: "green" }
|
||||
{ executeImmediately: true, buttonColor: CONTEXT_ACTION_COLORS[ContextActionColors.OTHER] }
|
||||
);
|
||||
|
||||
/* Context actions that require a target unit */
|
||||
@ -2035,7 +2041,7 @@ export class GroundUnit extends Unit {
|
||||
(units: Unit[], targetUnit: Unit | null, _) => {
|
||||
if (targetUnit) getApp().getUnitsManager().attackUnit(targetUnit.ID, units);
|
||||
},
|
||||
{ buttonColor: "blue" }
|
||||
{ buttonColor: CONTEXT_ACTION_COLORS[ContextActionColors.ENGAGE] }
|
||||
);
|
||||
|
||||
/* Context actions that require a target position */
|
||||
@ -2050,7 +2056,7 @@ export class GroundUnit extends Unit {
|
||||
(units: Unit[], _, targetPosition: LatLng | null) => {
|
||||
if (targetPosition) getApp().getUnitsManager().fireAtArea(targetPosition, units);
|
||||
},
|
||||
{ buttonColor: "blue" }
|
||||
{ buttonColor: CONTEXT_ACTION_COLORS[ContextActionColors.ENGAGE] }
|
||||
);
|
||||
contextActionSet.addContextAction(
|
||||
this,
|
||||
@ -2062,7 +2068,7 @@ export class GroundUnit extends Unit {
|
||||
(units: Unit[], _, targetPosition: LatLng | null) => {
|
||||
if (targetPosition) getApp().getUnitsManager().simulateFireFight(targetPosition, units);
|
||||
},
|
||||
{ buttonColor: "purple" }
|
||||
{ buttonColor: CONTEXT_ACTION_COLORS[ContextActionColors.ADMIN] }
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -2154,7 +2160,7 @@ export class NavyUnit extends Unit {
|
||||
(units: Unit[], _1, _2) => {
|
||||
getApp().getUnitsManager().createGroup(units);
|
||||
},
|
||||
{ executeImmediately: true, buttonColor: "green" }
|
||||
{ executeImmediately: true, buttonColor: CONTEXT_ACTION_COLORS[ContextActionColors.OTHER] }
|
||||
);
|
||||
contextActionSet.addContextAction(
|
||||
this,
|
||||
@ -2166,7 +2172,7 @@ export class NavyUnit extends Unit {
|
||||
(units: Unit[]) => {
|
||||
getApp().getMap().centerOnUnit(units[0]);
|
||||
},
|
||||
{ executeImmediately: true, buttonColor: "green" }
|
||||
{ executeImmediately: true, buttonColor: CONTEXT_ACTION_COLORS[ContextActionColors.OTHER] }
|
||||
);
|
||||
|
||||
/* Context actions that require a target unit */
|
||||
@ -2180,7 +2186,7 @@ export class NavyUnit extends Unit {
|
||||
(units: Unit[], targetUnit: Unit | null, _) => {
|
||||
if (targetUnit) getApp().getUnitsManager().attackUnit(targetUnit.ID, units);
|
||||
},
|
||||
{ buttonColor: "blue" }
|
||||
{ buttonColor: CONTEXT_ACTION_COLORS[ContextActionColors.ENGAGE] }
|
||||
);
|
||||
|
||||
/* Context actions that require a target position */
|
||||
@ -2193,7 +2199,8 @@ export class NavyUnit extends Unit {
|
||||
"position",
|
||||
(units: Unit[], _, targetPosition: LatLng | null) => {
|
||||
if (targetPosition) getApp().getUnitsManager().fireAtArea(targetPosition, units);
|
||||
}, { buttonColor: "blue" }
|
||||
},
|
||||
{ buttonColor: CONTEXT_ACTION_COLORS[ContextActionColors.ENGAGE] }
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@ -381,25 +381,50 @@ function Olympus.move(groupName, lat, lng, altitude, altitudeType, speed, speedT
|
||||
end
|
||||
Olympus.debug("Olympus.move executed successfully on Helicopter", 2)
|
||||
elseif category == "GroundUnit" then
|
||||
local startPoint = mist.getLeadPos(group)
|
||||
local endPoint = coord.LLtoLO(lat, lng, 0)
|
||||
local bearing = math.atan2(endPoint.z - startPoint.z, endPoint.x - startPoint.x)
|
||||
|
||||
vars = {
|
||||
group = group,
|
||||
point = endPoint,
|
||||
heading = bearing,
|
||||
speed = speed
|
||||
}
|
||||
|
||||
local action = "Off Road"
|
||||
local disableRoads = true
|
||||
if taskOptions and taskOptions['id'] == 'FollowRoads' and taskOptions['value'] == true then
|
||||
vars["disableRoads"] = false
|
||||
else
|
||||
vars["form"] = "Off Road"
|
||||
vars["disableRoads"] = true
|
||||
action = "On Road"
|
||||
disableRoads = false
|
||||
end
|
||||
|
||||
missionTask = {
|
||||
id = 'Mission',
|
||||
params = {
|
||||
route = {
|
||||
points = {
|
||||
[1] = {
|
||||
type = "Turning Point",
|
||||
action = action,
|
||||
disableRoads = disableRoads,
|
||||
x = endPoint.x,
|
||||
y = endPoint.z,
|
||||
speed = speed,
|
||||
speed_locked = false,
|
||||
ETA_locked = false,
|
||||
name = 'Mission1',
|
||||
},
|
||||
[2] = {
|
||||
type = "Turning Point",
|
||||
action = action,
|
||||
disableRoads = disableRoads,
|
||||
x = endPoint.x,
|
||||
y = endPoint.z,
|
||||
speed = speed,
|
||||
speed_locked = false,
|
||||
ETA_locked = false,
|
||||
name = 'Mission1',
|
||||
},
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
local groupCon = group:getController()
|
||||
if groupCon then
|
||||
groupCon:setTask(missionTask)
|
||||
end
|
||||
|
||||
mist.groupToRandomPoint(vars)
|
||||
Olympus.debug("Olympus.move executed successfully on GroundUnit", 2)
|
||||
elseif category == "NavyUnit" then
|
||||
local startPoint = mist.getLeadPos(group)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user