put charselect stuff in a separate file
This commit is contained in:
parent
38c01f2cca
commit
939f6cc3fd
@ -42,7 +42,8 @@ SOURCES += main.cpp\
|
||||
aomusicplayer.cpp \
|
||||
aoblipplayer.cpp \
|
||||
evidence.cpp \
|
||||
aoevidencebutton.cpp
|
||||
aoevidencebutton.cpp \
|
||||
charselect.cpp
|
||||
|
||||
HEADERS += lobby.h \
|
||||
aoimage.h \
|
||||
|
125
charselect.cpp
Normal file
125
charselect.cpp
Normal file
@ -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();
|
||||
}
|
||||
|
||||
}
|
||||
|
135
courtroom.cpp
135
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;
|
||||
|
12
courtroom.h
12
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();
|
||||
|
Loading…
Reference in New Issue
Block a user