16
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-07-19 12:19:18 +02:00

Merge pull request #23 from marcinn/feature/add-missing-enable-disable-commands

Add useful enable and disable commands
This commit is contained in:
Milek7
2022-09-30 03:31:57 +02:00
committed by GitHub
7 changed files with 483 additions and 57 deletions

397
Train.cpp
View File

@@ -246,6 +246,8 @@ TTrain::commandhandler_map const TTrain::m_commandhandlers = {
{ user_command::manualbrakeincrease, &TTrain::OnCommand_manualbrakeincrease },
{ user_command::manualbrakedecrease, &TTrain::OnCommand_manualbrakedecrease },
{ user_command::alarmchaintoggle, &TTrain::OnCommand_alarmchaintoggle },
{ user_command::alarmchainenable, &TTrain::OnCommand_alarmchainenable},
{ user_command::alarmchaindisable, &TTrain::OnCommand_alarmchaindisable},
{ user_command::wheelspinbrakeactivate, &TTrain::OnCommand_wheelspinbrakeactivate },
{ user_command::sandboxactivate, &TTrain::OnCommand_sandboxactivate },
{ user_command::autosandboxtoggle, &TTrain::OnCommand_autosandboxtoggle },
@@ -365,10 +367,20 @@ TTrain::commandhandler_map const TTrain::m_commandhandlers = {
{ user_command::redmarkerenableright, &TTrain::OnCommand_redmarkerenableright },
{ user_command::redmarkerdisableright, &TTrain::OnCommand_redmarkerdisableright },
{ user_command::headlighttogglerearleft, &TTrain::OnCommand_headlighttogglerearleft },
{ user_command::headlightenablerearleft, &TTrain::OnCommand_headlightenablerearleft },
{ user_command::headlightdisablerearleft, &TTrain::OnCommand_headlightdisablerearleft },
{ user_command::headlighttogglerearright, &TTrain::OnCommand_headlighttogglerearright },
{ user_command::headlightenablerearright, &TTrain::OnCommand_headlightenablerearright },
{ user_command::headlightdisablerearright, &TTrain::OnCommand_headlightdisablerearright },
{ user_command::headlighttogglerearupper, &TTrain::OnCommand_headlighttogglerearupper },
{ user_command::headlightenablerearupper, &TTrain::OnCommand_headlightenablerearupper },
{ user_command::headlightdisablerearupper, &TTrain::OnCommand_headlightdisablerearupper },
{ user_command::redmarkertogglerearleft, &TTrain::OnCommand_redmarkertogglerearleft },
{ user_command::redmarkerenablerearleft, &TTrain::OnCommand_redmarkerenablerearleft },
{ user_command::redmarkerdisablerearleft, &TTrain::OnCommand_redmarkerdisablerearleft },
{ user_command::redmarkertogglerearright, &TTrain::OnCommand_redmarkertogglerearright },
{ user_command::redmarkerenablerearright, &TTrain::OnCommand_redmarkerenablerearright },
{ user_command::redmarkerdisablerearright, &TTrain::OnCommand_redmarkerdisablerearright },
{ user_command::redmarkerstoggle, &TTrain::OnCommand_redmarkerstoggle },
{ user_command::endsignalstoggle, &TTrain::OnCommand_endsignalstoggle },
{ user_command::headlightsdimtoggle, &TTrain::OnCommand_headlightsdimtoggle },
@@ -387,7 +399,11 @@ TTrain::commandhandler_map const TTrain::m_commandhandlers = {
{ user_command::instrumentlightenable, &TTrain::OnCommand_instrumentlightenable },
{ user_command::instrumentlightdisable, &TTrain::OnCommand_instrumentlightdisable },
{ user_command::dashboardlighttoggle, &TTrain::OnCommand_dashboardlighttoggle },
{ user_command::dashboardlightenable, &TTrain::OnCommand_dashboardlightenable },
{ user_command::dashboardlightdisable, &TTrain::OnCommand_dashboardlightdisable },
{ user_command::timetablelighttoggle, &TTrain::OnCommand_timetablelighttoggle },
{ user_command::timetablelightenable, &TTrain::OnCommand_timetablelightenable },
{ user_command::timetablelightdisable, &TTrain::OnCommand_timetablelightdisable },
{ user_command::doorlocktoggle, &TTrain::OnCommand_doorlocktoggle },
{ user_command::doortoggleleft, &TTrain::OnCommand_doortoggleleft },
{ user_command::doortoggleright, &TTrain::OnCommand_doortoggleright },
@@ -414,9 +430,13 @@ TTrain::commandhandler_map const TTrain::m_commandhandlers = {
{ user_command::hornhighactivate, &TTrain::OnCommand_hornhighactivate },
{ user_command::whistleactivate, &TTrain::OnCommand_whistleactivate },
{ user_command::radiotoggle, &TTrain::OnCommand_radiotoggle },
{ user_command::radioenable, &TTrain::OnCommand_radioenable },
{ user_command::radiodisable, &TTrain::OnCommand_radiodisable },
{ user_command::radiochannelincrease, &TTrain::OnCommand_radiochannelincrease },
{ user_command::radiochanneldecrease, &TTrain::OnCommand_radiochanneldecrease },
{ user_command::radiostopsend, &TTrain::OnCommand_radiostopsend },
{ user_command::radiostopenable, &TTrain::OnCommand_radiostopenable },
{ user_command::radiostopdisable, &TTrain::OnCommand_radiostopdisable },
{ user_command::radiostoptest, &TTrain::OnCommand_radiostoptest },
{ user_command::radiocall3send, &TTrain::OnCommand_radiocall3send },
{ user_command::radiovolumeincrease, &TTrain::OnCommand_radiovolumeincrease },
@@ -1037,7 +1057,7 @@ void TTrain::OnCommand_jointcontrollerset( TTrain *Train, command_data const &Co
// on press or hold
// value controls brake in range 0-0.5, master controller in range 0.5-1.0
if( Command.param1 >= 0.5 ) {
Train->set_master_controller(
Train->set_master_controller(
( Command.param1 * 2 - 1 )
* ( Train->mvControlled->CoupledCtrl ?
Train->mvControlled->MainCtrlPosNo + Train->mvControlled->ScndCtrlPosNo :
@@ -1812,20 +1832,36 @@ void TTrain::OnCommand_alarmchaintoggle( TTrain *Train, command_data const &Comm
if( Command.action == GLFW_PRESS ) {
if( false == Train->mvOccupied->AlarmChainFlag ) {
// pull
Train->mvOccupied->AlarmChainSwitch( true );
// visual feedback
Train->ggAlarmChain.UpdateValue( 1.0 );
OnCommand_alarmchainenable(Train, Command);
}
else {
// release
Train->mvOccupied->AlarmChainSwitch( false );
// visual feedback
Train->ggAlarmChain.UpdateValue( 0.0 );
OnCommand_alarmchaindisable(Train, Command);
}
}
}
void TTrain::OnCommand_alarmchainenable(TTrain *Train, command_data const &Command)
{
if (Command.action == GLFW_PRESS) {
// pull
Train->mvOccupied->AlarmChainSwitch(true);
// visual feedback
Train->ggAlarmChain.UpdateValue(1.0);
}
}
void TTrain::OnCommand_alarmchaindisable(TTrain *Train, command_data const &Command) {
if (Command.action == GLFW_PRESS) {
// release
Train->mvOccupied->AlarmChainSwitch(false);
// visual feedback
Train->ggAlarmChain.UpdateValue(0.0);
}
}
void TTrain::OnCommand_wheelspinbrakeactivate( TTrain *Train, command_data const &Command ) {
// TODO: proper control deviced definition for the interiors, that doesn't hinge of presence of 3d submodels
@@ -3672,7 +3708,7 @@ void TTrain::OnCommand_compressorpresetactivateprevious(TTrain *Train, command_d
if( Train->ggCompressorListButton.type() == TGaugeType::push ) {
// impulse switch toggles only between positions 'default' and 'default+1'
return;
}
}
if ((Train->mvOccupied->CompressorListPos > 1)
|| (true == Train->mvOccupied->CompressorListWrap)) {
@@ -4443,23 +4479,74 @@ void TTrain::OnCommand_headlighttogglerearleft( TTrain *Train, command_data cons
end::rear :
end::front ) };
// only reacting to press, so the switch doesn't flip back and forth if key is held down
if( ( Train->mvOccupied->iLights[ vehicleotherend ] & light::headlight_right ) == 0 ) {
OnCommand_headlightenablerearleft(Train, Command);
}
else {
OnCommand_headlightdisablerearleft(Train, Command);
}
}
}
void TTrain::OnCommand_headlightenablerearleft( TTrain *Train, command_data const &Command ) {
if( Train->mvOccupied->LightsPosNo > 0 ) {
// lights are controlled by preset selector
return;
}
if( Command.action == GLFW_PRESS ) {
auto const vehicleotherend { (
Train->cab_to_end() == end::front ?
end::rear :
end::front ) };
// already enabled
if( ( Train->mvOccupied->iLights[ vehicleotherend ] & light::headlight_right ) == 0 ) {
// turn on
Train->mvOccupied->iLights[ vehicleotherend ] ^= light::headlight_right;
// visual feedback
Train->ggRearLeftLightButton.UpdateValue( 1.0, Train->dsbSwitch );
}
else {
//turn off
Train->mvOccupied->iLights[ vehicleotherend ] ^= light::headlight_right;
// visual feedback
Train->ggRearLeftLightButton.UpdateValue( 0.0, Train->dsbSwitch );
}
}
}
void TTrain::OnCommand_headlightdisablerearleft( TTrain *Train, command_data const &Command ) {
if( Train->mvOccupied->LightsPosNo > 0 ) {
// lights are controlled by preset selector
return;
}
if( Command.action == GLFW_PRESS ) {
auto const vehicleotherend { (
Train->cab_to_end() == end::front ?
end::rear :
end::front ) };
// already disabled
if( ( Train->mvOccupied->iLights[ vehicleotherend ] & light::headlight_right ) == 0 ) {return;}
//turn off
Train->mvOccupied->iLights[ vehicleotherend ] ^= light::headlight_right;
// visual feedback
Train->ggRearLeftLightButton.UpdateValue( 0.0, Train->dsbSwitch );
}
}
void TTrain::OnCommand_headlighttogglerearright( TTrain *Train, command_data const &Command ) {
if( Command.action == GLFW_PRESS ) {
// NOTE: we toggle the light on opposite side, as 'rear right' is 'front left' on the rear end etc
auto const vehicleotherend { (
Train->cab_to_end() == end::front ?
end::rear :
end::front ) };
// only reacting to press, so the switch doesn't flip back and forth if key is held down
if( ( Train->mvOccupied->iLights[ vehicleotherend ] & light::headlight_left ) == 0 ) {
OnCommand_headlightenablerearright(Train, Command);
}
else {
OnCommand_headlightdisablerearright(Train, Command);
}
}
}
void TTrain::OnCommand_headlightenablerearright( TTrain *Train, command_data const &Command ) {
if( Train->mvOccupied->LightsPosNo > 0 ) {
// lights are controlled by preset selector
return;
@@ -4471,19 +4558,35 @@ void TTrain::OnCommand_headlighttogglerearright( TTrain *Train, command_data con
Train->cab_to_end() == end::front ?
end::rear :
end::front ) };
// only reacting to press, so the switch doesn't flip back and forth if key is held down
if( ( Train->mvOccupied->iLights[ vehicleotherend ] & light::headlight_left ) == 0 ) {
// turn on
Train->mvOccupied->iLights[ vehicleotherend ] ^= light::headlight_left;
// visual feedback
Train->ggRearRightLightButton.UpdateValue( 1.0, Train->dsbSwitch );
}
else {
//turn off
Train->mvOccupied->iLights[ vehicleotherend ] ^= light::headlight_left;
// visual feedback
Train->ggRearRightLightButton.UpdateValue( 0.0, Train->dsbSwitch );
}
}
}
void TTrain::OnCommand_headlightdisablerearright( TTrain *Train, command_data const &Command ) {
if( Train->mvOccupied->LightsPosNo > 0 ) {
// lights are controlled by preset selector
return;
}
if( Command.action == GLFW_PRESS ) {
// NOTE: we toggle the light on opposite side, as 'rear right' is 'front left' on the rear end etc
auto const vehicleotherend { (
Train->cab_to_end() == end::front ?
end::rear :
end::front ) };
// already disabled
if( ( Train->mvOccupied->iLights[ vehicleotherend ] & light::headlight_left ) == 0 ) { return; }
//turn off
Train->mvOccupied->iLights[ vehicleotherend ] ^= light::headlight_left;
// visual feedback
Train->ggRearRightLightButton.UpdateValue( 0.0, Train->dsbSwitch );
}
}
@@ -4494,6 +4597,28 @@ void TTrain::OnCommand_headlighttogglerearupper( TTrain *Train, command_data con
return;
}
if( Command.action == GLFW_PRESS ) {
// only reacting to press, so the switch doesn't flip back and forth if key is held down
auto const vehicleotherend { (
Train->cab_to_end() == end::front ?
end::rear :
end::front ) };
if( ( Train->mvOccupied->iLights[ vehicleotherend ] & light::headlight_upper ) == 0 ) {
OnCommand_headlightenablerearupper(Train, Command);
}
else {
OnCommand_headlightdisablerearupper(Train, Command);
}
}
}
void TTrain::OnCommand_headlightenablerearupper( TTrain *Train, command_data const &Command ) {
if( Train->mvOccupied->LightsPosNo > 0 ) {
// lights are controlled by preset selector
return;
}
if( Command.action == GLFW_PRESS ) {
// only reacting to press, so the switch doesn't flip back and forth if key is held down
auto const vehicleotherend { (
@@ -4506,16 +4631,50 @@ void TTrain::OnCommand_headlighttogglerearupper( TTrain *Train, command_data con
// visual feedback
Train->ggRearUpperLightButton.UpdateValue( 1.0, Train->dsbSwitch );
}
else {
//turn off
Train->mvOccupied->iLights[ vehicleotherend ] ^= light::headlight_upper;
// visual feedback
Train->ggRearUpperLightButton.UpdateValue( 0.0, Train->dsbSwitch );
}
}
}
void TTrain::OnCommand_headlightdisablerearupper( TTrain *Train, command_data const &Command ) {
if( Train->mvOccupied->LightsPosNo > 0 ) {
// lights are controlled by preset selector
return;
}
if( Command.action == GLFW_PRESS ) {
// only reacting to press, so the switch doesn't flip back and forth if key is held down
auto const vehicleotherend { (
Train->cab_to_end() == end::front ?
end::rear :
end::front ) };
// already disabled?
if( ( Train->mvOccupied->iLights[ vehicleotherend ] & light::headlight_upper ) == 0 ) { return ; }
//turn off
Train->mvOccupied->iLights[ vehicleotherend ] ^= light::headlight_upper;
// visual feedback
Train->ggRearUpperLightButton.UpdateValue( 0.0, Train->dsbSwitch );
}
}
void TTrain::OnCommand_redmarkertogglerearleft( TTrain *Train, command_data const &Command ) {
if( Command.action == GLFW_PRESS ) {
// NOTE: we toggle the light on opposite side, as 'rear right' is 'front left' on the rear end etc
auto const vehicleotherend { (
Train->cab_to_end() == end::front ?
end::rear :
end::front ) };
// only reacting to press, so the switch doesn't flip back and forth if key is held down
if( ( Train->mvOccupied->iLights[ vehicleotherend ] & light::redmarker_right ) == 0 ) {
OnCommand_redmarkerenablerearleft(Train, Command);
}
else {
OnCommand_redmarkerdisablerearleft(Train, Command);
}
}
}
void TTrain::OnCommand_redmarkerenablerearleft( TTrain *Train, command_data const &Command ) {
if( Train->mvOccupied->LightsPosNo > 0 ) {
// lights are controlled by preset selector
@@ -4528,19 +4687,33 @@ void TTrain::OnCommand_redmarkertogglerearleft( TTrain *Train, command_data cons
Train->cab_to_end() == end::front ?
end::rear :
end::front ) };
// only reacting to press, so the switch doesn't flip back and forth if key is held down
if( ( Train->mvOccupied->iLights[ vehicleotherend ] & light::redmarker_right ) == 0 ) {
// turn on
Train->mvOccupied->iLights[ vehicleotherend ] ^= light::redmarker_right;
// visual feedback
Train->ggRearLeftEndLightButton.UpdateValue( 1.0, Train->dsbSwitch );
}
else {
//turn off
Train->mvOccupied->iLights[ vehicleotherend ] ^= light::redmarker_right;
// visual feedback
Train->ggRearLeftEndLightButton.UpdateValue( 0.0, Train->dsbSwitch );
}
}
}
void TTrain::OnCommand_redmarkerdisablerearleft( TTrain *Train, command_data const &Command ) {
if( Train->mvOccupied->LightsPosNo > 0 ) {
// lights are controlled by preset selector
return;
}
if( Command.action == GLFW_PRESS ) {
// NOTE: we toggle the light on opposite side, as 'rear right' is 'front left' on the rear end etc
auto const vehicleotherend { (
Train->cab_to_end() == end::front ?
end::rear :
end::front ) };
if( ( Train->mvOccupied->iLights[ vehicleotherend ] & light::redmarker_right ) == 0 ) { return; }
//turn off
Train->mvOccupied->iLights[ vehicleotherend ] ^= light::redmarker_right;
// visual feedback
Train->ggRearLeftEndLightButton.UpdateValue( 0.0, Train->dsbSwitch );
}
}
@@ -4558,18 +4731,55 @@ void TTrain::OnCommand_redmarkertogglerearright( TTrain *Train, command_data con
end::rear :
end::front ) };
// only reacting to press, so the switch doesn't flip back and forth if key is held down
if( ( Train->mvOccupied->iLights[ vehicleotherend ] & light::redmarker_left ) == 0 ) {
OnCommand_redmarkerenablerearright(Train, Command);
}
else {
OnCommand_redmarkerdisablerearright(Train, Command);
}
}
}
void TTrain::OnCommand_redmarkerenablerearright( TTrain *Train, command_data const &Command ) {
if( Train->mvOccupied->LightsPosNo > 0 ) {
// lights are controlled by preset selector
return;
}
if( Command.action == GLFW_PRESS ) {
// NOTE: we toggle the light on opposite side, as 'rear right' is 'front left' on the rear end etc
auto const vehicleotherend { (
Train->cab_to_end() == end::front ?
end::rear :
end::front ) };
if( ( Train->mvOccupied->iLights[ vehicleotherend ] & light::redmarker_left ) == 0 ) {
// turn on
Train->mvOccupied->iLights[ vehicleotherend ] ^= light::redmarker_left;
// visual feedback
Train->ggRearRightEndLightButton.UpdateValue( 1.0, Train->dsbSwitch );
}
else {
//turn off
Train->mvOccupied->iLights[ vehicleotherend ] ^= light::redmarker_left;
// visual feedback
Train->ggRearRightEndLightButton.UpdateValue( 0.0, Train->dsbSwitch );
}
}
}
void TTrain::OnCommand_redmarkerdisablerearright( TTrain *Train, command_data const &Command ) {
if( Train->mvOccupied->LightsPosNo > 0 ) {
// lights are controlled by preset selector
return;
}
if( Command.action == GLFW_PRESS ) {
// NOTE: we toggle the light on opposite side, as 'rear right' is 'front left' on the rear end etc
auto const vehicleotherend { (
Train->cab_to_end() == end::front ?
end::rear :
end::front ) };
if( ( Train->mvOccupied->iLights[ vehicleotherend ] & light::redmarker_left ) == 0 ) { return; }
//turn off
Train->mvOccupied->iLights[ vehicleotherend ] ^= light::redmarker_left;
// visual feedback
Train->ggRearRightEndLightButton.UpdateValue( 0.0, Train->dsbSwitch );
}
}
@@ -4938,6 +5148,15 @@ void TTrain::OnCommand_instrumentlightdisable( TTrain *Train, command_data const
}
void TTrain::OnCommand_dashboardlighttoggle( TTrain *Train, command_data const &Command ) {
if( false == Train->DashboardLightActive ) {
OnCommand_dashboardlightenable(Train, Command);
}
else {
OnCommand_dashboardlightdisable(Train, Command);
}
}
void TTrain::OnCommand_dashboardlightenable( TTrain *Train, command_data const &Command ) {
// only reacting to press, so the switch doesn't flip back and forth if key is held down
if( Command.action != GLFW_PRESS ) { return; }
@@ -4953,7 +5172,19 @@ void TTrain::OnCommand_dashboardlighttoggle( TTrain *Train, command_data const &
// visual feedback
Train->ggDashboardLightButton.UpdateValue( 1.0, Train->dsbSwitch );
}
else {
}
void TTrain::OnCommand_dashboardlightdisable( TTrain *Train, command_data const &Command ) {
// only reacting to press, so the switch doesn't flip back and forth if key is held down
if( Command.action != GLFW_PRESS ) { return; }
if( Train->ggDashboardLightButton.SubModel == nullptr ) {
// TODO: proper control deviced definition for the interiors, that doesn't hinge of presence of 3d submodels
WriteLog( "Dashboard Light switch is missing, or wasn't defined" );
return;
}
if( Train->DashboardLightActive ) {
//turn off
Train->DashboardLightActive = false;
// visual feedback
@@ -4965,6 +5196,18 @@ void TTrain::OnCommand_timetablelighttoggle( TTrain *Train, command_data const &
// only reacting to press, so the switch doesn't flip back and forth if key is held down
if( Command.action != GLFW_PRESS ) { return; }
if( false == Train->TimetableLightActive ) {
OnCommand_timetablelightenable(Train, Command);
}
else {
OnCommand_timetablelightdisable(Train, Command);
}
}
void TTrain::OnCommand_timetablelightenable( TTrain *Train, command_data const &Command ) {
// only reacting to press, so the switch doesn't flip back and forth if key is held down
if( Command.action != GLFW_PRESS ) { return; }
if( Train->ggTimetableLightButton.SubModel == nullptr ) {
// TODO: proper control deviced definition for the interiors, that doesn't hinge of presence of 3d submodels
WriteLog( "Timetable Light switch is missing, or wasn't defined" );
@@ -4977,7 +5220,18 @@ void TTrain::OnCommand_timetablelighttoggle( TTrain *Train, command_data const &
// visual feedback
Train->ggTimetableLightButton.UpdateValue( 1.0, Train->dsbSwitch );
}
else {
}
void TTrain::OnCommand_timetablelightdisable( TTrain *Train, command_data const &Command ) {
// only reacting to press, so the switch doesn't flip back and forth if key is held down
if( Command.action != GLFW_PRESS ) { return; }
if( Train->ggTimetableLightButton.SubModel == nullptr ) {
// TODO: proper control deviced definition for the interiors, that doesn't hinge of presence of 3d submodels
WriteLog( "Timetable Light switch is missing, or wasn't defined" );
return;
}
if( Train->TimetableLightActive ) {
//turn off
Train->TimetableLightActive = false;
// visual feedback
@@ -5031,7 +5285,7 @@ void TTrain::OnCommand_heatingdisable( TTrain *Train, command_data const &Comman
Train->mvOccupied->HeatingSwitch( false );
// visual feedback
Train->ggTrainHeatingButton.UpdateValue(
Train->ggTrainHeatingButton.UpdateValue(
( Train->ggTrainHeatingButton.type() == TGaugeType::push ?
1.0 :
0.0 ),
@@ -5167,7 +5421,7 @@ void TTrain::OnCommand_springbrakeshutoffdisable(TTrain *Train, command_data con
void TTrain::OnCommand_springbrakerelease(TTrain *Train, command_data const &Command) {
if (Command.action == GLFW_PRESS) {
// only reacting to press, so the switch doesn't flip back and forth if key is held down
auto *vehicle{ Train->find_nearest_consist_vehicle(Command.freefly, Command.location) };
if (vehicle == nullptr) { return; }
Train->mvOccupied->SpringBrakeRelease();
@@ -5271,7 +5525,7 @@ void TTrain::OnCommand_inverterenable(TTrain *Train, command_data const &Command
{
itemindex -= p->MoverParameters->InvertersNo;
}
}
p = (kier ? p->Next(flag) : p->Prev(flag));
}
@@ -6193,7 +6447,6 @@ void TTrain::OnCommand_whistleactivate( TTrain *Train, command_data const &Comma
}
void TTrain::OnCommand_radiotoggle( TTrain *Train, command_data const &Command ) {
if( Command.action != GLFW_PRESS ) { return; }
// NOTE: we ignore the lack of 3d model to allow system reset after receiving radio-stop signal
@@ -6205,10 +6458,26 @@ void TTrain::OnCommand_radiotoggle( TTrain *Train, command_data const &Command )
// only reacting to press, so the sound can loop uninterrupted
if( false == Train->mvOccupied->Radio ) {
// turn on
Train->mvOccupied->Radio = true;
OnCommand_radioenable(Train, Command);
}
else {
// turn off
OnCommand_radiodisable(Train, Command);
}
}
void TTrain::OnCommand_radioenable( TTrain *Train, command_data const &Command ) {
if( Command.action != GLFW_PRESS ) { return; }
if( false == Train->mvOccupied->Radio ) {
Train->mvOccupied->Radio = true;
}
}
void TTrain::OnCommand_radiodisable( TTrain *Train, command_data const &Command ) {
if( Command.action != GLFW_PRESS ) { return; }
if(Train->mvOccupied->Radio ) {
Train->mvOccupied->Radio = false;
}
}
@@ -6257,6 +6526,24 @@ void TTrain::OnCommand_radiostopsend( TTrain *Train, command_data const &Command
}
}
void TTrain::OnCommand_radiostopenable( TTrain *Train, command_data const &Command ) {
if( Command.action == GLFW_PRESS && Train->ggRadioStop.GetValue() == 0 ) {
if( ( true == Train->mvOccupied->Radio )
&& ( Train->mvOccupied->Power24vIsAvailable || Train->mvOccupied->Power110vIsAvailable ) ) {
simulation::Region->RadioStop( Train->Dynamic()->GetPosition() );
}
// visual feedback
Train->ggRadioStop.UpdateValue( 1.0 );
}
}
void TTrain::OnCommand_radiostopdisable( TTrain *Train, command_data const &Command ) {
if( Command.action == GLFW_PRESS && Train->ggRadioStop.GetValue() > 0 ) {
// visual feedback
Train->ggRadioStop.UpdateValue( 0.0 );
}
}
void TTrain::OnCommand_radiostoptest( TTrain *Train, command_data const &Command ) {
if( Command.action == GLFW_PRESS ) {
@@ -6434,8 +6721,8 @@ void TTrain::UpdateCab() {
// Ra: przesiadka, jeśli AI zmieniło kabinę (a człon?)...
if( ( DynamicObject->Mechanik ) // może nie być?
&& ( DynamicObject->Mechanik->AIControllFlag ) ) {
&& ( DynamicObject->Mechanik->AIControllFlag ) ) {
if( iCabn != ( // numer kabiny (-1: kabina B)
mvOccupied->CabOccupied == -1 ?
2 :
@@ -7466,7 +7753,7 @@ bool TTrain::Update( double const Deltatime )
{
#ifdef _WIN32
if (DynamicObject->Mechanik ?
(DynamicObject->Mechanik->AIControllFlag ? false :
(DynamicObject->Mechanik->AIControllFlag ? false :
(Global.iFeedbackMode == 4 /*|| (Global.bMWDmasterEnable && Global.bMWDBreakEnable)*/)) :
false && Global.fCalibrateIn[ 0 ][ 1 ] != 0.0) // nie blokujemy AI
{ // Ra: nie najlepsze miejsce, ale na początek gdzieś to dać trzeba
@@ -7660,7 +7947,7 @@ bool TTrain::Update( double const Deltatime )
ggHelperButton.UpdateValue( DynamicObject->Mechanik->HelperState );
}
ggHelperButton.Update();
ggSpeedControlIncreaseButton.Update( lowvoltagepower );
ggSpeedControlDecreaseButton.Update( lowvoltagepower );
ggSpeedControlPowerIncreaseButton.Update( lowvoltagepower );
@@ -7859,7 +8146,7 @@ TTrain::update_sounds( double const Deltatime ) {
rsHissX->stop();
}
}
// upuszczanie z czasowego
// upuszczanie z czasowego
if( rsHissT ) {
volume = mvOccupied->Handle->GetSound( s_fv4a_t ) * rsHissT->m_amplitudefactor + +rsHissT->m_amplitudeoffset;
if( volume * brakevolumescale > 0.05 ) {
@@ -9517,7 +9804,7 @@ void TTrain::set_cab_controls( int const Cab ) {
p = (kier ? p->Next(flag) : p->Prev(flag));
}
}
// we reset all indicators, as they're set during the update pass
// TODO: when cleaning up break setting indicator state into a separate function, so we can reuse it
}

20
Train.h
View File

@@ -265,6 +265,8 @@ class TTrain {
static void OnCommand_manualbrakeincrease( TTrain *Train, command_data const &Command );
static void OnCommand_manualbrakedecrease( TTrain *Train, command_data const &Command );
static void OnCommand_alarmchaintoggle( TTrain *Train, command_data const &Command );
static void OnCommand_alarmchainenable(TTrain *Train, command_data const &Command);
static void OnCommand_alarmchaindisable(TTrain *Train, command_data const &Command);
static void OnCommand_wheelspinbrakeactivate( TTrain *Train, command_data const &Command );
static void OnCommand_sandboxactivate( TTrain *Train, command_data const &Command );
static void OnCommand_autosandboxtoggle(TTrain *Train, command_data const &Command);
@@ -386,10 +388,20 @@ class TTrain {
static void OnCommand_redmarkerenableright( TTrain *Train, command_data const &Command );
static void OnCommand_redmarkerdisableright( TTrain *Train, command_data const &Command );
static void OnCommand_headlighttogglerearleft( TTrain *Train, command_data const &Command );
static void OnCommand_headlightenablerearleft( TTrain *Train, command_data const &Command );
static void OnCommand_headlightdisablerearleft( TTrain *Train, command_data const &Command );
static void OnCommand_headlighttogglerearright( TTrain *Train, command_data const &Command );
static void OnCommand_headlightenablerearright( TTrain *Train, command_data const &Command );
static void OnCommand_headlightdisablerearright( TTrain *Train, command_data const &Command );
static void OnCommand_headlighttogglerearupper( TTrain *Train, command_data const &Command );
static void OnCommand_headlightenablerearupper( TTrain *Train, command_data const &Command );
static void OnCommand_headlightdisablerearupper( TTrain *Train, command_data const &Command );
static void OnCommand_redmarkertogglerearleft( TTrain *Train, command_data const &Command );
static void OnCommand_redmarkerenablerearleft( TTrain *Train, command_data const &Command );
static void OnCommand_redmarkerdisablerearleft( TTrain *Train, command_data const &Command );
static void OnCommand_redmarkertogglerearright( TTrain *Train, command_data const &Command );
static void OnCommand_redmarkerenablerearright( TTrain *Train, command_data const &Command );
static void OnCommand_redmarkerdisablerearright( TTrain *Train, command_data const &Command );
static void OnCommand_redmarkerstoggle( TTrain *Train, command_data const &Command );
static void OnCommand_endsignalstoggle( TTrain *Train, command_data const &Command );
static void OnCommand_headlightsdimtoggle( TTrain *Train, command_data const &Command );
@@ -408,7 +420,11 @@ class TTrain {
static void OnCommand_instrumentlightenable( TTrain *Train, command_data const &Command );
static void OnCommand_instrumentlightdisable( TTrain *Train, command_data const &Command );
static void OnCommand_dashboardlighttoggle( TTrain *Train, command_data const &Command );
static void OnCommand_dashboardlightenable( TTrain *Train, command_data const &Command );
static void OnCommand_dashboardlightdisable( TTrain *Train, command_data const &Command );
static void OnCommand_timetablelighttoggle( TTrain *Train, command_data const &Command );
static void OnCommand_timetablelightenable( TTrain *Train, command_data const &Command );
static void OnCommand_timetablelightdisable( TTrain *Train, command_data const &Command );
static void OnCommand_doorlocktoggle( TTrain *Train, command_data const &Command );
static void OnCommand_doortoggleleft( TTrain *Train, command_data const &Command );
static void OnCommand_doortoggleright( TTrain *Train, command_data const &Command );
@@ -436,9 +452,13 @@ class TTrain {
static void OnCommand_hornhighactivate( TTrain *Train, command_data const &Command );
static void OnCommand_whistleactivate( TTrain *Train, command_data const &Command );
static void OnCommand_radiotoggle( TTrain *Train, command_data const &Command );
static void OnCommand_radioenable( TTrain *Train, command_data const &Command );
static void OnCommand_radiodisable( TTrain *Train, command_data const &Command );
static void OnCommand_radiochannelincrease( TTrain *Train, command_data const &Command );
static void OnCommand_radiochanneldecrease( TTrain *Train, command_data const &Command );
static void OnCommand_radiostopsend( TTrain *Train, command_data const &Command );
static void OnCommand_radiostopenable( TTrain *Train, command_data const &Command );
static void OnCommand_radiostopdisable( TTrain *Train, command_data const &Command );
static void OnCommand_radiostoptest( TTrain *Train, command_data const &Command );
static void OnCommand_radiocall3send( TTrain *Train, command_data const &Command );
static void OnCommand_radiovolumeincrease(TTrain *Train, command_data const &Command);

View File

@@ -62,6 +62,8 @@ commanddescription_sequence Commands_descriptions = {
{ "manualbrakeincrease", command_target::vehicle, command_mode::oneoff },
{ "manualbrakedecrease", command_target::vehicle, command_mode::oneoff },
{ "alarmchaintoggle", command_target::vehicle, command_mode::oneoff },
{ "alarmchainenable", command_target::vehicle, command_mode::oneoff},
{ "alarmchaindisable", command_target::vehicle, command_mode::oneoff},
{ "wheelspinbrakeactivate", command_target::vehicle, command_mode::oneoff },
{ "sandboxactivate", command_target::vehicle, command_mode::oneoff },
{ "autosandboxtoggle", command_target::vehicle, command_mode::oneoff },
@@ -134,9 +136,13 @@ commanddescription_sequence Commands_descriptions = {
{ "hornhighactivate", command_target::vehicle, command_mode::oneoff },
{ "whistleactivate", command_target::vehicle, command_mode::oneoff },
{ "radiotoggle", command_target::vehicle, command_mode::oneoff },
{ "radioenable", command_target::vehicle, command_mode::oneoff },
{ "radiodisable", command_target::vehicle, command_mode::oneoff },
{ "radiochannelincrease", command_target::vehicle, command_mode::oneoff },
{ "radiochanneldecrease", command_target::vehicle, command_mode::oneoff },
{ "radiostopsend", command_target::vehicle, command_mode::oneoff },
{ "radiostopenable", command_target::vehicle, command_mode::oneoff },
{ "radiostopdisable", command_target::vehicle, command_mode::oneoff },
{ "radiostoptest", command_target::vehicle, command_mode::oneoff },
{ "radiocall3send", command_target::vehicle, command_mode::oneoff },
{ "radiovolumeincrease", command_target::vehicle, command_mode::oneoff },
@@ -216,10 +222,20 @@ commanddescription_sequence Commands_descriptions = {
{ "redmarkerenableright", command_target::vehicle, command_mode::oneoff },
{ "redmarkerdisableright", command_target::vehicle, command_mode::oneoff },
{ "headlighttogglerearleft", command_target::vehicle, command_mode::oneoff },
{ "headlightenablerearleft", command_target::vehicle, command_mode::oneoff },
{ "headlightdisablerearleft", command_target::vehicle, command_mode::oneoff },
{ "headlighttogglerearright", command_target::vehicle, command_mode::oneoff },
{ "headlightenablerearright", command_target::vehicle, command_mode::oneoff },
{ "headlightdisablerearright", command_target::vehicle, command_mode::oneoff },
{ "headlighttogglerearupper", command_target::vehicle, command_mode::oneoff },
{ "headlightenablerearupper", command_target::vehicle, command_mode::oneoff },
{ "headlightdisablerearupper", command_target::vehicle, command_mode::oneoff },
{ "redmarkertogglerearleft", command_target::vehicle, command_mode::oneoff },
{ "redmarkerenablerearleft", command_target::vehicle, command_mode::oneoff },
{ "redmarkerdisablerearleft", command_target::vehicle, command_mode::oneoff },
{ "redmarkertogglerearright", command_target::vehicle, command_mode::oneoff },
{ "redmarkerenablerearright", command_target::vehicle, command_mode::oneoff },
{ "redmarkerdisablerearright", command_target::vehicle, command_mode::oneoff },
{ "redmarkerstoggle", command_target::vehicle, command_mode::oneoff },
{ "endsignalstoggle", command_target::vehicle, command_mode::oneoff },
{ "headlightsdimtoggle", command_target::vehicle, command_mode::oneoff },
@@ -241,7 +257,11 @@ commanddescription_sequence Commands_descriptions = {
{ "instrumentlightenable", command_target::vehicle, command_mode::oneoff },
{ "instrumentlightdisable", command_target::vehicle, command_mode::oneoff },
{ "dashboardlighttoggle", command_target::vehicle, command_mode::oneoff },
{ "dashboardlightenable", command_target::vehicle, command_mode::oneoff },
{ "dashboardlightdisable", command_target::vehicle, command_mode::oneoff },
{ "timetablelighttoggle", command_target::vehicle, command_mode::oneoff },
{ "timetablelightenable", command_target::vehicle, command_mode::oneoff },
{ "timetablelightdisable", command_target::vehicle, command_mode::oneoff },
{ "generictoggle0", command_target::vehicle, command_mode::oneoff },
{ "generictoggle1", command_target::vehicle, command_mode::oneoff },
{ "generictoggle2", command_target::vehicle, command_mode::oneoff },

View File

@@ -55,6 +55,8 @@ enum class user_command {
manualbrakeincrease,
manualbrakedecrease,
alarmchaintoggle,
alarmchainenable,
alarmchaindisable,
wheelspinbrakeactivate,
sandboxactivate,
autosandboxtoggle,
@@ -127,9 +129,13 @@ enum class user_command {
hornhighactivate,
whistleactivate,
radiotoggle,
radioenable,
radiodisable,
radiochannelincrease,
radiochanneldecrease,
radiostopsend,
radiostopenable,
radiostopdisable,
radiostoptest,
radiocall3send,
radiovolumeincrease,
@@ -211,10 +217,20 @@ enum class user_command {
redmarkerenableright,
redmarkerdisableright,
headlighttogglerearleft,
headlightenablerearleft,
headlightdisablerearleft,
headlighttogglerearright,
headlightenablerearright,
headlightdisablerearright,
headlighttogglerearupper,
headlightenablerearupper,
headlightdisablerearupper,
redmarkertogglerearleft,
redmarkerenablerearleft,
redmarkerdisablerearleft,
redmarkertogglerearright,
redmarkerenablerearright,
redmarkerdisablerearright,
redmarkerstoggle,
endsignalstoggle,
headlightsdimtoggle,
@@ -236,7 +252,11 @@ enum class user_command {
instrumentlightenable,
instrumentlightdisable,
dashboardlighttoggle,
dashboardlightenable,
dashboardlightdisable,
timetablelighttoggle,
timetablelightenable,
timetablelightdisable,
generictoggle0,
generictoggle1,
generictoggle2,

View File

@@ -64,6 +64,8 @@ driverkeyboard_input::default_bindings() {
{ user_command::manualbrakeincrease, GLFW_KEY_KP_1 | keymodifier::control },
{ user_command::manualbrakedecrease, GLFW_KEY_KP_7 | keymodifier::control },
{ user_command::alarmchaintoggle, GLFW_KEY_B | keymodifier::shift | keymodifier::control },
// alarmchainenable,
// alarmchaindisable,
{ user_command::wheelspinbrakeactivate, GLFW_KEY_KP_ENTER },
{ user_command::sandboxactivate, GLFW_KEY_S | keymodifier::shift },
// autosandboxtoggle,
@@ -135,9 +137,13 @@ driverkeyboard_input::default_bindings() {
{ user_command::hornhighactivate, GLFW_KEY_S },
{ user_command::whistleactivate, GLFW_KEY_Z },
{ user_command::radiotoggle, GLFW_KEY_R | keymodifier::control },
// radioenable
// radiodisable
{ user_command::radiochannelincrease, GLFW_KEY_EQUAL },
{ user_command::radiochanneldecrease, GLFW_KEY_MINUS },
{ user_command::radiostopsend, GLFW_KEY_PAUSE | keymodifier::shift | keymodifier::control },
// radiostopenable
// radiostopdisable
{ user_command::radiostoptest, GLFW_KEY_R | keymodifier::shift | keymodifier::control },
{ user_command::radiocall3send, GLFW_KEY_BACKSPACE },
// radiovolumeincrease,
@@ -216,10 +222,20 @@ driverkeyboard_input::default_bindings() {
// redmarkerenableright,
// redmarkerdisableright,
{ user_command::headlighttogglerearleft, GLFW_KEY_Y | keymodifier::control },
// headlightenablerearleft
// headlightdisablerearleft
{ user_command::headlighttogglerearright, GLFW_KEY_I | keymodifier::control },
// headlightenablerearright
// headlightdisablerearright
{ user_command::headlighttogglerearupper, GLFW_KEY_U | keymodifier::control },
// headlightenablerearupper
// headlightdisablerearupper
{ user_command::redmarkertogglerearleft, GLFW_KEY_Y | keymodifier::control | keymodifier::shift },
// redmarkerenablerearleft
// redmarkerdisablerearleft
{ user_command::redmarkertogglerearright, GLFW_KEY_I | keymodifier::control | keymodifier::shift },
// redmarkerenablerearright
// redmarkerdisablerearright
{ user_command::redmarkerstoggle, GLFW_KEY_E | keymodifier::shift },
{ user_command::endsignalstoggle, GLFW_KEY_E },
{ user_command::headlightsdimtoggle, GLFW_KEY_L | keymodifier::control },
@@ -241,7 +257,11 @@ driverkeyboard_input::default_bindings() {
// instrumentlightenable,
// instrumentlightdisable,
{ user_command::dashboardlighttoggle, GLFW_KEY_SEMICOLON | keymodifier::shift },
// dashboardlightenable
// dashboardlightdisable
{ user_command::timetablelighttoggle, GLFW_KEY_APOSTROPHE | keymodifier::shift },
// timetablelightenable
// timetablelightdisable
{ user_command::generictoggle0, GLFW_KEY_0 },
{ user_command::generictoggle1, GLFW_KEY_1 },
{ user_command::generictoggle2, GLFW_KEY_2 },

View File

@@ -64,7 +64,7 @@ mouse_slider::bind( user_command const &Command ) {
auto const brakerangemultiplier { powerrange / LocalBrakePosNo };
m_valuerange = 1.0;
m_value =
m_value =
0.5
+ 0.5 * ( vehicle->CoupledCtrl ?
vehicle->MainCtrlPos + vehicle->ScndCtrlPos :
@@ -550,6 +550,12 @@ drivermouse_input::default_bindings() {
{ "alarmchain:", {
user_command::alarmchaintoggle,
user_command::none } },
{ "alarmchainon:", {
user_command::alarmchainenable,
user_command::none} },
{ "alarmchainoff:", {
user_command::alarmchainenable,
user_command::none} },
{ "brakeprofile_sw:", {
user_command::brakeactingspeedincrease,
user_command::brakeactingspeeddecrease } },
@@ -770,6 +776,12 @@ drivermouse_input::default_bindings() {
{ "radio_sw:", {
user_command::radiotoggle,
user_command::none } },
{ "radioon_sw:", {
user_command::radioenable,
user_command::none } },
{ "radiooff_sw:", {
user_command::radiodisable,
user_command::none } },
{ "radiochannel_sw:", {
user_command::radiochannelincrease,
user_command::radiochanneldecrease } },
@@ -782,6 +794,12 @@ drivermouse_input::default_bindings() {
{ "radiostop_sw:", {
user_command::radiostopsend,
user_command::none } },
{ "radiostopon_sw:", {
user_command::radiostopenable,
user_command::none } },
{ "radiostopoff_sw:", {
user_command::radiostopdisable,
user_command::none } },
{ "radiotest_sw:", {
user_command::radiostoptest,
user_command::none } },
@@ -851,9 +869,21 @@ drivermouse_input::default_bindings() {
{ "dashboardlight_sw:", {
user_command::dashboardlighttoggle,
user_command::none } },
{ "dashboardlighton_sw:", {
user_command::dashboardlightenable,
user_command::none } },
{ "dashboardlightoff_sw:", {
user_command::dashboardlightdisable,
user_command::none } },
{ "timetablelight_sw:", {
user_command::timetablelighttoggle,
user_command::none } },
{ "timetablelighton_sw:", {
user_command::timetablelightenable,
user_command::none } },
{ "timetablelightoff_sw:", {
user_command::timetablelightdisable,
user_command::none } },
{ "cablight_sw:", {
user_command::interiorlighttoggle,
user_command::none } },

View File

@@ -434,6 +434,12 @@ std::unordered_map<std::string, vr_openvr::button_bindings> vr_openvr::m_buttonb
{ "alarmchain:", {
user_command::alarmchaintoggle,
user_command::none } },
{ "alarmchainon:", {
user_command::alarmchainenable,
user_command::none} },
{ "alarmchainoff:", {
user_command::alarmchainenable,
user_command::none} },
{ "brakeprofile_sw:", {
user_command::brakeactingspeedincrease,
user_command::brakeactingspeeddecrease } },
@@ -651,6 +657,12 @@ std::unordered_map<std::string, vr_openvr::button_bindings> vr_openvr::m_buttonb
{ "radio_sw:", {
user_command::radiotoggle,
user_command::none } },
{ "radioon_sw:", {
user_command::radioenable,
user_command::none } },
{ "radiooff_sw:", {
user_command::radiodisable,
user_command::none } },
{ "radiochannel_sw:", {
user_command::radiochannelincrease,
user_command::radiochanneldecrease } },
@@ -663,6 +675,12 @@ std::unordered_map<std::string, vr_openvr::button_bindings> vr_openvr::m_buttonb
{ "radiostop_sw:", {
user_command::radiostopsend,
user_command::none } },
{ "radiostopon_sw:", {
user_command::radiostopenable,
user_command::none } },
{ "radiostopoff_sw:", {
user_command::radiostopdisable,
user_command::none } },
{ "radiotest_sw:", {
user_command::radiostoptest,
user_command::none } },
@@ -729,9 +747,21 @@ std::unordered_map<std::string, vr_openvr::button_bindings> vr_openvr::m_buttonb
{ "dashboardlight_sw:", {
user_command::dashboardlighttoggle,
user_command::none } },
{ "dashboardlighton_sw:", {
user_command::dashboardlightenable,
user_command::none } },
{ "dashboardlightoff_sw:", {
user_command::dashboardlightdisable,
user_command::none } },
{ "timetablelight_sw:", {
user_command::timetablelighttoggle,
user_command::none } },
{ "timetablelighton_sw:", {
user_command::timetablelightenable,
user_command::none } },
{ "timetablelightoff_sw:", {
user_command::timetablelightdisable,
user_command::none } },
{ "cablight_sw:", {
user_command::interiorlighttoggle,
user_command::none } },
@@ -942,4 +972,3 @@ std::unordered_map<std::string, vr_openvr::button_bindings> vr_openvr::m_buttonb
};
bool vr_openvr::backend_register = vr_interface_factory::get_instance()->register_backend("openvr", vr_openvr::create_func);