added emote comments to emote buttons with missing image

This commit is contained in:
David Skoland 2017-02-14 15:58:36 +01:00
parent 9e5598cbed
commit 47f96cf0a4
10 changed files with 111 additions and 10 deletions

View File

@ -41,7 +41,8 @@ SOURCES += main.cpp\
aosfxplayer.cpp \
aomusicplayer.cpp \
aoblipplayer.cpp \
evidence.cpp
evidence.cpp \
aoevidencebutton.cpp
HEADERS += lobby.h \
aoimage.h \
@ -65,7 +66,8 @@ HEADERS += lobby.h \
bass.h \
aosfxplayer.h \
aomusicplayer.h \
aoblipplayer.h
aoblipplayer.h \
aoevidencebutton.h
unix:LIBS += -L/home/omnitroid/Project/Attorney_Online_2/src -lbass
win32:LIBS += "$$PWD/bass.dll"

View File

@ -91,6 +91,7 @@ public:
QString get_music_path(QString p_song);
QString get_background_path();
QString get_default_background_path();
QString get_evidence_path();
//implementation in text_file_functions.cpp
QString read_user_theme();
@ -105,6 +106,7 @@ public:
int get_text_delay(QString p_char, QString p_emote);
QString get_char_name(QString p_char);
int get_emote_number(QString p_char);
QString get_emote_comment(QString p_char, int p_emote);
QString get_emote(QString p_char, int p_emote);
QString get_pre_emote(QString p_char, int p_emote);
QString get_sfx_name(QString p_char, int p_emote);

View File

@ -1,6 +1,7 @@
#include "aoemotebutton.h"
#include "file_functions.h"
#include <QDebug>
AOEmoteButton::AOEmoteButton(QWidget *p_parent, AOApplication *p_ao_app, int p_x, int p_y) : QPushButton(p_parent)
{
@ -26,7 +27,7 @@ void AOEmoteButton::set_on(QString p_char, int p_emote)
}
else
{
this->setText(emotion_number);
this->setText(ao_app->get_emote_comment(p_char, p_emote));
this->setStyleSheet("border-image:url(\"\")");
}
}
@ -43,7 +44,7 @@ void AOEmoteButton::set_off(QString p_char, int p_emote)
}
else
{
this->setText(emotion_number);
this->setText(ao_app->get_emote_comment(p_char, p_emote));
this->setStyleSheet("border-image:url(\"\")");
}
}

24
aoevidencebutton.cpp Normal file
View File

@ -0,0 +1,24 @@
#include "aoevidencebutton.h"
#include "file_functions.h"
AOEvidenceButton::AOEvidenceButton(QWidget *p_parent, AOApplication *p_ao_app) : QPushButton(p_parent)
{
ao_app = p_ao_app;
}
void AOEvidenceButton::set_image(QString p_image)
{
QString image_path = ao_app->get_evidence_path() + p_image;
if (file_exists(image_path))
{
this->setText("");
this->setStyleSheet("border-image:url(\"" + image_path + "\")");
}
else
{
this->setText("evi");
this->setStyleSheet("");
}
}

20
aoevidencebutton.h Normal file
View File

@ -0,0 +1,20 @@
#ifndef AOEVIDENCEBUTTON_H
#define AOEVIDENCEBUTTON_H
#include "aoapplication.h"
#include <QPushButton>
#include <QString>
class AOEvidenceButton : public QPushButton
{
public:
AOEvidenceButton(QWidget *p_parent, AOApplication *p_ao_app);
void set_image(QString p_image);
private:
AOApplication *ao_app;
};
#endif // AOEVIDENCEBUTTON_H

View File

