16
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-07-23 12:09:18 +02:00

radio volume slider

This commit is contained in:
milek7
2023-08-08 16:05:16 +02:00
parent 27e03ab9e8
commit 9259708d4c
5 changed files with 22 additions and 26 deletions

View File

@@ -154,8 +154,8 @@ global_settings::ConfigParse(cParser &Parser) {
{ {
// selected device for audio renderer // selected device for audio renderer
Parser.getTokens(); Parser.getTokens();
Parser >> RadioVolume; Parser >> DefaultRadioVolume;
RadioVolume = clamp(RadioVolume, 0.f, 1.f); DefaultRadioVolume = clamp(DefaultRadioVolume, 0.f, 1.f);
} }
else if (token == "sound.maxsources") { else if (token == "sound.maxsources") {
Parser.getTokens(); Parser.getTokens();
@@ -1241,7 +1241,7 @@ global_settings::export_as_text( std::ostream &Output ) const {
export_as_text( Output, "soundenabled", bSoundEnabled ); export_as_text( Output, "soundenabled", bSoundEnabled );
export_as_text( Output, "sound.openal.renderer", AudioRenderer ); export_as_text( Output, "sound.openal.renderer", AudioRenderer );
export_as_text( Output, "sound.volume", AudioVolume ); export_as_text( Output, "sound.volume", AudioVolume );
export_as_text( Output, "sound.volume.radio", RadioVolume ); export_as_text( Output, "sound.volume.radio", DefaultRadioVolume );
export_as_text( Output, "sound.volume.vehicle", VehicleVolume ); export_as_text( Output, "sound.volume.vehicle", VehicleVolume );
export_as_text( Output, "sound.volume.positional", EnvironmentPositionalVolume ); export_as_text( Output, "sound.volume.positional", EnvironmentPositionalVolume );
export_as_text( Output, "sound.volume.ambient", EnvironmentAmbientVolume ); export_as_text( Output, "sound.volume.ambient", EnvironmentAmbientVolume );

View File

@@ -161,7 +161,7 @@ struct global_settings {
// audio // audio
bool bSoundEnabled{ true }; bool bSoundEnabled{ true };
float AudioVolume{ 1.f }; float AudioVolume{ 1.f };
float RadioVolume{ 0.75f }; float DefaultRadioVolume{ 0.75f };
float VehicleVolume{ 1.0f }; float VehicleVolume{ 1.0f };
float EnvironmentPositionalVolume{ 1.0f }; float EnvironmentPositionalVolume{ 1.0f };
float EnvironmentAmbientVolume{ 1.0f }; float EnvironmentAmbientVolume{ 1.0f };

View File

@@ -724,7 +724,7 @@ dictionary_source *TTrain::GetTrainState( dictionary_source const &Extraparamete
} }
dict->insert( "radio", mvOccupied->Radio ); dict->insert( "radio", mvOccupied->Radio );
dict->insert( "radio_channel", RadioChannel() ); dict->insert( "radio_channel", RadioChannel() );
dict->insert( "radio_volume", Global.RadioVolume ); dict->insert( "radio_volume", m_radiovolume );
dict->insert( "door_lock", mvOccupied->Doors.lock_enabled ); dict->insert( "door_lock", mvOccupied->Doors.lock_enabled );
dict->insert( "door_step", mvOccupied->Doors.step_enabled ); dict->insert( "door_step", mvOccupied->Doors.step_enabled );
dict->insert( "door_permit_left", mvOccupied->Doors.instances[side::left].open_permit ); dict->insert( "door_permit_left", mvOccupied->Doors.instances[side::left].open_permit );
@@ -6601,7 +6601,7 @@ void TTrain::OnCommand_radiovolumeincrease(TTrain *Train, command_data const &Co
if (Command.action == GLFW_PRESS) { if (Command.action == GLFW_PRESS) {
command_data newCommand = Command; command_data newCommand = Command;
newCommand.param1 = Global.RadioVolume + 0.125; newCommand.param1 = Train->m_radiovolume + 0.125;
OnCommand_radiovolumeset(Train, newCommand); OnCommand_radiovolumeset(Train, newCommand);
Train->ggRadioVolumeNext.UpdateValue(1.0); Train->ggRadioVolumeNext.UpdateValue(1.0);
} }
@@ -6615,7 +6615,7 @@ void TTrain::OnCommand_radiovolumedecrease(TTrain *Train, command_data const &Co
if (Command.action == GLFW_PRESS) { if (Command.action == GLFW_PRESS) {
command_data newCommand = Command; command_data newCommand = Command;
newCommand.param1 = Global.RadioVolume - 0.125; newCommand.param1 = Train->m_radiovolume - 0.125;
OnCommand_radiovolumeset(Train, newCommand); OnCommand_radiovolumeset(Train, newCommand);
Train->ggRadioVolumePrevious.UpdateValue(1.0); Train->ggRadioVolumePrevious.UpdateValue(1.0);
} }
@@ -6628,8 +6628,9 @@ void TTrain::OnCommand_radiovolumedecrease(TTrain *Train, command_data const &Co
void TTrain::OnCommand_radiovolumeset(TTrain *Train, command_data const &Command) { void TTrain::OnCommand_radiovolumeset(TTrain *Train, command_data const &Command) {
if( Command.action != GLFW_RELEASE ) { if( Command.action != GLFW_RELEASE ) {
// on press or hold // on press or hold
Global.RadioVolume = clamp(Command.param1, 0.0, 1.0); Train->m_radiovolume = clamp(Command.param1, 0.0, 1.0);
Train->ggRadioVolumeSelector.UpdateValue(Global.RadioVolume); Train->ggRadioVolumeSelector.UpdateValue(Train->m_radiovolume);
audio::event_volume_change = true;
} }
} }
@@ -8457,7 +8458,7 @@ void TTrain::update_sounds_radio() {
( true == radioenabled ) ( true == radioenabled )
&& ( Dynamic()->Mechanik != nullptr ) && ( Dynamic()->Mechanik != nullptr )
&& ( message.first == RadioChannel() ) ? && ( message.first == RadioChannel() ) ?
Global.RadioVolume : m_radiovolume :
0.0 }; 0.0 };
message.second->gain( volume ); message.second->gain( volume );
radio_message_played |= (true == radioenabled) && (Dynamic()->Mechanik != nullptr) && (message.first == RadioChannel()); radio_message_played |= (true == radioenabled) && (Dynamic()->Mechanik != nullptr) && (message.first == RadioChannel());
@@ -8475,7 +8476,7 @@ void TTrain::update_sounds_radio() {
} }
if (radio_message_played) if (radio_message_played)
{ {
btLampkaRadioMessage.gain(Global.RadioVolume); btLampkaRadioMessage.gain(m_radiovolume);
} }
} }
@@ -9805,7 +9806,7 @@ void TTrain::set_cab_controls( int const Cab ) {
0.f ); 0.f );
} }
// radio // radio
ggRadioVolumeSelector.PutValue( Global.RadioVolume ); ggRadioVolumeSelector.PutValue( m_radiovolume );
//finding each inverter - not so optimal, but action ins performed only during changing cabin //finding each inverter - not so optimal, but action ins performed only during changing cabin
bool kier = (DynamicObject->DirectionGet() * mvOccupied->CabOccupied > 0); bool kier = (DynamicObject->DirectionGet() * mvOccupied->CabOccupied > 0);

