Added context buttons, temporary fixes to allow preview

This commit is contained in:
Davide Passoni
2024-06-28 11:04:18 +02:00
parent 329e9b86fd
commit cd38a2f053
12 changed files with 164 additions and 28 deletions

View File

@@ -158,7 +158,8 @@ export class OlympusApp {
this.#weaponsManager = new WeaponsManager();
/* Set the address of the server */
this.getServerManager().setAddress(window.location.href.split('?')[0]);
// Temporary forcing port 3000 for development
this.getServerManager().setAddress(window.location.href.split('?')[0].replace('8080', '3000'));
/* Setup all global events */
this.#setupEvents();
@@ -181,8 +182,8 @@ export class OlympusApp {
})
/* Load the config file from the server */
// Temporary
const configRequest = new Request("http://localhost:3000/" + "resources/config");
// Temporary forcing port 3000 for development
const configRequest = new Request(window.location.href.split('?')[0].replace('8080', '3000') + "resources/config");
fetch(configRequest).then((response) => {
if (response.status === 200) {
return response.json();

View File

@@ -129,8 +129,6 @@ export class ServerManager {
}
setAddress(address: string) {
// Temporary
address = "http://localhost:3000/"
this.#REST_ADDRESS = `${address}olympus`
console.log(`Setting REST address to ${this.#REST_ADDRESS}`)
}

File diff suppressed because one or more lines are too long

View File

@@ -4,8 +4,8 @@ import { UnitDatabase } from "./unitdatabase"
export class AircraftDatabase extends UnitDatabase {
constructor() {
//Temporary
super('http://localhost:3000/api/databases/units/aircraftdatabase');
// Temporary forcing port 3000 for development
super(window.location.href.split('?')[0].replace('8080', '3000') + 'api/databases/units/aircraftdatabase');
}
getCategory() {

View File

@@ -4,8 +4,8 @@ import { UnitDatabase } from "./unitdatabase"
export class GroundUnitDatabase extends UnitDatabase {
constructor() {
// Temporary
super('http://localhost:3000/api/databases/units/groundunitdatabase');
// Temporary forcing port 3000 for development
super(window.location.href.split('?')[0].replace('8080', '3000') + 'api/databases/units/groundunitdatabase');
}
getSpawnPointsByName(name: string) {

View File

@@ -4,8 +4,8 @@ import { UnitDatabase } from "./unitdatabase"
export class HelicopterDatabase extends UnitDatabase {
constructor() {
// Temporary
super('http://localhost:3000/api/databases/units/helicopterdatabase');
// Temporary forcing port 3000 for development
super(window.location.href.split('?')[0].replace('8080', '3000') + 'api/databases/units/helicopterdatabase');
}
getSpawnPointsByName(name: string) {

View File

@@ -4,8 +4,8 @@ import { UnitDatabase } from "./unitdatabase"
export class NavyUnitDatabase extends UnitDatabase {
constructor() {
// Temporary
super('http://localhost:3000/api/databases/units/navyunitdatabase');
// Temporary forcing port 3000 for development
super(window.location.href.split('?')[0].replace('8080', '3000') + 'api/databases/units/navyunitdatabase');
}
getSpawnPointsByName(name: string) {

View File

@@ -15,8 +15,9 @@ import { RangeCircle } from "../map/rangecircle";
import { Group } from './group';
import { ContextActionSet } from './contextactionset';
import * as turf from "@turf/turf";
import { olIconsDiamond, olIconsEchelonLh, olIconsEchelonRh, olIconsFollow, olIconsFront, olIconsGroupGround, olIconsLandAtPoint, olIconsLineAbreast, olIconsTrail, olStatesAttack, olStatesRefuel } from '../ui/components/olicons';
import { faArrowDown, faExclamation, faQuestionCircle } from '@fortawesome/free-solid-svg-icons';
import { olButtonsContextMissOnPurpose, olButtonsContextScenicAaa, olButtonsContextSimulateFireFight, olIconsDiamond, olIconsEchelonLh, olIconsEchelonRh, olIconsFollow, olIconsFront, olIconsGroupGround, olIconsLandAtPoint, olIconsLineAbreast, olIconsTrail, olStatesAttack, olStatesMissOnPurpose, olStatesRefuel } from '../ui/components/olicons';
import { faArrowDown, faExclamation, faLocationCrosshairs, faMapLocation, faPeopleGroup, faQuestionCircle, faXmarksLines } from '@fortawesome/free-solid-svg-icons';
import { FaXmarksLines } from 'react-icons/fa6';
var pathIcon = new Icon({
iconUrl: '/resources/theme/images/markers/marker-icon.png',
@@ -1505,7 +1506,7 @@ export abstract class AirUnit extends Unit {
contextActionSet.addContextAction(this, "refuel", "Refuel", "Refuel units at the nearest AAR Tanker. If no tanker is available the unit will RTB", olStatesRefuel, (units: Unit[]) => {
getApp().getUnitsManager().refuel(units)
}, { executeImmediately: true });
contextActionSet.addContextAction(this, "center-map", "Center map", "Center the map on the unit and follow it", faQuestionCircle, (units: Unit[]) => {
contextActionSet.addContextAction(this, "center-map", "Center map", "Center the map on the unit and follow it", faMapLocation, (units: Unit[]) => {
getApp().getMap().centerOnUnit(units[0]);
}, { executeImmediately: true });
@@ -1520,11 +1521,11 @@ export abstract class AirUnit extends Unit {
});
/* Context actions with a target position */
contextActionSet.addContextAction(this, "bomb", "Precision bombing", "Click on a point to execute a precision bombing attack", faQuestionCircle, (units: Unit[], targetUnit: Unit | null, targetPosition: LatLng | null) => {
contextActionSet.addContextAction(this, "bomb", "Precision bombing", "Click on a point to execute a precision bombing attack", faLocationCrosshairs, (units: Unit[], targetUnit: Unit | null, targetPosition: LatLng | null) => {
if (targetPosition)
getApp().getUnitsManager().bombPoint(targetPosition , units)
});
contextActionSet.addContextAction(this, "carpet-bomb", "Carpet bombing", "Click on a point to execute a carpet bombing attack", faQuestionCircle, (units: Unit[], targetUnit: Unit | null, targetPosition: LatLng | null) => {
contextActionSet.addContextAction(this, "carpet-bomb", "Carpet bombing", "Click on a point to execute a carpet bombing attack", faXmarksLines, (units: Unit[], targetUnit: Unit | null, targetPosition: LatLng | null) => {
if (targetPosition)
getApp().getUnitsManager().carpetBomb(targetPosition , units)
});
@@ -1603,35 +1604,35 @@ export class GroundUnit extends Unit {
appendContextActions(contextActionSet: ContextActionSet) {
/* Context actions to be executed immediately */
contextActionSet.addContextAction(this, "group-ground", "Group ground units", "Create a group of ground units", olIconsGroupGround, (units: Unit[], targetUnit: Unit | null, targetPosition: LatLng | null) => {
contextActionSet.addContextAction(this, "group-ground", "Group ground units", "Create a group of ground units", faPeopleGroup, (units: Unit[], targetUnit: Unit | null, targetPosition: LatLng | null) => {
getApp().getUnitsManager().createGroup(units)
}, { executeImmediately: true });
contextActionSet.addContextAction(this, "center-map", "Center map", "Center the map on the unit and follow it", faQuestionCircle, (units: Unit[]) => {
contextActionSet.addContextAction(this, "center-map", "Center map", "Center the map on the unit and follow it", faMapLocation, (units: Unit[]) => {
getApp().getMap().centerOnUnit(units[0]);
}, { executeImmediately: true });
if (this.canAAA()) {
contextActionSet.addContextAction(this, "scenic-aaa", "Scenic AAA", "Shoot AAA in the air without aiming at any target, when an enemy unit gets close enough. WARNING: works correctly only on neutral units, blue or red units will aim", faQuestionCircle, (units: Unit[]) => {
contextActionSet.addContextAction(this, "scenic-aaa", "Scenic AAA", "Shoot AAA in the air without aiming at any target, when an enemy unit gets close enough. WARNING: works correctly only on neutral units, blue or red units will aim", olButtonsContextScenicAaa, (units: Unit[]) => {
getApp().getUnitsManager().scenicAAA(units)
}, { executeImmediately: true });
contextActionSet.addContextAction(this, "miss-aaa", "Dynamic accuracy AAA", "Shoot AAA towards the closest enemy unit, but don't aim precisely. WARNING: works correctly only on neutral units, blue or red units will aim", faQuestionCircle, (units: Unit[]) => {
contextActionSet.addContextAction(this, "miss-aaa", "Dynamic accuracy AAA", "Shoot AAA towards the closest enemy unit, but don't aim precisely. WARNING: works correctly only on neutral units, blue or red units will aim", olButtonsContextMissOnPurpose, (units: Unit[]) => {
getApp().getUnitsManager().missOnPurpose(units)
}, { executeImmediately: true });
}
/* Context actions that require a target unit */
contextActionSet.addContextAction(this, "attack", "Attack unit", "Click on a unit to attack it", faQuestionCircle, (units: Unit[], targetUnit: Unit | null, targetPosition: LatLng | null) => {
contextActionSet.addContextAction(this, "attack", "Attack unit", "Click on a unit to attack it", olStatesAttack, (units: Unit[], targetUnit: Unit | null, targetPosition: LatLng | null) => {
if (targetUnit)
getApp().getUnitsManager().attackUnit(targetUnit.ID, units)
});
/* Context actions that require a target position */
if (this.canTargetPoint()) {
contextActionSet.addContextAction(this, "fire-at-area", "Fire at area", "Click on a point to precisely fire at it (if possible)", faQuestionCircle, (units: Unit[], targetUnit: Unit | null, targetPosition: LatLng | null) => {
contextActionSet.addContextAction(this, "fire-at-area", "Fire at area", "Click on a point to precisely fire at it (if possible)", faLocationCrosshairs, (units: Unit[], targetUnit: Unit | null, targetPosition: LatLng | null) => {
if (targetPosition)
getApp().getUnitsManager().fireAtArea(targetPosition , units)
});
contextActionSet.addContextAction(this, "simulate-fire-fight", "Simulate fire fight", "Simulate a fire fight by shooting randomly in a certain large area. WARNING: works correctly only on neutral units, blue or red units will aim", faQuestionCircle, (units: Unit[], targetUnit: Unit | null, targetPosition: LatLng | null) => {
contextActionSet.addContextAction(this, "simulate-fire-fight", "Simulate fire fight", "Simulate a fire fight by shooting randomly in a certain large area. WARNING: works correctly only on neutral units, blue or red units will aim", olButtonsContextSimulateFireFight, (units: Unit[], targetUnit: Unit | null, targetPosition: LatLng | null) => {
if (targetPosition)
getApp().getUnitsManager().simulateFireFight(targetPosition , units)
});
@@ -1711,7 +1712,7 @@ export class NavyUnit extends Unit {
contextActionSet.addContextAction(this, "group-navy", "Group navy units", "Create a group of navy units", faQuestionCircle, (units: Unit[], targetUnit: Unit | null, targetPosition: LatLng | null) => {
getApp().getUnitsManager().createGroup(units)
}, { executeImmediately: true });
contextActionSet.addContextAction(this, "center-map", "Center map", "Center the map on the unit and follow it", faQuestionCircle, (units: Unit[]) => {
contextActionSet.addContextAction(this, "center-map", "Center map", "Center the map on the unit and follow it", faMapLocation, (units: Unit[]) => {
getApp().getMap().centerOnUnit(units[0]);
}, { executeImmediately: true });