Config files for cheats, palette and properties can now be properly

selected from the UI.


git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@1329 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
stephena 2007-07-20 13:31:11 +00:00
parent 55e01a57ce
commit 9f2a046e11
4 changed files with 42 additions and 31 deletions

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: BrowserDialog.cxx,v 1.26 2007-01-19 21:53:27 stephena Exp $ // $Id: BrowserDialog.cxx,v 1.27 2007-07-20 13:31:10 stephena Exp $
// //
// Based on code from ScummVM - Scumm Interpreter // Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project // Copyright (C) 2002-2004 The ScummVM project
@ -45,7 +45,8 @@ BrowserDialog::BrowserDialog(GuiObject* boss, const GUI::Font& font,
CommandSender(boss), CommandSender(boss),
_fileList(NULL), _fileList(NULL),
_currentPath(NULL), _currentPath(NULL),
_nodeList(NULL) _nodeList(NULL),
_mode(AbstractFilesystemNode::kListDirectoriesOnly)
{ {
const int lineHeight = font.getLineHeight(), const int lineHeight = font.getLineHeight(),
bwidth = font.getStringWidth("Cancel") + 20, bwidth = font.getStringWidth("Cancel") + 20,
@ -113,8 +114,11 @@ BrowserDialog::~BrowserDialog()
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void BrowserDialog::setStartPath(const string& startpath) void BrowserDialog::setStartPath(const string& startpath,
FilesystemNode::ListMode mode)
{ {
_mode = mode;
// If no node has been set, or the last used one is now invalid, // If no node has been set, or the last used one is now invalid,
// go back to the root/default dir. // go back to the root/default dir.
_node = FilesystemNode(startpath); _node = FilesystemNode(startpath);
@ -122,6 +126,10 @@ void BrowserDialog::setStartPath(const string& startpath)
if(!_node.isValid()) if(!_node.isValid())
_node = FilesystemNode(); _node = FilesystemNode();
// Generally, we always want a directory listing
if(!_node.isDirectory() && _node.hasParent())
_node = _node.getParent();
// Alway refresh file list // Alway refresh file list
updateListing(); updateListing();
} }
@ -139,8 +147,7 @@ void BrowserDialog::updateListing()
_currentPath->setLabel(_node.path()); _currentPath->setLabel(_node.path());
// Read in the data from the file system // Read in the data from the file system
FSList content = _node.listDir(); FSList content = _node.listDir(_mode);
content.sort();
// Add '[..]' to indicate previous folder // Add '[..]' to indicate previous folder
if(_node.hasParent()) if(_node.hasParent())
@ -159,6 +166,7 @@ void BrowserDialog::updateListing()
_nodeList->appendGame(name, content[idx].path(), "", isDir); _nodeList->appendGame(name, content[idx].path(), "", isDir);
} }
_nodeList->sortByName();
// Now fill the list widget with the contents of the GameList // Now fill the list widget with the contents of the GameList
StringList l; StringList l;

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: BrowserDialog.hxx,v 1.11 2007-01-01 18:04:52 stephena Exp $ // $Id: BrowserDialog.hxx,v 1.12 2007-07-20 13:31:10 stephena Exp $
// //
// Based on code from ScummVM - Scumm Interpreter // Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project // Copyright (C) 2002-2004 The ScummVM project
@ -45,7 +45,7 @@ class BrowserDialog : public Dialog, public CommandSender
void setTitle(const string& title) { _title->setLabel(title); } void setTitle(const string& title) { _title->setLabel(title); }
void setEmitSignal(int cmd) { _cmd = cmd; } void setEmitSignal(int cmd) { _cmd = cmd; }
void setStartPath(const string& startpath); void setStartPath(const string& startpath, FilesystemNode::ListMode mode);
protected: protected:
virtual void handleCommand(CommandSender* sender, int cmd, int data, int id); virtual void handleCommand(CommandSender* sender, int cmd, int data, int id);
@ -66,6 +66,8 @@ class BrowserDialog : public Dialog, public CommandSender
FilesystemNode _node; FilesystemNode _node;
GameList* _nodeList; GameList* _nodeList;
FilesystemNode::ListMode _mode;
}; };
#endif #endif

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: FileSnapDialog.cxx,v 1.7 2007-07-19 16:21:39 stephena Exp $ // $Id: FileSnapDialog.cxx,v 1.8 2007-07-20 13:31:11 stephena Exp $
// //
// Based on code from ScummVM - Scumm Interpreter // Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project // Copyright (C) 2002-2004 The ScummVM project
@ -198,10 +198,12 @@ void FileSnapDialog::loadConfig()
bool b = instance()->settings().getBool("rombrowse"); bool b = instance()->settings().getBool("rombrowse");
myBrowseCheckbox->setState(b); myBrowseCheckbox->setState(b);
myReloadButton->setEnabled(myIsGlobal && !b); myReloadButton->setEnabled(myIsGlobal && !b);
myStatePath->setLabel(instance()->stateDir()); myStatePath->setLabel(instance()->stateDir());
myCheatFile->setLabel(instance()->cheatFile()); myCheatFile->setLabel(instance()->cheatFile());
myPaletteFile->setLabel(instance()->paletteFile()); myPaletteFile->setLabel(instance()->paletteFile());
myPropsFile->setLabel(instance()->propertiesFile()); myPropsFile->setLabel(instance()->propertiesFile());
mySnapPath->setLabel(instance()->settings().getString("ssdir")); mySnapPath->setLabel(instance()->settings().getString("ssdir"));
mySnapSingleCheckbox->setState(!instance()->settings().getBool("sssingle")); mySnapSingleCheckbox->setState(!instance()->settings().getBool("sssingle"));
@ -211,34 +213,31 @@ void FileSnapDialog::loadConfig()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FileSnapDialog::saveConfig() void FileSnapDialog::saveConfig()
{ {
string s; instance()->settings().setString("romdir", myRomPath->getLabel());
bool b; instance()->settings().setBool("rombrowse", myBrowseCheckbox->getState());
s = myRomPath->getLabel(); instance()->settings().setString("statedir", myStatePath->getLabel());
instance()->settings().setString("romdir", s); instance()->settings().setString("cheatfile", myCheatFile->getLabel());
instance()->settings().setString("palettefile", myPaletteFile->getLabel());
instance()->settings().setString("propsfile", myPropsFile->getLabel());
b = myBrowseCheckbox->getState(); instance()->settings().setString("ssdir", mySnapPath->getLabel());
instance()->settings().setBool("rombrowse", b); instance()->settings().setBool("sssingle", !mySnapSingleCheckbox->getState());
s = mySnapPath->getLabel(); // Flush changes to disk and inform the OSystem
instance()->settings().setString("ssdir", s);
b = mySnapSingleCheckbox->getState();
instance()->settings().setBool("sssingle", !b);
// Flush changes to disk
instance()->settings().saveConfig(); instance()->settings().saveConfig();
instance()->setConfigPaths();
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FileSnapDialog::openBrowser(const string& title, const string& startpath, void FileSnapDialog::openBrowser(const string& title, const string& startpath,
int cmd) FilesystemNode::ListMode mode, int cmd)
{ {
parent()->addDialog(myBrowser); parent()->addDialog(myBrowser);
myBrowser->setTitle(title); myBrowser->setTitle(title);
myBrowser->setEmitSignal(cmd); myBrowser->setEmitSignal(cmd);
myBrowser->setStartPath(startpath); myBrowser->setStartPath(startpath, mode);
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -259,32 +258,32 @@ void FileSnapDialog::handleCommand(CommandSender* sender, int cmd,
case kChooseRomDirCmd: case kChooseRomDirCmd:
openBrowser("Select ROM directory:", myRomPath->getLabel(), openBrowser("Select ROM directory:", myRomPath->getLabel(),
kRomDirChosenCmd); FilesystemNode::kListDirectoriesOnly, kRomDirChosenCmd);
break; break;
case kChooseStateDirCmd: case kChooseStateDirCmd:
openBrowser("Select state directory:", myStatePath->getLabel(), openBrowser("Select state directory:", myStatePath->getLabel(),
kStateDirChosenCmd); FilesystemNode::kListDirectoriesOnly, kStateDirChosenCmd);
break; break;
case kChooseCheatFileCmd: case kChooseCheatFileCmd:
openBrowser("Select cheat file:", myCheatFile->getLabel(), openBrowser("Select cheat file:", myCheatFile->getLabel(),
kCheatFileChosenCmd); FilesystemNode::kListAll, kCheatFileChosenCmd);
break; break;
case kChoosePaletteFileCmd: case kChoosePaletteFileCmd:
openBrowser("Select palette file:", myPaletteFile->getLabel(), openBrowser("Select palette file:", myPaletteFile->getLabel(),
kPaletteFileChosenCmd); FilesystemNode::kListAll, kPaletteFileChosenCmd);
break; break;
case kChoosePropsFileCmd: case kChoosePropsFileCmd:
openBrowser("Select properties file:", myPropsFile->getLabel(), openBrowser("Select properties file:", myPropsFile->getLabel(),
kPropsFileChosenCmd); FilesystemNode::kListAll, kPropsFileChosenCmd);
break; break;
case kChooseSnapDirCmd: case kChooseSnapDirCmd:
openBrowser("Select snapshot directory:", mySnapPath->getLabel(), openBrowser("Select snapshot directory:", mySnapPath->getLabel(),
kSnapDirChosenCmd); FilesystemNode::kListDirectoriesOnly, kSnapDirChosenCmd);
break; break;
case kRomDirChosenCmd: case kRomDirChosenCmd:

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: FileSnapDialog.hxx,v 1.3 2007-07-19 16:21:39 stephena Exp $ // $Id: FileSnapDialog.hxx,v 1.4 2007-07-20 13:31:11 stephena Exp $
// //
// Based on code from ScummVM - Scumm Interpreter // Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project // Copyright (C) 2002-2004 The ScummVM project
@ -33,6 +33,7 @@ class TabWidget;
#include "Dialog.hxx" #include "Dialog.hxx"
#include "Command.hxx" #include "Command.hxx"
#include "FSNode.hxx"
class FileSnapDialog : public Dialog, public CommandSender class FileSnapDialog : public Dialog, public CommandSender
{ {
@ -48,7 +49,8 @@ class FileSnapDialog : public Dialog, public CommandSender
virtual void handleCommand(CommandSender* sender, int cmd, int data, int id); virtual void handleCommand(CommandSender* sender, int cmd, int data, int id);
private: private:
void openBrowser(const string& title, const string& startpath, int cmd); void openBrowser(const string& title, const string& startpath,
FilesystemNode::ListMode mode, int cmd);
private: private:
enum { enum {