mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-19 00:59:18 +02:00
Added volume switch and buttons for radio
This commit is contained in:
40
Train.cpp
40
Train.cpp
@@ -350,6 +350,8 @@ TTrain::commandhandler_map const TTrain::m_commandhandlers = {
|
||||
{ user_command::radiostopsend, &TTrain::OnCommand_radiostopsend },
|
||||
{ user_command::radiostoptest, &TTrain::OnCommand_radiostoptest },
|
||||
{ user_command::radiocall3send, &TTrain::OnCommand_radiocall3send },
|
||||
{ user_command::radiovolumeincrease, &TTrain::OnCommand_radiovolumeincrease },
|
||||
{ user_command::radiovolumedecrease, &TTrain::OnCommand_radiovolumedecrease },
|
||||
{ user_command::cabchangeforward, &TTrain::OnCommand_cabchangeforward },
|
||||
{ user_command::cabchangebackward, &TTrain::OnCommand_cabchangebackward },
|
||||
{ user_command::generictoggle0, &TTrain::OnCommand_generictoggle },
|
||||
@@ -527,6 +529,7 @@ dictionary_source *TTrain::GetTrainState() {
|
||||
dict->insert( "pantpress", std::abs( mvControlled->PantPress ) );
|
||||
dict->insert( "universal3", InstrumentLightActive );
|
||||
dict->insert( "radio_channel", iRadioChannel );
|
||||
dict->insert( "radio_volume", Global.RadioVolume );
|
||||
dict->insert( "door_lock", mvOccupied->Doors.lock_enabled );
|
||||
// movement data
|
||||
dict->insert( "velocity", std::abs( mvOccupied->Vel ) );
|
||||
@@ -5393,6 +5396,34 @@ void TTrain::OnCommand_radiocall3send( TTrain *Train, command_data const &Comman
|
||||
}
|
||||
}
|
||||
|
||||
void TTrain::OnCommand_radiovolumeincrease(TTrain *Train, command_data const &Command) {
|
||||
|
||||
if (Command.action == GLFW_PRESS) {
|
||||
Global.RadioVolume = clamp(Global.RadioVolume + 0.125, 0.0, 1.0);
|
||||
// visual feedback
|
||||
Train->ggRadioVolumeSelector.UpdateValue(Global.RadioVolume);
|
||||
Train->ggRadioVolumeNext.UpdateValue(1.0);
|
||||
}
|
||||
else if (Command.action == GLFW_RELEASE) {
|
||||
// visual feedback
|
||||
Train->ggRadioVolumeNext.UpdateValue(0.0);
|
||||
}
|
||||
}
|
||||
|
||||
void TTrain::OnCommand_radiovolumedecrease(TTrain *Train, command_data const &Command) {
|
||||
|
||||
if (Command.action == GLFW_PRESS) {
|
||||
Global.RadioVolume = clamp(Global.RadioVolume - 0.125, 0.0, 1.0);
|
||||
// visual feedback
|
||||
Train->ggRadioVolumeSelector.UpdateValue(Global.RadioVolume);
|
||||
Train->ggRadioVolumePrevious.UpdateValue(1.0);
|
||||
}
|
||||
else if (Command.action == GLFW_RELEASE) {
|
||||
// visual feedback
|
||||
Train->ggRadioVolumePrevious.UpdateValue(0.0);
|
||||
}
|
||||
}
|
||||
|
||||
void TTrain::OnCommand_cabchangeforward( TTrain *Train, command_data const &Command ) {
|
||||
|
||||
if( Command.action == GLFW_PRESS ) {
|
||||
@@ -6559,6 +6590,9 @@ bool TTrain::Update( double const Deltatime )
|
||||
ggRadioStop.Update();
|
||||
ggRadioTest.Update();
|
||||
ggRadioCall3.Update();
|
||||
ggRadioVolumeSelector.Update();
|
||||
ggRadioVolumePrevious.Update();
|
||||
ggRadioVolumeNext.Update();
|
||||
ggDepartureSignalButton.Update();
|
||||
|
||||
ggPantFrontButton.Update();
|
||||
@@ -7834,6 +7868,9 @@ void TTrain::clear_cab_controls()
|
||||
ggRadioStop.Clear();
|
||||
ggRadioTest.Clear();
|
||||
ggRadioCall3.Clear();
|
||||
ggRadioVolumeSelector.Clear();
|
||||
ggRadioVolumePrevious.Clear();
|
||||
ggRadioVolumeNext.Clear();
|
||||
ggDoorLeftPermitButton.Clear();
|
||||
ggDoorRightPermitButton.Clear();
|
||||
ggDoorPermitPresetButton.Clear();
|
||||
@@ -8540,6 +8577,9 @@ bool TTrain::initialize_gauge(cParser &Parser, std::string const &Label, int con
|
||||
{ "radiostop_sw:", ggRadioStop },
|
||||
{ "radiotest_sw:", ggRadioTest },
|
||||
{ "radiocall3_sw:", ggRadioCall3 },
|
||||
{ "radiovolume_sw:", ggRadioVolumeSelector },
|
||||
{ "radiovolumeprev_sw:", ggRadioVolumePrevious },
|
||||
{ "radiovolumenext_sw:", ggRadioVolumeNext },
|
||||
{ "pantfront_sw:", ggPantFrontButton },
|
||||
{ "pantrear_sw:", ggPantRearButton },
|
||||
{ "pantfrontoff_sw:", ggPantFrontButtonOff },
|
||||
|
||||
5
Train.h
5
Train.h
@@ -363,6 +363,8 @@ class TTrain {
|
||||
static void OnCommand_radiostopsend( 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);
|
||||
static void OnCommand_radiovolumedecrease(TTrain *Train, command_data const &Command);
|
||||
static void OnCommand_cabchangeforward( TTrain *Train, command_data const &Command );
|
||||
static void OnCommand_cabchangebackward( TTrain *Train, command_data const &Command );
|
||||
static void OnCommand_generictoggle( TTrain *Train, command_data const &Command );
|
||||
@@ -455,6 +457,9 @@ public: // reszta może by?publiczna
|
||||
TGauge ggRadioTest;
|
||||
TGauge ggRadioStop;
|
||||
TGauge ggRadioCall3;
|
||||
TGauge ggRadioVolumeSelector;
|
||||
TGauge ggRadioVolumePrevious;
|
||||
TGauge ggRadioVolumeNext;
|
||||
TGauge ggUpperLightButton;
|
||||
TGauge ggLeftLightButton;
|
||||
TGauge ggRightLightButton;
|
||||
|
||||
@@ -133,6 +133,8 @@ commanddescription_sequence Commands_descriptions = {
|
||||
{ "radiostopsend", command_target::vehicle },
|
||||
{ "radiostoptest", command_target::vehicle },
|
||||
{ "radiocall3send", command_target::vehicle },
|
||||
{ "radiovolumeincrease", command_target::vehicle },
|
||||
{ "radiovolumedecrease", command_target::vehicle },
|
||||
// TBD, TODO: make cab change controls entity-centric
|
||||
{ "cabchangeforward", command_target::vehicle },
|
||||
{ "cabchangebackward", command_target::vehicle },
|
||||
|
||||
@@ -127,6 +127,8 @@ enum class user_command {
|
||||
radiostopsend,
|
||||
radiostoptest,
|
||||
radiocall3send,
|
||||
radiovolumeincrease,
|
||||
radiovolumedecrease,
|
||||
cabchangeforward,
|
||||
cabchangebackward,
|
||||
|
||||
|
||||
@@ -735,6 +735,15 @@ drivermouse_input::default_bindings() {
|
||||
{ "radiocall3_sw:", {
|
||||
user_command::radiocall3send,
|
||||
user_command::none } },
|
||||
{ "radiovolume_sw:",{
|
||||
user_command::radiovolumeincrease,
|
||||
user_command::radiovolumedecrease } },
|
||||
{ "radiovolumeprev_sw:",{
|
||||
user_command::radiovolumedecrease,
|
||||
user_command::none } },
|
||||
{ "radiovolumenext_sw:",{
|
||||
user_command::radiovolumeincrease,
|
||||
user_command::none } },
|
||||
{ "pantfront_sw:", {
|
||||
user_command::pantographtogglefront,
|
||||
user_command::none } },
|
||||
|
||||
Reference in New Issue
Block a user