From bea44bafff653e088ca296fb2edeaf0766269b52 Mon Sep 17 00:00:00 2001 From: stephena Date: Fri, 14 Mar 2008 15:23:24 +0000 Subject: [PATCH] Initial UI code for the new 'ROM Audit' functionality. Basically, one will be able to select a ROM directory to scan, and have all files identified as a ROM (by extension) renamed according to their properties name. This will create ROMs with 'pretty names', and takes the place of the previously removed 'non-browse' mode. git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@1429 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba --- stella/src/gui/OptionsDialog.cxx | 20 +++- stella/src/gui/OptionsDialog.hxx | 8 +- stella/src/gui/RomAuditDialog.cxx | 146 ++++++++++++++++++++++++++++++ stella/src/gui/RomAuditDialog.hxx | 68 ++++++++++++++ stella/src/gui/module.mk | 1 + 5 files changed, 238 insertions(+), 5 deletions(-) create mode 100644 stella/src/gui/RomAuditDialog.cxx create mode 100644 stella/src/gui/RomAuditDialog.hxx diff --git a/stella/src/gui/OptionsDialog.cxx b/stella/src/gui/OptionsDialog.cxx index 6d73df935..b563fef86 100644 --- a/stella/src/gui/OptionsDialog.cxx +++ b/stella/src/gui/OptionsDialog.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: OptionsDialog.cxx,v 1.65 2008-03-13 22:58:07 stephena Exp $ +// $Id: OptionsDialog.cxx,v 1.66 2008-03-14 15:23:23 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -29,6 +29,7 @@ #include "InputDialog.hxx" #include "UIDialog.hxx" #include "FileSnapDialog.hxx" +#include "RomAuditDialog.hxx" #include "GameInfoDialog.hxx" #include "HelpDialog.hxx" #include "AboutDialog.hxx" @@ -82,6 +83,9 @@ OptionsDialog::OptionsDialog(OSystem* osystem, DialogContainer* parent, myFileSnapButton = addBigButton("Config Files", kFileSnapCmd); wid.push_back(myFileSnapButton); + myRomAuditButton = addBigButton("Audit ROMs", kAuditCmd); + wid.push_back(myRomAuditButton); + // Move to second column xoffset += kBigButtonWidth + 10; yoffset = 10; @@ -131,6 +135,9 @@ OptionsDialog::OptionsDialog(OSystem* osystem, DialogContainer* parent, myFileSnapDialog = new FileSnapDialog(myOSystem, parent, font, boss, x, y, w, h); + w = 280; h = 120; + myRomAuditDialog = new RomAuditDialog(myOSystem, parent, font, x, y, w, h); + w = 255; h = 190; myGameInfoDialog = new GameInfoDialog(myOSystem, parent, font, this, x, y, w, h); @@ -150,10 +157,12 @@ OptionsDialog::OptionsDialog(OSystem* osystem, DialogContainer* parent, // Certain buttons are disabled depending on mode if(myIsGlobal) { -// myGameInfoButton->clearFlags(WIDGET_ENABLED); myCheatCodeButton->clearFlags(WIDGET_ENABLED); } - + else + { + myRomAuditButton->clearFlags(WIDGET_ENABLED); + } #ifdef _WIN32_WCE myAudioSettingsButton->clearFlags(WIDGET_ENABLED); // not honored in wince port #endif @@ -176,6 +185,7 @@ OptionsDialog::~OptionsDialog() delete myInputDialog; delete myUIDialog; delete myFileSnapDialog; + delete myRomAuditDialog; delete myGameInfoDialog; #ifdef CHEATCODE_SUPPORT delete myCheatCodeDialog; @@ -232,6 +242,10 @@ void OptionsDialog::handleCommand(CommandSender* sender, int cmd, parent()->addDialog(myFileSnapDialog); break; + case kAuditCmd: + parent()->addDialog(myRomAuditDialog); + break; + case kInfoCmd: parent()->addDialog(myGameInfoDialog); break; diff --git a/stella/src/gui/OptionsDialog.hxx b/stella/src/gui/OptionsDialog.hxx index a0ad16225..990b8592e 100644 --- a/stella/src/gui/OptionsDialog.hxx +++ b/stella/src/gui/OptionsDialog.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: OptionsDialog.hxx,v 1.27 2008-03-12 22:04:53 stephena Exp $ +// $Id: OptionsDialog.hxx,v 1.28 2008-03-14 15:23:24 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -30,6 +30,7 @@ class AudioDialog; class InputDialog; class UIDialog; class FileSnapDialog; +class RomAuditDialog; class GameInfoDialog; class CheatCodeDialog; class HelpDialog; @@ -57,6 +58,7 @@ class OptionsDialog : public Dialog InputDialog* myInputDialog; UIDialog* myUIDialog; FileSnapDialog* myFileSnapDialog; + RomAuditDialog* myRomAuditDialog; GameInfoDialog* myGameInfoDialog; CheatCodeDialog* myCheatCodeDialog; HelpDialog* myHelpDialog; @@ -66,6 +68,7 @@ class OptionsDialog : public Dialog ButtonWidget* myAudioSettingsButton; ButtonWidget* myUIButton; ButtonWidget* myFileSnapButton; + ButtonWidget* myRomAuditButton; ButtonWidget* myGameInfoButton; ButtonWidget* myCheatCodeButton; ButtonWidget* myHelpButton; @@ -80,6 +83,7 @@ class OptionsDialog : public Dialog kInptCmd = 'INPT', kUsrIfaceCmd = 'URIF', kFileSnapCmd = 'FLSN', + kAuditCmd = 'RAUD', kInfoCmd = 'INFO', kCheatCmd = 'CHET', kHelpCmd = 'HELP', @@ -91,7 +95,7 @@ class OptionsDialog : public Dialog kRowHeight = 22, kBigButtonWidth = 90, kMainMenuWidth = (2*kBigButtonWidth + 30), - kMainMenuHeight = 5*kRowHeight + 15 + kMainMenuHeight = 6*kRowHeight + 15 }; }; diff --git a/stella/src/gui/RomAuditDialog.cxx b/stella/src/gui/RomAuditDialog.cxx new file mode 100644 index 000000000..7d6f406ea --- /dev/null +++ b/stella/src/gui/RomAuditDialog.cxx @@ -0,0 +1,146 @@ +//============================================================================ +// +// SSSS tt lll lll +// SS SS tt ll ll +// SS tttttt eeee ll ll aaaa +// SSSS tt ee ee ll ll aa +// SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator" +// SS SS tt ee ll ll aa aa +// SSSS ttt eeeee llll llll aaaaa +// +// Copyright (c) 1995-2008 by Bradford W. Mott and the Stella team +// +// See the file "license" for information on usage and redistribution of +// this file, and for a DISCLAIMER OF ALL WARRANTIES. +// +// $Id: RomAuditDialog.cxx,v 1.1 2008-03-14 15:23:24 stephena Exp $ +// +// Based on code from ScummVM - Scumm Interpreter +// Copyright (C) 2002-2004 The ScummVM project +//============================================================================ + +#include "bspf.hxx" + +#include "BrowserDialog.hxx" +#include "DialogContainer.hxx" +#include "EditTextWidget.hxx" +#include "FSNode.hxx" +#include "Settings.hxx" + +#include "RomAuditDialog.hxx" + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +RomAuditDialog::RomAuditDialog(OSystem* osystem, DialogContainer* parent, + const GUI::Font& font, + int x, int y, int w, int h) + : Dialog(osystem, parent, x, y, w, h), + myBrowser(NULL) +{ + const int vBorder = 8; + const int bwidth = font.getStringWidth("Audit path:") + 20, + bheight = font.getLineHeight() + 4, + fontHeight = font.getLineHeight(); + int xpos = vBorder, ypos = vBorder; + WidgetArray wid; + ButtonWidget* b; + + // Audit path + ButtonWidget* romButton = + new ButtonWidget(this, font, xpos, ypos, bwidth, bheight, "Audit path:", + kChooseAuditDirCmd); + wid.push_back(romButton); + xpos += bwidth + 10; + myRomPath = new EditTextWidget(this, font, xpos, ypos + 2, + _w - xpos - 10, font.getLineHeight(), ""); + wid.push_back(myRomPath); + + // Show results of ROM audit + xpos = 10; ypos += bheight; + myResults1 = new StaticTextWidget(this, font, xpos, ypos, _w - 20, fontHeight, + "", kTextAlignLeft); + myResults1->setFlags(WIDGET_CLEARBG); + ypos += bheight; + myResults2 = new StaticTextWidget(this, font, xpos, ypos, _w - 20, fontHeight, + "", kTextAlignLeft); + myResults2->setFlags(WIDGET_CLEARBG); + + + // Add OK & Cancel buttons +#ifndef MAC_OSX + b = addButton(font, _w - 2 * (kButtonWidth + 7), _h - 24, "Audit", kOKCmd); + wid.push_back(b); + addOKWidget(b); + b = addButton(font, _w - (kButtonWidth + 10), _h - 24, "Cancel", kCloseCmd); + wid.push_back(b); + addCancelWidget(b); +#else + b = addButton(font, _w - 2 * (kButtonWidth + 7), _h - 24, "Cancel", kCloseCmd); + wid.push_back(b); + addCancelWidget(b); + b = addButton(font, _w - (kButtonWidth + 10), _h - 24, "Audit", kOKCmd); + wid.push_back(b); + addOKWidget(b); +#endif + + addToFocusList(wid); + + // Create file browser dialog + myBrowser = new BrowserDialog(this, font, 60, 20, 200, 200); +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +RomAuditDialog::~RomAuditDialog() +{ + delete myBrowser; +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void RomAuditDialog::loadConfig() +{ + myRomPath->setEditString(instance()->settings().getString("romdir")); +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void RomAuditDialog::auditRoms() +{ + cerr << "do rom audit\n"; +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void RomAuditDialog::openBrowser(const string& title, const string& startpath, + FilesystemNode::ListMode mode, int cmd) +{ + parent()->addDialog(myBrowser); + + myBrowser->setTitle(title); + myBrowser->setEmitSignal(cmd); + myBrowser->setStartPath(startpath, mode); +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void RomAuditDialog::handleCommand(CommandSender* sender, int cmd, + int data, int id) +{ + switch (cmd) + { + case kOKCmd: + auditRoms(); + break; + + case kChooseAuditDirCmd: + openBrowser("Select ROM directory to audit:", myRomPath->getEditString(), + FilesystemNode::kListDirectoriesOnly, kAuditDirChosenCmd); + break; + + case kAuditDirChosenCmd: + { + FilesystemNode dir(myBrowser->getResult()); + myRomPath->setEditString(dir.path()); + break; + } + + default: + Dialog::handleCommand(sender, cmd, data, 0); + break; + } +} diff --git a/stella/src/gui/RomAuditDialog.hxx b/stella/src/gui/RomAuditDialog.hxx new file mode 100644 index 000000000..20e910bc0 --- /dev/null +++ b/stella/src/gui/RomAuditDialog.hxx @@ -0,0 +1,68 @@ +//============================================================================ +// +// SSSS tt lll lll +// SS SS tt ll ll +// SS tttttt eeee ll ll aaaa +// SSSS tt ee ee ll ll aa +// SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator" +// SS SS tt ee ll ll aa aa +// SSSS ttt eeeee llll llll aaaaa +// +// Copyright (c) 1995-2008 by Bradford W. Mott and the Stella team +// +// See the file "license" for information on usage and redistribution of +// this file, and for a DISCLAIMER OF ALL WARRANTIES. +// +// $Id: RomAuditDialog.hxx,v 1.1 2008-03-14 15:23:24 stephena Exp $ +// +// Based on code from ScummVM - Scumm Interpreter +// Copyright (C) 2002-2004 The ScummVM project +//============================================================================ + +#ifndef ROM_AUDIT_DIALOG_HXX +#define ROM_AUDIT_DIALOG_HXX + +class OSystem; +class GuiObject; +class DialogContainer; +class BrowserDialog; +class EditTextWidget; +class StaticTextWidget; + +#include "Dialog.hxx" +#include "Command.hxx" +#include "FSNode.hxx" + +class RomAuditDialog : public Dialog +{ + public: + RomAuditDialog(OSystem* osystem, DialogContainer* parent, + const GUI::Font& font, int x, int y, int w, int h); + ~RomAuditDialog(); + + void handleCommand(CommandSender* sender, int cmd, int data, int id); + + private: + void loadConfig(); + void auditRoms(); + void openBrowser(const string& title, const string& startpath, + FilesystemNode::ListMode mode, int cmd); + + private: + enum { + kChooseAuditDirCmd = 'RAsl', // audit dir select + kAuditDirChosenCmd = 'RAch' // audit dir changed + }; + + // ROM audit path + EditTextWidget* myRomPath; + + // Show the results of the ROM audit + StaticTextWidget* myResults1; + StaticTextWidget* myResults2; + + // Select a new ROM audit path + BrowserDialog* myBrowser; +}; + +#endif diff --git a/stella/src/gui/module.mk b/stella/src/gui/module.mk index 457d33972..f6b7070e7 100644 --- a/stella/src/gui/module.mk +++ b/stella/src/gui/module.mk @@ -25,6 +25,7 @@ MODULE_OBJS := \ src/gui/OptionsDialog.o \ src/gui/PopUpWidget.o \ src/gui/ProgressDialog.o \ + src/gui/RomAuditDialog.o \ src/gui/RomInfoWidget.o \ src/gui/ScrollBarWidget.o \ src/gui/Surface.o \