added AOScene class, and basic background functionality
This commit is contained in:
parent
6e1f2cf20d
commit
922506261f
@ -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
|
||||
|
21
aoscene.cpp
Normal file
21
aoscene.cpp
Normal file
@ -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);
|
||||
}
|
21
aoscene.h
Normal file
21
aoscene.h
Normal file
@ -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
|
@ -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()
|
||||
|
10
courtroom.h
10
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;
|
||||
|
@ -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")
|
||||
{
|
||||
|
@ -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/";
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user