1
0
Fork 0
mirror of https://github.com/AquariaOSE/Aquaria.git synced 2024-12-25 06:05:45 +00:00

Intial support for package paths (as suggested by smls).

This commit is mainly intended to ease packaging for linux.
Unless environment variable AQUARIA_DATA_PATH is set, there are two
directories which are checked by the game:
If AQUARIA_DEFAULT_DATA_DIR is defined, it will chdir there for main
operation. If it's not defined, it chdirs into the directory where
the executable is located.
Then, if AQUARIA_EXTRA_DATA_DIR is defined, it will mount this directory
and all contents into the working path, so that the files present there
will override those from the working directory when accessed by the game.

Setting the environment variable AQUARIA_DATA_PATH will disable this
behavior altogether and use *only* AQUARIA_DATA_PATH as working dir.
This commit is contained in:
fgenesis 2013-06-19 02:08:24 +02:00
parent 8fbed64db3
commit 13eca9785f
6 changed files with 47 additions and 7 deletions

View file

@ -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());

View file

@ -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();

View file

@ -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();

View file

@ -41,6 +41,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#if BBGE_BUILD_WINDOWS
#include <shlobj.h>
#include <direct.h>
#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

View file

@ -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;

View file

@ -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)