From 38a89c66ee04cb81e67610aa6041a69824cf1046 Mon Sep 17 00:00:00 2001 From: James Packer Date: Sun, 9 Aug 2026 17:06:31 +0100 Subject: [PATCH 1/5] Allow changing the simulation time, initially with the 8 and 9 number buttons, for main Bridge Command and multiplayer hub. --- src/MyEventReceiver.cpp | 6 ++++++ src/OtherShip.cpp | 7 +++++++ src/OtherShip.hpp | 1 + src/OtherShips.cpp | 7 +++++++ src/OtherShips.hpp | 1 + src/SimulationModel.cpp | 6 ++++++ src/SimulationModel.hpp | 1 + src/multiplayerHub/EventReceiver.cpp | 14 +++++++++++++- src/multiplayerHub/EventReceiver.hpp | 2 ++ src/multiplayerHub/main.cpp | 4 ++++ 10 files changed, 48 insertions(+), 1 deletion(-) diff --git a/src/MyEventReceiver.cpp b/src/MyEventReceiver.cpp index 1362c22fa..335d4bf51 100644 --- a/src/MyEventReceiver.cpp +++ b/src/MyEventReceiver.cpp @@ -1024,6 +1024,12 @@ bool MyEventReceiver::OnEvent(const irr::SEvent &event) case irr::KEY_KEY_H: model->startHorn(); break; + case irr::KEY_KEY_8: + model->changeTime(-3600); + break; + case irr::KEY_KEY_9: + model->changeTime(3600); + break; // DEE_NOV22 vvvvv diff --git a/src/OtherShip.cpp b/src/OtherShip.cpp index efe8da2b8..92453e2c9 100644 --- a/src/OtherShip.cpp +++ b/src/OtherShip.cpp @@ -418,6 +418,13 @@ void OtherShip::resetLegs(irr::f32 course, irr::f32 speedKts, irr::f32 distanceN legs.push_back(stopLeg); } +void OtherShip::offsetLegTimes(irr::f32 deltaTime) +{ + for (std::vector::iterator it = legs.begin(); it != legs.end(); ++it) { + it->startTime += deltaTime; + } +} + void OtherShip::setRateOfTurn(irr::f32 rateOfTurn) //Sets the rate of turn (only used in multiplayer mode) { this->rateOfTurn = rateOfTurn; diff --git a/src/OtherShip.hpp b/src/OtherShip.hpp index ba8d2a279..050ced6a5 100644 --- a/src/OtherShip.hpp +++ b/src/OtherShip.hpp @@ -46,6 +46,7 @@ class OtherShip : public Ship void addLeg(int afterLegNumber, irr::f32 bearing, irr::f32 speed, irr::f32 distance, irr::f32 scenarioTime); void deleteLeg(int legNumber, irr::f32 scenarioTime); void resetLegs(irr::f32 course, irr::f32 speedKts, irr::f32 distanceNm, irr::f32 scenarioTime); + void offsetLegTimes(irr::f32 deltaTime); RadarData getRadarData(irr::core::vector3df scannerPosition) const; void update(irr::f32 deltaTime, irr::f32 scenarioTime, irr::f32 tideHeight, irr::u32 lightLevel); void enableTriangleSelector(bool selectorEnabled); diff --git a/src/OtherShips.cpp b/src/OtherShips.cpp index 53b061049..4e0282ff5 100644 --- a/src/OtherShips.cpp +++ b/src/OtherShips.cpp @@ -336,3 +336,10 @@ void OtherShips::moveNode(irr::f32 deltaX, irr::f32 deltaY, irr::f32 deltaZ) (*it)->moveNode(deltaX,deltaY,deltaZ); } } + +void OtherShips::offsetLegTimes(irr::f32 deltaTime) +{ + for (std::vector::iterator it = otherShips.begin(); it != otherShips.end(); ++it) { + (*it)->offsetLegTimes(deltaTime); + } +} diff --git a/src/OtherShips.hpp b/src/OtherShips.hpp index e8c2611c0..670dc43f1 100644 --- a/src/OtherShips.hpp +++ b/src/OtherShips.hpp @@ -61,6 +61,7 @@ class OtherShips void resetLegs(int shipNumber, irr::f32 course, irr::f32 speedKts, irr::f32 distanceNm, irr::f32 scenarioTime); std::string getName(int number) const; void moveNode(irr::f32 deltaX, irr::f32 deltaY, irr::f32 deltaZ); + void offsetLegTimes(irr::f32 deltaTime); void enableAllTriangleSelectors(); irr::scene::ISceneNode* getSceneNode(int number); diff --git a/src/SimulationModel.cpp b/src/SimulationModel.cpp index 26d6ffa68..3a20b4aae 100644 --- a/src/SimulationModel.cpp +++ b/src/SimulationModel.cpp @@ -365,6 +365,12 @@ SimulationModel::~SimulationModel() return scenarioOffsetTime; } + void SimulationModel::changeTime(irr::f32 deltaTime) { + scenarioTime += deltaTime; + // Need to update all other ship leg information to keep consistent. + otherShips.offsetLegTimes(deltaTime); + } + void SimulationModel::setTimeDelta(irr::f32 scenarioTime) { this->scenarioTime = scenarioTime; } diff --git a/src/SimulationModel.hpp b/src/SimulationModel.hpp index 4a6c0b2c3..b890d3b28 100644 --- a/src/SimulationModel.hpp +++ b/src/SimulationModel.hpp @@ -179,6 +179,7 @@ class SimulationModel //Start of the 'Model' part of MVC //void getDate(irr::u8& day, irr::u8& month, irr::u16& year) const; uint64_t getTimestamp() const; //The unix timestamp in s uint64_t getTimeOffset() const; //The timestamp at the start of the first day of the scenario + void changeTime(irr::f32 deltaTime); // Change the scenario time, without affecting other ship movements irr::f32 getTimeDelta() const; //The change in time (s) since the start of the start day of the scenario void setTimeDelta(irr::f32 scenarioTime); diff --git a/src/multiplayerHub/EventReceiver.cpp b/src/multiplayerHub/EventReceiver.cpp index d6effb3b5..3406e6cc4 100644 --- a/src/multiplayerHub/EventReceiver.cpp +++ b/src/multiplayerHub/EventReceiver.cpp @@ -22,6 +22,7 @@ irr::f32 initialAccelerator) //Constructor { accelerator = initialAccelerator; + timeShift = 0; this->pauseButtonID = pauseButtonID; this->runButtonID = runButtonID; } @@ -45,7 +46,11 @@ { accelerator = 0; } else if ((event.KeyInput.Key==irr::KEY_KEY_0) || (event.KeyInput.Key == irr::KEY_RETURN)) { - accelerator = 1; + accelerator = 1; + } else if (event.KeyInput.Key == irr::KEY_KEY_8) { + timeShift = -3600; + } else if (event.KeyInput.Key == irr::KEY_KEY_9) { + timeShift = 3600; } } return false; @@ -54,4 +59,11 @@ irr::f32 EventReceiver::getAccelerator() const { return accelerator; + } + + irr::f32 EventReceiver::getAndResetTimeShift() + { + irr::f32 returnValue = timeShift; + timeShift = 0; + return returnValue; } \ No newline at end of file diff --git a/src/multiplayerHub/EventReceiver.hpp b/src/multiplayerHub/EventReceiver.hpp index 94e89c580..0d6c84e81 100644 --- a/src/multiplayerHub/EventReceiver.hpp +++ b/src/multiplayerHub/EventReceiver.hpp @@ -30,10 +30,12 @@ class EventReceiver : public irr::IEventReceiver bool OnEvent(const irr::SEvent& event); irr::f32 getAccelerator() const; + irr::f32 getAndResetTimeShift(); private: irr::f32 accelerator; + irr::f32 timeShift; irr::s32 pauseButtonID; irr::s32 runButtonID; diff --git a/src/multiplayerHub/main.cpp b/src/multiplayerHub/main.cpp index 3eb64d028..e49394c3d 100644 --- a/src/multiplayerHub/main.cpp +++ b/src/multiplayerHub/main.cpp @@ -360,6 +360,10 @@ int main() // Find current time acceleration accelerator = eventReceiver.getAccelerator(); + // Apply a time shift if requrested by the event receiver + irr::f32 timeShift = eventReceiver.getAndResetTimeShift(); + scenarioTime += timeShift; + //Do time handling here. currentTime = std::chrono::system_clock::now(); std::chrono::duration elapsedTime = currentTime-previousTime; From 3d8459ac43fb6e613ea8b6fe11a291028461c76f Mon Sep 17 00:00:00 2001 From: James Packer Date: Sun, 9 Aug 2026 17:18:24 +0100 Subject: [PATCH 2/5] Avoid light problems if scenarioTime becomes negative. --- src/Constants.hpp | 3 ++- src/Light.cpp | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Constants.hpp b/src/Constants.hpp index 29710825e..69bdb7199 100644 --- a/src/Constants.hpp +++ b/src/Constants.hpp @@ -32,7 +32,8 @@ const irr::f32 VIEW_PROPORTION_3D = 0.6; //units conversions const irr::f32 SECONDS_IN_HOUR = 3600.0; -const irr::f32 SECONDS_IN_DAY = SECONDS_IN_HOUR * 24; +const irr::f32 HOURS_IN_DAY = 24.0; +const irr::f32 SECONDS_IN_DAY = SECONDS_IN_HOUR * HOURS_IN_DAY; const irr::f32 M_IN_NM = 1852.0; const irr::f32 KTS_TO_MPS = M_IN_NM/SECONDS_IN_HOUR; const irr::f32 MPS_TO_KTS = SECONDS_IN_HOUR/M_IN_NM; diff --git a/src/Light.cpp b/src/Light.cpp index 0bfd0512a..1715015c8 100644 --- a/src/Light.cpp +++ b/src/Light.cpp @@ -62,6 +62,9 @@ void Light::update(irr::f32 scenarioTime) { //convert scenario time (in seconds) into hours irr::f32 hourTime = std::fmod(scenarioTime,SECONDS_IN_DAY)/SECONDS_IN_HOUR; + while (hourTime < 0) { + hourTime += HOURS_IN_DAY; + } //Light parameters irr::s32 lightLow=50; From 00fe32c0e0f8209d8cc03f2dab26216f9b8dbd48 Mon Sep 17 00:00:00 2001 From: James Packer Date: Tue, 11 Aug 2026 08:12:57 +0100 Subject: [PATCH 3/5] Allow map controller to change time of day. --- bin/languageController-en.txt | 3 +++ bin/languageController-es.txt | 3 +++ bin/languageController-fr.txt | 3 +++ src/NetworkPrimary.cpp | 7 +++++++ src/controller/EventReceiver.cpp | 19 +++++++++++++++++++ src/controller/GUI.cpp | 4 ++++ src/controller/GUI.hpp | 4 +++- 7 files changed, 42 insertions(+), 1 deletion(-) diff --git a/bin/languageController-en.txt b/bin/languageController-en.txt index 904be1bd1..8023567f9 100644 --- a/bin/languageController-en.txt +++ b/bin/languageController-en.txt @@ -91,3 +91,6 @@ multiplayerinfo="Editing a multiplayer scenario:\n\nThe 'own ship' entry will be multiplayerNeedsMP="Multiplayer scenario name must end in _mp" nonMultiplayerNoMP="Non-multiplayer scenario name must not end in _mp" +shiftTimeForward="Change time of day later" +shiftTimeBackward="Change time of day earlier" + diff --git a/bin/languageController-es.txt b/bin/languageController-es.txt index 45fa6f899..9cd529c71 100644 --- a/bin/languageController-es.txt +++ b/bin/languageController-es.txt @@ -90,3 +90,6 @@ multiplayer="¿Modo multijugador?" multiplayerinfo="Editar un escenario multijugador: \n\nEl menú 'Tu buque' será ignorado. Cada 'Otro buque' será utilizado en orden por los clientes multijugador como su buque. Añade una ruta para cada buque para establecer la velocidad inicial y el rumbo." multiplayerNeedsMP="El nombre de los escenario multijugador debe terminar por "_mp"" nonMultiplayerNoMP="El nombre de los escenario que NO son multijugador NO debe terminar por '_mp'" + +shiftTimeForward="Adelantar la hora del día" +shiftTimeBackward="Retroceder la hora del día" diff --git a/bin/languageController-fr.txt b/bin/languageController-fr.txt index e1b93eb19..42ef9eb9b 100644 --- a/bin/languageController-fr.txt +++ b/bin/languageController-fr.txt @@ -90,3 +90,6 @@ multiplayer="Mode multijoueurs ?" multiplayerinfo="Edition d'un scénario multijoueurs :\n\nL'entrée 'Votre navire' sera ignorée.\n\nChaque 'autre navire' est utilisé dans l'ordre par les clients multijoueurs comme leur navire. Ajoutez un itinéraire pour chaque navire pour paramétrer la vitesse et le cap initiaux." multiplayerNeedsMP="Le nom du scénario multijoueurs doit se terminer par _mp" nonMultiplayerNoMP="Le scénario non multijoueurs ne doit pas se terminer par _mp" + +shiftTimeForward="Avancer l'heure de la journée" +shiftTimeBackward="Reculer l'heure de la journée" diff --git a/src/NetworkPrimary.cpp b/src/NetworkPrimary.cpp index aad2e658f..07ef75975 100644 --- a/src/NetworkPrimary.cpp +++ b/src/NetworkPrimary.cpp @@ -411,6 +411,13 @@ void NetworkPrimary::receiveNetwork() } model->setOtherShipSARTOn(shipNo, sartStatus); } + } else if (thisCommand.substr(0, 2).compare("CT") == 0) { + //'CT', Change time + std::vector parts = Utilities::split(thisCommand, ','); //Split into parts, 1st is command itself, 2nd and greater is the data + if (parts.size() == 2) { + irr::f32 timeChange = Utilities::lexical_cast(parts.at(1)); + model->changeTime(timeChange); + } } diff --git a/src/controller/EventReceiver.cpp b/src/controller/EventReceiver.cpp index e55abc1b7..51315613e 100644 --- a/src/controller/EventReceiver.cpp +++ b/src/controller/EventReceiver.cpp @@ -195,6 +195,16 @@ network->setStringToSend(messageToSend); } + if (id == GUIMain::GUI_ID_TIMEFORWARD_BUTTON) { + std::string messageToSend = "MCCT,3600#"; + network->setStringToSend(messageToSend); + } + + if (id == GUIMain::GUI_ID_TIMEBACKWARD_BUTTON) { + std::string messageToSend = "MCCT,-3600#"; + network->setStringToSend(messageToSend); + } + } if (event.GUIEvent.EventType==irr::gui::EGET_COMBO_BOX_CHANGED || event.GUIEvent.EventType==irr::gui::EGET_LISTBOX_CHANGED) { @@ -299,6 +309,15 @@ } else { //Shift and Ctrl not down + if (event.KeyInput.Key == irr::KEY_KEY_9) { + std::string messageToSend = "MCCT,3600#"; + network->setStringToSend(messageToSend); + } + + if (event.KeyInput.Key == irr::KEY_KEY_8) { + std::string messageToSend = "MCCT,-3600#"; + network->setStringToSend(messageToSend); + } } } //end of key down event diff --git a/src/controller/GUI.cpp b/src/controller/GUI.cpp index d9020d461..8e2614f71 100644 --- a/src/controller/GUI.cpp +++ b/src/controller/GUI.cpp @@ -179,6 +179,10 @@ GUIMain::GUIMain(irr::IrrlichtDevice* device, Lang* language) brightnessBar->setSmallStep(1); brightnessBar->setPos(100); + //Add buttons to allow user to change scenario time + guienv->addButton(irr::core::rect(15.0 * fw, 1 * fh, 35 * fw, 3.25 * fh), extraTab, GUI_ID_TIMEFORWARD_BUTTON, language->translate("shiftTimeForward").c_str()); + guienv->addButton(irr::core::rect(15.0 * fw, 3.25 * fh, 35 * fw, 5.5 * fh), extraTab, GUI_ID_TIMEBACKWARD_BUTTON, language->translate("shiftTimeBackward").c_str()); + //This is used to track when the edit boxes need updating, when ship or legs have changed editBoxesNeedUpdating = false; diff --git a/src/controller/GUI.hpp b/src/controller/GUI.hpp index 47b9a5e66..adefd99cf 100644 --- a/src/controller/GUI.hpp +++ b/src/controller/GUI.hpp @@ -68,7 +68,9 @@ class GUIMain //Create, build and update GUI GUI_ID_STREAMDIRECTION_SCROLL_BAR, GUI_ID_STREAMSPEED_SCROLL_BAR, GUI_ID_STREAMOVERRIDE_BOX, - GUI_ID_BRIGHTNESS_SCROLLBAR + GUI_ID_BRIGHTNESS_SCROLLBAR, + GUI_ID_TIMEFORWARD_BUTTON, + GUI_ID_TIMEBACKWARD_BUTTON }; void updateGuiData(irr::f32 time, irr::s32 mapOffsetX, irr::s32 mapOffsetZ, irr::f32 metresPerPx, irr::f32 ownShipPosX, irr::f32 ownShipPosZ, irr::f32 ownShipHeading, const std::vector& buoys, const std::vector& otherShips, const std::vector& aisData, bool mobVisible, irr::f32 mobPosX, irr::f32 mobPosZ, irr::video::ITexture* displayMapTexture, irr::s32 selectedShip, irr::s32 selectedLeg, irr::f32 terrainLong, irr::f32 terrainLongExtent, irr::f32 terrainXWidth, irr::f32 terrainLat, irr::f32 terrainLatExtent, irr::f32 terrainZWidth, irr::f32 weather, irr::f32 visibility, irr::f32 rain, irr::f32 windDirection, irr::f32 windSpeed, irr::f32 streamDirection, irr::f32 streamSpeed, bool streamOverride); From 33134faf058c499fc06bd49b25b6b11d2f7c3237 Mon Sep 17 00:00:00 2001 From: James Packer Date: Tue, 11 Aug 2026 08:29:44 +0100 Subject: [PATCH 4/5] Add time shift buttons to the multiplayer controller --- bin/languageMultiplayer-en.txt | 3 ++- bin/languageMultiplayer-es.txt | 2 ++ bin/languageMultiplayer-fr.txt | 2 ++ src/multiplayerHub/EventReceiver.cpp | 8 ++++++++ src/multiplayerHub/EventReceiver.hpp | 4 ++++ src/multiplayerHub/main.cpp | 12 ++++++++---- 6 files changed, 26 insertions(+), 5 deletions(-) diff --git a/bin/languageMultiplayer-en.txt b/bin/languageMultiplayer-en.txt index e17a491f5..57a9b0ac4 100644 --- a/bin/languageMultiplayer-en.txt +++ b/bin/languageMultiplayer-en.txt @@ -14,4 +14,5 @@ heading="Heading" startupInstructions="Please ensure each player has started Bridge Command first, then start the scenario by clicking OK below." run="Run" pause="Pause" - +shiftTimeForward="Change time of day later" +shiftTimeBackward="Change time of day earlier" \ No newline at end of file diff --git a/bin/languageMultiplayer-es.txt b/bin/languageMultiplayer-es.txt index c757cf842..9bdc36c3f 100644 --- a/bin/languageMultiplayer-es.txt +++ b/bin/languageMultiplayer-es.txt @@ -14,3 +14,5 @@ heading="Rumbo" startupInstructions="Asegurese de que cada jugador a iniciado Bridge Command. Después, inicie el escenario haciendo click sobre OK." run="Empezar" pause="Pausa" +shiftTimeForward="Adelantar la hora del día" +shiftTimeBackward="Retroceder la hora del día" diff --git a/bin/languageMultiplayer-fr.txt b/bin/languageMultiplayer-fr.txt index 02bac6125..f26341168 100644 --- a/bin/languageMultiplayer-fr.txt +++ b/bin/languageMultiplayer-fr.txt @@ -14,3 +14,5 @@ heading="Cap" startupInstructions="Veuillez vous assurer que chaque joueur a démarré Bridge Command, puis démarrez le scénario en cliquant sur OK ci-dessous." run="Demarrer" pause="Pause" +shiftTimeForward="Avancer l'heure de la journée" +shiftTimeBackward="Reculer l'heure de la journée" diff --git a/src/multiplayerHub/EventReceiver.cpp b/src/multiplayerHub/EventReceiver.cpp index 3406e6cc4..a59859978 100644 --- a/src/multiplayerHub/EventReceiver.cpp +++ b/src/multiplayerHub/EventReceiver.cpp @@ -19,12 +19,16 @@ EventReceiver::EventReceiver( irr::s32 pauseButtonID, irr::s32 runButtonID, + irr::s32 timeForwardButtonID, + irr::s32 timeBackwardButtonID, irr::f32 initialAccelerator) //Constructor { accelerator = initialAccelerator; timeShift = 0; this->pauseButtonID = pauseButtonID; this->runButtonID = runButtonID; + this->timeForwardButtonID = timeForwardButtonID; + this->timeBackwardButtonID = timeBackwardButtonID; } bool EventReceiver::OnEvent(const irr::SEvent& event) @@ -37,6 +41,10 @@ accelerator = 0; } else if (id == runButtonID) { accelerator = 1; + } else if (id == timeForwardButtonID) { + timeShift = 3600; + } else if (id == timeBackwardButtonID) { + timeShift = -3600; } } } diff --git a/src/multiplayerHub/EventReceiver.hpp b/src/multiplayerHub/EventReceiver.hpp index 0d6c84e81..56e2e2e4f 100644 --- a/src/multiplayerHub/EventReceiver.hpp +++ b/src/multiplayerHub/EventReceiver.hpp @@ -26,6 +26,8 @@ class EventReceiver : public irr::IEventReceiver EventReceiver( irr::s32 pauseButtonID, irr::s32 runButtonID, + irr::s32 timeForwardButtonID, + irr::s32 timeBackwardButtonID, irr::f32 initialAccelerator); bool OnEvent(const irr::SEvent& event); @@ -38,6 +40,8 @@ class EventReceiver : public irr::IEventReceiver irr::f32 timeShift; irr::s32 pauseButtonID; irr::s32 runButtonID; + irr::s32 timeForwardButtonID; + irr::s32 timeBackwardButtonID; }; diff --git a/src/multiplayerHub/main.cpp b/src/multiplayerHub/main.cpp index e49394c3d..3204e1165 100644 --- a/src/multiplayerHub/main.cpp +++ b/src/multiplayerHub/main.cpp @@ -299,14 +299,18 @@ int main() irr::u32 sh = driver->getScreenSize().Height; irr::gui::IGUIStaticText* text = device->getGUIEnvironment()->addStaticText(L"",irr::core::rect(0.01*su,0.01*sh,0.99*su,0.74*sh),true); - // Add run and pause buttons + // Add run, pause and time shift buttons irr::s32 runButtonID = 101; irr::s32 pauseButtonID = 102; - irr::gui::IGUIButton* runButton = device->getGUIEnvironment()->addButton(irr::core::rect(0.01*su,0.76*sh,0.49*su,0.99*sh), 0, runButtonID, language.translate("run").c_str()); - irr::gui::IGUIButton* pauseButton = device->getGUIEnvironment()->addButton(irr::core::rect(0.51*su,0.76*sh,0.99*su,0.99*sh), 0, pauseButtonID, language.translate("pause").c_str()); + irr::s32 timeForwardButtonID = 103; + irr::s32 timeBackwardButtonID = 104; + device->getGUIEnvironment()->addButton(irr::core::rect(0.01*su,0.76*sh,0.49*su,0.87*sh), 0, runButtonID, language.translate("run").c_str()); + device->getGUIEnvironment()->addButton(irr::core::rect(0.51*su,0.76*sh,0.99*su,0.87*sh), 0, pauseButtonID, language.translate("pause").c_str()); + device->getGUIEnvironment()->addButton(irr::core::rect(0.01 * su, 0.88 * sh, 0.49 * su, 0.99 * sh), 0, timeForwardButtonID, language.translate("shiftTimeForward").c_str()); + device->getGUIEnvironment()->addButton(irr::core::rect(0.51 * su, 0.88 * sh, 0.99 * su, 0.99 * sh), 0, timeBackwardButtonID, language.translate("shiftTimeBackward").c_str()); // Setup event receiver - EventReceiver eventReceiver(pauseButtonID, runButtonID, accelerator); + EventReceiver eventReceiver(pauseButtonID, runButtonID, timeForwardButtonID, timeBackwardButtonID, accelerator); device->setEventReceiver(&eventReceiver); //Fixme: Think about time zone handling From e3e6be30a88ef9055a3fad5ccffc75f19384f172 Mon Sep 17 00:00:00 2001 From: James Packer Date: Tue, 11 Aug 2026 17:56:12 +0100 Subject: [PATCH 5/5] Add time change (and time compression) buttons in Bridge Command, in Extra Controls/Time. --- bin/language-en.txt | 5 +++++ bin/language-es.txt | 5 +++++ bin/language-fr.txt | 5 +++++ src/GUIMain.cpp | 14 ++++++++++++ src/GUIMain.hpp | 12 +++++++++- src/MyEventReceiver.cpp | 50 +++++++++++++++++++++++++++++++++++++++++ 6 files changed, 90 insertions(+), 1 deletion(-) diff --git a/bin/language-en.txt b/bin/language-en.txt index 908efffce..e8c2ba14b 100644 --- a/bin/language-en.txt +++ b/bin/language-en.txt @@ -116,6 +116,11 @@ collided="YOU ARE IN COLLISION!" showinterface="Show" hideinterface="Hide" +time="Time" +pause="Pause" +shiftTimeForward="Change time later" +shiftTimeBackward="Change time earlier" + exit="Exit" log="!" diff --git a/bin/language-es.txt b/bin/language-es.txt index 60d76484e..02cb61797 100644 --- a/bin/language-es.txt +++ b/bin/language-es.txt @@ -116,6 +116,11 @@ collided="¡COLISIÓN!" showinterface="Mostrar" hideinterface="Ocultar" +time="Tiempo" +pause="Pausa" +shiftTimeForward="Adelantar la hora" +shiftTimeBackward="Retroceder la hora" + exit="Salir" log="!" diff --git a/bin/language-fr.txt b/bin/language-fr.txt index 6cedd3f2d..47312598c 100644 --- a/bin/language-fr.txt +++ b/bin/language-fr.txt @@ -116,6 +116,11 @@ collided="COLLISION !" showinterface="Afficher" hideinterface="Cacher" +time="Temps" +pause="Pause" +shiftTimeForward="Avancer l'heure" +shiftTimeBackward="Reculer l'heure" + exit="Quitter" log="!" diff --git a/src/GUIMain.cpp b/src/GUIMain.cpp index cbf84dab3..90238549a 100644 --- a/src/GUIMain.cpp +++ b/src/GUIMain.cpp @@ -475,6 +475,20 @@ void GUIMain::load(irr::IrrlichtDevice* device, Lang* language, std::vectorsetSmallStep(5); magnificationScrollbar->setPos(1.0 * 10); // Initialise as 1x zoom + //Add extra controls for time (compression and time of day) + irr::gui::IGUITab* extraControlsTabTime = extraControlsTabControl->addTab(language->translate("time").c_str()); + guienv->addButton(irr::core::rect(0.005 * su, 0.010 * sh, 0.16 * su, 0.035 * sh), extraControlsTabTime, GUI_ID_TIMECOMPRESSION_0_BUTTON, language->translate("pause").c_str()); + guienv->addButton(irr::core::rect(0.005 * su, 0.035 * sh, 0.16 * su, 0.060 * sh), extraControlsTabTime, GUI_ID_TIMECOMPRESSION_1_BUTTON, L"1:1"); + guienv->addButton(irr::core::rect(0.005 * su, 0.060 * sh, 0.16 * su, 0.085 * sh), extraControlsTabTime, GUI_ID_TIMECOMPRESSION_2_BUTTON, L"2:1"); + guienv->addButton(irr::core::rect(0.005 * su, 0.085 * sh, 0.16 * su, 0.110 * sh), extraControlsTabTime, GUI_ID_TIMECOMPRESSION_5_BUTTON, L"5:1"); + guienv->addButton(irr::core::rect(0.005 * su, 0.110 * sh, 0.16 * su, 0.135 * sh), extraControlsTabTime, GUI_ID_TIMECOMPRESSION_15_BUTTON, L"15:1"); + + guienv->addButton(irr::core::rect(0.165 * su, 0.010 * sh, 0.325 * su, 0.035 * sh), extraControlsTabTime, GUI_ID_TIMECOMPRESSION_30_BUTTON, L"30:1"); + guienv->addButton(irr::core::rect(0.165 * su, 0.035 * sh, 0.325 * su, 0.060 * sh), extraControlsTabTime, GUI_ID_TIMECOMPRESSION_60_BUTTON, L"60:1"); + guienv->addButton(irr::core::rect(0.165 * su, 0.060 * sh, 0.325 * su, 0.085 * sh), extraControlsTabTime, GUI_ID_TIMECOMPRESSION_3600_BUTTON, L"3600:1"); + guienv->addButton(irr::core::rect(0.165 * su, 0.085 * sh, 0.325 * su, 0.110 * sh), extraControlsTabTime, GUI_ID_TIMEFORWARD_BUTTON, language->translate("shiftTimeForward").c_str()); + guienv->addButton(irr::core::rect(0.165 * su, 0.110 * sh, 0.325 * su, 0.135 * sh), extraControlsTabTime, GUI_ID_TIMEBACKWARD_BUTTON, language->translate("shiftTimeBackward").c_str()); + //Add an additional window for lines (will normally be hidden) irr::core::rect linesWindowPos = stdDataDisplayPos; linesWindowPos.LowerRightCorner -= irr::core::position2d(0,0.03*sh); diff --git a/src/GUIMain.hpp b/src/GUIMain.hpp index 548887201..e8092db88 100644 --- a/src/GUIMain.hpp +++ b/src/GUIMain.hpp @@ -203,7 +203,17 @@ class GUIMain //Create, build and update GUI GUI_ID_LINES_LIST, GUI_ID_CHANGE_VIEW_BUTTON, GUI_ID_EXIT_BUTTON, - GUI_ID_CLOSE_BOX + GUI_ID_CLOSE_BOX, + GUI_ID_TIMEFORWARD_BUTTON, + GUI_ID_TIMEBACKWARD_BUTTON, + GUI_ID_TIMECOMPRESSION_0_BUTTON, + GUI_ID_TIMECOMPRESSION_1_BUTTON, + GUI_ID_TIMECOMPRESSION_2_BUTTON, + GUI_ID_TIMECOMPRESSION_5_BUTTON, + GUI_ID_TIMECOMPRESSION_15_BUTTON, + GUI_ID_TIMECOMPRESSION_30_BUTTON, + GUI_ID_TIMECOMPRESSION_60_BUTTON, + GUI_ID_TIMECOMPRESSION_3600_BUTTON }; bool getShowInterface() const; diff --git a/src/MyEventReceiver.cpp b/src/MyEventReceiver.cpp index 335d4bf51..eb3f54df4 100644 --- a/src/MyEventReceiver.cpp +++ b/src/MyEventReceiver.cpp @@ -721,6 +721,56 @@ bool MyEventReceiver::OnEvent(const irr::SEvent &event) model->changeView(); } + if (id == GUIMain::GUI_ID_TIMECOMPRESSION_0_BUTTON) + { + model->setAccelerator(0.0); + } + + if (id == GUIMain::GUI_ID_TIMECOMPRESSION_1_BUTTON) + { + model->setAccelerator(1.0); + } + + if (id == GUIMain::GUI_ID_TIMECOMPRESSION_2_BUTTON) + { + model->setAccelerator(2.0); + } + + if (id == GUIMain::GUI_ID_TIMECOMPRESSION_5_BUTTON) + { + model->setAccelerator(5.0); + } + + if (id == GUIMain::GUI_ID_TIMECOMPRESSION_15_BUTTON) + { + model->setAccelerator(15.0); + } + + if (id == GUIMain::GUI_ID_TIMECOMPRESSION_30_BUTTON) + { + model->setAccelerator(30.0); + } + + if (id == GUIMain::GUI_ID_TIMECOMPRESSION_60_BUTTON) + { + model->setAccelerator(60.0); + } + + if (id == GUIMain::GUI_ID_TIMECOMPRESSION_3600_BUTTON) + { + model->setAccelerator(3600.0); + } + + if (id == GUIMain::GUI_ID_TIMEFORWARD_BUTTON) + { + model->changeTime(3600); + } + + if (id == GUIMain::GUI_ID_TIMEBACKWARD_BUTTON) + { + model->changeTime(-3600); + } + } // Button clicked if (event.GUIEvent.EventType == irr::gui::EGET_COMBO_BOX_CHANGED)