mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-22 12:49:18 +02:00
refactoring: radio channel variable unification
This commit is contained in:
16
Train.cpp
16
Train.cpp
@@ -524,7 +524,7 @@ dictionary_source *TTrain::GetTrainState() {
|
|||||||
dict->insert( "distance_counter", m_distancecounter );
|
dict->insert( "distance_counter", m_distancecounter );
|
||||||
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", iRadioChannel );
|
dict->insert( "radio_channel", RadioChannel() );
|
||||||
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 ) );
|
||||||
@@ -5353,9 +5353,9 @@ void TTrain::OnCommand_radiotoggle( TTrain *Train, command_data const &Command )
|
|||||||
void TTrain::OnCommand_radiochannelincrease( TTrain *Train, command_data const &Command ) {
|
void TTrain::OnCommand_radiochannelincrease( TTrain *Train, command_data const &Command ) {
|
||||||
|
|
||||||
if( Command.action == GLFW_PRESS ) {
|
if( Command.action == GLFW_PRESS ) {
|
||||||
Train->iRadioChannel = clamp( Train->iRadioChannel + 1, 1, 10 );
|
Train->RadioChannel() = clamp( Train->RadioChannel() + 1, 1, 10 );
|
||||||
// visual feedback
|
// visual feedback
|
||||||
Train->ggRadioChannelSelector.UpdateValue( Train->iRadioChannel - 1 );
|
Train->ggRadioChannelSelector.UpdateValue( Train->RadioChannel() - 1 );
|
||||||
Train->ggRadioChannelNext.UpdateValue( 1.0 );
|
Train->ggRadioChannelNext.UpdateValue( 1.0 );
|
||||||
}
|
}
|
||||||
else if( Command.action == GLFW_RELEASE ) {
|
else if( Command.action == GLFW_RELEASE ) {
|
||||||
@@ -5367,9 +5367,9 @@ void TTrain::OnCommand_radiochannelincrease( TTrain *Train, command_data const &
|
|||||||
void TTrain::OnCommand_radiochanneldecrease( TTrain *Train, command_data const &Command ) {
|
void TTrain::OnCommand_radiochanneldecrease( TTrain *Train, command_data const &Command ) {
|
||||||
|
|
||||||
if( Command.action == GLFW_PRESS ) {
|
if( Command.action == GLFW_PRESS ) {
|
||||||
Train->iRadioChannel = clamp( Train->iRadioChannel - 1, 1, 10 );
|
Train->RadioChannel() = clamp( Train->RadioChannel() - 1, 1, 10 );
|
||||||
// visual feedback
|
// visual feedback
|
||||||
Train->ggRadioChannelSelector.UpdateValue( Train->iRadioChannel - 1 );
|
Train->ggRadioChannelSelector.UpdateValue( Train->RadioChannel() - 1 );
|
||||||
Train->ggRadioChannelPrevious.UpdateValue( 1.0 );
|
Train->ggRadioChannelPrevious.UpdateValue( 1.0 );
|
||||||
}
|
}
|
||||||
else if( Command.action == GLFW_RELEASE ) {
|
else if( Command.action == GLFW_RELEASE ) {
|
||||||
@@ -7085,7 +7085,7 @@ void TTrain::update_sounds_radio() {
|
|||||||
for( auto &message : m_radiomessages ) {
|
for( auto &message : m_radiomessages ) {
|
||||||
auto const volume {
|
auto const volume {
|
||||||
( true == radioenabled )
|
( true == radioenabled )
|
||||||
&& ( message.first == iRadioChannel ) ?
|
&& ( message.first == RadioChannel() ) ?
|
||||||
Global.RadioVolume :
|
Global.RadioVolume :
|
||||||
0.0 };
|
0.0 };
|
||||||
message.second->gain( volume );
|
message.second->gain( volume );
|
||||||
@@ -7743,7 +7743,7 @@ TTrain::radio_message( sound_source *Message, int const Channel ) {
|
|||||||
auto const radioenabled { ( true == mvOccupied->Radio ) && ( mvControlled->Battery || mvControlled->ConverterFlag ) };
|
auto const radioenabled { ( true == mvOccupied->Radio ) && ( mvControlled->Battery || mvControlled->ConverterFlag ) };
|
||||||
auto const volume {
|
auto const volume {
|
||||||
( true == radioenabled )
|
( true == radioenabled )
|
||||||
&& ( Channel == iRadioChannel ) ?
|
&& ( Channel == RadioChannel() ) ?
|
||||||
1.0 :
|
1.0 :
|
||||||
0.0 };
|
0.0 };
|
||||||
message
|
message
|
||||||
@@ -8038,7 +8038,7 @@ void TTrain::set_cab_controls( int const Cab ) {
|
|||||||
if( true == mvOccupied->Radio ) {
|
if( true == mvOccupied->Radio ) {
|
||||||
ggRadioButton.PutValue( 1.f );
|
ggRadioButton.PutValue( 1.f );
|
||||||
}
|
}
|
||||||
ggRadioChannelSelector.PutValue( iRadioChannel - 1 );
|
ggRadioChannelSelector.PutValue( RadioChannel() - 1 );
|
||||||
// pantographs
|
// pantographs
|
||||||
if( mvOccupied->PantSwitchType != "impulse" ) {
|
if( mvOccupied->PantSwitchType != "impulse" ) {
|
||||||
if( ggPantFrontButton.SubModel ) {
|
if( ggPantFrontButton.SubModel ) {
|
||||||
|
|||||||
5
Train.h
5
Train.h
@@ -11,6 +11,7 @@ http://mozilla.org/MPL/2.0/.
|
|||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include "DynObj.h"
|
#include "DynObj.h"
|
||||||
|
#include "Driver.h"
|
||||||
#include "Button.h"
|
#include "Button.h"
|
||||||
#include "Gauge.h"
|
#include "Gauge.h"
|
||||||
#include "sound.h"
|
#include "sound.h"
|
||||||
@@ -729,7 +730,6 @@ private:
|
|||||||
float fPPress, fNPress;
|
float fPPress, fNPress;
|
||||||
bool m_mastercontrollerinuse { false };
|
bool m_mastercontrollerinuse { false };
|
||||||
float m_mastercontrollerreturndelay { 0.f };
|
float m_mastercontrollerreturndelay { 0.f };
|
||||||
int iRadioChannel { 1 }; // numer aktualnego kana?u radiowego
|
|
||||||
std::vector<std::pair<std::string, texture_handle>> m_screens;
|
std::vector<std::pair<std::string, texture_handle>> m_screens;
|
||||||
float m_distancecounter { -1.f }; // distance traveled since meter was activated or -1 if inactive
|
float m_distancecounter { -1.f }; // distance traveled since meter was activated or -1 if inactive
|
||||||
|
|
||||||
@@ -739,9 +739,10 @@ private:
|
|||||||
static std::vector<std::string> const fPress_labels;
|
static std::vector<std::string> const fPress_labels;
|
||||||
float fEIMParams[9][10]; // parametry dla silnikow asynchronicznych
|
float fEIMParams[9][10]; // parametry dla silnikow asynchronicznych
|
||||||
float fDieselParams[9][10]; // parametry dla silnikow asynchronicznych
|
float fDieselParams[9][10]; // parametry dla silnikow asynchronicznych
|
||||||
int RadioChannel() const { return iRadioChannel; };
|
|
||||||
// plays provided sound from position of the radio
|
// plays provided sound from position of the radio
|
||||||
void radio_message( sound_source *Message, int const Channel );
|
void radio_message( sound_source *Message, int const Channel );
|
||||||
|
inline auto const &RadioChannel() const { return Dynamic()->Mechanik->iRadioChannel; }
|
||||||
|
inline auto &RadioChannel() { return Dynamic()->Mechanik->iRadioChannel; }
|
||||||
inline TDynamicObject *Dynamic() { return DynamicObject; };
|
inline TDynamicObject *Dynamic() { return DynamicObject; };
|
||||||
inline TDynamicObject const *Dynamic() const { return DynamicObject; };
|
inline TDynamicObject const *Dynamic() const { return DynamicObject; };
|
||||||
inline TMoverParameters *Controlled() { return mvControlled; };
|
inline TMoverParameters *Controlled() { return mvControlled; };
|
||||||
|
|||||||
Reference in New Issue
Block a user