mirror of https://github.com/stella-emu/stella.git
enhanced and cleaned up OS specific path code
improved mouse double click marking added file list resizing in browser dialog
This commit is contained in:
parent
034017923d
commit
1ca00c7a0b
|
@ -336,6 +336,17 @@ namespace BSPF
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline bool isWhiteSpace(const char s)
|
||||||
|
{
|
||||||
|
const string WHITESPACES = " ,.;:+-*&/\\'";
|
||||||
|
|
||||||
|
for(size_t i = 0; i < WHITESPACES.length(); ++i)
|
||||||
|
if(s == WHITESPACES[i])
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
} // namespace BSPF
|
} // namespace BSPF
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -217,8 +217,8 @@ void OSystem::loadConfig(const Settings::Options& options)
|
||||||
{
|
{
|
||||||
// Get base directory and config file from derived class
|
// Get base directory and config file from derived class
|
||||||
// It will decide whether it can override its default location
|
// It will decide whether it can override its default location
|
||||||
string baseDir, cfgFile, homeDir, unused;
|
string baseDir, cfgFile, homeDir;
|
||||||
getBaseDirAndConfig(baseDir, cfgFile, homeDir, unused,
|
getBaseDirAndConfig(baseDir, cfgFile, homeDir,
|
||||||
ourOverrideBaseDirWithApp, ourOverrideBaseDir);
|
ourOverrideBaseDirWithApp, ourOverrideBaseDir);
|
||||||
|
|
||||||
// Get fully-qualified pathnames, and make directories when needed
|
// Get fully-qualified pathnames, and make directories when needed
|
||||||
|
@ -239,10 +239,9 @@ void OSystem::loadConfig(const Settings::Options& options)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
mySettings->setRepository(createSettingsRepository());
|
mySettings->setRepository(createSettingsRepository());
|
||||||
|
|
||||||
mySettings->load(options);
|
mySettings->load(options);
|
||||||
|
|
||||||
// TODO: check if affected by '-baseDir'and 'basedirinapp' params
|
// userDir is NOT affected by '-baseDir'and '-basedirinapp' params
|
||||||
string userDir = mySettings->getString("userdir");
|
string userDir = mySettings->getString("userdir");
|
||||||
if(userDir.empty())
|
if(userDir.empty())
|
||||||
userDir = homeDir;
|
userDir = homeDir;
|
||||||
|
|
|
@ -463,8 +463,7 @@ class OSystem
|
||||||
@param basedir The base directory for all configuration files
|
@param basedir The base directory for all configuration files
|
||||||
@param cfgfile The fully qualified pathname of the config file
|
@param cfgfile The fully qualified pathname of the config file
|
||||||
(including the base directory)
|
(including the base directory)
|
||||||
@param savedir The default directory to save various other files
|
@param homedir The default directory to store various other files
|
||||||
@param loaddir The default directory to load various other files
|
|
||||||
@param useappdir A hint that the base dir should be set to the
|
@param useappdir A hint that the base dir should be set to the
|
||||||
app directory; not all ports can do this, so
|
app directory; not all ports can do this, so
|
||||||
they are free to ignore it
|
they are free to ignore it
|
||||||
|
@ -473,8 +472,8 @@ class OSystem
|
||||||
they are free to ignore it
|
they are free to ignore it
|
||||||
*/
|
*/
|
||||||
virtual void getBaseDirAndConfig(string& basedir, string& cfgfile,
|
virtual void getBaseDirAndConfig(string& basedir, string& cfgfile,
|
||||||
string& savedir, string& loaddir,
|
string& homedir,
|
||||||
bool useappdir, const string& usedir) = 0;
|
bool useappdir, const string& usedir) = 0;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// Pointer to the EventHandler object
|
// Pointer to the EventHandler object
|
||||||
|
|
|
@ -126,9 +126,9 @@ void BrowserDialog::show(const string& startpath,
|
||||||
const string& ext)
|
const string& ext)
|
||||||
{
|
{
|
||||||
const int fontWidth = _font.getMaxCharWidth(),
|
const int fontWidth = _font.getMaxCharWidth(),
|
||||||
//fontHeight = _font.getFontHeight(),
|
fontHeight = _font.getFontHeight(),
|
||||||
HBORDER = fontWidth * 1.25;
|
HBORDER = fontWidth * 1.25,
|
||||||
//VGAP = fontHeight / 4;
|
VGAP = fontHeight / 4;
|
||||||
|
|
||||||
_mode = mode;
|
_mode = mode;
|
||||||
_cmd = cmd;
|
_cmd = cmd;
|
||||||
|
@ -153,7 +153,7 @@ void BrowserDialog::show(const string& startpath,
|
||||||
_fileList->setNameFilter([ext](const FilesystemNode& node) {
|
_fileList->setNameFilter([ext](const FilesystemNode& node) {
|
||||||
return BSPF::endsWithIgnoreCase(node.getName(), ext);
|
return BSPF::endsWithIgnoreCase(node.getName(), ext);
|
||||||
});
|
});
|
||||||
//_fileList->setHeight(_selected->getTop() - VGAP * 2 - _fileList->getTop());
|
_fileList->setHeight(_selected->getTop() - VGAP * 2 - _fileList->getTop());
|
||||||
|
|
||||||
_currentPath->setWidth(_savePathBox->getLeft() - _currentPath->getLeft() - fontWidth);
|
_currentPath->setWidth(_savePathBox->getLeft() - _currentPath->getLeft() - fontWidth);
|
||||||
_savePathBox->setEnabled(true);
|
_savePathBox->setEnabled(true);
|
||||||
|
@ -172,7 +172,7 @@ void BrowserDialog::show(const string& startpath,
|
||||||
_fileList->setNameFilter([ext](const FilesystemNode& node) {
|
_fileList->setNameFilter([ext](const FilesystemNode& node) {
|
||||||
return BSPF::endsWithIgnoreCase(node.getName(), ext);
|
return BSPF::endsWithIgnoreCase(node.getName(), ext);
|
||||||
});
|
});
|
||||||
//_fileList->setHeight(_selected->getTop() - VGAP * 2 - _fileList->getTop());
|
_fileList->setHeight(_selected->getTop() - VGAP * 2 - _fileList->getTop());
|
||||||
|
|
||||||
_currentPath->setWidth(_savePathBox->getLeft() - _currentPath->getLeft() - fontWidth);
|
_currentPath->setWidth(_savePathBox->getLeft() - _currentPath->getLeft() - fontWidth);
|
||||||
_savePathBox->setEnabled(true);
|
_savePathBox->setEnabled(true);
|
||||||
|
@ -192,7 +192,7 @@ void BrowserDialog::show(const string& startpath,
|
||||||
_fileList->setListMode(FilesystemNode::ListMode::DirectoriesOnly);
|
_fileList->setListMode(FilesystemNode::ListMode::DirectoriesOnly);
|
||||||
_fileList->setNameFilter([](const FilesystemNode&) { return true; });
|
_fileList->setNameFilter([](const FilesystemNode&) { return true; });
|
||||||
// TODO: scrollbar affected too!
|
// TODO: scrollbar affected too!
|
||||||
//_fileList->setHeight(_selected->getBottom() - _fileList->getTop());
|
_fileList->setHeight(_selected->getBottom() - _fileList->getTop());
|
||||||
|
|
||||||
_currentPath->setWidth(_savePathBox->getRight() - _currentPath->getLeft());
|
_currentPath->setWidth(_savePathBox->getRight() - _currentPath->getLeft());
|
||||||
_savePathBox->setEnabled(false);
|
_savePathBox->setEnabled(false);
|
||||||
|
|
|
@ -657,7 +657,7 @@ bool EditableWidget::killWord(int direction)
|
||||||
{
|
{
|
||||||
while(currentPos > 0)
|
while(currentPos > 0)
|
||||||
{
|
{
|
||||||
if(_editString[currentPos - 1] == ' ')
|
if(BSPF::isWhiteSpace(_editString[currentPos - 1]))
|
||||||
{
|
{
|
||||||
if(!space)
|
if(!space)
|
||||||
break;
|
break;
|
||||||
|
@ -673,7 +673,7 @@ bool EditableWidget::killWord(int direction)
|
||||||
{
|
{
|
||||||
while(currentPos < int(_editString.size()))
|
while(currentPos < int(_editString.size()))
|
||||||
{
|
{
|
||||||
if(currentPos && _editString[currentPos - 1] == ' ')
|
if(currentPos && BSPF::isWhiteSpace(_editString[currentPos - 1]))
|
||||||
{
|
{
|
||||||
if(!space)
|
if(!space)
|
||||||
break;
|
break;
|
||||||
|
@ -709,7 +709,7 @@ bool EditableWidget::moveWord(int direction, bool select)
|
||||||
{
|
{
|
||||||
while (currentPos > 0)
|
while (currentPos > 0)
|
||||||
{
|
{
|
||||||
if (_editString[currentPos - 1] == ' ')
|
if (BSPF::isWhiteSpace(_editString[currentPos - 1]))
|
||||||
{
|
{
|
||||||
if (!space)
|
if (!space)
|
||||||
break;
|
break;
|
||||||
|
@ -728,7 +728,7 @@ bool EditableWidget::moveWord(int direction, bool select)
|
||||||
{
|
{
|
||||||
while (currentPos < int(_editString.size()))
|
while (currentPos < int(_editString.size()))
|
||||||
{
|
{
|
||||||
if (currentPos && _editString[currentPos - 1] == ' ')
|
if (currentPos && BSPF::isWhiteSpace(_editString[currentPos - 1]))
|
||||||
{
|
{
|
||||||
if (!space)
|
if (!space)
|
||||||
break;
|
break;
|
||||||
|
@ -754,14 +754,14 @@ bool EditableWidget::markWord()
|
||||||
|
|
||||||
while(_caretPos + _selectSize < int(_editString.size()))
|
while(_caretPos + _selectSize < int(_editString.size()))
|
||||||
{
|
{
|
||||||
if(_editString[_caretPos + _selectSize] == ' ')
|
if(BSPF::isWhiteSpace(_editString[_caretPos + _selectSize]))
|
||||||
break;
|
break;
|
||||||
_selectSize++;
|
_selectSize++;
|
||||||
}
|
}
|
||||||
|
|
||||||
while(_caretPos > 0)
|
while(_caretPos > 0)
|
||||||
{
|
{
|
||||||
if(_editString[_caretPos - 1] == ' ')
|
if(BSPF::isWhiteSpace(_editString[_caretPos - 1]))
|
||||||
break;
|
break;
|
||||||
_caretPos--;
|
_caretPos--;
|
||||||
_selectSize++;
|
_selectSize++;
|
||||||
|
|
|
@ -56,6 +56,17 @@ ListWidget::ListWidget(GuiObject* boss, const GUI::Font& font,
|
||||||
_w = w - 1;
|
_w = w - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
void ListWidget::setHeight(int h)
|
||||||
|
{
|
||||||
|
Widget::setHeight(h);
|
||||||
|
if(_useScrollbar)
|
||||||
|
_scrollBar->setHeight(h);
|
||||||
|
|
||||||
|
_rows = (h - 2) / _lineHeight;
|
||||||
|
recalc();
|
||||||
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
void ListWidget::setSelected(int item)
|
void ListWidget::setSelected(int item)
|
||||||
{
|
{
|
||||||
|
|
|
@ -47,6 +47,7 @@ class ListWidget : public EditableWidget
|
||||||
|
|
||||||
int rows() const { return _rows; }
|
int rows() const { return _rows; }
|
||||||
int currentPos() const { return _currentPos; }
|
int currentPos() const { return _currentPos; }
|
||||||
|
void setHeight(int h) override;
|
||||||
|
|
||||||
int getSelected() const { return _selectedItem; }
|
int getSelected() const { return _selectedItem; }
|
||||||
void setSelected(int item);
|
void setSelected(int item);
|
||||||
|
|
|
@ -26,8 +26,8 @@
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
void OSystemLIBRETRO::getBaseDirAndConfig(string& basedir, string& cfgfile,
|
void OSystemLIBRETRO::getBaseDirAndConfig(string& basedir, string& cfgfile,
|
||||||
string& savedir, string& loaddir,
|
string& homedir,
|
||||||
bool useappdir, const string& usedir)
|
bool useappdir, const string& usedir)
|
||||||
{
|
{
|
||||||
loaddir = savedir = cfgfile = basedir = "." + slash;
|
basedir = cfgfile = homedir = "." + slash;
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,8 +41,7 @@ class OSystemLIBRETRO : public OSystem
|
||||||
@param basedir The base directory for all configuration files
|
@param basedir The base directory for all configuration files
|
||||||
@param cfgfile The fully qualified pathname of the config file
|
@param cfgfile The fully qualified pathname of the config file
|
||||||
(including the base directory)
|
(including the base directory)
|
||||||
@param savedir The default directory to save various other files
|
@param homedir The default directory to store various other files
|
||||||
@param loaddir The default directory to load various other files
|
|
||||||
@param useappdir A hint that the base dir should be set to the
|
@param useappdir A hint that the base dir should be set to the
|
||||||
app directory; not all ports can do this, so
|
app directory; not all ports can do this, so
|
||||||
they are free to ignore it
|
they are free to ignore it
|
||||||
|
@ -51,8 +50,8 @@ class OSystemLIBRETRO : public OSystem
|
||||||
they are free to ignore it
|
they are free to ignore it
|
||||||
*/
|
*/
|
||||||
void getBaseDirAndConfig(string& basedir, string& cfgfile,
|
void getBaseDirAndConfig(string& basedir, string& cfgfile,
|
||||||
string& savedir, string& loaddir,
|
string& homedir,
|
||||||
bool useappdir, const string& usedir) override;
|
bool useappdir, const string& usedir) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -21,8 +21,8 @@
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
void OSystemMACOS::getBaseDirAndConfig(string& basedir, string& cfgfile,
|
void OSystemMACOS::getBaseDirAndConfig(string& basedir, string& cfgfile,
|
||||||
string& savedir, string& loaddir,
|
string& homedir,
|
||||||
bool useappdir, const string& usedir)
|
bool useappdir, const string& usedir)
|
||||||
{
|
{
|
||||||
basedir = "~/Library/Application Support/Stella/";
|
basedir = "~/Library/Application Support/Stella/";
|
||||||
|
|
||||||
|
@ -31,14 +31,11 @@ void OSystemMACOS::getBaseDirAndConfig(string& basedir, string& cfgfile,
|
||||||
if(useappdir)
|
if(useappdir)
|
||||||
cout << "ERROR: base dir in app folder not supported" << endl;
|
cout << "ERROR: base dir in app folder not supported" << endl;
|
||||||
else if(usedir != "")
|
else if(usedir != "")
|
||||||
{
|
|
||||||
basedir = FilesystemNode(usedir).getPath();
|
basedir = FilesystemNode(usedir).getPath();
|
||||||
savedir = loaddir = basedir;
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
FilesystemNode desktop("~/Desktop/");
|
FilesystemNode desktop("~/Desktop/");
|
||||||
savedir = loaddir = desktop.isDirectory() ? desktop.getShortPath() : "~/";
|
homedir = desktop.isDirectory() ? desktop.getShortPath() : "~/";
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
|
|
@ -41,8 +41,7 @@ class OSystemMACOS : public OSystem
|
||||||
@param basedir The base directory for all configuration files
|
@param basedir The base directory for all configuration files
|
||||||
@param cfgfile The fully qualified pathname of the config file
|
@param cfgfile The fully qualified pathname of the config file
|
||||||
(including the base directory)
|
(including the base directory)
|
||||||
@param savedir The default directory to save various other files
|
@param homedir The default directory to store various other files
|
||||||
@param loaddir The default directory to load various other files
|
|
||||||
@param useappdir A hint that the base dir should be set to the
|
@param useappdir A hint that the base dir should be set to the
|
||||||
app directory; not all ports can do this, so
|
app directory; not all ports can do this, so
|
||||||
they are free to ignore it
|
they are free to ignore it
|
||||||
|
@ -51,8 +50,8 @@ class OSystemMACOS : public OSystem
|
||||||
they are free to ignore it
|
they are free to ignore it
|
||||||
*/
|
*/
|
||||||
void getBaseDirAndConfig(string& basedir, string& cfgfile,
|
void getBaseDirAndConfig(string& basedir, string& cfgfile,
|
||||||
string& savedir, string& loaddir,
|
string& homedir,
|
||||||
bool useappdir, const string& usedir) override;
|
bool useappdir, const string& usedir) override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual shared_ptr<KeyValueRepository> createSettingsRepository() override;
|
virtual shared_ptr<KeyValueRepository> createSettingsRepository() override;
|
||||||
|
|
|
@ -23,23 +23,21 @@
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
void OSystemUNIX::getBaseDirAndConfig(string& basedir, string& cfgfile,
|
void OSystemUNIX::getBaseDirAndConfig(string& basedir, string& cfgfile,
|
||||||
string& savedir, string& loaddir,
|
string& homedir,
|
||||||
bool useappdir, const string& usedir)
|
bool useappdir, const string& usedir)
|
||||||
{
|
{
|
||||||
// Use XDG_CONFIG_HOME if defined, otherwise use the default
|
// Use XDG_CONFIG_HOME if defined, otherwise use the default
|
||||||
string configDir = BSPF::getenv("XDG_CONFIG_HOME");
|
string configDir = BSPF::getenv("XDG_CONFIG_HOME");
|
||||||
|
|
||||||
if(configDir == EmptyString) configDir = "~/.config";
|
if(configDir == EmptyString) configDir = "~/.config";
|
||||||
basedir = configDir + "/stella";
|
basedir = configDir + "/stella";
|
||||||
savedir = loaddir = "~/";
|
homedir = "~/";
|
||||||
|
|
||||||
// Check to see if basedir overrides are active
|
// Check to see if basedir overrides are active
|
||||||
if(useappdir)
|
if(useappdir)
|
||||||
cout << "ERROR: base dir in app folder not supported" << endl;
|
cout << "ERROR: base dir in app folder not supported" << endl;
|
||||||
else if(usedir != "")
|
else if(usedir != "")
|
||||||
{
|
|
||||||
basedir = FilesystemNode(usedir).getPath();
|
basedir = FilesystemNode(usedir).getPath();
|
||||||
savedir = loaddir = basedir;
|
|
||||||
}
|
|
||||||
|
|
||||||
// (Currently) non-documented alternative for using version-specific
|
// (Currently) non-documented alternative for using version-specific
|
||||||
// config file
|
// config file
|
||||||
|
|
|
@ -41,8 +41,7 @@ class OSystemUNIX : public OSystem
|
||||||
@param basedir The base directory for all configuration files
|
@param basedir The base directory for all configuration files
|
||||||
@param cfgfile The fully qualified pathname of the config file
|
@param cfgfile The fully qualified pathname of the config file
|
||||||
(including the base directory)
|
(including the base directory)
|
||||||
@param savedir The default directory to save various other files
|
@param homedir The default directory to store various other files
|
||||||
@param loaddir The default directory to load various other files
|
|
||||||
@param useappdir A hint that the base dir should be set to the
|
@param useappdir A hint that the base dir should be set to the
|
||||||
app directory; not all ports can do this, so
|
app directory; not all ports can do this, so
|
||||||
they are free to ignore it
|
they are free to ignore it
|
||||||
|
@ -51,8 +50,8 @@ class OSystemUNIX : public OSystem
|
||||||
they are free to ignore it
|
they are free to ignore it
|
||||||
*/
|
*/
|
||||||
void getBaseDirAndConfig(string& basedir, string& cfgfile,
|
void getBaseDirAndConfig(string& basedir, string& cfgfile,
|
||||||
string& savedir, string& loaddir,
|
string& homedir,
|
||||||
bool useappdir, const string& usedir) override;
|
bool useappdir, const string& usedir) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Following constructors and assignment operators not supported
|
// Following constructors and assignment operators not supported
|
||||||
|
|
|
@ -19,8 +19,8 @@
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
void OSystemR77::getBaseDirAndConfig(string& basedir, string& cfgfile,
|
void OSystemR77::getBaseDirAndConfig(string& basedir, string& cfgfile,
|
||||||
string& savedir, string& loaddir, bool, const string&)
|
string& homeDir, bool, const string&)
|
||||||
{
|
{
|
||||||
basedir = savedir = loaddir = "/mnt/stella";
|
basedir = homeDir = "/mnt/stella";
|
||||||
cfgfile = "/mnt/stella/stellarc";
|
cfgfile = "/mnt/stella/stellarc";
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,8 +43,7 @@ class OSystemR77 : public OSystem
|
||||||
@param basedir The base directory for all configuration files
|
@param basedir The base directory for all configuration files
|
||||||
@param cfgfile The fully qualified pathname of the config file
|
@param cfgfile The fully qualified pathname of the config file
|
||||||
(including the base directory)
|
(including the base directory)
|
||||||
@param savedir The default directory to save various other files
|
@param homedir The default directory to store various other files
|
||||||
@param loaddir The default directory to load various other files
|
|
||||||
@param useappdir A hint that the base dir should be set to the
|
@param useappdir A hint that the base dir should be set to the
|
||||||
app directory; not all ports can do this, so
|
app directory; not all ports can do this, so
|
||||||
they are free to ignore it
|
they are free to ignore it
|
||||||
|
@ -53,8 +52,8 @@ class OSystemR77 : public OSystem
|
||||||
they are free to ignore it
|
they are free to ignore it
|
||||||
*/
|
*/
|
||||||
void getBaseDirAndConfig(string& basedir, string& cfgfile,
|
void getBaseDirAndConfig(string& basedir, string& cfgfile,
|
||||||
string& savedir, string& loaddir,
|
string& homedir,
|
||||||
bool useappdir, const string& usedir) override;
|
bool useappdir, const string& usedir) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Following constructors and assignment operators not supported
|
// Following constructors and assignment operators not supported
|
||||||
|
|
|
@ -23,11 +23,12 @@
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
void OSystemWINDOWS::getBaseDirAndConfig(string& basedir, string& cfgfile,
|
void OSystemWINDOWS::getBaseDirAndConfig(string& basedir, string& cfgfile,
|
||||||
string& savedir, string& loaddir,
|
string& homedir,
|
||||||
bool useappdir, const string& usedir)
|
bool useappdir, const string& usedir)
|
||||||
{
|
{
|
||||||
HomeFinder homefinder;
|
HomeFinder homefinder;
|
||||||
FilesystemNode appdata(homefinder.getAppDataPath());
|
FilesystemNode appdata(homefinder.getAppDataPath());
|
||||||
|
|
||||||
if(appdata.isDirectory())
|
if(appdata.isDirectory())
|
||||||
{
|
{
|
||||||
basedir = appdata.getShortPath();
|
basedir = appdata.getShortPath();
|
||||||
|
@ -35,8 +36,9 @@ void OSystemWINDOWS::getBaseDirAndConfig(string& basedir, string& cfgfile,
|
||||||
basedir += '\\';
|
basedir += '\\';
|
||||||
basedir += "Stella\\";
|
basedir += "Stella\\";
|
||||||
}
|
}
|
||||||
FilesystemNode defaultLoadSaveDir(homefinder.getDesktopPath());
|
|
||||||
savedir = loaddir = defaultLoadSaveDir.getShortPath();
|
FilesystemNode defaultHomeDir(homefinder.getDesktopPath());
|
||||||
|
homedir = defaultHomeDir.getShortPath();
|
||||||
|
|
||||||
// Check to see if basedir overrides are active
|
// Check to see if basedir overrides are active
|
||||||
if(useappdir)
|
if(useappdir)
|
||||||
|
@ -44,12 +46,13 @@ void OSystemWINDOWS::getBaseDirAndConfig(string& basedir, string& cfgfile,
|
||||||
char filename[MAX_PATH];
|
char filename[MAX_PATH];
|
||||||
GetModuleFileNameA(NULL, filename, sizeof(filename));
|
GetModuleFileNameA(NULL, filename, sizeof(filename));
|
||||||
FilesystemNode appdir(filename);
|
FilesystemNode appdir(filename);
|
||||||
|
|
||||||
appdir = appdir.getParent();
|
appdir = appdir.getParent();
|
||||||
if(appdir.isDirectory())
|
if(appdir.isDirectory())
|
||||||
savedir = loaddir = basedir = appdir.getPath();
|
basedir = appdir.getPath();
|
||||||
}
|
}
|
||||||
else if(usedir != "")
|
else if(usedir != "")
|
||||||
savedir = loaddir = basedir = FilesystemNode(usedir).getPath();
|
basedir = FilesystemNode(usedir).getPath();
|
||||||
|
|
||||||
cfgfile = basedir + "stella.ini";
|
cfgfile = basedir + "stella.ini";
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,8 +41,7 @@ class OSystemWINDOWS : public OSystem
|
||||||
@param basedir The base directory for all configuration files
|
@param basedir The base directory for all configuration files
|
||||||
@param cfgfile The fully qualified pathname of the config file
|
@param cfgfile The fully qualified pathname of the config file
|
||||||
(including the base directory)
|
(including the base directory)
|
||||||
@param savedir The default directory to save various other files
|
@param homedir The default directory to store various other files
|
||||||
@param loaddir The default directory to load various other files
|
|
||||||
@param useappdir A hint that the base dir should be set to the
|
@param useappdir A hint that the base dir should be set to the
|
||||||
app directory; not all ports can do this, so
|
app directory; not all ports can do this, so
|
||||||
they are free to ignore it
|
they are free to ignore it
|
||||||
|
@ -51,8 +50,8 @@ class OSystemWINDOWS : public OSystem
|
||||||
they are free to ignore it
|
they are free to ignore it
|
||||||
*/
|
*/
|
||||||
void getBaseDirAndConfig(string& basedir, string& cfgfile,
|
void getBaseDirAndConfig(string& basedir, string& cfgfile,
|
||||||
string& savedir, string& loaddir,
|
string& homedir,
|
||||||
bool useappdir, const string& usedir) override;
|
bool useappdir, const string& usedir) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Following constructors and assignment operators not supported
|
// Following constructors and assignment operators not supported
|
||||||
|
|
Loading…
Reference in New Issue