mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-21 15:59:18 +02:00
(commands) add enable/disable commands for rear lights and redmarks
This commit is contained in:
248
Train.cpp
248
Train.cpp
@@ -365,10 +365,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 },
|
||||
@@ -4443,23 +4453,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 +4532,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 +4571,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 +4605,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 +4661,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 +4705,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 );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
10
Train.h
10
Train.h
@@ -386,10 +386,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 );
|
||||
|
||||
10
command.cpp
10
command.cpp
@@ -216,10 +216,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 },
|
||||
|
||||
10
command.h
10
command.h
@@ -211,10 +211,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,
|
||||
|
||||
@@ -216,10 +216,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 },
|
||||
|
||||
Reference in New Issue
Block a user