Removed 'non-browse' mode in the ROM launcher, this time for good. I

actually removed it from 2.4.1, and re-added it in 2.4.2.  But I think
I've figured out a way to get the best of both worlds, and only have
one browsing mode.  This will become clearer once I finish the ROM
auditing feature.


git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@1426 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
stephena 2008-03-12 19:42:36 +00:00
parent cb0b5ae1ee
commit 3b32d07c1d
6 changed files with 69 additions and 148 deletions

View File

@ -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: Settings.cxx,v 1.133 2008-03-03 18:54:51 stephena Exp $
// $Id: Settings.cxx,v 1.134 2008-03-12 19:42:36 stephena Exp $
//============================================================================
#include <cassert>
@ -86,8 +86,6 @@ Settings::Settings(OSystem* osystem)
setInternal("propsfile", "");
// ROM browser options
setInternal("rombrowse", "true");
setInternal("lastrom", "");
setInternal("romviewer", "false");
// UI-related options
@ -316,7 +314,6 @@ void Settings::usage()
<< " -pspeed <number> Speed of digital emulated paddle movement (1-15)\n"
<< " -sa1 <left|right> Stelladaptor 1 emulates specified joystick port\n"
<< " -sa2 <left|right> Stelladaptor 2 emulates specified joystick port\n"
<< " -rombrowse <1|0> Use ROM browser mode (shows files and folders)\n"
<< " -romviewer <1|0> Show ROM info viewer in ROM launcher\n"
<< " -autoslot <1|0> Automatically switch to next save slot when state saving\n"
<< " -ssdir <path> The directory to save snapshot files to\n"

View File

@ -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.14 2008-02-06 13:45:23 stephena Exp $
// $Id: FileSnapDialog.cxx,v 1.15 2008-03-12 19:42:36 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -110,23 +110,8 @@ FileSnapDialog::FileSnapDialog(
_w - xpos - 10, font.getLineHeight(), "");
wid.push_back(mySnapPath);
// Use ROM browse mode
xpos = 30; ypos += mySnapPath->getHeight() + 8;
myBrowseCheckbox =
new CheckboxWidget(this, font, xpos, ypos, "Browse folders", kBrowseDirCmd);
wid.push_back(myBrowseCheckbox);
// Reload current ROM listing (in non-browse mode)
xpos += myBrowseCheckbox->getWidth() + 20;
myReloadRomButton =
new ButtonWidget(this, font, xpos, ypos-2,
font.getStringWidth(" Reload ROM Listing "), bheight,
"Reload ROM Listing", kReloadRomDirCmd);
//myReloadButton->setEditable(true);
wid.push_back(myReloadRomButton);
// Snapshot single or multiple saves
xpos = 30; ypos += myBrowseCheckbox->getHeight() + 4;
xpos = 30; ypos += b->getHeight() + 5;
mySnapSingleCheckbox = new CheckboxWidget(this, font, xpos, ypos,
"Multiple snapshots");
wid.push_back(mySnapSingleCheckbox);
@ -157,8 +142,6 @@ FileSnapDialog::FileSnapDialog(
{
romButton->clearFlags(WIDGET_ENABLED);
myRomPath->setEditable(false);
myBrowseCheckbox->clearFlags(WIDGET_ENABLED);
myReloadRomButton->clearFlags(WIDGET_ENABLED);
}
// Create file browser dialog
@ -180,9 +163,6 @@ void FileSnapDialog::loadConfig()
myPaletteFile->setEditString(instance()->paletteFile());
myPropsFile->setEditString(instance()->propertiesFile());
mySnapPath->setEditString(instance()->settings().getString("ssdir"));
bool b = instance()->settings().getBool("rombrowse");
myBrowseCheckbox->setState(b);
myReloadRomButton->setEnabled(myIsGlobal && !b);
mySnapSingleCheckbox->setState(!instance()->settings().getBool("sssingle"));
}
@ -195,7 +175,6 @@ void FileSnapDialog::saveConfig()
instance()->settings().setString("palettefile", myPaletteFile->getEditString());
instance()->settings().setString("propsfile", myPropsFile->getEditString());
instance()->settings().setString("ssdir", mySnapPath->getEditString());
instance()->settings().setBool("rombrowse", myBrowseCheckbox->getState());
instance()->settings().setBool("sssingle", !mySnapSingleCheckbox->getState());
// Flush changes to disk and inform the OSystem
@ -212,6 +191,7 @@ void FileSnapDialog::setDefaults()
const string& cheatfile = basedir + BSPF_PATH_SEPARATOR + "stella.cht";
const string& palettefile = basedir + BSPF_PATH_SEPARATOR + "stella.pal";
const string& propsfile = basedir + BSPF_PATH_SEPARATOR + "stella.pro";
const string& ssdir = basedir + BSPF_PATH_SEPARATOR;
myRomPath->setEditString(romdir);
myStatePath->setEditString(statedir);
@ -219,7 +199,7 @@ void FileSnapDialog::setDefaults()
myPaletteFile->setEditString(palettefile);
myPropsFile->setEditString(propsfile);
mySnapPath->setEditString(string(".") + BSPF_PATH_SEPARATOR);
mySnapPath->setEditString(ssdir);
mySnapSingleCheckbox->setState(true);
}
@ -244,10 +224,7 @@ void FileSnapDialog::handleCommand(CommandSender* sender, int cmd,
saveConfig();
close();
if(myIsGlobal)
{
sendCommand(kBrowseChangedCmd, 0, 0); // Call this before refreshing ROMs
sendCommand(kRomDirChosenCmd, 0, 0); // Let the boss know romdir has changed
}
break;
case kDefaultsCmd:

View File

@ -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.9 2008-02-06 13:45:23 stephena Exp $
// $Id: FileSnapDialog.hxx,v 1.10 2008-03-12 19:42:36 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -60,7 +60,6 @@ class FileSnapDialog : public Dialog, public CommandSender
kChoosePaletteFileCmd = 'LOpf', // palette file (stella.pal)
kChoosePropsFileCmd = 'LOpr', // properties file (stella.pro)
kChooseSnapDirCmd = 'LOsn', // snapshot dir
kBrowseDirCmd = 'LObd', // browse mode
kStateDirChosenCmd = 'LOsc', // state dir changed
kCheatFileChosenCmd = 'LOcc', // cheatfile changed
kPaletteFileChosenCmd = 'LOpc', // palette file changed
@ -78,9 +77,6 @@ class FileSnapDialog : public Dialog, public CommandSender
EditTextWidget* mySnapPath;
CheckboxWidget* mySnapSingleCheckbox;
CheckboxWidget* myBrowseCheckbox;
ButtonWidget* myReloadRomButton;
// Indicates if this dialog is used for global (vs. in-game) settings
bool myIsGlobal;
};

