Completely remove ability to use a per-ROM properties file.

This 'feature' now seems unnecessary, and it complicates the code by having it.
This commit is contained in:
Stephen Anthony 2018-08-17 13:56:08 -02:30
parent 77c8da55f3
commit 7ae6d84739
9 changed files with 40 additions and 160 deletions

View File

@ -1518,12 +1518,6 @@
<td>Shift-Control + f</td> <td>Shift-Control + f</td>
</tr> </tr>
<tr>
<td>Save current game's properties to a separate properties file</td>
<td>Control + s</td>
<td>Control + s</td>
</tr>
<tr> <tr>
<td>Switch mouse between controller emulation modes (see <b>Game Properties - <a href="#Controller">Controller</a></b>)</td> <td>Switch mouse between controller emulation modes (see <b>Game Properties - <a href="#Controller">Controller</a></b>)</td>
<td>Control + 0</td> <td>Control + 0</td>

View File

@ -524,21 +524,6 @@ void PhysicalKeyboardHandler::handleEvent(StellaKey key, StellaMod mod, bool sta
myOSystem.console().changeHeight(-1); myOSystem.console().changeHeight(-1);
break; break;
case KBDK_S: // Ctrl-s saves properties to a file
{
string filename = myOSystem.baseDir() +
myOSystem.console().properties().get(Cartridge_Name) + ".pro";
ofstream out(filename);
if(out)
{
out << myOSystem.console().properties();
myOSystem.frameBuffer().showMessage("Properties saved");
}
else
myOSystem.frameBuffer().showMessage("Error saving properties");
break;
}
default: default:
handled = false; handled = false;
break; break;

View File

@ -132,8 +132,8 @@ bool OSystem::create()
myEventHandler = MediaFactory::createEventHandler(*this); myEventHandler = MediaFactory::createEventHandler(*this);
myEventHandler->initialize(); myEventHandler->initialize();
// Create a properties set for us to use and set it up // Create the ROM properties database
myPropSet = make_unique<PropertiesSet>(propertiesFile()); myPropSet = make_unique<PropertiesSet>(myPropertiesFile);
#ifdef CHEATCODE_SUPPORT #ifdef CHEATCODE_SUPPORT
myCheatManager = make_unique<CheatManager>(*this); myCheatManager = make_unique<CheatManager>(*this);
@ -220,56 +220,6 @@ void OSystem::setConfigPaths()
mySettings->setValue("propsfile", node.getShortPath()); mySettings->setValue("propsfile", node.getShortPath());
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
PropertiesSet& OSystem::propSet(const string& md5)
{
FilesystemNode node = FilesystemNode();
return propSet(md5, node);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
PropertiesSet& OSystem::propSet(const string& md5, const FilesystemNode& node)
{
if(md5 == EmptyString)
return *myPropSet;
else if(md5 == myGamePropSetMD5)
return *myGamePropSet;
else if (!node.exists())
return *myPropSet;
// Get a valid set of game specific properties
Properties props;
string path = myBaseDir + node.getNameWithExt(".pro");
// Create a properties set based on ROM name
FilesystemNode propNode = FilesystemNode(path);
myGamePropertiesFile = propNode.getPath();
myGamePropSet = make_unique<PropertiesSet>(myGamePropertiesFile);
// Check if game specific property file exists and has matching md5
if(myGamePropSet->size() && myGamePropSet->getMD5(md5, props))
{
myGamePropSetMD5 = md5;
return *myGamePropSet;
}
else
{
myGamePropSetMD5 = "";
return *myPropSet;
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void OSystem::saveGamePropSet(const string& md5)
{
if(myGamePropSet->size() && md5 == myGamePropSetMD5)
{
myGamePropSet->save(myGamePropertiesFile);
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void OSystem::setBaseDir(const string& basedir) void OSystem::setBaseDir(const string& basedir)
{ {
@ -504,13 +454,6 @@ unique_ptr<Console> OSystem::openConsole(const FilesystemNode& romfile, string&
// For initial creation of the Cart, we're only concerned with the BS type // For initial creation of the Cart, we're only concerned with the BS type
Properties props; Properties props;
// Load and use game specific props if existing
FilesystemNode node = FilesystemNode(romfile);
string path = myBaseDir + node.getNameWithExt(".pro");
PropertiesSet& propset = propSet(md5, romfile);
propset.getMD5(md5, props);
// Local helper method // Local helper method
auto CMDLINE_PROPS_UPDATE = [&](const string& name, PropertyType prop) auto CMDLINE_PROPS_UPDATE = [&](const string& name, PropertyType prop)
{ {
@ -531,12 +474,12 @@ unique_ptr<Console> OSystem::openConsole(const FilesystemNode& romfile, string&
// and that the md5 (and hence the cart) has changed // and that the md5 (and hence the cart) has changed
if(props.get(Cartridge_MD5) != cartmd5) if(props.get(Cartridge_MD5) != cartmd5)
{ {
if(!propset.getMD5(cartmd5, props)) if(!myPropSet->getMD5(cartmd5, props))
{ {
// Cart md5 wasn't found, so we create a new props for it // Cart md5 wasn't found, so we create a new props for it
props.set(Cartridge_MD5, cartmd5); props.set(Cartridge_MD5, cartmd5);
props.set(Cartridge_Name, props.get(Cartridge_Name)+cart->multiCartID()); props.set(Cartridge_Name, props.get(Cartridge_Name)+cart->multiCartID());
propset.insert(props, false); myPropSet->insert(props, false);
} }
} }

View File

@ -112,13 +112,7 @@ class OSystem
@return The properties set object @return The properties set object
*/ */
PropertiesSet& propSet(const string& md5 = EmptyString); PropertiesSet& propSet() const { return *myPropSet; }
PropertiesSet& propSet(const string& md5, const FilesystemNode& node);
/**
Save the game specific property file.
*/
void saveGamePropSet(const string& md5);
/** /**
Get the console of the system. The console won't always exist, Get the console of the system. The console won't always exist,
@ -270,14 +264,6 @@ class OSystem
*/ */
const string& paletteFile() const { return myPaletteFile; } const string& paletteFile() const { return myPaletteFile; }
/**
This method should be called to get the full path of the
properties file (stella.pro).
@return String representing the full path of the properties filename.
*/
const string& propertiesFile() const { return myPropertiesFile; }
/** /**
This method should be called to get the full path of the currently This method should be called to get the full path of the currently
loaded ROM. loaded ROM.
@ -448,12 +434,6 @@ class OSystem
// Pointer to the PropertiesSet object // Pointer to the PropertiesSet object
unique_ptr<PropertiesSet> myPropSet; unique_ptr<PropertiesSet> myPropSet;
// Pointer to the game's PropertiesSet object
unique_ptr<PropertiesSet> myGamePropSet;
// MD5 of the currently loaded game PropertiesSet object
string myGamePropSetMD5;
// Pointer to the (currently defined) Console object // Pointer to the (currently defined) Console object
unique_ptr<Console> myConsole; unique_ptr<Console> myConsole;
@ -510,7 +490,6 @@ class OSystem
string myConfigFile; string myConfigFile;
string myPaletteFile; string myPaletteFile;
string myPropertiesFile; string myPropertiesFile;
string myGamePropertiesFile;
FilesystemNode myRomFile; FilesystemNode myRomFile;
string myRomMD5; string myRomMD5;

View File

@ -170,13 +170,6 @@ void PropertiesSet::insert(const Properties& properties, bool save)
} }
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void PropertiesSet::removeMD5(const string& md5)
{
// We only remove from the external list
myExternalProps.erase(md5);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void PropertiesSet::print() const void PropertiesSet::print() const
{ {

View File

@ -100,23 +100,11 @@ class PropertiesSet
*/ */
void insert(const Properties& properties, bool save = true); void insert(const Properties& properties, bool save = true);
/**
Marks the property with the given MD5 as being removed.
@param md5 The md5 of the property to remove
*/
void removeMD5(const string& md5);
/** /**
Prints the contents of the PropertiesSet as a flat file. Prints the contents of the PropertiesSet as a flat file.
*/ */
void print() const; void print() const;
/**
Return the size of the myExternalProps list
*/
uInt64 size() const { return myExternalProps.size(); }
private: private:
using PropsList = std::map<string, Properties>; using PropsList = std::map<string, Properties>;

View File

@ -363,7 +363,7 @@ void GameInfoDialog::loadConfig()
else else
{ {
const string& md5 = instance().launcher().selectedRomMD5(); const string& md5 = instance().launcher().selectedRomMD5();
instance().propSet(md5).getMD5(md5, myGameProperties); instance().propSet().getMD5(md5, myGameProperties);
} }
loadCartridgeProperties(myGameProperties); loadCartridgeProperties(myGameProperties);
@ -375,16 +375,16 @@ void GameInfoDialog::loadConfig()
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void GameInfoDialog::loadCartridgeProperties(Properties properties) void GameInfoDialog::loadCartridgeProperties(const Properties& props)
{ {
myName->setText(properties.get(Cartridge_Name)); myName->setText(props.get(Cartridge_Name));
myMD5->setText(properties.get(Cartridge_MD5)); myMD5->setText(props.get(Cartridge_MD5));
myManufacturer->setText(properties.get(Cartridge_Manufacturer)); myManufacturer->setText(props.get(Cartridge_Manufacturer));
myModelNo->setText(properties.get(Cartridge_ModelNo)); myModelNo->setText(props.get(Cartridge_ModelNo));
myRarity->setText(properties.get(Cartridge_Rarity)); myRarity->setText(props.get(Cartridge_Rarity));
myNote->setText(properties.get(Cartridge_Note)); myNote->setText(props.get(Cartridge_Note));
mySound->setState(properties.get(Cartridge_Sound) == "STEREO"); mySound->setState(props.get(Cartridge_Sound) == "STEREO");
myType->setSelected(properties.get(Cartridge_Type), "AUTO"); myType->setSelected(props.get(Cartridge_Type), "AUTO");
if(instance().hasConsole() && myType->getSelectedTag().toString() == "AUTO") if(instance().hasConsole() && myType->getSelectedTag().toString() == "AUTO")
{ {
@ -400,23 +400,23 @@ void GameInfoDialog::loadCartridgeProperties(Properties properties)
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void GameInfoDialog::loadConsoleProperties(Properties properties) void GameInfoDialog::loadConsoleProperties(const Properties& props)
{ {
myLeftDiffGroup->setSelected(properties.get(Console_LeftDifficulty) == "A" ? 0 : 1); myLeftDiffGroup->setSelected(props.get(Console_LeftDifficulty) == "A" ? 0 : 1);
myRightDiffGroup->setSelected(properties.get(Console_RightDifficulty) == "A" ? 0 : 1); myRightDiffGroup->setSelected(props.get(Console_RightDifficulty) == "A" ? 0 : 1);
myTVTypeGroup->setSelected(properties.get(Console_TelevisionType) == "BW" ? 1 : 0); myTVTypeGroup->setSelected(props.get(Console_TelevisionType) == "BW" ? 1 : 0);
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void GameInfoDialog::loadControllerProperties(Properties properties) void GameInfoDialog::loadControllerProperties(const Properties& props)
{ {
myP0Controller->setSelected(properties.get(Controller_Left), "JOYSTICK"); myP0Controller->setSelected(props.get(Controller_Left), "JOYSTICK");
myP1Controller->setSelected(properties.get(Controller_Right), "JOYSTICK"); myP1Controller->setSelected(props.get(Controller_Right), "JOYSTICK");
mySwapPorts->setState(properties.get(Console_SwapPorts) == "YES"); mySwapPorts->setState(props.get(Console_SwapPorts) == "YES");
mySwapPaddles->setState(properties.get(Controller_SwapPaddles) == "YES"); mySwapPaddles->setState(props.get(Controller_SwapPaddles) == "YES");
// MouseAxis property (potentially contains 'range' information) // MouseAxis property (potentially contains 'range' information)
istringstream m_axis(properties.get(Controller_MouseAxis)); istringstream m_axis(props.get(Controller_MouseAxis));
string m_control, m_range; string m_control, m_range;
m_axis >> m_control; m_axis >> m_control;
bool autoAxis = BSPF::equalsIgnoreCase(m_control, "AUTO"); bool autoAxis = BSPF::equalsIgnoreCase(m_control, "AUTO");
@ -446,9 +446,9 @@ void GameInfoDialog::loadControllerProperties(Properties properties)
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void GameInfoDialog::loadDisplayProperties(Properties properties) void GameInfoDialog::loadDisplayProperties(const Properties& props)
{ {
myFormat->setSelected(properties.get(Display_Format), "AUTO"); myFormat->setSelected(props.get(Display_Format), "AUTO");
if(instance().hasConsole() && myFormat->getSelectedTag().toString() == "AUTO") if(instance().hasConsole() && myFormat->getSelectedTag().toString() == "AUTO")
{ {
const string& format = instance().console().about().DisplayFormat; const string& format = instance().console().about().DisplayFormat;
@ -458,7 +458,7 @@ void GameInfoDialog::loadDisplayProperties(Properties properties)
else else
myFormatDetected->setLabel(""); myFormatDetected->setLabel("");
const string& ystart = properties.get(Display_YStart); const string& ystart = props.get(Display_YStart);
myYStart->setValue(atoi(ystart.c_str())); myYStart->setValue(atoi(ystart.c_str()));
myYStart->setValueLabel(ystart == "0" ? "Auto" : ystart); myYStart->setValueLabel(ystart == "0" ? "Auto" : ystart);
myYStart->setValueUnit(ystart == "0" ? "" : "px"); myYStart->setValueUnit(ystart == "0" ? "" : "px");
@ -471,7 +471,7 @@ void GameInfoDialog::loadDisplayProperties(Properties properties)
else else
myYStartDetected->setLabel(""); myYStartDetected->setLabel("");
const string& height = properties.get(Display_Height); const string& height = props.get(Display_Height);
myHeight->setValue(atoi(height.c_str())); myHeight->setValue(atoi(height.c_str()));
myHeight->setValueLabel(height == "0" ? "Auto" : height); myHeight->setValueLabel(height == "0" ? "Auto" : height);
myHeight->setValueUnit(height == "0" ? "" : "px"); myHeight->setValueUnit(height == "0" ? "" : "px");
@ -485,11 +485,11 @@ void GameInfoDialog::loadDisplayProperties(Properties properties)
else else
myHeightDetected->setLabel(""); myHeightDetected->setLabel("");
bool usePhosphor = properties.get(Display_Phosphor) == "YES"; bool usePhosphor = props.get(Display_Phosphor) == "YES";
myPhosphor->setState(usePhosphor); myPhosphor->setState(usePhosphor);
myPPBlend->setEnabled(usePhosphor); myPPBlend->setEnabled(usePhosphor);
const string& blend = properties.get(Display_PPBlend); const string& blend = props.get(Display_PPBlend);
myPPBlend->setValue(atoi(blend.c_str())); myPPBlend->setValue(atoi(blend.c_str()));
myPPBlend->setValueLabel(blend == "0" ? "Default" : blend); myPPBlend->setValueLabel(blend == "0" ? "Default" : blend);
myPPBlend->setValueUnit(blend == "0" ? "" : "%"); myPPBlend->setValueUnit(blend == "0" ? "" : "%");
@ -539,10 +539,8 @@ void GameInfoDialog::saveConfig()
myGameProperties.set(Display_PPBlend, myPPBlend->getValueLabel() == "Default" ? "0" : myGameProperties.set(Display_PPBlend, myPPBlend->getValueLabel() == "Default" ? "0" :
myPPBlend->getValueLabel()); myPPBlend->getValueLabel());
const string& md5 = myGameProperties.get(Cartridge_MD5); // Always insert; if the properties are already present, nothing will happen
// always insert, doesn't hurt instance().propSet().insert(myGameProperties);
instance().propSet(md5).insert(myGameProperties);
instance().saveGamePropSet(myGameProperties.get(Cartridge_MD5));
// In any event, inform the Console // In any event, inform the Console
if(instance().hasConsole()) if(instance().hasConsole())
@ -583,9 +581,9 @@ void GameInfoDialog::setDefaults()
{ {
// Load the default properties // Load the default properties
Properties defaultProperties; Properties defaultProperties;
string md5 = myGameProperties.get(Cartridge_MD5); const string& md5 = myGameProperties.get(Cartridge_MD5);
instance().propSet(md5).getMD5(md5, defaultProperties, true); instance().propSet().getMD5(md5, defaultProperties, true);
switch(myTab->getActiveTab()) switch(myTab->getActiveTab())
{ {

View File

@ -46,13 +46,13 @@ class GameInfoDialog : public Dialog, public CommandSender
void setDefaults() override; void setDefaults() override;
// load the properties for the 'Cartridge' tab // load the properties for the 'Cartridge' tab
void loadCartridgeProperties(Properties properties); void loadCartridgeProperties(const Properties& props);
// load the properties for the 'Console' tab // load the properties for the 'Console' tab
void loadConsoleProperties(Properties properties); void loadConsoleProperties(const Properties& props);
// load the properties for the 'Controller' tab // load the properties for the 'Controller' tab
void loadControllerProperties(Properties properties); void loadControllerProperties(const Properties& props);
// load the properties for the 'Display' tab // load the properties for the 'Display' tab
void loadDisplayProperties(Properties properties); void loadDisplayProperties(const Properties& props);
void updateControllerStates(); void updateControllerStates();
void eraseEEPROM(); void eraseEEPROM();

View File

@ -332,7 +332,7 @@ void LauncherDialog::loadRomInfo()
// Get the properties for this entry // Get the properties for this entry
Properties props; Properties props;
instance().propSet(myGameList->md5(item), node).getMD5WithInsert(node, myGameList->md5(item), props); instance().propSet().getMD5WithInsert(node, myGameList->md5(item), props);
myRomInfoWidget->setProperties(props); myRomInfoWidget->setProperties(props);
} }