From c4dff0f5284d5dfa37142ffce7eb27f72abaf1f1 Mon Sep 17 00:00:00 2001 From: David Skoland Date: Mon, 16 Jan 2017 16:11:54 +0100 Subject: [PATCH] more work on the courtroom + added the aocharbutton class --- Attorney_Online_remake.pro | 6 ++++-- aoapplication.cpp | 4 ++-- aoapplication.h | 3 +-- aocharbutton.cpp | 33 +++++++++++++++++++++++++++++++++ aocharbutton.h | 21 +++++++++++++++++++++ courtroom.cpp | 2 +- courtroom.h | 13 ++++++------- path_functions.cpp | 10 ++++++++++ path_functions.h | 2 ++ 9 files changed, 80 insertions(+), 14 deletions(-) create mode 100644 aocharbutton.cpp create mode 100644 aocharbutton.h diff --git a/Attorney_Online_remake.pro b/Attorney_Online_remake.pro index 1f2af98..a51e1f6 100644 --- a/Attorney_Online_remake.pro +++ b/Attorney_Online_remake.pro @@ -28,7 +28,8 @@ SOURCES += main.cpp\ packet_distribution.cpp \ hex_functions.cpp \ encryption_functions.cpp \ - courtroom.cpp + courtroom.cpp \ + aocharbutton.cpp HEADERS += lobby.h \ text_file_functions.h \ @@ -44,4 +45,5 @@ HEADERS += lobby.h \ aopacket.h \ hex_functions.h \ encryption_functions.h \ - courtroom.h + courtroom.h \ + aocharbutton.h diff --git a/aoapplication.cpp b/aoapplication.cpp index c2eef1f..7706642 100644 --- a/aoapplication.cpp +++ b/aoapplication.cpp @@ -1,6 +1,7 @@ #include #include "lobby.h" +#include "courtroom.h" #include "networkmanager.h" #include "aoapplication.h" @@ -47,8 +48,7 @@ void AOApplication::construct_courtroom() return; } - //T0D0, make custom Courtroom class and uncomment - //w_courtroom = new QMainWindow(this); + w_courtroom = new Courtroom(this); courtroom_constructed = true; } diff --git a/aoapplication.h b/aoapplication.h index d37dc86..34f1fef 100644 --- a/aoapplication.h +++ b/aoapplication.h @@ -21,8 +21,7 @@ public: NetworkManager *net_manager; Lobby *w_lobby; - //T0D0: change to custom class "Courtroom" - QMainWindow *w_courtroom; + Courtroom *w_courtroom; bool lobby_constructed = false; bool courtroom_constructed = false; diff --git a/aocharbutton.cpp b/aocharbutton.cpp new file mode 100644 index 0000000..1c0b4f7 --- /dev/null +++ b/aocharbutton.cpp @@ -0,0 +1,33 @@ +#include "aocharbutton.h" + +#include "path_functions.h" +#include "file_functions.h" + +#include + +AOCharButton::AOCharButton(QWidget *parent) +{ + m_parent = parent; + + this->resize(60, 60); +} + +void AOCharButton::set_image(QString p_character) +{ + QString image_path = get_character_path(p_character) + "char_icon.png"; + QString legacy_path = get_demothings_path() + p_character.toLower() + "_char_icon.png"; + + if (file_exists(image_path)) + this->setStyleSheet("border-image:url(\"" + image_path + "\")"); + else if (file_exists(legacy_path)) + { + this->setStyleSheet("border-image:url(\"" + legacy_path + "\")"); + //ninja optimization + QFile::copy(legacy_path, image_path); + } + else + { + this->setStyleSheet("border-image:url()"); + this->setText(p_character); + } +} diff --git a/aocharbutton.h b/aocharbutton.h new file mode 100644 index 0000000..231fe66 --- /dev/null +++ b/aocharbutton.h @@ -0,0 +1,21 @@ +#ifndef AOCHARBUTTON_H +#define AOCHARBUTTON_H + +#include +#include +#include + +class AOCharButton : public QPushButton +{ + Q_OBJECT + +public: + AOCharButton(QWidget *parent); + + void set_image(QString p_character); + +private: + QWidget *m_parent; +}; + +#endif // AOCHARBUTTON_H diff --git a/courtroom.cpp b/courtroom.cpp index c49ec03..6032d41 100644 --- a/courtroom.cpp +++ b/courtroom.cpp @@ -2,7 +2,7 @@ #include "aoapplication.h" -Courtroom::Courtroom(AOApplication *parent) : QMainWindow(parent) +Courtroom::Courtroom(AOApplication *parent) : QMainWindow() { ao_app = parent; diff --git a/courtroom.h b/courtroom.h index 90ccdb3..932bbe3 100644 --- a/courtroom.h +++ b/courtroom.h @@ -3,6 +3,7 @@ #include "aoimage.h" #include "aobutton.h" +#include "aobuttongrid.h" #include "aopacket.h" #include @@ -84,17 +85,15 @@ private: QComboBox *ui_text_color; + QSlider *ui_music_slider; + QSlider *ui_sfx_slider; + QSlider *ui_blip_slider; AOImage *ui_muted; - - - //ui_charselect w/ icons - -signals: - -public slots: + AOImage *ui_char_select_background; + AOButtonGrid *char_button_grid; }; #endif // COURTROOM_H diff --git a/path_functions.cpp b/path_functions.cpp index 4a3cdb7..0282bd4 100644 --- a/path_functions.cpp +++ b/path_functions.cpp @@ -19,3 +19,13 @@ QString get_default_theme_path() { return get_base_path() + "themes/default/"; } + +QString get_character_path(QString p_character) +{ + return get_base_path() + "characters/" + p_character.toLower() + "/"; +} + +QString get_demothings_path() +{ + return get_base_path() + "misc/demothings/"; +} diff --git a/path_functions.h b/path_functions.h index eae5c75..67cbd29 100644 --- a/path_functions.h +++ b/path_functions.h @@ -6,5 +6,7 @@ QString get_base_path(); QString get_theme_path(); QString get_default_theme_path(); +QString get_character_path(QString p_character); +QString get_demothings_path(); #endif // PATH_FUNCTIONS_H