aboutsummaryrefslogtreecommitdiff
path: root/emotes.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'emotes.cpp')
-rw-r--r--emotes.cpp81
1 files changed, 79 insertions, 2 deletions
diff --git a/emotes.cpp b/emotes.cpp
index 71f9cb4..a77a300 100644
--- a/emotes.cpp
+++ b/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();
}