mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-03-22 15:05:03 +01:00
radio volume slider
This commit is contained in:
@@ -154,8 +154,8 @@ global_settings::ConfigParse(cParser &Parser) {
|
||||
{
|
||||
// selected device for audio renderer
|
||||
Parser.getTokens();
|
||||
Parser >> RadioVolume;
|
||||
RadioVolume = clamp(RadioVolume, 0.f, 1.f);
|
||||
Parser >> DefaultRadioVolume;
|
||||
DefaultRadioVolume = clamp(DefaultRadioVolume, 0.f, 1.f);
|
||||
}
|
||||
else if (token == "sound.maxsources") {
|
||||
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, "sound.openal.renderer", AudioRenderer );
|
||||
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.positional", EnvironmentPositionalVolume );
|
||||
export_as_text( Output, "sound.volume.ambient", EnvironmentAmbientVolume );
|
||||
|
||||
@@ -161,7 +161,7 @@ struct global_settings {
|
||||
// audio
|
||||
bool bSoundEnabled{ true };
|
||||
float AudioVolume{ 1.f };
|
||||
float RadioVolume{ 0.75f };
|
||||
float DefaultRadioVolume{ 0.75f };
|
||||
float VehicleVolume{ 1.0f };
|
||||
float EnvironmentPositionalVolume{ 1.0f };
|
||||
float EnvironmentAmbientVolume{ 1.0f };
|
||||
|
||||
17
Train.cpp
17
Train.cpp
@@ -724,7 +724,7 @@ dictionary_source *TTrain::GetTrainState( dictionary_source const &Extraparamete
|
||||
}
|
||||
dict->insert( "radio", mvOccupied->Radio );
|
||||
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_step", mvOccupied->Doors.step_enabled );
|
||||
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) {
|
||||
command_data newCommand = Command;
|
||||
newCommand.param1 = Global.RadioVolume + 0.125;
|
||||
newCommand.param1 = Train->m_radiovolume + 0.125;
|
||||
OnCommand_radiovolumeset(Train, newCommand);
|
||||
Train->ggRadioVolumeNext.UpdateValue(1.0);
|
||||
}
|
||||
@@ -6615,7 +6615,7 @@ void TTrain::OnCommand_radiovolumedecrease(TTrain *Train, command_data const &Co
|
||||
|
||||
if (Command.action == GLFW_PRESS) {
|
||||
command_data newCommand = Command;
|
||||
newCommand.param1 = Global.RadioVolume - 0.125;
|
||||
newCommand.param1 = Train->m_radiovolume - 0.125;
|
||||
OnCommand_radiovolumeset(Train, newCommand);
|
||||
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) {
|
||||
if( Command.action != GLFW_RELEASE ) {
|
||||
// on press or hold
|
||||
Global.RadioVolume = clamp(Command.param1, 0.0, 1.0);
|
||||
Train->ggRadioVolumeSelector.UpdateValue(Global.RadioVolume);
|
||||
Train->m_radiovolume = clamp(Command.param1, 0.0, 1.0);
|
||||
Train->ggRadioVolumeSelector.UpdateValue(Train->m_radiovolume);
|
||||
audio::event_volume_change = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8457,7 +8458,7 @@ void TTrain::update_sounds_radio() {
|
||||
( true == radioenabled )
|
||||
&& ( Dynamic()->Mechanik != nullptr )
|
||||
&& ( message.first == RadioChannel() ) ?
|
||||
Global.RadioVolume :
|
||||
m_radiovolume :
|
||||
0.0 };
|
||||
message.second->gain( volume );
|
||||
radio_message_played |= (true == radioenabled) && (Dynamic()->Mechanik != nullptr) && (message.first == RadioChannel());
|
||||
@@ -8475,7 +8476,7 @@ void TTrain::update_sounds_radio() {
|
||||
}
|
||||
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 );
|
||||
}
|
||||
// radio
|
||||
ggRadioVolumeSelector.PutValue( Global.RadioVolume );
|
||||
ggRadioVolumeSelector.PutValue( m_radiovolume );
|
||||
|
||||
//finding each inverter - not so optimal, but action ins performed only during changing cabin
|
||||
bool kier = (DynamicObject->DirectionGet() * mvOccupied->CabOccupied > 0);
|
||||
|
||||
16
Train.h
16
Train.h
@@ -169,6 +169,7 @@ class TTrain {
|
||||
bool LoadMMediaFile(std::string const &asFileName);
|
||||
dictionary_source *GetTrainState( dictionary_source const &Extraparameters );
|
||||
state_t get_state() const;
|
||||
inline float get_radiovolume() const { return m_radiovolume; }
|
||||
// basic_table interface
|
||||
inline
|
||||
std::string name() const {
|
||||
@@ -872,6 +873,7 @@ private:
|
||||
// ld substitute
|
||||
bool m_couplingdisconnect { false };
|
||||
bool m_couplingdisconnectback { false };
|
||||
float m_radiovolume { Global.DefaultRadioVolume };
|
||||
|
||||
public:
|
||||
float fPress[20][7]; // cisnienia dla wszystkich czlonow
|
||||
@@ -897,20 +899,6 @@ private:
|
||||
Math3D::vector3 clamp_inside( Math3D::vector3 const &Point ) const;
|
||||
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();
|
||||
bool pending_delete = false;
|
||||
};
|
||||
|
||||
@@ -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" ) ) {
|
||||
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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user