fixed all known bugs + improved preanims(probably)

This commit is contained in:
David Skoland 2017-02-15 15:32:20 +01:00
parent f7db8fa64a
commit be017b7278
9 changed files with 66 additions and 25 deletions

View File

@ -13,7 +13,7 @@ RC_ICONS = logo.ico
TARGET = Attorney_Online_remake TARGET = Attorney_Online_remake
TEMPLATE = app TEMPLATE = app
VERSION = 2.1.3.0 VERSION = 2.1.4.0
SOURCES += main.cpp\ SOURCES += main.cpp\
lobby.cpp \ lobby.cpp \

View File

@ -103,6 +103,7 @@ public:
QString get_showname(QString p_char); QString get_showname(QString p_char);
QString get_chat(QString p_char); QString get_chat(QString p_char);
int get_preanim_duration(QString p_char, QString p_emote); int get_preanim_duration(QString p_char, QString p_emote);
int get_ao2_preanim_duration(QString p_char, QString p_emote);
int get_text_delay(QString p_char, QString p_emote); int get_text_delay(QString p_char, QString p_emote);
QString get_char_name(QString p_char); QString get_char_name(QString p_char);
int get_emote_number(QString p_char); int get_emote_number(QString p_char);
@ -117,7 +118,7 @@ public:
private: private:
const int RELEASE = 2; const int RELEASE = 2;
const int MAJOR_VERSION = 1; const int MAJOR_VERSION = 1;
const int MINOR_VERSION = 3; const int MINOR_VERSION = 4;
QString user_theme = "default"; QString user_theme = "default";

View File

