aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--aoapplication.h3
-rw-r--r--aoemotebutton.cpp2
-rw-r--r--file_functions.cpp6
-rw-r--r--file_functions.h1
-rw-r--r--path_functions.cpp45
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;
-#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;
}