diff options
Diffstat (limited to 'src/emotes.cpp')
| -rw-r--r-- | src/emotes.cpp | 63 |
1 files changed, 49 insertions, 14 deletions
diff --git a/src/emotes.cpp b/src/emotes.cpp index bbe2f5c9..8de55244 100644 --- a/src/emotes.cpp +++ b/src/emotes.cpp @@ -2,20 +2,48 @@ #include "aoemotebutton.h" -void Courtroom::construct_emotes() +void Courtroom::initialize_emotes() { ui_emotes = new QWidget(this); + ui_emote_left = new AOButton(this, ao_app); + ui_emote_right = new AOButton(this, ao_app); + + ui_emote_dropdown = new QComboBox(this); + + 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_emote_dropdown, SIGNAL(activated(int)), this, + SLOT(on_emote_dropdown_changed(int))); +} + +void Courtroom::refresh_emotes() +{ + // Should properly refresh the emote list + qDeleteAll(ui_emote_list.begin(), ui_emote_list.end()); + ui_emote_list.clear(); + set_size_and_pos(ui_emotes, "emotes"); + set_size_and_pos(ui_emote_left, "emote_left"); + ui_emote_left->set_image("arrow_left"); + + set_size_and_pos(ui_emote_right, "emote_right"); + ui_emote_right->set_image("arrow_right"); + QPoint f_spacing = ao_app->get_button_spacing("emote_button_spacing", "courtroom_design.ini"); + QPoint p_point = + ao_app->get_button_spacing("emote_button_size", "courtroom_design.ini"); - const int button_width = 40; + const int button_width = p_point.x(); int x_spacing = f_spacing.x(); int x_mod_count = 0; - const int button_height = 40; + const int button_height = p_point.y(); int y_spacing = f_spacing.y(); int y_mod_count = 0; @@ -30,7 +58,8 @@ void Courtroom::construct_emotes() int x_pos = (button_width + x_spacing) * x_mod_count; int y_pos = (button_height + y_spacing) * y_mod_count; - AOEmoteButton *f_emote = new AOEmoteButton(ui_emotes, ao_app, x_pos, y_pos); + AOEmoteButton *f_emote = new AOEmoteButton(ui_emotes, ao_app, x_pos, y_pos, + button_width, button_height); ui_emote_list.append(f_emote); @@ -82,16 +111,19 @@ void Courtroom::set_emote_page() if (current_emote_page > 0) ui_emote_left->show(); - for (int n_emote = 0; n_emote < emotes_on_page; ++n_emote) { + for (int n_emote = 0; + n_emote < emotes_on_page && n_emote < ui_emote_list.size(); ++n_emote) { int n_real_emote = n_emote + current_emote_page * max_emotes_on_page; AOEmoteButton *f_emote = ui_emote_list.at(n_emote); if (n_real_emote == current_emote) - f_emote->set_image(current_char, n_real_emote, "_on.png"); + f_emote->set_char_image(current_char, n_real_emote, "_on"); else - f_emote->set_image(current_char, n_real_emote, "_off.png"); + f_emote->set_char_image(current_char, n_real_emote, "_off"); f_emote->show(); + f_emote->setToolTip(QString::number(n_real_emote + 1) + ": " + + ao_app->get_emote_comment(current_char, n_real_emote)); } } @@ -103,7 +135,8 @@ void Courtroom::set_emote_dropdown() QStringList emote_list; for (int n = 0; n < total_emotes; ++n) { - emote_list.append(ao_app->get_emote_comment(current_char, n)); + emote_list.append(QString::number(n + 1) + ": " + + ao_app->get_emote_comment(current_char, n)); } ui_emote_dropdown->addItems(emote_list); @@ -116,7 +149,7 @@ void Courtroom::select_emote(int p_id) if (current_emote >= min && current_emote <= max) ui_emote_list.at(current_emote % max_emotes_on_page) - ->set_image(current_char, current_emote, "_off.png"); + ->set_char_image(current_char, current_emote, "_off"); int old_emote = current_emote; @@ -124,17 +157,19 @@ void Courtroom::select_emote(int p_id) if (current_emote >= min && current_emote <= max) ui_emote_list.at(current_emote % max_emotes_on_page) - ->set_image(current_char, current_emote, "_on.png"); + ->set_char_image(current_char, current_emote, "_on"); int emote_mod = ao_app->get_emote_mod(current_char, current_emote); if (old_emote == current_emote) { ui_pre->setChecked(!ui_pre->isChecked()); } - else if (emote_mod == 1) - ui_pre->setChecked(true); - else - ui_pre->setChecked(false); + else if (!ao_app->is_stickypres_enabled()) { + if (emote_mod == 1 || emote_mod == 4) + ui_pre->setChecked(true); + else + ui_pre->setChecked(false); + } ui_emote_dropdown->setCurrentIndex(current_emote); |
