finished charselect and cleaned up some files

This commit is contained in:
David Skoland 2017-01-26 16:03:48 +01:00
parent 47ffce5db5
commit 5e2ea2b24c
29 changed files with 219 additions and 43 deletions

View File

@ -5,13 +5,50 @@
#include <QFile>
AOCharButton::AOCharButton(QWidget *parent, AOApplication *p_ao_app) : QPushButton(parent)
AOCharButton::AOCharButton(QWidget *parent, AOApplication *p_ao_app, int x_pos, int y_pos) : QPushButton(parent)
{
m_parent = parent;
ao_app = p_ao_app;
this->resize(60, 60);
this->move(x_pos, y_pos);
ui_taken = new AOImage(this, ao_app);
ui_taken->resize(60, 60);
ui_taken->set_image("char_taken.png");
ui_taken->setAttribute(Qt::WA_TransparentForMouseEvents);
ui_taken->hide();
ui_passworded = new AOImage(this, ao_app);
ui_passworded->resize(60, 60);
ui_passworded->set_image("char_passworded");
ui_passworded->setAttribute(Qt::WA_TransparentForMouseEvents);
ui_passworded->hide();
ui_selector = new AOImage(parent, ao_app);
ui_selector->resize(62, 62);
ui_selector->move(x_pos - 1, y_pos - 1);
ui_selector->set_image("char_selector.png");
ui_selector->setAttribute(Qt::WA_TransparentForMouseEvents);
ui_selector->hide();
}
void AOCharButton::reset()
{
ui_taken->hide();
ui_passworded->hide();
ui_selector->hide();
}
void AOCharButton::set_taken()
{
ui_taken->show();
}
void AOCharButton::set_passworded()
{
ui_passworded->show();
}
void AOCharButton::set_image(QString p_character)
@ -19,6 +56,8 @@ void AOCharButton::set_image(QString p_character)
QString image_path = ao_app->get_character_path(p_character) + "char_icon.png";
QString legacy_path = ao_app->get_demothings_path() + p_character.toLower() + "_char_icon.png";
this->setText("");
if (file_exists(image_path))
this->setStyleSheet("border-image:url(\"" + image_path + "\")");
else if (file_exists(legacy_path))
@ -33,3 +72,20 @@ void AOCharButton::set_image(QString p_character)
this->setText(p_character);
}
}
void AOCharButton::enterEvent(QEvent * e)
{
ui_selector->raise();
ui_selector->show();
setFlat(false);
QPushButton::enterEvent(e);
}
void AOCharButton::leaveEvent(QEvent * e)
{
ui_selector->hide();
QPushButton::leaveEvent(e);
}

View File

@ -6,20 +6,33 @@
#include <QPushButton>
#include <QString>
#include <QWidget>
#include "aoimage.h"
class AOCharButton : public QPushButton
{
Q_OBJECT
public:
AOCharButton(QWidget *parent, AOApplication *p_ao_app);
AOCharButton(QWidget *parent, AOApplication *p_ao_app, int x_pos, int y_pos);
AOApplication *ao_app;
void reset();
void set_taken();
void set_passworded();
void set_image(QString p_character);
private:
QWidget *m_parent;
AOImage *ui_taken;
AOImage *ui_passworded;
AOImage *ui_selector;
protected:
void enterEvent(QEvent *e);
void leaveEvent(QEvent *e);
};
#endif // AOCHARBUTTON_H

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 29 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 29 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 29 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 25 KiB

View File

@ -1 +0,0 @@
theme = default

4
base/serverlist.txt Normal file
View File

@ -0,0 +1,4 @@
10.0.0.1:27071:the shit server
88.203.168.170:27777:Demon Server For Demons! Vanilla! 1.8+
24.193.75.13:27053:The Flaming Phoenix
51.255.160.217:50000:Attorney Online Vidya(Dedicated)

View File

