diff --git a/Aquaria/DSQ.cpp b/Aquaria/DSQ.cpp index bc4fff4..ae5b482 100644 --- a/Aquaria/DSQ.cpp +++ b/Aquaria/DSQ.cpp @@ -153,7 +153,8 @@ Vector savesz; #define APPNAME "Aquaria" #endif -DSQ::DSQ(std::string fileSystem) : Core(fileSystem, LR_MAX, APPNAME, PARTICLE_AMOUNT_DEFAULT, "Aquaria") +DSQ::DSQ(const std::string& fileSystem, const std::string& extraDataDir) +: Core(fileSystem, extraDataDir, LR_MAX, APPNAME, PARTICLE_AMOUNT_DEFAULT, "Aquaria") { // 2048 //createDirectory(getSaveDirectory()); diff --git a/Aquaria/DSQ.h b/Aquaria/DSQ.h index 5043f36..258617e 100644 --- a/Aquaria/DSQ.h +++ b/Aquaria/DSQ.h @@ -1227,7 +1227,7 @@ enum NagType class DSQ : public Core { public: - DSQ(std::string fileSystem); + DSQ(const std::string& fileSystem, const std::string& extraDataDir); ~DSQ(); void init(); diff --git a/Aquaria/Main.cpp b/Aquaria/Main.cpp index 215c659..290e54d 100644 --- a/Aquaria/Main.cpp +++ b/Aquaria/Main.cpp @@ -83,18 +83,31 @@ static void CheckConfig(void) extern "C" int main(int argc,char *argv[]) { std::string dsqParam = ""; // fileSystem + std::string extraDataDir = ""; + const char *envPath = 0; #ifdef BBGE_BUILD_UNIX - const char *envPath = getenv("AQUARIA_DATA_PATH"); - if (envPath != NULL) + envPath = getenv("AQUARIA_DATA_PATH"); + if (envPath) + { dsqParam = envPath; + } #endif +#ifdef AQUARIA_DEFAULT_DATA_DIR + if(!envPath) + dsqParam = AQUARIA_DEFAULT_DATA_DIR; +#endif +#ifdef AQUARIA_EXTRA_DATA_DIR + if(!envPath) + extraDataDir = AQUARIA_EXTRA_DATA_DIR; +#endif + #endif CheckConfig(); { - DSQ dsql(dsqParam); + DSQ dsql(dsqParam, extraDataDir); dsql.init(); dsql.main(); dsql.shutdown(); diff --git a/BBGE/Core.cpp b/BBGE/Core.cpp index b71581c..5f865ce 100644 --- a/BBGE/Core.cpp +++ b/BBGE/Core.cpp @@ -41,6 +41,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #if BBGE_BUILD_WINDOWS #include +#include #endif #ifdef BBGE_BUILD_SDL @@ -884,12 +885,13 @@ static bool checkWritable(const std::string& path, bool warn, bool critical) const float SORT_DELAY = 10; -Core::Core(const std::string &filesystem, int numRenderLayers, const std::string &appName, int particleSize, std::string userDataSubFolder) +Core::Core(const std::string &filesystem, const std::string& extraDataDir, int numRenderLayers, const std::string &appName, int particleSize, std::string userDataSubFolder) : ActionMapper(), StateManager(), appName(appName) { sound = NULL; screenCapScale = Vector(1,1,1); timeUpdateType = TIMEUPDATE_DYNAMIC; + _extraDataDir = extraDataDir; fixedFPS = 60; @@ -1093,6 +1095,13 @@ void Core::initPlatform(const std::string &filesystem) } #endif #ifdef BBGE_BUILD_WINDOWS + if(filesystem.length()) + { + if(_chdir(filesystem.c_str()) != 0) + { + debugLog("chdir failed: " + filesystem); + } + } // FIXME: filesystem not handled #endif } @@ -4858,6 +4867,9 @@ void Core::setupFileAccess() //vfs.AddArchive("aqfiles.zip", false, ""); + if(_extraDataDir.length()) + vfs.MountExternalPath(_extraDataDir.c_str(), "", true, true); + debugLog("Done"); #endif diff --git a/BBGE/Core.h b/BBGE/Core.h index 84b08cb..d0b0f0b 100644 --- a/BBGE/Core.h +++ b/BBGE/Core.h @@ -973,7 +973,7 @@ public: NO_DESTROY }; // init - Core(const std::string &filesystem, int numRenderLayers, const std::string &appName="BBGE", int particleSize=1024, std::string userDataSubFolder=""); + Core(const std::string &filesystem, const std::string& extraDataDir, int numRenderLayers, const std::string &appName="BBGE", int particleSize=1024, std::string userDataSubFolder=""); void initPlatform(const std::string &filesystem); ~Core(); @@ -1402,6 +1402,7 @@ protected: virtual void onRender(){} void setupFileAccess(); + std::string _extraDataDir; }; extern Core *core; diff --git a/CMakeLists.txt b/CMakeLists.txt index 6c16bd0..552eb09 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -211,6 +211,19 @@ if (NOT(AQUARIA_CUSTOM_BUILD_ID STREQUAL "")) ADD_DEFINITIONS("-DAQUARIA_CUSTOM_BUILD_ID=\"${AQUARIA_CUSTOM_BUILD_ID}\"") endif (NOT(AQUARIA_CUSTOM_BUILD_ID STREQUAL "")) +# Custom data directories +SET(AQUARIA_DEFAULT_DATA_DIR "" CACHE STRING + "Default data directory (for package maintainers only)") +if(NOT(AQUARIA_DEFAULT_DATA_DIR STREQUAL "")) + ADD_DEFINITIONS("-DAQUARIA_DEFAULT_DATA_DIR=\"${AQUARIA_DEFAULT_DATA_DIR}\"") +endif(NOT(AQUARIA_DEFAULT_DATA_DIR STREQUAL "")) + +SET(AQUARIA_EXTRA_DATA_DIR "" CACHE STRING + "Extra data directory, overrides files from default datadir (for package maintainers only)") +if(NOT(AQUARIA_EXTRA_DATA_DIR STREQUAL "")) + ADD_DEFINITIONS("-DAQUARIA_EXTRA_DATA_DIR=\"${AQUARIA_EXTRA_DATA_DIR}\"") +endif(NOT(AQUARIA_EXTRA_DATA_DIR STREQUAL "")) + # Aquaria/BBGE specific defines... ADD_DEFINITIONS(-DGL_GLEXT_LEGACY=1)