aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Attorney_Online_remake.pro6
-rw-r--r--aoevidencedisplay.cpp100
-rw-r--r--aoevidencedisplay.h31
-rw-r--r--aosfxplayer.cpp5
-rw-r--r--aosfxplayer.h1
-rw-r--r--courtroom.cpp25
-rw-r--r--courtroom.h2
-rw-r--r--evidence.cpp1
8 files changed, 167 insertions, 4 deletions
diff --git a/Attorney_Online_remake.pro b/Attorney_Online_remake.pro
index e132277b..3f7e02ed 100644
--- a/Attorney_Online_remake.pro
+++ b/Attorney_Online_remake.pro
@@ -46,7 +46,8 @@ SOURCES += main.cpp\
charselect.cpp \
aotextarea.cpp \
aolineedit.cpp \
- aotextedit.cpp
+ aotextedit.cpp \
+ aoevidencedisplay.cpp
HEADERS += lobby.h \
aoimage.h \
@@ -74,7 +75,8 @@ HEADERS += lobby.h \
aoevidencebutton.h \
aotextarea.h \
aolineedit.h \
- aotextedit.h
+ aotextedit.h \
+ aoevidencedisplay.h
unix:LIBS += -L$$PWD -lbass
win32:LIBS += "$$PWD/bass.dll"
diff --git a/aoevidencedisplay.cpp b/aoevidencedisplay.cpp
new file mode 100644
index 00000000..20be4537
--- /dev/null
+++ b/aoevidencedisplay.cpp
@@ -0,0 +1,100 @@
+#include <QDebug>
+
+#include "aoevidencedisplay.h"
+
+#include "file_functions.h"
+#include "datatypes.h"
+#include "misc_functions.h"
+
+AOEvidenceDisplay::AOEvidenceDisplay(QWidget *p_parent, AOApplication *p_ao_app) : QLabel(p_parent)
+{
+ ao_app = p_ao_app;
+
+ evidence_movie = new QMovie(this);
+ evidence_icon = new QLabel(this);
+ sfx_player = new AOSfxPlayer(this, ao_app);
+
+ connect(evidence_movie, SIGNAL(frameChanged(int)), this, SLOT(frame_change(int)));
+}
+
+void AOEvidenceDisplay::show_evidence(QString p_evidence_image, bool is_left_side, int p_volume)
+{
+ this->reset();
+
+ sfx_player->set_volume(p_volume);
+
+ QString f_evidence_path = ao_app->get_evidence_path() + p_evidence_image;
+
+ QPixmap f_pixmap(f_evidence_path);
+
+ QString final_gif_path;
+ QString gif_name;
+ QString icon_identifier;
+
+ if (is_left_side)
+ {
+ icon_identifier = "left_evidence_icon";
+ gif_name = "evidence_appear_left.gif";
+ }
+ else
+ {
+ icon_identifier = "right_evidence_icon";
+ gif_name = "evidence_appear_right.gif";
+ }
+
+ pos_size_type icon_dimensions = ao_app->get_element_dimensions(icon_identifier, "courtroom_design.ini");
+
+ evidence_icon->move(icon_dimensions.x, icon_dimensions.y);
+ evidence_icon->resize(icon_dimensions.width, icon_dimensions.height);
+
+ evidence_icon->setPixmap(f_pixmap.scaled(evidence_icon->width(), evidence_icon->height(), Qt::IgnoreAspectRatio));
+
+ QString f_default_gif_path = ao_app->get_default_theme_path() + gif_name;
+ QString f_gif_path = ao_app->get_theme_path() + gif_name;
+
+ if (file_exists(f_gif_path))
+ final_gif_path = f_gif_path;
+ else
+ final_gif_path = f_default_gif_path;
+
+ evidence_movie->setFileName(final_gif_path);
+
+ if(evidence_movie->frameCount() < 1)
+ return;
+
+ this->setMovie(evidence_movie);
+
+ evidence_movie->start();
+ sfx_player->play(ao_app->get_sfx("evidence_present", "courtroom_sounds.ini"));
+}
+
+void AOEvidenceDisplay::frame_change(int p_frame)
+{
+ qDebug() << "total evi frames: " << evidence_movie->frameCount();
+ qDebug() << "evi_frame: " << p_frame;
+ if (p_frame == (evidence_movie->frameCount() - 1))
+ {
+ //we need this or else the last frame wont show
+ delay(evidence_movie->nextFrameDelay());
+
+ evidence_movie->stop();
+ this->clear();
+
+ evidence_icon->show();
+ }
+}
+
+void AOEvidenceDisplay::reset()
+{
+ sfx_player->stop();
+ evidence_movie->stop();
+ evidence_icon->hide();
+ this->clear();
+}
+
+QLabel* AOEvidenceDisplay::get_evidence_icon()
+{
+ return evidence_icon;
+}
+
+
diff --git a/aoevidencedisplay.h b/aoevidencedisplay.h
new file mode 100644
index 00000000..b973a296
--- /dev/null
+++ b/aoevidencedisplay.h
@@ -0,0 +1,31 @@
+#ifndef AOEVIDENCEDISPLAY_H
+#define AOEVIDENCEDISPLAY_H
+
+#include <QLabel>
+#include <QMovie>
+
+#include "aoapplication.h"
+#include "aosfxplayer.h"
+
+class AOEvidenceDisplay : public QLabel
+{
+ Q_OBJECT
+
+public:
+ AOEvidenceDisplay(QWidget *p_parent, AOApplication *p_ao_app);
+
+ void show_evidence(QString p_evidence_image, bool is_left_side, int p_volume);
+ QLabel* get_evidence_icon();
+ void reset();
+
+private:
+ AOApplication *ao_app;
+ QMovie *evidence_movie;
+ QLabel *evidence_icon;
+ AOSfxPlayer *sfx_player;
+
+private slots:
+ void frame_change(int p_frame);
+};
+
+#endif // AOEVIDENCEDISPLAY_H
diff --git a/aosfxplayer.cpp b/aosfxplayer.cpp
index 394fabd1..b783616d 100644
--- a/aosfxplayer.cpp
+++ b/aosfxplayer.cpp
@@ -30,6 +30,11 @@ void AOSfxPlayer::play(QString p_sfx, QString p_char)
BASS_ChannelPlay(m_stream, false);
}
+void AOSfxPlayer::stop()
+{
+ BASS_ChannelStop(m_stream);
+}
+
void AOSfxPlayer::set_volume(int p_value)
{
m_volume = p_value;
diff --git a/aosfxplayer.h b/aosfxplayer.h
index 61280e2e..5065c617 100644
--- a/aosfxplayer.h
+++ b/aosfxplayer.h
@@ -12,6 +12,7 @@ public:
AOSfxPlayer(QWidget *parent, AOApplication *p_ao_app);
void play(QString p_sfx, QString p_char = "");
+ void stop();
void set_volume(int p_volume);
private:
diff --git a/courtroom.cpp b/courtroom.cpp
index b19eeec6..a09520b3 100644
--- a/courtroom.cpp
+++ b/courtroom.cpp
@@ -63,6 +63,8 @@ Courtroom::Courtroom(AOApplication *p_ao_app) : QMainWindow()
ui_vp_desk = new AOScene(ui_viewport, ao_app);
ui_vp_legacy_desk = new AOScene(ui_viewport, ao_app);
+ ui_vp_evidence_display = new AOEvidenceDisplay(this, ao_app);
+
ui_vp_chatbox = new AOImage(this, ao_app);
ui_vp_showname = new QLabel(ui_vp_chatbox);
ui_vp_message = new QTextEdit(ui_vp_chatbox);
@@ -329,6 +331,9 @@ void Courtroom::set_widgets()
ui_vp_legacy_desk->move(0, final_y);
ui_vp_legacy_desk->hide();
+ ui_vp_evidence_display->move(0, 0);
+ ui_vp_evidence_display->resize(ui_viewport->width(), ui_viewport->height());
+
set_size_and_pos(ui_vp_showname, "showname");
set_size_and_pos(ui_vp_message, "message");
@@ -856,8 +861,12 @@ void Courtroom::on_chat_return_pressed()
packet_contents.append(f_obj_state);
- //evidence. 0 for now
- packet_contents.append("0");
+ if (is_presenting_evidence)
+ //the evidence index is shifted by 1 because 0 is no evidence per legacy standards
+ //besides, older clients crash if we pass -1
+ packet_contents.append(QString::number(current_evidence + 1));
+ else
+ packet_contents.append("0");
QString f_flip;
@@ -1035,6 +1044,18 @@ void Courtroom::handle_chatmessage_3()
{
start_chat_ticking();
+ int f_evi_id = m_chatmessage[EVIDENCE_ID].toInt();
+ QString f_side = m_chatmessage[SIDE];
+
+ if (f_evi_id > 0 && f_evi_id <= local_evidence_list.size())
+ {
+ //shifted by 1 because 0 is no evidence per legacy standards
+ QString f_image = local_evidence_list.at(f_evi_id - 1).image;
+ //def jud and hlp should display the evidence icon on the RIGHT side
+ bool is_left_side = !(f_side == "def" || f_side == "hlp" || "jud");
+ ui_vp_evidence_display->show_evidence(f_image, is_left_side, ui_sfx_slider->value());
+ }
+
int emote_mod = m_chatmessage[EMOTE_MOD].toInt();
if (emote_mod == 5 ||
diff --git a/courtroom.h b/courtroom.h
index 35721d12..cd4679f8 100644
--- a/courtroom.h
+++ b/courtroom.h
@@ -16,6 +16,7 @@
#include "aotextarea.h"
#include "aolineedit.h"
#include "aotextedit.h"
+#include "aoevidencedisplay.h"
#include "datatypes.h"
#include <QMainWindow>
@@ -220,6 +221,7 @@ private:
AOCharMovie *ui_vp_player_char;
AOScene *ui_vp_desk;
AOScene *ui_vp_legacy_desk;
+ AOEvidenceDisplay *ui_vp_evidence_display;
AOImage *ui_vp_chatbox;
QLabel *ui_vp_showname;
QTextEdit *ui_vp_message;
diff --git a/evidence.cpp b/evidence.cpp
index e6d5059f..43ee56b8 100644
--- a/evidence.cpp
+++ b/evidence.cpp
@@ -239,6 +239,7 @@ void Courtroom::on_evidence_double_clicked(int p_id)
void Courtroom::on_evidence_hover(int p_id, bool p_state)
{
+ ui_evidence_name->setReadOnly(true);
int final_id = p_id + max_evidence_on_page * current_evidence_page;
if (p_state)