diff --git a/bin/language-en.txt b/bin/language-en.txt index 908efffc..e8c2ba14 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 60d76484..02cb6179 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 6cedd3f2..47312598 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/bin/languageController-en.txt b/bin/languageController-en.txt index 904be1bd..8023567f 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 45fa6f89..9cd529c7 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 e1b93eb1..42ef9eb9 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/bin/languageMultiplayer-en.txt b/bin/languageMultiplayer-en.txt index e17a491f..57a9b0ac 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 c757cf84..9bdc36c3 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 02bac612..f2634116 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/Constants.hpp b/src/Constants.hpp index 29710825..69bdb719 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/GUIMain.cpp b/src/GUIMain.cpp index cbf84dab..90238549 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 54888720..e8092db8 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/Light.cpp b/src/Light.cpp index 0bfd0512..1715015c 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; diff --git a/src/MyEventReceiver.cpp b/src/MyEventReceiver.cpp index 1362c22f..eb3f54df 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) @@ -1024,6 +1074,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/NetworkPrimary.cpp b/src/NetworkPrimary.cpp index aad2e658..07ef7597 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/OtherShip.cpp b/src/OtherShip.cpp index efe8da2b..92453e2c 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 ba8d2a27..050ced6a 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 53b06104..4e0282ff 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 e8c2611c..670dc43f 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 26d6ffa6..3a20b4aa 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 4a6c0b2c..b890d3b2 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/controller/EventReceiver.cpp b/src/controller/EventReceiver.cpp index e55abc1b..51315613 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 d9020d46..8e2614f7 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 47b9a5e6..adefd99c 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); diff --git a/src/multiplayerHub/EventReceiver.cpp b/src/multiplayerHub/EventReceiver.cpp index d6effb3b..a5985997 100644 --- a/src/multiplayerHub/EventReceiver.cpp +++ b/src/multiplayerHub/EventReceiver.cpp @@ -19,11 +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) @@ -36,6 +41,10 @@ accelerator = 0; } else if (id == runButtonID) { accelerator = 1; + } else if (id == timeForwardButtonID) { + timeShift = 3600; + } else if (id == timeBackwardButtonID) { + timeShift = -3600; } } } @@ -45,7 +54,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 +67,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 94e89c58..56e2e2e4 100644 --- a/src/multiplayerHub/EventReceiver.hpp +++ b/src/multiplayerHub/EventReceiver.hpp @@ -26,16 +26,22 @@ 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); irr::f32 getAccelerator() const; + irr::f32 getAndResetTimeShift(); private: irr::f32 accelerator; + 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 3eb64d02..3204e116 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 @@ -360,6 +364,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;