Removed defaultProperties() method from the Console class and put

it in the PropertiesSet class, since it made more sense there.

This also allows the use of Properties and PropertiesSet classes in
StellaX without needing to bring in the Console class (and everything
associated with it).


git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@299 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
stephena 2004-07-10 13:20:36 +00:00
parent 14728bf2cc
commit 287bf03829
6 changed files with 66 additions and 67 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.11 2004-07-07 22:46:01 stephena Exp $
// $Id: mainSDL.cxx,v 1.12 2004-07-10 13:20:25 stephena Exp $
//============================================================================
#include <fstream>
@ -721,13 +721,13 @@ void setupProperties(PropertiesSet& set)
useMemList = true;
if(theAlternateProFile != "")
set.load(theAlternateProFile, &Console::defaultProperties(), useMemList);
set.load(theAlternateProFile, useMemList);
else if(theUserProFile != "")
set.load(theUserProFile, &Console::defaultProperties(), useMemList);
set.load(theUserProFile, useMemList);
else if(theSystemProFile != "")
set.load(theSystemProFile, &Console::defaultProperties(), useMemList);
set.load(theSystemProFile, useMemList);
else
set.load("", &Console::defaultProperties(), false);
set.load("", false);
}

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: Console.cxx,v 1.33 2004-07-07 22:46:01 stephena Exp $
// $Id: Console.cxx,v 1.34 2004-07-10 13:20:26 stephena Exp $
//============================================================================
#include <assert.h>
@ -236,41 +236,6 @@ Console& Console::operator = (const Console&)
return *this;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
const Properties& Console::defaultProperties()
{
// Make sure the <key,value> pairs are in the default properties object
ourDefaultProperties.set("Cartridge.Filename", "");
ourDefaultProperties.set("Cartridge.MD5", "");
ourDefaultProperties.set("Cartridge.Manufacturer", "");
ourDefaultProperties.set("Cartridge.ModelNo", "");
ourDefaultProperties.set("Cartridge.Name", "Untitled");
ourDefaultProperties.set("Cartridge.Note", "");
ourDefaultProperties.set("Cartridge.Rarity", "");
ourDefaultProperties.set("Cartridge.Type", "Auto-detect");
ourDefaultProperties.set("Console.LeftDifficulty", "B");
ourDefaultProperties.set("Console.RightDifficulty", "B");
ourDefaultProperties.set("Console.TelevisionType", "Color");
ourDefaultProperties.set("Controller.Left", "Joystick");
ourDefaultProperties.set("Controller.Right", "Joystick");
ourDefaultProperties.set("Display.Format", "NTSC");
ourDefaultProperties.set("Display.XStart", "0");
ourDefaultProperties.set("Display.Width", "160");
ourDefaultProperties.set("Display.YStart", "34");
ourDefaultProperties.set("Display.Height", "210");
ourDefaultProperties.set("Emulation.CPU", "Auto-detect");
ourDefaultProperties.set("Emulation.HmoveBlanks", "Yes");
return ourDefaultProperties;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Properties Console::ourDefaultProperties;
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Console::toggleFormat()
{

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: Console.hxx,v 1.21 2004-07-07 22:46:01 stephena Exp $
// $Id: Console.hxx,v 1.22 2004-07-10 13:20:35 stephena Exp $
//============================================================================
#ifndef CONSOLE_HXX
@ -40,7 +40,7 @@ class FrameBuffer;
This class represents the entire game console.
@author Bradford W. Mott
@version $Id: Console.hxx,v 1.21 2004-07-07 22:46:01 stephena Exp $
@version $Id: Console.hxx,v 1.22 2004-07-10 13:20:35 stephena Exp $
*/
class Console
{
@ -163,12 +163,6 @@ class Console
Console& operator = (const Console& console);
public:
/**
Get the default properties object to use for other properties objects
@return The default properties object
*/
static const Properties& defaultProperties();
/**
Toggle between NTSC and PAL mode. The frontends will need to
@ -262,9 +256,5 @@ class Console
// Pointer to the EventHandler object
EventHandler* myEventHandler;
private:
// Default properties to use for properties objects
static Properties ourDefaultProperties;
};
#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: PropsSet.cxx,v 1.7 2004-07-05 00:53:48 stephena Exp $
// $Id: PropsSet.cxx,v 1.8 2004-07-10 13:20:35 stephena Exp $
//============================================================================
#include <assert.h>
@ -29,6 +29,7 @@ PropertiesSet::PropertiesSet()
myPropertiesFilename(""),
mySaveOnExit(false)
{
myDefaultProperties = &defaultProperties();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -170,10 +171,9 @@ void PropertiesSet::deleteNode(TreeNode *node)
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void PropertiesSet::load(string filename, const Properties* defaults, bool useList)
void PropertiesSet::load(string filename, bool useList)
{
myUseMemList = useList;
myDefaultProperties = defaults;
if(filename == "")
return;
@ -259,3 +259,38 @@ bool PropertiesSet::merge(Properties& properties, string& filename, bool saveOnE
return true;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
const Properties& PropertiesSet::defaultProperties()
{
// Make sure the <key,value> pairs are in the default properties object
ourDefaultProperties.set("Cartridge.Filename", "");
ourDefaultProperties.set("Cartridge.MD5", "");
ourDefaultProperties.set("Cartridge.Manufacturer", "");
ourDefaultProperties.set("Cartridge.ModelNo", "");
ourDefaultProperties.set("Cartridge.Name", "Untitled");
ourDefaultProperties.set("Cartridge.Note", "");
ourDefaultProperties.set("Cartridge.Rarity", "");
ourDefaultProperties.set("Cartridge.Type", "Auto-detect");
ourDefaultProperties.set("Console.LeftDifficulty", "B");
ourDefaultProperties.set("Console.RightDifficulty", "B");
ourDefaultProperties.set("Console.TelevisionType", "Color");
ourDefaultProperties.set("Controller.Left", "Joystick");
ourDefaultProperties.set("Controller.Right", "Joystick");
ourDefaultProperties.set("Display.Format", "NTSC");
ourDefaultProperties.set("Display.XStart", "0");
ourDefaultProperties.set("Display.Width", "160");
ourDefaultProperties.set("Display.YStart", "34");
ourDefaultProperties.set("Display.Height", "210");
ourDefaultProperties.set("Emulation.CPU", "Auto-detect");
ourDefaultProperties.set("Emulation.HmoveBlanks", "Yes");
return ourDefaultProperties;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Properties PropertiesSet::ourDefaultProperties;

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: PropsSet.hxx,v 1.5 2004-07-05 00:53:48 stephena Exp $
// $Id: PropsSet.hxx,v 1.6 2004-07-10 13:20:35 stephena Exp $
//============================================================================
#ifndef PROPERTIESSET_HXX
@ -65,10 +65,9 @@ class PropertiesSet
defaults properties as the defaults for any properties loaded.
@param string The input file to use
@param defaults The default properties to use
@param useList Flag to indicate storing properties in memory (default true)
*/
void load(string filename, const Properties* defaults, bool useList = true);
void load(string filename, bool useList = true);
/**
Save properties to the specified output stream
@ -148,9 +147,22 @@ class PropertiesSet
*/
void printNode(TreeNode *node);
/**
Get the default properties object to use for other properties objects
@return The default properties object
*/
static const Properties& defaultProperties();
// The root of the BST
TreeNode* myRoot;
// Default properties to use for properties objects
static Properties ourDefaultProperties;
// The default properties set
const Properties* myDefaultProperties;
// Property to use as the key
string myKey;
@ -163,9 +175,6 @@ class PropertiesSet
// The file stream for the stella.pro file
ifstream myPropertiesStream;
// The default properties set
const Properties* myDefaultProperties;
// The filename where this PropertiesSet should be saved
string myPropertiesFilename;

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.1.1.1 2004-06-16 02:30:30 markgrebe Exp $
// $Id: mainSDL.cxx,v 1.2 2004-07-10 13:20:36 stephena Exp $
//============================================================================
#include <fstream>
@ -904,23 +904,23 @@ bool setupProperties(PropertiesSet& set)
if(theAlternateProFile != "")
{
set.load(theAlternateProFile, &Console::defaultProperties(), useMemList);
set.load(theAlternateProFile, useMemList);
return true;
}
if(theUserProFile != "")
{
set.load(theUserProFile, &Console::defaultProperties(), useMemList);
set.load(theUserProFile, useMemList);
return true;
}
else if(theSystemProFile != "")
{
set.load(theSystemProFile, &Console::defaultProperties(), useMemList);
set.load(theSystemProFile, useMemList);
return true;
}
else
{
set.load("", &Console::defaultProperties(), false);
set.load("", false);
return true;
}
}