Fixed 'Game Info' button in Options Dialog to only be shown when a valid

ROM has been selected in the ROM launcher (or if we're in emulation mode).

BTW, I forgot to mention in the previous commit that Stella now only
recognizes ROMs if they're named with the following extensions: .bin,
.a26, .rom, .zip, .gz (not case sensitive).  Right now, attempting to
select something else prints an error message.  Eventually, a MessageBox
will be shown indicating that the filename isn't valid.

For now, this restriction is only for files started from the built-in
launcher.  I haven't decided if it should apply to the commandline as well.


git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@1427 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
stephena 2008-03-12 22:04:53 +00:00
parent 3b32d07c1d
commit 90dce82289
7 changed files with 50 additions and 26 deletions

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: GameInfoDialog.cxx,v 1.49 2008-02-27 20:13:55 stephena Exp $ // $Id: GameInfoDialog.cxx,v 1.50 2008-03-12 22:04:51 stephena Exp $
// //
// Based on code from ScummVM - Scumm Interpreter // Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project // Copyright (C) 2002-2004 The ScummVM project
@ -336,15 +336,11 @@ void GameInfoDialog::loadConfig()
} }
else if(&myOSystem->launcher()) else if(&myOSystem->launcher())
{ {
string file; const string& md5 = myOSystem->launcher().selectedRomMD5();
const string& md5 = myOSystem->launcher().romMD5(file);
if(md5 != "") if(md5 != "")
{ {
instance()->propSet().getMD5(md5, myGameProperties); instance()->propSet().getMD5(md5, myGameProperties);
myPropertiesLoaded = true; myPropertiesLoaded = true;
myGameProperties.set(Cartridge_Name, file);
myGameProperties.set(Cartridge_ModelNo, file);
myGameProperties.set(Cartridge_Manufacturer, file);
loadView(); loadView();
} }
} }
@ -640,7 +636,7 @@ void GameInfoDialog::setDefaults()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void GameInfoDialog::handleCommand(CommandSender* sender, int cmd, void GameInfoDialog::handleCommand(CommandSender* sender, int cmd,
int data, int id) int data, int id)
{ {
switch (cmd) switch (cmd)
{ {
@ -683,6 +679,7 @@ const char* GameInfoDialog::ourControllerList[kNumControllerTypes][2] = {
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
const char* GameInfoDialog::ourCartridgeList[kNumCartTypes][2] = { const char* GameInfoDialog::ourCartridgeList[kNumCartTypes][2] = {
{ "Auto-detect", "AUTO-DETECT" }, { "Auto-detect", "AUTO-DETECT" },
{ "0840 (8K ECONObanking)", "0840" },
{ "2K (2K Atari)", "2K" }, { "2K (2K Atari)", "2K" },
{ "3E (32K Tigervision)", "3E" }, { "3E (32K Tigervision)", "3E" },
{ "3F (512K Tigervision)", "3F" }, { "3F (512K Tigervision)", "3F" },
@ -705,6 +702,5 @@ const char* GameInfoDialog::ourCartridgeList[kNumCartTypes][2] = {
{ "MC (C. Wilkson Megacart)", "MC" }, { "MC (C. Wilkson Megacart)", "MC" },
{ "SB (128-256k SUPERbanking)", "SB" }, { "SB (128-256k SUPERbanking)", "SB" },
{ "UA (8K UA Ltd.)", "UA" }, { "UA (8K UA Ltd.)", "UA" },
{ "X07 (64K AtariAge)", "X07" }, { "X07 (64K AtariAge)", "X07" }
{ "0840 (8K ECONObanking)", "0840" }
}; };

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: Launcher.cxx,v 1.21 2008-02-06 13:45:23 stephena Exp $ // $Id: Launcher.cxx,v 1.22 2008-03-12 22:04:51 stephena Exp $
//============================================================================ //============================================================================
#include <sstream> #include <sstream>
@ -62,7 +62,7 @@ void Launcher::initializeVideo()
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
string Launcher::romMD5(string& file) string Launcher::selectedRomMD5()
{ {
return ((LauncherDialog*)myBaseDialog)->selectedRomMD5(file); return ((LauncherDialog*)myBaseDialog)->selectedRomMD5();
} }

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: Launcher.hxx,v 1.14 2008-02-06 13:45:24 stephena Exp $ // $Id: Launcher.hxx,v 1.15 2008-03-12 22:04:51 stephena Exp $
//============================================================================ //============================================================================
#ifndef LAUNCHER_HXX #ifndef LAUNCHER_HXX
@ -28,7 +28,7 @@ class OSystem;
The base dialog for the ROM launcher in Stella. The base dialog for the ROM launcher in Stella.
@author Stephen Anthony @author Stephen Anthony
@version $Id: Launcher.hxx,v 1.14 2008-02-06 13:45:24 stephena Exp $ @version $Id: Launcher.hxx,v 1.15 2008-03-12 22:04:51 stephena Exp $
*/ */
class Launcher : public DialogContainer class Launcher : public DialogContainer
{ {
@ -49,9 +49,9 @@ class Launcher : public DialogContainer
void initializeVideo(); void initializeVideo();
/** /**
Get game properties for the currently selected ROM. Wrapper for LauncherDialog::selectedRomMD5() method.
*/ */
string romMD5(string& file); string selectedRomMD5();
private: private:
// The width and height of this dialog // The width and height of this dialog

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: LauncherDialog.cxx,v 1.77 2008-03-12 19:42:36 stephena Exp $ // $Id: LauncherDialog.cxx,v 1.78 2008-03-12 22:04:52 stephena Exp $
// //
// Based on code from ScummVM - Scumm Interpreter // Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project // Copyright (C) 2002-2004 The ScummVM project
@ -172,10 +172,11 @@ LauncherDialog::~LauncherDialog()
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
string LauncherDialog::selectedRomMD5(string& file) string LauncherDialog::selectedRomMD5()
{ {
int item = myList->getSelected(); int item = myList->getSelected();
if(item < 0 || myGameList->isDir(item)) if(item < 0 || myGameList->isDir(item) ||
!isValidRomName(myGameList->name(item)))
return ""; return "";
// Make sure we have a valid md5 for this ROM // Make sure we have a valid md5 for this ROM
@ -183,10 +184,8 @@ string LauncherDialog::selectedRomMD5(string& file)
{ {
const string& md5 = MD5FromFile(myGameList->path(item)); const string& md5 = MD5FromFile(myGameList->path(item));
myGameList->setMd5(item, md5); myGameList->setMd5(item, md5);
return md5;
} }
else return myGameList->md5(item);
return myGameList->md5(item);
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: LauncherDialog.hxx,v 1.32 2008-03-12 19:42:36 stephena Exp $ // $Id: LauncherDialog.hxx,v 1.33 2008-03-12 22:04:53 stephena Exp $
// //
// Based on code from ScummVM - Scumm Interpreter // Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project // Copyright (C) 2002-2004 The ScummVM project
@ -54,7 +54,12 @@ class LauncherDialog : public Dialog
int x, int y, int w, int h); int x, int y, int w, int h);
~LauncherDialog(); ~LauncherDialog();
string selectedRomMD5(string& file); /**
Get MD5sum for the currently selected file
@return md5sum if a valid ROM file, else the empty string
*/
string selectedRomMD5();
/** /**
Is this a valid ROM filename (does it have a valid extension?) Is this a valid ROM filename (does it have a valid extension?)

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: OptionsDialog.cxx,v 1.63 2008-03-12 19:42:36 stephena Exp $ // $Id: OptionsDialog.cxx,v 1.64 2008-03-12 22:04:53 stephena Exp $
// //
// Based on code from ScummVM - Scumm Interpreter // Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project // Copyright (C) 2002-2004 The ScummVM project
@ -33,6 +33,7 @@
#include "HelpDialog.hxx" #include "HelpDialog.hxx"
#include "AboutDialog.hxx" #include "AboutDialog.hxx"
#include "OptionsDialog.hxx" #include "OptionsDialog.hxx"
#include "Launcher.hxx"
#ifdef CHEATCODE_SUPPORT #ifdef CHEATCODE_SUPPORT
#include "CheatCodeDialog.hxx" #include "CheatCodeDialog.hxx"
@ -183,6 +184,28 @@ OptionsDialog::~OptionsDialog()
delete myAboutDialog; delete myAboutDialog;
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void OptionsDialog::loadConfig()
{
// Determine whether we should show the 'Game Information' button
// We always show it in emulation mode, or if a valid ROM is selected
// in launcher mode
switch(instance()->eventHandler().state())
{
case EventHandler::S_EMULATE:
myGameInfoButton->setFlags(WIDGET_ENABLED);
break;
case EventHandler::S_LAUNCHER:
if(instance()->launcher().selectedRomMD5() != "")
myGameInfoButton->setFlags(WIDGET_ENABLED);
else
myGameInfoButton->clearFlags(WIDGET_ENABLED);
break;
default:
break;
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void OptionsDialog::handleCommand(CommandSender* sender, int cmd, void OptionsDialog::handleCommand(CommandSender* sender, int cmd,
int data, int id) int data, int id)

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: OptionsDialog.hxx,v 1.26 2008-02-06 13:45:24 stephena Exp $ // $Id: OptionsDialog.hxx,v 1.27 2008-03-12 22:04:53 stephena Exp $
// //
// Based on code from ScummVM - Scumm Interpreter // Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project // Copyright (C) 2002-2004 The ScummVM project
@ -47,6 +47,7 @@ class OptionsDialog : public Dialog
virtual ~OptionsDialog(); virtual ~OptionsDialog();
private: private:
void loadConfig();
virtual void handleCommand(CommandSender* sender, int cmd, int data, int id); virtual void handleCommand(CommandSender* sender, int cmd, int data, int id);
void checkBounds(int width, int height, int* x, int* y, int* w, int* h); void checkBounds(int width, int height, int* x, int* y, int* w, int* h);