From 922506261f420102375c8bb91836c1a0e7151ca3 Mon Sep 17 00:00:00 2001 From: David Skoland Date: Mon, 30 Jan 2017 02:58:30 +0100 Subject: [PATCH] added AOScene class, and basic background functionality --- Attorney_Online_remake.pro | 6 ++++-- aoscene.cpp | 21 +++++++++++++++++++++ aoscene.h | 21 +++++++++++++++++++++ courtroom.cpp | 10 ++++++++++ courtroom.h | 10 ++++++++++ packet_distribution.cpp | 7 +++++++ path_functions.cpp | 11 +++++++++++ 7 files changed, 84 insertions(+), 2 deletions(-) create mode 100644 aoscene.cpp create mode 100644 aoscene.h diff --git a/Attorney_Online_remake.pro b/Attorney_Online_remake.pro index a34f049..55f3d99 100644 --- a/Attorney_Online_remake.pro +++ b/Attorney_Online_remake.pro @@ -31,7 +31,8 @@ SOURCES += main.cpp\ encryption_functions.cpp \ courtroom.cpp \ aocharbutton.cpp \ - hardware_functions.cpp + hardware_functions.cpp \ + aoscene.cpp HEADERS += lobby.h \ aoimage.h \ @@ -46,4 +47,5 @@ HEADERS += lobby.h \ encryption_functions.h \ courtroom.h \ aocharbutton.h \ - hardware_functions.h + hardware_functions.h \ + aoscene.h diff --git a/aoscene.cpp b/aoscene.cpp new file mode 100644 index 0000000..d910a3e --- /dev/null +++ b/aoscene.cpp @@ -0,0 +1,21 @@ +#include "aoscene.h" + +#include "courtroom.h" + +#include "file_functions.h" + +AOScene::AOScene(Courtroom *parent) : QLabel(parent) +{ + m_courtroom = parent; +} + +void AOScene::set_image(QString p_image) +{ + QString background_path = m_courtroom->get_background_path() + p_image; + QString default_path = m_courtroom->get_default_background_path() + p_image; + + if (file_exists(background_path)) + this->setPixmap(background_path); + else + this->setPixmap(default_path); +} diff --git a/aoscene.h b/aoscene.h new file mode 100644 index 0000000..f62235f --- /dev/null +++ b/aoscene.h @@ -0,0 +1,21 @@ +#ifndef AOSCENE_H +#define AOSCENE_H + +#include + +class Courtroom; + +class AOScene : public QLabel +{ + Q_OBJECT +public: + explicit AOScene(Courtroom *parent); + + void set_image(QString p_image); + +private: + Courtroom *m_courtroom; + +}; + +#endif // AOSCENE_H diff --git a/courtroom.cpp b/courtroom.cpp index e2a2a56..46c27a1 100644 --- a/courtroom.cpp +++ b/courtroom.cpp @@ -18,6 +18,10 @@ Courtroom::Courtroom(AOApplication *p_ao_app) : QMainWindow() //viewport elements like background, desk, etc. + ui_vp_background = new AOScene(this); + ui_vp_background->move(m_viewport_x, m_viewport_y); + ui_vp_background->resize(m_viewport_width, m_viewport_height); + ui_ic_chatlog = new QPlainTextEdit(this); ui_ic_chatlog->setReadOnly(true); @@ -482,6 +486,12 @@ void Courtroom::handle_chatmessage(QStringList *p_contents) } //T0D0: play objection gif->preanimation if there is any + + //D3BUG START + + ui_vp_background->set_image("defenseempty.png"); + + //D3BUG END } void Courtroom::on_ooc_return_pressed() diff --git a/courtroom.h b/courtroom.h index c1876d7..63dfe4f 100644 --- a/courtroom.h +++ b/courtroom.h @@ -5,6 +5,7 @@ #include "aobutton.h" #include "aocharbutton.h" #include "aopacket.h" +#include "aoscene.h" #include "datatypes.h" #include @@ -35,6 +36,11 @@ public: 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){current_background = p_background;} + + //implementations in path_functions.cpp + QString get_background_path(); + QString get_default_background_path(); void enter_courtroom(int p_cid); @@ -73,10 +79,14 @@ private: //wether the ooc chat is server or master chat, true is server bool server_ooc = true; + QString current_background = "gs4"; + AOImage *ui_background; //T0D0: add viewport elements like background, desk, etc. + AOScene *ui_vp_background; + QPlainTextEdit *ui_ic_chatlog; QPlainTextEdit *ui_ms_chatlog; diff --git a/packet_distribution.cpp b/packet_distribution.cpp index 6d24278..6942b7e 100644 --- a/packet_distribution.cpp +++ b/packet_distribution.cpp @@ -279,6 +279,13 @@ void AOApplication::server_packet_received(AOPacket *p_packet) destruct_lobby(); } + else if (header == "BN") + { + if (f_contents.size() < 1) + return; + + w_courtroom->set_background(f_contents.at(0)); + } //server accepting char request(CC) packet else if (header == "PV") { diff --git a/path_functions.cpp b/path_functions.cpp index 0093e4d..c4c2440 100644 --- a/path_functions.cpp +++ b/path_functions.cpp @@ -1,4 +1,5 @@ #include "aoapplication.h" +#include "courtroom.h" #include #include @@ -32,3 +33,13 @@ QString AOApplication::get_demothings_path() { return get_base_path() + "misc/demothings/"; } + +QString Courtroom::get_background_path() +{ + return ao_app->get_base_path() + "background/" + current_background.toLower() + "/"; +} + +QString Courtroom::get_default_background_path() +{ + return ao_app->get_base_path() + "background/gs4/"; +}