mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-22 15:09:19 +02:00
Added volume switch and buttons for radio
This commit is contained in:
committed by
tmj-fstate
parent
0e87e554dc
commit
50f1a45def
68
Train.cpp
68
Train.cpp
@@ -348,6 +348,8 @@ TTrain::commandhandler_map const TTrain::m_commandhandlers = {
|
|||||||
{ user_command::radiostopsend, &TTrain::OnCommand_radiostopsend },
|
{ user_command::radiostopsend, &TTrain::OnCommand_radiostopsend },
|
||||||
{ user_command::radiostoptest, &TTrain::OnCommand_radiostoptest },
|
{ user_command::radiostoptest, &TTrain::OnCommand_radiostoptest },
|
||||||
{ user_command::radiocall3send, &TTrain::OnCommand_radiocall3send },
|
{ 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::cabchangeforward, &TTrain::OnCommand_cabchangeforward },
|
||||||
{ user_command::cabchangebackward, &TTrain::OnCommand_cabchangebackward },
|
{ user_command::cabchangebackward, &TTrain::OnCommand_cabchangebackward },
|
||||||
{ user_command::generictoggle0, &TTrain::OnCommand_generictoggle },
|
{ user_command::generictoggle0, &TTrain::OnCommand_generictoggle },
|
||||||
@@ -525,6 +527,7 @@ dictionary_source *TTrain::GetTrainState() {
|
|||||||
dict->insert( "pantpress", std::abs( mvControlled->PantPress ) );
|
dict->insert( "pantpress", std::abs( mvControlled->PantPress ) );
|
||||||
dict->insert( "universal3", InstrumentLightActive );
|
dict->insert( "universal3", InstrumentLightActive );
|
||||||
dict->insert( "radio_channel", RadioChannel() );
|
dict->insert( "radio_channel", RadioChannel() );
|
||||||
|
dict->insert( "radio_volume", Global.RadioVolume );
|
||||||
dict->insert( "door_lock", mvOccupied->Doors.lock_enabled );
|
dict->insert( "door_lock", mvOccupied->Doors.lock_enabled );
|
||||||
// movement data
|
// movement data
|
||||||
dict->insert( "velocity", std::abs( mvOccupied->Vel ) );
|
dict->insert( "velocity", std::abs( mvOccupied->Vel ) );
|
||||||
@@ -622,8 +625,8 @@ TTrain::state_t
|
|||||||
TTrain::get_state() const {
|
TTrain::get_state() const {
|
||||||
|
|
||||||
return {
|
return {
|
||||||
btLampkaSHP.GetValue(),
|
btLampkaSHP.GetValue(),
|
||||||
btLampkaCzuwaka.GetValue(),
|
btLampkaCzuwaka.GetValue(),
|
||||||
btLampkaRadioStop.GetValue(),
|
btLampkaRadioStop.GetValue(),
|
||||||
btLampkaOpory.GetValue(),
|
btLampkaOpory.GetValue(),
|
||||||
btLampkaWylSzybki.GetValue(),
|
btLampkaWylSzybki.GetValue(),
|
||||||
@@ -639,7 +642,7 @@ TTrain::get_state() const {
|
|||||||
static_cast<std::uint8_t>( iCabn ),
|
static_cast<std::uint8_t>( iCabn ),
|
||||||
btHaslerBrakes.GetValue(),
|
btHaslerBrakes.GetValue(),
|
||||||
btHaslerCurrent.GetValue(),
|
btHaslerCurrent.GetValue(),
|
||||||
mvOccupied->SecuritySystem.is_beeping(),
|
mvOccupied->SecuritySystem.is_beeping(),
|
||||||
btLampkaHVoltageB.GetValue(),
|
btLampkaHVoltageB.GetValue(),
|
||||||
fTachoVelocity,
|
fTachoVelocity,
|
||||||
static_cast<float>( mvOccupied->Compressor ),
|
static_cast<float>( mvOccupied->Compressor ),
|
||||||
@@ -3120,8 +3123,8 @@ void TTrain::OnCommand_compressorpresetactivatenext(TTrain *Train, command_data
|
|||||||
// active light preset is stored as value in range 1-LigthPosNo
|
// active light preset is stored as value in range 1-LigthPosNo
|
||||||
Train->mvOccupied->CompressorListPos = (
|
Train->mvOccupied->CompressorListPos = (
|
||||||
Train->mvOccupied->CompressorListPos < Train->mvOccupied->CompressorListPosNo ?
|
Train->mvOccupied->CompressorListPos < Train->mvOccupied->CompressorListPosNo ?
|
||||||
Train->mvOccupied->CompressorListPos + 1 :
|
Train->mvOccupied->CompressorListPos + 1 :
|
||||||
1); // wrap mode
|
1); // wrap mode
|
||||||
|
|
||||||
// visual feedback
|
// visual feedback
|
||||||
if (Train->ggCompressorListButton.SubModel != nullptr) {
|
if (Train->ggCompressorListButton.SubModel != nullptr) {
|
||||||
@@ -3142,12 +3145,12 @@ void TTrain::OnCommand_compressorpresetactivateprevious(TTrain *Train, command_d
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ((Train->mvOccupied->CompressorListPos > 1)
|
if ((Train->mvOccupied->CompressorListPos > 1)
|
||||||
|| (true == Train->mvOccupied->CompressorListWrap)) {
|
|| (true == Train->mvOccupied->CompressorListWrap)) {
|
||||||
// active light preset is stored as value in range 1-LigthPosNo
|
// active light preset is stored as value in range 1-LigthPosNo
|
||||||
Train->mvOccupied->CompressorListPos = (
|
Train->mvOccupied->CompressorListPos = (
|
||||||
Train->mvOccupied->CompressorListPos > 1 ?
|
Train->mvOccupied->CompressorListPos > 1 ?
|
||||||
Train->mvOccupied->CompressorListPos - 1 :
|
Train->mvOccupied->CompressorListPos - 1 :
|
||||||
Train->mvOccupied->CompressorListPosNo); // wrap mode
|
Train->mvOccupied->CompressorListPosNo); // wrap mode
|
||||||
|
|
||||||
// visual feedback
|
// visual feedback
|
||||||
if (Train->ggCompressorListButton.SubModel != nullptr) {
|
if (Train->ggCompressorListButton.SubModel != nullptr) {
|
||||||
@@ -5431,6 +5434,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 ) {
|
void TTrain::OnCommand_cabchangeforward( TTrain *Train, command_data const &Command ) {
|
||||||
|
|
||||||
if( Command.action == GLFW_PRESS ) {
|
if( Command.action == GLFW_PRESS ) {
|
||||||
@@ -6328,17 +6359,17 @@ bool TTrain::Update( double const Deltatime )
|
|||||||
btLampkaWylSzybkiB.Turn( mover->Mains );
|
btLampkaWylSzybkiB.Turn( mover->Mains );
|
||||||
btLampkaWylSzybkiBOff.Turn(
|
btLampkaWylSzybkiBOff.Turn(
|
||||||
( false == mover->Mains )
|
( false == mover->Mains )
|
||||||
&& ( mover->MainsInitTimeCountdown <= 0.0 )
|
&& ( mover->MainsInitTimeCountdown <= 0.0 )
|
||||||
/*&& ( fHVoltage != 0.0 )*/ );
|
/*&& ( fHVoltage != 0.0 )*/ );
|
||||||
|
|
||||||
btLampkaOporyB.Turn( mover->ResistorsFlagCheck() );
|
btLampkaOporyB.Turn( mover->ResistorsFlagCheck() );
|
||||||
btLampkaBezoporowaB.Turn(
|
btLampkaBezoporowaB.Turn(
|
||||||
( true == mover->ResistorsFlagCheck() )
|
( true == mover->ResistorsFlagCheck() )
|
||||||
|| ( mover->MainCtrlActualPos == 0 ) ); // do EU04
|
|| ( mover->MainCtrlActualPos == 0 ) ); // do EU04
|
||||||
|
|
||||||
if( ( mover->StLinFlag )
|
if( ( mover->StLinFlag )
|
||||||
|| ( mover->BrakePress > 2.0 )
|
|| ( mover->BrakePress > 2.0 )
|
||||||
|| ( mover->PipePress < 0.36 ) ) {
|
|| ( mover->PipePress < 0.36 ) ) {
|
||||||
btLampkaStycznB.Turn( false );
|
btLampkaStycznB.Turn( false );
|
||||||
}
|
}
|
||||||
else if( mover->BrakePress < 1.0 ) {
|
else if( mover->BrakePress < 1.0 ) {
|
||||||
@@ -6598,6 +6629,9 @@ bool TTrain::Update( double const Deltatime )
|
|||||||
ggRadioStop.Update();
|
ggRadioStop.Update();
|
||||||
ggRadioTest.Update();
|
ggRadioTest.Update();
|
||||||
ggRadioCall3.Update();
|
ggRadioCall3.Update();
|
||||||
|
ggRadioVolumeSelector.Update();
|
||||||
|
ggRadioVolumePrevious.Update();
|
||||||
|
ggRadioVolumeNext.Update();
|
||||||
ggDepartureSignalButton.Update();
|
ggDepartureSignalButton.Update();
|
||||||
|
|
||||||
ggPantFrontButton.Update();
|
ggPantFrontButton.Update();
|
||||||
@@ -7873,6 +7907,9 @@ void TTrain::clear_cab_controls()
|
|||||||
ggRadioStop.Clear();
|
ggRadioStop.Clear();
|
||||||
ggRadioTest.Clear();
|
ggRadioTest.Clear();
|
||||||
ggRadioCall3.Clear();
|
ggRadioCall3.Clear();
|
||||||
|
ggRadioVolumeSelector.Clear();
|
||||||
|
ggRadioVolumePrevious.Clear();
|
||||||
|
ggRadioVolumeNext.Clear();
|
||||||
ggDoorLeftPermitButton.Clear();
|
ggDoorLeftPermitButton.Clear();
|
||||||
ggDoorRightPermitButton.Clear();
|
ggDoorRightPermitButton.Clear();
|
||||||
ggDoorPermitPresetButton.Clear();
|
ggDoorPermitPresetButton.Clear();
|
||||||
@@ -8579,6 +8616,9 @@ bool TTrain::initialize_gauge(cParser &Parser, std::string const &Label, int con
|
|||||||
{ "radiostop_sw:", ggRadioStop },
|
{ "radiostop_sw:", ggRadioStop },
|
||||||
{ "radiotest_sw:", ggRadioTest },
|
{ "radiotest_sw:", ggRadioTest },
|
||||||
{ "radiocall3_sw:", ggRadioCall3 },
|
{ "radiocall3_sw:", ggRadioCall3 },
|
||||||
|
{ "radiovolume_sw:", ggRadioVolumeSelector },
|
||||||
|
{ "radiovolumeprev_sw:", ggRadioVolumePrevious },
|
||||||
|
{ "radiovolumenext_sw:", ggRadioVolumeNext },
|
||||||
{ "pantfront_sw:", ggPantFrontButton },
|
{ "pantfront_sw:", ggPantFrontButton },
|
||||||
{ "pantrear_sw:", ggPantRearButton },
|
{ "pantrear_sw:", ggPantRearButton },
|
||||||
{ "pantfrontoff_sw:", ggPantFrontButtonOff },
|
{ "pantfrontoff_sw:", ggPantFrontButtonOff },
|
||||||
@@ -8609,7 +8649,7 @@ bool TTrain::initialize_gauge(cParser &Parser, std::string const &Label, int con
|
|||||||
{ "universal7:", ggUniversals[ 7 ] },
|
{ "universal7:", ggUniversals[ 7 ] },
|
||||||
{ "universal8:", ggUniversals[ 8 ] },
|
{ "universal8:", ggUniversals[ 8 ] },
|
||||||
{ "universal9:", ggUniversals[ 9 ] }
|
{ "universal9:", ggUniversals[ 9 ] }
|
||||||
};
|
};
|
||||||
{
|
{
|
||||||
auto const lookup { gauges.find( Label ) };
|
auto const lookup { gauges.find( Label ) };
|
||||||
if( lookup != gauges.end() ) {
|
if( lookup != gauges.end() ) {
|
||||||
|
|||||||
5
Train.h
5
Train.h
@@ -368,6 +368,8 @@ class TTrain {
|
|||||||
static void OnCommand_radiostopsend( TTrain *Train, command_data const &Command );
|
static void OnCommand_radiostopsend( TTrain *Train, command_data const &Command );
|
||||||
static void OnCommand_radiostoptest( 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_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_cabchangeforward( TTrain *Train, command_data const &Command );
|
||||||
static void OnCommand_cabchangebackward( 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 );
|
static void OnCommand_generictoggle( TTrain *Train, command_data const &Command );
|
||||||
@@ -460,6 +462,9 @@ public: // reszta może by?publiczna
|
|||||||
TGauge ggRadioTest;
|
TGauge ggRadioTest;
|
||||||
TGauge ggRadioStop;
|
TGauge ggRadioStop;
|
||||||
TGauge ggRadioCall3;
|
TGauge ggRadioCall3;
|
||||||
|
TGauge ggRadioVolumeSelector;
|
||||||
|
TGauge ggRadioVolumePrevious;
|
||||||
|
TGauge ggRadioVolumeNext;
|
||||||
TGauge ggUpperLightButton;
|
TGauge ggUpperLightButton;
|
||||||
TGauge ggLeftLightButton;
|
TGauge ggLeftLightButton;
|
||||||
TGauge ggRightLightButton;
|
TGauge ggRightLightButton;
|
||||||
|
|||||||
@@ -133,6 +133,8 @@ commanddescription_sequence Commands_descriptions = {
|
|||||||
{ "radiostopsend", command_target::vehicle },
|
{ "radiostopsend", command_target::vehicle },
|
||||||
{ "radiostoptest", command_target::vehicle },
|
{ "radiostoptest", command_target::vehicle },
|
||||||
{ "radiocall3send", command_target::vehicle },
|
{ "radiocall3send", command_target::vehicle },
|
||||||
|
{ "radiovolumeincrease", command_target::vehicle },
|
||||||
|
{ "radiovolumedecrease", command_target::vehicle },
|
||||||
// TBD, TODO: make cab change controls entity-centric
|
// TBD, TODO: make cab change controls entity-centric
|
||||||
{ "cabchangeforward", command_target::vehicle },
|
{ "cabchangeforward", command_target::vehicle },
|
||||||
{ "cabchangebackward", command_target::vehicle },
|
{ "cabchangebackward", command_target::vehicle },
|
||||||
|
|||||||
@@ -127,6 +127,8 @@ enum class user_command {
|
|||||||
radiostopsend,
|
radiostopsend,
|
||||||
radiostoptest,
|
radiostoptest,
|
||||||
radiocall3send,
|
radiocall3send,
|
||||||
|
radiovolumeincrease,
|
||||||
|
radiovolumedecrease,
|
||||||
cabchangeforward,
|
cabchangeforward,
|
||||||
cabchangebackward,
|
cabchangebackward,
|
||||||
|
|
||||||
|
|||||||
@@ -740,6 +740,15 @@ drivermouse_input::default_bindings() {
|
|||||||
{ "radiocall3_sw:", {
|
{ "radiocall3_sw:", {
|
||||||
user_command::radiocall3send,
|
user_command::radiocall3send,
|
||||||
user_command::none } },
|
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:", {
|
{ "pantfront_sw:", {
|
||||||
user_command::pantographtogglefront,
|
user_command::pantographtogglefront,
|
||||||
user_command::none } },
|
user_command::none } },
|
||||||
|
|||||||
Reference in New Issue
Block a user