@ -8,7 +8,7 @@ area_list = 266, 494, 224, 174
music_list = 490, 342, 224, 326
ic_chat_message = 0, 192, 255, 23
ooc_chat_message = 492, 281, 222, 19
ooc_chat_name = 492, 300, 32, 19
ooc_chat_name = 492, 300, 85, 19
area_password = 266, 471, 224, 23
music_search = 490, 319, 226, 23
emote_left = 0, 253, 20, 20
@ -20,6 +20,7 @@ sfx_label = 260, 410, 21, 16
blip_label = 260, 430, 31, 16
hold_it = 10, 312, 76, 28
objection = 90, 312, 76, 28
take_that = 170, 312, 76, 28
ooc_toggle = 580, 300, 133, 19
witness_testimony = 5, 345, 85, 42
cross_examination = 95, 345, 85, 42
@ -30,8 +31,8 @@ pre = 187, 345, 51, 21
flip = 187, 362, 51, 21
guard = 187, 379, 61, 21
custom_objection = 250, 325, 40, 40
realization = 295, 323, 40, 40
mute = 340, 325, 40, 40
realization = 295, 325, 40, 40
mute_button = 340, 325, 40, 40
defense_plus = 477, 325, 9, 9
defense_minus = 385, 325, 9, 9
prosecution_plus = 477, 342, 9, 9

View File

@ -1,28 +0,0 @@
hold_it = 10, 312
objection = 90, 312
take_that = 170, 312
objection_custom = 250, 325
realization = 295, 325
mute = 340, 325
text_color = 390, 360
defense_bar = 393, 323
prosecution_bar = 393, 340
def_plus = 477, 325
def_minus = 385, 325
pro_plus = 477, 342
pro_minus = 385, 342
witness_testimony = 5, 345
cross_examination = 95, 345
pre = 187, 345
flip = 187, 362
guard = 187, 379
change_character = 5, 390
reload_theme = 5, 415
call_mod = 5, 440
music_label = 260, 390
music_slider = 310, 392
sfx_label = 260, 410
sfx_slider = 310, 412
blips_label = 260, 430
blips_slider = 310, 432

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

View File

@ -0,0 +1,16 @@
lobby = 0, 0, 517, 666
public_servers = 46, 88, 114, 30
favorites = 164, 88, 114, 30
refresh = 56, 381, 132, 28
add_to_fav = 194, 381, 132, 28
connect = 332, 381, 132, 28
about = 428, 1, 88, 21
server_list = 20, 125, 286, 240
player_count = 336, 91, 173, 16
description = 337, 109, 173, 245
chatbox = 2, 445, 515, 198
chatname = 3, 646, 85, 19
chatmessage = 93, 646, 424, 19
loading_label = 135, 92, 254, 95
progress_bar = 135, 188, 254, 21
cancel = 220, 220, 80, 20

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.6 KiB

After

Width:  |  Height:  |  Size: 1013 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.6 KiB

View File

@ -11,6 +11,8 @@ Courtroom::Courtroom(AOApplication *p_ao_app) : QMainWindow()
{
ao_app = p_ao_app;
char_button_mapper = new QSignalMapper(this);
ui_background = new AOImage(this, ao_app);
//viewport elements like background, desk, etc.
@ -91,7 +93,7 @@ Courtroom::Courtroom(AOApplication *p_ao_app) : QMainWindow()
ui_char_select_background = new AOImage(this, ao_app);
//setting up the grid and positions
//constructing character button grid
const int base_x_pos{25};
const int base_y_pos{36};
@ -103,15 +105,37 @@ Courtroom::Courtroom(AOApplication *p_ao_app) : QMainWindow()
for (int n = 0 ; n < 90 ; ++n)
{
ui_char_button_list.append(new AOCharButton(ui_char_select_background, ao_app));
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(ui_change_character, SIGNAL(clicked()), this, SLOT(on_change_character_clicked()));
@ -120,6 +144,9 @@ Courtroom::Courtroom(AOApplication *p_ao_app) : QMainWindow()
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()));
set_widgets();
@ -256,10 +283,9 @@ void Courtroom::set_widgets()
ui_char_select_background->move(0, 0);
ui_char_select_background->resize(m_courtroom_width, m_courtroom_height);
//T0D0: uncomment and set position properly
//QVector<AOCharButton*> ui_char_button_list;
//buttons are in the constructor
ui_selector->set_image("selector.png");
ui_selector->set_image("char_selector.png");
ui_selector->hide();
ui_back_to_lobby->setText("Back to Lobby");
@ -267,6 +293,14 @@ void Courtroom::set_widgets()
set_size_and_pos(ui_char_password, "char_password");
ui_char_select_left->set_image("arrow_left.png");
ui_char_select_left->move(2, 325);
ui_char_select_left->resize(20, 20);
ui_char_select_right->set_image("arrow_right.png");
ui_char_select_right->move(691, 325);
ui_char_select_right->resize(20, 20);
ui_spectator->setText("Spectator");
set_size_and_pos(ui_spectator, "spectator");
@ -305,13 +339,57 @@ void Courtroom::set_taken(int n_char, bool p_taken)
}
char_type f_char;
f_char.name = char_list.at(0).name;
f_char.description = char_list.at(1).description;
f_char.name = char_list.at(n_char).name;
f_char.description = char_list.at(n_char).description;
f_char.taken = p_taken;
char_list.replace(n_char, f_char);
}
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;
qDebug() << "chars_on_page: " << chars_on_page;
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;
ui_char_button_list.at(n_button)->set_image(char_list.at(n_real_char).name);
ui_char_button_list.at(n_button)->show();
}
}
void Courtroom::on_change_character_clicked()
{
ui_char_select_background->show();
@ -331,11 +409,28 @@ void Courtroom::on_back_to_lobby_clicked()
ao_app->destruct_courtroom();
}
void Courtroom::on_char_select_left_clicked()
{
--current_char_page;
set_char_select_page();
}
void Courtroom::on_char_select_right_clicked()
{
++current_char_page;
set_char_select_page();
}
void Courtroom::on_spectator_clicked()
{
ui_char_select_background->hide();
}
void Courtroom::char_clicked(int n_char)
{
}
Courtroom::~Courtroom()
{

View File

@ -16,6 +16,7 @@
#include <QSlider>
#include <QVector>
#include <QCloseEvent>
#include <QSignalMapper>
class AOApplication;
@ -32,6 +33,7 @@ public:
void set_widgets();
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();
~Courtroom();
@ -51,8 +53,15 @@ private:
QVector<evi_type> evidence_list;
QVector<QString> music_list;
QSignalMapper *char_button_mapper;
//0 is the first page, 1 second etc.
//makes char arithmetic easier
int current_char_page = 0;
AOImage *ui_background;
//viewport elements like background, desk, etc.
//T0D0: add viewport elements like background, desk, etc.
QPlainTextEdit *ui_ic_chatlog;
@ -72,7 +81,7 @@ private:
QLineEdit *ui_area_password;
QLineEdit *ui_music_search;
//emote buttons
//T0D0: add emote buttons
AOButton *ui_emote_left;
AOButton *ui_emote_right;
@ -129,6 +138,9 @@ private:
QLineEdit *ui_char_password;
AOButton *ui_char_select_left;
AOButton *ui_char_select_right;
AOButton *ui_spectator;
private slots:
void on_change_character_clicked();
@ -138,6 +150,11 @@ private slots:
void on_spectator_clicked();
void on_char_select_left_clicked();
void on_char_select_right_clicked();
void char_clicked(int n_char);
};
#endif // COURTROOM_H

View File

@ -176,6 +176,7 @@ void AOApplication::server_packet_received(AOPacket *p_packet)
w_lobby->set_loading_text("Loading chars:\n" + QString::number(loaded_chars) + "/" + QString::number(char_list_size));
w_courtroom->append_char(f_char);
//qDebug() << "appended " << f_char.name << " to char_list";
}
if (loaded_chars < char_list_size)
@ -278,6 +279,8 @@ void AOApplication::server_packet_received(AOPacket *p_packet)
if (!courtroom_constructed)
return;
w_courtroom->set_char_select_page();
w_courtroom->show();
destruct_lobby();