diff --git a/stella/src/emucore/FSNode.cxx b/stella/src/emucore/FSNode.cxx index 2bd8c863b..d476171d7 100644 --- a/stella/src/emucore/FSNode.cxx +++ b/stella/src/emucore/FSNode.cxx @@ -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: FSNode.cxx,v 1.4 2006-03-08 20:03:03 stephena Exp $ +// $Id: FSNode.cxx,v 1.5 2006-03-19 22:06:20 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -112,3 +112,9 @@ FilesystemNode FilesystemNode::getParent() const else return AbstractFilesystemNode::wrap(node); } + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +bool FilesystemNode::hasParent() const +{ + return _realNode->parent() != 0; +} diff --git a/stella/src/emucore/FSNode.hxx b/stella/src/emucore/FSNode.hxx index 7bf4b2cce..720fd0c31 100644 --- a/stella/src/emucore/FSNode.hxx +++ b/stella/src/emucore/FSNode.hxx @@ -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: FSNode.hxx,v 1.8 2005-12-09 01:16:13 stephena Exp $ +// $Id: FSNode.hxx,v 1.9 2006-03-19 22:06:20 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -184,6 +184,7 @@ class FilesystemNode : public AbstractFilesystemNode FilesystemNode &operator =(const FilesystemNode &node); FilesystemNode getParent() const; + bool hasParent() const; virtual string displayName() const { return _realNode->displayName(); } virtual bool isValid() const { return _realNode->isValid(); } diff --git a/stella/src/gui/BrowserDialog.cxx b/stella/src/gui/BrowserDialog.cxx index c5d49ca18..8f0ac3314 100644 --- a/stella/src/gui/BrowserDialog.cxx +++ b/stella/src/gui/BrowserDialog.cxx @@ -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.15 2006-03-08 20:03:03 stephena Exp $ +// $Id: BrowserDialog.cxx,v 1.16 2006-03-19 22:06:20 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -30,11 +30,6 @@ #include "bspf.hxx" -enum { - kChooseCmd = 'CHOS', - kGoUpCmd = 'GOUP' -}; - /* We want to use this as a general directory selector at some point... possible uses * - to select the data dir for a game * - to select the place where save games are stored @@ -77,8 +72,8 @@ BrowserDialog::BrowserDialog(GuiObject* boss, const GUI::Font& font, // Buttons xpos = 10; ypos = _h - bheight - 8; - new ButtonWidget(this, font, xpos, ypos, bwidth, bheight, "Go up", - kGoUpCmd, 0); + _goUpButton = new ButtonWidget(this, font, xpos, ypos, bwidth, bheight, + "Go up", kGoUpCmd, 0); #ifndef MAC_OSX xpos = _w - 2 *(bwidth + 10); new ButtonWidget(this, font, xpos, ypos, bwidth, bheight, "Choose", @@ -179,6 +174,9 @@ void BrowserDialog::updateListing() if(size > 0) _fileList->setSelected(0); + // Only hilite the 'up' button if there's a parent directory + _goUpButton->setEnabled(_node.hasParent()); + // Finally, redraw setDirty(); draw(); } diff --git a/stella/src/gui/BrowserDialog.hxx b/stella/src/gui/BrowserDialog.hxx index bb6c16655..cecdcdc2f 100644 --- a/stella/src/gui/BrowserDialog.hxx +++ b/stella/src/gui/BrowserDialog.hxx @@ -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.7 2006-02-22 17:38:04 stephena Exp $ +// $Id: BrowserDialog.hxx,v 1.8 2006-03-19 22:06:20 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -23,6 +23,7 @@ #define BROWSER_DIALOG_HXX class GuiObject; +class ButtonWidget; class StaticTextWidget; class StringListWidget; @@ -51,12 +52,19 @@ class BrowserDialog : public Dialog, public CommandSender StringListWidget* _fileList; StaticTextWidget* _currentPath; StaticTextWidget* _title; + ButtonWidget* _goUpButton; + FilesystemNode _node; FSList _nodeContent; FilesystemNode _choice; private: int _cmd; + + enum { + kChooseCmd = 'CHOS', + kGoUpCmd = 'GOUP' + }; }; #endif diff --git a/stella/src/gui/LauncherDialog.cxx b/stella/src/gui/LauncherDialog.cxx index 5a2b1c0f1..9e9d69aeb 100644 --- a/stella/src/gui/LauncherDialog.cxx +++ b/stella/src/gui/LauncherDialog.cxx @@ -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.49 2006-03-19 20:57:55 stephena Exp $ +// $Id: LauncherDialog.cxx,v 1.50 2006-03-19 22:06:20 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -191,8 +191,6 @@ void LauncherDialog::enableButtons(bool enable) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void LauncherDialog::updateListing(bool fullReload) { - enableButtons(false); - // Start with empty list myGameList->clear(); @@ -216,9 +214,16 @@ void LauncherDialog::updateListing(bool fullReload) myCurrentDir = romdir; loadDirListing(); + + // Only hilite the 'up' button if there's a parent directory + FilesystemNode dir(myCurrentDir); + myPrevDirButton->setEnabled(dir.hasParent()); } else { + // Disable buttons, pending a reload from disk + enableButtons(false); + // Figure out if the ROM dir has changed since we last accessed it. // If so, we do a full reload from disk (takes quite some time). // Otherwise, we can use the cache file (which is much faster). @@ -231,6 +236,9 @@ void LauncherDialog::updateListing(bool fullReload) loadListFromCache(); else // we have no other choice loadListFromDisk(); + + // Re-enable buttons + enableButtons(true); } // Now fill the list widget with the contents of the GameList @@ -245,8 +253,6 @@ void LauncherDialog::updateListing(bool fullReload) buf << myGameList->size() << " items found"; myRomCount->setLabel(buf.str()); - enableButtons(true); - // Restore last selection if(!myList->getList().isEmpty()) { @@ -275,6 +281,8 @@ void LauncherDialog::updateListing(bool fullReload) } } } + else + myList->setSelected(-1); // redraw the empty list } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/stella/src/gui/ListWidget.cxx b/stella/src/gui/ListWidget.cxx index 0c5d42954..2b848f52b 100644 --- a/stella/src/gui/ListWidget.cxx +++ b/stella/src/gui/ListWidget.cxx @@ -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: ListWidget.cxx,v 1.40 2006-02-22 17:38:04 stephena Exp $ +// $Id: ListWidget.cxx,v 1.41 2006-03-19 22:06:20 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -67,7 +67,7 @@ ListWidget::~ListWidget() // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void ListWidget::setSelected(int item) { - assert(item >= -1 && item < (int)_list.size()); + assert(item >= -2 && item < (int)_list.size()); if(isEnabled()) { diff --git a/stella/src/gui/ListWidget.hxx b/stella/src/gui/ListWidget.hxx index 2a60b2a5c..82f86ba98 100644 --- a/stella/src/gui/ListWidget.hxx +++ b/stella/src/gui/ListWidget.hxx @@ -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: ListWidget.hxx,v 1.16 2006-02-22 17:38:04 stephena Exp $ +// $Id: ListWidget.hxx,v 1.17 2006-03-19 22:06:20 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -52,7 +52,7 @@ class ListWidget : public EditableWidget int currentPos() const { return _currentPos; } int getSelected() const { return _selectedItem; } - void setSelected(int item); + void setSelected(int item); // Use '-1' to indicate a redraw of an empty list int getHighlighted() const { return _highlightedItem; } void setHighlighted(int item);