@ -61,6 +61,8 @@ Courtroom::Courtroom(AOApplication *p_ao_app) : QMainWindow()
ui_vp_showname = new QLabel(ui_vp_chatbox);
ui_vp_message = new QPlainTextEdit(ui_vp_chatbox);
ui_vp_message->setFrameStyle(QFrame::NoFrame);
ui_vp_message->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
ui_vp_message->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
ui_vp_testimony = new AOImage(ui_viewport, ao_app);
ui_vp_realization = new AOImage(this, ao_app);
ui_vp_wtce = new AOMovie(ui_viewport, ao_app);
@ -332,6 +334,7 @@ void Courtroom::set_widgets()
m_courtroom_width = f_courtroom.width;
m_courtroom_height = f_courtroom.height;
this->resize(m_courtroom_width, m_courtroom_height);
this->setFixedSize(m_courtroom_width, m_courtroom_height);
ui_background->set_image("courtroombackground.png");
@ -1184,7 +1187,6 @@ void Courtroom::start_chat_ticking()
void Courtroom::chat_tick()
{
//T0D0: play tick sound based on gender
//note: this is called fairly often(every 60 ms when char is talking)
//do not perform heavy operations here
@ -1204,6 +1206,7 @@ void Courtroom::chat_tick()
else
{
ui_vp_message->insertPlainText(f_message.at(tick_pos));
//ui_vp_message->app
QScrollBar *scroll = ui_vp_message->verticalScrollBar();
scroll->setValue(scroll->maximum());

View File

@ -12,6 +12,7 @@
#include "aomusicplayer.h"
#include "aosfxplayer.h"
#include "aoblipplayer.h"
#include "aoevidencebutton.h"
#include "datatypes.h"
#include <QMainWindow>
@ -172,7 +173,10 @@ private:
int max_emotes_on_page = 10;
int current_evidence_page = 0;
//int current_evidence
int current_evidence = 0;
int evidence_columns = 6;
int evidence_rows = 3;
int max_evidence_on_page = 18;
//is set to true if the bg folder contains defensedesk.png, prosecutiondesk.png and stand.png
bool is_ao2_bg = false;
@ -269,6 +273,9 @@ private:
AOImage *ui_muted;
AOButton *ui_evidence_button;
QVector<AOEvidenceButton*> ui_evidence_list;
AOImage *ui_evidence_left;
AOImage *ui_evidence_right;
AOImage *ui_evidence;

View File

@ -2,7 +2,7 @@
void Courtroom::construct_evidence()
{
//constructing emote button grid
//constructing evidence button grid
const int base_x_pos{10};
const int base_y_pos{0};
@ -12,8 +12,31 @@ void Courtroom::construct_evidence()
const int y_modifier{49};
int y_mod_count{0};
emote_columns = ui_emotes->width() / x_modifier;
emote_rows = ui_emotes->height() / y_modifier;
evidence_columns = ui_evidence->width() / x_modifier;
evidence_rows = ui_evidence->height() / y_modifier;
max_emotes_on_page = emote_columns * emote_rows;
max_evidence_on_page = evidence_columns * evidence_rows;
for (int n = 0 ; n < max_emotes_on_page ; ++n)
{
int x_pos = base_x_pos + (x_modifier * x_mod_count);
int y_pos = base_y_pos + (y_modifier * y_mod_count);
AOEmoteButton *f_emote = new AOEmoteButton(ui_emotes, ao_app, x_pos, y_pos);
ui_emote_list.append(f_emote);
f_emote->set_id(n);
connect(f_emote, SIGNAL(emote_clicked(int)), this, SLOT(on_emote_clicked(int)));
++x_mod_count;
//if emote number is divisible by columns with rest columns -1 then the next emote button should start on a new line
if ((n % emote_columns) == (emote_columns - 1) && (n != 0))
{
++y_mod_count;
x_mod_count = 0;
}
}
}

View File

@ -58,6 +58,11 @@ QString AOApplication::get_default_background_path()
return get_base_path() + "background/gs4/";
}
QString AOApplication::get_evidence_path()
{
return get_base_path() + "evidence/";
}
QString Courtroom::get_background_path()
{
return ao_app->get_base_path() + "background/" + current_background.toLower() + "/";

View File

@ -256,6 +256,20 @@ int AOApplication::get_emote_number(QString p_char)
else return f_result.toInt();
}
QString AOApplication::get_emote_comment(QString p_char, int p_emote)
{
QString f_result = read_char_ini(p_char, QString::number(p_emote + 1), "[Emotions]", "[SoundN]");
QStringList result_contents = f_result.split("#");
if (result_contents.size() < 4)
{
qDebug() << "W: misformatted char.ini: " << p_char << ", " << p_emote;
return "normal";
}
else return result_contents.at(0);
}
QString AOApplication::get_pre_emote(QString p_char, int p_emote)
{
QString f_result = read_char_ini(p_char, QString::number(p_emote + 1), "[Emotions]", "[SoundN]");