Made the error message clearer when a snapshot file couldn't be created.

Made the default snapshot folder be $BASEDIR/snapshots, and got rid
of the previous default './'.  I suspect this relative pathname was
causing a problem.  The user is still free to choose another
snapshot dir, but the one in $BASEDIR is always created anyway.

Removed the logic that entering Stella directly from a ROM wouldn't
allow one to enter the ROM launcher afterwords.  You can now always
exit from a ROM back to the launcher, no matter how Stella was
launched.


git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@1452 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
stephena 2008-03-30 15:01:38 +00:00
parent cd9d21051f
commit c90e67d398
8 changed files with 25 additions and 49 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: Snapshot.cxx,v 1.18 2008-02-06 13:45:19 stephena Exp $ // $Id: Snapshot.cxx,v 1.19 2008-03-30 15:01:38 stephena Exp $
//============================================================================ //============================================================================
#include <zlib.h> #include <zlib.h>
@ -46,8 +46,8 @@ void Snapshot::savePNG(FrameBuffer& framebuffer, const Properties& props,
int height = framebuffer.imageHeight(); int height = framebuffer.imageHeight();
out.open(filename.c_str(), ios_base::binary); out.open(filename.c_str(), ios_base::binary);
if(!out) if(!out.is_open())
throw "Couldn't open snapshot file"; throw "Error: Couldn't create snapshot file";
// PNG file header // PNG file header
uInt8 header[8] = { 137, 80, 78, 71, 13, 10, 26, 10 }; uInt8 header[8] = { 137, 80, 78, 71, 13, 10, 26, 10 };

View File

@ -14,7 +14,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: EventHandler.cxx,v 1.220 2008-03-28 23:29:13 stephena Exp $ // $Id: EventHandler.cxx,v 1.221 2008-03-30 15:01:38 stephena Exp $
//============================================================================ //============================================================================
#include <sstream> #include <sstream>
@ -64,7 +64,6 @@ EventHandler::EventHandler(OSystem* osystem)
myOverlay(NULL), myOverlay(NULL),
myState(S_NONE), myState(S_NONE),
myGrabMouseFlag(false), myGrabMouseFlag(false),
myUseLauncherFlag(false),
myAllowAllDirectionsFlag(false), myAllowAllDirectionsFlag(false),
myFryingFlag(false) myFryingFlag(false)
{ {
@ -155,13 +154,8 @@ void EventHandler::initialize()
void EventHandler::reset(State state) void EventHandler::reset(State state)
{ {
setEventState(state); setEventState(state);
myEvent->clear(); myEvent->clear();
myOSystem->state().reset(); myOSystem->state().reset();
if(myState == S_LAUNCHER)
myUseLauncherFlag = true;
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -982,10 +976,7 @@ void EventHandler::handleEvent(Event::Type event, int state)
return; return;
case Event::LauncherMode: case Event::LauncherMode:
// ExitGame will only work when we've launched stella using the ROM if((myState == S_EMULATE || myState == S_CMDMENU) && state)
// launcher. Otherwise, the only way to exit the main loop is to Quit.
if((myState == S_EMULATE || myState == S_CMDMENU) &&
myUseLauncherFlag && state)
{ {
myOSystem->settings().saveConfig(); myOSystem->settings().saveConfig();
myOSystem->deleteConsole(); myOSystem->deleteConsole();

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: EventHandler.hxx,v 1.109 2008-03-22 17:35:02 stephena Exp $ // $Id: EventHandler.hxx,v 1.110 2008-03-30 15:01:38 stephena Exp $
//============================================================================ //============================================================================
#ifndef EVENTHANDLER_HXX #ifndef EVENTHANDLER_HXX
@ -61,7 +61,7 @@ enum EventMode {
mapping can take place. mapping can take place.
@author Stephen Anthony @author Stephen Anthony
@version $Id: EventHandler.hxx,v 1.109 2008-03-22 17:35:02 stephena Exp $ @version $Id: EventHandler.hxx,v 1.110 2008-03-30 15:01:38 stephena Exp $
*/ */
class EventHandler class EventHandler
{ {
@ -164,12 +164,6 @@ class EventHandler
*/ */
inline State state() { return myState; } inline State state() { return myState; }
/**
Returns the current launcher state (decide whether to enter launcher
on game exit).
*/
inline bool useLauncher() { return myUseLauncherFlag; }
/** /**
Resets the state machine of the EventHandler to the defaults Resets the state machine of the EventHandler to the defaults
@ -497,9 +491,6 @@ class EventHandler
// Indicates whether the mouse cursor is grabbed // Indicates whether the mouse cursor is grabbed
bool myGrabMouseFlag; bool myGrabMouseFlag;
// Indicates whether to use launcher mode when exiting a game
bool myUseLauncherFlag;
// Indicates whether the joystick emulates 'impossible' directions // Indicates whether the joystick emulates 'impossible' directions
bool myAllowAllDirectionsFlag; bool myAllowAllDirectionsFlag;

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: OSystem.cxx,v 1.119 2008-03-23 16:22:40 stephena Exp $ // $Id: OSystem.cxx,v 1.120 2008-03-30 15:01:38 stephena Exp $
//============================================================================ //============================================================================
#include <cassert> #include <cassert>
@ -217,7 +217,12 @@ void OSystem::setConfigPaths()
FilesystemNode::makeDir(myStateDir); FilesystemNode::makeDir(myStateDir);
mySettings->setString("statedir", myStateDir); mySettings->setString("statedir", myStateDir);
myGameListCacheFile = myBaseDir + BSPF_PATH_SEPARATOR + "stella.cache"; mySnapshotDir = mySettings->getString("ssdir");
if(mySnapshotDir == "")
mySnapshotDir = myBaseDir + BSPF_PATH_SEPARATOR + "snapshots";
if(!FilesystemNode::dirExists(mySnapshotDir))
FilesystemNode::makeDir(mySnapshotDir);
mySettings->setString("ssdir", mySnapshotDir);
myCheatFile = mySettings->getString("cheatfile"); myCheatFile = mySettings->getString("cheatfile");
if(myCheatFile == "") if(myCheatFile == "")

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: OSystem.hxx,v 1.62 2008-03-14 19:34:56 stephena Exp $ // $Id: OSystem.hxx,v 1.63 2008-03-30 15:01:38 stephena Exp $
//============================================================================ //============================================================================
#ifndef OSYSTEM_HXX #ifndef OSYSTEM_HXX
@ -55,7 +55,7 @@ typedef Common::Array<Resolution> ResolutionList;
other objects belong. other objects belong.
@author Stephen Anthony @author Stephen Anthony
@version $Id: OSystem.hxx,v 1.62 2008-03-14 19:34:56 stephena Exp $ @version $Id: OSystem.hxx,v 1.63 2008-03-30 15:01:38 stephena Exp $
*/ */
class OSystem class OSystem
{ {
@ -244,12 +244,9 @@ class OSystem
const string& stateDir() const { return myStateDir; } const string& stateDir() const { return myStateDir; }
/** /**
This method should be called to get the full path of the gamelist Return the directory for storing PNG snapshots.
cache file (used by the Launcher to show a listing of available games).
@return String representing the full path of the gamelist cache file.
*/ */
const string& cacheFile() const { return myGameListCacheFile; } const string& snapshotDir() const { return mySnapshotDir; }
/** /**
This method should be called to get the full path of the cheat file. This method should be called to get the full path of the cheat file.
@ -435,11 +432,6 @@ class OSystem
*/ */
void setBaseDir(const string& basedir); void setBaseDir(const string& basedir);
/**
Set the location of the gamelist cache file
*/
void setCacheFile(const string& cachefile) { myGameListCacheFile = cachefile; }
/** /**
Set the locations of config file Set the locations of config file
*/ */
@ -501,13 +493,13 @@ class OSystem
enum { kNumUIPalettes = 2 }; enum { kNumUIPalettes = 2 };
string myBaseDir; string myBaseDir;
string myStateDir; string myStateDir;
string mySnapshotDir;
string myCheatFile; string myCheatFile;
string myConfigFile; string myConfigFile;
string myPaletteFile; string myPaletteFile;
string myPropertiesFile; string myPropertiesFile;
string myGameListCacheFile;
string myRomFile; string myRomFile;
string myFeatures; string myFeatures;

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: Settings.cxx,v 1.139 2008-03-26 23:59:21 stephena Exp $ // $Id: Settings.cxx,v 1.140 2008-03-30 15:01:38 stephena Exp $
//============================================================================ //============================================================================
#include <cassert> #include <cassert>
@ -74,7 +74,7 @@ Settings::Settings(OSystem* osystem)
setInternal("sa2", "right"); setInternal("sa2", "right");
// Snapshot options // Snapshot options
setInternal("ssdir", string(".") + BSPF_PATH_SEPARATOR); setInternal("ssdir", "");
setInternal("sssingle", "false"); setInternal("sssingle", "false");
// Config files and paths // Config files and paths

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: CommandDialog.cxx,v 1.17 2008-02-06 13:45:23 stephena Exp $ // $Id: CommandDialog.cxx,v 1.18 2008-03-30 15:01:38 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
@ -204,10 +204,7 @@ void CommandDialog::handleCommand(CommandSender* sender, int cmd,
break; break;
case kExitCmd: case kExitCmd:
if(instance()->eventHandler().useLauncher()) instance()->eventHandler().handleEvent(Event::LauncherMode, 1);
instance()->eventHandler().handleEvent(Event::LauncherMode, 1);
else
instance()->quit();
execute = false; execute = false;
break; break;

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: FileSnapDialog.cxx,v 1.17 2008-03-23 17:43:22 stephena Exp $ // $Id: FileSnapDialog.cxx,v 1.18 2008-03-30 15:01:38 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
@ -183,7 +183,7 @@ void FileSnapDialog::setDefaults()
const string& cheatfile = basedir + BSPF_PATH_SEPARATOR + "stella.cht"; const string& cheatfile = basedir + BSPF_PATH_SEPARATOR + "stella.cht";
const string& palettefile = basedir + BSPF_PATH_SEPARATOR + "stella.pal"; const string& palettefile = basedir + BSPF_PATH_SEPARATOR + "stella.pal";
const string& propsfile = basedir + BSPF_PATH_SEPARATOR + "stella.pro"; const string& propsfile = basedir + BSPF_PATH_SEPARATOR + "stella.pro";
const string& ssdir = basedir + BSPF_PATH_SEPARATOR; const string& ssdir = basedir + BSPF_PATH_SEPARATOR + "snapshots";
myRomPath->setEditString(romdir); myRomPath->setEditString(romdir);
myStatePath->setEditString(statedir); myStatePath->setEditString(statedir);