started implementing emotes
This commit is contained in:
		
							parent
							
								
									0997bdc26f
								
							
						
					
					
						commit
						ea09ad9dfc
					
				@ -35,7 +35,9 @@ SOURCES += main.cpp\
 | 
			
		||||
    aoscene.cpp \
 | 
			
		||||
    aomovie.cpp \
 | 
			
		||||
    misc_functions.cpp \
 | 
			
		||||
    aocharmovie.cpp
 | 
			
		||||
    aocharmovie.cpp \
 | 
			
		||||
    aoemotebutton.cpp \
 | 
			
		||||
    emotes.cpp
 | 
			
		||||
 | 
			
		||||
HEADERS  += lobby.h \
 | 
			
		||||
    aoimage.h \
 | 
			
		||||
@ -54,4 +56,5 @@ HEADERS  += lobby.h \
 | 
			
		||||
    aoscene.h \
 | 
			
		||||
    aomovie.h \
 | 
			
		||||
    misc_functions.h \
 | 
			
		||||
    aocharmovie.h
 | 
			
		||||
    aocharmovie.h \
 | 
			
		||||
    aoemotebutton.h
 | 
			
		||||
 | 
			
		||||
@ -95,6 +95,14 @@ void AOApplication::set_favorite_list()
 | 
			
		||||
  favorite_list = read_serverlist_txt();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
