Advertisement
dominus

Untitled

Aug 6th, 2023
1,712
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 4.76 KB | None | 0 0
  1. diff --git a/gumps/AudioOptions_gump.cc b/gumps/AudioOptions_gump.cc
  2. index d1ef5b7d2..00a2b9879 100644
  3. --- a/gumps/AudioOptions_gump.cc
  4. +++ b/gumps/AudioOptions_gump.cc
  5. @@ -153,10 +153,9 @@ void AudioOptions_gump::rebuild_buttons() {
  6.         rebuild_sfx_buttons();
  7.  
  8.     // speech on/off
  9. -   buttons[id_speech_enabled] = std::make_unique<AudioEnabledToggle>(this, &AudioOptions_gump::toggle_speech_enabled,
  10. -           speech_enabled, colx[2], rowy[11], 59);
  11. -   if (speech_enabled)
  12. -       rebuild_speech_buttons();
  13. +   std::vector<std::string> speech_options = {"Subtitles only", "Voice only", "Voice + Subtitles"};
  14. +   buttons[id_speech_enabled] = std::make_unique<AudioTextToggle>(this, &AudioOptions_gump::toggle_speech_enabled,
  15. +           std::move(speech_options), speech_option, colx[2] - 49, rowy[11], 108);
  16.  }
  17.  
  18.  void AudioOptions_gump::rebuild_midi_buttons() {
  19. @@ -226,17 +225,6 @@ void AudioOptions_gump::rebuild_sfx_buttons() {
  20.  #endif
  21.  }
  22.  
  23. -void AudioOptions_gump::rebuild_speech_buttons() {
  24. -   buttons[id_speech_subtitles].reset();
  25. -
  26. -   if (!speech_enabled)
  27. -       return;
  28. -   else {
  29. -       buttons[id_speech_subtitles] = std::make_unique<AudioEnabledToggle>(this, &AudioOptions_gump::toggle_speech_subtitles,
  30. -               speech_subtitles, colx[2], rowy[12], 59);
  31. -   }
  32. -}
  33. -
  34.  void AudioOptions_gump::rebuild_mididriveroption_buttons() {
  35.     std::string s = "Default";
  36.     if (midi_driver != MidiDriver::getDriverCount()) s = MidiDriver::getDriverName(midi_driver);
  37. @@ -282,6 +270,12 @@ void AudioOptions_gump::load_settings() {
  38.     const bool sfx_on = (Audio::get_ptr()->are_effects_enabled());
  39.     speech_enabled = (Audio::get_ptr()->is_speech_enabled() ? 1 : 0);
  40.     speech_subtitles = (Audio::get_ptr()->is_speech_with_subs() ? 1 : 0);
  41. +   if (speech_enabled == 0)
  42. +       speech_option = 0;
  43. +   else if (speech_enabled == 1 && speech_subtitles == 0)
  44. +       speech_option = 1;
  45. +   else if (speech_enabled == 1  && speech_subtitles == 1)
  46. +       speech_option = 2;
  47.     midi_looping = (Audio::get_ptr()->is_music_looping_allowed() ? 1 : 0);
  48.     speaker_type = true; // stereo
  49.     sample_rate = 44100;
  50. @@ -478,16 +472,17 @@ void AudioOptions_gump::save_settings() {
  51.     Audio::get_ptr()->set_effects_enabled(sfx_enabled != 0);
  52.     if (!sfx_enabled)       // Stop what's playing.
  53.         Audio::get_ptr()->stop_sound_effects();
  54. -   Audio::get_ptr()->set_speech_enabled(speech_enabled == 1);
  55. -   Audio::get_ptr()->set_speech_with_subs(speech_subtitles == 1);
  56. +   Audio::get_ptr()->set_speech_enabled(speech_option != 0);
  57. +   Audio::get_ptr()->set_speech_with_subs(speech_option != 1);
  58.     Audio::get_ptr()->set_allow_music_looping(midi_looping == 1);
  59.  
  60.     config->set("config/audio/enabled", audio_enabled ? "yes" : "no", false);
  61.     config->set("config/audio/midi/enabled", midi_enabled ? "yes" : "no", false);
  62.     config->set("config/audio/effects/enabled", sfx_enabled ? "yes" : "no", false);
  63. -   config->set("config/audio/speech/enabled", speech_enabled ? "yes" : "no", false);
  64. -   config->set("config/audio/speech/with_subs", speech_subtitles ? "yes" : "no", false);
  65. -
  66. +   if (speech_option == 0 || speech_option == 1)
  67. +       config->set("config/audio/speech/enabled", speech_option ? "yes" : "no", false);
  68. +   if (speech_option == 1 || speech_option == 2)
  69. +       config->set("config/audio/speech/with_subs", (speech_option & 2) ? "yes" : "no", false);
  70.     config->set("config/audio/midi/chorus/enabled", (midi_reverb_chorus & 2) ? "yes" : "no", false);
  71.     config->set("config/audio/midi/reverb/enabled", (midi_reverb_chorus & 1) ? "yes" : "no", false);
  72.     config->set("config/audio/midi/looping", midi_looping ? "yes" : "no", false);
  73. @@ -598,8 +593,6 @@ void AudioOptions_gump::paint() {
  74.         }
  75.  #endif
  76.         font->paint_text(iwin->get_ib8(), "Speech:", x + colx[0], y + rowy[11] + 1);
  77. -       if (speech_enabled == 1)
  78. -           font->paint_text(iwin->get_ib8(), "subtitles", x + colx[1], y + rowy[12] + 1);
  79.     }
  80.     gwin->set_painted();
  81.  }
  82. diff --git a/gumps/AudioOptions_gump.h b/gumps/AudioOptions_gump.h
  83. index ae43eb146..509c21fbb 100644
  84. --- a/gumps/AudioOptions_gump.h
  85. +++ b/gumps/AudioOptions_gump.h
  86. @@ -70,6 +70,7 @@ class AudioOptions_gump : public Modal_gump {
  87.  #ifdef ENABLE_MIDISFX
  88.     int sfx_conversion;
  89.  #endif
  90. +   int speech_option;
  91.     int speech_enabled;
  92.     int speech_subtitles;
  93.  
  94. @@ -104,7 +105,6 @@ class AudioOptions_gump : public Modal_gump {
  95.     void rebuild_midi_driver_buttons();
  96.     void rebuild_mididriveroption_buttons();
  97.     void rebuild_sfx_buttons();
  98. -   void rebuild_speech_buttons();
  99.  
  100.     void load_settings();
  101.     void save_settings();
  102. @@ -151,12 +151,7 @@ class AudioOptions_gump : public Modal_gump {
  103.     }
  104.     void toggle_sfx_pack(int state);
  105.     void toggle_speech_enabled(int state) {
  106. -       speech_enabled = state;
  107. -       rebuild_speech_buttons();
  108. -       paint();
  109. -   }
  110. -   void toggle_speech_subtitles(int state) {
  111. -       speech_subtitles = state;
  112. +       speech_option = state;
  113.     }
  114.  };
  115.  
  116.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement