From f217c68f85156e5ea816c10a7c4723a6c55c0b77 Mon Sep 17 00:00:00 2001 From: Cerapter Date: Wed, 12 Dec 2018 19:22:34 +0100 Subject: [PATCH] The charselect's "shadows" correctly update based on what chars are taken. This was purely a graphical bug. The characters were correctly recognised as taken by the client, but there was no way to update the "taken-shadow" over their icons. Which meant that they were locked into the way they were when the user first joined the server. As a result of this, a `CharsCheck` package from the server will correctly display the taken characters to the client in the character selection. --- aocharbutton.cpp | 11 ++++++++++- aocharbutton.h | 4 +++- charselect.cpp | 9 +++++++-- 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/aocharbutton.cpp b/aocharbutton.cpp index 23fd0c6..7661027 100644 --- a/aocharbutton.cpp +++ b/aocharbutton.cpp @@ -40,13 +40,22 @@ void AOCharButton::reset() ui_selector->hide(); } -void AOCharButton::set_taken() +void AOCharButton::set_taken(bool is_taken) +{ + taken = is_taken; +} + +void AOCharButton::apply_taken_image() { if (taken) { ui_taken->move(0,0); ui_taken->show(); } + else + { + ui_taken->hide(); + } } void AOCharButton::set_passworded() diff --git a/aocharbutton.h b/aocharbutton.h index 6e5e50e..f372cdf 100644 --- a/aocharbutton.h +++ b/aocharbutton.h @@ -20,9 +20,11 @@ public: void refresh(); void reset(); - void set_taken(); + void set_taken(bool is_taken); void set_passworded(); + void apply_taken_image(); + void set_image(QString p_character); private: diff --git a/charselect.cpp b/charselect.cpp index 01b6ae7..8e1b912 100644 --- a/charselect.cpp +++ b/charselect.cpp @@ -168,8 +168,7 @@ void Courtroom::put_button_in_place(int starting, int chars_on_this_page) ui_char_button_list_filtered.at(n)->move(x_pos, y_pos); ui_char_button_list_filtered.at(n)->show(); - - ui_char_button_list_filtered.at(n)->set_taken(); + ui_char_button_list_filtered.at(n)->apply_taken_image(); ++x_mod_count; @@ -240,6 +239,12 @@ void Courtroom::filter_character_list() if (!char_list.at(i).name.contains(ui_char_search->text(), Qt::CaseInsensitive)) continue; + // We only really need to update the fact that a character is taken + // for the buttons that actually appear. + // You'd also update the passwordedness and etc. here later. + current_char->reset(); + current_char->set_taken(char_list.at(i).taken); + ui_char_button_list_filtered.append(current_char); }