QString AOApplication::get_current_char()
 | 
			
		||||
{
 | 
			
		||||
  if (courtroom_constructed)
 | 
			
		||||
    return w_courtroom->get_current_char();
 | 
			
		||||
  else
 | 
			
		||||
    return "";
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void AOApplication::add_favorite_server(int p_server)
 | 
			
		||||
{
 | 
			
		||||
  if (p_server < 0 || p_server >= server_list.size())
 | 
			
		||||
 | 
			
		||||
@ -74,6 +74,8 @@ public:
 | 
			
		||||
  void set_user_theme();
 | 
			
		||||
  QString get_user_theme() {return user_theme;}
 | 
			
		||||
 | 
			
		||||
  QString get_current_char();
 | 
			
		||||
 | 
			
		||||
  //implementation in path_functions.cpp
 | 
			
		||||
  QString get_base_path();
 | 
			
		||||
  QString get_theme_path();
 | 
			
		||||
@ -82,7 +84,6 @@ public:
 | 
			
		||||
  QString get_demothings_path();
 | 
			
		||||
  QString get_sounds_path();
 | 
			
		||||
  QString get_music_path();
 | 
			
		||||
 | 
			
		||||
  QString get_background_path();
 | 
			
		||||
  QString get_default_background_path();
 | 
			
		||||
 | 
			
		||||
@ -96,6 +97,7 @@ 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);
 | 
			
		||||
 | 
			
		||||
private:
 | 
			
		||||
  const int RELEASE = 2;
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										10
									
								
								aoemotebutton.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										10
									
								
								aoemotebutton.cpp
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,10 @@
 | 
			
		||||
#include "aoemotebutton.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;
 | 
			
		||||
 | 
			
		||||
  this->move(p_x, p_y);
 | 
			
		||||
  this->resize(40, 40);
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										20
									
								
								aoemotebutton.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										20
									
								
								aoemotebutton.h
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,20 @@
 | 
			
		||||
#ifndef AOEMOTEBUTTON_H
 | 
			
		||||
#define AOEMOTEBUTTON_H
 | 
			
		||||
 | 
			
		||||
#include <QPushButton>
 | 
			
		||||
 | 
			
		||||
#include "aoapplication.h"
 | 
			
		||||
 | 
			
		||||
class AOEmoteButton : public QPushButton
 | 
			
		||||
{
 | 
			
		||||
  Q_OBJECT
 | 
			
		||||
 | 
			
		||||
public:
 | 
			
		||||
  AOEmoteButton(QWidget *p_parent, AOApplication *p_ao_app, int p_x, int p_y);
 | 
			
		||||
 | 
			
		||||
private:
 | 
			
		||||
  QWidget *m_parent;
 | 
			
		||||
  AOApplication *m_ao_app;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
#endif // AOEMOTEBUTTON_H
 | 
			
		||||
@ -74,10 +74,15 @@ Courtroom::Courtroom(AOApplication *p_ao_app) : QMainWindow()
 | 
			
		||||
  ui_music_search = new QLineEdit(this);
 | 
			
		||||
  ui_music_search->setFrame(false);
 | 
			
		||||
 | 
			
		||||
  //emote buttons
 | 
			
		||||
  //////////emotes//////////////////////
 | 
			
		||||
 | 
			
		||||
  ui_emote_left = new AOButton(this, ao_app);
 | 
			
		||||
  ui_emote_right = new AOButton(this, ao_app);
 | 
			
		||||
  ui_emotes = new QWidget(this);
 | 
			
		||||
 | 
			
		||||
  //implementation in emotes.cpp
 | 
			
		||||
  construct_emotes();
 | 
			
		||||
 | 
			
		||||
  ui_emote_left = new AOButton(ui_emotes, ao_app);
 | 
			
		||||
  ui_emote_right = new AOButton(ui_emotes, ao_app);
 | 
			
		||||
 | 
			
		||||
  ui_defense_bar = new AOImage(this, ao_app);
 | 
			
		||||
  ui_prosecution_bar = new  AOImage(this, ao_app);
 | 
			
		||||
@ -314,6 +319,8 @@ void Courtroom::set_widgets()
 | 
			
		||||
  set_size_and_pos(ui_area_password, "area_password");
 | 
			
		||||
  set_size_and_pos(ui_music_search, "music_search");
 | 
			
		||||
 | 
			
		||||
  set_size_and_pos(ui_emotes, "emotes");
 | 
			
		||||
 | 
			
		||||
  //emote buttons
 | 
			
		||||
 | 
			
		||||
  set_size_and_pos(ui_emote_left, "emote_left");
 | 
			
		||||
@ -543,9 +550,12 @@ void Courtroom::set_background(QString p_background)
 | 
			
		||||
void Courtroom::enter_courtroom(int p_cid)
 | 
			
		||||
{
 | 
			
		||||
  m_cid = p_cid;
 | 
			
		||||
  QString f_char = char_list.at(m_cid).name;
 | 
			
		||||
  QString f_char = ao_app->get_char_name(char_list.at(m_cid).name);
 | 
			
		||||
  current_char = f_char;
 | 
			
		||||
 | 
			
		||||
  //T0D0: set emote buttons
 | 
			
		||||
  current_emote_page = 0;
 | 
			
		||||
 | 
			
		||||
  set_emote_page();
 | 
			
		||||
 | 
			
		||||
  QString side = ao_app->get_char_side(f_char);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										25
									
								
								courtroom.h
									
									
									
									
									
								
							
							
						
						
									
										25
									
								
								courtroom.h
									
									
									
									
									
								
							@ -4,6 +4,7 @@
 | 
			
		||||
#include "aoimage.h"
 | 
			
		||||
#include "aobutton.h"
 | 
			
		||||
#include "aocharbutton.h"
 | 
			
		||||
#include "aoemotebutton.h"
 | 
			
		||||
#include "aopacket.h"
 | 
			
		||||
#include "aoscene.h"
 | 
			
		||||
#include "aomovie.h"
 | 
			
		||||
@ -52,6 +53,7 @@ public:
 | 
			
		||||
  QString get_default_background_path();
 | 
			
		||||
 | 
			
		||||
  int get_cid() {return m_cid;}
 | 
			
		||||
  QString get_current_char() {return current_char;}
 | 
			
		||||
 | 
			
		||||
  void enter_courtroom(int p_cid);
 | 
			
		||||
 | 
			
		||||
@ -114,17 +116,21 @@ private:
 | 
			
		||||
  //state of text ticking, 0 = not yet ticking, 1 = ticking in progress, 2 = ticking done
 | 
			
		||||
  int text_state = 0;
 | 
			
		||||
 | 
			
		||||
  //0 is the first page, 1 second etc.
 | 
			
		||||
  //makes char arithmetic easier
 | 
			
		||||
  int current_char_page = 0;
 | 
			
		||||
 | 
			
		||||
  //character id, which index of the char_list the player is
 | 
			
		||||
  int m_cid = 0;
 | 
			
		||||
  //cid and this may differ in cases of ini-editing
 | 
			
		||||
  QString current_char = "";
 | 
			
		||||
 | 
			
		||||
  int current_emote_page = 0;
 | 
			
		||||
  int current_emote = 0;
 | 
			
		||||
  const int max_emotes_on_page = 10;
 | 
			
		||||
 | 
			
		||||
  //is set to true if the bg folder contains defensedesk.png, prosecutiondesk.png and stand.png
 | 
			
		||||
  bool is_ao2_bg = false;
 | 
			
		||||
 | 
			
		||||
  //wether the ooc chat is server or master chat, true is server
 | 
			
		||||
  //whether the ooc chat is server or master chat, true is server
 | 
			
		||||
  bool server_ooc = true;
 | 
			
		||||
 | 
			
		||||
  QString current_background = "gs4";
 | 
			
		||||
@ -133,14 +139,12 @@ private:
 | 
			
		||||
 | 
			
		||||
  AOImage *ui_background;
 | 
			
		||||
 | 
			
		||||
  //ui_viewport is the parent of all the viewport widgets
 | 
			
		||||
  QWidget *ui_viewport;
 | 
			
		||||
  AOScene *ui_vp_background;
 | 
			
		||||
  AOMovie *ui_vp_speedlines;
 | 
			
		||||
  AOCharMovie *ui_vp_player_char;
 | 
			
		||||
  AOScene *ui_vp_desk;
 | 
			
		||||
  AOScene *ui_vp_legacy_desk;
 | 
			
		||||
  //AOImage *ui_vp_legacy_padding;
 | 
			
		||||
  AOImage *ui_vp_chatbox;
 | 
			
		||||
  QLabel *ui_vp_showname;
 | 
			
		||||
  QPlainTextEdit *ui_vp_message;
 | 
			
		||||
@ -166,8 +170,8 @@ private:
 | 
			
		||||
  QLineEdit *ui_area_password;
 | 
			
		||||
  QLineEdit *ui_music_search;
 | 
			
		||||
 | 
			
		||||
  //T0D0: add emote buttons
 | 
			
		||||
 | 
			
		||||
  QWidget *ui_emotes;
 | 
			
		||||
  QVector<AOEmoteButton*> ui_emote_list;
 | 
			
		||||
  AOButton *ui_emote_left;
 | 
			
		||||
  AOButton *ui_emote_right;
 | 
			
		||||
 | 
			
		||||
@ -213,8 +217,6 @@ private:
 | 
			
		||||
 | 
			
		||||
  AOImage *ui_muted;
 | 
			
		||||
 | 
			
		||||
  //char select stuff under here
 | 
			
		||||
 | 
			
		||||
  AOImage *ui_char_select_background;
 | 
			
		||||
 | 
			
		||||
  QVector<AOCharButton*> ui_char_button_list;
 | 
			
		||||
@ -229,6 +231,11 @@ private:
 | 
			
		||||
 | 
			
		||||
  AOButton *ui_spectator;
 | 
			
		||||
 | 
			
		||||
  void construct_emotes();
 | 
			
		||||
  void set_emote_page();
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
public slots:
 | 
			
		||||
  void objection_done();
 | 
			
		||||
  void preanim_done();
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										45
									
								
								emotes.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										45
									
								
								emotes.cpp
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,45 @@
 | 
			
		||||
#include "courtroom.h"
 | 
			
		||||
 | 
			
		||||
#include "aoemotebutton.h"
 | 
			
		||||
 | 
			
		||||
void Courtroom::construct_emotes()
 | 
			
		||||
{
 | 
			
		||||
  //constructing emote button grid
 | 
			
		||||
  const int base_x_pos{10};
 | 
			
		||||
  const int base_y_pos{0};
 | 
			
		||||
 | 
			
		||||
  const int x_modifier{49};
 | 
			
		||||
  int x_mod_count{0};
 | 
			
		||||
 | 
			
		||||
  const int y_modifier{49};
 | 
			
		||||
  int y_mod_count{0};
 | 
			
		||||
 | 
			
		||||
  for (int n = 0 ; n < 90 ; ++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));
 | 
			
		||||
 | 
			
		||||
    ++x_mod_count;
 | 
			
		||||
 | 
			
		||||
    //if char number is divisible by 5 with rest 4 then the next emote button should start on a new line
 | 
			
		||||
    if (n % 5 == 4 && n != 0)
 | 
			
		||||
    {
 | 
			
		||||
      ++y_mod_count;
 | 
			
		||||
      x_mod_count = 0;
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void Courtroom::set_emote_page()
 | 
			
		||||
{
 | 
			
		||||
  ui_emote_left->hide();
 | 
			
		||||
  ui_emote_right->hide();
 | 
			
		||||
 | 
			
		||||
  for (AOEmoteButton *i_button : ui_emote_list)
 | 
			
		||||
  {
 | 
			
		||||
    i_button->hide();
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@ -283,3 +283,36 @@ int AOApplication::get_text_delay(QString p_char, QString p_emote)
 | 
			
		||||
  return -1;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
QString AOApplication::get_char_name(QString p_name)
 | 
			
		||||
{
 | 
			
		||||
  QString char_ini_path = get_character_path(p_name) + "char.ini";
 | 
			
		||||
 | 
			
		||||
  QFile char_ini;
 | 
			
		||||
 | 
			
		||||
  char_ini.setFileName(char_ini_path);
 | 
			
		||||
 | 
			
		||||
  if (!char_ini.open(QIODevice::ReadOnly))
 | 
			
		||||
  {
 | 
			
		||||
    return "";
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  QTextStream in(&char_ini);
 | 
			
		||||
 | 
			
		||||
  while(!in.atEnd())
 | 
			
		||||
  {
 | 
			
		||||
    QString line = in.readLine();
 | 
			
		||||
 | 
			
		||||
    if (!line.startsWith("name"))
 | 
			
		||||
      continue;
 | 
			
		||||
 | 
			
		||||
    QStringList line_elements = line.split("=");
 | 
			
		||||
 | 
			
		||||
    if (line_elements.size() < 2)
 | 
			
		||||
      continue;
 | 
			
		||||
 | 
			
		||||
    return line_elements.at(1).trimmed();
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  return "";
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user