From 6356d56c58402de62281fce281ca66cf6bc027d1 Mon Sep 17 00:00:00 2001 From: thrust26 Date: Thu, 24 Dec 2020 12:24:23 +0100 Subject: [PATCH] refactored directory names, removed default load dir updated docs --- Changes.txt | 2 ++ docs/index.html | 10 ++++++++++ src/debugger/CartDebug.cxx | 6 +++--- src/debugger/DebuggerParser.cxx | 8 ++++---- src/debugger/gui/DebuggerDialog.cxx | 2 +- src/emucore/OSystem.cxx | 28 ++++++++++++---------------- src/emucore/OSystem.hxx | 13 ++++++------- src/emucore/Settings.cxx | 17 ++++++++--------- src/gui/BrowserDialog.cxx | 2 +- src/gui/GameInfoDialog.cxx | 2 +- src/gui/LoggerDialog.cxx | 2 +- src/gui/SnapshotDialog.cxx | 2 +- src/gui/UIDialog.cxx | 2 +- 13 files changed, 51 insertions(+), 45 deletions(-) diff --git a/Changes.txt b/Changes.txt index 2f733a6e3..32a133633 100644 --- a/Changes.txt +++ b/Changes.txt @@ -32,6 +32,8 @@ * Added sound to Time Machine playback. + * Added browser dialogs for user saved files. + * Extended global hotkeys for input devices & ports settings. * Increased sample size for CDFJ+. diff --git a/docs/index.html b/docs/index.html index 359a8bfed..5657ce955 100644 --- a/docs/index.html +++ b/docs/index.html @@ -3189,6 +3189,16 @@ Make the start path follow ROM launcher navigation. + +
-userdir <dir>
+ Set the path to save user files to. + + + +
-saveuserdir <0|1>
+ Update the user path when navigating in browser. + +
-maxres <WxH>
Useful for developers, this sets the maximum size of window that diff --git a/src/debugger/CartDebug.cxx b/src/debugger/CartDebug.cxx index b91e5dc26..47d3212ab 100644 --- a/src/debugger/CartDebug.cxx +++ b/src/debugger/CartDebug.cxx @@ -1352,7 +1352,7 @@ string CartDebug::saveDisassembly(string path) if(path.empty()) - path = myOSystem.userSaveDir().getPath() + path = myOSystem.userDir().getPath() + myConsole.properties().get(PropType::Cart_Name) + ".asm"; else // Append default extension when missing @@ -1380,7 +1380,7 @@ string CartDebug::saveDisassembly(string path) string CartDebug::saveRom(string path) { if(path.empty()) - path = myOSystem.userSaveDir().getPath() + path = myOSystem.userDir().getPath() + myConsole.properties().get(PropType::Cart_Name) + ".a26"; else // Append default extension when missing @@ -1406,7 +1406,7 @@ string CartDebug::saveAccessFile(string path) try { if(path.empty()) - path = myOSystem.userSaveDir().getPath() + path = myOSystem.userDir().getPath() + myConsole.properties().get(PropType::Cart_Name) + ".csv"; else // Append default extension when missing diff --git a/src/debugger/DebuggerParser.cxx b/src/debugger/DebuggerParser.cxx index 2c02c53dd..488fb68f6 100644 --- a/src/debugger/DebuggerParser.cxx +++ b/src/debugger/DebuggerParser.cxx @@ -683,7 +683,7 @@ string DebuggerParser::saveScriptFile(string file) // Use default path if no path is provided if(file.find_first_of(FilesystemNode::PATH_SEPARATOR) == string::npos) - file = debugger.myOSystem.userSaveDir().getPath() + file; + file = debugger.myOSystem.userDir().getPath() + file; FilesystemNode node(file); @@ -1144,7 +1144,7 @@ void DebuggerParser::executeDump() else { ostringstream file; - file << debugger.myOSystem.userSaveDir() + file << debugger.myOSystem.userDir() << debugger.myOSystem.console().properties().get(PropType::Cart_Name) << "_dbg_"; if(execDepth > 0) { @@ -1240,7 +1240,7 @@ void DebuggerParser::executeExec() file += ".script"; FilesystemNode node(file); if (!node.exists()) - node = FilesystemNode(debugger.myOSystem.userSaveDir().getPath() + file); + node = FilesystemNode(debugger.myOSystem.userDir().getPath() + file); if (argCount == 2) { execPrefix = argStrings[1]; @@ -1910,7 +1910,7 @@ void DebuggerParser::executeSaveses() { ostringstream filename; auto timeinfo = BSPF::localTime(); - filename << debugger.myOSystem.userSaveDir() + filename << debugger.myOSystem.userDir() << std::put_time(&timeinfo, "session_%F_%H-%M-%S.txt"); if(argCount && argStrings[0] == "?") diff --git a/src/debugger/gui/DebuggerDialog.cxx b/src/debugger/gui/DebuggerDialog.cxx index e258aca08..24b2ed4bf 100644 --- a/src/debugger/gui/DebuggerDialog.cxx +++ b/src/debugger/gui/DebuggerDialog.cxx @@ -466,7 +466,7 @@ void DebuggerDialog::showBrowser(BrowserType type, const string& defaultName) { createBrowser("Save " + title + " as"); - const string path = instance().userSaveDir().getPath() + defaultName; + const string path = instance().userDir().getPath() + defaultName; myBrowser->show(path, BrowserDialog::FileSave, cmd, kBdCancelCmd); } } diff --git a/src/emucore/OSystem.cxx b/src/emucore/OSystem.cxx index c9fb0070b..72ec65814 100644 --- a/src/emucore/OSystem.cxx +++ b/src/emucore/OSystem.cxx @@ -217,8 +217,8 @@ void OSystem::loadConfig(const Settings::Options& options) { // Get base directory and config file from derived class // It will decide whether it can override its default location - string baseDir, cfgFile, defSaveDir, defLoadDir; - getBaseDirAndConfig(baseDir, cfgFile, defSaveDir, defLoadDir, + string baseDir, cfgFile, homeDir, unused; + getBaseDirAndConfig(baseDir, cfgFile, homeDir, unused, ourOverrideBaseDirWithApp, ourOverrideBaseDir); // Get fully-qualified pathnames, and make directories when needed @@ -228,13 +228,9 @@ void OSystem::loadConfig(const Settings::Options& options) if(!cfgFile.empty()) myConfigFile = FilesystemNode(cfgFile); - myDefaultSaveDir = FilesystemNode(defSaveDir); - if(!myDefaultSaveDir.isDirectory()) - myDefaultSaveDir.makeDir(); - - myDefaultLoadDir = FilesystemNode(defLoadDir); - if(!myDefaultLoadDir.isDirectory()) - myDefaultLoadDir.makeDir(); + myHomeDir = FilesystemNode(homeDir); + if(!myHomeDir.isDirectory()) + myHomeDir.makeDir(); #ifdef SQLITE_SUPPORT mySettingsDb = make_shared(myBaseDir.getPath(), "settings"); @@ -249,10 +245,10 @@ void OSystem::loadConfig(const Settings::Options& options) // TODO: check if affected by '-baseDir'and 'basedirinapp' params string userDir = mySettings->getString("userdir"); if(userDir.empty()) - userDir = defSaveDir; - myUserSaveDir = FilesystemNode(userDir); - if(!myUserSaveDir.isDirectory()) - myUserSaveDir.makeDir(); + userDir = homeDir; + myUserDir = FilesystemNode(userDir); + if(!myUserDir.isDirectory()) + myUserDir.makeDir(); Logger::instance().setLogParameters(mySettings->getInt("loglevel"), mySettings->getBool("logtoconsole")); @@ -303,7 +299,7 @@ void OSystem::setConfigPaths() #ifdef PNG_SUPPORT const string& ssSaveDir = mySettings->getString("snapsavedir"); if(ssSaveDir == EmptyString) - mySnapshotSaveDir = defaultSaveDir(); + mySnapshotSaveDir = userDir(); else mySnapshotSaveDir = FilesystemNode(ssSaveDir); if(!mySnapshotSaveDir.isDirectory()) @@ -311,7 +307,7 @@ void OSystem::setConfigPaths() const string& ssLoadDir = mySettings->getString("snaploaddir"); if(ssLoadDir == EmptyString) - mySnapshotLoadDir = defaultLoadDir(); + mySnapshotLoadDir = userDir(); else mySnapshotLoadDir = FilesystemNode(ssLoadDir); if(!mySnapshotLoadDir.isDirectory()) @@ -346,7 +342,7 @@ void OSystem::setUserDir(const string& path) { mySettings->setValue("userdir", path); - myUserSaveDir = FilesystemNode(path); + myUserDir = FilesystemNode(path); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/emucore/OSystem.hxx b/src/emucore/OSystem.hxx index 1ac973976..0ce5aef4b 100644 --- a/src/emucore/OSystem.hxx +++ b/src/emucore/OSystem.hxx @@ -318,12 +318,11 @@ class OSystem const FilesystemNode& romFile() const { return myRomFile; } /** - The default locations for saving and loading various files that - don't already have a specific location. + The default and user defined locations for saving and loading various + files that don't already have a specific location. */ - const FilesystemNode& defaultSaveDir() const { return myDefaultSaveDir; } - const FilesystemNode& defaultLoadDir() const { return myDefaultLoadDir; } - const FilesystemNode& userSaveDir() const { return myUserSaveDir; } + const FilesystemNode& homeDir() const { return myHomeDir; } + const FilesystemNode& userDir() const { return myUserDir; } /** Open the given ROM and return an array containing its contents. @@ -556,8 +555,8 @@ class OSystem private: FilesystemNode myBaseDir, myStateDir, mySnapshotSaveDir, mySnapshotLoadDir, - myNVRamDir, myCfgDir, myDefaultSaveDir, myDefaultLoadDir, - myUserSaveDir; + myNVRamDir, myCfgDir, myHomeDir, + myUserDir; FilesystemNode myCheatFile, myConfigFile, myPaletteFile, myPropertiesFile; FilesystemNode myRomFile; string myRomMD5; diff --git a/src/emucore/Settings.cxx b/src/emucore/Settings.cxx index 8068b29a9..f9d8e459e 100644 --- a/src/emucore/Settings.cxx +++ b/src/emucore/Settings.cxx @@ -528,14 +528,14 @@ void Settings::usage() const << endl << " -saveonexit emulation\n" - << " -autoslot <1|0> Automatically change to next save slot when\n" + << " -autoslot <0|1> Automatically change to next save slot when\n" << " state saving\n" << endl << " -rominfo Display detailed information for the given ROM\n" << " -listrominfo Display contents of stella.pro, one line per ROM\n" << " entry\n" << endl - << " -exitlauncher <1|0> On exiting a ROM, go back to the ROM launcher\n" + << " -exitlauncher <0|1> On exiting a ROM, go back to the ROM launcher\n" << " -launcherpos Sets the window position in windowed EOM launcher mode\n" << " -launcherdisplay Sets the display for the ROM launcher\n" << " -launcherres The resolution to use in ROM launcher mode\n" @@ -544,11 +544,14 @@ void Settings::usage() const << " medium|large|\n" << " large12|large14|\n" << " large16>\n" - << " -launcherroms <1|0> Show only ROMs in the launcher (vs. all files)\n" - << " -launchersubdirs <1|0> Show files from subdirectories too\n" << " -romviewer Show ROM info viewer at given zoom level in ROM\n" << " launcher (use 0 for off)\n" - << " -followlauncher <0|1> Default ROM path follows launcher navigation\n" + << " -launcherroms <1|0> Show only ROMs in the launcher (vs. all files)\n" + << " -launchersubdirs <0|1> Show files from subdirectories too\n" + << " -romdir Set the path where the ROM launcher will start\n" + << " -followlauncher <0|1> Default ROM path follows launcher navigation\n" + << " -userdir Set the path to save user files to\n" + << " -saveuserdir <0|1> Update user path when navigating in browser\n" << " -lastrom Last played ROM, automatically selected in\n" << " launcher\n" << " -romloadcount Number of ROM to load next from multicard\n" @@ -572,10 +575,6 @@ void Settings::usage() const << " -ctrlrate Rate per second of repeated controller input in\n" << " UI\n" << " -basic_settings <0|1> Display only a basic settings dialog\n" - << " -romdir Set the directory where the ROM launcher will\n" - << " start\n" - << " -userdir The directory to save user files to\n" - << " -saveuserdir <1|0> Update user directory when navigating in browser\n" << " -avoxport The name of the serial port where an AtariVox is\n" << " connected\n" << " -holdreset Start the emulator with the Game Reset switch\n" diff --git a/src/gui/BrowserDialog.cxx b/src/gui/BrowserDialog.cxx index 026c16b2f..d401ed8cb 100644 --- a/src/gui/BrowserDialog.cxx +++ b/src/gui/BrowserDialog.cxx @@ -271,7 +271,7 @@ void BrowserDialog::handleCommand(CommandSender* sender, int cmd, break; case kHomeDirCmd: - _fileList->setDirectory(FilesystemNode(instance().defaultSaveDir())); + _fileList->setDirectory(FilesystemNode(instance().homeDir())); break; case EditableWidget::kChangedCmd: diff --git a/src/gui/GameInfoDialog.cxx b/src/gui/GameInfoDialog.cxx index 4273ce6fc..7710e9fa1 100644 --- a/src/gui/GameInfoDialog.cxx +++ b/src/gui/GameInfoDialog.cxx @@ -1397,7 +1397,7 @@ void GameInfoDialog::handleCommand(CommandSender* sender, int cmd, // to re-create it as necessary createBrowser("Export properties as"); - myBrowser->show(instance().userSaveDir().getPath() + myGameFile.getNameWithExt(".pro"), + myBrowser->show(instance().userDir().getPath() + myGameFile.getNameWithExt(".pro"), BrowserDialog::FileSave, kExportChosen); break; diff --git a/src/gui/LoggerDialog.cxx b/src/gui/LoggerDialog.cxx index 3f94e093e..83929464e 100644 --- a/src/gui/LoggerDialog.cxx +++ b/src/gui/LoggerDialog.cxx @@ -116,7 +116,7 @@ void LoggerDialog::saveConfig() // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void LoggerDialog::saveLogFile() { - FilesystemNode node = instance().defaultSaveDir(); + FilesystemNode node = instance().userDir(); node /= "stella.log"; try diff --git a/src/gui/SnapshotDialog.cxx b/src/gui/SnapshotDialog.cxx index 1f3edc36f..69ad94936 100644 --- a/src/gui/SnapshotDialog.cxx +++ b/src/gui/SnapshotDialog.cxx @@ -131,7 +131,7 @@ void SnapshotDialog::saveConfig() // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void SnapshotDialog::setDefaults() { - mySnapSavePath->setText(instance().userSaveDir().getShortPath()); + mySnapSavePath->setText(instance().userDir().getShortPath()); mySnapInterval->setValue(2); mySnapName->setState(false); mySnapSingle->setState(false); diff --git a/src/gui/UIDialog.cxx b/src/gui/UIDialog.cxx index 6ba10d9f8..b5b8fb72c 100644 --- a/src/gui/UIDialog.cxx +++ b/src/gui/UIDialog.cxx @@ -515,7 +515,7 @@ void UIDialog::setDefaults() myLauncherHeightSlider->setValue(h); myLauncherFontPopup->setSelected("medium", ""); myRomViewerSize->setValue(35); - mySnapLoadPath->setText(instance().defaultLoadDir().getShortPath()); + mySnapLoadPath->setText(instance().userDir().getShortPath()); myLauncherExitWidget->setState(false); break; }