Fix SFX dropdown regressions, make dropdown play sound if custom sound is listed regardless of Pre (#656)
* Fix SFX dropdown not playing a sound despite a sound being selected. It was waiting on a preanim box to be checked, but that behavior was not intuitive. Plus this is a regression from intended behavior * Make "default" sfx behavior behave as expected * Tidy up the network logic for emote_mod and comment all of its behavior Fix sfx not playing when immeidate is checked on * make emote_mod an enum so I don't have to go scouring documentation to learn what it does anymore not adding emote mod for enums 2, 3 and 4 cuz those are planned to be deprecated in a later PR Make Clang happy with no bracket-less if statements
This commit is contained in:
		
							parent
							
								
									35fcbdeea8
								
							
						
					
					
						commit
						c3fd82eacc
					
				@ -101,6 +101,13 @@ enum CHAT_MESSAGE {
 | 
			
		||||
  EFFECTS
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
enum EMOTE_MOD {
 | 
			
		||||
  IDLE = 0,
 | 
			
		||||
  PREANIM = 1,
 | 
			
		||||
  ZOOM = 5,
 | 
			
		||||
  PREANIM_ZOOM = 6,
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
enum MUSIC_EFFECT { FADE_IN = 1, FADE_OUT = 2, SYNC_POS = 4 };
 | 
			
		||||
 | 
			
		||||
#endif // DATATYPES_H
 | 
			
		||||
 | 
			
		||||
@ -1870,30 +1870,72 @@ void Courtroom::on_chat_return_pressed()
 | 
			
		||||
 | 
			
		||||
  packet_contents.append(f_side);
 | 
			
		||||
 | 
			
		||||
  packet_contents.append(get_char_sfx());
 | 
			
		||||
 | 
			
		||||
  int f_emote_mod = ao_app->get_emote_mod(current_char, current_emote);
 | 
			
		||||
 | 
			
		||||
  // needed or else legacy won't understand what we're saying
 | 
			
		||||
  if (objection_state > 0 && ui_pre->isChecked()) {
 | 
			
		||||
    if (f_emote_mod == 4 || f_emote_mod == 5)
 | 
			
		||||
      f_emote_mod = 6;
 | 
			
		||||
    else
 | 
			
		||||
      f_emote_mod = 2;
 | 
			
		||||
  QString f_sfx = "1";
 | 
			
		||||
// EMOTE MOD OVERRIDES:
 | 
			
		||||
  // Emote_mod 2 is only used by objection check later, having it in the char.ini does nothing
 | 
			
		||||
  if (f_emote_mod == 2) {
 | 
			
		||||
    f_emote_mod = PREANIM;
 | 
			
		||||
  }
 | 
			
		||||
  else if (ui_pre->isChecked() && !ui_immediate->isChecked()) {
 | 
			
		||||
    if (f_emote_mod == 0)
 | 
			
		||||
      f_emote_mod = 1;
 | 
			
		||||
    else if (f_emote_mod == 5 && ao_app->prezoom_enabled)
 | 
			
		||||
      f_emote_mod = 6;
 | 
			
		||||
  // No clue what emote_mod 3 is even supposed to be.
 | 
			
		||||
  if (f_emote_mod == 3) {
 | 
			
		||||
    f_emote_mod = IDLE;
 | 
			
		||||
  }
 | 
			
		||||
  // Emote_mod 4 seems to be a legacy bugfix that just refers it to emote_mod 5 which is zoom emote
 | 
			
		||||
  if (f_emote_mod == 4) {
 | 
			
		||||
    f_emote_mod = ZOOM;
 | 
			
		||||
  }
 | 
			
		||||
  // If we have "pre" on, and immediate is not checked
 | 
			
		||||
  if (ui_pre->isChecked() && !ui_immediate->isChecked()) {
 | 
			
		||||
    // Turn idle into preanim
 | 
			
		||||
    if (f_emote_mod == IDLE) {
 | 
			
		||||
      f_emote_mod = PREANIM;
 | 
			
		||||
    }
 | 
			
		||||
    // Turn zoom into preanim zoom
 | 
			
		||||
    else if (f_emote_mod == ZOOM && ao_app->prezoom_enabled) {
 | 
			
		||||
      f_emote_mod = PREANIM_ZOOM;
 | 
			
		||||
    }
 | 
			
		||||
    // Play the sfx
 | 
			
		||||
    f_sfx = get_char_sfx();
 | 
			
		||||
  }
 | 
			
		||||
  // If we have "pre" off, or immediate is checked
 | 
			
		||||
  else {
 | 
			
		||||
    if (f_emote_mod == 1)
 | 
			
		||||
      f_emote_mod = 0;
 | 
			
		||||
    else if (f_emote_mod == 4)
 | 
			
		||||
      f_emote_mod = 5;
 | 
			
		||||
    // Turn preanim into idle
 | 
			
		||||
    if (f_emote_mod == PREANIM) {
 | 
			
		||||
      f_emote_mod = IDLE;
 | 
			
		||||
    }
 | 
			
		||||
    // Turn preanim zoom into zoom
 | 
			
		||||
    else if (f_emote_mod == PREANIM_ZOOM) {
 | 
			
		||||
      f_emote_mod = ZOOM;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    // Play the sfx if pre is checked
 | 
			
		||||
    if (ui_pre->isChecked()) {
 | 
			
		||||
      f_sfx = get_char_sfx();
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
// TODO: deprecate this garbage. See https://github.com/AttorneyOnline/AO2-Client/issues/692
 | 
			
		||||
  // If our objection is enabled
 | 
			
		||||
  if (objection_state > 0) {
 | 
			
		||||
    // Turn preanim zoom emote mod into non-pre
 | 
			
		||||
    if (f_emote_mod == ZOOM) {
 | 
			
		||||
      f_emote_mod = PREANIM_ZOOM;
 | 
			
		||||
    }
 | 
			
		||||
    // Turn it into preanim objection emote mod
 | 
			
		||||
    else {
 | 
			
		||||
      f_emote_mod = 2;
 | 
			
		||||
    }
 | 
			
		||||
    // Play the sfx
 | 
			
		||||
    f_sfx = get_char_sfx();
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  // Custom sfx override via sound list dropdown.
 | 
			
		||||
  if (!custom_sfx.isEmpty() || ui_sfx_dropdown->currentIndex() != 0) {
 | 
			
		||||
    f_sfx = get_char_sfx();
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  packet_contents.append(f_sfx);
 | 
			
		||||
  packet_contents.append(QString::number(f_emote_mod));
 | 
			
		||||
  packet_contents.append(QString::number(m_cid));
 | 
			
		||||
 | 
			
		||||
@ -2059,7 +2101,7 @@ void Courtroom::reset_ui()
 | 
			
		||||
  ui_screenshake->set_image("screenshake");
 | 
			
		||||
  ui_evidence_present->set_image("present");
 | 
			
		||||
 | 
			
		||||
  if (ui_pre->isChecked() && !ao_app->is_stickysounds_enabled()) {
 | 
			
		||||
  if (!ao_app->is_stickysounds_enabled()) {
 | 
			
		||||
    ui_sfx_dropdown->setCurrentIndex(0);
 | 
			
		||||
    ui_sfx_remove->hide();
 | 
			
		||||
    custom_sfx = "";
 | 
			
		||||
@ -2504,6 +2546,7 @@ void Courtroom::handle_emote_mod(int emote_mod, bool p_immediate)
 | 
			
		||||
    // If immediate is not ticked on...
 | 
			
		||||
    if (!p_immediate)
 | 
			
		||||
    {
 | 
			
		||||
      play_sfx();
 | 
			
		||||
      // Skip preanim.
 | 
			
		||||
      handle_ic_speaking();
 | 
			
		||||
    }
 | 
			
		||||
@ -4637,8 +4680,9 @@ QString Courtroom::get_char_sfx()
 | 
			
		||||
  if (!custom_sfx.isEmpty())
 | 
			
		||||
    return custom_sfx;
 | 
			
		||||
  int index = ui_sfx_dropdown->currentIndex();
 | 
			
		||||
  if (index == 0) // Default
 | 
			
		||||
  if (index == 0) { // Default
 | 
			
		||||
    return ao_app->get_sfx_name(current_char, current_emote);
 | 
			
		||||
  }
 | 
			
		||||
  if (index == 1) // Nothing
 | 
			
		||||
    return "1";
 | 
			
		||||
  QString sfx = sound_list[index-2].split("=")[0].trimmed();
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user