diff --git a/Attorney_Online_remake.pro b/Attorney_Online_remake.pro index b3f93b1..62a7dc9 100644 --- a/Attorney_Online_remake.pro +++ b/Attorney_Online_remake.pro @@ -5,7 +5,6 @@ #------------------------------------------------- QT += core gui multimedia network - greaterThan(QT_MAJOR_VERSION, 4): QT += widgets RC_ICONS = logo.ico @@ -13,7 +12,7 @@ RC_ICONS = logo.ico TARGET = Attorney_Online TEMPLATE = app -VERSION = 2.4.10.0 +VERSION = 2.6.0.0 SOURCES += main.cpp\ lobby.cpp \ @@ -87,16 +86,17 @@ HEADERS += lobby.h \ chatlogpiece.h \ aocaseannouncerdialog.h -# You need to compile the Discord Rich Presence SDK separately and add the lib/headers. -# Discord RPC uses CMake, which does not play nicely with QMake, so this step must be manual. - -unix:LIBS += -L$$PWD -ldiscord-rpc -lbass -win32:LIBS += -L$$PWD -ldiscord-rpc #"$$PWD/discord-rpc.dll" +# 1. You need to get BASS and put the x86 bass DLL/headers in the project root folder +# AND the compilation output folder. If you want a static link, you'll probably +# need the .lib file too. MinGW-GCC is really finicky finding BASS, it seems. +# 2. You need to compile the Discord Rich Presence SDK separately and add the lib/headers +# in the same way as BASS. Discord RPC uses CMake, which does not play nicely with +# QMake, so this step must be manual. +unix:LIBS += -L$$PWD -lbass -ldiscord-rpc +win32:LIBS += -L$$PWD "$$PWD/bass.dll" -ldiscord-rpc CONFIG += c++11 -ANDROID_PACKAGE_SOURCE_DIR = $$PWD/android - RESOURCES += \ resources.qrc diff --git a/aoapplication.h b/aoapplication.h index 353bbc6..dbda673 100644 --- a/aoapplication.h +++ b/aoapplication.h @@ -205,6 +205,12 @@ public: //Returns the sfx with p_identifier from sounds.ini in the current theme path QString get_sfx(QString p_identifier); + //Figure out if we can opus this or if we should fall back to wav + QString get_sfx_suffix(QString sound_to_check); + + // Can we use APNG for this? If not, fall back to a gif. + QString get_image_suffix(QString path_to_check); + //Returns the value of p_search_line within target_tag and terminator_tag QString read_char_ini(QString p_char, QString p_search_line, QString target_tag); diff --git a/aocharmovie.cpp b/aocharmovie.cpp index 4170855..e9c88ba 100644 --- a/aocharmovie.cpp +++ b/aocharmovie.cpp @@ -21,11 +21,14 @@ void AOCharMovie::play(QString p_char, QString p_emote, QString emote_prefix) { QString original_path = ao_app->get_character_path(p_char) + emote_prefix + p_emote.toLower() + ".gif"; QString alt_path = ao_app->get_character_path(p_char) + p_emote.toLower() + ".png"; + QString apng_path = ao_app->get_character_path(p_char) + emote_prefix + p_emote.toLower() + ".apng"; QString placeholder_path = ao_app->get_theme_path() + "placeholder.gif"; QString placeholder_default_path = ao_app->get_default_theme_path() + "placeholder.gif"; QString gif_path; - if (file_exists(original_path)) + if (file_exists(apng_path)) + gif_path = apng_path; + else if (file_exists(original_path)) gif_path = original_path; else if (file_exists(alt_path)) gif_path = alt_path; @@ -155,6 +158,7 @@ void AOCharMovie::move(int ax, int ay) void AOCharMovie::frame_change(int n_frame) { + if (movie_frames.size() > n_frame) { QPixmap f_pixmap = QPixmap::fromImage(movie_frames.at(n_frame)); diff --git a/aomovie.cpp b/aomovie.cpp index d7727aa..88f81e9 100644 --- a/aomovie.cpp +++ b/aomovie.cpp @@ -28,9 +28,9 @@ void AOMovie::play(QString p_gif, QString p_char, QString p_custom_theme) QString custom_path; if (p_gif == "custom") - custom_path = ao_app->get_character_path(p_char) + p_gif + ".gif"; + custom_path = ao_app->get_image_suffix(ao_app->get_character_path(p_char) + p_gif); else - custom_path = ao_app->get_character_path(p_char) + p_gif + "_bubble.gif"; + custom_path = ao_app->get_image_suffix(ao_app->get_character_path(p_char) + p_gif + "_bubble"); QString misc_path = ao_app->get_base_path() + "misc/" + p_custom_theme + "/" + p_gif + "_bubble.gif"; QString custom_theme_path = ao_app->get_base_path() + "themes/" + p_custom_theme + "/" + p_gif + ".gif"; diff --git a/courtroom.cpp b/courtroom.cpp index a8efbce..dd6bc66 100644 --- a/courtroom.cpp +++ b/courtroom.cpp @@ -877,7 +877,7 @@ void Courtroom::enter_courtroom(int p_cid) QString char_path = ao_app->get_character_path(current_char); if (ao_app->custom_objection_enabled && - file_exists(char_path + "custom.gif") && + (file_exists(char_path + "custom.gif") || file_exists(char_path + "custom.apng")) && file_exists(char_path + "custom.wav")) ui_custom_objection->show(); else @@ -1670,6 +1670,9 @@ void Courtroom::handle_chatmessage_3() void Courtroom::append_ic_text(QString p_text, QString p_name) { + // a bit of a silly hack, should use QListWidget for IC in the first place though + static bool isEmpty = true; + QTextCharFormat bold; QTextCharFormat normal; bold.setFontWeight(QFont::Bold); @@ -1994,13 +1997,13 @@ void Courtroom::play_preanim() preanim_duration = ao2_duration; sfx_delay_timer->start(sfx_delay); - - if (!file_exists(ao_app->get_character_path(f_char) + f_preanim.toLower() + ".gif") || + QString anim_to_find = ao_app->get_image_suffix(ao_app->get_character_path(f_char) + f_preanim.toLower()); + if (!file_exists(anim_to_find) || preanim_duration < 0) { anim_state = 1; preanim_done(); - qDebug() << "could not find " + ao_app->get_character_path(f_char) + f_preanim.toLower() + ".gif"; + qDebug() << "could not find " + anim_to_find; return; } @@ -2029,13 +2032,13 @@ void Courtroom::play_noninterrupting_preanim() preanim_duration = ao2_duration; sfx_delay_timer->start(sfx_delay); - - if (!file_exists(ao_app->get_character_path(f_char) + f_preanim.toLower() + ".gif") || + QString anim_to_find = ao_app->get_image_suffix(ao_app->get_character_path(f_char) + f_preanim.toLower()); + if (!file_exists(anim_to_find) || preanim_duration < 0) { anim_state = 4; preanim_done(); - qDebug() << "could not find " + ao_app->get_character_path(f_char) + f_preanim.toLower() + ".gif"; + qDebug() << "could not find " + anim_to_find; return; } @@ -2415,7 +2418,7 @@ void Courtroom::play_sfx() if (sfx_name == "1") return; - sfx_player->play(sfx_name + ".wav"); + sfx_player->play(ao_app->get_sfx_suffix(sfx_name)); } void Courtroom::set_scene() @@ -3404,24 +3407,33 @@ void Courtroom::on_spectator_clicked() void Courtroom::on_call_mod_clicked() { - if (!ao_app->modcall_reason_enabled) - { - ao_app->send_server_packet(new AOPacket("ZZ#%")); - ui_ic_chat_message->setFocus(); - return; - } + if (ao_app->modcall_reason_enabled) { + QMessageBox errorBox; + QInputDialog input; - bool ok; - QString text = QInputDialog::getText(ui_viewport, "Call a mod", - "Reason for the modcall (optional):", QLineEdit::Normal, - "", &ok); - if (ok) - { - text = text.left(100); - if (!text.isEmpty()) - ao_app->send_server_packet(new AOPacket("ZZ#" + text + "#%")); - else - ao_app->send_server_packet(new AOPacket("ZZ#%")); + input.setWindowFlags(Qt::WindowSystemMenuHint); + input.setLabelText("Reason:"); + input.setWindowTitle("Call Moderator"); + auto code = input.exec(); + + if (code != QDialog::Accepted) + return; + + QString text = input.textValue(); + if (text.isEmpty()) { + errorBox.critical(nullptr, "Error", "You must provide a reason."); + return; + } else if (text.length() > 256) { + errorBox.critical(nullptr, "Error", "The message is too long."); + return; + } + + QStringList mod_reason; + mod_reason.append(text); + + ao_app->send_server_packet(new AOPacket("ZZ", mod_reason)); + } else { + ao_app->send_server_packet(new AOPacket("ZZ#%")); } ui_ic_chat_message->setFocus(); diff --git a/lobby.cpp b/lobby.cpp index aa1f43f..28da1fa 100644 --- a/lobby.cpp +++ b/lobby.cpp @@ -9,7 +9,7 @@ Lobby::Lobby(AOApplication *p_ao_app) : QMainWindow() { ao_app = p_ao_app; - this->setWindowTitle("Attorney Online 2"); + this->setWindowTitle("Attorney Online Vidya (AO2)"); ui_background = new AOImage(this, ao_app); ui_public_servers = new AOButton(this, ao_app); diff --git a/main.cpp b/main.cpp index 5696e2e..cf51b0a 100644 --- a/main.cpp +++ b/main.cpp @@ -5,9 +5,9 @@ #include "networkmanager.h" #include "lobby.h" #include "courtroom.h" - +#include #include - +Q_IMPORT_PLUGIN(ApngImagePlugin); int main(int argc, char *argv[]) { #if QT_VERSION > QT_VERSION_CHECK(5, 6, 0) @@ -16,10 +16,10 @@ int main(int argc, char *argv[]) // packages up to Qt 5.6, so this is conditional. AOApplication::setAttribute(Qt::AA_EnableHighDpiScaling); #endif + AOApplication main_app(argc, argv); main_app.construct_lobby(); main_app.net_manager->connect_to_master(); main_app.w_lobby->show(); - return main_app.exec(); } diff --git a/packet_distribution.cpp b/packet_distribution.cpp index 82b4387..0254064 100644 --- a/packet_distribution.cpp +++ b/packet_distribution.cpp @@ -634,25 +634,23 @@ void AOApplication::server_packet_received(AOPacket *p_packet) } else if (header == "KK") { - if (courtroom_constructed && f_contents.size() > 0) + if (courtroom_constructed && f_contents.size() >= 1) { - int f_cid = w_courtroom->get_cid(); - int remote_cid = f_contents.at(0).toInt(); - - if (f_cid != remote_cid && remote_cid != -1) - goto end; - - call_notice("You have been kicked."); + call_notice("You have been kicked from the server.\nReason: " + f_contents.at(0)); + construct_lobby(); + destruct_courtroom(); + } + } + else if (header == "KB") + { + if (courtroom_constructed && f_contents.size() >= 1) + { + call_notice("You have been banned from the server.\nReason: " + f_contents.at(0)); construct_lobby(); destruct_courtroom(); } } - else if (header == "KB") - { - if (courtroom_constructed && f_contents.size() > 0) - w_courtroom->set_ban(f_contents.at(0).toInt()); - } else if (header == "BD") { call_notice("You are banned on this server."); diff --git a/text_file_functions.cpp b/text_file_functions.cpp index 42bcd74..a633dd9 100644 --- a/text_file_functions.cpp +++ b/text_file_functions.cpp @@ -315,6 +315,32 @@ QString AOApplication::get_sfx(QString p_identifier) return return_sfx; } +QString AOApplication::get_sfx_suffix(QString sound_to_check) +{ + QString mp3_check = get_sounds_path() + sound_to_check + ".mp3"; + QString opus_check = get_sounds_path() + sound_to_check + ".opus"; + if(file_exists(opus_check)) + { + return sound_to_check + ".opus"; + } + if(file_exists(mp3_check)) + { + return sound_to_check + ".mp3"; + } + return sound_to_check + ".wav"; +} + +QString AOApplication::get_image_suffix(QString path_to_check) +{ + QString apng_check = path_to_check + ".apng"; + if(file_exists(apng_check)) + { + return path_to_check + ".apng"; + } + return path_to_check + ".gif"; +} + + //returns whatever is to the right of "search_line =" within target_tag and terminator_tag, trimmed //returns the empty string if the search line couldnt be found QString AOApplication::read_char_ini(QString p_char, QString p_search_line, QString target_tag)