Check in WIP on config paths before I screw something up (already happened multiple times).

This commit is contained in:
Stephen Anthony 2019-02-20 14:06:39 -03:30
parent e80e15538b
commit 8808f7b5e0
3 changed files with 37 additions and 10 deletions

View File

@ -42,18 +42,43 @@
#include "CheatManager.hxx"
#endif
/**
Checks the commandline for special settings that are used by various ports
to use a specific 'base directory'.
This needs to be done separately from the main commandline and settings
functionality, since they both depend on the settings file being already
available. However, since a variabe basedir implies a different location
for the settings file, it *must* be processed first.
This function will set the environment variables STELLA_BASEDIR and
STELLA_USECURRENTASBASEDIR; it is up to each port to use these as they wish.
*/
void checkForCustomBaseDir(int ac, char* av[]);
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void checkForCustomBaseDir(int ac, char* av[])
{
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#if defined(BSPF_MACOS)
int stellaMain(int argc, char* argv[])
int stellaMain(int ac, char* av[])
#else
int main(int argc, char* argv[])
int main(int ac, char* av[])
#endif
{
SET_MAIN_THREAD;
std::ios_base::sync_with_stdio(false);
// Check for custom base directory
// This needs to be done separately from the normal startup, since it
// queries information from the commandline that both OSystem and Settings
// need *before* they are created
checkForCustomBaseDir(ac, av);
// Create the parent OSystem object
unique_ptr<OSystem> theOSystem = MediaFactory::createOSystem();
theOSystem->loadConfig();
@ -70,7 +95,7 @@ int main(int argc, char* argv[])
// Take care of commandline arguments
theOSystem->logMessage("Loading commandline arguments ...", 2);
string romfile = theOSystem->settings().loadCommandLine(argc, argv);
string romfile = theOSystem->settings().loadCommandLine(ac, av);
// Finally, make sure the settings are valid
// We do it once here, so the rest of the program can assume valid settings

View File

@ -203,8 +203,13 @@ void OSystem::setConfigPaths()
buildDirIfRequired(myNVRamDir, myBaseDir + "nvram");
buildDirIfRequired(myCfgDir, myBaseDir + "cfg");
buildDirIfRequired(mySnapshotSaveDir, defaultSaveDir());
buildDirIfRequired(mySnapshotLoadDir, defaultLoadDir());
mySnapshotSaveDir = mySettings->getString("snapsavedir");
if(mySnapshotSaveDir == "") mySnapshotSaveDir = defaultSaveDir();
buildDirIfRequired(mySnapshotSaveDir, mySnapshotSaveDir);
mySnapshotLoadDir = mySettings->getString("snaploaddir");
if(mySnapshotLoadDir == "") mySnapshotLoadDir = defaultLoadDir();
buildDirIfRequired(mySnapshotLoadDir, mySnapshotLoadDir);
myCheatFile = FilesystemNode(myBaseDir + "stella.cht").getPath();
myPaletteFile = FilesystemNode(myBaseDir + "stella.pal").getPath();

View File

@ -15,8 +15,6 @@
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//============================================================================
#include <cassert>
#include "bspf.hxx"
#include "OSystem.hxx"
@ -104,7 +102,6 @@ Settings::Settings(OSystem& osystem)
// Config files and paths
setInternal("romdir", "");
// FIXME setInternal("basedir", "");
// ROM browser options
setInternal("exitlauncher", "false");
@ -147,7 +144,7 @@ Settings::Settings(OSystem& osystem)
setInternal("dev.rwportbreak", "true");
#endif
// player settings
// Player settings
setInternal("plr.stats", "false");
setInternal("plr.bankrandom", "false");
setInternal("plr.ramrandom", "true");
@ -164,7 +161,7 @@ Settings::Settings(OSystem& osystem)
setInternal("plr.tm.horizon", "10m"); // = ~10 minutes
setInternal("plr.eepromaccess", "false");
// developer settings
// Developer settings
setInternal("dev.settings", "false");
setInternal("dev.stats", "true");
setInternal("dev.bankrandom", "true");