Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions bin/language-en.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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="!"
Expand Down
5 changes: 5 additions & 0 deletions bin/language-es.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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="!"
Expand Down
5 changes: 5 additions & 0 deletions bin/language-fr.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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="!"
Expand Down
3 changes: 3 additions & 0 deletions bin/languageController-en.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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"

3 changes: 3 additions & 0 deletions bin/languageController-es.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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"
3 changes: 3 additions & 0 deletions bin/languageController-fr.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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"
3 changes: 2 additions & 1 deletion bin/languageMultiplayer-en.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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"
2 changes: 2 additions & 0 deletions bin/languageMultiplayer-es.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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"
2 changes: 2 additions & 0 deletions bin/languageMultiplayer-fr.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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"
3 changes: 2 additions & 1 deletion src/Constants.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
14 changes: 14 additions & 0 deletions src/GUIMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,20 @@ void GUIMain::load(irr::IrrlichtDevice* device, Lang* language, std::vector<std:
magnificationScrollbar->setSmallStep(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<irr::s32>(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<irr::s32>(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<irr::s32>(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<irr::s32>(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<irr::s32>(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<irr::s32>(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<irr::s32>(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<irr::s32>(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<irr::s32>(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<irr::s32>(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<irr::s32> linesWindowPos = stdDataDisplayPos;
linesWindowPos.LowerRightCorner -= irr::core::position2d<irr::s32>(0,0.03*sh);
Expand Down
12 changes: 11 additions & 1 deletion src/GUIMain.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 3 additions & 0 deletions src/Light.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
56 changes: 56 additions & 0 deletions src/MyEventReceiver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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

Expand Down
7 changes: 7 additions & 0 deletions src/NetworkPrimary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::string> 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<irr::f32>(parts.at(1));
model->changeTime(timeChange);
}
}


Expand Down
7 changes: 7 additions & 0 deletions src/OtherShip.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<Leg>::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;
Expand Down
1 change: 1 addition & 0 deletions src/OtherShip.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
7 changes: 7 additions & 0 deletions src/OtherShips.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<OtherShip*>::iterator it = otherShips.begin(); it != otherShips.end(); ++it) {
(*it)->offsetLegTimes(deltaTime);
}
}
1 change: 1 addition & 0 deletions src/OtherShips.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
6 changes: 6 additions & 0 deletions src/SimulationModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
1 change: 1 addition & 0 deletions src/SimulationModel.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
19 changes: 19 additions & 0 deletions src/controller/EventReceiver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions src/controller/GUI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<irr::s32>(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<irr::s32>(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;

Expand Down
4 changes: 3 additions & 1 deletion src/controller/GUI.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<PositionData>& buoys, const std::vector<OtherShipDisplayData>& otherShips, const std::vector<AISData>& 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);
Expand Down
22 changes: 21 additions & 1 deletion src/multiplayerHub/EventReceiver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -36,6 +41,10 @@
accelerator = 0;
} else if (id == runButtonID) {
accelerator = 1;
} else if (id == timeForwardButtonID) {
timeShift = 3600;
} else if (id == timeBackwardButtonID) {
timeShift = -3600;
}
}
}
Expand All @@ -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;
Expand All @@ -54,4 +67,11 @@
irr::f32 EventReceiver::getAccelerator() const
{
return accelerator;
}

irr::f32 EventReceiver::getAndResetTimeShift()
{
irr::f32 returnValue = timeShift;
timeShift = 0;
return returnValue;
}
Loading
Loading