View File

@ -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: LauncherDialog.cxx,v 1.76 2008-02-06 13:45:24 stephena Exp $
// $Id: LauncherDialog.cxx,v 1.77 2008-03-12 19:42:36 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -55,7 +55,6 @@ LauncherDialog::LauncherDialog(OSystem* osystem, DialogContainer* parent,
myProgressBar(NULL),
myRomInfoWidget(NULL),
mySelectedItem(0),
myBrowseModeFlag(true),
myRomInfoFlag(false)
{
const GUI::Font& font = instance()->launcherFont();
@ -109,15 +108,15 @@ LauncherDialog::LauncherDialog(OSystem* osystem, DialogContainer* parent,
xpos = 10;
xpos += 5; ypos += myList->getHeight() + 4;
lwidth = font.getStringWidth("Note:");
myNoteLabel = new StaticTextWidget(this, font, xpos, ypos, lwidth, fontHeight,
"Note:", kTextAlignLeft);
myDirLabel = new StaticTextWidget(this, font, xpos, ypos, lwidth, fontHeight,
"Dir:", kTextAlignLeft);
xpos += lwidth + 5;
myNote = new StaticTextWidget(this, font, xpos, ypos,
myDir = new StaticTextWidget(this, font, xpos, ypos,
_w - xpos - 10, fontHeight,
"", kTextAlignLeft);
// Add four buttons at the bottom
xpos = 10; ypos += myNote->getHeight() + 4;
xpos = 10; ypos += myDir->getHeight() + 4;
#ifndef MAC_OSX
myStartButton = new ButtonWidget(this, font, xpos, ypos, bwidth, bheight,
"Select", kStartCmd);
@ -179,9 +178,6 @@ string LauncherDialog::selectedRomMD5(string& file)
if(item < 0 || myGameList->isDir(item))
return "";
FilesystemNode node(myGameList->path(item));
file = node.displayName();
// Make sure we have a valid md5 for this ROM
if(myGameList->md5(item) == "")
{
@ -200,10 +196,7 @@ void LauncherDialog::loadConfig()
// has been called (and we should reload the list).
if(myList->getList().isEmpty())
{
// (De)activate browse mode
myBrowseModeFlag = instance()->settings().getBool("rombrowse");
myPrevDirButton->setEnabled(myBrowseModeFlag);
myNoteLabel->setLabel(myBrowseModeFlag ? "Dir:" : "Note:");
myPrevDirButton->setEnabled(false);
myCurrentNode = instance()->settings().getString("romdir");
updateListing();
@ -215,7 +208,7 @@ void LauncherDialog::loadConfig()
void LauncherDialog::enableButtons(bool enable)
{
myStartButton->setEnabled(enable);
myPrevDirButton->setEnabled(enable && myBrowseModeFlag);
myPrevDirButton->setEnabled(enable);
myOptionsButton->setEnabled(enable);
myQuitButton->setEnabled(enable);
}
@ -225,35 +218,16 @@ void LauncherDialog::updateListing(bool fullReload)
{
// Start with empty list
myGameList->clear();
myNote->setLabel("");
myDir->setLabel("");
string romdir = instance()->settings().getString("romdir");
// If in ROM browse mode, just load the current directory and
// don't translate by md5sum at all
if(myBrowseModeFlag)
{
loadDirListing();
// Only hilite the 'up' button if there's a parent directory
myPrevDirButton->setEnabled(myCurrentNode.hasParent());
// Show current directory
myNote->setLabel(myCurrentNode.path());
}
else
{
// Disable buttons, pending a reload from disk
enableButtons(false);
if(FilesystemNode::fileExists(instance()->cacheFile()) && !fullReload)
loadListFromCache();
else // we have no other choice
loadListFromDisk();
// Re-enable buttons
enableButtons(true);
}
myDir->setLabel(myCurrentNode.path());
// Now fill the list widget with the contents of the GameList
StringList l;
@ -264,40 +238,10 @@ void LauncherDialog::updateListing(bool fullReload)
// Indicate how many files were found
ostringstream buf;
buf << (myBrowseModeFlag ? myGameList->size() -1 : myGameList->size())
<< " items found";
buf << (myGameList->size() - 1) << " items found";
myRomCount->setLabel(buf.str());
// Restore last selection
if(!myList->getList().isEmpty())
{
if(myBrowseModeFlag)
myList->setSelected(0);
else
{
string lastrom = instance()->settings().getString("lastrom");
if(lastrom == "")
myList->setSelected(0);
else
{
unsigned int itemToSelect = 0;
StringList::const_iterator iter;
for (iter = myList->getList().begin(); iter != myList->getList().end();
++iter, ++itemToSelect)
{
if (lastrom == *iter)
{
myList->setSelected(itemToSelect);
break;
}
}
if(itemToSelect > myList->getList().size())
myList->setSelected(0);
}
}
}
else
myList->setSelected(-1); // redraw the empty list
myList->setSelected(myList->getList().isEmpty() ? -1 : 0);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -327,6 +271,7 @@ void LauncherDialog::loadDirListing()
myGameList->sortByName();
}
/*
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void LauncherDialog::loadListFromDisk()
{
@ -421,20 +366,17 @@ void LauncherDialog::createListCache()
}
out.close();
}
*/
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void LauncherDialog::loadRomInfo()
{
if(!myRomInfoFlag) return;
int item = myList->getSelected();
if(item < 0) return;
if(item < 0 || myGameList->isDir(item)) return;
if(myGameList->isDir(item))
if(isValidRomName(myGameList->name(item)))
{
if(myRomInfoFlag)
myRomInfoWidget->clearInfo();
return;
}
// Make sure we have a valid md5 for this ROM
if(myGameList->md5(item) == "")
myGameList->setMd5(item, MD5FromFile(myGameList->path(item)));
@ -444,11 +386,10 @@ void LauncherDialog::loadRomInfo()
const string& md5 = myGameList->md5(item);
instance()->propSet().getMD5(md5, props);
if(!myBrowseModeFlag)
myNote->setLabel(props.get(Cartridge_Note));
if(myRomInfoFlag)
myRomInfoWidget->showInfo(props);
}
else
myRomInfoWidget->clearInfo();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -465,6 +406,22 @@ string LauncherDialog::MD5FromFile(const string& path)
return md5;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool LauncherDialog::isValidRomName(const string& filename)
{
string::size_type idx = filename.find_last_of('.');
if(idx != string::npos)
{
string ext = filename.substr(idx+1);
return BSPF_strncasecmp(ext.c_str(), "bin", 3) == 0 ||
BSPF_strncasecmp(ext.c_str(), "a26", 3) == 0 ||
BSPF_strncasecmp(ext.c_str(), "zip", 3) == 0 ||
BSPF_strncasecmp(ext.c_str(), "rom", 3) == 0 ||
BSPF_strncasecmp(ext.c_str(), "gz", 2) == 0 ;
}
return false;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void LauncherDialog::handleCommand(CommandSender* sender, int cmd,
int data, int id)
@ -482,7 +439,7 @@ void LauncherDialog::handleCommand(CommandSender* sender, int cmd,
const string& md5 = myGameList->md5(item);
// Directory's should be selected (ie, enter them and redisplay)
if(myBrowseModeFlag && myGameList->isDir(item))
if(myGameList->isDir(item))
{
if(myGameList->name(item) == " [..]")
myCurrentNode = myCurrentNode.getParent();
@ -490,11 +447,10 @@ void LauncherDialog::handleCommand(CommandSender* sender, int cmd,
myCurrentNode = rom;
updateListing();
}
else if(instance()->createConsole(rom, md5))
else if(!isValidRomName(rom) || !instance()->createConsole(rom, md5))
{
#if !defined(GP2X) // Quick GP2X hack to spare flash-card saves
instance()->settings().setString("lastrom", myList->getSelectedString());
#endif
// TODO - show messagebox that ROM couldn't be started
cerr << "Error: invalid ROM (name or file)\n";
}
}
break;
@ -506,7 +462,7 @@ void LauncherDialog::handleCommand(CommandSender* sender, int cmd,
case kPrevDirCmd:
myCurrentNode = myCurrentNode.getParent();
updateListing(!myBrowseModeFlag); // Force full update in non-browse mode
updateListing(false);
break;
case kListSelectionChangedCmd:
@ -527,13 +483,6 @@ void LauncherDialog::handleCommand(CommandSender* sender, int cmd,
// Stub just in case we need it
break;
case kBrowseChangedCmd:
myCurrentNode = instance()->settings().getString("romdir");
myBrowseModeFlag = instance()->settings().getBool("rombrowse");
myPrevDirButton->setEnabled(myBrowseModeFlag);
myNoteLabel->setLabel(myBrowseModeFlag ? "Dir:" : "Note:");
break;
case kReloadRomDirCmd:
updateListing(true);
break;

View File

@ -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: LauncherDialog.hxx,v 1.31 2008-02-06 13:45:24 stephena Exp $
// $Id: LauncherDialog.hxx,v 1.32 2008-03-12 19:42:36 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -44,7 +44,6 @@ class StringListWidget;
enum {
kRomDirChosenCmd = 'romc', // rom chosen
kSnapDirChosenCmd = 'snpc', // snap chosen
kBrowseChangedCmd = 'broc', // browse mode toggled
kReloadRomDirCmd = 'rdrl' // reload the current listing
};
@ -57,6 +56,13 @@ class LauncherDialog : public Dialog
string selectedRomMD5(string& file);
/**
Is this a valid ROM filename (does it have a valid extension?)
@param filename Filename of potential ROM file
*/
static bool isValidRomName(const string& filename);
protected:
virtual void handleCommand(CommandSender* sender, int cmd, int data, int id);
@ -70,8 +76,8 @@ class LauncherDialog : public Dialog
ButtonWidget* myQuitButton;
StringListWidget* myList;
StaticTextWidget* myNoteLabel;
StaticTextWidget* myNote;
StaticTextWidget* myDirLabel;
StaticTextWidget* myDir;
StaticTextWidget* myRomCount;
GameList* myGameList;
@ -83,15 +89,11 @@ class LauncherDialog : public Dialog
private:
void enableButtons(bool enable);
void loadDirListing();
void loadListFromDisk();
void loadListFromCache();
void createListCache();
void loadRomInfo();
string MD5FromFile(const string& path);
private:
int mySelectedItem;
bool myBrowseModeFlag;
bool myRomInfoFlag;
FilesystemNode myCurrentNode;

View File

@ -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: OptionsDialog.cxx,v 1.62 2008-02-06 13:45:24 stephena Exp $
// $Id: OptionsDialog.cxx,v 1.63 2008-03-12 19:42:36 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -126,7 +126,7 @@ OptionsDialog::OptionsDialog(OSystem* osystem, DialogContainer* parent,
w = 200; h = 155;
myUIDialog = new UIDialog(myOSystem, parent, font, x, y, w, h);
w = 280; h = 190;
w = 280; h = 180;
myFileSnapDialog = new FileSnapDialog(myOSystem, parent, font,
boss, x, y, w, h);