Log objections IC, overhaul custom objections context menu, add more configuration options per-character (#356)
* initial commit * The Quick-Fix is a secondary weapon for the Medic. It is a prototype Medi Gun with a group of three gauges on one side, a (cosmetic) ÜberCharge gauge on the other side, and what appears to be a blender for a body. The main gun is coupled with a medicinal reactor backpack with glowing portions that replaces Medic's default backpack. * fixed settings dialog * slightly less stupid custom objection default Co-authored-by: oldmud0 <oldmud0@users.noreply.github.com> Co-authored-by: oldmud0 <oldmud0@users.noreply.github.com>
This commit is contained in:
		
							parent
							
								
									7bac3c9514
								
							
						
					
					
						commit
						15c3d607c6
					
				@ -220,6 +220,9 @@ public:
 | 
			
		||||
  // Returns whether the log should have a timestamp.
 | 
			
		||||
  bool get_log_timestamp();
 | 
			
		||||
 | 
			
		||||
  // Returns whether to log IC actions.
 | 
			
		||||
  bool get_log_ic_actions();
 | 
			
		||||
 | 
			
		||||
  // Returns the username the user may have set in config.ini.
 | 
			
		||||
  QString get_default_username();
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -52,6 +52,8 @@ private:
 | 
			
		||||
  QSpinBox *ui_log_margin_spinbox;
 | 
			
		||||
  QLabel *ui_log_timestamp_lbl;
 | 
			
		||||
  QCheckBox *ui_log_timestamp_cb;
 | 
			
		||||
  QLabel *ui_log_ic_actions_lbl;
 | 
			
		||||
  QCheckBox *ui_log_ic_actions_cb;
 | 
			
		||||
  QFrame *ui_log_names_divider;
 | 
			
		||||
  QLineEdit *ui_username_textbox;
 | 
			
		||||
  QLabel *ui_username_lbl;
 | 
			
		||||
 | 
			
		||||
@ -332,6 +332,9 @@ private:
 | 
			
		||||
  // True, if the log should display the message like name<br>text instead of name: text
 | 
			
		||||
  bool log_newline = false;
 | 
			
		||||
 | 
			
		||||
  // True, if the log should include RP actions like interjections, showing evidence, etc.
 | 
			
		||||
  bool log_ic_actions = true;
 | 
			
		||||
 | 
			
		||||
  // Margin in pixels between log entries for the IC log.
 | 
			
		||||
  int log_margin = 0;
 | 
			
		||||
 | 
			
		||||
@ -398,6 +401,11 @@ private:
 | 
			
		||||
 | 
			
		||||
  int objection_state = 0;
 | 
			
		||||
  QString objection_custom = "";
 | 
			
		||||
  struct CustomObjection {
 | 
			
		||||
    QString name;
 | 
			
		||||
    QString filename;
 | 
			
		||||
  };
 | 
			
		||||
  QList<CustomObjection> custom_objections_list;
 | 
			
		||||
  int realization_state = 0;
 | 
			
		||||
  int screenshake_state = 0;
 | 
			
		||||
  int text_color = 0;
 | 
			
		||||
 | 
			
		||||
@ -163,6 +163,19 @@ AOOptionsDialog::AOOptionsDialog(QWidget *parent, AOApplication *p_ao_app)
 | 
			
		||||
 | 
			
		||||
  ui_gameplay_form->setWidget(row, QFormLayout::FieldRole, ui_log_timestamp_cb);
 | 
			
		||||
 | 
			
		||||
  row += 1;
 | 
			
		||||
  ui_log_ic_actions_lbl = new QLabel(ui_form_layout_widget);
 | 
			
		||||
  ui_log_ic_actions_lbl->setText(tr("Log IC actions:"));
 | 
			
		||||
  ui_log_ic_actions_lbl->setToolTip(
 | 
			
		||||
      tr("If ticked, log will show IC actions such as shouting and presenting evidence."));
 | 
			
		||||
 | 
			
		||||
  ui_gameplay_form->setWidget(row, QFormLayout::LabelRole, ui_log_ic_actions_lbl);
 | 
			
		||||
 | 
			
		||||
  ui_log_ic_actions_cb = new QCheckBox(ui_form_layout_widget);
 | 
			
		||||
  ui_log_ic_actions_cb->setChecked(p_ao_app->get_log_ic_actions());
 | 
			
		||||
 | 
			
		||||
  ui_gameplay_form->setWidget(row, QFormLayout::FieldRole, ui_log_ic_actions_cb);
 | 
			
		||||
  
 | 
			
		||||
  row += 1;
 | 
			
		||||
  ui_log_names_divider = new QFrame(ui_form_layout_widget);
 | 
			
		||||
  ui_log_names_divider->setFrameShape(QFrame::HLine);
 | 
			
		||||
@ -765,6 +778,7 @@ void AOOptionsDialog::save_pressed()
 | 
			
		||||
  configini->setValue("log_newline", ui_log_newline_cb->isChecked());
 | 
			
		||||
  configini->setValue("log_margin", ui_log_margin_spinbox->value());
 | 
			
		||||
  configini->setValue("log_timestamp", ui_log_timestamp_cb->isChecked());
 | 
			
		||||
  configini->setValue("log_ic_actions", ui_log_ic_actions_cb->isChecked());
 | 
			
		||||
  configini->setValue("default_username", ui_username_textbox->text());
 | 
			
		||||
  configini->setValue("show_custom_shownames", ui_showname_cb->isChecked());
 | 
			
		||||
  configini->setValue("master", ui_ms_textbox->text());
 | 
			
		||||
 | 
			
		||||
@ -1300,10 +1300,16 @@ void Courtroom::update_character(int p_cid)
 | 
			
		||||
  if (ao_app->custom_objection_enabled) // if setting is enabled
 | 
			
		||||
  {
 | 
			
		||||
    custom_obj_menu->clear();
 | 
			
		||||
    custom_objections_list.clear();
 | 
			
		||||
    if (file_exists(ao_app->get_image_suffix(
 | 
			
		||||
            ao_app->get_character_path(current_char, "custom")))) {
 | 
			
		||||
      ui_custom_objection->show();
 | 
			
		||||
      QAction *action = custom_obj_menu->addAction("Default");
 | 
			
		||||
      QString custom_name = ao_app->read_char_ini(f_char, "custom_name", "Shouts");
 | 
			
		||||
      QAction *action;
 | 
			
		||||
      if (custom_name != "")
 | 
			
		||||
        action = custom_obj_menu->addAction(custom_name);
 | 
			
		||||
      else
 | 
			
		||||
        action = custom_obj_menu->addAction("Default");
 | 
			
		||||
      custom_obj_menu->setDefaultAction(action);
 | 
			
		||||
      objection_custom = "";
 | 
			
		||||
    }
 | 
			
		||||
@ -1318,11 +1324,23 @@ void Courtroom::update_character(int p_cid)
 | 
			
		||||
                                                                 << "*.webp",
 | 
			
		||||
                                                   QDir::Files);
 | 
			
		||||
      for (const QString &filename : custom_obj) {
 | 
			
		||||
        QAction *action = custom_obj_menu->addAction(filename);
 | 
			
		||||
        CustomObjection custom_objection;
 | 
			
		||||
        custom_objection.filename = filename;
 | 
			
		||||
        QString custom_name = ao_app->read_char_ini(f_char, filename.split(".")[0] + "_name", "Shouts");
 | 
			
		||||
        QAction *action;
 | 
			
		||||
        if (custom_name != "") {
 | 
			
		||||
          custom_objection.name = custom_name;
 | 
			
		||||
          action = custom_obj_menu->addAction(custom_name);
 | 
			
		||||
        }
 | 
			
		||||
        else {
 | 
			
		||||
          custom_objection.name = filename.split(".")[0];
 | 
			
		||||
          action = custom_obj_menu->addAction(filename.split(".")[0]);
 | 
			
		||||
        }
 | 
			
		||||
        if (custom_obj_menu->defaultAction() == nullptr) {
 | 
			
		||||
          custom_obj_menu->setDefaultAction(action);
 | 
			
		||||
          objection_custom = action->text();
 | 
			
		||||
          objection_custom = custom_objection.filename;
 | 
			
		||||
        }
 | 
			
		||||
      custom_objections_list.append(custom_objection);
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
@ -1881,34 +1899,36 @@ void Courtroom::handle_chatmessage(QStringList *p_contents)
 | 
			
		||||
  {
 | 
			
		||||
    m_chatmessage[MESSAGE] = ""; // Turn it into true blankpost
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  if (prev_char_id != f_char_id || !m_chatmessage[MESSAGE].isEmpty() ||
 | 
			
		||||
      ic_chatlog_history.isEmpty() || ic_chatlog_history.last().get_message() != "") {
 | 
			
		||||
    log_ic_text(f_charname, f_displayname, m_chatmessage[MESSAGE], "",
 | 
			
		||||
                m_chatmessage[TEXT_COLOR].toInt());
 | 
			
		||||
    append_ic_text(m_chatmessage[MESSAGE], f_displayname, "",
 | 
			
		||||
                   m_chatmessage[TEXT_COLOR].toInt());
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  
 | 
			
		||||
  QString f_char = m_chatmessage[CHAR_NAME];
 | 
			
		||||
  QString f_custom_theme = ao_app->get_char_shouts(f_char);
 | 
			
		||||
 | 
			
		||||
  // if an objection is used
 | 
			
		||||
  if (objection_mod <= 4 && objection_mod >= 1) {
 | 
			
		||||
    QString shout_message;
 | 
			
		||||
    switch (objection_mod) {
 | 
			
		||||
    case 1:
 | 
			
		||||
      ui_vp_objection->play("holdit_bubble", f_char, f_custom_theme, 724);
 | 
			
		||||
      objection_player->play("holdit", f_char, f_custom_theme);
 | 
			
		||||
      shout_message = ao_app->read_char_ini(f_char, "holdit_message", "Shouts");
 | 
			
		||||
      if (shout_message == "")
 | 
			
		||||
        shout_message = tr("HOLD IT!");
 | 
			
		||||
      break;
 | 
			
		||||
    case 2:
 | 
			
		||||
      ui_vp_objection->play("objection_bubble", f_char, f_custom_theme, 724);
 | 
			
		||||
      objection_player->play("objection", f_char, f_custom_theme);
 | 
			
		||||
      shout_message = ao_app->read_char_ini(f_char, "objection_message", "Shouts");
 | 
			
		||||
      if (shout_message == "")
 | 
			
		||||
        shout_message = tr("OBJECTION!");
 | 
			
		||||
      if (ao_app->objection_stop_music())
 | 
			
		||||
        music_player->stop();
 | 
			
		||||
      break;
 | 
			
		||||
    case 3:
 | 
			
		||||
      ui_vp_objection->play("takethat_bubble", f_char, f_custom_theme, 724);
 | 
			
		||||
      objection_player->play("takethat", f_char, f_custom_theme);
 | 
			
		||||
      shout_message = ao_app->read_char_ini(f_char, "takethat_message", "Shouts");
 | 
			
		||||
      if (shout_message == "")
 | 
			
		||||
        shout_message = tr("TAKE THAT!");
 | 
			
		||||
      break;
 | 
			
		||||
    // case 4 is AO2 only
 | 
			
		||||
    case 4:
 | 
			
		||||
@ -1918,19 +1938,36 @@ void Courtroom::handle_chatmessage(QStringList *p_contents)
 | 
			
		||||
        objection_player->play("custom_objections/" +
 | 
			
		||||
                                   custom_objection.split('.')[0],
 | 
			
		||||
                               f_char, f_custom_theme);
 | 
			
		||||
        shout_message = ao_app->read_char_ini(f_char, custom_objection.split('.')[0] + "_message", "Shouts");
 | 
			
		||||
        if (shout_message == "")
 | 
			
		||||
          shout_message = custom_objection.split('.')[0];
 | 
			
		||||
      }
 | 
			
		||||
      else {
 | 
			
		||||
        ui_vp_objection->play("custom", f_char, f_custom_theme,
 | 
			
		||||
                              shout_stay_time);
 | 
			
		||||
        objection_player->play("custom", f_char, f_custom_theme);
 | 
			
		||||
        shout_message = ao_app->read_char_ini(f_char, "custom_message", "Shouts");
 | 
			
		||||
        if (shout_message == "")
 | 
			
		||||
          shout_message = tr("CUSTOM OBJECTION!");
 | 
			
		||||
      }
 | 
			
		||||
      m_chatmessage[EMOTE_MOD] = 1;
 | 
			
		||||
      break;
 | 
			
		||||
    }
 | 
			
		||||
    log_ic_text(f_char, f_displayname, shout_message,
 | 
			
		||||
                  tr("shouts"),2);
 | 
			
		||||
    append_ic_text(shout_message, f_displayname, tr("shouts"));
 | 
			
		||||
    sfx_player->clear(); // Objection played! Cut all sfx.
 | 
			
		||||
  }
 | 
			
		||||
  else
 | 
			
		||||
    handle_chatmessage_2();
 | 
			
		||||
 | 
			
		||||
 if (!m_chatmessage[MESSAGE].isEmpty() || ic_chatlog_history.isEmpty() ||
 | 
			
		||||
      ic_chatlog_history.last().get_message() != "") {
 | 
			
		||||
    log_ic_text(f_charname, f_displayname, m_chatmessage[MESSAGE], "",
 | 
			
		||||
                m_chatmessage[TEXT_COLOR].toInt());
 | 
			
		||||
    append_ic_text(m_chatmessage[MESSAGE], f_displayname, "",
 | 
			
		||||
                   m_chatmessage[TEXT_COLOR].toInt());
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void Courtroom::objection_done() { handle_chatmessage_2(); }
 | 
			
		||||
@ -2294,11 +2331,12 @@ void Courtroom::handle_chatmessage_3()
 | 
			
		||||
                          f_side == "jud" || f_side == "jur");
 | 
			
		||||
    ui_vp_evidence_display->show_evidence(f_image, is_left_side,
 | 
			
		||||
                                          ui_sfx_slider->value());
 | 
			
		||||
 | 
			
		||||
    log_ic_text(m_chatmessage[CHAR_NAME], m_chatmessage[SHOWNAME], f_evi_name,
 | 
			
		||||
                tr("has presented evidence"),
 | 
			
		||||
                m_chatmessage[TEXT_COLOR].toInt());
 | 
			
		||||
    append_ic_text(f_evi_name, f_showname, tr("has presented evidence"));
 | 
			
		||||
    if (log_ic_actions) {
 | 
			
		||||
      log_ic_text(m_chatmessage[CHAR_NAME], m_chatmessage[SHOWNAME], f_evi_name,
 | 
			
		||||
                  tr("has presented evidence"),
 | 
			
		||||
                  m_chatmessage[TEXT_COLOR].toInt());
 | 
			
		||||
      append_ic_text(f_evi_name, f_showname, tr("has presented evidence"));
 | 
			
		||||
    }
 | 
			
		||||
    evidence_presented = true; // we're done presenting evidence, and we
 | 
			
		||||
                               // don't want to do it twice
 | 
			
		||||
  }
 | 
			
		||||
@ -2657,8 +2695,16 @@ void Courtroom::append_ic_text(QString p_text, QString p_name, QString p_action,
 | 
			
		||||
  if (p_action == tr("has stopped the music")) {
 | 
			
		||||
    ui_ic_chatlog->textCursor().insertText(" " + p_action + ".", normal);
 | 
			
		||||
  }
 | 
			
		||||
  // Make shout text bold
 | 
			
		||||
  else if (p_action == tr("shouts") && log_ic_actions) {
 | 
			
		||||
    ui_ic_chatlog->textCursor().insertText(" " + p_action + " ", normal);
 | 
			
		||||
    if (log_colors)
 | 
			
		||||
      ui_ic_chatlog->textCursor().insertHtml("<b>" + filter_ic_text(p_text, true, -1, 0) + "</b>");
 | 
			
		||||
    else
 | 
			
		||||
      ui_ic_chatlog->textCursor().insertText(" " + p_text, italics);
 | 
			
		||||
  }
 | 
			
		||||
  // If action not blank:
 | 
			
		||||
  else if (p_action != "") {
 | 
			
		||||
  else if (p_action != "" && log_ic_actions) {
 | 
			
		||||
    // Format the action in normal
 | 
			
		||||
    ui_ic_chatlog->textCursor().insertText(" " + p_action, normal);
 | 
			
		||||
    if (log_newline)
 | 
			
		||||
@ -4424,10 +4470,16 @@ void Courtroom::show_custom_objection_menu(const QPoint &pos)
 | 
			
		||||
    ui_take_that->set_image("takethat");
 | 
			
		||||
    ui_hold_it->set_image("holdit");
 | 
			
		||||
    ui_custom_objection->set_image("custom_selected");
 | 
			
		||||
    if (selecteditem->text() == "Default")
 | 
			
		||||
    if (selecteditem->text() == ao_app->read_char_ini(current_char, "custom_name", "Shouts") || selecteditem->text() == "Default")
 | 
			
		||||
      objection_custom = "";
 | 
			
		||||
    else
 | 
			
		||||
      objection_custom = selecteditem->text();
 | 
			
		||||
    else {
 | 
			
		||||
      foreach (CustomObjection custom_objection, custom_objections_list) {
 | 
			
		||||
        if (custom_objection.name == selecteditem->text()) {
 | 
			
		||||
          objection_custom = custom_objection.filename;
 | 
			
		||||
          break;
 | 
			
		||||
        }
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
    objection_state = 4;
 | 
			
		||||
    custom_obj_menu->setDefaultAction(selecteditem);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
@ -73,6 +73,13 @@ bool AOApplication::get_log_timestamp()
 | 
			
		||||
  return result.startsWith("true");
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
bool AOApplication::get_log_ic_actions()
 | 
			
		||||
{
 | 
			
		||||
  QString result =
 | 
			
		||||
      configini->value("log_ic_actions", "true").value<QString>();
 | 
			
		||||
  return result.startsWith("true");
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
bool AOApplication::get_showname_enabled_by_default()
 | 
			
		||||
{
 | 
			
		||||
  QString result =
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user