implemented sending IC messages
This commit is contained in:
		
							parent
							
								
									ea09ad9dfc
								
							
						
					
					
						commit
						b7b9794839
					
				@ -97,7 +97,13 @@ public:
 | 
			
		||||
  QString get_chat(QString p_char);
 | 
			
		||||
  int get_preanim_duration(QString p_char, QString p_emote);
 | 
			
		||||
  int get_text_delay(QString p_char, QString p_emote);
 | 
			
		||||
  QString get_char_name(QString p_name);
 | 
			
		||||
  QString get_char_name(QString p_char);
 | 
			
		||||
  int get_emote_number(QString p_char);
 | 
			
		||||
  QString get_emote(QString p_char, int p_emote);
 | 
			
		||||
  QString get_pre_emote(QString p_char, int p_emote);
 | 
			
		||||
  QString get_sfx_name(QString p_char, int p_emote);
 | 
			
		||||
  int get_sfx_delay(QString p_char, int p_emote);
 | 
			
		||||
  int get_emote_mod(QString p_char, int p_emote);
 | 
			
		||||
 | 
			
		||||
private:
 | 
			
		||||
  const int RELEASE = 2;
 | 
			
		||||
 | 
			
		||||
@ -1,10 +1,54 @@
 | 
			
		||||
#include "aoemotebutton.h"
 | 
			
		||||
 | 
			
		||||
#include "file_functions.h"
 | 
			
		||||
 | 
			
		||||
