Add option to disable music streaming. (#829)
* Add option to disable streamintg This one gets a unique message to prevent people forgetting they disable it and the wondering why streaming broke. * Fix code order * Fixes the music channel still playing audio when a new stream was blocked. * Update tooltip * Update tooltip to reflect the current way the feature works.
This commit is contained in:
		
							parent
							
								
									7b88d4be95
								
							
						
					
					
						commit
						4fa86c0174
					
				@ -194,6 +194,9 @@ public:
 | 
				
			|||||||
  // Returns true if stop music on objection is enabled in the config.ini
 | 
					  // Returns true if stop music on objection is enabled in the config.ini
 | 
				
			||||||
  bool objection_stop_music();
 | 
					  bool objection_stop_music();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  // Returns true if streaming is enabled in the config.ini
 | 
				
			||||||
 | 
					  bool is_streaming_disabled();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  // Returns the value of default_music in config.ini
 | 
					  // Returns the value of default_music in config.ini
 | 
				
			||||||
  int get_default_music();
 | 
					  int get_default_music();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -145,6 +145,8 @@ private:
 | 
				
			|||||||
  QCheckBox *ui_loopsfx_cb;
 | 
					  QCheckBox *ui_loopsfx_cb;
 | 
				
			||||||
  QLabel *ui_objectmusic_lbl;
 | 
					  QLabel *ui_objectmusic_lbl;
 | 
				
			||||||
  QCheckBox *ui_objectmusic_cb;
 | 
					  QCheckBox *ui_objectmusic_cb;
 | 
				
			||||||
 | 
					  QLabel *ui_disablestreams_lbl;
 | 
				
			||||||
 | 
					  QCheckBox *ui_disablestreams_cb;
 | 
				
			||||||
  QDialogButtonBox *ui_settings_buttons;
 | 
					  QDialogButtonBox *ui_settings_buttons;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  QWidget *ui_casing_tab;
 | 
					  QWidget *ui_casing_tab;
 | 
				
			||||||
 | 
				
			|||||||
@ -29,6 +29,12 @@ QString AOMusicPlayer::play(QString p_song, int channel, bool loop,
 | 
				
			|||||||
  QString f_path = p_song;
 | 
					  QString f_path = p_song;
 | 
				
			||||||
  DWORD newstream;
 | 
					  DWORD newstream;
 | 
				
			||||||
  if (f_path.startsWith("http")) {
 | 
					  if (f_path.startsWith("http")) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if (ao_app->is_streaming_disabled()) {
 | 
				
			||||||
 | 
					        BASS_ChannelStop(m_stream_list[channel]);
 | 
				
			||||||
 | 
					        return QObject::tr("[MISSING] Streaming disabled.");
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (f_path.endsWith(".opus"))
 | 
					    if (f_path.endsWith(".opus"))
 | 
				
			||||||
      newstream = BASS_OPUS_StreamCreateURL(f_path.toStdString().c_str(), 0, streaming_flags, nullptr, 0);
 | 
					      newstream = BASS_OPUS_StreamCreateURL(f_path.toStdString().c_str(), 0, streaming_flags, nullptr, 0);
 | 
				
			||||||
    else if (f_path.endsWith(".mid"))
 | 
					    else if (f_path.endsWith(".mid"))
 | 
				
			||||||
 | 
				
			|||||||
@ -697,6 +697,16 @@ AOOptionsDialog::AOOptionsDialog(QWidget *parent, AOApplication *p_ao_app)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  ui_audio_layout->setWidget(row, QFormLayout::FieldRole, ui_objectmusic_cb);
 | 
					  ui_audio_layout->setWidget(row, QFormLayout::FieldRole, ui_objectmusic_cb);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  row += 1;
 | 
				
			||||||
 | 
					  ui_disablestreams_lbl = new QLabel(ui_audio_widget);
 | 
				
			||||||
 | 
					  ui_disablestreams_lbl->setText(tr("Disable Music Streaming:"));
 | 
				
			||||||
 | 
					  ui_disablestreams_lbl->setToolTip(
 | 
				
			||||||
 | 
					      tr("If true, AO2 will not play any streamed audio and show that streaming is disabled."));
 | 
				
			||||||
 | 
					  ui_audio_layout->setWidget(row, QFormLayout::LabelRole, ui_disablestreams_lbl);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  ui_disablestreams_cb = new QCheckBox(ui_audio_widget);
 | 
				
			||||||
 | 
					  ui_audio_layout->setWidget(row, QFormLayout::FieldRole, ui_disablestreams_cb);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  // The casing tab!
 | 
					  // The casing tab!
 | 
				
			||||||
  ui_casing_tab = new QWidget(this);
 | 
					  ui_casing_tab = new QWidget(this);
 | 
				
			||||||
  ui_settings_tabs->addTab(ui_casing_tab, tr("Casing"));
 | 
					  ui_settings_tabs->addTab(ui_casing_tab, tr("Casing"));
 | 
				
			||||||
@ -1217,6 +1227,7 @@ void AOOptionsDialog::update_values() {
 | 
				
			|||||||
  ui_blank_blips_cb->setChecked(ao_app->get_blank_blip());
 | 
					  ui_blank_blips_cb->setChecked(ao_app->get_blank_blip());
 | 
				
			||||||
  ui_loopsfx_cb->setChecked(ao_app->get_looping_sfx());
 | 
					  ui_loopsfx_cb->setChecked(ao_app->get_looping_sfx());
 | 
				
			||||||
  ui_objectmusic_cb->setChecked(ao_app->objection_stop_music());
 | 
					  ui_objectmusic_cb->setChecked(ao_app->objection_stop_music());
 | 
				
			||||||
 | 
					  ui_disablestreams_cb->setChecked(ao_app->is_streaming_disabled());
 | 
				
			||||||
  ui_casing_enabled_cb->setChecked(ao_app->get_casing_enabled());
 | 
					  ui_casing_enabled_cb->setChecked(ao_app->get_casing_enabled());
 | 
				
			||||||
  ui_casing_def_cb->setChecked(ao_app->get_casing_defence_enabled());
 | 
					  ui_casing_def_cb->setChecked(ao_app->get_casing_defence_enabled());
 | 
				
			||||||
  ui_casing_pro_cb->setChecked(ao_app->get_casing_prosecution_enabled());
 | 
					  ui_casing_pro_cb->setChecked(ao_app->get_casing_prosecution_enabled());
 | 
				
			||||||
@ -1323,6 +1334,7 @@ void AOOptionsDialog::save_pressed()
 | 
				
			|||||||
  configini->setValue("blank_blip", ui_blank_blips_cb->isChecked());
 | 
					  configini->setValue("blank_blip", ui_blank_blips_cb->isChecked());
 | 
				
			||||||
  configini->setValue("looping_sfx", ui_loopsfx_cb->isChecked());
 | 
					  configini->setValue("looping_sfx", ui_loopsfx_cb->isChecked());
 | 
				
			||||||
  configini->setValue("objection_stop_music", ui_objectmusic_cb->isChecked());
 | 
					  configini->setValue("objection_stop_music", ui_objectmusic_cb->isChecked());
 | 
				
			||||||
 | 
					  configini->setValue("streaming_disabled", ui_disablestreams_cb->isChecked());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  configini->setValue("casing_enabled", ui_casing_enabled_cb->isChecked());
 | 
					  configini->setValue("casing_enabled", ui_casing_enabled_cb->isChecked());
 | 
				
			||||||
  configini->setValue("casing_defence_enabled", ui_casing_def_cb->isChecked());
 | 
					  configini->setValue("casing_defence_enabled", ui_casing_def_cb->isChecked());
 | 
				
			||||||
 | 
				
			|||||||
@ -1037,6 +1037,11 @@ bool AOApplication::objection_stop_music()
 | 
				
			|||||||
  return result.startsWith("true");
 | 
					  return result.startsWith("true");
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					bool AOApplication::is_streaming_disabled()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    return configini->value("streaming_disabled", false).toBool();
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
bool AOApplication::is_instant_objection_enabled()
 | 
					bool AOApplication::is_instant_objection_enabled()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  QString result = configini->value("instant_objection", "true").value<QString>();
 | 
					  QString result = configini->value("instant_objection", "true").value<QString>();
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user