added custom classes, started working on viewport. wt/ce sfx done
This commit is contained in:
parent
ba8b0e59d8
commit
9031779bc9
@ -32,7 +32,10 @@ SOURCES += main.cpp\
|
||||
courtroom.cpp \
|
||||
aocharbutton.cpp \
|
||||
hardware_functions.cpp \
|
||||
aoscene.cpp
|
||||
aoscene.cpp \
|
||||
aomovie.cpp \
|
||||
aocharselect.cpp \
|
||||
misc_functions.cpp
|
||||
|
||||
HEADERS += lobby.h \
|
||||
aoimage.h \
|
||||
@ -48,4 +51,7 @@ HEADERS += lobby.h \
|
||||
courtroom.h \
|
||||
aocharbutton.h \
|
||||
hardware_functions.h \
|
||||
aoscene.h
|
||||
aoscene.h \
|
||||
aomovie.h \
|
||||
aocharselect.h \
|
||||
misc_functions.h
|
||||
|
@ -80,6 +80,8 @@ public:
|
||||
QString get_default_theme_path();
|
||||
QString get_character_path(QString p_character);
|
||||
QString get_demothings_path();
|
||||
QString get_sounds_path();
|
||||
QString get_music_path();
|
||||
|
||||
//implementation in text_file_functions.cpp
|
||||
QString read_user_theme();
|
||||
|
6
aocharselect.cpp
Normal file
6
aocharselect.cpp
Normal file
@ -0,0 +1,6 @@
|
||||
#include "aocharselect.h"
|
||||
|
||||
AOCharSelect::AOCharSelect()
|
||||
{
|
||||
|
||||
}
|
12
aocharselect.h
Normal file
12
aocharselect.h
Normal file
@ -0,0 +1,12 @@
|
||||
#ifndef AOCHARSELECT_H
|
||||
#define AOCHARSELECT_H
|
||||
|
||||
#include <QLabel>
|
||||
|
||||
class AOCharSelect : public QLabel
|
||||
{
|
||||
public:
|
||||
AOCharSelect();
|
||||
};
|
||||
|
||||
#endif // AOCHARSELECT_H
|
57
aomovie.cpp
Normal file
57
aomovie.cpp
Normal file
@ -0,0 +1,57 @@
|
||||
#include "aomovie.h"
|
||||
|
||||
#include "file_functions.h"
|
||||
#include "courtroom.h"
|
||||
#include "misc_functions.h"
|
||||
|
||||
AOMovie::AOMovie(QWidget *p_parent, AOApplication *p_ao_app) : QLabel(p_parent)
|
||||
{
|
||||
ao_app = p_ao_app;
|
||||
|
||||
m_movie = new QMovie();
|
||||
|
||||
this->setMovie(m_movie);
|
||||
|
||||
connect(m_movie, SIGNAL(frameChanged(int)), this, SLOT(frame_change(int)));
|
||||
}
|
||||
|
||||
void AOMovie::play(QString p_gif)
|
||||
{
|
||||
QString gif_path = ao_app->get_theme_path() + p_gif;
|
||||
QString default_path = ao_app->get_default_theme_path() + p_gif;
|
||||
|
||||
if (file_exists(gif_path))
|
||||
m_movie->setFileName(gif_path);
|
||||
else
|
||||
m_movie->setFileName(default_path);
|
||||
|
||||
this->show();
|
||||
m_movie->start();
|
||||
}
|
||||
|
||||
void AOMovie::stop()
|
||||
{
|
||||
m_movie->stop();
|
||||
this->hide();
|
||||
}
|
||||
|
||||
void AOMovie::frame_change(int n_frame)
|
||||
{
|
||||
if (n_frame == (m_movie->frameCount() - 1))
|
||||
{
|
||||
//we need this or else the last frame wont show
|
||||
delay(m_movie->nextFrameDelay());
|
||||
|
||||
this->stop();
|
||||
|
||||
//signal connected to courtroom object, let it figure out what to do
|
||||
done();
|
||||
}
|
||||
}
|
||||
|
||||
void AOMovie::combo_resize(int w, int h)
|
||||
{
|
||||
QSize f_size(w, h);
|
||||
this->resize(f_size);
|
||||
m_movie->setScaledSize(f_size);
|
||||
}
|
32
aomovie.h
Normal file
32
aomovie.h
Normal file
@ -0,0 +1,32 @@
|
||||
#ifndef AOMOVIE_H
|
||||
#define AOMOVIE_H
|
||||
|
||||
#include <QLabel>
|
||||
#include <QMovie>
|
||||
|
||||
class Courtroom;
|
||||
class AOApplication;
|
||||
|
||||
class AOMovie : public QLabel
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
AOMovie(QWidget *p_parent, AOApplication *p_ao_app);
|
||||
|
||||
void play(QString p_gif);
|
||||
void combo_resize(int w, int h);
|
||||
void stop();
|
||||
|
||||
private:
|
||||
QMovie *m_movie;
|
||||
AOApplication *ao_app;
|
||||
|
||||
signals:
|
||||
void done();
|
||||
|
||||
private slots:
|
||||
void frame_change(int n_frame);
|
||||
};
|
||||
|
||||
#endif // AOMOVIE_H
|
11
aoscene.cpp
11
aoscene.cpp
@ -14,8 +14,15 @@ 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;
|
||||
|
||||
QPixmap background(background_path);
|
||||
QPixmap default_bg(default_path);
|
||||
|
||||
int w = this->width();
|
||||
int h = this->height();
|
||||
|
||||
|
||||
if (file_exists(background_path))
|
||||
this->setPixmap(background_path);
|
||||
this->setPixmap(background.scaled(w, h));
|
||||
else
|
||||
this->setPixmap(default_path);
|
||||
this->setPixmap(default_bg.scaled(w, h));
|
||||
}
|
||||
|
183
courtroom.cpp
183
courtroom.cpp
@ -15,13 +15,20 @@ Courtroom::Courtroom(AOApplication *p_ao_app) : QMainWindow()
|
||||
|
||||
char_button_mapper = new QSignalMapper(this);
|
||||
|
||||
sfx_player = new QSoundEffect(this);
|
||||
|
||||
ui_background = new AOImage(this, ao_app);
|
||||
|
||||
//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_vp_player_char = new AOMovie(this, ao_app);
|
||||
ui_vp_desk = new AOScene(this);
|
||||
ui_vp_chatbox = new AOImage(this, ao_app);
|
||||
ui_vp_showname = new QLabel(this);
|
||||
ui_vp_message = new QPlainTextEdit(this);
|
||||
ui_vp_testimony = new AOImage(this, ao_app);
|
||||
ui_vp_realization = new AOImage(this, ao_app);
|
||||
ui_vp_wtce = new AOMovie(this, ao_app);
|
||||
ui_vp_objection = new AOMovie(this, ao_app);
|
||||
|
||||
ui_ic_chatlog = new QPlainTextEdit(this);
|
||||
ui_ic_chatlog->setReadOnly(true);
|
||||
@ -155,14 +162,20 @@ Courtroom::Courtroom(AOApplication *p_ao_app) : QMainWindow()
|
||||
|
||||
ui_spectator = new AOButton(ui_char_select_background, ao_app);
|
||||
|
||||
connect(ui_vp_objection, SIGNAL(done()), this, SLOT(objection_done()));
|
||||
|
||||
connect(ui_ooc_chat_message, SIGNAL(returnPressed()), this, SLOT(on_ooc_return_pressed()));
|
||||
connect(ui_ooc_toggle, SIGNAL(clicked()), this, SLOT(on_ooc_toggle_clicked()));
|
||||
connect(ui_change_character, SIGNAL(clicked()), this, SLOT(on_change_character_clicked()));
|
||||
|
||||
connect(ui_witness_testimony, SIGNAL(clicked()), this, SLOT(on_witness_testimony_clicked()));
|
||||
connect(ui_cross_examination, SIGNAL(clicked()), this, SLOT(on_cross_examination_clicked()));
|
||||
|
||||
connect(ui_change_character, SIGNAL(clicked()), this, SLOT(on_change_character_clicked()));
|
||||
connect(ui_reload_theme, SIGNAL(clicked()), this, SLOT(on_reload_theme_clicked()));
|
||||
connect(ui_back_to_lobby, SIGNAL(clicked()), this, SLOT(on_back_to_lobby_clicked()));
|
||||
connect(ui_call_mod, SIGNAL(clicked()), this, SLOT(on_call_mod_clicked()));
|
||||
|
||||
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()));
|
||||
|
||||
@ -173,14 +186,83 @@ Courtroom::Courtroom(AOApplication *p_ao_app) : QMainWindow()
|
||||
|
||||
void Courtroom::set_widgets()
|
||||
{
|
||||
QString design_ini_path = ao_app->get_theme_path() + "courtroom_design.ini";
|
||||
QString default_ini_path = ao_app->get_base_path() + "themes/default/courtroom_design.ini";
|
||||
|
||||
pos_size_type f_courtroom = ao_app->get_pos_and_size("courtroom", design_ini_path);
|
||||
pos_size_type f_viewport = ao_app->get_pos_and_size("viewport", design_ini_path);
|
||||
|
||||
if (f_courtroom.width < 0 || f_courtroom.height < 0)
|
||||
{
|
||||
f_courtroom = ao_app->get_pos_and_size("courtroom", default_ini_path);
|
||||
if (f_courtroom.width < 0 || f_courtroom.height < 0)
|
||||
{
|
||||
qDebug() << "ERROR: did not find courtroom width or height in courtroom_design.ini!";
|
||||
//T0D0: add error box then quit application, this is not recoverable
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (f_viewport.width < 0 || f_viewport.height < 0)
|
||||
{
|
||||
f_viewport = ao_app->get_pos_and_size("viewport", default_ini_path);
|
||||
if (f_viewport.width < 0 || f_viewport.height < 0)
|
||||
{
|
||||
qDebug() << "ERROR: did not find viewport width or height in courtroom_design.ini!";
|
||||
//T0D0: same, critical error
|
||||
}
|
||||
}
|
||||
|
||||
m_courtroom_width = f_courtroom.width;
|
||||
m_courtroom_height = f_courtroom.height;
|
||||
|
||||
m_viewport_x = f_viewport.x;
|
||||
m_viewport_y = f_viewport.y;
|
||||
m_viewport_width = f_viewport.width;
|
||||
m_viewport_height = f_viewport.height;
|
||||
|
||||
this->setFixedSize(m_courtroom_width, m_courtroom_height);
|
||||
this->setWindowTitle("Attorney Online 2: Server name here");
|
||||
|
||||
ui_background->set_image("courtroombackground.png");
|
||||
ui_background->move(0, 0);
|
||||
ui_background->resize(m_courtroom_width, m_courtroom_height);
|
||||
|
||||
//viewport elements like background, desk, etc. go here
|
||||
ui_vp_background->move(m_viewport_x, m_viewport_y);
|
||||
ui_vp_background->resize(m_viewport_width, m_viewport_height);
|
||||
|
||||
ui_vp_player_char->move(m_viewport_x, m_viewport_y);
|
||||
ui_vp_player_char->combo_resize(m_viewport_width, m_viewport_height);
|
||||
|
||||
ui_vp_desk->move(m_viewport_x, m_viewport_y);
|
||||
ui_vp_desk->resize(m_viewport_width, m_viewport_height);
|
||||
|
||||
ui_vp_chatbox->move(m_viewport_x, m_viewport_y);
|
||||
ui_vp_chatbox->resize(m_viewport_width, m_viewport_height);
|
||||
|
||||
ui_vp_showname->move(m_viewport_x, m_viewport_y);
|
||||
ui_vp_showname->resize(m_viewport_width, m_viewport_height);
|
||||
|
||||
ui_vp_message->move(m_viewport_x, m_viewport_y);
|
||||
ui_vp_message->resize(m_viewport_width, m_viewport_height);
|
||||
|
||||
//T0D0: resize it properly
|
||||
//D3BUG START
|
||||
//obscures some things
|
||||
ui_vp_message->hide();
|
||||
//D3BUG END
|
||||
|
||||
ui_vp_testimony->move(m_viewport_x, m_viewport_y);
|
||||
ui_vp_testimony->resize(m_viewport_width, m_viewport_height);
|
||||
|
||||
ui_vp_realization->move(m_viewport_x, m_viewport_y);
|
||||
ui_vp_realization->resize(m_viewport_width, m_viewport_height);
|
||||
|
||||
ui_vp_wtce->move(m_viewport_x, m_viewport_y);
|
||||
ui_vp_wtce->combo_resize(m_viewport_width, m_viewport_height);
|
||||
|
||||
ui_vp_objection->move(m_viewport_x, m_viewport_y);
|
||||
ui_vp_objection->combo_resize(m_viewport_width, m_viewport_height);
|
||||
|
||||
set_size_and_pos(ui_ic_chatlog, "ic_chatlog");
|
||||
ui_ic_chatlog->setStyleSheet("background-color: rgba(0, 0, 0, 0);"
|
||||
@ -453,12 +535,50 @@ void Courtroom::enter_courtroom(int p_cid)
|
||||
|
||||
void Courtroom::append_ms_chatmessage(QString f_message)
|
||||
{
|
||||
const QTextCursor old_cursor = ui_ms_chatlog->textCursor();
|
||||
const int old_scrollbar_value = ui_ms_chatlog->verticalScrollBar()->value();
|
||||
const bool is_scrolled_down = old_scrollbar_value == ui_ms_chatlog->verticalScrollBar()->maximum();
|
||||
|
||||
ui_ms_chatlog->moveCursor(QTextCursor::End);
|
||||
|
||||
ui_ms_chatlog->appendPlainText(f_message);
|
||||
|
||||
if (old_cursor.hasSelection() || !is_scrolled_down)
|
||||
{
|
||||
// The user has selected text or scrolled away from the bottom: maintain position.
|
||||
ui_ms_chatlog->setTextCursor(old_cursor);
|
||||
ui_ms_chatlog->verticalScrollBar()->setValue(old_scrollbar_value);
|
||||
}
|
||||
else
|
||||
{
|
||||
// The user hasn't selected any text and the scrollbar is at the bottom: scroll to the bottom.
|
||||
ui_ms_chatlog->moveCursor(QTextCursor::End);
|
||||
ui_ms_chatlog->verticalScrollBar()->setValue(ui_ms_chatlog->verticalScrollBar()->maximum());
|
||||
}
|
||||
}
|
||||
|
||||
void Courtroom::append_server_chatmessage(QString f_message)
|
||||
{
|
||||
const QTextCursor old_cursor = ui_server_chatlog->textCursor();
|
||||
const int old_scrollbar_value = ui_server_chatlog->verticalScrollBar()->value();
|
||||
const bool is_scrolled_down = old_scrollbar_value == ui_server_chatlog->verticalScrollBar()->maximum();
|
||||
|
||||
ui_server_chatlog->moveCursor(QTextCursor::End);
|
||||
|
||||
ui_server_chatlog->appendPlainText(f_message);
|
||||
|
||||
if (old_cursor.hasSelection() || !is_scrolled_down)
|
||||
{
|
||||
// The user has selected text or scrolled away from the bottom: maintain position.
|
||||
ui_server_chatlog->setTextCursor(old_cursor);
|
||||
ui_server_chatlog->verticalScrollBar()->setValue(old_scrollbar_value);
|
||||
}
|
||||
else
|
||||
{
|
||||
// The user hasn't selected any text and the scrollbar is at the bottom: scroll to the bottom.
|
||||
ui_server_chatlog->moveCursor(QTextCursor::End);
|
||||
ui_server_chatlog->verticalScrollBar()->setValue(ui_server_chatlog->verticalScrollBar()->maximum());
|
||||
}
|
||||
}
|
||||
|
||||
void Courtroom::handle_chatmessage(QStringList *p_contents)
|
||||
@ -492,11 +612,46 @@ void Courtroom::handle_chatmessage(QStringList *p_contents)
|
||||
|
||||
//D3BUG START
|
||||
|
||||
//ui_vp_background->set_image("defenseempty.png");
|
||||
ui_vp_background->set_image("defenseempty.png");
|
||||
|
||||
//D3BUG END
|
||||
}
|
||||
|
||||
void Courtroom::objection_done()
|
||||
{
|
||||
//T0D0: play preanim, advance to step 2 in chat message handling
|
||||
}
|
||||
|
||||
void Courtroom::handle_wtce(QString p_wtce)
|
||||
{
|
||||
//witness testimony
|
||||
if (p_wtce == "testimony1")
|
||||
{
|
||||
QString wt_path = ao_app->get_sounds_path() + "sfx-testimony2.wav";
|
||||
QUrl wt_sfx(QUrl::fromLocalFile(wt_path));
|
||||
|
||||
sfx_player->stop();
|
||||
ui_vp_wtce->stop();
|
||||
sfx_player->setSource(wt_sfx);
|
||||
|
||||
sfx_player->play();
|
||||
ui_vp_wtce->play("witnesstestimony.gif");
|
||||
}
|
||||
//cross examination
|
||||
else if (p_wtce == "testimony2")
|
||||
{
|
||||
QString ce_path = ao_app->get_sounds_path() + "sfx-testimony.wav";
|
||||
QUrl ce_sfx(QUrl::fromLocalFile(ce_path));
|
||||
|
||||
sfx_player->stop();
|
||||
ui_vp_wtce->stop();
|
||||
sfx_player->setSource(ce_sfx);
|
||||
|
||||
sfx_player->play();
|
||||
ui_vp_wtce->play("crossexamination.gif");
|
||||
}
|
||||
}
|
||||
|
||||
void Courtroom::on_ooc_return_pressed()
|
||||
{
|
||||
if (ui_ooc_chat_message->text() == "" || ui_ooc_chat_name->text() == "")
|
||||
@ -536,6 +691,16 @@ void Courtroom::on_ooc_toggle_clicked()
|
||||
}
|
||||
}
|
||||
|
||||
void Courtroom::on_witness_testimony_clicked()
|
||||
{
|
||||
ao_app->send_server_packet(new AOPacket("RT#testimony1#%"));
|
||||
}
|
||||
|
||||
void Courtroom::on_cross_examination_clicked()
|
||||
{
|
||||
ao_app->send_server_packet(new AOPacket("RT#testimony2#%"));
|
||||
}
|
||||
|
||||
void Courtroom::on_change_character_clicked()
|
||||
{
|
||||
ui_char_select_background->show();
|
||||
|
37
courtroom.h
37
courtroom.h
@ -6,6 +6,7 @@
|
||||
#include "aocharbutton.h"
|
||||
#include "aopacket.h"
|
||||
#include "aoscene.h"
|
||||
#include "aomovie.h"
|
||||
#include "datatypes.h"
|
||||
|
||||
#include <QMainWindow>
|
||||
@ -18,6 +19,7 @@
|
||||
#include <QVector>
|
||||
#include <QCloseEvent>
|
||||
#include <QSignalMapper>
|
||||
#include <QSoundEffect>
|
||||
|
||||
class AOApplication;
|
||||
|
||||
@ -48,20 +50,21 @@ public:
|
||||
void append_server_chatmessage(QString f_message);
|
||||
|
||||
void handle_chatmessage(QStringList *p_contents);
|
||||
void handle_wtce(QString p_wtce);
|
||||
|
||||
~Courtroom();
|
||||
|
||||
private:
|
||||
AOApplication *ao_app;
|
||||
|
||||
const int m_courtroom_width = 714;
|
||||
const int m_courtroom_height = 668;
|
||||
int m_courtroom_width = 714;
|
||||
int m_courtroom_height = 668;
|
||||
|
||||
const int m_viewport_x = 0;
|
||||
const int m_viewport_y = 0;
|
||||
int m_viewport_x = 0;
|
||||
int m_viewport_y = 0;
|
||||
|
||||
const int m_viewport_width = 256;
|
||||
const int m_viewport_height = 192;
|
||||
int m_viewport_width = 256;
|
||||
int m_viewport_height = 192;
|
||||
|
||||
QVector<char_type> char_list;
|
||||
QVector<evi_type> evidence_list;
|
||||
@ -81,18 +84,26 @@ private:
|
||||
|
||||
QString current_background = "gs4";
|
||||
|
||||
QSoundEffect *sfx_player;
|
||||
|
||||
AOImage *ui_background;
|
||||
|
||||
//T0D0: add viewport elements like background, desk, etc.
|
||||
|
||||
AOScene *ui_vp_background;
|
||||
AOMovie *ui_vp_player_char;
|
||||
AOScene *ui_vp_desk;
|
||||
AOImage *ui_vp_chatbox;
|
||||
QLabel *ui_vp_showname;
|
||||
QPlainTextEdit *ui_vp_message;
|
||||
AOImage *ui_vp_testimony;
|
||||
AOImage *ui_vp_realization;
|
||||
AOMovie *ui_vp_wtce;
|
||||
AOMovie *ui_vp_objection;
|
||||
|
||||
QPlainTextEdit *ui_ic_chatlog;
|
||||
|
||||
QPlainTextEdit *ui_ms_chatlog;
|
||||
QPlainTextEdit *ui_server_chatlog;
|
||||
|
||||
|
||||
QListWidget *ui_mute_list;
|
||||
QListWidget *ui_area_list;
|
||||
QListWidget *ui_music_list;
|
||||
@ -122,6 +133,7 @@ private:
|
||||
AOButton *ui_take_that;
|
||||
|
||||
AOButton *ui_ooc_toggle;
|
||||
|
||||
AOButton *ui_witness_testimony;
|
||||
AOButton *ui_cross_examination;
|
||||
|
||||
@ -166,10 +178,17 @@ private:
|
||||
AOButton *ui_char_select_right;
|
||||
|
||||
AOButton *ui_spectator;
|
||||
|
||||
public slots:
|
||||
void objection_done();
|
||||
|
||||
private slots:
|
||||
void on_ooc_return_pressed();
|
||||
void on_ooc_toggle_clicked();
|
||||
|
||||
void on_witness_testimony_clicked();
|
||||
void on_cross_examination_clicked();
|
||||
|
||||
void on_change_character_clicked();
|
||||
void on_reload_theme_clicked();
|
||||
void on_call_mod_clicked();
|
||||
|
24
lobby.cpp
24
lobby.cpp
@ -5,6 +5,7 @@
|
||||
#include "networkmanager.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QScrollBar>
|
||||
|
||||
Lobby::Lobby(AOApplication *p_ao_app) : QMainWindow()
|
||||
{
|
||||
@ -307,9 +308,28 @@ void Lobby::list_favorites()
|
||||
}
|
||||
}
|
||||
|
||||
void Lobby::append_chatmessage(QString p_message_line)
|
||||
void Lobby::append_chatmessage(QString f_message)
|
||||
{
|
||||
ui_chatbox->appendPlainText(p_message_line);
|
||||
const QTextCursor old_cursor = ui_chatbox->textCursor();
|
||||
const int old_scrollbar_value = ui_chatbox->verticalScrollBar()->value();
|
||||
const bool is_scrolled_down = old_scrollbar_value == ui_chatbox->verticalScrollBar()->maximum();
|
||||
|
||||
ui_chatbox->moveCursor(QTextCursor::End);
|
||||
|
||||
ui_chatbox->appendPlainText(f_message);
|
||||
|
||||
if (old_cursor.hasSelection() || !is_scrolled_down)
|
||||
{
|
||||
// The user has selected text or scrolled away from the bottom: maintain position.
|
||||
ui_chatbox->setTextCursor(old_cursor);
|
||||
ui_chatbox->verticalScrollBar()->setValue(old_scrollbar_value);
|
||||
}
|
||||
else
|
||||
{
|
||||
// The user hasn't selected any text and the scrollbar is at the bottom: scroll to the bottom.
|
||||
ui_chatbox->moveCursor(QTextCursor::End);
|
||||
ui_chatbox->verticalScrollBar()->setValue(ui_chatbox->verticalScrollBar()->maximum());
|
||||
}
|
||||
}
|
||||
|
||||
void Lobby::set_player_count(int players_online, int max_players)
|
||||
|
2
lobby.h
2
lobby.h
@ -24,7 +24,7 @@ public:
|
||||
void set_widgets();
|
||||
void list_servers();
|
||||
void list_favorites();
|
||||
void append_chatmessage(QString p_message_line);
|
||||
void append_chatmessage(QString f_message);
|
||||
void set_player_count(int players_online, int max_players);
|
||||
void set_loading_text(QString p_text);
|
||||
void show_loading_overlay(){ui_loading_background->show();}
|
||||
|
30
misc_functions.cpp
Normal file
30
misc_functions.cpp
Normal file
@ -0,0 +1,30 @@
|
||||
#include "misc_functions.h"
|
||||
|
||||
#include <QTime>
|
||||
#include <QCoreApplication>
|
||||
|
||||
void delay(int p_milliseconds)
|
||||
{
|
||||
QTime dieTime = QTime::currentTime().addMSecs(p_milliseconds);
|
||||
|
||||
while(QTime::currentTime() < dieTime)
|
||||
QCoreApplication::processEvents(QEventLoop::AllEvents, 100);
|
||||
}
|
||||
|
||||
//alternates between true and false every time it is called. useful for certain optimization
|
||||
bool cyclic_function()
|
||||
{
|
||||
static bool cycle = true;
|
||||
|
||||
if (cycle)
|
||||
{
|
||||
cycle = false;
|
||||
return cycle;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
cycle = true;
|
||||
return cycle;
|
||||
}
|
||||
}
|
7
misc_functions.h
Normal file
7
misc_functions.h
Normal file
@ -0,0 +1,7 @@
|
||||
#ifndef MISC_FUNCTIONS_H
|
||||
#define MISC_FUNCTIONS_H
|
||||
|
||||
void delay(int p_milliseconds);
|
||||
bool cyclic_function();
|
||||
|
||||
#endif // MISC_FUNCTIONS_H
|
@ -55,7 +55,7 @@ void AOApplication::ms_packet_received(AOPacket *p_packet)
|
||||
else if (f_contents.size() >= 2)
|
||||
message_line = f_contents.at(0) + ": " + f_contents.at(1);
|
||||
else
|
||||
return;
|
||||
goto end;
|
||||
|
||||
if (lobby_constructed)
|
||||
{
|
||||
@ -66,6 +66,10 @@ void AOApplication::ms_packet_received(AOPacket *p_packet)
|
||||
w_courtroom->append_ms_chatmessage(message_line);
|
||||
}
|
||||
}
|
||||
|
||||
end:
|
||||
|
||||
delete p_packet;
|
||||
}
|
||||
|
||||
void AOApplication::server_packet_received(AOPacket *p_packet)
|
||||
@ -82,7 +86,7 @@ void AOApplication::server_packet_received(AOPacket *p_packet)
|
||||
if (header == "decryptor")
|
||||
{
|
||||
if (f_contents.size() == 0)
|
||||
return;
|
||||
goto end;
|
||||
|
||||
//you may ask where 322 comes from. that would be a good question.
|
||||
s_decryptor = fanta_decrypt(f_contents.at(0), 322).toUInt();
|
||||
@ -96,12 +100,12 @@ void AOApplication::server_packet_received(AOPacket *p_packet)
|
||||
else if (header == "ID")
|
||||
{
|
||||
if (f_contents.size() < 1)
|
||||
return;
|
||||
goto end;
|
||||
|
||||
s_pv = f_contents.at(0).toInt();
|
||||
|
||||
if (f_contents.size() < 2)
|
||||
return;
|
||||
goto end;
|
||||
|
||||
//T0D0: store server version
|
||||
}
|
||||
@ -110,7 +114,7 @@ void AOApplication::server_packet_received(AOPacket *p_packet)
|
||||
if (f_contents.size() < 2)
|
||||
{
|
||||
qDebug() << "W: malformed packet!";
|
||||
return;
|
||||
goto end;
|
||||
}
|
||||
|
||||
QString message_line = f_contents.at(0) + ": " + f_contents.at(1);
|
||||
@ -121,14 +125,14 @@ void AOApplication::server_packet_received(AOPacket *p_packet)
|
||||
else if (header == "PN")
|
||||
{
|
||||
if (f_contents.size() < 2)
|
||||
return;
|
||||
goto end;
|
||||
|
||||
w_lobby->set_player_count(f_contents.at(0).toInt(), f_contents.at(1).toInt());
|
||||
}
|
||||
else if (header == "SI")
|
||||
{
|
||||
if (f_contents.size() < 3)
|
||||
return;
|
||||
goto end;
|
||||
|
||||
char_list_size = f_contents.at(0).toInt();
|
||||
loaded_chars = 0;
|
||||
@ -166,7 +170,7 @@ void AOApplication::server_packet_received(AOPacket *p_packet)
|
||||
else if (header == "CI")
|
||||
{
|
||||
if (!courtroom_constructed)
|
||||
return;
|
||||
goto end;
|
||||
|
||||
for (int n_element = 0 ; n_element < f_contents.size() ; n_element += 2)
|
||||
{
|
||||
@ -200,20 +204,20 @@ void AOApplication::server_packet_received(AOPacket *p_packet)
|
||||
}
|
||||
else if (header == "EI"){
|
||||
if (!courtroom_constructed)
|
||||
return;
|
||||
goto end;
|
||||
|
||||
|
||||
// +1 because evidence starts at 1 rather than 0 for whatever reason
|
||||
//enjoy fanta
|
||||
if (f_contents.at(0).toInt() != loaded_evidence + 1)
|
||||
return;
|
||||
goto end;
|
||||
|
||||
if (f_contents.size() < 2)
|
||||
return;
|
||||
goto end;
|
||||
|
||||
QStringList sub_elements = f_contents.at(1).split("&");
|
||||
if (sub_elements.size() < 4)
|
||||
return;
|
||||
goto end;
|
||||
|
||||
evi_type f_evi;
|
||||
f_evi.name = sub_elements.at(0);
|
||||
@ -234,7 +238,7 @@ void AOApplication::server_packet_received(AOPacket *p_packet)
|
||||
else if (header == "EM")
|
||||
{
|
||||
if (!courtroom_constructed)
|
||||
return;
|
||||
goto end;
|
||||
|
||||
for (int n_element = 0 ; n_element < f_contents.size() ; n_element += 2)
|
||||
{
|
||||
@ -269,7 +273,7 @@ void AOApplication::server_packet_received(AOPacket *p_packet)
|
||||
else if (header == "DONE")
|
||||
{
|
||||
if (!courtroom_constructed)
|
||||
return;
|
||||
goto end;
|
||||
|
||||
w_courtroom->set_char_select_page();
|
||||
|
||||
@ -282,7 +286,7 @@ void AOApplication::server_packet_received(AOPacket *p_packet)
|
||||
else if (header == "BN")
|
||||
{
|
||||
if (f_contents.size() < 1)
|
||||
return;
|
||||
goto end;
|
||||
|
||||
if (courtroom_constructed)
|
||||
w_courtroom->set_background(f_contents.at(0));
|
||||
@ -291,7 +295,7 @@ void AOApplication::server_packet_received(AOPacket *p_packet)
|
||||
else if (header == "PV")
|
||||
{
|
||||
if (f_contents.size() < 3)
|
||||
return;
|
||||
goto end;
|
||||
|
||||
w_courtroom->enter_courtroom(f_contents.at(2).toInt());
|
||||
}
|
||||
@ -300,6 +304,15 @@ void AOApplication::server_packet_received(AOPacket *p_packet)
|
||||
if (courtroom_constructed)
|
||||
w_courtroom->handle_chatmessage(&p_packet->get_contents());
|
||||
}
|
||||
else if (header == "RT")
|
||||
{
|
||||
if (f_contents.size() < 1)
|
||||
goto end;
|
||||
|
||||
w_courtroom->handle_wtce(f_contents.at(0));
|
||||
}
|
||||
|
||||
end:
|
||||
|
||||
delete p_packet;
|
||||
}
|
||||
|
@ -33,6 +33,14 @@ QString AOApplication::get_demothings_path()
|
||||
{
|
||||
return get_base_path() + "misc/demothings/";
|
||||
}
|
||||
QString AOApplication::get_sounds_path()
|
||||
{
|
||||
return get_base_path() + "sounds/general/";
|
||||
}
|
||||
QString AOApplication::get_music_path()
|
||||
{
|
||||
return get_base_path() + "sounds/music/";
|
||||
}
|
||||
|
||||
QString Courtroom::get_background_path()
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user