From 9eed8feb838c31368dba6cd9716f67d800bf6e3b Mon Sep 17 00:00:00 2001 From: Björn Steinbrink Date: Thu, 4 Aug 2005 21:19:25 +0000 Subject: Added a method to the resource mananger to determine the real path of a file in the search path. Added a first user of that function. Minor cleanup. --- ChangeLog | 9 +++++++++ src/gui/browserbox.cpp | 4 +++- src/main.cpp | 2 +- src/resources/resourcemanager.cpp | 7 +++++++ src/resources/resourcemanager.h | 5 +++++ 5 files changed, 25 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 32230b5b..8f41d7f6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2005-08-04 Björn Steinbrink + + * src/main.cpp: Use "true" instead of "1" as bool argument. + * src/resources/resourcemanager.cpp, src/resources/resourcemanager.h: + Added a method to determine the real path of a file in the PhysFS search + path. + * src/gui/browserbox.cpp: Make use of then new resource manager method to + determine the real path of a file. + 2005-08-03 Andrej Sinicyn * src/game.cpp, src/game.h, src/gui/requesttrade.cpp,src/gui/requesttrade.h: diff --git a/src/gui/browserbox.cpp b/src/gui/browserbox.cpp index 58877b6e..52a13763 100644 --- a/src/gui/browserbox.cpp +++ b/src/gui/browserbox.cpp @@ -24,6 +24,7 @@ #include #include "../graphics.h" #include "../main.h" +#include "../resources/resourcemanager.h" #include "browserbox.h" #include "gui.h" @@ -45,7 +46,8 @@ BrowserBox::BrowserBox(unsigned int mode): { if (useOpenGL) { browserFont = new gcn::ImageFont( - TMW_DATADIR "data/graphics/gui/browserfont.png", + ResourceManager::getInstance()->getRealPath( + "graphics/gui/browserfont.png"), " abcdefghijklmnopqrstuvwxyz" "ABCDEFGHIJKLMNOPQRSTUVWXYZ01234567" "89:@!\"$%&/=?^+*#[]{}()<>_;'.,\\|-~`"); diff --git a/src/main.cpp b/src/main.cpp index 8e068601..df03908f 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -170,7 +170,7 @@ void init_engine() // Add the main data directory to our PhysicsFS search path resman->addToSearchPath("data", true); - resman->addToSearchPath(TMW_DATADIR "data", 1); + resman->addToSearchPath(TMW_DATADIR "data", true); // Add zip files to PhysicsFS resman->searchAndAddArchives("/", ".zip", true); // Updates, these override other files diff --git a/src/resources/resourcemanager.cpp b/src/resources/resourcemanager.cpp index 82029adf..d185b99a 100644 --- a/src/resources/resourcemanager.cpp +++ b/src/resources/resourcemanager.cpp @@ -118,6 +118,13 @@ bool ResourceManager::isDirectory(const std::string &path) return PHYSFS_isDirectory(path.c_str()); } +std::string ResourceManager::getRealPath(const std::string &path) +{ + const char *dirSep = PHYSFS_getDirSeparator(); + + return std::string(PHYSFS_getRealDir(path.c_str())) + dirSep + path; +} + Resource* ResourceManager::get(const E_RESOURCE_TYPE &type, const std::string &idPath) { diff --git a/src/resources/resourcemanager.h b/src/resources/resourcemanager.h index 9db8ccce..fa7d9610 100644 --- a/src/resources/resourcemanager.h +++ b/src/resources/resourcemanager.h @@ -95,6 +95,11 @@ class ResourceManager */ bool isDirectory(const std::string &path); + /** + * Returns the real path to the given path in the PhysFS search path + */ + std::string getRealPath(const std::string &path); + /** * Creates a resource and adds it to the resource map. The idPath is * converted into the appropriate path for the current operating system -- cgit v1.2.3-70-g09d2