From 009884dad47826ab2a332887a14aa3e97f608849 Mon Sep 17 00:00:00 2001 From: stephena Date: Mon, 11 Nov 2002 02:46:34 +0000 Subject: [PATCH] Removed all DEVELOPER_SUPPORT #ifdef's from the code. The methods will now be compiled into the core. It's up to the GUI's to call (or not call) the DEVELOPER methods. Changed the behaviour of Console::saveProperties() in that it now accepts a boolean variable 'merge', which if true, will make a call to PropertiesSet::merge() and indicate that these properties are to be saved into a stella.pro file. If merge is false, it simply saves the properties to the specified file (as before). git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@129 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba --- stella/src/emucore/Console.cxx | 54 +++++++++++++++++++++------------- stella/src/emucore/Console.hxx | 13 ++++---- 2 files changed, 42 insertions(+), 25 deletions(-) diff --git a/stella/src/emucore/Console.cxx b/stella/src/emucore/Console.cxx index 12d72caf4..750d85a5e 100644 --- a/stella/src/emucore/Console.cxx +++ b/stella/src/emucore/Console.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: Console.cxx,v 1.6 2002-11-10 19:05:57 stephena Exp $ +// $Id: Console.cxx,v 1.7 2002-11-11 02:46:34 stephena Exp $ //============================================================================ #include @@ -46,7 +46,8 @@ Console::Console(const uInt8* image, uInt32 size, const char* filename, const Event& event, PropertiesSet& propertiesSet, uInt32 sampleRate, const Properties* userDefinedProperties) - : myEvent(event) + : myEvent(event), + myPropSet(propertiesSet) { myControllers[0] = 0; myControllers[1] = 0; @@ -58,7 +59,7 @@ Console::Console(const uInt8* image, uInt32 size, const char* filename, string md5 = MD5(image, size); // Search for the properties based on MD5 - propertiesSet.getMD5(md5, myProperties); + myPropSet.getMD5(md5, myProperties); // Merge any user-defined properties if(userDefinedProperties != 0) @@ -149,7 +150,8 @@ Console::Console(const uInt8* image, uInt32 size, const char* filename, // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Console::Console(const Console& console) - : myEvent(console.myEvent) + : myEvent(console.myEvent), + myPropSet(console.myPropSet) { // TODO: Write this method assert(false); @@ -214,8 +216,6 @@ const Properties& Console::defaultProperties() // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Properties Console::ourDefaultProperties; - -#ifdef DEVELOPER_SUPPORT // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void Console::toggleFormat() { @@ -399,25 +399,39 @@ void Console::changeHeight(const uInt32 direction) } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void Console::saveProperties(string& filename) +void Console::saveProperties(string& filename, bool merge) { string message; - // Replace all spaces in filename with underscores - replace(filename.begin(), filename.end(), ' ', '_'); - ofstream out(filename.c_str(), ios::out); - - if(out && out.is_open()) + // Merge the current properties into the PropertiesSet file + if(merge) { - myProperties.save(out); - out.close(); - message = "Properties saved"; - myMediaSource->showMessage(message, 120); + if(myPropSet.merge(myProperties, filename)) + { + message = "Properties merged"; + myMediaSource->showMessage(message, 120); + } + else + { + message = "Properties not merged"; + myMediaSource->showMessage(message, 120); + } } - else + else // Save to the specified file directly { - message = "Properties not saved"; - myMediaSource->showMessage(message, 120); + ofstream out(filename.c_str(), ios::out); + + if(out && out.is_open()) + { + myProperties.save(out); + out.close(); + message = "Properties saved"; + myMediaSource->showMessage(message, 120); + } + else + { + message = "Properties not saved"; + myMediaSource->showMessage(message, 120); + } } } -#endif diff --git a/stella/src/emucore/Console.hxx b/stella/src/emucore/Console.hxx index e5e43df5b..8322282bf 100644 --- a/stella/src/emucore/Console.hxx +++ b/stella/src/emucore/Console.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: Console.hxx,v 1.5 2002-11-10 19:05:57 stephena Exp $ +// $Id: Console.hxx,v 1.6 2002-11-11 02:46:34 stephena Exp $ //============================================================================ #ifndef CONSOLE_HXX @@ -36,7 +36,7 @@ class System; This class represents the entire game console. @author Bradford W. Mott - @version $Id: Console.hxx,v 1.5 2002-11-10 19:05:57 stephena Exp $ + @version $Id: Console.hxx,v 1.6 2002-11-11 02:46:34 stephena Exp $ */ class Console { @@ -134,7 +134,6 @@ class Console */ static const Properties& defaultProperties(); -#ifdef DEVELOPER_SUPPORT public: /** Toggle between NTSC and PAL mode. The GUI's may need to reload their palette. @@ -177,9 +176,10 @@ class Console Save a copy of the current properties after any changes. @param filename Filename to save the properties into. + @param merge Whether or not to merge the changes into the + main properties file. */ - void saveProperties(string& filename); -#endif + void saveProperties(string& filename, bool merge = false); private: // Pointers to the left and right controllers @@ -200,6 +200,9 @@ class Console // Pointer to the 6502 based system being emulated System* mySystem; + // Reference to the PropertiesSet object + PropertiesSet& myPropSet; + private: // Default properties to use for properties objects static Properties ourDefaultProperties;