From 6478176abb6078dd9934f3dfb09faa348873056c Mon Sep 17 00:00:00 2001 From: stephena Date: Tue, 21 Dec 2010 18:42:53 +0000 Subject: [PATCH] Upon opening the ROM audit dialog, the current directory from the ROM launcher is selected, not the actual ROM directory. This speeds up access, because generally you'll want to audit the directory you're actually looking at. git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@2196 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba --- Changes.txt | 3 +++ src/gui/Launcher.cxx | 15 ++++++++++++++- src/gui/Launcher.hxx | 13 ++++++++++++- src/gui/LauncherDialog.cxx | 6 +++--- src/gui/LauncherDialog.hxx | 16 ++++++++++++++-- src/gui/RomAuditDialog.cxx | 11 +++++++++-- 6 files changed, 55 insertions(+), 9 deletions(-) diff --git a/Changes.txt b/Changes.txt index 623f94fad..cf5c132c8 100644 --- a/Changes.txt +++ b/Changes.txt @@ -19,6 +19,9 @@ * Updated internal ROM properties database to ROM-Hunter version 6 (thanks go to RomHunter for his tireless research in this area). + * The ROM audit dialog now automatically selects the current + directory in the ROM launcher. + -Have fun! diff --git a/src/gui/Launcher.cxx b/src/gui/Launcher.cxx index 0e8a8801b..60628b95b 100644 --- a/src/gui/Launcher.cxx +++ b/src/gui/Launcher.cxx @@ -21,6 +21,7 @@ #include "Version.hxx" #include "OSystem.hxx" #include "Settings.hxx" +#include "FSNode.hxx" #include "FrameBuffer.hxx" #include "bspf.hxx" @@ -57,7 +58,19 @@ FBInitStatus Launcher::initializeVideo() } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -string Launcher::selectedRomMD5() +const string& Launcher::selectedRomMD5() { return ((LauncherDialog*)myBaseDialog)->selectedRomMD5(); } + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +const FilesystemNode& Launcher::currentNode() const +{ + return ((LauncherDialog*)myBaseDialog)->currentNode(); +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void Launcher::reload() +{ + ((LauncherDialog*)myBaseDialog)->reload(); +} diff --git a/src/gui/Launcher.hxx b/src/gui/Launcher.hxx index b0bc1537c..8950b3459 100644 --- a/src/gui/Launcher.hxx +++ b/src/gui/Launcher.hxx @@ -22,6 +22,7 @@ class Properties; class OSystem; +class FilesystemNode; #include "DialogContainer.hxx" #include "FrameBuffer.hxx" @@ -53,7 +54,17 @@ class Launcher : public DialogContainer /** Wrapper for LauncherDialog::selectedRomMD5() method. */ - string selectedRomMD5(); + const string& selectedRomMD5(); + + /** + Wrapper for LauncherDialog::currentNode() method. + */ + const FilesystemNode& currentNode() const; + + /** + Wrapper for LauncherDialog::reload() method. + */ + void reload(); private: // The width and height of this dialog diff --git a/src/gui/LauncherDialog.cxx b/src/gui/LauncherDialog.cxx index ed8c801e2..b1129205a 100644 --- a/src/gui/LauncherDialog.cxx +++ b/src/gui/LauncherDialog.cxx @@ -213,13 +213,13 @@ LauncherDialog::~LauncherDialog() } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -string LauncherDialog::selectedRomMD5() +const string& LauncherDialog::selectedRomMD5() { string extension; int item = myList->getSelected(); if(item < 0 || myGameList->isDir(item) || !LauncherFilterDialog::isValidRomName(myGameList->name(item), extension)) - return ""; + return EmptyString; // Make sure we have a valid md5 for this ROM if(myGameList->md5(item) == "") @@ -433,7 +433,7 @@ void LauncherDialog::setListFilters() } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -bool LauncherDialog::matchPattern(const string& s, const string& pattern) +bool LauncherDialog::matchPattern(const string& s, const string& pattern) const { // This method is modelled after strcasestr, which we don't use // because it isn't guaranteed to be available everywhere diff --git a/src/gui/LauncherDialog.hxx b/src/gui/LauncherDialog.hxx index 379c241a4..222ab2a43 100644 --- a/src/gui/LauncherDialog.hxx +++ b/src/gui/LauncherDialog.hxx @@ -67,7 +67,19 @@ class LauncherDialog : public Dialog @return md5sum if a valid ROM file, else the empty string */ - string selectedRomMD5(); + const string& selectedRomMD5(); + + /** + Get node for the currently selected directory + + @return FilesystemNode currently active + */ + const FilesystemNode& currentNode() const { return myCurrentNode; } + + /** + Reload the current listing + */ + void reload() { updateListing(); } protected: virtual void handleKeyDown(int ascii, int keycode, int modifiers); @@ -83,7 +95,7 @@ class LauncherDialog : public Dialog void loadRomInfo(); void handleContextMenu(); void setListFilters(); - bool matchPattern(const string& s, const string& pattern); + bool matchPattern(const string& s, const string& pattern) const; private: ButtonWidget* myStartButton; diff --git a/src/gui/RomAuditDialog.cxx b/src/gui/RomAuditDialog.cxx index afe3d0158..c23ba2ab1 100644 --- a/src/gui/RomAuditDialog.cxx +++ b/src/gui/RomAuditDialog.cxx @@ -22,6 +22,7 @@ #include "bspf.hxx" +#include "Launcher.hxx" #include "LauncherFilterDialog.hxx" #include "BrowserDialog.hxx" #include "DialogContainer.hxx" @@ -107,7 +108,12 @@ RomAuditDialog::~RomAuditDialog() // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void RomAuditDialog::loadConfig() { - myRomPath->setEditString(instance().settings().getString("romdir")); + const string& currentdir = + instance().launcher().currentNode().getRelativePath(); + const string& path = currentdir == "" ? + instance().settings().getString("romdir") : currentdir; + + myRomPath->setEditString(path); myResults1->setLabel(""); myResults2->setLabel(""); } @@ -192,6 +198,7 @@ void RomAuditDialog::handleCommand(CommandSender* sender, int cmd, case kConfirmAuditCmd: auditRoms(); + instance().launcher().reload(); break; case kChooseAuditDirCmd: @@ -202,7 +209,7 @@ void RomAuditDialog::handleCommand(CommandSender* sender, int cmd, case kAuditDirChosenCmd: { FilesystemNode dir(myBrowser->getResult()); - myRomPath->setEditString(dir.getPath()); + myRomPath->setEditString(dir.getRelativePath()); myResults1->setLabel(""); myResults2->setLabel(""); break;