mirror of
https://github.com/TerryCavanagh/VVVVVV.git
synced 2024-12-22 17:49:43 +01:00
Add -basedir option to specify base user directory (#154)
Useful for maintaining multiple save files or for debugging
This commit is contained in:
parent
93ec5783d5
commit
dd7170dc59
5 changed files with 29 additions and 7 deletions
|
@ -3,6 +3,7 @@ Contributors
|
||||||
|
|
||||||
(Ordered alphabetically by last name.)
|
(Ordered alphabetically by last name.)
|
||||||
|
|
||||||
|
* Matt "Stelpjo" Aaldenberg
|
||||||
* Christoph Böhmwalder (@chrboe)
|
* Christoph Böhmwalder (@chrboe)
|
||||||
* Charlie Bruce (@charliebruce)
|
* Charlie Bruce (@charliebruce)
|
||||||
* Brian Callahan (@ibara)
|
* Brian Callahan (@ibara)
|
||||||
|
@ -10,6 +11,7 @@ Contributors
|
||||||
* Allison Fleischer (AllisonFleischer)
|
* Allison Fleischer (AllisonFleischer)
|
||||||
* Daniel Lee (@ddm999)
|
* Daniel Lee (@ddm999)
|
||||||
* Fredrik Ljungdahl (@FredrIQ)
|
* Fredrik Ljungdahl (@FredrIQ)
|
||||||
|
* Matt Penny (@mwpenny)
|
||||||
* Elliott Saltar (@eboyblue3)
|
* Elliott Saltar (@eboyblue3)
|
||||||
* Marvin Scholz (@ePirat)
|
* Marvin Scholz (@ePirat)
|
||||||
* Keith Stellyes (@keithstellyes)
|
* Keith Stellyes (@keithstellyes)
|
||||||
|
@ -22,4 +24,3 @@ Contributors
|
||||||
* Rémi Verschelde (@akien-mga)
|
* Rémi Verschelde (@akien-mga)
|
||||||
* viri (viri.me)
|
* viri (viri.me)
|
||||||
* Wouter (Xesxen)
|
* Wouter (Xesxen)
|
||||||
* Matt "Stelpjo" Aaldenberg
|
|
||||||
|
|
|
@ -39,16 +39,30 @@ void PLATFORM_getOSDirectory(char* output);
|
||||||
void PLATFORM_migrateSaveData(char* output);
|
void PLATFORM_migrateSaveData(char* output);
|
||||||
void PLATFORM_copyFile(const char *oldLocation, const char *newLocation);
|
void PLATFORM_copyFile(const char *oldLocation, const char *newLocation);
|
||||||
|
|
||||||
int FILESYSTEM_init(char *argvZero, char *assetsPath)
|
int FILESYSTEM_init(char *argvZero, char* baseDir, char *assetsPath)
|
||||||
{
|
{
|
||||||
char output[MAX_PATH];
|
char output[MAX_PATH];
|
||||||
int mkdirResult;
|
int mkdirResult;
|
||||||
|
const char* pathSep = PHYSFS_getDirSeparator();
|
||||||
|
|
||||||
PHYSFS_init(argvZero);
|
PHYSFS_init(argvZero);
|
||||||
PHYSFS_permitSymbolicLinks(1);
|
PHYSFS_permitSymbolicLinks(1);
|
||||||
|
|
||||||
/* Determine the OS user directory */
|
/* Determine the OS user directory */
|
||||||
PLATFORM_getOSDirectory(output);
|
if (baseDir && strlen(baseDir) > 0)
|
||||||
|
{
|
||||||
|
strcpy(output, baseDir);
|
||||||
|
|
||||||
|
/* We later append to this path and assume it ends in a slash */
|
||||||
|
if (strcmp(std::string(1, output[strlen(output) - 1]).c_str(), pathSep) != 0)
|
||||||
|
{
|
||||||
|
strcat(output, pathSep);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
PLATFORM_getOSDirectory(output);
|
||||||
|
}
|
||||||
|
|
||||||
/* Create base user directory, mount */
|
/* Create base user directory, mount */
|
||||||
mkdirResult = mkdir(output, 0777);
|
mkdirResult = mkdir(output, 0777);
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
|
|
||||||
#include "tinyxml.h"
|
#include "tinyxml.h"
|
||||||
|
|
||||||
int FILESYSTEM_init(char *argvZero, char* assetsPath);
|
int FILESYSTEM_init(char *argvZero, char* baseDir, char* assetsPath);
|
||||||
void FILESYSTEM_deinit();
|
void FILESYSTEM_deinit();
|
||||||
|
|
||||||
char *FILESYSTEM_getUserSaveDirectory();
|
char *FILESYSTEM_getUserSaveDirectory();
|
||||||
|
|
|
@ -468,12 +468,15 @@ void Game::init(void)
|
||||||
patrons.push_back("Timothy Bragan");
|
patrons.push_back("Timothy Bragan");
|
||||||
|
|
||||||
/* CONTRIBUTORS.txt, again listed alphabetically (according to `sort`) by last name */
|
/* CONTRIBUTORS.txt, again listed alphabetically (according to `sort`) by last name */
|
||||||
|
githubfriends.push_back("Matt \"Stelpjo\" Aaldenberg");
|
||||||
githubfriends.push_back("Christoph B{hmwalder");
|
githubfriends.push_back("Christoph B{hmwalder");
|
||||||
githubfriends.push_back("Charlie Bruce");
|
githubfriends.push_back("Charlie Bruce");
|
||||||
githubfriends.push_back("Brian Callahan");
|
githubfriends.push_back("Brian Callahan");
|
||||||
githubfriends.push_back("Dav999");
|
githubfriends.push_back("Dav999");
|
||||||
githubfriends.push_back("Allison Fleischer");
|
githubfriends.push_back("Allison Fleischer");
|
||||||
githubfriends.push_back("Daniel Lee");
|
githubfriends.push_back("Daniel Lee");
|
||||||
|
githubfriends.push_back("Fredrik Ljungdahl");
|
||||||
|
githubfriends.push_back("Matt Penny");
|
||||||
githubfriends.push_back("Elliott Saltar");
|
githubfriends.push_back("Elliott Saltar");
|
||||||
githubfriends.push_back("Marvin Scholz");
|
githubfriends.push_back("Marvin Scholz");
|
||||||
githubfriends.push_back("Keith Stellyes");
|
githubfriends.push_back("Keith Stellyes");
|
||||||
|
|
|
@ -51,19 +51,23 @@ int main(int argc, char *argv[])
|
||||||
SDL_INIT_GAMECONTROLLER
|
SDL_INIT_GAMECONTROLLER
|
||||||
);
|
);
|
||||||
|
|
||||||
char* assets = NULL;
|
char* baseDir = NULL;
|
||||||
|
char* assetsPath = NULL;
|
||||||
|
|
||||||
for (int i = 1; i < argc; ++i) {
|
for (int i = 1; i < argc; ++i) {
|
||||||
if (strcmp(argv[i], "-renderer") == 0) {
|
if (strcmp(argv[i], "-renderer") == 0) {
|
||||||
++i;
|
++i;
|
||||||
SDL_SetHintWithPriority(SDL_HINT_RENDER_DRIVER, argv[i], SDL_HINT_OVERRIDE);
|
SDL_SetHintWithPriority(SDL_HINT_RENDER_DRIVER, argv[i], SDL_HINT_OVERRIDE);
|
||||||
|
} else if (strcmp(argv[i], "-basedir") == 0) {
|
||||||
|
++i;
|
||||||
|
baseDir = argv[i];
|
||||||
} else if (strcmp(argv[i], "-assets") == 0) {
|
} else if (strcmp(argv[i], "-assets") == 0) {
|
||||||
++i;
|
++i;
|
||||||
assets = argv[i];
|
assetsPath = argv[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!FILESYSTEM_init(argv[0], assets))
|
if(!FILESYSTEM_init(argv[0], baseDir, assetsPath))
|
||||||
{
|
{
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue