mirror of
https://github.com/Pax1601/DCSOlympus.git
synced 2025-10-29 16:56:34 +00:00
Started to add advanced RTS options to backend
This commit is contained in:
parent
4ae72b7c0b
commit
8ffd5ef972
@ -64,27 +64,29 @@ export class MissionHandler {
|
||||
}
|
||||
|
||||
updateMission(data: MissionData) {
|
||||
if (data.mission.theatre != this.#theatre) {
|
||||
this.#theatre = data.mission.theatre;
|
||||
getMap().setTheatre(this.#theatre);
|
||||
getInfoPopup().setText("Map set to " + this.#theatre);
|
||||
}
|
||||
if (data.mission) {
|
||||
if (data.mission.theatre != this.#theatre) {
|
||||
this.#theatre = data.mission.theatre;
|
||||
getMap().setTheatre(this.#theatre);
|
||||
getInfoPopup().setText("Map set to " + this.#theatre);
|
||||
}
|
||||
|
||||
this.#dateAndTime = data.mission.dateAndTime;
|
||||
this.#dateAndTime = data.mission.dateAndTime;
|
||||
|
||||
this.#setRTSOptions(data.mission.RTSOptions);
|
||||
getUnitsManager().setCommandMode(this.#RTSOptions.commandMode);
|
||||
this.#setRTSOptions(data.mission.RTSOptions);
|
||||
getUnitsManager().setCommandMode(this.#RTSOptions.commandMode);
|
||||
|
||||
this.#remainingSetupTime = this.#RTSOptions.setupTime - this.getDateAndTime().elapsedTime;
|
||||
var RTSPhaseEl = document.querySelector("#rts-phase") as HTMLElement;
|
||||
if (RTSPhaseEl) {
|
||||
if (this.#remainingSetupTime > 0) {
|
||||
var remainingTime = `-${new Date(this.#remainingSetupTime * 1000).toISOString().substring(14, 19)}`;
|
||||
RTSPhaseEl.dataset.remainingTime = remainingTime;
|
||||
}
|
||||
|
||||
RTSPhaseEl.classList.toggle("setup-phase", this.#remainingSetupTime > 0);
|
||||
RTSPhaseEl.classList.toggle("game-commenced", this.#remainingSetupTime <= 0);
|
||||
this.#remainingSetupTime = this.#RTSOptions.setupTime - this.getDateAndTime().elapsedTime;
|
||||
var RTSPhaseEl = document.querySelector("#rts-phase") as HTMLElement;
|
||||
if (RTSPhaseEl) {
|
||||
if (this.#remainingSetupTime > 0) {
|
||||
var remainingTime = `-${new Date(this.#remainingSetupTime * 1000).toISOString().substring(14, 19)}`;
|
||||
RTSPhaseEl.dataset.remainingTime = remainingTime;
|
||||
}
|
||||
|
||||
RTSPhaseEl.classList.toggle("setup-phase", this.#remainingSetupTime > 0);
|
||||
RTSPhaseEl.classList.toggle("game-commenced", this.#remainingSetupTime <= 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -847,9 +847,9 @@ function Olympus.setMissionData(arg, time)
|
||||
local mission = {}
|
||||
mission.theatre = env.mission.theatre
|
||||
mission.dateAndTime = {
|
||||
["elapsedTime"] = DCS.getRealTime()
|
||||
["time"] = mist.time.getDHMS(timer.getAbsTime())
|
||||
["startTime"] = env.mission.start_time
|
||||
["elapsedTime"] = DCS.getRealTime() - env.mission.start_time,
|
||||
["time"] = mist.time.getDHMS(timer.getAbsTime()),
|
||||
["startTime"] = env.mission.start_time,
|
||||
["date"] = env.mission.date
|
||||
}
|
||||
|
||||
|
||||
@ -13,13 +13,33 @@ public:
|
||||
void execute(lua_State* L);
|
||||
void handleRequest(string key, json::value value);
|
||||
|
||||
int getLoad();
|
||||
void setFrameRate(double newFrameRate) { frameRate = newFrameRate; }
|
||||
void setRestrictSpawns(bool newRestrictSpawns) { restrictSpawns = newRestrictSpawns; }
|
||||
void setRestrictToCoalition(bool newRestrictToCoalition) { restrictSpawns = newRestrictToCoalition; }
|
||||
void setSetupTime(unsigned int newSetupTime) { setupTime = newSetupTime; }
|
||||
void setBlueSpawnPoints(unsigned int newBlueSpawnPoints) { blueSpawnPoints = newBlueSpawnPoints; }
|
||||
void setRedSpawnPoints(unsigned int newRedSpawnPoints) { redSpawnPoints = newRedSpawnPoints; }
|
||||
void setEras(vector<string> newEras) { eras = newEras; }
|
||||
|
||||
int getFrameRate() { return frameRate; };
|
||||
|
||||
int getLoad();
|
||||
bool getRestrictSpawns() { return restrictSpawns; }
|
||||
bool getRestrictToCoalition() { return restrictSpawns; }
|
||||
unsigned int getSetupTime() { return setupTime; }
|
||||
unsigned int getBlueSpawnPoints() { return blueSpawnPoints; }
|
||||
unsigned int getRedSpawnPoints() { return redSpawnPoints; }
|
||||
vector<string> getEras() { return eras; }
|
||||
|
||||
private:
|
||||
list<Command*> commands;
|
||||
unsigned int load;
|
||||
double frameRate;
|
||||
|
||||
bool restrictSpawns = false;
|
||||
bool restrictToCoalition = false;
|
||||
unsigned int setupTime = 300;
|
||||
unsigned int blueSpawnPoints = 10000;
|
||||
unsigned int redSpawnPoints = 10000;
|
||||
vector<string> eras = { "WW2", "Early Cold War", "Mid Cold War", "Late Cold War", "Modern" };
|
||||
};
|
||||
|
||||
|
||||
@ -11,6 +11,8 @@ Scheduler::Scheduler(lua_State* L) :
|
||||
load(0)
|
||||
{
|
||||
LogInfo(L, "Scheduler constructor called successfully");
|
||||
|
||||
|
||||
}
|
||||
|
||||
Scheduler::~Scheduler()
|
||||
|
||||
@ -109,19 +109,31 @@ void Server::handle_get(http_request request)
|
||||
getLogsJSON(logs, time);
|
||||
answer[L"logs"] = logs;
|
||||
}
|
||||
|
||||
else if (URI.compare(AIRBASES_URI) == 0 && missionData.has_object_field(L"airbases"))
|
||||
answer[L"airbases"] = missionData[L"airbases"];
|
||||
else if (URI.compare(BULLSEYE_URI) == 0 && missionData.has_object_field(L"bullseyes"))
|
||||
answer[L"bullseyes"] = missionData[L"bullseyes"];
|
||||
else if (URI.compare(MISSION_URI) == 0 && missionData.has_object_field(L"mission")) {
|
||||
answer[L"mission"] = missionData[L"mission"];
|
||||
answer[L"mission"][L"RTSOptions"] = json::value::object();
|
||||
if (password.compare(gameMasterPassword) == 0)
|
||||
answer[L"mission"][L"commandMode"] = json::value(L"Game master");
|
||||
answer[L"mission"][L"RTSOptions"][L"commandMode"] = json::value(L"Game master");
|
||||
else if (password.compare(blueCommanderPassword) == 0)
|
||||
answer[L"mission"][L"commandMode"] = json::value(L"Blue commander");
|
||||
answer[L"mission"][L"RTSOptions"][L"commandMode"] = json::value(L"Blue commander");
|
||||
else if (password.compare(redCommanderPassword) == 0)
|
||||
answer[L"mission"][L"commandMode"] = json::value(L"Red commander");
|
||||
answer[L"mission"][L"RTSOptions"][L"commandMode"] = json::value(L"Red commander");
|
||||
|
||||
answer[L"mission"][L"RTSOptions"][L"restrictSpawns"] = json::value(scheduler->getRestrictSpawns());
|
||||
answer[L"mission"][L"RTSOptions"][L"restrictToCoalition"] = json::value(scheduler->getRestrictToCoalition());
|
||||
answer[L"mission"][L"RTSOptions"][L"setupTime"] = json::value(scheduler->getSetupTime());
|
||||
answer[L"mission"][L"RTSOptions"][L"spawnPoints"] = json::value::object();
|
||||
answer[L"mission"][L"RTSOptions"][L"spawnPoints"][L"blue"] = json::value(scheduler->getBlueSpawnPoints());
|
||||
answer[L"mission"][L"RTSOptions"][L"spawnPoints"][L"red"] = json::value(scheduler->getRedSpawnPoints());
|
||||
|
||||
int idx = 0;
|
||||
answer[L"mission"][L"RTSOptions"][L"eras"] = json::value::array();
|
||||
for (string era : scheduler->getEras())
|
||||
answer[L"mission"][L"RTSOptions"][L"eras"].as_array()[idx++] = json::value(to_wstring(era));
|
||||
}
|
||||
|
||||
answer[L"time"] = json::value::string(to_wstring(ms.count()));
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user