@ -12,7 +12,7 @@ AOBlipPlayer::AOBlipPlayer(QWidget *parent, AOApplication *p_ao_app)
void AOBlipPlayer::set_blips(QString p_sfx) void AOBlipPlayer::set_blips(QString p_sfx)
{ {
QString f_path = ao_app->get_sounds_path() + p_sfx; QString f_path = ao_app->get_sounds_path() + p_sfx.toLower();
for (int n_stream = 0 ; n_stream < 5 ; ++n_stream) for (int n_stream = 0 ; n_stream < 5 ; ++n_stream)
{ {

View File

@ -19,7 +19,8 @@ AOCharMovie::AOCharMovie(QWidget *p_parent, AOApplication *p_ao_app) : QLabel(p_
this->setMovie(m_movie); this->setMovie(m_movie);
connect(m_movie, SIGNAL(frameChanged(int)), this, SLOT(frame_change(int))); connect(m_movie, SIGNAL(frameChanged(int)), this, SLOT(frame_change(int)));
connect(preanim_timer, SIGNAL(timeout()), this, SLOT(preanim_done())); connect(m_movie, SIGNAL(finished()), this, SLOT(movie_done()));
connect(preanim_timer, SIGNAL(timeout()), this, SLOT(timer_done()));
} }
void AOCharMovie::play(QString p_char, QString p_emote, QString emote_prefix) void AOCharMovie::play(QString p_char, QString p_emote, QString emote_prefix)
@ -63,9 +64,16 @@ void AOCharMovie::play(QString p_char, QString p_emote, QString emote_prefix)
void AOCharMovie::play_pre(QString p_char, QString p_emote, int duration) void AOCharMovie::play_pre(QString p_char, QString p_emote, int duration)
{ {
play(p_char, p_emote, ""); if (duration == 0)
play_once = true;
else
{
play_once = false;
preanim_timer->start(duration); preanim_timer->start(duration);
} }
play(p_char, p_emote, "");
}
void AOCharMovie::play_talking(QString p_char, QString p_emote) void AOCharMovie::play_talking(QString p_char, QString p_emote)
{ {
@ -95,9 +103,15 @@ void AOCharMovie::frame_change(int n_frame)
{ {
if (m_flipped && flipped_movie.size() > n_frame) if (m_flipped && flipped_movie.size() > n_frame)
this->setPixmap(QPixmap::fromImage(flipped_movie.at(n_frame))); this->setPixmap(QPixmap::fromImage(flipped_movie.at(n_frame)));
if (m_movie->frameCount() - 1 == n_frame && play_once)
{
delay(m_movie->nextFrameDelay());
done();
}
} }
void AOCharMovie::preanim_done() void AOCharMovie::timer_done()
{ {
done(); done();
} }

View File

@ -34,12 +34,14 @@ private:
bool m_flipped = false; bool m_flipped = false;
bool play_once = true;
signals: signals:
void done(); void done();
private slots: private slots:
void frame_change(int n_frame); void frame_change(int n_frame);
void preanim_done(); void timer_done();
}; };
#endif // AOCHARMOVIE_H #endif // AOCHARMOVIE_H

View File

@ -50,5 +50,8 @@ void AOImage::set_scaled_image(QString p_image)
QPixmap f_pixmap(final_image_path); QPixmap f_pixmap(final_image_path);
this->setPixmap(f_pixmap.scaled(this->width(), this->height())); qDebug() << "aoimage width" << this->width();
qDebug() << "aoimage height" << this->height();
this->setPixmap(f_pixmap.scaled(this->width(), this->height(), Qt::IgnoreAspectRatio));
} }

View File

@ -43,6 +43,8 @@ Courtroom::Courtroom(AOApplication *p_ao_app) : QMainWindow()
music_player->set_volume(0); music_player->set_volume(0);
sfx_player = new AOSfxPlayer(this, ao_app); sfx_player = new AOSfxPlayer(this, ao_app);
sfx_player->set_volume(0); sfx_player->set_volume(0);
objection_player = new AOSfxPlayer(this, ao_app);
sfx_player->set_volume(0);
blip_player = new AOBlipPlayer(this, ao_app); blip_player = new AOBlipPlayer(this, ao_app);
blip_player->set_volume(0); blip_player->set_volume(0);
@ -57,17 +59,18 @@ Courtroom::Courtroom(AOApplication *p_ao_app) : QMainWindow()
ui_vp_player_char = new AOCharMovie(ui_viewport, ao_app); ui_vp_player_char = new AOCharMovie(ui_viewport, ao_app);
ui_vp_desk = new AOScene(ui_viewport, ao_app); ui_vp_desk = new AOScene(ui_viewport, ao_app);
ui_vp_legacy_desk = new AOScene(ui_viewport, ao_app); ui_vp_legacy_desk = new AOScene(ui_viewport, ao_app);
ui_vp_chatbox = new AOImage(ui_viewport, ao_app); 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);
ui_vp_objection = new AOMovie(ui_viewport, ao_app);
ui_vp_chatbox = new AOImage(this, ao_app);
ui_vp_showname = new QLabel(ui_vp_chatbox); ui_vp_showname = new QLabel(ui_vp_chatbox);
ui_vp_message = new QPlainTextEdit(ui_vp_chatbox); ui_vp_message = new QPlainTextEdit(ui_vp_chatbox);
ui_vp_message->setFrameStyle(QFrame::NoFrame); ui_vp_message->setFrameStyle(QFrame::NoFrame);
ui_vp_message->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); ui_vp_message->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
ui_vp_message->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); ui_vp_message->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
ui_vp_message->setReadOnly(true); ui_vp_message->setReadOnly(true);
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);
ui_vp_objection = new AOMovie(ui_viewport, ao_app);
ui_ic_chatlog = new QPlainTextEdit(this); ui_ic_chatlog = new QPlainTextEdit(this);
ui_ic_chatlog->setReadOnly(true); ui_ic_chatlog->setReadOnly(true);
@ -378,6 +381,7 @@ void Courtroom::set_widgets()
"color: white;"); "color: white;");
set_size_and_pos(ui_vp_message, "message"); set_size_and_pos(ui_vp_message, "message");
ui_vp_message->setTextInteractionFlags(Qt::NoTextInteraction);
#if (defined (_WIN32) || defined (_WIN64)) #if (defined (_WIN32) || defined (_WIN64))
ui_vp_message->setFont(pt_10); ui_vp_message->setFont(pt_10);
#else #else
@ -408,14 +412,14 @@ void Courtroom::set_widgets()
#else #else
ui_ic_chatlog->setFont(pt_9); ui_ic_chatlog->setFont(pt_9);
#endif #endif
ui_ic_chatlog->setStyleSheet("background-color: rgba(0, 0, 0, 0);" ui_ic_chatlog->setStyleSheet("QPlainTextEdit{ background-color: rgba(0, 0, 0, 0);"
"color: white;"); "color: white; }");
set_size_and_pos(ui_ms_chatlog, "ms_chatlog"); set_size_and_pos(ui_ms_chatlog, "ms_chatlog");
ui_ms_chatlog->setStyleSheet("background-color: rgba(0, 0, 0, 0);"); ui_ms_chatlog->setStyleSheet("QPlainTextEdit{ background-color: rgba(0, 0, 0, 0); }");
set_size_and_pos(ui_server_chatlog, "server_chatlog"); set_size_and_pos(ui_server_chatlog, "server_chatlog");
ui_server_chatlog->setStyleSheet("background-color: rgba(0, 0, 0, 0);"); ui_server_chatlog->setStyleSheet("QPlainTextEdit{ background-color: rgba(0, 0, 0, 0); }");
set_size_and_pos(ui_mute_list, "mute_list"); set_size_and_pos(ui_mute_list, "mute_list");
ui_mute_list->hide(); ui_mute_list->hide();
@ -601,6 +605,7 @@ void Courtroom::done_received()
music_player->set_volume(0); music_player->set_volume(0);
sfx_player->set_volume(0); sfx_player->set_volume(0);
objection_player->set_volume(0);
blip_player->set_volume(0); blip_player->set_volume(0);
set_char_select_page(); set_char_select_page();
@ -747,6 +752,7 @@ void Courtroom::enter_courtroom(int p_cid)
music_player->set_volume(ui_music_slider->value()); music_player->set_volume(ui_music_slider->value());
sfx_player->set_volume(ui_sfx_slider->value()); sfx_player->set_volume(ui_sfx_slider->value());
objection_player->set_volume(ui_sfx_slider->value());
blip_player->set_volume(ui_blip_slider->value()); blip_player->set_volume(ui_blip_slider->value());
testimony_in_progress = false; testimony_in_progress = false;
@ -954,7 +960,7 @@ void Courtroom::handle_chatmessage(QStringList *p_contents)
if (mute_map.value(m_chatmessage[CHAR_NAME])) if (mute_map.value(m_chatmessage[CHAR_NAME]))
return; return;
QString f_showname = ao_app->get_showname(m_chatmessage[CHAR_NAME]); QString f_showname = ao_app->get_showname(char_list.at(m_chatmessage[CHAR_ID].toInt()).name);
QString f_message = f_showname + ": " + m_chatmessage[MESSAGE] + '\n'; QString f_message = f_showname + ": " + m_chatmessage[MESSAGE] + '\n';
@ -992,20 +998,20 @@ void Courtroom::handle_chatmessage(QStringList *p_contents)
{ {
case 1: case 1:
ui_vp_objection->play("holdit"); ui_vp_objection->play("holdit");
sfx_player->play("holdit.wav", m_chatmessage[CHAR_NAME]); objection_player->play("holdit.wav", m_chatmessage[CHAR_NAME]);
break; break;
case 2: case 2:
ui_vp_objection->play("objection"); ui_vp_objection->play("objection");
sfx_player->play("objection.wav", m_chatmessage[CHAR_NAME]); objection_player->play("objection.wav", m_chatmessage[CHAR_NAME]);
break; break;
case 3: case 3:
ui_vp_objection->play("takethat"); ui_vp_objection->play("takethat");
sfx_player->play("takethat.wav", m_chatmessage[CHAR_NAME]); objection_player->play("takethat.wav", m_chatmessage[CHAR_NAME]);
break; break;
//case 4 is AO2 only //case 4 is AO2 only
case 4: case 4:
ui_vp_objection->play("custom", m_chatmessage[CHAR_NAME]); ui_vp_objection->play("custom", m_chatmessage[CHAR_NAME]);
sfx_player->play("custom.wav", m_chatmessage[CHAR_NAME]); objection_player->play("custom.wav", m_chatmessage[CHAR_NAME]);
break; break;
default: default:
qDebug() << "W: Logic error in objection switch statement!"; qDebug() << "W: Logic error in objection switch statement!";
@ -1030,7 +1036,7 @@ void Courtroom::handle_chatmessage_2()
ui_vp_speedlines->stop(); ui_vp_speedlines->stop();
ui_vp_player_char->stop(); ui_vp_player_char->stop();
QString f_showname = ao_app->get_showname(m_chatmessage[CHAR_NAME]); QString f_showname = ao_app->get_showname(char_list.at(m_chatmessage[CHAR_ID].toInt()).name);
ui_vp_showname->setText(f_showname); ui_vp_showname->setText(f_showname);
@ -1157,14 +1163,15 @@ void Courtroom::play_preanim()
QString f_char = m_chatmessage[CHAR_NAME]; QString f_char = m_chatmessage[CHAR_NAME];
QString f_preanim = m_chatmessage[PRE_EMOTE]; QString f_preanim = m_chatmessage[PRE_EMOTE];
if (!file_exists(ao_app->get_character_path(f_char) + ".gif")) if (!file_exists(ao_app->get_character_path(f_char) + f_preanim.toLower() + ".gif"))
{ {
preanim_done(); preanim_done();
qDebug() << "could not find " + ao_app->get_character_path(f_char) + f_preanim + ".gif";
return; return;
} }
//all time values in char.inis are multiplied by a constant(time_mod) to get the actual time //all time values in char.inis are multiplied by a constant(time_mod) to get the actual time
int preanim_duration = ao_app->get_preanim_duration(f_char, f_preanim) * time_mod; int preanim_duration = ao_app->get_ao2_preanim_duration(f_char, f_preanim) * time_mod;
int text_delay = ao_app->get_text_delay(f_char, f_preanim) * time_mod; int text_delay = ao_app->get_text_delay(f_char, f_preanim) * time_mod;
int sfx_delay = m_chatmessage[SFX_DELAY].toInt() * time_mod; int sfx_delay = m_chatmessage[SFX_DELAY].toInt() * time_mod;
@ -1720,6 +1727,7 @@ void Courtroom::on_music_slider_moved(int p_value)
void Courtroom::on_sfx_slider_moved(int p_value) void Courtroom::on_sfx_slider_moved(int p_value)
{ {
sfx_player->set_volume(p_value); sfx_player->set_volume(p_value);
objection_player->set_volume(p_value);
ui_ic_chat_message->setFocus(); ui_ic_chat_message->setFocus();
} }
@ -1753,6 +1761,7 @@ void Courtroom::on_change_character_clicked()
{ {
music_player->set_volume(0); music_player->set_volume(0);
sfx_player->set_volume(0); sfx_player->set_volume(0);
sfx_player->set_volume(0);
blip_player->set_volume(0); blip_player->set_volume(0);
ui_char_select_background->show(); ui_char_select_background->show();
@ -1862,4 +1871,6 @@ Courtroom::~Courtroom()
{ {
delete music_player; delete music_player;
delete sfx_player; delete sfx_player;
delete objection_player;
delete blip_player;
} }

View File

@ -190,6 +190,7 @@ private:
AOMusicPlayer *music_player; AOMusicPlayer *music_player;
AOSfxPlayer *sfx_player; AOSfxPlayer *sfx_player;
AOSfxPlayer *objection_player;
AOBlipPlayer *blip_player; AOBlipPlayer *blip_player;
AOSfxPlayer *modcall_player; AOSfxPlayer *modcall_player;

View File

@ -247,6 +247,15 @@ int AOApplication::get_preanim_duration(QString p_char, QString p_emote)
else return f_result.toInt(); else return f_result.toInt();
} }
int AOApplication::get_ao2_preanim_duration(QString p_char, QString p_emote)
{
QString f_result = read_char_ini(p_char, "%" + p_emote, "[Time]", "[Emotions]");
if (f_result == "")
return 0;
else return f_result.toInt();
}
int AOApplication::get_emote_number(QString p_char) int AOApplication::get_emote_number(QString p_char)
{ {
QString f_result = read_char_ini(p_char, "number", "[Emotions]", "[SoundN]"); QString f_result = read_char_ini(p_char, "number", "[Emotions]", "[SoundN]");