18
0
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:
jerrrrycho
2026-11-08 17:52:39 +01:00
parent 30bdc3da61
commit 43fc80f452
7 changed files with 94 additions and 34 deletions

View File

@@ -130,13 +130,22 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
case driver_hint::radioon: {
if( AIControllFlag ) {
mvOccupied->Radio = true;
mvOccupied->RadioFuse = true;
}
remove_hint( driver_hint::radiooff );
hint(
Action,
[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;
}
case driver_hint::radiochannel: {

View File

@@ -2,6 +2,7 @@ DRIVER_HINT_DEF(batteryon, STRN("Switch on battery"))
DRIVER_HINT_DEF(batteryoff, STRN("Switch off battery"))
DRIVER_HINT_DEF(radioon, STRN("Switch on 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(oilpumpon, STRN("Switch on oil pump"))
DRIVER_HINT_DEF(oilpumpoff, STRN("Switch off oil pump"))

View File

@@ -810,7 +810,7 @@ debug_panel::update_section_vehicle( std::vector<text_line> &Output ) {
mover.HeatingAllow ? 'h' :
'.',
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(),
// power transfers
// 3000v

View File

@@ -271,6 +271,8 @@ std::string locale::label_cab_control(std::string const &Label)
{ "converteroff_sw:", STRN("converter") },
{ "main_sw:", STRN("line breaker") },
{ "radio_sw:", STRN("radio") },
{ "radioon_sw:", STRN("radio") },
{ "radiooff_sw:", STRN("radio") },
{ "radiofuse_sw:", STRN("radio fuse") },
{ "radiofuseon_sw:", STRN("radio fuse") },
{ "radiofuseoff_sw:", STRN("radio fuse") },

View File

@@ -2689,6 +2689,7 @@ bool TController::PrepareEngine()
cue_action( driver_hint::batteryon );
cue_action( driver_hint::cabactivation);
cue_action( driver_hint::radiofuseon );
cue_action( driver_hint::radioon );
if( has_diesel_engine() ) {
@@ -6300,7 +6301,13 @@ TController::control_security_system( double const Timedelta ) {
// arbitrary 5 sec delay before switching radio back on
m_radiocontroltime = std::min( m_radiocontroltime, 5.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 {
m_radiocontroltime -= Timedelta;

View File

@@ -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
// only reacting to press, so the sound can loop uninterrupted
if (false == Train->mvOccupied->Radio)
{
// turn on
OnCommand_radioenable(Train, Command);
}
else
{
// turn off
OnCommand_radiodisable(Train, Command);
}
// 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);
}
void TTrain::OnCommand_radioenable(TTrain *Train, command_data const &Command)
{
if (Command.action != GLFW_PRESS)
{
return;
}
if (false == Train->mvOccupied->Radio)
if (Command.action == GLFW_PRESS)
{
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)
{
if (Command.action != GLFW_PRESS)
{
return;
}
if (Train->mvOccupied->Radio)
if (Command.action == GLFW_PRESS)
{
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;
}
if (Train->mvOccupied->RadioFuse)
{
OnCommand_radiofusedisable(Train, Command);
}
else
{
OnCommand_radiofuseenable(Train, Command);
}
// NOTE: flips the state directly rather than through radiofuseenable/radiofusedisable, so it doesn't move the
// radiofuseon_sw:/radiofuseoff_sw: buttons
Train->mvOccupied->RadioFuse = (false == Train->mvOccupied->RadioFuse);
}
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)
{
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)
{
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();
ggRadioVolumePrevious.Update();
ggRadioVolumeNext.Update();
ggRadioOnButton.Update();
ggRadioOffButton.Update();
ggRadioFuseOnButton.Update();
ggRadioFuseOffButton.Update();
ggDepartureSignalButton.Update();
/*
ggPantFrontButton.Update();
@@ -11102,6 +11131,10 @@ void TTrain::clear_cab_controls()
ggRadioVolumeSelector.Clear();
ggRadioVolumePrevious.Clear();
ggRadioVolumeNext.Clear();
ggRadioOnButton.Clear();
ggRadioOffButton.Clear();
ggRadioFuseOnButton.Clear();
ggRadioFuseOffButton.Clear();
ggDoorLeftPermitButton.Clear();
ggDoorRightPermitButton.Clear();
ggDoorPermitPresetButton.Clear();
@@ -11844,6 +11877,10 @@ bool TTrain::initialize_gauge(cParser &Parser, std::string const &Label, int con
{"radiovolume_sw:", ggRadioVolumeSelector},
{"radiovolumeprev_sw:", ggRadioVolumePrevious},
{"radiovolumenext_sw:", ggRadioVolumeNext},
{"radioon_sw:", ggRadioOnButton},
{"radiooff_sw:", ggRadioOffButton},
{"radiofuseon_sw:", ggRadioFuseOnButton},
{"radiofuseoff_sw:", ggRadioFuseOffButton},
/*
{ "pantfront_sw:", ggPantFrontButton },
{ "pantrear_sw:", ggPantRearButton },

View File

@@ -598,6 +598,10 @@ public: // reszta może by?publiczna
TGauge ggRadioVolumeSelector;
TGauge ggRadioVolumePrevious;
TGauge ggRadioVolumeNext;
TGauge ggRadioOnButton;
TGauge ggRadioOffButton;
TGauge ggRadioFuseOnButton;
TGauge ggRadioFuseOffButton;
TGauge ggUpperLightButton;
TGauge ggLeftLightButton;
TGauge ggRightLightButton;