mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-11-24 02:39:14 +01:00
fix: radio fuse review: working push buttons, own hint, HUD
- radioon_sw:/radiooff_sw:/radiofuseon_sw:/radiofuseoff_sw: are now loaded as push-button gauges in initialize_gauge, so they can be clicked; the enable/disable commands press them while held. radiotoggle and radiofusetoggle flip the state directly, so they don't move them. - New driver hint "Close radio fuse" (radiofuseon); "Switch on radio" is given only when the radio's own switch is off. - The HUD shows the radio channel only with the fuse closed. (eu07/maszyna#438)
This commit is contained in:
@@ -130,13 +130,22 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
|
|||||||
case driver_hint::radioon: {
|
case driver_hint::radioon: {
|
||||||
if( AIControllFlag ) {
|
if( AIControllFlag ) {
|
||||||
mvOccupied->Radio = true;
|
mvOccupied->Radio = true;
|
||||||
mvOccupied->RadioFuse = true;
|
|
||||||
}
|
}
|
||||||
remove_hint( driver_hint::radiooff );
|
remove_hint( driver_hint::radiooff );
|
||||||
hint(
|
hint(
|
||||||
Action,
|
Action,
|
||||||
[this](float const /*Parameter*/) {
|
[this](float const /*Parameter*/) {
|
||||||
return mvOccupied->Radio && mvOccupied->RadioFuse; } );
|
return mvOccupied->Radio == true; } );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case driver_hint::radiofuseon: {
|
||||||
|
if( AIControllFlag ) {
|
||||||
|
mvOccupied->RadioFuse = true;
|
||||||
|
}
|
||||||
|
hint(
|
||||||
|
Action,
|
||||||
|
[this](float const /*Parameter*/) {
|
||||||
|
return mvOccupied->RadioFuse == true; } );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case driver_hint::radiochannel: {
|
case driver_hint::radiochannel: {
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ DRIVER_HINT_DEF(batteryon, STRN("Switch on battery"))
|
|||||||
DRIVER_HINT_DEF(batteryoff, STRN("Switch off battery"))
|
DRIVER_HINT_DEF(batteryoff, STRN("Switch off battery"))
|
||||||
DRIVER_HINT_DEF(radioon, STRN("Switch on radio"))
|
DRIVER_HINT_DEF(radioon, STRN("Switch on radio"))
|
||||||
DRIVER_HINT_DEF(radiooff, STRN("Switch off radio"))
|
DRIVER_HINT_DEF(radiooff, STRN("Switch off radio"))
|
||||||
|
DRIVER_HINT_DEF(radiofuseon, STRN("Close radio fuse"))
|
||||||
DRIVER_HINT_DEF(radiochannel, STRN("Tune into channel %.0f"))
|
DRIVER_HINT_DEF(radiochannel, STRN("Tune into channel %.0f"))
|
||||||
DRIVER_HINT_DEF(oilpumpon, STRN("Switch on oil pump"))
|
DRIVER_HINT_DEF(oilpumpon, STRN("Switch on oil pump"))
|
||||||
DRIVER_HINT_DEF(oilpumpoff, STRN("Switch off oil pump"))
|
DRIVER_HINT_DEF(oilpumpoff, STRN("Switch off oil pump"))
|
||||||
|
|||||||
@@ -810,7 +810,7 @@ debug_panel::update_section_vehicle( std::vector<text_line> &Output ) {
|
|||||||
mover.HeatingAllow ? 'h' :
|
mover.HeatingAllow ? 'h' :
|
||||||
'.',
|
'.',
|
||||||
mover.Hamulec->Releaser() ? '^' : '.',
|
mover.Hamulec->Releaser() ? '^' : '.',
|
||||||
std::string( m_input.mechanik ? STR(" R") + ( mover.Radio ? std::to_string( m_input.mechanik->iRadioChannel ) : "-" ) : "" ).c_str(),
|
std::string( m_input.mechanik ? STR(" R") + ( mover.Radio && mover.RadioFuse ? std::to_string( m_input.mechanik->iRadioChannel ) : "-" ) : "" ).c_str(),
|
||||||
std::string( isdieselenginepowered ? STR(" oil pressure: ") + to_string( mover.OilPump.pressure, 2 ) : "" ).c_str(),
|
std::string( isdieselenginepowered ? STR(" oil pressure: ") + to_string( mover.OilPump.pressure, 2 ) : "" ).c_str(),
|
||||||
// power transfers
|
// power transfers
|
||||||
// 3000v
|
// 3000v
|
||||||
|
|||||||
@@ -271,6 +271,8 @@ std::string locale::label_cab_control(std::string const &Label)
|
|||||||
{ "converteroff_sw:", STRN("converter") },
|
{ "converteroff_sw:", STRN("converter") },
|
||||||
{ "main_sw:", STRN("line breaker") },
|
{ "main_sw:", STRN("line breaker") },
|
||||||
{ "radio_sw:", STRN("radio") },
|
{ "radio_sw:", STRN("radio") },
|
||||||
|
{ "radioon_sw:", STRN("radio") },
|
||||||
|
{ "radiooff_sw:", STRN("radio") },
|
||||||
{ "radiofuse_sw:", STRN("radio fuse") },
|
{ "radiofuse_sw:", STRN("radio fuse") },
|
||||||
{ "radiofuseon_sw:", STRN("radio fuse") },
|
{ "radiofuseon_sw:", STRN("radio fuse") },
|
||||||
{ "radiofuseoff_sw:", STRN("radio fuse") },
|
{ "radiofuseoff_sw:", STRN("radio fuse") },
|
||||||
|
|||||||
@@ -2689,6 +2689,7 @@ bool TController::PrepareEngine()
|
|||||||
|
|
||||||
cue_action( driver_hint::batteryon );
|
cue_action( driver_hint::batteryon );
|
||||||
cue_action( driver_hint::cabactivation);
|
cue_action( driver_hint::cabactivation);
|
||||||
|
cue_action( driver_hint::radiofuseon );
|
||||||
cue_action( driver_hint::radioon );
|
cue_action( driver_hint::radioon );
|
||||||
|
|
||||||
if( has_diesel_engine() ) {
|
if( has_diesel_engine() ) {
|
||||||
@@ -6300,7 +6301,13 @@ TController::control_security_system( double const Timedelta ) {
|
|||||||
// arbitrary 5 sec delay before switching radio back on
|
// arbitrary 5 sec delay before switching radio back on
|
||||||
m_radiocontroltime = std::min( m_radiocontroltime, 5.0 );
|
m_radiocontroltime = std::min( m_radiocontroltime, 5.0 );
|
||||||
if( m_radiocontroltime < 0.0 ) {
|
if( m_radiocontroltime < 0.0 ) {
|
||||||
cue_action( driver_hint::radioon );
|
// hint at whichever of the two is open, the radio's switch or the cut-off in its power supply
|
||||||
|
if( false == mvOccupied->RadioFuse ) {
|
||||||
|
cue_action( driver_hint::radiofuseon );
|
||||||
|
}
|
||||||
|
if( false == mvOccupied->Radio ) {
|
||||||
|
cue_action( driver_hint::radioon );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
m_radiocontroltime -= Timedelta;
|
m_radiocontroltime -= Timedelta;
|
||||||
|
|||||||
@@ -7998,41 +7998,47 @@ void TTrain::OnCommand_radiotoggle(TTrain *Train, command_data const &Command)
|
|||||||
|
|
||||||
// NOTE: works without the switch in the 3d model too, to allow system reset after receiving radio-stop signal
|
// NOTE: works without the switch in the 3d model too, to allow system reset after receiving radio-stop signal
|
||||||
// only reacting to press, so the sound can loop uninterrupted
|
// only reacting to press, so the sound can loop uninterrupted
|
||||||
if (false == Train->mvOccupied->Radio)
|
// NOTE: flips the state directly rather than through radioenable/radiodisable, so it doesn't move the radioon_sw:/radiooff_sw: buttons
|
||||||
{
|
Train->mvOccupied->Radio = (false == Train->mvOccupied->Radio);
|
||||||
// turn on
|
|
||||||
OnCommand_radioenable(Train, Command);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// turn off
|
|
||||||
OnCommand_radiodisable(Train, Command);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TTrain::OnCommand_radioenable(TTrain *Train, command_data const &Command)
|
void TTrain::OnCommand_radioenable(TTrain *Train, command_data const &Command)
|
||||||
{
|
{
|
||||||
if (Command.action != GLFW_PRESS)
|
if (Command.action == GLFW_PRESS)
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (false == Train->mvOccupied->Radio)
|
|
||||||
{
|
{
|
||||||
Train->mvOccupied->Radio = true;
|
Train->mvOccupied->Radio = true;
|
||||||
|
// visual feedback
|
||||||
|
if (Train->m_controlmapper.contains("radioon_sw:"))
|
||||||
|
{
|
||||||
|
Train->ggRadioOnButton.UpdateValue(1.0f, Train->dsbSwitch);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (Command.action == GLFW_RELEASE)
|
||||||
|
{
|
||||||
|
if (Train->m_controlmapper.contains("radioon_sw:"))
|
||||||
|
{
|
||||||
|
Train->ggRadioOnButton.UpdateValue(0.0f, Train->dsbSwitch);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TTrain::OnCommand_radiodisable(TTrain *Train, command_data const &Command)
|
void TTrain::OnCommand_radiodisable(TTrain *Train, command_data const &Command)
|
||||||
{
|
{
|
||||||
if (Command.action != GLFW_PRESS)
|
if (Command.action == GLFW_PRESS)
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Train->mvOccupied->Radio)
|
|
||||||
{
|
{
|
||||||
Train->mvOccupied->Radio = false;
|
Train->mvOccupied->Radio = false;
|
||||||
|
// visual feedback
|
||||||
|
if (Train->m_controlmapper.contains("radiooff_sw:"))
|
||||||
|
{
|
||||||
|
Train->ggRadioOffButton.UpdateValue(1.0f, Train->dsbSwitch);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (Command.action == GLFW_RELEASE)
|
||||||
|
{
|
||||||
|
if (Train->m_controlmapper.contains("radiooff_sw:"))
|
||||||
|
{
|
||||||
|
Train->ggRadioOffButton.UpdateValue(0.0f, Train->dsbSwitch);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -8045,14 +8051,9 @@ void TTrain::OnCommand_radiofusetoggle(TTrain *Train, command_data const &Comman
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Train->mvOccupied->RadioFuse)
|
// NOTE: flips the state directly rather than through radiofuseenable/radiofusedisable, so it doesn't move the
|
||||||
{
|
// radiofuseon_sw:/radiofuseoff_sw: buttons
|
||||||
OnCommand_radiofusedisable(Train, Command);
|
Train->mvOccupied->RadioFuse = (false == Train->mvOccupied->RadioFuse);
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
OnCommand_radiofuseenable(Train, Command);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TTrain::OnCommand_radiofuseenable(TTrain *Train, command_data const &Command)
|
void TTrain::OnCommand_radiofuseenable(TTrain *Train, command_data const &Command)
|
||||||
@@ -8060,6 +8061,18 @@ void TTrain::OnCommand_radiofuseenable(TTrain *Train, command_data const &Comman
|
|||||||
if (Command.action == GLFW_PRESS)
|
if (Command.action == GLFW_PRESS)
|
||||||
{
|
{
|
||||||
Train->mvOccupied->RadioFuse = true;
|
Train->mvOccupied->RadioFuse = true;
|
||||||
|
// visual feedback
|
||||||
|
if (Train->m_controlmapper.contains("radiofuseon_sw:"))
|
||||||
|
{
|
||||||
|
Train->ggRadioFuseOnButton.UpdateValue(1.0f, Train->dsbSwitch);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (Command.action == GLFW_RELEASE)
|
||||||
|
{
|
||||||
|
if (Train->m_controlmapper.contains("radiofuseon_sw:"))
|
||||||
|
{
|
||||||
|
Train->ggRadioFuseOnButton.UpdateValue(0.0f, Train->dsbSwitch);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -8068,6 +8081,18 @@ void TTrain::OnCommand_radiofusedisable(TTrain *Train, command_data const &Comma
|
|||||||
if (Command.action == GLFW_PRESS)
|
if (Command.action == GLFW_PRESS)
|
||||||
{
|
{
|
||||||
Train->mvOccupied->RadioFuse = false;
|
Train->mvOccupied->RadioFuse = false;
|
||||||
|
// visual feedback
|
||||||
|
if (Train->m_controlmapper.contains("radiofuseoff_sw:"))
|
||||||
|
{
|
||||||
|
Train->ggRadioFuseOffButton.UpdateValue(1.0f, Train->dsbSwitch);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (Command.action == GLFW_RELEASE)
|
||||||
|
{
|
||||||
|
if (Train->m_controlmapper.contains("radiofuseoff_sw:"))
|
||||||
|
{
|
||||||
|
Train->ggRadioFuseOffButton.UpdateValue(0.0f, Train->dsbSwitch);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -9562,6 +9587,10 @@ bool TTrain::Update(double const Deltatime)
|
|||||||
ggRadioVolumeSelector.Update();
|
ggRadioVolumeSelector.Update();
|
||||||
ggRadioVolumePrevious.Update();
|
ggRadioVolumePrevious.Update();
|
||||||
ggRadioVolumeNext.Update();
|
ggRadioVolumeNext.Update();
|
||||||
|
ggRadioOnButton.Update();
|
||||||
|
ggRadioOffButton.Update();
|
||||||
|
ggRadioFuseOnButton.Update();
|
||||||
|
ggRadioFuseOffButton.Update();
|
||||||
ggDepartureSignalButton.Update();
|
ggDepartureSignalButton.Update();
|
||||||
/*
|
/*
|
||||||
ggPantFrontButton.Update();
|
ggPantFrontButton.Update();
|
||||||
@@ -11102,6 +11131,10 @@ void TTrain::clear_cab_controls()
|
|||||||
ggRadioVolumeSelector.Clear();
|
ggRadioVolumeSelector.Clear();
|
||||||
ggRadioVolumePrevious.Clear();
|
ggRadioVolumePrevious.Clear();
|
||||||
ggRadioVolumeNext.Clear();
|
ggRadioVolumeNext.Clear();
|
||||||
|
ggRadioOnButton.Clear();
|
||||||
|
ggRadioOffButton.Clear();
|
||||||
|
ggRadioFuseOnButton.Clear();
|
||||||
|
ggRadioFuseOffButton.Clear();
|
||||||
ggDoorLeftPermitButton.Clear();
|
ggDoorLeftPermitButton.Clear();
|
||||||
ggDoorRightPermitButton.Clear();
|
ggDoorRightPermitButton.Clear();
|
||||||
ggDoorPermitPresetButton.Clear();
|
ggDoorPermitPresetButton.Clear();
|
||||||
@@ -11844,6 +11877,10 @@ bool TTrain::initialize_gauge(cParser &Parser, std::string const &Label, int con
|
|||||||
{"radiovolume_sw:", ggRadioVolumeSelector},
|
{"radiovolume_sw:", ggRadioVolumeSelector},
|
||||||
{"radiovolumeprev_sw:", ggRadioVolumePrevious},
|
{"radiovolumeprev_sw:", ggRadioVolumePrevious},
|
||||||
{"radiovolumenext_sw:", ggRadioVolumeNext},
|
{"radiovolumenext_sw:", ggRadioVolumeNext},
|
||||||
|
{"radioon_sw:", ggRadioOnButton},
|
||||||
|
{"radiooff_sw:", ggRadioOffButton},
|
||||||
|
{"radiofuseon_sw:", ggRadioFuseOnButton},
|
||||||
|
{"radiofuseoff_sw:", ggRadioFuseOffButton},
|
||||||
/*
|
/*
|
||||||
{ "pantfront_sw:", ggPantFrontButton },
|
{ "pantfront_sw:", ggPantFrontButton },
|
||||||
{ "pantrear_sw:", ggPantRearButton },
|
{ "pantrear_sw:", ggPantRearButton },
|
||||||
|
|||||||
@@ -598,6 +598,10 @@ public: // reszta może by?publiczna
|
|||||||
TGauge ggRadioVolumeSelector;
|
TGauge ggRadioVolumeSelector;
|
||||||
TGauge ggRadioVolumePrevious;
|
TGauge ggRadioVolumePrevious;
|
||||||
TGauge ggRadioVolumeNext;
|
TGauge ggRadioVolumeNext;
|
||||||
|
TGauge ggRadioOnButton;
|
||||||
|
TGauge ggRadioOffButton;
|
||||||
|
TGauge ggRadioFuseOnButton;
|
||||||
|
TGauge ggRadioFuseOffButton;
|
||||||
TGauge ggUpperLightButton;
|
TGauge ggUpperLightButton;
|
||||||
TGauge ggLeftLightButton;
|
TGauge ggLeftLightButton;
|
||||||
TGauge ggRightLightButton;
|
TGauge ggRightLightButton;
|
||||||
|
|||||||
Reference in New Issue
Block a user