aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Skoland <davidskoland@gmail.com>2017-01-30 02:58:30 +0100
committerDavid Skoland <davidskoland@gmail.com>2017-01-30 02:58:30 +0100
commit922506261f420102375c8bb91836c1a0e7151ca3 (patch)
tree9f2d993bf77554814eec6e8eadddec287cd401c8
parent6e1f2cf20d7581e31350c428663a4a7af1dda914 (diff)
added AOScene class, and basic background functionality
-rw-r--r--Attorney_Online_remake.pro6
-rw-r--r--aoscene.cpp21
-rw-r--r--aoscene.h21
-rw-r--r--courtroom.cpp10
-rw-r--r--courtroom.h10
-rw-r--r--packet_distribution.cpp7
-rw-r--r--path_functions.cpp11
7 files changed, 84 insertions, 2 deletions
diff --git a/Attorney_Online_remake.pro b/Attorney_Online_remake.pro
index a34f049d..55f3d99b 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 00000000..d910a3ec
--- /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 00000000..f62235f4
--- /dev/null
+++ b/aoscene.h
@@ -0,0 +1,21 @@
+#ifndef AOSCENE_H
+#define AOSCENE_H
+
+#include <QLabel>
+
+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 e2a2a56f..46c27a1a 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 c1876d7d..63dfe4f9 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 <QMainWindow>
@@ -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 6d242783..6942b7e9 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 0093e4df..c4c24406 100644
--- a/path_functions.cpp
+++ b/path_functions.cpp
@@ -1,4 +1,5 @@
#include "aoapplication.h"
+#include "courtroom.h"
#include <QDir>
#include <QDebug>
@@ -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/";
+}