(commands) add timetablelightenable and timetablelightdisable commands

This commit is contained in:
Marcin Nowak
2022-09-28 23:56:10 +02:00
parent 57dbcf79e1
commit 1d34194453
7 changed files with 46 additions and 1 deletions

View File

@@ -400,6 +400,8 @@ TTrain::commandhandler_map const TTrain::m_commandhandlers = {
{ user_command::instrumentlightdisable, &TTrain::OnCommand_instrumentlightdisable },
{ user_command::dashboardlighttoggle, &TTrain::OnCommand_dashboardlighttoggle },
{ 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 },
@@ -5171,6 +5173,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" );
@@ -5183,7 +5197,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

View File

@@ -421,6 +421,8 @@ class TTrain {
static void OnCommand_instrumentlightdisable( TTrain *Train, command_data const &Command );
static void OnCommand_dashboardlighttoggle( 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 );

View File

@@ -258,6 +258,8 @@ commanddescription_sequence Commands_descriptions = {
{ "instrumentlightdisable", command_target::vehicle, command_mode::oneoff },
{ "dashboardlighttoggle", 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

@@ -253,6 +253,8 @@ enum class user_command {
instrumentlightdisable,
dashboardlighttoggle,
timetablelighttoggle,
timetablelightenable,
timetablelightdisable,
generictoggle0,
generictoggle1,
generictoggle2,

View File

@@ -258,6 +258,8 @@ driverkeyboard_input::default_bindings() {
// instrumentlightdisable,
{ user_command::dashboardlighttoggle, GLFW_KEY_SEMICOLON | keymodifier::shift },
{ 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

@@ -872,6 +872,12 @@ drivermouse_input::default_bindings() {
{ "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

@@ -750,6 +750,12 @@ std::unordered_map<std::string, vr_openvr::button_bindings> vr_openvr::m_buttonb
{ "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 } },