aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Skoland <davidskoland@gmail.com>2017-01-31 15:55:21 +0100
committerDavid Skoland <davidskoland@gmail.com>2017-01-31 15:55:21 +0100
commit295ea74b7c652ee98ed865fdbc572ecd65478bc4 (patch)
treed0a290f2e0eb6ae47e7cbf7515cf35f4cc14b58a
parent9031779bc93c376596d98ae1e3fb7df1c8742399 (diff)
did some work on the gif custom classes
-rw-r--r--Attorney_Online_remake.pro8
-rw-r--r--aocharmovie.cpp97
-rw-r--r--aocharmovie.h42
-rw-r--r--aocharselect.cpp6
-rw-r--r--aocharselect.h12
-rw-r--r--aomovie.cpp2
-rw-r--r--courtroom.cpp15
-rw-r--r--courtroom.h4
-rw-r--r--path_functions.cpp2
9 files changed, 157 insertions, 31 deletions
diff --git a/Attorney_Online_remake.pro b/Attorney_Online_remake.pro
index 45d0ea7f..71369390 100644
--- a/Attorney_Online_remake.pro
+++ b/Attorney_Online_remake.pro
@@ -34,8 +34,8 @@ SOURCES += main.cpp\
hardware_functions.cpp \
aoscene.cpp \
aomovie.cpp \
- aocharselect.cpp \
- misc_functions.cpp
+ misc_functions.cpp \
+ aocharmovie.cpp
HEADERS += lobby.h \
aoimage.h \
@@ -53,5 +53,5 @@ HEADERS += lobby.h \
hardware_functions.h \
aoscene.h \
aomovie.h \
- aocharselect.h \
- misc_functions.h
+ misc_functions.h \
+ aocharmovie.h
diff --git a/aocharmovie.cpp b/aocharmovie.cpp
new file mode 100644
index 00000000..ff5e64c0
--- /dev/null
+++ b/aocharmovie.cpp
@@ -0,0 +1,97 @@
+#include "aocharmovie.h"
+
+#include "misc_functions.h"
+#include "file_functions.h"
+#include "aoapplication.h"
+
+AOCharMovie::AOCharMovie(QWidget *p_parent, AOApplication *p_ao_app) : QLabel(p_parent)
+{
+ ao_app = p_ao_app;
+
+ m_movie = new QMovie(this);
+
+ this->setMovie(m_movie);
+
+ connect(m_movie, SIGNAL(frameChanged(int)), this, SLOT(frame_change(int)));
+}
+
+void AOCharMovie::set(QString p_char, QString p_pre, QString p_gif)
+{
+ m_char = p_char;
+ m_pre = p_pre;
+ m_gif = p_gif;
+}
+
+void AOCharMovie::play_pre()
+{
+ m_movie->stop();
+
+ QString pre_path = ao_app->get_character_path(m_char) + m_pre.toLower() + ".gif";
+ QString placeholder_path = ao_app->get_theme_path() + "placeholder.gif";
+
+ if (file_exists(pre_path))
+ m_movie->setFileName(pre_path);
+ else
+ m_movie->setFileName(placeholder_path);
+
+ this->show();
+ m_movie->start();
+}
+
+void AOCharMovie::play_talking()
+{
+ m_movie->stop();
+
+ QString talking_path = ao_app->get_character_path(m_char) + "(b)" + m_gif.toLower() + ".gif";
+ QString placeholder_path = ao_app->get_theme_path() + "placeholder.gif";
+
+ if (file_exists(talking_path))
+ m_movie->setFileName(talking_path);
+ else
+ m_movie->setFileName(placeholder_path);
+
+ this->show();
+ m_movie->start();
+}
+
+void AOCharMovie::play_idle()
+{
+ m_movie->stop();
+
+ QString idle_path = ao_app->get_character_path(m_char) + "(a)" + m_gif.toLower() + ".gif";
+ QString placeholder_path = ao_app->get_theme_path() + "placeholder.gif";
+
+ if (file_exists(idle_path))
+ m_movie->setFileName(idle_path);
+ else
+ m_movie->setFileName(placeholder_path);
+
+ this->show();
+ m_movie->start();
+}
+
+void AOCharMovie::stop()
+{
+ //for all intents and purposes, stopping is the same as hiding. at no point do we want a frozen gif to display
+ m_movie->stop();
+ this->hide();
+}
+
+void AOCharMovie::combo_resize(int w, int h)
+{
+ QSize f_size(w, h);
+ this->resize(f_size);
+ m_movie->setScaledSize(f_size);
+}
+
+void AOCharMovie::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());
+
+ //signal connected to courtroom object, let it figure out what to do
+ done();
+ }
+}
diff --git a/aocharmovie.h b/aocharmovie.h
new file mode 100644
index 00000000..0aff95a0
--- /dev/null
+++ b/aocharmovie.h
@@ -0,0 +1,42 @@
+#ifndef AOCHARMOVIE_H
+#define AOCHARMOVIE_H
+
+#include <QMovie>
+#include <QLabel>
+
+class AOApplication;
+
+class AOCharMovie : public QLabel
+{
+ Q_OBJECT
+
+public:
+ AOCharMovie(QWidget *p_parent, AOApplication *p_ao_app);
+
+ void set(QString p_char, QString p_pre, QString p_gif);
+
+ void play_pre();
+ void play_talking();
+ void play_idle();
+
+ void stop();
+
+ void combo_resize(int w, int h);
+
+private:
+ AOApplication *ao_app;
+
+ QMovie *m_movie;
+
+ QString m_char = "null";
+ QString m_pre;
+ QString m_gif;
+
+signals:
+ void done();
+
+private slots:
+ void frame_change(int n_frame);
+};
+
+#endif // AOCHARMOVIE_H
diff --git a/aocharselect.cpp b/aocharselect.cpp
deleted file mode 100644
index 1921e670..00000000
--- a/aocharselect.cpp
+++ /dev/null
@@ -1,6 +0,0 @@
-#include "aocharselect.h"
-
-AOCharSelect::AOCharSelect()
-{
-
-}
diff --git a/aocharselect.h b/aocharselect.h
deleted file mode 100644
index be57dde5..00000000
--- a/aocharselect.h
+++ /dev/null
@@ -1,12 +0,0 @@
-#ifndef AOCHARSELECT_H
-#define AOCHARSELECT_H
-
-#include <QLabel>
-
-class AOCharSelect : public QLabel
-{
-public:
- AOCharSelect();
-};
-
-#endif // AOCHARSELECT_H
diff --git a/aomovie.cpp b/aomovie.cpp
index 2c848c41..7d3e1ba2 100644
--- a/aomovie.cpp
+++ b/aomovie.cpp
@@ -17,6 +17,8 @@ AOMovie::AOMovie(QWidget *p_parent, AOApplication *p_ao_app) : QLabel(p_parent)
void AOMovie::play(QString p_gif)
{
+ m_movie->stop();
+
QString gif_path = ao_app->get_theme_path() + p_gif;
QString default_path = ao_app->get_default_theme_path() + p_gif;
diff --git a/courtroom.cpp b/courtroom.cpp
index 6600c34a..2c941b85 100644
--- a/courtroom.cpp
+++ b/courtroom.cpp
@@ -5,6 +5,7 @@
#include "hardware_functions.h"
#include "file_functions.h"
#include "datatypes.h"
+#include "debug_functions.h"
#include <QDebug>
#include <QScrollBar>
@@ -20,8 +21,9 @@ Courtroom::Courtroom(AOApplication *p_ao_app) : QMainWindow()
ui_background = new AOImage(this, ao_app);
ui_vp_background = new AOScene(this);
- ui_vp_player_char = new AOMovie(this, ao_app);
+ ui_vp_player_char = new AOCharMovie(this, ao_app);
ui_vp_desk = new AOScene(this);
+ ui_vp_legacy_desk = new AOScene(this);
ui_vp_chatbox = new AOImage(this, ao_app);
ui_vp_showname = new QLabel(this);
ui_vp_message = new QPlainTextEdit(this);
@@ -427,9 +429,7 @@ void Courtroom::set_size_and_pos(QWidget *p_widget, QString p_identifier)
if (design_ini_result.width < 0 || design_ini_result.height < 0)
{
//at this point it's pretty much game over
- //T0D0: add message box
- qDebug() << "CRITICAL ERROR: NO SUITABLE DATA FOR SETTING " << p_identifier;
- ao_app->quit();
+ call_error(" could not find \"" + p_identifier + "\" in courtroom_design.ini");
}
}
@@ -583,7 +583,7 @@ void Courtroom::append_server_chatmessage(QString f_message)
void Courtroom::handle_chatmessage(QStringList *p_contents)
{
- QString f_message = p_contents->at(2) + ": " + p_contents->at(4) + '\n';
+ QString f_message = p_contents->at(CHAR_NAME) + ": " + p_contents->at(MESSAGE) + '\n';
const QTextCursor old_cursor = ui_ic_chatlog->textCursor();
const int old_scrollbar_value = ui_ic_chatlog->verticalScrollBar()->value();
@@ -614,6 +614,9 @@ void Courtroom::handle_chatmessage(QStringList *p_contents)
ui_vp_background->set_image("defenseempty.png");
+ ui_vp_player_char->set(p_contents->at(CHAR_NAME), p_contents->at(EMOTE), p_contents->at(PRE_EMOTE));
+ ui_vp_player_char->play_talking();
+
//D3BUG END
}
@@ -631,7 +634,6 @@ void Courtroom::handle_wtce(QString p_wtce)
QUrl wt_sfx(QUrl::fromLocalFile(wt_path));
sfx_player->stop();
- ui_vp_wtce->stop();
sfx_player->setSource(wt_sfx);
sfx_player->play();
@@ -644,7 +646,6 @@ void Courtroom::handle_wtce(QString p_wtce)
QUrl ce_sfx(QUrl::fromLocalFile(ce_path));
sfx_player->stop();
- ui_vp_wtce->stop();
sfx_player->setSource(ce_sfx);
sfx_player->play();
diff --git a/courtroom.h b/courtroom.h
index 63e83e34..a2902970 100644
--- a/courtroom.h
+++ b/courtroom.h
@@ -7,6 +7,7 @@
#include "aopacket.h"
#include "aoscene.h"
#include "aomovie.h"
+#include "aocharmovie.h"
#include "datatypes.h"
#include <QMainWindow>
@@ -89,8 +90,9 @@ private:
AOImage *ui_background;
AOScene *ui_vp_background;
- AOMovie *ui_vp_player_char;
+ AOCharMovie *ui_vp_player_char;
AOScene *ui_vp_desk;
+ AOScene *ui_vp_legacy_desk;
AOImage *ui_vp_chatbox;
QLabel *ui_vp_showname;
QPlainTextEdit *ui_vp_message;
diff --git a/path_functions.cpp b/path_functions.cpp
index 14586492..b1fd1168 100644
--- a/path_functions.cpp
+++ b/path_functions.cpp
@@ -7,7 +7,7 @@
QString AOApplication::get_base_path(){
#ifdef OMNI_DEBUG
- return "/media/omnitroid/Data/winshare/AO/client/base/";
+ return "/media/omnitroid/Data/winshare/AO/client/4chan_base/";
#else
return (QDir::currentPath() + "/base/");
#endif