aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Skoland <davidskoland@gmail.com>2017-02-06 14:06:58 +0100
committerDavid Skoland <davidskoland@gmail.com>2017-02-06 14:06:58 +0100
commitea09ad9dfc8accf30934b573dba486eb1e932160 (patch)
tree1a7dc9abb820bc7e32b433dd02157705a3a986b4
parent0997bdc26f90d8dfa8d8a37dca155be09e43cb46 (diff)
started implementing emotes
-rw-r--r--Attorney_Online_remake.pro7
-rw-r--r--aoapplication.cpp8
-rw-r--r--aoapplication.h4
-rw-r--r--aoemotebutton.cpp10
-rw-r--r--aoemotebutton.h20
-rw-r--r--courtroom.cpp20
-rw-r--r--courtroom.h25
-rw-r--r--emotes.cpp45
-rw-r--r--text_file_functions.cpp33
9 files changed, 155 insertions, 17 deletions
diff --git a/Attorney_Online_remake.pro b/Attorney_Online_remake.pro
index 71369390..97c241f0 100644
--- a/Attorney_Online_remake.pro
+++ b/Attorney_Online_remake.pro
@@ -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
diff --git a/aoapplication.cpp b/aoapplication.cpp
index f0576eea..876d9340 100644
--- a/aoapplication.cpp
+++ b/aoapplication.cpp
@@ -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())
diff --git a/aoapplication.h b/aoapplication.h
index 6c503e66..aeb95940 100644
--- a/aoapplication.h
+++ b/aoapplication.h
@@ -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;
diff --git a/aoemotebutton.cpp b/aoemotebutton.cpp
new file mode 100644
index 00000000..6cb99c77
--- /dev/null
+++ b/aoemotebutton.cpp
@@ -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);
+}
diff --git a/aoemotebutton.h b/aoemotebutton.h
new file mode 100644
index 00000000..654972da
--- /dev/null
+++ b/aoemotebutton.h
@@ -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
diff --git a/courtroom.cpp b/courtroom.cpp
index 3f68416a..b706c47d 100644
--- a/courtroom.cpp
+++ b/courtroom.cpp
@@ -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_emotes = new QWidget(this);
+
+ //implementation in emotes.cpp
+ construct_emotes();
- ui_emote_left = new AOButton(this, ao_app);
- ui_emote_right = new AOButton(this, ao_app);
+ 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;
+
+ current_emote_page = 0;
- //T0D0: set emote buttons
+ set_emote_page();
QString side = ao_app->get_char_side(f_char);
diff --git a/courtroom.h b/courtroom.h
index 2fc7da2f..09200f39 100644
--- a/courtroom.h
+++ b/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();
diff --git a/emotes.cpp b/emotes.cpp
new file mode 100644
index 00000000..71f9cb40
--- /dev/null
+++ b/emotes.cpp
@@ -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();
+ }
+
+}
diff --git a/text_file_functions.cpp b/text_file_functions.cpp
index bde24fbb..27c8dc6d 100644
--- a/text_file_functions.cpp
+++ b/text_file_functions.cpp
@@ -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 "";
+}
+