aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOmniTroid <davidskoland@gmail.com>2017-03-15 04:33:26 +0100
committerOmniTroid <davidskoland@gmail.com>2017-03-15 04:33:26 +0100
commit939f6cc3fd937660f2c3bdf328fdf7fff219a0cc (patch)
tree937eea956ac84553e38f33bb52fabc601248463d
parent38c01f2cca55222f7d40b03367aea1f5b2f9c463 (diff)
put charselect stuff in a separate file
-rw-r--r--Attorney_Online_remake.pro3
-rw-r--r--charselect.cpp125
-rw-r--r--courtroom.cpp135
-rw-r--r--courtroom.h12
4 files changed, 141 insertions, 134 deletions
diff --git a/Attorney_Online_remake.pro b/Attorney_Online_remake.pro
index 82f6cda0..7cda4ca4 100644
--- a/Attorney_Online_remake.pro
+++ b/Attorney_Online_remake.pro
@@ -42,7 +42,8 @@ SOURCES += main.cpp\
aomusicplayer.cpp \
aoblipplayer.cpp \
evidence.cpp \
- aoevidencebutton.cpp
+ aoevidencebutton.cpp \
+ charselect.cpp
HEADERS += lobby.h \
aoimage.h \
diff --git a/charselect.cpp b/charselect.cpp
new file mode 100644
index 00000000..6465565e
--- /dev/null
+++ b/charselect.cpp
@@ -0,0 +1,125 @@
+#include "courtroom.h"
+
+#include <QDebug>
+
+void Courtroom::construct_char_select()
+{
+ ui_char_select_background = new AOImage(this, ao_app);
+
+ 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_back_to_lobby = new AOButton(ui_char_select_background, ao_app);
+
+ ui_char_password = new QLineEdit(ui_char_select_background);
+
+ 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);
+
+ //constructing character button grid
+
+ const int x_modifier{67};
+ int x_mod_count{0};
+
+ const int y_modifier{67};
+ int y_mod_count{0};
+
+ for (int n = 0 ; n < 90 ; ++n)
+ {
+ int x_pos = (x_modifier * x_mod_count);
+ int y_pos = (y_modifier * y_mod_count);
+
+ ui_char_button_list.append(new AOCharButton(ui_char_buttons, ao_app, x_pos, y_pos));
+
+ connect(ui_char_button_list.at(n), SIGNAL(clicked()), char_button_mapper, SLOT(map())) ;
+ char_button_mapper->setMapping (ui_char_button_list.at(n), n) ;
+
+ ++x_mod_count;
+
+ //if char number is divisible by ten with rest 9 then the next charicon should start on a new line
+ if (n % 10 == 9 && n != 0)
+ {
+ ++y_mod_count;
+ x_mod_count = 0;
+ }
+ }
+
+ connect (char_button_mapper, SIGNAL(mapped(int)), this, SLOT(char_clicked(int)));
+ 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_spectator, SIGNAL(clicked()), this, SLOT(on_spectator_clicked()));
+}
+
+void Courtroom::set_char_select()
+{
+ QString filename = "courtroom_design.ini";
+
+ 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 courtroom 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.png");
+}
+
+void Courtroom::set_char_select_page()
+{
+ ui_char_select_background->show();
+
+ ui_char_select_left->hide();
+ ui_char_select_right->hide();
+
+ for (AOCharButton *i_button : ui_char_button_list)
+ i_button->hide();
+
+ int total_pages = char_list.size() / 90;
+ int chars_on_page = 0;
+
+ if (char_list.size() % 90 != 0)
+ {
+ ++total_pages;
+ //i. e. not on the last page
+ if (total_pages > current_char_page + 1)
+ chars_on_page = 90;
+ else
+ chars_on_page = char_list.size() % 90;
+
+ }
+ else
+ chars_on_page = 90;
+
+ if (total_pages > current_char_page + 1)
+ ui_char_select_right->show();
+
+ if (current_char_page > 0)
+ ui_char_select_left->show();
+
+ for (int n_button = 0 ; n_button < chars_on_page ; ++n_button)
+ {
+ int n_real_char = n_button + current_char_page * 90;
+ AOCharButton *f_button = ui_char_button_list.at(n_button);
+
+ f_button->reset();
+ f_button->set_image(char_list.at(n_real_char).name);
+ f_button->show();
+
+ if (char_list.at(n_real_char).taken)
+ f_button->set_taken();
+ }
+
+}
+
diff --git a/courtroom.cpp b/courtroom.cpp
index 868ed9f6..0eb9d5d2 100644
--- a/courtroom.cpp
+++ b/courtroom.cpp
@@ -183,55 +183,6 @@ Courtroom::Courtroom(AOApplication *p_ao_app) : QMainWindow()
ui_evidence = new AOImage(this, ao_app);
- /////////////char select widgets under here///////////////
-
- ui_char_select_background = new AOImage(this, ao_app);
-
- //constructing character button grid
- const int base_x_pos{25};
- const int base_y_pos{36};
-
- const int x_modifier{67};
- int x_mod_count{0};
-
- const int y_modifier{67};
- int y_mod_count{0};
-
- for (int n = 0 ; n < 90 ; ++n)
- {
- int x_pos = base_x_pos + (x_modifier * x_mod_count);
- int y_pos = base_y_pos + (y_modifier * y_mod_count);
-
- ui_char_button_list.append(new AOCharButton(ui_char_select_background, ao_app, x_pos, y_pos));
-
- connect(ui_char_button_list.at(n), SIGNAL(clicked()), char_button_mapper, SLOT(map())) ;
- char_button_mapper->setMapping (ui_char_button_list.at(n), n) ;
-
- ++x_mod_count;
-
- //if char number is divisible by ten with rest 9 then the next charicon should start on a new line
- if (n % 10 == 9 && n != 0)
- {
- ++y_mod_count;
- x_mod_count = 0;
- }
- }
-
- connect (char_button_mapper, SIGNAL(mapped(int)), this, SLOT(char_clicked(int))) ;
-
- 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_char_password = new QLineEdit(ui_char_select_background);
-
- 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);
-
connect(keepalive_timer, SIGNAL(timeout()), this, SLOT(ping_server()));
connect(ui_vp_objection, SIGNAL(done()), this, SLOT(objection_done()));
@@ -295,15 +246,10 @@ Courtroom::Courtroom(AOApplication *p_ao_app) : QMainWindow()
connect(ui_evidence_button, SIGNAL(clicked()), this, SLOT(on_evidence_button_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_spectator, SIGNAL(clicked()), this, SLOT(on_spectator_clicked()));
-
connect(disconnect_timer, SIGNAL(timeout()), this, SLOT(connection_timeout()));
+ construct_char_select();
+
set_widgets();
construct_evidence();
@@ -465,8 +411,6 @@ void Courtroom::set_widgets()
set_size_and_pos(ui_emote_dropdown, "emote_dropdown");
- //emote buttons
-
set_size_and_pos(ui_defense_bar, "defense_bar");
ui_defense_bar->set_image("defensebar" + QString::number(defense_bar_state) + ".png");
@@ -544,8 +488,6 @@ void Courtroom::set_widgets()
set_size_and_pos(ui_evidence, "evidence_background");
ui_evidence->set_image("evidencebackground.png");
- //buttons are in the constructor
-
ui_selector->set_image("char_selector.png");
ui_selector->hide();
@@ -554,12 +496,12 @@ void Courtroom::set_widgets()
set_size_and_pos(ui_char_password, "char_password");
- ui_char_select_left->move(2, 325);
- ui_char_select_left->resize(20, 20);
+ set_size_and_pos(ui_char_buttons, "char_buttons");
+
+ set_size_and_pos(ui_char_select_left, "char_select_left");
ui_char_select_left->set_image("arrow_left.png");
- ui_char_select_right->move(691, 325);
- ui_char_select_right->resize(20, 20);
+ set_size_and_pos(ui_char_select_right, "char_select_right");
ui_char_select_right->set_image("arrow_right.png");
set_size_and_pos(ui_spectator, "spectator");
@@ -650,71 +592,6 @@ void Courtroom::done_received()
ui_spectator->show();
}
-void Courtroom::set_char_select()
-{
- QString filename = "courtroom_design.ini";
-
- 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 courtroom 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.png");
-}
-
-void Courtroom::set_char_select_page()
-{
- ui_char_select_background->show();
-
- ui_char_select_left->hide();
- ui_char_select_right->hide();
-
- for (AOCharButton *i_button : ui_char_button_list)
- i_button->hide();
-
- int total_pages = char_list.size() / 90;
- int chars_on_page = 0;
-
- if (char_list.size() % 90 != 0)
- {
- ++total_pages;
- //i. e. not on the last page
- if (total_pages > current_char_page + 1)
- chars_on_page = 90;
- else
- chars_on_page = char_list.size() % 90;
-
- }
- else
- chars_on_page = 90;
-
- if (total_pages > current_char_page + 1)
- ui_char_select_right->show();
-
- if (current_char_page > 0)
- ui_char_select_left->show();
-
- for (int n_button = 0 ; n_button < chars_on_page ; ++n_button)
- {
- int n_real_char = n_button + current_char_page * 90;
- AOCharButton *f_button = ui_char_button_list.at(n_button);
-
- f_button->reset();
- f_button->set_image(char_list.at(n_real_char).name);
- f_button->show();
-
- if (char_list.at(n_real_char).taken)
- f_button->set_taken();
- }
-
-}
-
void Courtroom::set_background(QString p_background)
{
current_background = p_background;
diff --git a/courtroom.h b/courtroom.h
index 80bee17c..cf9bcefb 100644
--- a/courtroom.h
+++ b/courtroom.h
@@ -46,10 +46,9 @@ public:
void set_window_title(QString p_title);
void set_size_and_pos(QWidget *p_widget, QString p_identifier);
void set_taken(int n_char, bool p_taken);
- void set_char_select_page();
void set_background(QString p_background);
- void set_char_select();
+
void done_received();
@@ -199,8 +198,6 @@ private:
//whether the ooc chat is server or master chat, true is server
bool server_ooc = true;
-
-
QString current_background = "gs4";
AOMusicPlayer *music_player;
@@ -304,6 +301,9 @@ private:
AOImage *ui_char_select_background;
+ //abstract widget to hold char buttons
+ QWidget *ui_char_buttons;
+
QVector<AOCharButton*> ui_char_button_list;
AOImage *ui_selector;
@@ -316,6 +316,10 @@ private:
AOButton *ui_spectator;
+ void construct_char_select();
+ void set_char_select();
+ void set_char_select_page();
+
void construct_emotes();
void set_emote_page();
void set_emote_dropdown();