16
Train.h
View File

@@ -169,6 +169,7 @@ class TTrain {
bool LoadMMediaFile(std::string const &asFileName); bool LoadMMediaFile(std::string const &asFileName);
dictionary_source *GetTrainState( dictionary_source const &Extraparameters ); dictionary_source *GetTrainState( dictionary_source const &Extraparameters );
state_t get_state() const; state_t get_state() const;
inline float get_radiovolume() const { return m_radiovolume; }
// basic_table interface // basic_table interface
inline inline
std::string name() const { std::string name() const {
@@ -872,6 +873,7 @@ private:
// ld substitute // ld substitute
bool m_couplingdisconnect { false }; bool m_couplingdisconnect { false };
bool m_couplingdisconnectback { false }; bool m_couplingdisconnectback { false };
float m_radiovolume { Global.DefaultRadioVolume };
public: public:
float fPress[20][7]; // cisnienia dla wszystkich czlonow float fPress[20][7]; // cisnienia dla wszystkich czlonow
@@ -897,20 +899,6 @@ private:
Math3D::vector3 clamp_inside( Math3D::vector3 const &Point ) const; Math3D::vector3 clamp_inside( Math3D::vector3 const &Point ) const;
const screenentry_sequence & get_screens(); const screenentry_sequence & get_screens();
float get_tacho();
float get_tank_pressure();
float get_pipe_pressure();
float get_brake_pressure();
float get_hv_voltage();
std::array<float, 3> get_current();
bool get_alarm();
int get_drive_direction();
void set_mainctrl(int);
void set_scndctrl(int);
void set_trainbrake(float);
void set_localbrake(float);
uint16_t id(); uint16_t id();
bool pending_delete = false; bool pending_delete = false;
}; };

View File

@@ -1516,6 +1516,13 @@ debug_panel::render_section_settings() {
if( ImGui::SliderFloat( ( to_string( static_cast<int>( Global.EnvironmentAmbientVolume * 100 ) ) + "%###volumeambient" ).c_str(), &Global.EnvironmentAmbientVolume, 0.0f, 1.0f, "Ambient sounds" ) ) { if( ImGui::SliderFloat( ( to_string( static_cast<int>( Global.EnvironmentAmbientVolume * 100 ) ) + "%###volumeambient" ).c_str(), &Global.EnvironmentAmbientVolume, 0.0f, 1.0f, "Ambient sounds" ) ) {
audio::event_volume_change = true; audio::event_volume_change = true;
} }
if (simulation::Train) {
float val = simulation::Train->get_radiovolume();
if( ImGui::SliderFloat( ( to_string( static_cast<int>( val * 100 ) ) + "%###volumeradio" ).c_str(), &val, 0.0f, 1.0f, "Vehicle radio volume" ) ) {
command_relay relay;
relay.post(user_command::radiovolumeset, val, 0.0, GLFW_PRESS, 0);
}
}
return true; return true;
} }