mirror of https://github.com/stella-emu/stella.git
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:
parent
55e01a57ce
commit
9f2a046e11
|
@ -13,7 +13,7 @@
|
|||
// See the file "license" for information on usage and redistribution of
|
||||
// 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
|
||||
// Copyright (C) 2002-2004 The ScummVM project
|
||||
|
@ -45,7 +45,8 @@ BrowserDialog::BrowserDialog(GuiObject* boss, const GUI::Font& font,
|
|||
CommandSender(boss),
|
||||
_fileList(NULL),
|
||||
_currentPath(NULL),
|
||||
_nodeList(NULL)
|
||||
_nodeList(NULL),
|
||||
_mode(AbstractFilesystemNode::kListDirectoriesOnly)
|
||||
{
|
||||
const int lineHeight = font.getLineHeight(),
|
||||
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,
|
||||
// go back to the root/default dir.
|
||||
_node = FilesystemNode(startpath);
|
||||
|
@ -122,6 +126,10 @@ void BrowserDialog::setStartPath(const string& startpath)
|
|||
if(!_node.isValid())
|
||||
_node = FilesystemNode();
|
||||
|
||||
// Generally, we always want a directory listing
|
||||
if(!_node.isDirectory() && _node.hasParent())
|
||||
_node = _node.getParent();
|
||||
|
||||
// Alway refresh file list
|
||||
updateListing();
|
||||
}
|
||||
|
@ -139,8 +147,7 @@ void BrowserDialog::updateListing()
|
|||
_currentPath->setLabel(_node.path());
|
||||
|
||||
// Read in the data from the file system
|
||||
FSList content = _node.listDir();
|
||||
content.sort();
|
||||
FSList content = _node.listDir(_mode);
|
||||
|
||||
// Add '[..]' to indicate previous folder
|
||||
if(_node.hasParent())
|
||||
|
@ -159,6 +166,7 @@ void BrowserDialog::updateListing()
|
|||
|
||||
_nodeList->appendGame(name, content[idx].path(), "", isDir);
|
||||
}
|
||||
_nodeList->sortByName();
|
||||
|
||||
// Now fill the list widget with the contents of the GameList
|
||||
StringList l;
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
// See the file "license" for information on usage and redistribution of
|
||||
// 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
|
||||
// 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 setEmitSignal(int cmd) { _cmd = cmd; }
|
||||
void setStartPath(const string& startpath);
|
||||
void setStartPath(const string& startpath, FilesystemNode::ListMode mode);
|
||||
|
||||
protected:
|
||||
virtual void handleCommand(CommandSender* sender, int cmd, int data, int id);
|
||||
|
@ -66,6 +66,8 @@ class BrowserDialog : public Dialog, public CommandSender
|
|||
|
||||
FilesystemNode _node;
|
||||
GameList* _nodeList;
|
||||
|
||||
FilesystemNode::ListMode _mode;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
// See the file "license" for information on usage and redistribution of
|
||||
// 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
|
||||
// Copyright (C) 2002-2004 The ScummVM project
|
||||
|
@ -198,10 +198,12 @@ void FileSnapDialog::loadConfig()
|
|||
bool b = instance()->settings().getBool("rombrowse");
|
||||
myBrowseCheckbox->setState(b);
|
||||
myReloadButton->setEnabled(myIsGlobal && !b);
|
||||
|
||||
myStatePath->setLabel(instance()->stateDir());
|
||||
myCheatFile->setLabel(instance()->cheatFile());
|
||||
myPaletteFile->setLabel(instance()->paletteFile());
|
||||
myPropsFile->setLabel(instance()->propertiesFile());
|
||||
|
||||
mySnapPath->setLabel(instance()->settings().getString("ssdir"));
|
||||
mySnapSingleCheckbox->setState(!instance()->settings().getBool("sssingle"));
|
||||
|
||||
|
@ -211,34 +213,31 @@ void FileSnapDialog::loadConfig()
|
|||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void FileSnapDialog::saveConfig()
|
||||
{
|
||||
string s;
|
||||
bool b;
|
||||
instance()->settings().setString("romdir", myRomPath->getLabel());
|
||||
instance()->settings().setBool("rombrowse", myBrowseCheckbox->getState());
|
||||
|
||||
s = myRomPath->getLabel();
|
||||
instance()->settings().setString("romdir", s);
|
||||
instance()->settings().setString("statedir", myStatePath->getLabel());
|
||||
instance()->settings().setString("cheatfile", myCheatFile->getLabel());
|
||||
instance()->settings().setString("palettefile", myPaletteFile->getLabel());
|
||||
instance()->settings().setString("propsfile", myPropsFile->getLabel());
|
||||
|
||||
b = myBrowseCheckbox->getState();
|
||||
instance()->settings().setBool("rombrowse", b);
|
||||
instance()->settings().setString("ssdir", mySnapPath->getLabel());
|
||||
instance()->settings().setBool("sssingle", !mySnapSingleCheckbox->getState());
|
||||
|
||||
s = mySnapPath->getLabel();
|
||||
instance()->settings().setString("ssdir", s);
|
||||
|
||||
b = mySnapSingleCheckbox->getState();
|
||||
instance()->settings().setBool("sssingle", !b);
|
||||
|
||||
// Flush changes to disk
|
||||
// Flush changes to disk and inform the OSystem
|
||||
instance()->settings().saveConfig();
|
||||
instance()->setConfigPaths();
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void FileSnapDialog::openBrowser(const string& title, const string& startpath,
|
||||
int cmd)
|
||||
FilesystemNode::ListMode mode, int cmd)
|
||||
{
|
||||
parent()->addDialog(myBrowser);
|
||||
|
||||
myBrowser->setTitle(title);
|
||||
myBrowser->setEmitSignal(cmd);
|
||||
myBrowser->setStartPath(startpath);
|
||||
myBrowser->setStartPath(startpath, mode);
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
@ -259,32 +258,32 @@ void FileSnapDialog::handleCommand(CommandSender* sender, int cmd,
|
|||
|
||||
case kChooseRomDirCmd:
|
||||
openBrowser("Select ROM directory:", myRomPath->getLabel(),
|
||||
kRomDirChosenCmd);
|
||||
FilesystemNode::kListDirectoriesOnly, kRomDirChosenCmd);
|
||||
break;
|
||||
|
||||
case kChooseStateDirCmd:
|
||||
openBrowser("Select state directory:", myStatePath->getLabel(),
|
||||
kStateDirChosenCmd);
|
||||
FilesystemNode::kListDirectoriesOnly, kStateDirChosenCmd);
|
||||
break;
|
||||
|
||||
case kChooseCheatFileCmd:
|
||||
openBrowser("Select cheat file:", myCheatFile->getLabel(),
|
||||
kCheatFileChosenCmd);
|
||||
FilesystemNode::kListAll, kCheatFileChosenCmd);
|
||||
break;
|
||||
|
||||
case kChoosePaletteFileCmd:
|
||||
openBrowser("Select palette file:", myPaletteFile->getLabel(),
|
||||
kPaletteFileChosenCmd);
|
||||
FilesystemNode::kListAll, kPaletteFileChosenCmd);
|
||||
break;
|
||||
|
||||
case kChoosePropsFileCmd:
|
||||
openBrowser("Select properties file:", myPropsFile->getLabel(),
|
||||
kPropsFileChosenCmd);
|
||||
FilesystemNode::kListAll, kPropsFileChosenCmd);
|
||||
break;
|
||||
|
||||
case kChooseSnapDirCmd:
|
||||
openBrowser("Select snapshot directory:", mySnapPath->getLabel(),
|
||||
kSnapDirChosenCmd);
|
||||
FilesystemNode::kListDirectoriesOnly, kSnapDirChosenCmd);
|
||||
break;
|
||||
|
||||
case kRomDirChosenCmd:
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
// See the file "license" for information on usage and redistribution of
|
||||
// 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
|
||||
// Copyright (C) 2002-2004 The ScummVM project
|
||||
|
@ -33,6 +33,7 @@ class TabWidget;
|
|||
|
||||
#include "Dialog.hxx"
|
||||
#include "Command.hxx"
|
||||
#include "FSNode.hxx"
|
||||
|
||||
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);
|
||||
|
||||
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:
|
||||
enum {
|
||||
|
|
Loading…
Reference in New Issue