From e9eefee1da52701ea197431c8b61c5549038b740 Mon Sep 17 00:00:00 2001 From: David Skoland Date: Thu, 15 Nov 2018 23:11:12 +0100 Subject: [PATCH 1/9] added extra define case in main.cpp for case-sensitive file systems --- main.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/main.cpp b/main.cpp index 5696e2e..a690f3c 100644 --- a/main.cpp +++ b/main.cpp @@ -8,6 +8,14 @@ #include +//this is a quite broad generalization +//the most common OSes(mac and windows) are _usually_ case insensitive +//however, there do exist mac installations with case sensitive filesystems +//in that case, define CASE_SENSITIVE_FILESYSTEM and compile on a mac +#if (defined (LINUX) || defined (__linux__)) +#define CASE_SENSITIVE_FILESYSTEM +#endif + int main(int argc, char *argv[]) { #if QT_VERSION > QT_VERSION_CHECK(5, 6, 0) From 051c8975eccffc0a0b5b1312e06b2b412590e475 Mon Sep 17 00:00:00 2001 From: David Skoland Date: Thu, 15 Nov 2018 23:56:58 +0100 Subject: [PATCH 2/9] added case insensitive path function for those filesystems --- aoapplication.h | 1 + courtroom.cpp | 2 +- main.cpp | 8 -------- path_functions.cpp | 31 ++++++++++++++++++++++++++++++- 4 files changed, 32 insertions(+), 10 deletions(-) diff --git a/aoapplication.h b/aoapplication.h index f69a0ea..0cb2c78 100644 --- a/aoapplication.h +++ b/aoapplication.h @@ -107,6 +107,7 @@ public: QString get_background_path(); QString get_default_background_path(); QString get_evidence_path(); + QString get_case_sensitive_path(QString p_dir, QString p_file); ////// Functions for reading and writing files ////// // Implementations file_functions.cpp diff --git a/courtroom.cpp b/courtroom.cpp index 5c552a1..5c3f966 100644 --- a/courtroom.cpp +++ b/courtroom.cpp @@ -748,7 +748,7 @@ void Courtroom::list_music() { ui_music_list->addItem(i_song); - QString song_path = ao_app->get_base_path() + "sounds/music/" + i_song.toLower(); + QString song_path = ao_app->get_music_path(i_song); if (file_exists(song_path)) ui_music_list->item(n_listed_songs)->setBackground(found_brush); diff --git a/main.cpp b/main.cpp index a690f3c..5696e2e 100644 --- a/main.cpp +++ b/main.cpp @@ -8,14 +8,6 @@ #include -//this is a quite broad generalization -//the most common OSes(mac and windows) are _usually_ case insensitive -//however, there do exist mac installations with case sensitive filesystems -//in that case, define CASE_SENSITIVE_FILESYSTEM and compile on a mac -#if (defined (LINUX) || defined (__linux__)) -#define CASE_SENSITIVE_FILESYSTEM -#endif - int main(int argc, char *argv[]) { #if QT_VERSION > QT_VERSION_CHECK(5, 6, 0) diff --git a/path_functions.cpp b/path_functions.cpp index 820c05a..5c4972f 100644 --- a/path_functions.cpp +++ b/path_functions.cpp @@ -4,10 +4,20 @@ #include #include #include +#include #ifdef BASE_OVERRIDE #include "base_override.h" #endif + +//this is a quite broad generalization +//the most common OSes(mac and windows) are _usually_ case insensitive +//however, there do exist mac installations with case sensitive filesystems +//in that case, define CASE_SENSITIVE_FILESYSTEM and compile on a mac +#if (defined (LINUX) || defined (__linux__)) +#define CASE_SENSITIVE_FILESYSTEM +#endif + QString base_path = ""; QString AOApplication::get_base_path() @@ -68,7 +78,11 @@ QString AOApplication::get_sounds_path() } QString AOApplication::get_music_path(QString p_song) { - return get_base_path() + "sounds/music/" + p_song.toLower(); +#ifndef CASE_SENSITIVE_FILESYSTEM + return get_base_path() + "sounds/music/" + p_song; +#else + return get_case_sensitive_path(get_base_path() + "sounds/music/", p_song); +#endif } QString AOApplication::get_background_path() @@ -96,6 +110,21 @@ QString AOApplication::get_evidence_path() return get_base_path() + default_path; } +QString AOApplication::get_case_sensitive_path(QString p_dir, QString p_file) { + qDebug() << "calling get_case_sensitive_path"; + QRegExp file_rx = QRegExp(p_file, Qt::CaseInsensitive); + QStringList files = QDir(p_dir).entryList(); + int result = files.indexOf(file_rx); + + if (result != -1) { + QString path = p_dir + files.at(result); + qDebug() << "returning " << path; + return path; + } + //if nothing is found, let the caller handle the missing file + return p_dir + p_file; +} + QString Courtroom::get_background_path() { return ao_app->get_base_path() + "background/" + current_background.toLower() + "/"; From 11c2f258ebf48f515cdba5c7ae9cccec447604dd Mon Sep 17 00:00:00 2001 From: David Skoland Date: Fri, 16 Nov 2018 01:02:55 +0100 Subject: [PATCH 3/9] removed legacy for char icons --- aoapplication.h | 9 +++++---- aocharbutton.cpp | 10 +--------- courtroom.h | 2 +- 3 files changed, 7 insertions(+), 14 deletions(-) diff --git a/aoapplication.h b/aoapplication.h index 0cb2c78..0fed8c9 100644 --- a/aoapplication.h +++ b/aoapplication.h @@ -98,16 +98,17 @@ public: //implementation in path_functions.cpp QString get_base_path(); QString get_data_path(); - QString get_theme_path(); - QString get_default_theme_path(); - QString get_character_path(QString p_character); + QString get_theme_path(QString p_file); + QString get_default_theme_path(QString p_file); + QString get_character_path(QString p_character, QString p_file); + QString get_character_emotions_path(QString p_character, QString p_file); QString get_demothings_path(); QString get_sounds_path(); QString get_music_path(QString p_song); QString get_background_path(); QString get_default_background_path(); QString get_evidence_path(); - QString get_case_sensitive_path(QString p_dir, QString p_file); + QString get_case_sensitive_path(QString p_file); ////// Functions for reading and writing files ////// // Implementations file_functions.cpp diff --git a/aocharbutton.cpp b/aocharbutton.cpp index 550e819..f7e7702 100644 --- a/aocharbutton.cpp +++ b/aocharbutton.cpp @@ -50,20 +50,12 @@ void AOCharButton::set_passworded() void AOCharButton::set_image(QString p_character) { - QString image_path = ao_app->get_character_path(p_character) + "char_icon.png"; - QString legacy_path = ao_app->get_demothings_path() + p_character.toLower() + "_char_icon.png"; - QString alt_path = ao_app->get_demothings_path() + p_character.toLower() + "_off.png"; + QString image_path = ao_app->get_character_path(p_character, "char_icon.png"); this->setText(""); if (file_exists(image_path)) this->setStyleSheet("border-image:url(\"" + image_path + "\")"); - else if (file_exists(legacy_path)) - { - this->setStyleSheet("border-image:url(\"" + legacy_path + "\")"); - //ninja optimization - QFile::copy(legacy_path, image_path); - } else { this->setStyleSheet("border-image:url()"); diff --git a/courtroom.h b/courtroom.h index 2cc099c..3c937b9 100644 --- a/courtroom.h +++ b/courtroom.h @@ -102,7 +102,7 @@ public: //implementations in path_functions.cpp QString get_background_path(); - QString get_default_background_path(); + QString get_default_background_path(QString p_file); //cid = character id, returns the cid of the currently selected character int get_cid() {return m_cid;} From 8ffdd2afb84ec483160f156d24cf786165a9506c Mon Sep 17 00:00:00 2001 From: David Skoland Date: Fri, 16 Nov 2018 02:01:08 +0100 Subject: [PATCH 4/9] refactored path functions and added support for case-sensitive filesystems --- aoapplication.h | 7 +- aobutton.cpp | 4 +- aocharmovie.cpp | 14 ++-- aoemotebutton.cpp | 8 +- aoevidencebutton.cpp | 6 +- aoevidencedisplay.cpp | 6 +- aoimage.cpp | 6 +- aomovie.cpp | 12 +-- aoscene.cpp | 12 +-- aosfxplayer.cpp | 2 +- charselect.cpp | 3 +- courtroom.cpp | 19 ++--- courtroom.h | 5 +- evidence.cpp | 2 +- path_functions.cpp | 171 ++++++++++++++++++++++++---------------- text_file_functions.cpp | 24 +++--- 16 files changed, 162 insertions(+), 139 deletions(-) diff --git a/aoapplication.h b/aoapplication.h index 0fed8c9..202a1b0 100644 --- a/aoapplication.h +++ b/aoapplication.h @@ -102,12 +102,11 @@ public: QString get_default_theme_path(QString p_file); QString get_character_path(QString p_character, QString p_file); QString get_character_emotions_path(QString p_character, QString p_file); - QString get_demothings_path(); QString get_sounds_path(); QString get_music_path(QString p_song); - QString get_background_path(); - QString get_default_background_path(); - QString get_evidence_path(); + QString get_background_path(QString p_file); + QString get_default_background_path(QString p_file); + QString get_evidence_path(QString p_file); QString get_case_sensitive_path(QString p_file); ////// Functions for reading and writing files ////// diff --git a/aobutton.cpp b/aobutton.cpp index ded35af..5be2e67 100644 --- a/aobutton.cpp +++ b/aobutton.cpp @@ -15,8 +15,8 @@ AOButton::~AOButton() void AOButton::set_image(QString p_image) { - QString image_path = ao_app->get_theme_path() + p_image; - QString default_image_path = ao_app->get_default_theme_path() + p_image; + QString image_path = ao_app->get_theme_path(p_image); + QString default_image_path = ao_app->get_default_theme_path(p_image); if (file_exists(image_path)) this->setStyleSheet("border-image:url(\"" + image_path + "\")"); diff --git a/aocharmovie.cpp b/aocharmovie.cpp index b591c22..180052a 100644 --- a/aocharmovie.cpp +++ b/aocharmovie.cpp @@ -19,10 +19,10 @@ AOCharMovie::AOCharMovie(QWidget *p_parent, AOApplication *p_ao_app) : QLabel(p_ 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 placeholder_path = ao_app->get_theme_path() + "placeholder.gif"; - QString placeholder_default_path = ao_app->get_default_theme_path() + "placeholder.gif"; + QString original_path = ao_app->get_character_path(p_char, emote_prefix + p_emote + ".gif"); + QString alt_path = ao_app->get_character_path(p_char, p_emote + ".png"); + 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)) @@ -58,7 +58,7 @@ void AOCharMovie::play(QString p_char, QString p_emote, QString emote_prefix) void AOCharMovie::play_pre(QString p_char, QString p_emote, int duration) { - QString gif_path = ao_app->get_character_path(p_char) + p_emote.toLower(); + QString gif_path = ao_app->get_character_path(p_char, p_emote); m_movie->stop(); this->clear(); @@ -107,7 +107,7 @@ void AOCharMovie::play_pre(QString p_char, QString p_emote, int duration) void AOCharMovie::play_talking(QString p_char, QString p_emote) { - QString gif_path = ao_app->get_character_path(p_char) + "(b)" + p_emote.toLower(); + QString gif_path = ao_app->get_character_path(p_char, "(b)" + p_emote); m_movie->stop(); this->clear(); @@ -120,7 +120,7 @@ void AOCharMovie::play_talking(QString p_char, QString p_emote) void AOCharMovie::play_idle(QString p_char, QString p_emote) { - QString gif_path = ao_app->get_character_path(p_char) + "(a)" + p_emote.toLower(); + QString gif_path = ao_app->get_character_path(p_char, "(a)" + p_emote); m_movie->stop(); this->clear(); diff --git a/aoemotebutton.cpp b/aoemotebutton.cpp index 9e3c446..76029cf 100644 --- a/aoemotebutton.cpp +++ b/aoemotebutton.cpp @@ -16,19 +16,13 @@ AOEmoteButton::AOEmoteButton(QWidget *p_parent, AOApplication *p_ao_app, int p_x void AOEmoteButton::set_image(QString p_char, int p_emote, QString suffix) { QString emotion_number = QString::number(p_emote + 1); - QString image_path = ao_app->get_character_path(p_char) + "emotions/ao2/button" + emotion_number + suffix; - QString alt_path = ao_app->get_character_path(p_char) + "emotions/button" + emotion_number + suffix; + QString image_path = ao_app->get_character_emotions_path(p_char, "button" + emotion_number + suffix); if (file_exists(image_path)) { this->setText(""); this->setStyleSheet("border-image:url(\"" + image_path + "\")"); } - else if (file_exists(alt_path)) - { - this->setText(""); - this->setStyleSheet("border-image:url(\"" + alt_path + "\")"); - } else { this->setText(ao_app->get_emote_comment(p_char, p_emote)); diff --git a/aoevidencebutton.cpp b/aoevidencebutton.cpp index 573b8ef..924aeb8 100644 --- a/aoevidencebutton.cpp +++ b/aoevidencebutton.cpp @@ -37,7 +37,7 @@ void AOEvidenceButton::reset() void AOEvidenceButton::set_image(QString p_image) { - QString image_path = ao_app->get_evidence_path() + p_image; + QString image_path = ao_app->get_evidence_path(p_image); if (file_exists(image_path)) { @@ -53,8 +53,8 @@ void AOEvidenceButton::set_image(QString p_image) void AOEvidenceButton::set_theme_image(QString p_image) { - QString theme_image_path = ao_app->get_theme_path() + p_image; - QString default_image_path = ao_app->get_default_theme_path() + p_image; + QString theme_image_path = ao_app->get_theme_path(p_image); + QString default_image_path = ao_app->get_default_theme_path(p_image); QString final_image_path; diff --git a/aoevidencedisplay.cpp b/aoevidencedisplay.cpp index 5364ffb..9ec105d 100644 --- a/aoevidencedisplay.cpp +++ b/aoevidencedisplay.cpp @@ -21,7 +21,7 @@ void AOEvidenceDisplay::show_evidence(QString p_evidence_image, bool is_left_sid sfx_player->set_volume(p_volume); - QString f_evidence_path = ao_app->get_evidence_path() + p_evidence_image; + QString f_evidence_path = ao_app->get_evidence_path(p_evidence_image); QPixmap f_pixmap(f_evidence_path); @@ -47,8 +47,8 @@ void AOEvidenceDisplay::show_evidence(QString p_evidence_image, bool is_left_sid evidence_icon->setPixmap(f_pixmap.scaled(evidence_icon->width(), evidence_icon->height(), Qt::IgnoreAspectRatio)); - QString f_default_gif_path = ao_app->get_default_theme_path() + gif_name; - QString f_gif_path = ao_app->get_theme_path() + gif_name; + QString f_default_gif_path = ao_app->get_default_theme_path(gif_name); + QString f_gif_path = ao_app->get_theme_path(gif_name); if (file_exists(f_gif_path)) final_gif_path = f_gif_path; diff --git a/aoimage.cpp b/aoimage.cpp index 935ba74..7bb56bb 100644 --- a/aoimage.cpp +++ b/aoimage.cpp @@ -15,8 +15,8 @@ AOImage::~AOImage() void AOImage::set_image(QString p_image) { - QString theme_image_path = ao_app->get_theme_path() + p_image; - QString default_image_path = ao_app->get_default_theme_path() + p_image; + QString theme_image_path = ao_app->get_theme_path(p_image); + QString default_image_path = ao_app->get_default_theme_path(p_image); QString final_image_path; @@ -32,7 +32,7 @@ void AOImage::set_image(QString p_image) void AOImage::set_image_from_path(QString p_path) { - QString default_path = ao_app->get_default_theme_path() + "chatmed.png"; + QString default_path = ao_app->get_default_theme_path("chatmed.png"); QString final_path; diff --git a/aomovie.cpp b/aomovie.cpp index 90c3701..53181de 100644 --- a/aomovie.cpp +++ b/aomovie.cpp @@ -28,15 +28,15 @@ 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_character_path(p_char, p_gif + ".gif"); else - custom_path = ao_app->get_character_path(p_char) + p_gif + "_bubble.gif"; + custom_path = ao_app->get_character_path(p_char, p_gif + "_bubble.gif"); QString custom_theme_path = ao_app->get_base_path() + "themes/" + p_custom_theme + "/" + p_gif + ".gif"; - QString theme_path = ao_app->get_theme_path() + p_gif + ".gif"; - QString default_theme_path = ao_app->get_default_theme_path() + p_gif + ".gif"; - QString placeholder_path = ao_app->get_theme_path() + "placeholder.gif"; - QString default_placeholder_path = ao_app->get_default_theme_path() + "placeholder.gif"; + QString theme_path = ao_app->get_theme_path(p_gif + ".gif"); + QString default_theme_path = ao_app->get_default_theme_path(p_gif + ".gif"); + QString placeholder_path = ao_app->get_theme_path("placeholder.gif"); + QString default_placeholder_path = ao_app->get_default_theme_path("placeholder.gif"); if (file_exists(custom_path)) gif_path = custom_path; diff --git a/aoscene.cpp b/aoscene.cpp index 5fe8304..7056bfc 100644 --- a/aoscene.cpp +++ b/aoscene.cpp @@ -10,9 +10,9 @@ AOScene::AOScene(QWidget *parent, AOApplication *p_ao_app) : QLabel(parent) void AOScene::set_image(QString p_image) { - QString background_path = ao_app->get_background_path() + p_image + ".png"; - QString animated_background_path = ao_app->get_background_path() + p_image + ".gif"; - QString default_path = ao_app->get_default_background_path() + p_image; + QString background_path = ao_app->get_background_path(p_image + ".png"); + QString animated_background_path = ao_app->get_background_path(p_image + ".gif"); + QString default_path = ao_app->get_default_background_path(p_image + ".png"); QPixmap background(background_path); QPixmap animated_background(animated_background_path); @@ -34,8 +34,8 @@ void AOScene::set_legacy_desk(QString p_image) //vanilla desks vary in both width and height. in order to make that work with viewport rescaling, //some INTENSE math is needed. - QString desk_path = ao_app->get_background_path() + p_image; - QString default_path = ao_app->get_default_background_path() + p_image; + QString desk_path = ao_app->get_background_path(p_image); + QString default_path = ao_app->get_default_background_path(p_image); QPixmap f_desk; @@ -53,7 +53,7 @@ void AOScene::set_legacy_desk(QString p_image) //int final_y = y_modifier * vp_height; //int final_w = w_modifier * f_desk.width(); - int final_h = h_modifier * f_desk.height(); + int final_h = static_cast(h_modifier * f_desk.height()); //this->resize(final_w, final_h); //this->setPixmap(f_desk.scaled(final_w, final_h)); diff --git a/aosfxplayer.cpp b/aosfxplayer.cpp index cc2f383..03a3ac5 100644 --- a/aosfxplayer.cpp +++ b/aosfxplayer.cpp @@ -19,7 +19,7 @@ void AOSfxPlayer::play(QString p_sfx, QString p_char) p_sfx = p_sfx.toLower(); QString f_path; if (p_char != "") - f_path = ao_app->get_character_path(p_char) + p_sfx; + f_path = ao_app->get_character_path(p_char, p_sfx); else f_path = ao_app->get_sounds_path() + p_sfx; diff --git a/charselect.cpp b/charselect.cpp index 4e4bccb..5686dd8 100644 --- a/charselect.cpp +++ b/charselect.cpp @@ -140,12 +140,11 @@ void Courtroom::char_clicked(int n_char) { int n_real_char = n_char + current_char_page * max_chars_on_page; - QString char_ini_path = ao_app->get_character_path(char_list.at(n_real_char).name) + "char.ini"; + QString char_ini_path = ao_app->get_character_path(char_list.at(n_real_char).name, "char.ini"); qDebug() << "char_ini_path" << char_ini_path; if (!file_exists(char_ini_path)) { - qDebug() << "did not find " << char_ini_path; call_notice("Could not find " + char_ini_path); return; } diff --git a/courtroom.cpp b/courtroom.cpp index 5c3f966..372d4b9 100644 --- a/courtroom.cpp +++ b/courtroom.cpp @@ -319,7 +319,7 @@ void Courtroom::set_widgets() //the size of the ui_vp_legacy_desk element relies on various factors and is set in set_scene() double y_modifier = 147.0 / 192.0; - int final_y = y_modifier * ui_viewport->height(); + int final_y = static_cast(y_modifier * ui_viewport->height()); ui_vp_legacy_desk->move(0, final_y); ui_vp_legacy_desk->hide(); @@ -620,11 +620,10 @@ void Courtroom::set_background(QString p_background) testimony_in_progress = false; current_background = p_background; - QString bg_path = get_background_path(); - is_ao2_bg = file_exists(bg_path + "defensedesk.png") && - file_exists(bg_path + "prosecutiondesk.png") && - file_exists(bg_path + "stand.png"); + is_ao2_bg = file_exists(ao_app->get_background_path("defensedesk.png")) && + file_exists(ao_app->get_background_path("prosecutiondesk.png")) && + file_exists(ao_app->get_background_path("stand.png")); if (is_ao2_bg) { @@ -696,11 +695,9 @@ void Courtroom::enter_courtroom(int p_cid) ui_prosecution_plus->hide(); } - 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.wav")) + file_exists(ao_app->get_character_path(current_char, "custom.gif")) && + file_exists(ao_app->get_character_path(current_char, "custom.wav"))) ui_custom_objection->show(); else ui_custom_objection->hide(); @@ -1197,12 +1194,12 @@ void Courtroom::play_preanim() sfx_delay_timer->start(sfx_delay); - if (!file_exists(ao_app->get_character_path(f_char) + f_preanim.toLower() + ".gif") || + if (!file_exists(ao_app->get_character_path(f_char, f_preanim.toLower() + ".gif")) || 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 " + ao_app->get_character_path(f_char, f_preanim.toLower() + ".gif"); return; } diff --git a/courtroom.h b/courtroom.h index 3c937b9..286ae7e 100644 --- a/courtroom.h +++ b/courtroom.h @@ -100,13 +100,10 @@ public: //send a message that the player is banned and quits the server void set_ban(int p_cid); - //implementations in path_functions.cpp - QString get_background_path(); - QString get_default_background_path(QString p_file); - //cid = character id, returns the cid of the currently selected character int get_cid() {return m_cid;} QString get_current_char() {return current_char;} + QString get_current_background() {return current_background;} //properly sets up some varibles: resets user state void enter_courtroom(int p_cid); diff --git a/evidence.cpp b/evidence.cpp index 19ffecf..4562136 100644 --- a/evidence.cpp +++ b/evidence.cpp @@ -195,7 +195,7 @@ void Courtroom::on_evidence_image_button_clicked() dialog.setFileMode(QFileDialog::ExistingFile); dialog.setNameFilter(tr("Images (*.png)")); dialog.setViewMode(QFileDialog::List); - dialog.setDirectory(ao_app->get_evidence_path()); + dialog.setDirectory(ao_app->get_base_path() + "evidence"); QStringList filenames; diff --git a/path_functions.cpp b/path_functions.cpp index 5c4972f..83e4752 100644 --- a/path_functions.cpp +++ b/path_functions.cpp @@ -46,91 +46,128 @@ QString AOApplication::get_data_path() return get_base_path() + "data/"; } -QString AOApplication::get_theme_path() -{ - return get_base_path() + "themes/" + current_theme.toLower() + "/"; -} - -QString AOApplication::get_default_theme_path() -{ - return get_base_path() + "themes/default/"; -} - -QString AOApplication::get_character_path(QString p_character) -{ - return get_base_path() + "characters/" + p_character.toLower() + "/"; -} - -QString AOApplication::get_demothings_path() -{ - QString default_path = "misc/demothings/"; - QString alt_path = "misc/RosterImages"; - if (dir_exists(default_path)) - return get_base_path() + default_path; - else if (dir_exists(alt_path)) - return get_base_path() + alt_path; - else - return get_base_path() + default_path; -} -QString AOApplication::get_sounds_path() -{ - return get_base_path() + "sounds/general/"; -} -QString AOApplication::get_music_path(QString p_song) +QString AOApplication::get_default_theme_path(QString p_file) { + QString path = get_base_path() + "themes/default/" + p_file; #ifndef CASE_SENSITIVE_FILESYSTEM - return get_base_path() + "sounds/music/" + p_song; + return path; #else - return get_case_sensitive_path(get_base_path() + "sounds/music/", p_song); + return get_case_sensitive_path(path); #endif } -QString AOApplication::get_background_path() +//assume that the capitalization of the theme in config is correct +QString AOApplication::get_theme_path(QString p_file) { - if (courtroom_constructed) - return w_courtroom->get_background_path(); + QString path = get_base_path() + "themes/" + current_theme + "/" + p_file; +#ifndef CASE_SENSITIVE_FILESYSTEM + return path; +#else + return get_case_sensitive_path(path); +#endif +} + +QString AOApplication::get_character_path(QString p_character, QString p_file) +{ + QString char_path = get_base_path() + "characters/" + p_character; +#ifndef CASE_SENSITIVE_FILESYSTEM + return char_path + "/" + p_file; +#else + //need two calls to get_case_sensitive_path because character folder name may be wrong as well as the filename + return get_case_sensitive_path( + get_case_sensitive_path(char_path) + "/" + p_file); +#endif +} + +QString AOApplication::get_character_emotions_path(QString p_character, QString p_file) +{ + QString char_path = get_base_path() + "characters/" + p_character; +#ifndef CASE_SENSITIVE_FILESYSTEM + return char_path + "/emotions/" + p_file; +#else + return get_case_sensitive_path( + get_case_sensitive_path(char_path) + "/emotions/" + p_file); +#endif +} + +QString AOApplication::get_sounds_path() +{ + QString path = get_base_path() + "sounds/general/"; +#ifndef CASE_SENSITIVE_FILESYSTEM + return path; +#else + return get_case_sensitive_path(path); +#endif +} + +QString AOApplication::get_music_path(QString p_song) +{ + QString path = get_base_path() + "sounds/music/" + p_song; +#ifndef CASE_SENSITIVE_FILESYSTEM + return path; +#else + return get_case_sensitive_path(path); +#endif +} + +QString AOApplication::get_background_path(QString p_file) +{ + QString bg_path = get_base_path() + "background/" + w_courtroom->get_current_background(); + if (courtroom_constructed) { +#ifndef CASE_SENSITIVE_FILESYSTEM + return bg_path + "/" + p_file; +#else + return get_case_sensitive_path( + get_case_sensitive_path(bg_path) + "/" + p_file); +#endif + } //this function being called when the courtroom isn't constructed makes no sense return ""; } -QString AOApplication::get_default_background_path() +QString AOApplication::get_default_background_path(QString p_file) { - return get_base_path() + "background/default/"; + QString path = get_base_path() + "background/default/" + p_file; +#ifndef CASE_SENSITIVE_FILESYSTEM + return path; +#else + return get_case_sensitive_path(path); +#endif } -QString AOApplication::get_evidence_path() +QString AOApplication::get_evidence_path(QString p_file) { - QString default_path = "evidence/"; - QString alt_path = "items/"; - if (dir_exists(default_path)) - return get_base_path() + default_path; - else if (dir_exists(alt_path)) - return get_base_path() + alt_path; - else - return get_base_path() + default_path; + QString path = get_base_path() + "evidence/" + p_file; +#ifndef CASE_SENSITIVE_FILESYSTEM + return path; +#else + return get_case_sensitive_path(path); +#endif } -QString AOApplication::get_case_sensitive_path(QString p_dir, QString p_file) { - qDebug() << "calling get_case_sensitive_path"; - QRegExp file_rx = QRegExp(p_file, Qt::CaseInsensitive); - QStringList files = QDir(p_dir).entryList(); +QString AOApplication::get_case_sensitive_path(QString p_file) { + qDebug() << "calling get_case_sensitive_path: " << p_file; + + QFileInfo file(p_file); + + //quick check to see if it's actually there first + if (file.exists()) return p_file; + + QString file_name = file.fileName(); + + qDebug() << "file_name: " << file_name; + + QString file_path = file.absolutePath(); + + qDebug() << "file_path: " << file_path; + + QRegExp file_rx = QRegExp(file_name, Qt::CaseInsensitive); + QStringList files = QDir(file_path).entryList(); int result = files.indexOf(file_rx); - if (result != -1) { - QString path = p_dir + files.at(result); - qDebug() << "returning " << path; - return path; - } + if (result != -1) + return file_path + "/" + files.at(result); + //if nothing is found, let the caller handle the missing file - return p_dir + p_file; -} - -QString Courtroom::get_background_path() -{ - return ao_app->get_base_path() + "background/" + current_background.toLower() + "/"; -} - -QString Courtroom::get_default_background_path() -{ - return ao_app->get_base_path() + "background/default/"; + return p_file; } diff --git a/text_file_functions.cpp b/text_file_functions.cpp index 1aebc35..e31ff86 100644 --- a/text_file_functions.cpp +++ b/text_file_functions.cpp @@ -212,8 +212,8 @@ QString AOApplication::read_design_ini(QString p_identifier, QString p_design_pa QPoint AOApplication::get_button_spacing(QString p_identifier, QString p_file) { - 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(p_file); + QString default_path = get_default_theme_path(p_file); QString f_result = read_design_ini(p_identifier, design_ini_path); QPoint return_value; @@ -242,8 +242,8 @@ QPoint AOApplication::get_button_spacing(QString p_identifier, QString p_file) pos_size_type AOApplication::get_element_dimensions(QString p_identifier, QString p_file) { - 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(p_file); + QString default_path = get_default_theme_path(p_file); QString f_result = read_design_ini(p_identifier, design_ini_path); pos_size_type return_value; @@ -276,8 +276,8 @@ pos_size_type AOApplication::get_element_dimensions(QString p_identifier, QStrin int AOApplication::get_font_size(QString p_identifier, QString p_file) { - 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(p_file); + QString default_path = get_default_theme_path(p_file); QString f_result = read_design_ini(p_identifier, design_ini_path); if (f_result == "") @@ -293,8 +293,8 @@ int AOApplication::get_font_size(QString p_identifier, QString p_file) QColor AOApplication::get_color(QString p_identifier, QString p_file) { - 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(p_file); + QString default_path = get_default_theme_path(p_file); QString f_result = read_design_ini(p_identifier, design_ini_path); QColor return_color(255, 255, 255); @@ -321,8 +321,8 @@ QColor AOApplication::get_color(QString p_identifier, QString p_file) QString AOApplication::get_sfx(QString p_identifier) { - QString design_ini_path = get_theme_path() + "courtroom_sounds.ini"; - QString default_path = get_default_theme_path() + "courtroom_sounds.ini"; + 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 = ""; @@ -344,7 +344,7 @@ QString AOApplication::get_sfx(QString p_identifier) //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, QString terminator_tag) { - QString char_ini_path = get_character_path(p_char) + "char.ini"; + QString char_ini_path = get_character_path(p_char, "char.ini"); QFile char_ini; @@ -586,4 +586,4 @@ bool AOApplication::ic_scroll_down_enabled() { QString f_result = read_config("ic_scroll_down"); return f_result.startsWith("true"); -} \ No newline at end of file +} From 727c39a1df42a5aba8a9c863ee2f05169d204ffa Mon Sep 17 00:00:00 2001 From: David Skoland Date: Fri, 16 Nov 2018 02:26:47 +0100 Subject: [PATCH 5/9] small fixes and removing compiler warnings --- aocharmovie.cpp | 6 ++++++ courtroom.cpp | 27 ++++++++++++--------------- path_functions.cpp | 35 ++++++++++++----------------------- 3 files changed, 30 insertions(+), 38 deletions(-) diff --git a/aocharmovie.cpp b/aocharmovie.cpp index 180052a..c3490ce 100644 --- a/aocharmovie.cpp +++ b/aocharmovie.cpp @@ -75,8 +75,11 @@ void AOCharMovie::play_pre(QString p_char, QString p_emote, int duration) real_duration += m_movie->nextFrameDelay(); m_movie->jumpToFrame(n_frame + 1); } + +#ifdef DEBUG_GIF qDebug() << "full_duration: " << full_duration; qDebug() << "real_duration: " << real_duration; +#endif double percentage_modifier = 100.0; @@ -88,7 +91,10 @@ void AOCharMovie::play_pre(QString p_char, QString p_emote, int duration) if (percentage_modifier > 100.0) percentage_modifier = 100.0; } + +#ifdef DEBUG_GIF qDebug() << "% mod: " << percentage_modifier; +#endif if (full_duration == 0 || full_duration >= real_duration) { diff --git a/courtroom.cpp b/courtroom.cpp index 372d4b9..e180817 100644 --- a/courtroom.cpp +++ b/courtroom.cpp @@ -1034,11 +1034,11 @@ void Courtroom::handle_chatmessage_2() case 1: case 2: case 6: play_preanim(); break; - default: - qDebug() << "W: invalid emote mod: " << QString::number(emote_mod); - //intentional fallthru case 0: case 5: handle_chatmessage_3(); + break; + default: + qDebug() << "W: invalid emote mod: " << QString::number(emote_mod); } } @@ -1094,15 +1094,11 @@ void Courtroom::handle_chatmessage_3() QString f_char = m_chatmessage[CHAR_NAME]; QString f_emote = m_chatmessage[EMOTE]; - switch (f_anim_state) - { - case 2: + if (f_anim_state == 2) { ui_vp_player_char->play_talking(f_char, f_emote); anim_state = 2; - break; - default: - qDebug() << "W: invalid anim_state: " << f_anim_state; - case 3: + } + else { ui_vp_player_char->play_idle(f_char, f_emote); anim_state = 3; } @@ -1194,12 +1190,11 @@ void Courtroom::play_preanim() sfx_delay_timer->start(sfx_delay); - if (!file_exists(ao_app->get_character_path(f_char, f_preanim.toLower() + ".gif")) || + if (!file_exists(ao_app->get_character_path(f_char, f_preanim + ".gif")) || preanim_duration < 0) { anim_state = 1; preanim_done(); - qDebug() << "could not find " + ao_app->get_character_path(f_char, f_preanim.toLower() + ".gif"); return; } @@ -1462,12 +1457,14 @@ void Courtroom::set_text_color() ui_vp_message->setStyleSheet("background-color: rgba(0, 0, 0, 0);" "color: yellow"); break; - default: - qDebug() << "W: undefined text color: " << m_chatmessage[TEXT_COLOR]; case WHITE: ui_vp_message->setStyleSheet("background-color: rgba(0, 0, 0, 0);" "color: white"); - + break; + default: + ui_vp_message->setStyleSheet("background-color: rgba(0, 0, 0, 0);" + "color: white"); + qDebug() << "W: undefined text color: " << m_chatmessage[TEXT_COLOR]; } } diff --git a/path_functions.cpp b/path_functions.cpp index 83e4752..f066102 100644 --- a/path_functions.cpp +++ b/path_functions.cpp @@ -18,27 +18,23 @@ #define CASE_SENSITIVE_FILESYSTEM #endif -QString base_path = ""; - QString AOApplication::get_base_path() { - if (base_path == "") - { -#ifdef BASE_OVERRIDE - base_path = base_override; -#elif defined(ANDROID) - QString sdcard_storage = getenv("SECONDARY_STORAGE"); - if (dir_exists(sdcard_storage + "/AO2/")){ - base_path = sdcard_storage + "/AO2/"; - }else{ - QString external_storage = getenv("EXTERNAL_STORAGE"); - base_path = external_storage + "/AO2/"; - } + QString base_path = ""; +#ifdef ANDROID + QString sdcard_storage = getenv("SECONDARY_STORAGE"); + if (dir_exists(sdcard_storage + "/AO2/")){ + base_path = sdcard_storage + "/AO2/"; + } + else { + QString external_storage = getenv("EXTERNAL_STORAGE"); + base_path = external_storage + "/AO2/"; + } #else base_path = QDir::currentPath() + "/base/"; #endif -} - return base_path; + + return base_path; } QString AOApplication::get_data_path() @@ -146,21 +142,14 @@ QString AOApplication::get_evidence_path(QString p_file) } QString AOApplication::get_case_sensitive_path(QString p_file) { - qDebug() << "calling get_case_sensitive_path: " << p_file; - QFileInfo file(p_file); //quick check to see if it's actually there first if (file.exists()) return p_file; QString file_name = file.fileName(); - - qDebug() << "file_name: " << file_name; - QString file_path = file.absolutePath(); - qDebug() << "file_path: " << file_path; - QRegExp file_rx = QRegExp(file_name, Qt::CaseInsensitive); QStringList files = QDir(file_path).entryList(); int result = files.indexOf(file_rx); From ee4b9acfeb1a860cf67957548c544ff893ce71bb Mon Sep 17 00:00:00 2001 From: David Skoland Date: Fri, 16 Nov 2018 02:37:57 +0100 Subject: [PATCH 6/9] fixed get_sounds_path as well + nuked the last unneccessary tolower calls --- aoapplication.h | 2 +- aoblipplayer.cpp | 2 +- aosfxplayer.cpp | 4 ++-- path_functions.cpp | 4 ++-- text_file_functions.cpp | 4 ++-- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/aoapplication.h b/aoapplication.h index 202a1b0..bb3067e 100644 --- a/aoapplication.h +++ b/aoapplication.h @@ -102,7 +102,7 @@ public: QString get_default_theme_path(QString p_file); QString get_character_path(QString p_character, QString p_file); QString get_character_emotions_path(QString p_character, QString p_file); - QString get_sounds_path(); + QString get_sounds_path(QString p_file); QString get_music_path(QString p_song); QString get_background_path(QString p_file); QString get_default_background_path(QString p_file); diff --git a/aoblipplayer.cpp b/aoblipplayer.cpp index 5e3929e..1e33236 100644 --- a/aoblipplayer.cpp +++ b/aoblipplayer.cpp @@ -16,7 +16,7 @@ AOBlipPlayer::~AOBlipPlayer() void AOBlipPlayer::set_blips(QString p_sfx) { m_sfxplayer->stop(); - QString f_path = ao_app->get_sounds_path() + p_sfx.toLower(); + QString f_path = ao_app->get_sounds_path(p_sfx); m_sfxplayer->setSource(QUrl::fromLocalFile(f_path)); set_volume(m_volume); } diff --git a/aosfxplayer.cpp b/aosfxplayer.cpp index 03a3ac5..575e91f 100644 --- a/aosfxplayer.cpp +++ b/aosfxplayer.cpp @@ -16,12 +16,12 @@ AOSfxPlayer::~AOSfxPlayer() void AOSfxPlayer::play(QString p_sfx, QString p_char) { m_sfxplayer->stop(); - p_sfx = p_sfx.toLower(); + p_sfx = p_sfx; QString f_path; if (p_char != "") f_path = ao_app->get_character_path(p_char, p_sfx); else - f_path = ao_app->get_sounds_path() + p_sfx; + f_path = ao_app->get_sounds_path(p_sfx); m_sfxplayer->setSource(QUrl::fromLocalFile(f_path)); set_volume(m_volume); diff --git a/path_functions.cpp b/path_functions.cpp index f066102..4d7e246 100644 --- a/path_functions.cpp +++ b/path_functions.cpp @@ -86,9 +86,9 @@ QString AOApplication::get_character_emotions_path(QString p_character, QString #endif } -QString AOApplication::get_sounds_path() +QString AOApplication::get_sounds_path(QString p_file) { - QString path = get_base_path() + "sounds/general/"; + QString path = get_base_path() + "sounds/general/" + p_file; #ifndef CASE_SENSITIVE_FILESYSTEM return path; #else diff --git a/text_file_functions.cpp b/text_file_functions.cpp index e31ff86..f63e720 100644 --- a/text_file_functions.cpp +++ b/text_file_functions.cpp @@ -433,14 +433,14 @@ QString AOApplication::get_chat(QString p_char) QString f_result = read_char_ini(p_char, "chat", "[Options]", "[Time]"); //handling the correct order of chat is a bit complicated, we let the caller do it - return f_result.toLower(); + return f_result; } QString AOApplication::get_char_shouts(QString p_char) { QString f_result = read_char_ini(p_char, "shouts", "[Options]", "[Time]"); - return f_result.toLower(); + return f_result; } int AOApplication::get_preanim_duration(QString p_char, QString p_emote) From 06c7a95bc2b10af9562e21825b810f045d410a57 Mon Sep 17 00:00:00 2001 From: David Skoland Date: Sat, 17 Nov 2018 18:57:35 +0100 Subject: [PATCH 7/9] changed variable names for clarity --- path_functions.cpp | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/path_functions.cpp b/path_functions.cpp index 4d7e246..d07a648 100644 --- a/path_functions.cpp +++ b/path_functions.cpp @@ -144,18 +144,28 @@ QString AOApplication::get_evidence_path(QString p_file) QString AOApplication::get_case_sensitive_path(QString p_file) { QFileInfo file(p_file); - //quick check to see if it's actually there first + //quick check to see if it's actually there first(also serves as base case for recursion) if (file.exists()) return p_file; - QString file_name = file.fileName(); - QString file_path = file.absolutePath(); + QString file_basename = file.fileName(); + QString file_parent_dir = file.absolutePath(); - QRegExp file_rx = QRegExp(file_name, Qt::CaseInsensitive); - QStringList files = QDir(file_path).entryList(); +#ifdef DEBUG_PATH_FUNCTIONS + qDebug() << "file_basename: " << file_basename; + qDebug() << "file_parent_dir: " << file_parent_dir; +#endif + + //if parent directory does not exist, recurse + //if (!file_exists(file_parent_dir)) { + + //} + + QRegExp file_rx = QRegExp(file_basename, Qt::CaseInsensitive); + QStringList files = QDir(file_parent_dir).entryList(); int result = files.indexOf(file_rx); if (result != -1) - return file_path + "/" + files.at(result); + return file_parent_dir + "/" + files.at(result); //if nothing is found, let the caller handle the missing file return p_file; From fddb72950ed475227a4f2c94a5b567049272a54e Mon Sep 17 00:00:00 2001 From: David Skoland Date: Sat, 17 Nov 2018 20:11:59 +0100 Subject: [PATCH 8/9] reworked get_case_sensitive_path to be recursive --- aoapplication.h | 3 +-- aoemotebutton.cpp | 2 +- file_functions.cpp | 6 ++++++ file_functions.h | 1 + path_functions.cpp | 45 ++++++++++++++------------------------------- 5 files changed, 23 insertions(+), 34 deletions(-) diff --git a/aoapplication.h b/aoapplication.h index bb3067e..6f97015 100644 --- a/aoapplication.h +++ b/aoapplication.h @@ -100,8 +100,7 @@ public: QString get_data_path(); QString get_theme_path(QString p_file); QString get_default_theme_path(QString p_file); - QString get_character_path(QString p_character, QString p_file); - QString get_character_emotions_path(QString p_character, QString p_file); + QString get_character_path(QString p_char, QString p_file); QString get_sounds_path(QString p_file); QString get_music_path(QString p_song); QString get_background_path(QString p_file); diff --git a/aoemotebutton.cpp b/aoemotebutton.cpp index 76029cf..9c1d388 100644 --- a/aoemotebutton.cpp +++ b/aoemotebutton.cpp @@ -16,7 +16,7 @@ AOEmoteButton::AOEmoteButton(QWidget *p_parent, AOApplication *p_ao_app, int p_x void AOEmoteButton::set_image(QString p_char, int p_emote, QString suffix) { QString emotion_number = QString::number(p_emote + 1); - QString image_path = ao_app->get_character_emotions_path(p_char, "button" + emotion_number + suffix); + QString image_path = ao_app->get_character_path(p_char, "emotions/button" + emotion_number + suffix); if (file_exists(image_path)) { diff --git a/file_functions.cpp b/file_functions.cpp index bc9185f..fa53ab6 100644 --- a/file_functions.cpp +++ b/file_functions.cpp @@ -16,3 +16,9 @@ bool dir_exists(QString dir_path) return check_dir.exists(); } + +bool exists(QString p_path) { + QFile file(p_path); + + return file.exists(); +} diff --git a/file_functions.h b/file_functions.h index 81a90ed..223804b 100644 --- a/file_functions.h +++ b/file_functions.h @@ -5,5 +5,6 @@ bool file_exists(QString file_path); bool dir_exists(QString file_path); +bool exists(QString p_path); #endif // FILE_FUNCTIONS_H diff --git a/path_functions.cpp b/path_functions.cpp index d07a648..19c6565 100644 --- a/path_functions.cpp +++ b/path_functions.cpp @@ -63,26 +63,13 @@ QString AOApplication::get_theme_path(QString p_file) #endif } -QString AOApplication::get_character_path(QString p_character, QString p_file) +QString AOApplication::get_character_path(QString p_char, QString p_file) { - QString char_path = get_base_path() + "characters/" + p_character; + QString path = get_base_path() + "characters/" + p_char + "/" + p_file; #ifndef CASE_SENSITIVE_FILESYSTEM - return char_path + "/" + p_file; + return path; #else - //need two calls to get_case_sensitive_path because character folder name may be wrong as well as the filename - return get_case_sensitive_path( - get_case_sensitive_path(char_path) + "/" + p_file); -#endif -} - -QString AOApplication::get_character_emotions_path(QString p_character, QString p_file) -{ - QString char_path = get_base_path() + "characters/" + p_character; -#ifndef CASE_SENSITIVE_FILESYSTEM - return char_path + "/emotions/" + p_file; -#else - return get_case_sensitive_path( - get_case_sensitive_path(char_path) + "/emotions/" + p_file); + return get_case_sensitive_path(path); #endif } @@ -142,31 +129,27 @@ QString AOApplication::get_evidence_path(QString p_file) } QString AOApplication::get_case_sensitive_path(QString p_file) { + //first, check to see if it's actually there (also serves as base case for recursion) + if (exists(p_file)) return p_file; + QFileInfo file(p_file); - //quick check to see if it's actually there first(also serves as base case for recursion) - if (file.exists()) return p_file; - QString file_basename = file.fileName(); - QString file_parent_dir = file.absolutePath(); + QString file_parent_dir = get_case_sensitive_path(file.absolutePath()); -#ifdef DEBUG_PATH_FUNCTIONS - qDebug() << "file_basename: " << file_basename; - qDebug() << "file_parent_dir: " << file_parent_dir; -#endif - - //if parent directory does not exist, recurse - //if (!file_exists(file_parent_dir)) { - - //} + //second, does it exist in the new parent dir? + if (exists(file_parent_dir + "/" + file_basename)) + return file_parent_dir + "/" + file_basename; + //last resort, dirlist parent dir and find case insensitive match QRegExp file_rx = QRegExp(file_basename, Qt::CaseInsensitive); QStringList files = QDir(file_parent_dir).entryList(); + int result = files.indexOf(file_rx); if (result != -1) return file_parent_dir + "/" + files.at(result); //if nothing is found, let the caller handle the missing file - return p_file; + return file_parent_dir + "/" + file_basename; } From 027f95deccef0f17759cbb093dc4097caf8184da Mon Sep 17 00:00:00 2001 From: David Skoland Date: Sat, 17 Nov 2018 20:26:12 +0100 Subject: [PATCH 9/9] adjusted functions to reflect change in get_case_sensitive_path --- path_functions.cpp | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/path_functions.cpp b/path_functions.cpp index 19c6565..afa1e11 100644 --- a/path_functions.cpp +++ b/path_functions.cpp @@ -52,7 +52,6 @@ QString AOApplication::get_default_theme_path(QString p_file) #endif } -//assume that the capitalization of the theme in config is correct QString AOApplication::get_theme_path(QString p_file) { QString path = get_base_path() + "themes/" + current_theme + "/" + p_file; @@ -95,17 +94,15 @@ QString AOApplication::get_music_path(QString p_song) QString AOApplication::get_background_path(QString p_file) { - QString bg_path = get_base_path() + "background/" + w_courtroom->get_current_background(); + QString path = get_base_path() + "background/" + w_courtroom->get_current_background() + "/" + p_file; if (courtroom_constructed) { #ifndef CASE_SENSITIVE_FILESYSTEM - return bg_path + "/" + p_file; + return path; #else - return get_case_sensitive_path( - get_case_sensitive_path(bg_path) + "/" + p_file); + return get_case_sensitive_path(path); #endif } - //this function being called when the courtroom isn't constructed makes no sense - return ""; + return get_default_background_path(p_file); } QString AOApplication::get_default_background_path(QString p_file)