AOEmoteButton::AOEmoteButton(QWidget *p_parent, AOApplication *p_ao_app, int p_x, int p_y) : QPushButton(p_parent)
 | 
			
		||||
{
 | 
			
		||||
  m_parent = p_parent;
 | 
			
		||||
  m_ao_app = p_ao_app;
 | 
			
		||||
  parent = p_parent;
 | 
			
		||||
  ao_app = p_ao_app;
 | 
			
		||||
 | 
			
		||||
  this->move(p_x, p_y);
 | 
			
		||||
  this->resize(40, 40);
 | 
			
		||||
 | 
			
		||||
  connect(this, SIGNAL(clicked()), this, SLOT(on_clicked()));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void AOEmoteButton::set_on(QString p_char, int p_emote)
 | 
			
		||||
{
 | 
			
		||||
  //+1 because programmatical emotes start on 0, while filesystem ones start on 1
 | 
			
		||||
  QString emotion_number = QString::number(p_emote + 1);
 | 
			
		||||
  QString image_path = ao_app->get_character_path(p_char) + "emotions/button" + emotion_number + "_on.png";
 | 
			
		||||
 | 
			
		||||
  if (file_exists(image_path))
 | 
			
		||||
  {
 | 
			
		||||
    this->setText("");
 | 
			
		||||
    this->setStyleSheet("border-image:url(\"" + image_path + "\")");
 | 
			
		||||
  }
 | 
			
		||||
  else
 | 
			
		||||
  {
 | 
			
		||||
    this->setText(emotion_number);
 | 
			
		||||
    this->setStyleSheet("border-image:url(\"\")");
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void AOEmoteButton::set_off(QString p_char, int p_emote)
 | 
			
		||||
{
 | 
			
		||||
  QString emotion_number = QString::number(p_emote + 1);
 | 
			
		||||
  QString image_path = ao_app->get_character_path(p_char) + "emotions/button" + emotion_number + "_off.png";
 | 
			
		||||
 | 
			
		||||
  if (file_exists(image_path))
 | 
			
		||||
  {
 | 
			
		||||
    this->setText("");
 | 
			
		||||
    this->setStyleSheet("border-image:url(\"" + image_path + "\")");
 | 
			
		||||
  }
 | 
			
		||||
  else
 | 
			
		||||
  {
 | 
			
		||||
    this->setText(emotion_number);
 | 
			
		||||
    this->setStyleSheet("border-image:url(\"\")");
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void AOEmoteButton::on_clicked()
 | 
			
		||||
{
 | 
			
		||||
  emote_clicked(m_id);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -12,9 +12,23 @@ class AOEmoteButton : public QPushButton
 | 
			
		||||
public:
 | 
			
		||||
  AOEmoteButton(QWidget *p_parent, AOApplication *p_ao_app, int p_x, int p_y);
 | 
			
		||||
 | 
			
		||||
  void set_on(QString p_char, int p_emote);
 | 
			
		||||
  void set_off(QString p_char, int p_emote);
 | 
			
		||||
 | 
			
		||||
  void set_id(int p_id) {m_id = p_id;}
 | 
			
		||||
  int get_id() {return m_id;}
 | 
			
		||||
 | 
			
		||||
private:
 | 
			
		||||
  QWidget *m_parent;
 | 
			
		||||
  AOApplication *m_ao_app;
 | 
			
		||||
  QWidget *parent;
 | 
			
		||||
  AOApplication *ao_app;
 | 
			
		||||
 | 
			
		||||
  int m_id = 0;
 | 
			
		||||
 | 
			
		||||
signals:
 | 
			
		||||
  void emote_clicked(int p_id);
 | 
			
		||||
 | 
			
		||||
private slots:
 | 
			
		||||
  void on_clicked();
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
#endif // AOEMOTEBUTTON_H
 | 
			
		||||
 | 
			
		||||
@ -192,9 +192,16 @@ Courtroom::Courtroom(AOApplication *p_ao_app) : QMainWindow()
 | 
			
		||||
 | 
			
		||||
  connect(chat_tick_timer, SIGNAL(timeout()), this, SLOT(chat_tick()));
 | 
			
		||||
 | 
			
		||||
  //emote signals are set in emotes.cpp
 | 
			
		||||
 | 
			
		||||
  connect(ui_ic_chat_message, SIGNAL(returnPressed()), this, SLOT(on_chat_return_pressed()));
 | 
			
		||||
 | 
			
		||||
  connect(ui_ooc_chat_message, SIGNAL(returnPressed()), this, SLOT(on_ooc_return_pressed()));
 | 
			
		||||
  connect(ui_ooc_toggle, SIGNAL(clicked()), this, SLOT(on_ooc_toggle_clicked()));
 | 
			
		||||
 | 
			
		||||
  connect(ui_emote_left, SIGNAL(clicked()), this, SLOT(on_emote_left_clicked()));
 | 
			
		||||
  connect(ui_emote_right, SIGNAL(clicked()), this, SLOT(on_emote_right_clicked()));
 | 
			
		||||
 | 
			
		||||
  connect(ui_witness_testimony, SIGNAL(clicked()), this, SLOT(on_witness_testimony_clicked()));
 | 
			
		||||
  connect(ui_cross_examination, SIGNAL(clicked()), this, SLOT(on_cross_examination_clicked()));
 | 
			
		||||
 | 
			
		||||
@ -503,8 +510,6 @@ void Courtroom::set_char_select_page()
 | 
			
		||||
  else
 | 
			
		||||
    chars_on_page = 90;
 | 
			
		||||
 | 
			
		||||
  qDebug() << "chars_on_page: " << chars_on_page;
 | 
			
		||||
 | 
			
		||||
  if (total_pages > current_char_page + 1)
 | 
			
		||||
    ui_char_select_right->show();
 | 
			
		||||
 | 
			
		||||
@ -554,6 +559,7 @@ void Courtroom::enter_courtroom(int p_cid)
 | 
			
		||||
  current_char = f_char;
 | 
			
		||||
 | 
			
		||||
  current_emote_page = 0;
 | 
			
		||||
  current_emote = 0;
 | 
			
		||||
 | 
			
		||||
  set_emote_page();
 | 
			
		||||
 | 
			
		||||
@ -629,6 +635,92 @@ void Courtroom::append_server_chatmessage(QString f_message)
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void Courtroom::on_chat_return_pressed()
 | 
			
		||||
{
 | 
			
		||||
  if (ui_ic_chat_message->text() == "")
 | 
			
		||||
    return;
 | 
			
		||||
 | 
			
		||||
  //MS#chat#
 | 
			
		||||
  //pre-emote#
 | 
			
		||||
  //character#
 | 
			
		||||
  //emote#
 | 
			
		||||
  //message#
 | 
			
		||||
  //side#
 | 
			
		||||
  //sfx-name#
 | 
			
		||||
  //emote_modifier#
 | 
			
		||||
  //char_id#
 | 
			
		||||
  //sfx_delay#
 | 
			
		||||
  //objection_modifier#
 | 
			
		||||
  //evidence#
 | 
			
		||||
  //placeholder#
 | 
			
		||||
  //realization#
 | 
			
		||||
  //text_color#%
 | 
			
		||||
 | 
			
		||||
  QStringList packet_contents;
 | 
			
		||||
 | 
			
		||||
  packet_contents.append("chat");
 | 
			
		||||
 | 
			
		||||
  packet_contents.append(ao_app->get_pre_emote(current_char, current_emote));
 | 
			
		||||
 | 
			
		||||
  packet_contents.append(current_char);
 | 
			
		||||
 | 
			
		||||
  packet_contents.append(ao_app->get_emote(current_char, current_emote));
 | 
			
		||||
 | 
			
		||||
  packet_contents.append(ui_ic_chat_message->text());
 | 
			
		||||
 | 
			
		||||
  packet_contents.append(ao_app->get_char_side(current_char));
 | 
			
		||||
 | 
			
		||||
  packet_contents.append(ao_app->get_sfx_name(current_char, current_emote));
 | 
			
		||||
 | 
			
		||||
  packet_contents.append(QString::number(ao_app->get_emote_mod(current_char, current_emote)));
 | 
			
		||||
 | 
			
		||||
  packet_contents.append(QString::number(m_cid));
 | 
			
		||||
 | 
			
		||||
  packet_contents.append(QString::number(ao_app->get_sfx_delay(current_char, current_emote)));
 | 
			
		||||
 | 
			
		||||
  QString f_obj_state;
 | 
			
		||||
 | 
			
		||||
  if ((objection_state > 3 && !ao_app->ao2_features) ||
 | 
			
		||||
    (objection_state < 0))
 | 
			
		||||
    f_obj_state = "0";
 | 
			
		||||
  else
 | 
			
		||||
    f_obj_state = QString::number(objection_state);
 | 
			
		||||
 | 
			
		||||
  packet_contents.append(f_obj_state);
 | 
			
		||||
 | 
			
		||||
  //evidence. 0 for now
 | 
			
		||||
  packet_contents.append("0");
 | 
			
		||||
 | 
			
		||||
  QString f_flip;
 | 
			
		||||
 | 
			
		||||
  if (ao_app->ao2_features)
 | 
			
		||||
  {
 | 
			
		||||
    if (ui_flip->isChecked())
 | 
			
		||||
      f_flip = "1";
 | 
			
		||||
    else
 | 
			
		||||
      f_flip = "0";
 | 
			
		||||
  }
 | 
			
		||||
  else
 | 
			
		||||
    f_flip = QString::number(m_cid);
 | 
			
		||||
 | 
			
		||||
  packet_contents.append(f_flip);
 | 
			
		||||
 | 
			
		||||
  packet_contents.append(QString::number(realization_state));
 | 
			
		||||
 | 
			
		||||
  QString f_text_color;
 | 
			
		||||
 | 
			
		||||
  if (text_color < 0)
 | 
			
		||||
    f_text_color = "0";
 | 
			
		||||
  else if (text_color > 4 && !ao_app->ao2_features)
 | 
			
		||||
    f_text_color = "0";
 | 
			
		||||
  else
 | 
			
		||||
    f_text_color = QString::number(text_color);
 | 
			
		||||
 | 
			
		||||
  packet_contents.append(f_text_color);
 | 
			
		||||
 | 
			
		||||
  ao_app->send_server_packet(new AOPacket("MS", packet_contents));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void Courtroom::handle_chatmessage(QStringList *p_contents)
 | 
			
		||||
{
 | 
			
		||||
  text_state = 0;
 | 
			
		||||
@ -639,6 +731,9 @@ void Courtroom::handle_chatmessage(QStringList *p_contents)
 | 
			
		||||
    m_chatmessage[n_string] = p_contents->at(n_string);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  if (m_chatmessage[MESSAGE] == ui_ic_chat_message->text())
 | 
			
		||||
    ui_ic_chat_message->clear();
 | 
			
		||||
 | 
			
		||||
  chatmessage_is_empty = m_chatmessage[MESSAGE] == " " || m_chatmessage[MESSAGE] == "";
 | 
			
		||||
 | 
			
		||||
  QString f_message = m_chatmessage[CHAR_NAME] + ": " + m_chatmessage[MESSAGE] + '\n';
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										12
									
								
								courtroom.h
									
									
									
									
									
								
							
							
						
						
									
										12
									
								
								courtroom.h
									
									
									
									
									
								
							@ -123,6 +123,10 @@ private:
 | 
			
		||||
  //cid and this may differ in cases of ini-editing
 | 
			
		||||
  QString current_char = "";
 | 
			
		||||
 | 
			
		||||
  int objection_state = 0;
 | 
			
		||||
  int realization_state = 0;
 | 
			
		||||
  int text_color = 0;
 | 
			
		||||
 | 
			
		||||
  int current_emote_page = 0;
 | 
			
		||||
  int current_emote = 0;
 | 
			
		||||
  const int max_emotes_on_page = 10;
 | 
			
		||||
@ -246,7 +250,15 @@ private slots:
 | 
			
		||||
 | 
			
		||||
  void chat_tick();
 | 
			
		||||
 | 
			
		||||
  void on_chat_return_pressed();
 | 
			
		||||
 | 
			
		||||
  void on_ooc_return_pressed();
 | 
			
		||||
 | 
			
		||||
  void on_emote_clicked(int p_id);
 | 
			
		||||
 | 
			
		||||
  void on_emote_left_clicked();
 | 
			
		||||
  void on_emote_right_clicked();
 | 
			
		||||
 | 
			
		||||
  void on_ooc_toggle_clicked();
 | 
			
		||||
 | 
			
		||||
  void on_witness_testimony_clicked();
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										81
									
								
								emotes.cpp
									
									
									
									
									
								
							
							
						
						
									
										81
									
								
								emotes.cpp
									
									
									
									
									
								
							@ -2,6 +2,8 @@
 | 
			
		||||
 | 
			
		||||
#include "aoemotebutton.h"
 | 
			
		||||
 | 
			
		||||
#include <QDebug>
 | 
			
		||||
 | 
			
		||||
void Courtroom::construct_emotes()
 | 
			
		||||
{
 | 
			
		||||
  //constructing emote button grid
 | 
			
		||||
@ -14,12 +16,18 @@ void Courtroom::construct_emotes()
 | 
			
		||||
  const int y_modifier{49};
 | 
			
		||||
  int y_mod_count{0};
 | 
			
		||||
 | 
			
		||||
  for (int n = 0 ; n < 90 ; ++n)
 | 
			
		||||
  for (int n = 0 ; n < 10 ; ++n)
 | 
			
		||||
  {
 | 
			
		||||
    int x_pos = base_x_pos + (x_modifier * x_mod_count);
 | 
			
		||||
    int y_pos = base_y_pos + (y_modifier * y_mod_count);
 | 
			
		||||
 | 
			
		||||
    ui_emote_list.append(new AOEmoteButton(ui_emotes, ao_app, x_pos, y_pos));
 | 
			
		||||
    AOEmoteButton *f_emote = new AOEmoteButton(ui_emotes, ao_app, x_pos, y_pos);
 | 
			
		||||
 | 
			
		||||
    ui_emote_list.append(f_emote);
 | 
			
		||||
 | 
			
		||||
    f_emote->set_id(n);
 | 
			
		||||
 | 
			
		||||
    connect(f_emote, SIGNAL(emote_clicked(int)), this, SLOT(on_emote_clicked(int)));
 | 
			
		||||
 | 
			
		||||
    ++x_mod_count;
 | 
			
		||||
 | 
			
		||||
@ -34,6 +42,8 @@ void Courtroom::construct_emotes()
 | 
			
		||||
 | 
			
		||||
void Courtroom::set_emote_page()
 | 
			
		||||
{
 | 
			
		||||
  int total_emotes = ao_app->get_emote_number(current_char);
 | 
			
		||||
 | 
			
		||||
  ui_emote_left->hide();
 | 
			
		||||
  ui_emote_right->hide();
 | 
			
		||||
 | 
			
		||||
@ -42,4 +52,71 @@ void Courtroom::set_emote_page()
 | 
			
		||||
    i_button->hide();
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  int total_pages = total_emotes / 10;
 | 
			
		||||
  int emotes_on_page = 0;
 | 
			
		||||
 | 
			
		||||
  if (total_emotes % 10 != 0)
 | 
			
		||||
  {
 | 
			
		||||
    ++total_pages;
 | 
			
		||||
    //i. e. not on the last page
 | 
			
		||||
    if (total_pages > current_emote_page + 1)
 | 
			
		||||
      emotes_on_page = 10;
 | 
			
		||||
    else
 | 
			
		||||
      emotes_on_page = total_emotes % 10;
 | 
			
		||||
 | 
			
		||||
  }
 | 
			
		||||
  else
 | 
			
		||||
    emotes_on_page = 10;
 | 
			
		||||
 | 
			
		||||
  if (total_pages > current_emote_page + 1)
 | 
			
		||||
    ui_emote_right->show();
 | 
			
		||||
 | 
			
		||||
  if (current_emote_page > 0)
 | 
			
		||||
    ui_emote_left->show();
 | 
			
		||||
 | 
			
		||||
  for (int n_emote = 0 ; n_emote < emotes_on_page ; ++n_emote)
 | 
			
		||||
  {
 | 
			
		||||
    int n_real_emote = n_emote + current_emote_page * 10;
 | 
			
		||||
    AOEmoteButton *f_emote = ui_emote_list.at(n_emote);
 | 
			
		||||
 | 
			
		||||
    if (n_real_emote == current_emote)
 | 
			
		||||
      f_emote->set_on(current_char, n_real_emote);
 | 
			
		||||
    else
 | 
			
		||||
      f_emote->set_off(current_char, n_real_emote);
 | 
			
		||||
 | 
			
		||||
    f_emote->show();
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void Courtroom::on_emote_clicked(int p_id)
 | 
			
		||||
{
 | 
			
		||||
  current_emote = p_id + 10 * current_emote_page;
 | 
			
		||||
 | 
			
		||||
  for (int n_emote = 0 ; n_emote < 10 ; ++n_emote)
 | 
			
		||||
  {
 | 
			
		||||
    int n_real_emote = n_emote + current_emote_page * 10;
 | 
			
		||||
    AOEmoteButton *f_emote = ui_emote_list.at(n_emote);
 | 
			
		||||
 | 
			
		||||
    if (n_real_emote == current_emote)
 | 
			
		||||
      f_emote->set_on(current_char, n_real_emote);
 | 
			
		||||
    else
 | 
			
		||||
      f_emote->set_off(current_char, n_real_emote);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  //T0D0: check pre if it's a pre emote
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void Courtroom::on_emote_left_clicked()
 | 
			
		||||
{
 | 
			
		||||
  --current_emote_page;
 | 
			
		||||
 | 
			
		||||
  set_emote_page();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void Courtroom::on_emote_right_clicked()
 | 
			
		||||
{
 | 
			
		||||
  ++current_emote_page;
 | 
			
		||||
 | 
			
		||||
  set_emote_page();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -283,9 +283,9 @@ int AOApplication::get_text_delay(QString p_char, QString p_emote)
 | 
			
		||||
  return -1;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
QString AOApplication::get_char_name(QString p_name)
 | 
			
		||||
QString AOApplication::get_char_name(QString p_char)
 | 
			
		||||
{
 | 
			
		||||
  QString char_ini_path = get_character_path(p_name) + "char.ini";
 | 
			
		||||
  QString char_ini_path = get_character_path(p_char) + "char.ini";
 | 
			
		||||
 | 
			
		||||
  QFile char_ini;
 | 
			
		||||
 | 
			
		||||
@ -316,3 +316,246 @@ QString AOApplication::get_char_name(QString p_name)
 | 
			
		||||
  return "";
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int AOApplication::get_emote_number(QString p_char)
 | 
			
		||||
{
 | 
			
		||||
  QString char_ini_path = get_character_path(p_char) + "char.ini";
 | 
			
		||||
  QFile char_ini;
 | 
			
		||||
  char_ini.setFileName(char_ini_path);
 | 
			
		||||
 | 
			
		||||
  if (!char_ini.open(QIODevice::ReadOnly))
 | 
			
		||||
  {
 | 
			
		||||
    return 0;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  QTextStream in(&char_ini);
 | 
			
		||||
  bool emotions_found = false;
 | 
			
		||||
 | 
			
		||||
  while(!in.atEnd())
 | 
			
		||||
  {
 | 
			
		||||
    QString line = in.readLine();
 | 
			
		||||
 | 
			
		||||
    if (line.startsWith("[SoundN]"))
 | 
			
		||||
      return 0;
 | 
			
		||||
 | 
			
		||||
    if (line.startsWith("[Emotions]"))
 | 
			
		||||
      emotions_found = true;
 | 
			
		||||
 | 
			
		||||
    if (!line.startsWith("number"))
 | 
			
		||||
      continue;
 | 
			
		||||
 | 
			
		||||
    QStringList line_elements = line.split("=");
 | 
			
		||||
 | 
			
		||||
    if (line_elements.size() < 2)
 | 
			
		||||
      continue;
 | 
			
		||||
 | 
			
		||||
    if (emotions_found)
 | 
			
		||||
      return line_elements.at(1).trimmed().toInt();
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
QString AOApplication::get_pre_emote(QString p_char, int p_emote)
 | 
			
		||||
{
 | 
			
		||||
  QString char_ini_path = get_character_path(p_char) + "char.ini";
 | 
			
		||||
  QFile char_ini;
 | 
			
		||||
  char_ini.setFileName(char_ini_path);
 | 
			
		||||
 | 
			
		||||
  if (!char_ini.open(QIODevice::ReadOnly))
 | 
			
		||||
  {
 | 
			
		||||
    return "normal";
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  QTextStream in(&char_ini);
 | 
			
		||||
  bool emotions_found = false;
 | 
			
		||||
  QString search_line = QString::number(p_emote + 1);
 | 
			
		||||
 | 
			
		||||
  while(!in.atEnd())
 | 
			
		||||
  {
 | 
			
		||||
    QString line = in.readLine();
 | 
			
		||||
 | 
			
		||||
    if (line.startsWith("[SoundN]"))
 | 
			
		||||
      return "normal";
 | 
			
		||||
 | 
			
		||||
    if (line.startsWith("[Emotions]"))
 | 
			
		||||
      emotions_found = true;
 | 
			
		||||
 | 
			
		||||
    if (!line.startsWith(search_line))
 | 
			
		||||
      continue;
 | 
			
		||||
 | 
			
		||||
    QStringList line_elements = line.split("=");
 | 
			
		||||
 | 
			
		||||
    if (line_elements.size() < 4)
 | 
			
		||||
      continue;
 | 
			
		||||
 | 
			
		||||
    if (emotions_found)
 | 
			
		||||
      return line_elements.at(1).trimmed();
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  return "normal";
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
QString AOApplication::get_emote(QString p_char, int p_emote)
 | 
			
		||||
{
 | 
			
		||||
  QString char_ini_path = get_character_path(p_char) + "char.ini";
 | 
			
		||||
  QFile char_ini;
 | 
			
		||||
  char_ini.setFileName(char_ini_path);
 | 
			
		||||
 | 
			
		||||
  if (!char_ini.open(QIODevice::ReadOnly))
 | 
			
		||||
  {
 | 
			
		||||
    return "normal";
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  QTextStream in(&char_ini);
 | 
			
		||||
  bool emotions_found = false;
 | 
			
		||||
  QString search_line = QString::number(p_emote + 1);
 | 
			
		||||
 | 
			
		||||
  while(!in.atEnd())
 | 
			
		||||
  {
 | 
			
		||||
    QString line = in.readLine();
 | 
			
		||||
 | 
			
		||||
    if (line.startsWith("[SoundN]"))
 | 
			
		||||
      return "normal";
 | 
			
		||||
 | 
			
		||||
    if (line.startsWith("[Emotions]"))
 | 
			
		||||
      emotions_found = true;
 | 
			
		||||
 | 
			
		||||
    if (!line.startsWith(search_line))
 | 
			
		||||
      continue;
 | 
			
		||||
 | 
			
		||||
    QStringList line_elements = line.split("=");
 | 
			
		||||
 | 
			
		||||
    if (line_elements.size() < 4)
 | 
			
		||||
      continue;
 | 
			
		||||
 | 
			
		||||
    if (emotions_found)
 | 
			
		||||
      return line_elements.at(2).trimmed();
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  return "normal";
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
QString AOApplication::get_sfx_name(QString p_char, int p_emote)
 | 
			
		||||
{
 | 
			
		||||
  QString char_ini_path = get_character_path(p_char) + "char.ini";
 | 
			
		||||
  QFile char_ini;
 | 
			
		||||
  char_ini.setFileName(char_ini_path);
 | 
			
		||||
 | 
			
		||||
  if (!char_ini.open(QIODevice::ReadOnly))
 | 
			
		||||
  {
 | 
			
		||||
    return "1";
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  QTextStream in(&char_ini);
 | 
			
		||||
  bool soundn_found = false;
 | 
			
		||||
  QString search_line = QString::number(p_emote + 1);
 | 
			
		||||
 | 
			
		||||
  while(!in.atEnd())
 | 
			
		||||
  {
 | 
			
		||||
    QString line = in.readLine();
 | 
			
		||||
 | 
			
		||||
    if (line.startsWith("[SoundT]"))
 | 
			
		||||
      return "1";
 | 
			
		||||
 | 
			
		||||
    if (line.startsWith("[SoundN]"))
 | 
			
		||||
      soundn_found = true;
 | 
			
		||||
 | 
			
		||||
    if (!soundn_found)
 | 
			
		||||
      continue;
 | 
			
		||||
 | 
			
		||||
    if (!line.startsWith(search_line))
 | 
			
		||||
      continue;
 | 
			
		||||
 | 
			
		||||
    QStringList line_elements = line.split("=");
 | 
			
		||||
 | 
			
		||||
    if (line_elements.size() < 2)
 | 
			
		||||
      continue;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    return line_elements.at(1).trimmed();
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  return "1";
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
int AOApplication::get_sfx_delay(QString p_char, int p_emote)
 | 
			
		||||
{
 | 
			
		||||
  QString char_ini_path = get_character_path(p_char) + "char.ini";
 | 
			
		||||
  QFile char_ini;
 | 
			
		||||
  char_ini.setFileName(char_ini_path);
 | 
			
		||||
 | 
			
		||||
  if (!char_ini.open(QIODevice::ReadOnly))
 | 
			
		||||
  {
 | 
			
		||||
    return 0;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  QTextStream in(&char_ini);
 | 
			
		||||
  bool soundt_found = false;
 | 
			
		||||
  QString search_line = QString::number(p_emote + 1);
 | 
			
		||||
 | 
			
		||||
  while(!in.atEnd())
 | 
			
		||||
  {
 | 
			
		||||
    QString line = in.readLine();
 | 
			
		||||
 | 
			
		||||
    if (line.startsWith("[SoundT]"))
 | 
			
		||||
      soundt_found = true;
 | 
			
		||||
 | 
			
		||||
    if (!soundt_found)
 | 
			
		||||
      continue;
 | 
			
		||||
 | 
			
		||||
    if (!line.startsWith(search_line))
 | 
			
		||||
      continue;
 | 
			
		||||
 | 
			
		||||
    QStringList line_elements = line.split("=");
 | 
			
		||||
 | 
			
		||||
    if (line_elements.size() < 2)
 | 
			
		||||
      continue;
 | 
			
		||||
 | 
			
		||||
    return line_elements.at(1).trimmed().toInt();
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int AOApplication::get_emote_mod(QString p_char, int p_emote)
 | 
			
		||||
{
 | 
			
		||||
  QString char_ini_path = get_character_path(p_char) + "char.ini";
 | 
			
		||||
  QFile char_ini;
 | 
			
		||||
  char_ini.setFileName(char_ini_path);
 | 
			
		||||
 | 
			
		||||
  if (!char_ini.open(QIODevice::ReadOnly))
 | 
			
		||||
  {
 | 
			
		||||
    return 0;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  QTextStream in(&char_ini);
 | 
			
		||||
  bool emotions_found = false;
 | 
			
		||||
  QString search_line = QString::number(p_emote + 1);
 | 
			
		||||
 | 
			
		||||
  while(!in.atEnd())
 | 
			
		||||
  {
 | 
			
		||||
    QString line = in.readLine();
 | 
			
		||||
 | 
			
		||||
    if (line.startsWith("[SoundN]"))
 | 
			
		||||
      return 0;
 | 
			
		||||
 | 
			
		||||
    if (line.startsWith("[Emotions]"))
 | 
			
		||||
      emotions_found = true;
 | 
			
		||||
 | 
			
		||||
    if (!line.startsWith(search_line))
 | 
			
		||||
      continue;
 | 
			
		||||
 | 
			
		||||
    QStringList line_elements = line.split("=");
 | 
			
		||||
 | 
			
		||||
    if (line_elements.size() < 4)
 | 
			
		||||
      continue;
 | 
			
		||||
 | 
			
		||||
    if (emotions_found)
 | 
			
		||||
      return line_elements.at(3).trimmed().toInt();
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user