Fixed a bug where the character taken symbol wouldn't show.

This commit is contained in:
Cerapter 2018-08-16 22:23:16 +02:00
parent 572888a9dd
commit c8b62267b9
3 changed files with 17 additions and 10 deletions

View File

@ -4,12 +4,14 @@
#include <QFile> #include <QFile>
AOCharButton::AOCharButton(QWidget *parent, AOApplication *p_ao_app, int x_pos, int y_pos) : QPushButton(parent) AOCharButton::AOCharButton(QWidget *parent, AOApplication *p_ao_app, int x_pos, int y_pos, bool is_taken) : QPushButton(parent)
{ {
m_parent = parent; m_parent = parent;
ao_app = p_ao_app; ao_app = p_ao_app;
taken = is_taken;
this->resize(60, 60); this->resize(60, 60);
this->move(x_pos, y_pos); this->move(x_pos, y_pos);
@ -42,8 +44,12 @@ void AOCharButton::reset()
void AOCharButton::set_taken() void AOCharButton::set_taken()
{ {
if (taken)
{
ui_taken->move(0,0);
ui_taken->show(); ui_taken->show();
} }
}
void AOCharButton::set_passworded() void AOCharButton::set_passworded()
{ {

View File

@ -13,10 +13,11 @@ class AOCharButton : public QPushButton
Q_OBJECT Q_OBJECT
public: public:
AOCharButton(QWidget *parent, AOApplication *p_ao_app, int x_pos, int y_pos); AOCharButton(QWidget *parent, AOApplication *p_ao_app, int x_pos, int y_pos, bool is_taken);
AOApplication *ao_app; AOApplication *ao_app;
void refresh();
void reset(); void reset();
void set_taken(); void set_taken();
void set_passworded(); void set_passworded();
@ -24,6 +25,8 @@ public:
void set_image(QString p_character); void set_image(QString p_character);
private: private:
bool taken;
QWidget *m_parent; QWidget *m_parent;
AOImage *ui_taken; AOImage *ui_taken;

View File

@ -85,6 +85,7 @@ void Courtroom::set_char_select_page()
for (AOCharButton *i_button : ui_char_button_list) for (AOCharButton *i_button : ui_char_button_list)
{ {
i_button->reset();
i_button->hide(); i_button->hide();
i_button->move(0,0); i_button->move(0,0);
} }
@ -163,6 +164,8 @@ 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)->move(x_pos, y_pos);
ui_char_button_list_filtered.at(n)->show(); ui_char_button_list_filtered.at(n)->show();
ui_char_button_list_filtered.at(n)->set_taken();
++x_mod_count; ++x_mod_count;
if (x_mod_count == char_columns) if (x_mod_count == char_columns)
@ -189,7 +192,8 @@ void Courtroom::character_loading_finished()
// Later on, we'll be revealing buttons as we need them. // Later on, we'll be revealing buttons as we need them.
for (int n = 0; n < char_list.size(); n++) for (int n = 0; n < char_list.size(); n++)
{ {
AOCharButton* character = new AOCharButton(ui_char_buttons, ao_app, 0, 0); AOCharButton* character = new AOCharButton(ui_char_buttons, ao_app, 0, 0, char_list.at(n).taken);
character->reset();
character->hide(); character->hide();
character->set_image(char_list.at(n).name); character->set_image(char_list.at(n).name);
ui_char_button_list.append(character); ui_char_button_list.append(character);
@ -207,12 +211,6 @@ void Courtroom::character_loading_finished()
} }
filter_character_list(); filter_character_list();
int chars_on_page = max_chars_on_page;
if (ui_char_button_list_filtered.size() < max_chars_on_page)
chars_on_page = ui_char_button_list_filtered.size();
put_button_in_place(0, chars_on_page);
} }
void Courtroom::filter_character_list() void Courtroom::filter_character_list()