From b085be5a2a0512c432bc9fd58413a9d8f93d451e Mon Sep 17 00:00:00 2001 From: Crystalwarrior Date: Mon, 16 Sep 2019 21:08:43 +0300 Subject: Add two new helper functions - get_design_element and get_static_image_suffix Modify all set_image calls to utilize said suffix helper function Dynamically change betweehn chatblank, chat, chatmed, chatbig based on the showname's length Use char.ini showname if showname is set to whitespace (doesn't yet check if char.ini showname is also whitespace) --- src/charselect.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/charselect.cpp') diff --git a/src/charselect.cpp b/src/charselect.cpp index 0cfb775..23b0513 100644 --- a/src/charselect.cpp +++ b/src/charselect.cpp @@ -71,7 +71,7 @@ void Courtroom::set_char_select() this->resize(f_charselect.width, f_charselect.height); ui_char_select_background->resize(f_charselect.width, f_charselect.height); - ui_char_select_background->set_image("charselect_background.png"); + ui_char_select_background->set_image("charselect_background"); filter_character_list(); -- cgit From 9d20cf03222add2ef04d4d2cc305458bdf00fcad Mon Sep 17 00:00:00 2001 From: Crystalwarrior Date: Tue, 17 Sep 2019 18:51:40 +0300 Subject: Streamlined ini swapping so the user can set up multiple character folders associated with a character. This will save to the character folder's iniswaps.ini. You can click on the dropdown and edit the text inside to add an iniswap, and press the [X] button that'll appear next to it to remove the ini swap. Recode the enter_courtroom and add a new update_character feature - the two are now separate and responsible for different things. The courtroom will reload the whole theme and widgets while the character is only responsible for all ui elements related to the character. This drastically improves performance when switching characters using /switch or something Add a set_char_ini helper function that allows you to modify the character variables. For now only used to set name= field when iniswapping --- src/charselect.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'src/charselect.cpp') diff --git a/src/charselect.cpp b/src/charselect.cpp index 23b0513..972a17a 100644 --- a/src/charselect.cpp +++ b/src/charselect.cpp @@ -64,7 +64,7 @@ void Courtroom::set_char_select() if (f_charselect.width < 0 || f_charselect.height < 0) { - qDebug() << "W: did not find courtroom width or height in courtroom_design.ini!"; + qDebug() << "W: did not find char_select width or height in courtroom_design.ini!"; this->resize(714, 668); } else @@ -129,15 +129,13 @@ void Courtroom::char_clicked(int n_char) return; } - if (n_char == m_cid) - { - enter_courtroom(m_cid); - } - else + if (n_char != m_cid) { ao_app->send_server_packet(new AOPacket("PW#" + ui_char_password->text() + "#%")); ao_app->send_server_packet(new AOPacket("CC#" + QString::number(ao_app->s_pv) + "#" + QString::number(n_char) + "#" + get_hdid() + "#%")); } + update_character(n_char); + enter_courtroom(); ui_ic_chat_name->setPlaceholderText(char_list.at(n_char).name); } -- cgit From 4f738bfe34695db745d251e9461823b8835de201 Mon Sep 17 00:00:00 2001 From: Crystalwarrior Date: Tue, 1 Oct 2019 01:07:03 +0300 Subject: Fix some read_file errors on effect loading Make FM packet only fetch music, and new FA packet to fetch areas (this way you don't have to reload the entire music list just to get new areas) Fix a possible segfault with emote lists if emote list size is bad Hide casing button if server doesn't support casing Hide the remove buttons by default for iniswaps and sfx list so they're not clickable when they shouldn't be Prevent background from being displayed unless the server asked us to Fix some redundancy surrounding current_side Rework music list so list_music doesn't care about search bar and the hiding is actually done in the search function Implement text centering, rightening and justifying Fix text scrolling meme that happened with \n and skipped chars Fix the pos dropdown not actually caring if you selected jur and sea pos. Fix the pos dropdown sending like a million packets when scrolled through. Prevent characters from being incorrectly resized if a different-scaled character speaks Fix character select screen letting you choose characters that the server doesn't want us to be --- src/charselect.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/charselect.cpp') diff --git a/src/charselect.cpp b/src/charselect.cpp index 972a17a..6739a1e 100644 --- a/src/charselect.cpp +++ b/src/charselect.cpp @@ -134,7 +134,9 @@ void Courtroom::char_clicked(int n_char) ao_app->send_server_packet(new AOPacket("PW#" + ui_char_password->text() + "#%")); ao_app->send_server_packet(new AOPacket("CC#" + QString::number(ao_app->s_pv) + "#" + QString::number(n_char) + "#" + get_hdid() + "#%")); } - update_character(n_char); + else + update_character(n_char); + enter_courtroom(); ui_ic_chat_name->setPlaceholderText(char_list.at(n_char).name); -- cgit From c8e12558cdd3fd0769b81679ad09edf1f29b780f Mon Sep 17 00:00:00 2001 From: Crystalwarrior Date: Fri, 22 May 2020 01:18:24 +0300 Subject: Clang-ify the code with this styling using Visual Studio Code: { BasedOnStyle: LLVM, UseTab: Never, IndentWidth: 4, TabWidth: 4, BreakBeforeBraces: Stroustrup, AllowShortIfStatementsOnASingleLine: false, IndentCaseLabels: false, ColumnLimit: 0, AccessModifierOffset: -4, NamespaceIndentation: All } (this is the Visual Studio preset with only "BreakBeforeBraces" changed from Allman to Stroustrup) --- src/charselect.cpp | 282 +++++++++++++++++++++++++---------------------------- 1 file changed, 135 insertions(+), 147 deletions(-) (limited to 'src/charselect.cpp') diff --git a/src/charselect.cpp b/src/charselect.cpp index 6739a1e..6575869 100644 --- a/src/charselect.cpp +++ b/src/charselect.cpp @@ -1,145 +1,139 @@ #include "courtroom.h" #include "lobby.h" -#include "file_functions.h" #include "debug_functions.h" +#include "file_functions.h" #include "hardware_functions.h" void Courtroom::construct_char_select() { - ui_char_select_background = new AOImage(this, ao_app); + ui_char_select_background = new AOImage(this, ao_app); - ui_char_buttons = new QWidget(ui_char_select_background); + ui_char_buttons = new QWidget(ui_char_select_background); - ui_selector = new AOImage(ui_char_select_background, ao_app); - ui_selector->setAttribute(Qt::WA_TransparentForMouseEvents); - ui_selector->resize(62, 62); + ui_selector = new AOImage(ui_char_select_background, ao_app); + ui_selector->setAttribute(Qt::WA_TransparentForMouseEvents); + ui_selector->resize(62, 62); - ui_back_to_lobby = new AOButton(ui_char_select_background, ao_app); + ui_back_to_lobby = new AOButton(ui_char_select_background, ao_app); - ui_char_password = new QLineEdit(ui_char_select_background); - ui_char_password->setPlaceholderText(tr("Password")); + ui_char_password = new QLineEdit(ui_char_select_background); + ui_char_password->setPlaceholderText(tr("Password")); - ui_char_select_left = new AOButton(ui_char_select_background, ao_app); - ui_char_select_right = new AOButton(ui_char_select_background, ao_app); + ui_char_select_left = new AOButton(ui_char_select_background, ao_app); + ui_char_select_right = new AOButton(ui_char_select_background, ao_app); - ui_spectator = new AOButton(ui_char_select_background, ao_app); - ui_spectator->setText(tr("Spectator")); + ui_spectator = new AOButton(ui_char_select_background, ao_app); + ui_spectator->setText(tr("Spectator")); - ui_char_search = new QLineEdit(ui_char_select_background); - ui_char_search->setPlaceholderText(tr("Search")); - ui_char_search->setFocus(); - set_size_and_pos(ui_char_search, "char_search"); + ui_char_search = new QLineEdit(ui_char_select_background); + ui_char_search->setPlaceholderText(tr("Search")); + ui_char_search->setFocus(); + set_size_and_pos(ui_char_search, "char_search"); - ui_char_passworded = new QCheckBox(ui_char_select_background); - ui_char_passworded->setText(tr("Passworded")); - set_size_and_pos(ui_char_passworded, "char_passworded"); + ui_char_passworded = new QCheckBox(ui_char_select_background); + ui_char_passworded->setText(tr("Passworded")); + set_size_and_pos(ui_char_passworded, "char_passworded"); - ui_char_taken = new QCheckBox(ui_char_select_background); - ui_char_taken->setText(tr("Taken")); - set_size_and_pos(ui_char_taken, "char_taken"); + ui_char_taken = new QCheckBox(ui_char_select_background); + ui_char_taken->setText(tr("Taken")); + set_size_and_pos(ui_char_taken, "char_taken"); - ui_char_taken->setChecked(true); - ui_char_passworded->setChecked(true); + ui_char_taken->setChecked(true); + ui_char_passworded->setChecked(true); - set_size_and_pos(ui_char_buttons, "char_buttons"); + set_size_and_pos(ui_char_buttons, "char_buttons"); - connect(ui_back_to_lobby, SIGNAL(clicked()), this, SLOT(on_back_to_lobby_clicked())); + connect(ui_back_to_lobby, SIGNAL(clicked()), this, SLOT(on_back_to_lobby_clicked())); - connect(ui_char_select_left, SIGNAL(clicked()), this, SLOT(on_char_select_left_clicked())); - connect(ui_char_select_right, SIGNAL(clicked()), this, SLOT(on_char_select_right_clicked())); + connect(ui_char_select_left, SIGNAL(clicked()), this, SLOT(on_char_select_left_clicked())); + connect(ui_char_select_right, SIGNAL(clicked()), this, SLOT(on_char_select_right_clicked())); - connect(ui_spectator, SIGNAL(clicked()), this, SLOT(on_spectator_clicked())); + connect(ui_spectator, SIGNAL(clicked()), this, SLOT(on_spectator_clicked())); - connect(ui_char_search, SIGNAL(textEdited(const QString&)), this, SLOT(on_char_search_changed())); - connect(ui_char_passworded, SIGNAL(stateChanged(int)), this, SLOT(on_char_passworded_clicked())); - connect(ui_char_taken, SIGNAL(stateChanged(int)), this, SLOT(on_char_taken_clicked())); + connect(ui_char_search, SIGNAL(textEdited(const QString &)), this, SLOT(on_char_search_changed())); + connect(ui_char_passworded, SIGNAL(stateChanged(int)), this, SLOT(on_char_passworded_clicked())); + connect(ui_char_taken, SIGNAL(stateChanged(int)), this, SLOT(on_char_taken_clicked())); } void Courtroom::set_char_select() { - QString filename = "courtroom_design.ini"; + QString filename = "courtroom_design.ini"; - pos_size_type f_charselect = ao_app->get_element_dimensions("char_select", filename); + pos_size_type f_charselect = ao_app->get_element_dimensions("char_select", filename); - if (f_charselect.width < 0 || f_charselect.height < 0) - { - qDebug() << "W: did not find char_select width or height in courtroom_design.ini!"; - this->resize(714, 668); - } - else - this->resize(f_charselect.width, f_charselect.height); + if (f_charselect.width < 0 || f_charselect.height < 0) { + qDebug() << "W: did not find char_select width or height in courtroom_design.ini!"; + this->resize(714, 668); + } + else + this->resize(f_charselect.width, f_charselect.height); - ui_char_select_background->resize(f_charselect.width, f_charselect.height); - ui_char_select_background->set_image("charselect_background"); + ui_char_select_background->resize(f_charselect.width, f_charselect.height); + ui_char_select_background->set_image("charselect_background"); - filter_character_list(); + filter_character_list(); - ui_char_search->setFocus(); + ui_char_search->setFocus(); } void Courtroom::set_char_select_page() { - ui_char_select_background->show(); + ui_char_select_background->show(); - ui_char_select_left->hide(); - ui_char_select_right->hide(); + ui_char_select_left->hide(); + ui_char_select_right->hide(); - for (AOCharButton *i_button : ui_char_button_list) - { - i_button->reset(); - i_button->hide(); - i_button->move(0,0); - } + for (AOCharButton *i_button : ui_char_button_list) { + i_button->reset(); + i_button->hide(); + i_button->move(0, 0); + } - int total_pages = ui_char_button_list_filtered.size() / max_chars_on_page; - int chars_on_page = 0; + int total_pages = ui_char_button_list_filtered.size() / max_chars_on_page; + int chars_on_page = 0; - if (ui_char_button_list_filtered.size() % max_chars_on_page != 0) - { - ++total_pages; - //i. e. not on the last page - if (total_pages > current_char_page + 1) - chars_on_page = max_chars_on_page; + if (ui_char_button_list_filtered.size() % max_chars_on_page != 0) { + ++total_pages; + //i. e. not on the last page + if (total_pages > current_char_page + 1) + chars_on_page = max_chars_on_page; + else + chars_on_page = ui_char_button_list_filtered.size() % max_chars_on_page; + } else - chars_on_page = ui_char_button_list_filtered.size() % max_chars_on_page; + chars_on_page = max_chars_on_page; - } - else - chars_on_page = max_chars_on_page; - - if (total_pages > current_char_page + 1) - ui_char_select_right->show(); + if (total_pages > current_char_page + 1) + ui_char_select_right->show(); - if (current_char_page > 0) - ui_char_select_left->show(); + if (current_char_page > 0) + ui_char_select_left->show(); - put_button_in_place(current_char_page * max_chars_on_page, chars_on_page); + put_button_in_place(current_char_page * max_chars_on_page, chars_on_page); } void Courtroom::char_clicked(int n_char) { - QString char_ini_path = ao_app->get_character_path(char_list.at(n_char).name, "char.ini"); + QString char_ini_path = ao_app->get_character_path(char_list.at(n_char).name, "char.ini"); - qDebug() << "char_ini_path" << char_ini_path; + qDebug() << "char_ini_path" << char_ini_path; - if (!file_exists(char_ini_path)) - { - call_notice("Could not find " + char_ini_path); - return; - } + if (!file_exists(char_ini_path)) { + call_notice("Could not find " + char_ini_path); + return; + } - if (n_char != m_cid) - { - ao_app->send_server_packet(new AOPacket("PW#" + ui_char_password->text() + "#%")); - ao_app->send_server_packet(new AOPacket("CC#" + QString::number(ao_app->s_pv) + "#" + QString::number(n_char) + "#" + get_hdid() + "#%")); - } - else - update_character(n_char); + if (n_char != m_cid) { + ao_app->send_server_packet(new AOPacket("PW#" + ui_char_password->text() + "#%")); + ao_app->send_server_packet(new AOPacket("CC#" + QString::number(ao_app->s_pv) + "#" + QString::number(n_char) + "#" + get_hdid() + "#%")); + } + else + update_character(n_char); - enter_courtroom(); + enter_courtroom(); - ui_ic_chat_name->setPlaceholderText(char_list.at(n_char).name); + ui_ic_chat_name->setPlaceholderText(char_list.at(n_char).name); } void Courtroom::put_button_in_place(int starting, int chars_on_this_page) @@ -161,22 +155,20 @@ void Courtroom::put_button_in_place(int starting, int chars_on_this_page) max_chars_on_page = char_columns * char_rows; int startout = starting; - for (int n = starting ; n < startout+chars_on_this_page ; ++n) - { - int x_pos = (button_width + x_spacing) * x_mod_count; - int y_pos = (button_height + y_spacing) * y_mod_count; - - 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)->apply_taken_image(); - - ++x_mod_count; - - if (x_mod_count == char_columns) - { - ++y_mod_count; - x_mod_count = 0; - } + for (int n = starting; n < startout + chars_on_this_page; ++n) { + int x_pos = (button_width + x_spacing) * x_mod_count; + int y_pos = (button_height + y_spacing) * y_mod_count; + + 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)->apply_taken_image(); + + ++x_mod_count; + + if (x_mod_count == char_columns) { + ++y_mod_count; + x_mod_count = 0; + } } } @@ -184,9 +176,8 @@ void Courtroom::character_loading_finished() { // Zeroeth, we'll clear any leftover characters from previous server visits. ao_app->generated_chars = 0; - if (ui_char_button_list.size() > 0) - { - foreach (AOCharButton* item, ui_char_button_list) { + if (ui_char_button_list.size() > 0) { + foreach (AOCharButton *item, ui_char_button_list) { delete item; } ui_char_button_list.clear(); @@ -195,28 +186,26 @@ void Courtroom::character_loading_finished() // First, we'll make all the character buttons in the very beginning. // We also hide them all, so they can't be accidentally clicked. // Later on, we'll be revealing buttons as we need them. - for (int n = 0; n < char_list.size(); n++) - { - AOCharButton* char_button = new AOCharButton(ui_char_buttons, ao_app, 0, 0, char_list.at(n).taken); - char_button->reset(); - char_button->hide(); - char_button->set_image(char_list.at(n).name); - ui_char_button_list.append(char_button); - - connect(char_button, &AOCharButton::clicked, [this, n](){ - this->char_clicked(n); - }); - - // This part here serves as a way of showing to the player that the game is still running, it is - // just loading the pictures of the characters. - if (ao_app->lobby_constructed) - { - ao_app->generated_chars++; - int total_loading_size = ao_app->char_list_size * 2 + ao_app->evidence_list_size + ao_app->music_list_size; - int loading_value = int(((ao_app->loaded_chars + ao_app->generated_chars + ao_app->loaded_music + ao_app->loaded_evidence) / static_cast(total_loading_size)) * 100); - ao_app->w_lobby->set_loading_value(loading_value); - ao_app->w_lobby->set_loading_text(tr("Generating chars:\n%1/%2").arg(QString::number(ao_app->generated_chars)).arg(QString::number(ao_app->char_list_size))); - } + for (int n = 0; n < char_list.size(); n++) { + AOCharButton *char_button = new AOCharButton(ui_char_buttons, ao_app, 0, 0, char_list.at(n).taken); + char_button->reset(); + char_button->hide(); + char_button->set_image(char_list.at(n).name); + ui_char_button_list.append(char_button); + + connect(char_button, &AOCharButton::clicked, [this, n]() { + this->char_clicked(n); + }); + + // This part here serves as a way of showing to the player that the game is still running, it is + // just loading the pictures of the characters. + if (ao_app->lobby_constructed) { + ao_app->generated_chars++; + int total_loading_size = ao_app->char_list_size * 2 + ao_app->evidence_list_size + ao_app->music_list_size; + int loading_value = int(((ao_app->loaded_chars + ao_app->generated_chars + ao_app->loaded_music + ao_app->loaded_evidence) / static_cast(total_loading_size)) * 100); + ao_app->w_lobby->set_loading_value(loading_value); + ao_app->w_lobby->set_loading_text(tr("Generating chars:\n%1/%2").arg(QString::number(ao_app->generated_chars)).arg(QString::number(ao_app->char_list_size))); + } } filter_character_list(); @@ -225,28 +214,27 @@ void Courtroom::character_loading_finished() void Courtroom::filter_character_list() { ui_char_button_list_filtered.clear(); - for (int i = 0; i < char_list.size(); i++) - { - AOCharButton* current_char = ui_char_button_list.at(i); + for (int i = 0; i < char_list.size(); i++) { + AOCharButton *current_char = ui_char_button_list.at(i); - // It seems passwording characters is unimplemented yet? - // Until then, this will stay here, I suppose. - //if (ui_char_passworded->isChecked() && character_is_passworded??) - // continue; + // It seems passwording characters is unimplemented yet? + // Until then, this will stay here, I suppose. + //if (ui_char_passworded->isChecked() && character_is_passworded??) + // continue; - if (!ui_char_taken->isChecked() && char_list.at(i).taken) - continue; + if (!ui_char_taken->isChecked() && char_list.at(i).taken) + continue; - if (!char_list.at(i).name.contains(ui_char_search->text(), Qt::CaseInsensitive)) - continue; + 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); + // 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); + ui_char_button_list_filtered.append(current_char); } current_char_page = 0; -- cgit From 88de4cde0433ef5e606f38a2f1e6041f0d24a87e Mon Sep 17 00:00:00 2001 From: Crystalwarrior Date: Fri, 22 May 2020 02:14:54 +0300 Subject: clang 2 electric boogaloo { BasedOnStyle: LLVM, BreakBeforeBraces: Stroustrup} --- src/charselect.cpp | 354 ++++++++++++++++++++++++++++------------------------- 1 file changed, 186 insertions(+), 168 deletions(-) (limited to 'src/charselect.cpp') diff --git a/src/charselect.cpp b/src/charselect.cpp index 6575869..de9748b 100644 --- a/src/charselect.cpp +++ b/src/charselect.cpp @@ -7,251 +7,269 @@ void Courtroom::construct_char_select() { - ui_char_select_background = new AOImage(this, ao_app); + ui_char_select_background = new AOImage(this, ao_app); - ui_char_buttons = new QWidget(ui_char_select_background); + ui_char_buttons = new QWidget(ui_char_select_background); - ui_selector = new AOImage(ui_char_select_background, ao_app); - ui_selector->setAttribute(Qt::WA_TransparentForMouseEvents); - ui_selector->resize(62, 62); + ui_selector = new AOImage(ui_char_select_background, ao_app); + ui_selector->setAttribute(Qt::WA_TransparentForMouseEvents); + ui_selector->resize(62, 62); - ui_back_to_lobby = new AOButton(ui_char_select_background, ao_app); + ui_back_to_lobby = new AOButton(ui_char_select_background, ao_app); - ui_char_password = new QLineEdit(ui_char_select_background); - ui_char_password->setPlaceholderText(tr("Password")); + ui_char_password = new QLineEdit(ui_char_select_background); + ui_char_password->setPlaceholderText(tr("Password")); - ui_char_select_left = new AOButton(ui_char_select_background, ao_app); - ui_char_select_right = new AOButton(ui_char_select_background, ao_app); + ui_char_select_left = new AOButton(ui_char_select_background, ao_app); + ui_char_select_right = new AOButton(ui_char_select_background, ao_app); - ui_spectator = new AOButton(ui_char_select_background, ao_app); - ui_spectator->setText(tr("Spectator")); + ui_spectator = new AOButton(ui_char_select_background, ao_app); + ui_spectator->setText(tr("Spectator")); - ui_char_search = new QLineEdit(ui_char_select_background); - ui_char_search->setPlaceholderText(tr("Search")); - ui_char_search->setFocus(); - set_size_and_pos(ui_char_search, "char_search"); + ui_char_search = new QLineEdit(ui_char_select_background); + ui_char_search->setPlaceholderText(tr("Search")); + ui_char_search->setFocus(); + set_size_and_pos(ui_char_search, "char_search"); - ui_char_passworded = new QCheckBox(ui_char_select_background); - ui_char_passworded->setText(tr("Passworded")); - set_size_and_pos(ui_char_passworded, "char_passworded"); + ui_char_passworded = new QCheckBox(ui_char_select_background); + ui_char_passworded->setText(tr("Passworded")); + set_size_and_pos(ui_char_passworded, "char_passworded"); - ui_char_taken = new QCheckBox(ui_char_select_background); - ui_char_taken->setText(tr("Taken")); - set_size_and_pos(ui_char_taken, "char_taken"); + ui_char_taken = new QCheckBox(ui_char_select_background); + ui_char_taken->setText(tr("Taken")); + set_size_and_pos(ui_char_taken, "char_taken"); - ui_char_taken->setChecked(true); - ui_char_passworded->setChecked(true); + ui_char_taken->setChecked(true); + ui_char_passworded->setChecked(true); - set_size_and_pos(ui_char_buttons, "char_buttons"); + set_size_and_pos(ui_char_buttons, "char_buttons"); - connect(ui_back_to_lobby, SIGNAL(clicked()), this, SLOT(on_back_to_lobby_clicked())); + connect(ui_back_to_lobby, SIGNAL(clicked()), this, + SLOT(on_back_to_lobby_clicked())); - connect(ui_char_select_left, SIGNAL(clicked()), this, SLOT(on_char_select_left_clicked())); - connect(ui_char_select_right, SIGNAL(clicked()), this, SLOT(on_char_select_right_clicked())); + connect(ui_char_select_left, SIGNAL(clicked()), this, + SLOT(on_char_select_left_clicked())); + connect(ui_char_select_right, SIGNAL(clicked()), this, + SLOT(on_char_select_right_clicked())); - connect(ui_spectator, SIGNAL(clicked()), this, SLOT(on_spectator_clicked())); + connect(ui_spectator, SIGNAL(clicked()), this, SLOT(on_spectator_clicked())); - connect(ui_char_search, SIGNAL(textEdited(const QString &)), this, SLOT(on_char_search_changed())); - connect(ui_char_passworded, SIGNAL(stateChanged(int)), this, SLOT(on_char_passworded_clicked())); - connect(ui_char_taken, SIGNAL(stateChanged(int)), this, SLOT(on_char_taken_clicked())); + connect(ui_char_search, SIGNAL(textEdited(const QString &)), this, + SLOT(on_char_search_changed())); + connect(ui_char_passworded, SIGNAL(stateChanged(int)), this, + SLOT(on_char_passworded_clicked())); + connect(ui_char_taken, SIGNAL(stateChanged(int)), this, + SLOT(on_char_taken_clicked())); } void Courtroom::set_char_select() { - QString filename = "courtroom_design.ini"; + QString filename = "courtroom_design.ini"; - pos_size_type f_charselect = ao_app->get_element_dimensions("char_select", filename); + pos_size_type f_charselect = + ao_app->get_element_dimensions("char_select", filename); - if (f_charselect.width < 0 || f_charselect.height < 0) { - qDebug() << "W: did not find char_select width or height in courtroom_design.ini!"; - this->resize(714, 668); - } - else - this->resize(f_charselect.width, f_charselect.height); + if (f_charselect.width < 0 || f_charselect.height < 0) { + qDebug() << "W: did not find char_select width or height in " + "courtroom_design.ini!"; + this->resize(714, 668); + } + else + this->resize(f_charselect.width, f_charselect.height); - ui_char_select_background->resize(f_charselect.width, f_charselect.height); - ui_char_select_background->set_image("charselect_background"); + ui_char_select_background->resize(f_charselect.width, f_charselect.height); + ui_char_select_background->set_image("charselect_background"); - filter_character_list(); + filter_character_list(); - ui_char_search->setFocus(); + ui_char_search->setFocus(); } void Courtroom::set_char_select_page() { - ui_char_select_background->show(); + ui_char_select_background->show(); - ui_char_select_left->hide(); - ui_char_select_right->hide(); + ui_char_select_left->hide(); + ui_char_select_right->hide(); - for (AOCharButton *i_button : ui_char_button_list) { - i_button->reset(); - i_button->hide(); - i_button->move(0, 0); - } + for (AOCharButton *i_button : ui_char_button_list) { + i_button->reset(); + i_button->hide(); + i_button->move(0, 0); + } - int total_pages = ui_char_button_list_filtered.size() / max_chars_on_page; - int chars_on_page = 0; + int total_pages = ui_char_button_list_filtered.size() / max_chars_on_page; + int chars_on_page = 0; - if (ui_char_button_list_filtered.size() % max_chars_on_page != 0) { - ++total_pages; - //i. e. not on the last page - if (total_pages > current_char_page + 1) - chars_on_page = max_chars_on_page; - else - chars_on_page = ui_char_button_list_filtered.size() % max_chars_on_page; - } + if (ui_char_button_list_filtered.size() % max_chars_on_page != 0) { + ++total_pages; + // i. e. not on the last page + if (total_pages > current_char_page + 1) + chars_on_page = max_chars_on_page; else - chars_on_page = max_chars_on_page; + chars_on_page = ui_char_button_list_filtered.size() % max_chars_on_page; + } + else + chars_on_page = max_chars_on_page; - if (total_pages > current_char_page + 1) - ui_char_select_right->show(); + if (total_pages > current_char_page + 1) + ui_char_select_right->show(); - if (current_char_page > 0) - ui_char_select_left->show(); + if (current_char_page > 0) + ui_char_select_left->show(); - put_button_in_place(current_char_page * max_chars_on_page, chars_on_page); + put_button_in_place(current_char_page * max_chars_on_page, chars_on_page); } void Courtroom::char_clicked(int n_char) { - QString char_ini_path = ao_app->get_character_path(char_list.at(n_char).name, "char.ini"); + QString char_ini_path = + ao_app->get_character_path(char_list.at(n_char).name, "char.ini"); - qDebug() << "char_ini_path" << char_ini_path; + qDebug() << "char_ini_path" << char_ini_path; - if (!file_exists(char_ini_path)) { - call_notice("Could not find " + char_ini_path); - return; - } + if (!file_exists(char_ini_path)) { + call_notice("Could not find " + char_ini_path); + return; + } - if (n_char != m_cid) { - ao_app->send_server_packet(new AOPacket("PW#" + ui_char_password->text() + "#%")); - ao_app->send_server_packet(new AOPacket("CC#" + QString::number(ao_app->s_pv) + "#" + QString::number(n_char) + "#" + get_hdid() + "#%")); - } - else - update_character(n_char); + if (n_char != m_cid) { + ao_app->send_server_packet( + new AOPacket("PW#" + ui_char_password->text() + "#%")); + ao_app->send_server_packet( + new AOPacket("CC#" + QString::number(ao_app->s_pv) + "#" + + QString::number(n_char) + "#" + get_hdid() + "#%")); + } + else + update_character(n_char); - enter_courtroom(); + enter_courtroom(); - ui_ic_chat_name->setPlaceholderText(char_list.at(n_char).name); + ui_ic_chat_name->setPlaceholderText(char_list.at(n_char).name); } void Courtroom::put_button_in_place(int starting, int chars_on_this_page) { - if (ui_char_button_list_filtered.size() == 0) - return; + if (ui_char_button_list_filtered.size() == 0) + return; - QPoint f_spacing = ao_app->get_button_spacing("char_button_spacing", "courtroom_design.ini"); + QPoint f_spacing = + ao_app->get_button_spacing("char_button_spacing", "courtroom_design.ini"); - int x_spacing = f_spacing.x(); - int x_mod_count = 0; + int x_spacing = f_spacing.x(); + int x_mod_count = 0; - int y_spacing = f_spacing.y(); - int y_mod_count = 0; + int y_spacing = f_spacing.y(); + int y_mod_count = 0; - char_columns = ((ui_char_buttons->width() - button_width) / (x_spacing + button_width)) + 1; - char_rows = ((ui_char_buttons->height() - button_height) / (y_spacing + button_height)) + 1; + char_columns = + ((ui_char_buttons->width() - button_width) / (x_spacing + button_width)) + + 1; + char_rows = ((ui_char_buttons->height() - button_height) / + (y_spacing + button_height)) + + 1; - max_chars_on_page = char_columns * char_rows; + max_chars_on_page = char_columns * char_rows; - int startout = starting; - for (int n = starting; n < startout + chars_on_this_page; ++n) { - int x_pos = (button_width + x_spacing) * x_mod_count; - int y_pos = (button_height + y_spacing) * y_mod_count; + int startout = starting; + for (int n = starting; n < startout + chars_on_this_page; ++n) { + int x_pos = (button_width + x_spacing) * x_mod_count; + int y_pos = (button_height + y_spacing) * y_mod_count; - 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)->apply_taken_image(); + 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)->apply_taken_image(); - ++x_mod_count; + ++x_mod_count; - if (x_mod_count == char_columns) { - ++y_mod_count; - x_mod_count = 0; - } + if (x_mod_count == char_columns) { + ++y_mod_count; + x_mod_count = 0; } + } } void Courtroom::character_loading_finished() { - // Zeroeth, we'll clear any leftover characters from previous server visits. - ao_app->generated_chars = 0; - if (ui_char_button_list.size() > 0) { - foreach (AOCharButton *item, ui_char_button_list) { - delete item; - } - ui_char_button_list.clear(); + // Zeroeth, we'll clear any leftover characters from previous server visits. + ao_app->generated_chars = 0; + if (ui_char_button_list.size() > 0) { + foreach (AOCharButton *item, ui_char_button_list) { + delete item; } - - // First, we'll make all the character buttons in the very beginning. - // We also hide them all, so they can't be accidentally clicked. - // Later on, we'll be revealing buttons as we need them. - for (int n = 0; n < char_list.size(); n++) { - AOCharButton *char_button = new AOCharButton(ui_char_buttons, ao_app, 0, 0, char_list.at(n).taken); - char_button->reset(); - char_button->hide(); - char_button->set_image(char_list.at(n).name); - ui_char_button_list.append(char_button); - - connect(char_button, &AOCharButton::clicked, [this, n]() { - this->char_clicked(n); - }); - - // This part here serves as a way of showing to the player that the game is still running, it is - // just loading the pictures of the characters. - if (ao_app->lobby_constructed) { - ao_app->generated_chars++; - int total_loading_size = ao_app->char_list_size * 2 + ao_app->evidence_list_size + ao_app->music_list_size; - int loading_value = int(((ao_app->loaded_chars + ao_app->generated_chars + ao_app->loaded_music + ao_app->loaded_evidence) / static_cast(total_loading_size)) * 100); - ao_app->w_lobby->set_loading_value(loading_value); - ao_app->w_lobby->set_loading_text(tr("Generating chars:\n%1/%2").arg(QString::number(ao_app->generated_chars)).arg(QString::number(ao_app->char_list_size))); - } + ui_char_button_list.clear(); + } + + // First, we'll make all the character buttons in the very beginning. + // We also hide them all, so they can't be accidentally clicked. + // Later on, we'll be revealing buttons as we need them. + for (int n = 0; n < char_list.size(); n++) { + AOCharButton *char_button = + new AOCharButton(ui_char_buttons, ao_app, 0, 0, char_list.at(n).taken); + char_button->reset(); + char_button->hide(); + char_button->set_image(char_list.at(n).name); + ui_char_button_list.append(char_button); + + connect(char_button, &AOCharButton::clicked, + [this, n]() { this->char_clicked(n); }); + + // This part here serves as a way of showing to the player that the game is + // still running, it is just loading the pictures of the characters. + if (ao_app->lobby_constructed) { + ao_app->generated_chars++; + int total_loading_size = ao_app->char_list_size * 2 + + ao_app->evidence_list_size + + ao_app->music_list_size; + int loading_value = + int(((ao_app->loaded_chars + ao_app->generated_chars + + ao_app->loaded_music + ao_app->loaded_evidence) / + static_cast(total_loading_size)) * + 100); + ao_app->w_lobby->set_loading_value(loading_value); + ao_app->w_lobby->set_loading_text( + tr("Generating chars:\n%1/%2") + .arg(QString::number(ao_app->generated_chars)) + .arg(QString::number(ao_app->char_list_size))); } + } - filter_character_list(); + filter_character_list(); } void Courtroom::filter_character_list() { - ui_char_button_list_filtered.clear(); - for (int i = 0; i < char_list.size(); i++) { - AOCharButton *current_char = ui_char_button_list.at(i); + ui_char_button_list_filtered.clear(); + for (int i = 0; i < char_list.size(); i++) { + AOCharButton *current_char = ui_char_button_list.at(i); - // It seems passwording characters is unimplemented yet? - // Until then, this will stay here, I suppose. - //if (ui_char_passworded->isChecked() && character_is_passworded??) - // continue; + // It seems passwording characters is unimplemented yet? + // Until then, this will stay here, I suppose. + // if (ui_char_passworded->isChecked() && character_is_passworded??) + // continue; - if (!ui_char_taken->isChecked() && char_list.at(i).taken) - continue; + if (!ui_char_taken->isChecked() && char_list.at(i).taken) + continue; - if (!char_list.at(i).name.contains(ui_char_search->text(), Qt::CaseInsensitive)) - continue; + 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); + // 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); - } + ui_char_button_list_filtered.append(current_char); + } - current_char_page = 0; - set_char_select_page(); + current_char_page = 0; + set_char_select_page(); } -void Courtroom::on_char_search_changed() -{ - filter_character_list(); -} +void Courtroom::on_char_search_changed() { filter_character_list(); } -void Courtroom::on_char_passworded_clicked() -{ - filter_character_list(); -} +void Courtroom::on_char_passworded_clicked() { filter_character_list(); } -void Courtroom::on_char_taken_clicked() -{ - filter_character_list(); -} +void Courtroom::on_char_taken_clicked() { filter_character_list(); } -- cgit