From c316e81e0c28a5f62e55f4a727f0ca152ab9874b Mon Sep 17 00:00:00 2001 From: Cerapter Date: Sun, 19 Aug 2018 09:19:18 +0200 Subject: Reset the default background to `default`. Reimplementation of `bed0b55e70f13adf772584fc0d31ebfe59597115` from old origin. --- path_functions.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'path_functions.cpp') diff --git a/path_functions.cpp b/path_functions.cpp index 6e772dbb..51ddcfdf 100644 --- a/path_functions.cpp +++ b/path_functions.cpp @@ -96,7 +96,7 @@ QString AOApplication::get_background_path() QString AOApplication::get_default_background_path() { - return get_base_path() + "background/gs4/"; + return get_base_path() + "background/default/"; } QString AOApplication::get_evidence_path() @@ -118,5 +118,5 @@ QString Courtroom::get_background_path() QString Courtroom::get_default_background_path() { - return ao_app->get_base_path() + "background/gs4/"; + return ao_app->get_base_path() + "background/default/"; } -- cgit From d314b8dd07f72d94724c3902258dfb2641d3435c Mon Sep 17 00:00:00 2001 From: Cerapter Date: Sun, 19 Aug 2018 09:37:34 +0200 Subject: Moved includes out of the CPP files into the header files. Reimplementation of `30a87d23c9c63bed072b3460e7482075dc530b2c` from the old origin. --- path_functions.cpp | 3 --- 1 file changed, 3 deletions(-) (limited to 'path_functions.cpp') diff --git a/path_functions.cpp b/path_functions.cpp index 51ddcfdf..5c3d7f3a 100644 --- a/path_functions.cpp +++ b/path_functions.cpp @@ -1,9 +1,6 @@ #include "aoapplication.h" #include "courtroom.h" #include "file_functions.h" -#include -#include -#include #ifdef BASE_OVERRIDE #include "base_override.h" -- cgit From 051c8975eccffc0a0b5b1312e06b2b412590e475 Mon Sep 17 00:00:00 2001 From: David Skoland Date: Thu, 15 Nov 2018 23:56:58 +0100 Subject: added case insensitive path function for those filesystems --- path_functions.cpp | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) (limited to 'path_functions.cpp') diff --git a/path_functions.cpp b/path_functions.cpp index 820c05a6..5c4972f0 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() + "/"; -- cgit From 8ffdd2afb84ec483160f156d24cf786165a9506c Mon Sep 17 00:00:00 2001 From: David Skoland Date: Fri, 16 Nov 2018 02:01:08 +0100 Subject: refactored path functions and added support for case-sensitive filesystems --- path_functions.cpp | 141 +++++++++++++++++++++++++++++++++-------------------- 1 file changed, 89 insertions(+), 52 deletions(-) (limited to 'path_functions.cpp') diff --git a/path_functions.cpp b/path_functions.cpp index 5c4972f0..83e47521 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() +QString AOApplication::get_default_theme_path(QString p_file) { - return get_base_path() + "themes/" + current_theme.toLower() + "/"; + QString path = get_base_path() + "themes/default/" + p_file; +#ifndef CASE_SENSITIVE_FILESYSTEM + return path; +#else + return get_case_sensitive_path(path); +#endif } -QString AOApplication::get_default_theme_path() +//assume that the capitalization of the theme in config is correct +QString AOApplication::get_theme_path(QString p_file) { - return get_base_path() + "themes/default/"; + 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 AOApplication::get_character_path(QString p_character, QString p_file) { - return get_base_path() + "characters/" + p_character.toLower() + "/"; + 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_demothings_path() +QString AOApplication::get_character_emotions_path(QString p_character, QString p_file) { - 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 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() { - return get_base_path() + "sounds/general/"; + 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 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() +QString AOApplication::get_background_path(QString p_file) { - if (courtroom_constructed) - return w_courtroom->get_background_path(); + 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(); - int result = files.indexOf(file_rx); +QString AOApplication::get_case_sensitive_path(QString p_file) { + qDebug() << "calling get_case_sensitive_path: " << p_file; - 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; -} + QFileInfo file(p_file); -QString Courtroom::get_background_path() -{ - return ao_app->get_base_path() + "background/" + current_background.toLower() + "/"; -} + //quick check to see if it's actually there first + if (file.exists()) return p_file; -QString Courtroom::get_default_background_path() -{ - return ao_app->get_base_path() + "background/default/"; + 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) + return file_path + "/" + files.at(result); + + //if nothing is found, let the caller handle the missing file + return p_file; } -- cgit From 727c39a1df42a5aba8a9c863ee2f05169d204ffa Mon Sep 17 00:00:00 2001 From: David Skoland Date: Fri, 16 Nov 2018 02:26:47 +0100 Subject: small fixes and removing compiler warnings --- path_functions.cpp | 35 ++++++++++++----------------------- 1 file changed, 12 insertions(+), 23 deletions(-) (limited to 'path_functions.cpp') diff --git a/path_functions.cpp b/path_functions.cpp index 83e47521..f066102d 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); -- cgit From ee4b9acfeb1a860cf67957548c544ff893ce71bb Mon Sep 17 00:00:00 2001 From: David Skoland Date: Fri, 16 Nov 2018 02:37:57 +0100 Subject: fixed get_sounds_path as well + nuked the last unneccessary tolower calls --- path_functions.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'path_functions.cpp') diff --git a/path_functions.cpp b/path_functions.cpp index f066102d..4d7e246c 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 -- cgit From 06c7a95bc2b10af9562e21825b810f045d410a57 Mon Sep 17 00:00:00 2001 From: David Skoland Date: Sat, 17 Nov 2018 18:57:35 +0100 Subject: changed variable names for clarity --- path_functions.cpp | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) (limited to 'path_functions.cpp') diff --git a/path_functions.cpp b/path_functions.cpp index 4d7e246c..d07a6481 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; -- cgit From fddb72950ed475227a4f2c94a5b567049272a54e Mon Sep 17 00:00:00 2001 From: David Skoland Date: Sat, 17 Nov 2018 20:11:59 +0100 Subject: reworked get_case_sensitive_path to be recursive --- path_functions.cpp | 45 ++++++++++++++------------------------------- 1 file changed, 14 insertions(+), 31 deletions(-) (limited to 'path_functions.cpp') diff --git a/path_functions.cpp b/path_functions.cpp index d07a6481..19c65654 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; -#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; + return path; #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) { - QFileInfo file(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; - //quick check to see if it's actually there first(also serves as base case for recursion) - if (file.exists()) return p_file; + QFileInfo file(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; } -- cgit From 027f95deccef0f17759cbb093dc4097caf8184da Mon Sep 17 00:00:00 2001 From: David Skoland Date: Sat, 17 Nov 2018 20:26:12 +0100 Subject: adjusted functions to reflect change in get_case_sensitive_path --- path_functions.cpp | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'path_functions.cpp') diff --git a/path_functions.cpp b/path_functions.cpp index 19c65654..afa1e11e 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) -- cgit From 5bf5a228335e4859b61ae1af8558778592395eeb Mon Sep 17 00:00:00 2001 From: oldmud0 Date: Sat, 17 Nov 2018 20:12:12 -0600 Subject: Fix compile-time issues from merge --- path_functions.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'path_functions.cpp') diff --git a/path_functions.cpp b/path_functions.cpp index 24041e2d..7d40054f 100644 --- a/path_functions.cpp +++ b/path_functions.cpp @@ -52,6 +52,16 @@ QString AOApplication::get_default_theme_path(QString p_file) #endif } +QString AOApplication::get_custom_theme_path(QString p_theme, QString p_file) +{ + QString path = get_base_path() + "themes/" + p_theme + "/" + p_file; +#ifndef CASE_SENSITIVE_FILESYSTEM + return path; +#else + return get_case_sensitive_path(path); +#endif +} + QString AOApplication::get_theme_path(QString p_file) { QString path = get_base_path() + "themes/" + current_theme + "/" + p_file; -- cgit