did some work on the gif custom classes

This commit is contained in:
David Skoland 2017-01-31 15:55:21 +01:00
parent 9031779bc9
commit 295ea74b7c
9 changed files with 157 additions and 31 deletions

View File

@ -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

97
aocharmovie.cpp Normal file
View File

@ -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();
}
}

42
aocharmovie.h Normal file
View File

@ -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

View File

@ -1,6 +0,0 @@
#include "aocharselect.h"
AOCharSelect::AOCharSelect()
{
}

View File

@ -1,12 +0,0 @@
#ifndef AOCHARSELECT_H
#define AOCHARSELECT_H
#include <QLabel>
class AOCharSelect : public QLabel
{
public:
AOCharSelect();
};
#endif // AOCHARSELECT_H

View File

@ -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;

View File

@ -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();

View File

@ -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;

View File

@ -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