Removed the filesystem-related methods (fileExists and mkdir) from OSystem

class into the FSNode class, since that's where all the other filesystem
stuff is.

Add OSX modifiers for event loop.  So Control in Linux/Win32 becomes
Command, and Alt becomes Shift-Command.  No doubt this will cause some
problems with weird key combinations in OSX, but we'll have to work around
them.


git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@437 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
stephena 2005-05-25 17:17:38 +00:00
parent fe67d725df
commit 6d53a85e58
21 changed files with 188 additions and 190 deletions

View File

@ -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: mainSDL.cxx,v 1.39 2005-05-12 18:45:20 stephena Exp $
// $Id: mainSDL.cxx,v 1.40 2005-05-25 17:17:33 stephena Exp $
//============================================================================
#include <fstream>
@ -180,7 +180,7 @@ int main(int argc, char* argv[])
// If not, use the built-in ROM launcher. In this case, we enter 'launcher'
// mode and let the main event loop take care of opening a new console/ROM.
string romfile = argv[argc - 1];
if(argc == 1 || !theOSystem->fileExists(romfile))
if(argc == 1 || !FilesystemNode::fileExists(romfile))
theOSystem->createLauncher();
else
theOSystem->createConsole(romfile);

View File

@ -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: Deserializer.cxx,v 1.2 2002-08-11 17:48:13 stephena Exp $
// $Id: Deserializer.cxx,v 1.3 2005-05-25 17:17:35 stephena Exp $
//============================================================================
#include <iostream>
@ -38,7 +38,7 @@ Deserializer::~Deserializer(void)
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool Deserializer::open(string& fileName)
bool Deserializer::open(const string& fileName)
{
close();
myStream = new ifstream(fileName.c_str(), ios::in | ios::binary);

View File

@ -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: Deserializer.hxx,v 1.4 2002-08-11 17:48:13 stephena Exp $
// $Id: Deserializer.hxx,v 1.5 2005-05-25 17:17:35 stephena Exp $
//============================================================================
#ifndef DESERIALIZER_HXX
@ -32,7 +32,7 @@
return.
@author Stephen Anthony
@version $Id: Deserializer.hxx,v 1.4 2002-08-11 17:48:13 stephena Exp $
@version $Id: Deserializer.hxx,v 1.5 2005-05-25 17:17:35 stephena Exp $
*/
class Deserializer
{
@ -58,7 +58,7 @@ class Deserializer
@param fileName The filename to get the deserialized data from.
@return Result of opening the file. True on success, false on failure
*/
bool open(string& fileName);
bool open(const string& fileName);
/**
Closes the current input stream.

View File

@ -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: EventHandler.cxx,v 1.59 2005-05-21 16:12:12 stephena Exp $
// $Id: EventHandler.cxx,v 1.60 2005-05-25 17:17:35 stephena Exp $
//============================================================================
#include <algorithm>
@ -22,6 +22,7 @@
#include "Event.hxx"
#include "EventHandler.hxx"
#include "FSNode.hxx"
#include "Settings.hxx"
#include "StellaEvent.hxx"
#include "System.hxx"
@ -43,7 +44,6 @@ EventHandler::EventHandler(OSystem* osystem)
myState(S_NONE),
myLSState(0),
myPauseFlag(false),
myExitGameFlag(false),
myQuitFlag(false),
myGrabMouseFlag(false),
myUseLauncherFlag(false),
@ -107,7 +107,6 @@ void EventHandler::reset(State state)
myState = state;
myLSState = 0;
myPauseFlag = false;
myExitGameFlag = false;
myQuitFlag = false;
myPaddleMode = 0;
@ -136,7 +135,7 @@ void EventHandler::reset(State state)
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void EventHandler::poll() // FIXME - add modifiers for OSX
void EventHandler::poll()
{
SDL_Event event;
@ -155,8 +154,12 @@ void EventHandler::poll() // FIXME - add modifiers for OSX
// An attempt to speed up event processing
// All SDL-specific event actions are accessed by either
// Control or Alt keys. So we quickly check for those.
// Control/Cmd or Alt/Shift-Cmd keys. So we quickly check for those.
#ifndef MAC_OSX
if(mod & KMOD_ALT && state)
#else
if((mod & KMOD_META) && (mod & KMOD_SHIFT) && state)
#endif
{
switch(int(key))
{
@ -181,7 +184,11 @@ void EventHandler::poll() // FIXME - add modifiers for OSX
break;
}
}
#ifndef MAC_OSX
else if(mod & KMOD_CTRL && state)
#else
else if((mod & KMOD_META) && !(mod & KMOD_SHIFT) && state)
#endif
{
switch(int(key))
{
@ -246,8 +253,12 @@ void EventHandler::handleKeyEvent(SDLKey key, SDLMod mod, uInt8 state)
case S_EMULATE:
// An attempt to speed up event processing
// All SDL-specific event actions are accessed by either
// Control and/or Alt keys. So we quickly check for those.
// Control/Cmd and/or Alt/Shift-Cmd keys. So we quickly check for those.
#ifndef MAC_OSX
if(mod & KMOD_ALT && state)
#else
if((mod & KMOD_META) && (mod & KMOD_SHIFT))
#endif
{
switch(int(key))
{
@ -259,7 +270,7 @@ void EventHandler::handleKeyEvent(SDLKey key, SDLMod mod, uInt8 state)
myOSystem->sound().adjustVolume(1);
break;
#ifdef DEVELOPER_SUPPORT
#ifdef DEVELOPER_SUPPORT
case SDLK_END: // Alt-End increases XStart
myOSystem->console().changeXStart(1);
break;
@ -275,8 +286,8 @@ void EventHandler::handleKeyEvent(SDLKey key, SDLMod mod, uInt8 state)
case SDLK_PAGEDOWN: // Alt-PageDown decreases YStart
myOSystem->console().changeYStart(0);
break;
#endif
#ifdef DEVELOPER_SUPPORT
#endif
#ifdef DEVELOPER_SUPPORT
case SDLK_z:
myOSystem->console().toggleP0Bit();
break;
@ -308,10 +319,14 @@ void EventHandler::handleKeyEvent(SDLKey key, SDLMod mod, uInt8 state)
case SDLK_SLASH:
myOSystem->console().enableBits(true);
break;
#endif
#endif
}
}
#ifndef MAC_OSX
else if(mod & KMOD_CTRL && state)
#else
else if((mod & KMOD_META) && !(mod & KMOD_SHIFT))
#endif
{
switch(int(key))
{
@ -343,7 +358,7 @@ void EventHandler::handleKeyEvent(SDLKey key, SDLMod mod, uInt8 state)
myOSystem->createConsole();
break;
#ifdef DEVELOPER_SUPPORT
#ifdef DEVELOPER_SUPPORT
case SDLK_END: // Ctrl-End increases Width
myOSystem->console().changeWidth(1);
break;
@ -359,7 +374,7 @@ void EventHandler::handleKeyEvent(SDLKey key, SDLMod mod, uInt8 state)
case SDLK_PAGEDOWN: // Ctrl-PageDown decreases Height
myOSystem->console().changeHeight(0);
break;
#endif
#endif
case SDLK_s: // Ctrl-s saves properties to a file
// Attempt to merge with propertiesSet
if(myOSystem->settings().getBool("mergeprops"))
@ -663,7 +678,11 @@ void EventHandler::setActionMappings()
// There are some keys which are hardcoded. These should be represented too.
string prepend = "";
if(event == Event::Quit)
prepend = "Ctrl Q"; // FIXME for OSX
#ifndef MAC_OSX
prepend = "Ctrl Q";
#else
prepend = "Cmd Q";
#endif
// else if ...
if(key == "")
@ -917,12 +936,14 @@ bool EventHandler::isValidList(string list, uInt32 length)
void EventHandler::saveState()
{
// Do a state save using the System
string md5 = myOSystem->console().properties().get("Cartridge.MD5");
string filename = myOSystem->stateFilename(md5, myLSState);
int result = myOSystem->console().system().saveState(filename, md5);
string md5 = myOSystem->console().properties().get("Cartridge.MD5");
ostringstream buf;
buf << myOSystem->stateDir() << BSPF_PATH_SEPARATOR << md5 << ".st" << myLSState;
int result = myOSystem->console().system().saveState(buf.str(), md5);
// Print appropriate message
ostringstream buf;
buf.str("");
if(result == 1)
buf << "State " << myLSState << " saved";
else if(result == 2)
@ -952,12 +973,14 @@ void EventHandler::changeState()
void EventHandler::loadState()
{
// Do a state save using the System
string md5 = myOSystem->console().properties().get("Cartridge.MD5");
string filename = myOSystem->stateFilename(md5, myLSState);
int result = myOSystem->console().system().loadState(filename, md5);
string md5 = myOSystem->console().properties().get("Cartridge.MD5");
ostringstream buf;
buf << myOSystem->stateDir() << BSPF_PATH_SEPARATOR << md5 << ".st" << myLSState;
int result = myOSystem->console().system().loadState(buf.str(), md5);
// Print appropriate message
ostringstream buf;
buf.str("");
if(result == 1)
buf << "State " << myLSState << " loaded";
else if(result == 2)
@ -990,14 +1013,14 @@ void EventHandler::takeSnapshot()
// Determine if the file already exists, checking each successive filename
// until one doesn't exist
filename = sspath + ".png";
if(myOSystem->fileExists(filename))
if(FilesystemNode::fileExists(filename))
{
ostringstream buf;
for(uInt32 i = 1; ;++i)
{
buf.str("");
buf << sspath << "_" << i << ".png";
if(!myOSystem->fileExists(buf.str()))
if(!FilesystemNode::fileExists(buf.str()))
break;
}
filename = buf.str();

View File

@ -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: EventHandler.hxx,v 1.29 2005-05-17 18:42:22 stephena Exp $
// $Id: EventHandler.hxx,v 1.30 2005-05-25 17:17:37 stephena Exp $
//============================================================================
#ifndef EVENTHANDLER_HXX
@ -57,7 +57,7 @@ struct ActionList {
mapping can take place.
@author Stephen Anthony
@version $Id: EventHandler.hxx,v 1.29 2005-05-17 18:42:22 stephena Exp $
@version $Id: EventHandler.hxx,v 1.30 2005-05-25 17:17:37 stephena Exp $
*/
class EventHandler
{
@ -127,11 +127,6 @@ class EventHandler
*/
inline bool doPause() { return myPauseFlag; }
/**
This method indicates whether a exit game event has been received.
*/
inline bool doExitGame() { return myExitGameFlag; }
/**
This method indicates whether a quit event has been received.
*/
@ -254,9 +249,6 @@ class EventHandler
// Indicates the current pause status
bool myPauseFlag;
// Indicates whether to quit the current game
bool myExitGameFlag;
// Indicates whether to quit the emulator
bool myQuitFlag;

View File

@ -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.3 2005-05-19 18:42:37 stephena Exp $
// $Id: FSNode.hxx,v 1.4 2005-05-25 17:17:37 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -125,12 +125,22 @@ class AbstractFilesystemNode
return first < second;
}
/**
Test whether given path exists as a file.
*/
static bool fileExists(const string& path);
/**
Test whether given path exists as a directory.
*/
static bool dirExists(const string& path);
/**
Create a directory from the given path.
*/
static bool makeDir(const string& path);
/* TODO:
bool exists();
bool isDirectory();
bool isFile();
bool isReadable();
bool isWriteable();
*/

View File

@ -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: OSystem.cxx,v 1.19 2005-05-21 16:12:13 stephena Exp $
// $Id: OSystem.cxx,v 1.20 2005-05-25 17:17:37 stephena Exp $
//============================================================================
#include <cassert>
@ -34,6 +34,7 @@
#include "SoundSDL.hxx"
#endif
#include "FSNode.hxx"
#include "Settings.hxx"
#include "PropsSet.hxx"
#include "EventHandler.hxx"
@ -96,16 +97,16 @@ OSystem::~OSystem()
void OSystem::setBaseDir(const string& basedir)
{
myBaseDir = basedir;
if(!fileExists(myBaseDir))
makeDir(myBaseDir);
if(!FilesystemNode::dirExists(myBaseDir))
FilesystemNode::makeDir(myBaseDir);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void OSystem::setStateDir(const string& statedir)
{
myStateDir = statedir;
if(!fileExists(myStateDir))
makeDir(myStateDir);
if(!FilesystemNode::dirExists(myStateDir))
FilesystemNode::makeDir(myStateDir);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -115,9 +116,9 @@ void OSystem::setPropertiesFiles(const string& userprops,
// Set up the input and output properties files
myPropertiesOutputFile = userprops;
if(fileExists(userprops))
if(FilesystemNode::fileExists(userprops))
myPropertiesInputFile = userprops;
else if(fileExists(systemprops))
else if(FilesystemNode::fileExists(systemprops))
myPropertiesInputFile = systemprops;
else
myPropertiesInputFile = "";
@ -130,9 +131,9 @@ void OSystem::setConfigFiles(const string& userconfig,
// Set up the names of the input and output config files
myConfigOutputFile = userconfig;
if(fileExists(userconfig))
if(FilesystemNode::fileExists(userconfig))
myConfigInputFile = userconfig;
else if(fileExists(systemconfig))
else if(FilesystemNode::fileExists(systemconfig))
myConfigInputFile = systemconfig;
else
myConfigInputFile = "";

View File

@ -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: OSystem.hxx,v 1.16 2005-05-18 22:35:37 stephena Exp $
// $Id: OSystem.hxx,v 1.17 2005-05-25 17:17:37 stephena Exp $
//============================================================================
#ifndef OSYSTEM_HXX
@ -38,7 +38,7 @@ class Launcher;
other objects belong.
@author Stephen Anthony
@version $Id: OSystem.hxx,v 1.16 2005-05-18 22:35:37 stephena Exp $
@version $Id: OSystem.hxx,v 1.17 2005-05-25 17:17:37 stephena Exp $
*/
class OSystem
{
@ -267,38 +267,6 @@ class OSystem
*/
virtual uInt32 getTicks() = 0;
/**
This method should be called to get the filename of a state file
given the state number.
@param md5 The md5sum to use as part of the filename.
@param state The state to use as part of the filename.
@return String representing the full path of the state filename.
*/
virtual string stateFilename(const string& md5, uInt32 state) = 0;
/////////////////////////////////////////////////////
// FIXME - move these to FSNode as static methods
/**
This method should be called to test whether the given file exists.
@param filename The filename to test for existence.
@return boolean representing whether or not the file exists
*/
virtual bool fileExists(const string& filename) = 0;
/**
This method should be called to create the specified directory.
@param path The directory to create
@return boolean representing whether or not the directory was created
*/
virtual bool makeDir(const string& path) = 0;
/////////////////////////////////////////////////////
protected:
/**
Set the base directory for all Stella files

View File

@ -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: Serializer.cxx,v 1.3 2004-04-04 02:03:15 stephena Exp $
// $Id: Serializer.cxx,v 1.4 2005-05-25 17:17:37 stephena Exp $
//============================================================================
#include <iostream>
@ -38,7 +38,7 @@ Serializer::~Serializer(void)
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool Serializer::open(string& fileName)
bool Serializer::open(const string& fileName)
{
close();
myStream = new ofstream(fileName.c_str(), ios::out | ios::binary);

View File

@ -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: Serializer.hxx,v 1.5 2004-04-04 02:03:15 stephena Exp $
// $Id: Serializer.hxx,v 1.6 2005-05-25 17:17:37 stephena Exp $
//============================================================================
#ifndef SERIALIZER_HXX
@ -33,7 +33,7 @@
Boolean values are written using a special pattern.
@author Stephen Anthony
@version $Id: Serializer.hxx,v 1.5 2004-04-04 02:03:15 stephena Exp $
@version $Id: Serializer.hxx,v 1.6 2005-05-25 17:17:37 stephena Exp $
*/
class Serializer
{
@ -59,7 +59,7 @@ class Serializer
@param fileName The filename to send the serialized data to.
@return Result of opening the file. True on success, false on failure
*/
bool open(string& fileName);
bool open(const string& fileName);
/**
Closes the current output stream.

View File

@ -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: System.cxx,v 1.6 2005-02-22 02:59:54 stephena Exp $
// $Id: System.cxx,v 1.7 2005-05-25 17:17:38 stephena Exp $
//============================================================================
#include <assert.h>
@ -205,7 +205,7 @@ const System::PageAccess& System::getPageAccess(uInt16 page)
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
int System::saveState(string &fileName, string& md5sum)
int System::saveState(const string& fileName, const string& md5sum)
{
// Open the file as a new Serializer
if(!serializer->open(fileName))
@ -247,7 +247,7 @@ int System::saveState(string &fileName, string& md5sum)
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
int System::loadState(string &fileName, string& md5sum)
int System::loadState(const string &fileName, const string& md5sum)
{
// Open the file as a new Deserializer
if(!deserializer->open(fileName))

View File

@ -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: System.hxx,v 1.3 2002-05-13 19:10:25 stephena Exp $
// $Id: System.hxx,v 1.4 2005-05-25 17:17:38 stephena Exp $
//============================================================================
#ifndef SYSTEM_HXX
@ -46,7 +46,7 @@ class Deserializer;
dynamic code for that page of memory.
@author Bradford W. Mott
@version $Id: System.hxx,v 1.3 2002-05-13 19:10:25 stephena Exp $
@version $Id: System.hxx,v 1.4 2005-05-25 17:17:38 stephena Exp $
*/
class System
{
@ -115,7 +115,7 @@ class System
2 file could not be opened for read/write
3 invalid state file
*/
int saveState(string& fileName, string& md5sum);
int saveState(const string& fileName, const string& md5sum);
/**
Loads the current state of Stella from the given file. Calls
@ -127,7 +127,7 @@ class System
2 file could not be opened for read/write
3 invalid state file
*/
int loadState(string& fileName, string& md5sum);
int loadState(const string& fileName, const string& md5sum);
public:
/**

View File

@ -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: bspf.hxx,v 1.5 2005-05-21 19:35:59 stephena Exp $
// $Id: bspf.hxx,v 1.6 2005-05-25 17:17:38 stephena Exp $
//============================================================================
#ifndef BSPF_HXX
@ -24,7 +24,7 @@
that need to be defined for different operating systems.
@author Bradford W. Mott
@version $Id: bspf.hxx,v 1.5 2005-05-21 19:35:59 stephena Exp $
@version $Id: bspf.hxx,v 1.6 2005-05-25 17:17:38 stephena Exp $
*/
// Types for 8-bit signed and unsigned integers
@ -62,7 +62,7 @@ typedef unsigned int uInt32;
#elif (defined(BSPF_DOS) || defined(BSPF_WIN32) || defined(BSPF_OS2))
#define BSPF_PATH_SEPARATOR "\\"
#elif defined BSPF_MAC_OSX
#define BSPF_PATH_SEPARATOR ":"
#define BSPF_PATH_SEPARATOR "/"
#endif
#endif

View File

@ -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: HelpDialog.cxx,v 1.6 2005-05-16 00:02:32 stephena Exp $
// $Id: HelpDialog.cxx,v 1.7 2005-05-25 17:17:38 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -62,8 +62,9 @@ void HelpDialog::updateStrings(uInt8 page, uInt8 lines,
dsc = new string[lines];
uInt8 i = 0;
switch(page) // FIXME - change for OSX
switch(page)
{
#ifndef MAC_OSX
case 1:
title = "Common commands:";
ADD_BIND("Ctrl Q", "Quit emulation");
@ -101,7 +102,45 @@ void HelpDialog::updateStrings(uInt8 page, uInt8 lines,
ADD_BIND("Ctrl End", "Increase Display.Width");
ADD_BIND("Ctrl Home", "Decrease Display.Width");
break;
#else
case 1:
title = "Common commands:";
ADD_BIND("Cmd Q", "Quit emulation");
ADD_BIND("Escape", "Exit current game");
ADD_BIND("Tab", "Enter/exit configuration menu");
ADD_LINE;
ADD_BIND("Shift-Cmd =", "Increase window size");
ADD_BIND("Shift-Cmd -", "Decrease window size");
ADD_BIND("Shift-Cmd Enter", "Toggle fullscreen/windowed mode");
ADD_LINE;
ADD_BIND("Shift-Cmd ]", "Increase volume by 2%");
ADD_BIND("Shift-Cmd [", "Decrease volume by 2%");
break;
case 2:
title = "Special commands:";
ADD_BIND("Cmd g", "Grab mouse (keep in window)");
ADD_BIND("Cmd f", "Switch between NTSC and PAL");
ADD_BIND("Cmd s", "Save (or merge) game properties");
ADD_LINE;
ADD_BIND("Cmd 0", "Mouse emulates paddle 0");
ADD_BIND("Cmd 1", "Mouse emulates paddle 1");
ADD_BIND("Cmd 2", "Mouse emulates paddle 2");
ADD_BIND("Cmd 3", "Mouse emulates paddle 3");
break;
case 3:
title = "Developer commands:";
ADD_BIND("Shift-Cmd PageUp", "Increase Display.YStart");
ADD_BIND("Shift-Cmd PageDown", "Decrease Display.YStart");
ADD_BIND("Cmd PageUp", "Increase Display.Height");
ADD_BIND("Cmd PageDown", "Decrease Display.Height");
ADD_BIND("Shift-Cmd End", "Increase Display.XStart");
ADD_BIND("Shift-Cmd Home", "Decrease Display.XStart");
ADD_BIND("Cmd End", "Increase Display.Width");
ADD_BIND("Cmd Home", "Decrease Display.Width");
break;
#endif
case 4:
title = "All other commands:";
ADD_LINE;

View File

@ -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.16 2005-05-21 16:12:13 stephena Exp $
// $Id: LauncherDialog.cxx,v 1.17 2005-05-25 17:17:38 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -166,7 +166,7 @@ void LauncherDialog::updateListing(bool fullReload)
myGameList->clear();
string cacheFile = instance()->cacheFile();
if(instance()->fileExists(cacheFile) && !fullReload)
if(FilesystemNode::fileExists(cacheFile) && !fullReload)
loadListFromCache();
else
loadListFromDisk();

View File

@ -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: mainSDL.cxx,v 1.10 2005-02-26 22:16:37 markgrebe Exp $
// $Id: mainSDL.cxx,v 1.11 2005-05-25 17:17:38 stephena Exp $
//============================================================================
#include <fstream>
@ -446,6 +446,16 @@ bool handleInitialEvents(void)
return status;
}
if((mod & KMOD_META) && (mod & KMOD_SHIFT))
if((mod & KMOD_META) && !(mod & KMOD_SHIFT))
/**
This routine should be called regularly to handle events
*/

View File

@ -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: FSNodePOSIX.cxx,v 1.4 2005-05-14 03:26:29 stephena Exp $
// $Id: FSNodePOSIX.cxx,v 1.5 2005-05-25 17:17:38 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -204,3 +204,29 @@ AbstractFilesystemNode *POSIXFilesystemNode::parent() const
return p;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool AbstractFilesystemNode::fileExists(const string& path)
{
struct stat st;
if(stat(path.c_str(), &st) != 0)
return false;
return S_ISREG(st.st_mode);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool AbstractFilesystemNode::dirExists(const string& path)
{
struct stat st;
if(stat(path.c_str(), &st) != 0)
return false;
return S_ISDIR(st.st_mode);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool AbstractFilesystemNode::makeDir(const string& path)
{
return mkdir(path.c_str(), 0777) == 0;
}

View File

@ -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: OSystemUNIX.cxx,v 1.8 2005-05-18 22:35:37 stephena Exp $
// $Id: OSystemUNIX.cxx,v 1.9 2005-05-25 17:17:38 stephena Exp $
//============================================================================
#include <cstdlib>
@ -92,7 +92,7 @@ void OSystemUNIX::mainLoop()
for(;;)
{
// Exit if the user wants to quit
if(myEventHandler->doExitGame() || myEventHandler->doQuit())
if(myEventHandler->doQuit())
break;
startTime = getTicks();
@ -125,7 +125,7 @@ void OSystemUNIX::mainLoop()
for(;;)
{
// Exit if the user wants to quit
if(myEventHandler->doExitGame() || myEventHandler->doQuit())
if(myEventHandler->doQuit())
break;
startTime = getTicks();
@ -174,24 +174,3 @@ uInt32 OSystemUNIX::getTicks()
return (uInt32) SDL_GetTicks() * 1000;
#endif
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
string OSystemUNIX::stateFilename(const string& md5, uInt32 state)
{
ostringstream buf;
buf << stateDir() << "/" << md5 << ".st" << state;
return buf.str();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool OSystemUNIX::fileExists(const string& filename)
{
return access(filename.c_str(), F_OK) == 0;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool OSystemUNIX::makeDir(const string& path)
{
return mkdir(path.c_str(), 0777) == 0;
}

View File

@ -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: OSystemUNIX.hxx,v 1.6 2005-05-18 22:35:37 stephena Exp $
// $Id: OSystemUNIX.hxx,v 1.7 2005-05-25 17:17:38 stephena Exp $
//============================================================================
#ifndef OSYSTEM_UNIX_HXX
@ -26,7 +26,7 @@
This class defines UNIX-like OS's (Linux) system specific settings.
@author Stephen Anthony
@version $Id: OSystemUNIX.hxx,v 1.6 2005-05-18 22:35:37 stephena Exp $
@version $Id: OSystemUNIX.hxx,v 1.7 2005-05-25 17:17:38 stephena Exp $
*/
class OSystemUNIX : public OSystem
{
@ -55,35 +55,6 @@ class OSystemUNIX : public OSystem
@return Current time in microseconds.
*/
virtual uInt32 getTicks();
/**
This method should be called to get the filename of a state file
given the state number.
@param md5 The md5sum to use as part of the filename.
@param state The state to use as part of the filename.
@return String representing the full path of the state filename.
*/
virtual string stateFilename(const string& md5, uInt32 state);
/**
This method should be called to test whether the given file exists.
@param filename The filename to test for existence.
@return boolean representing whether or not the file exists
*/
virtual bool fileExists(const string& filename);
/**
This method should be called to create the specified directory.
@param path The directory to create
@return boolean representing whether or not the directory was created
*/
virtual bool makeDir(const string& path);
};
#endif

View File

@ -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: OSystemWin32.cxx,v 1.1 2005-05-18 22:35:37 stephena Exp $
// $Id: OSystemWin32.cxx,v 1.2 2005-05-25 17:17:38 stephena Exp $
//============================================================================
#include <sstream>
@ -85,7 +85,7 @@ void OSystemWin32::mainLoop()
for(;;)
{
// Exit if the user wants to quit
if(myEventHandler->doExitGame() || myEventHandler->doQuit())
if(myEventHandler->doQuit())
break;
startTime = getTicks();
@ -127,15 +127,6 @@ uInt32 OSystemWin32::getTicks()
return (uInt32) SDL_GetTicks() * 1000;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
string OSystemWin32::stateFilename(const string& md5, uInt32 state)
{
ostringstream buf;
buf << stateDir() << "\\" << md5 << ".st" << state;
return buf.str();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool OSystemWin32::fileExists(const string& filename)
{

View File

@ -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: OSystemWin32.hxx,v 1.1 2005-05-18 22:35:37 stephena Exp $
// $Id: OSystemWin32.hxx,v 1.2 2005-05-25 17:17:38 stephena Exp $
//============================================================================
#ifndef OSYSTEM_WIN32_HXX
@ -26,7 +26,7 @@
This class defines Windows system specific settings.
@author Stephen Anthony
@version $Id: OSystemWin32.hxx,v 1.1 2005-05-18 22:35:37 stephena Exp $
@version $Id: OSystemWin32.hxx,v 1.2 2005-05-25 17:17:38 stephena Exp $
*/
class OSystemWin32 : public OSystem
{
@ -56,18 +56,6 @@ class OSystemWin32 : public OSystem
*/
virtual uInt32 getTicks();
/**
This method should be called to get the filename of a state file
given the state number.
@param md5 The md5sum to use as part of the filename.
@param state The state to use as part of the filename.
@return String representing the full path of the state filename.
*/
virtual string stateFilename(const string& md5, uInt32 state);
/**
This method should be called to test whether the given file exists.