From 71bac5414e4e5a7ae802e15af6407641df05ba76 Mon Sep 17 00:00:00 2001 From: OmniTroid Date: Tue, 30 May 2017 22:06:06 +0200 Subject: [PATCH] added call word function and fixed an evidence-related crash --- Attorney_Online_remake.pro | 2 +- aoapplication.h | 5 +++-- aoevidencedisplay.cpp | 2 +- courtroom.cpp | 22 ++++++++++++++++++---- text_file_functions.cpp | 30 +++++++++++++++++++++++++++--- 5 files changed, 50 insertions(+), 11 deletions(-) diff --git a/Attorney_Online_remake.pro b/Attorney_Online_remake.pro index 3028e03..87b77fe 100644 --- a/Attorney_Online_remake.pro +++ b/Attorney_Online_remake.pro @@ -13,7 +13,7 @@ RC_ICONS = logo.ico TARGET = Attorney_Online_remake TEMPLATE = app -VERSION = 2.4.1.0 +VERSION = 2.4.2.0 SOURCES += main.cpp\ lobby.cpp \ diff --git a/aoapplication.h b/aoapplication.h index 4f51c4c..387f8c9 100644 --- a/aoapplication.h +++ b/aoapplication.h @@ -108,6 +108,7 @@ public: int get_default_music(); int get_default_sfx(); int get_default_blip(); + QStringList get_call_words(); void write_to_serverlist_txt(QString p_line); QVector read_serverlist_txt(); QString read_design_ini(QString p_identifier, QString p_design_path); @@ -115,7 +116,7 @@ public: pos_size_type get_element_dimensions(QString p_identifier, QString p_file); int get_font_size(QString p_identifier, QString p_file); QColor get_color(QString p_identifier, QString p_file); - QString get_sfx(QString p_identifier, QString p_file); + QString get_sfx(QString p_identifier); QString read_char_ini(QString p_char, QString p_search_line, QString target_tag, QString terminator_tag); QString get_char_side(QString p_char); QString get_showname(QString p_char); @@ -138,7 +139,7 @@ public: private: const int RELEASE = 2; const int MAJOR_VERSION = 4; - const int MINOR_VERSION = 1; + const int MINOR_VERSION = 2; QString user_theme = "default"; diff --git a/aoevidencedisplay.cpp b/aoevidencedisplay.cpp index 4d19865..cbe37c0 100644 --- a/aoevidencedisplay.cpp +++ b/aoevidencedisplay.cpp @@ -65,7 +65,7 @@ void AOEvidenceDisplay::show_evidence(QString p_evidence_image, bool is_left_sid this->setMovie(evidence_movie); evidence_movie->start(); - sfx_player->play(ao_app->get_sfx("evidence_present", "courtroom_sounds.ini")); + sfx_player->play(ao_app->get_sfx("evidence_present")); } void AOEvidenceDisplay::frame_change(int p_frame) diff --git a/courtroom.cpp b/courtroom.cpp index 8100035..e41549b 100644 --- a/courtroom.cpp +++ b/courtroom.cpp @@ -1112,7 +1112,21 @@ void Courtroom::handle_chatmessage_3() { realization_timer->start(60); ui_vp_realization->show(); - sfx_player->play(ao_app->get_sfx("realization", "courtroom_sounds.ini")); + sfx_player->play(ao_app->get_sfx("realization")); + } + + QString f_message = m_chatmessage[MESSAGE]; + QStringList call_words = ao_app->get_call_words(); + + for (QString word : call_words) + { + if (f_message.contains(word, Qt::CaseInsensitive)) + { + modcall_player->play(ao_app->get_sfx("word_call")); + ao_app->alert(this); + + break; + } } } @@ -1508,7 +1522,7 @@ void Courtroom::handle_wtce(QString p_wtce) //witness testimony if (p_wtce == "testimony1") { - sfx_player->play(ao_app->get_sfx("witness_testimony", sfx_file)); + sfx_player->play(ao_app->get_sfx("witness_testimony")); ui_vp_wtce->play("witnesstestimony"); testimony_in_progress = true; show_testimony(); @@ -1516,7 +1530,7 @@ void Courtroom::handle_wtce(QString p_wtce) //cross examination else if (p_wtce == "testimony2") { - sfx_player->play(ao_app->get_sfx("cross_examination", sfx_file)); + sfx_player->play(ao_app->get_sfx("cross_examination")); ui_vp_wtce->play("crossexamination"); testimony_in_progress = false; } @@ -1544,7 +1558,7 @@ void Courtroom::mod_called(QString p_ip) ui_server_chatlog->append(p_ip); if (ui_guard->isChecked()) { - modcall_player->play("sfx-gallery.wav"); + modcall_player->play(ao_app->get_sfx("mod_call")); ao_app->alert(this); } } diff --git a/text_file_functions.cpp b/text_file_functions.cpp index 891e13c..47a9df3 100644 --- a/text_file_functions.cpp +++ b/text_file_functions.cpp @@ -90,6 +90,28 @@ int AOApplication::get_default_blip() else return f_result.toInt(); } +QStringList AOApplication::get_call_words() +{ + QStringList return_value; + + QFile callwords_ini; + + callwords_ini.setFileName(get_base_path() + "callwords.ini"); + + if (!callwords_ini.open(QIODevice::ReadOnly)) + return return_value; + + QTextStream in(&callwords_ini); + + while (!in.atEnd()) + { + QString line = in.readLine(); + return_value.append(line); + } + + return return_value; +} + void AOApplication::write_to_serverlist_txt(QString p_line) { QFile serverlist_txt; @@ -292,10 +314,10 @@ QColor AOApplication::get_color(QString p_identifier, QString p_file) return return_color; } -QString AOApplication::get_sfx(QString p_identifier, QString p_file) +QString AOApplication::get_sfx(QString p_identifier) { - QString design_ini_path = get_theme_path() + p_file; - QString default_path = get_default_theme_path() + p_file; + QString design_ini_path = get_theme_path() + "courtroom_sounds.ini"; + QString default_path = get_default_theme_path() + "courtroom_sounds.ini"; QString f_result = read_design_ini(p_identifier, design_ini_path); QString return_sfx = ""; @@ -552,3 +574,5 @@ bool AOApplication::get_blank_blip() + +