mirror of https://github.com/stella-emu/stella.git
load and update existing game specific properties file
This commit is contained in:
parent
d65ac4875f
commit
2a3bb4329e
|
@ -5,6 +5,8 @@
|
||||||
|
|
||||||
* Fixes for collision corner cases (during HBlank)
|
* Fixes for collision corner cases (during HBlank)
|
||||||
|
|
||||||
|
* UI modernization (new widget look, dialog titles added, dialogs refactored)
|
||||||
|
|
||||||
5.0.2 to 5.1: (February 4, 2018)
|
5.0.2 to 5.1: (February 4, 2018)
|
||||||
|
|
||||||
* Added "Time Machine" mode, which automatically creates save states
|
* Added "Time Machine" mode, which automatically creates save states
|
||||||
|
|
|
@ -217,6 +217,56 @@ 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)
|
||||||
{
|
{
|
||||||
|
@ -447,8 +497,7 @@ void OSystem::logMessage(const string& message, uInt8 level)
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
unique_ptr<Console>
|
unique_ptr<Console> OSystem::openConsole(const FilesystemNode& romfile, string& md5)
|
||||||
OSystem::openConsole(const FilesystemNode& romfile, string& md5)
|
|
||||||
{
|
{
|
||||||
unique_ptr<Console> console;
|
unique_ptr<Console> console;
|
||||||
|
|
||||||
|
@ -460,8 +509,15 @@ OSystem::openConsole(const FilesystemNode& romfile, string& md5)
|
||||||
// Get a valid set of properties, including any entered on the commandline
|
// Get a valid set of properties, including any entered on the commandline
|
||||||
// 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;
|
||||||
myPropSet->getMD5(md5, 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
|
||||||
auto CMDLINE_PROPS_UPDATE = [&](const string& name, PropertyType prop)
|
auto CMDLINE_PROPS_UPDATE = [&](const string& name, PropertyType prop)
|
||||||
{
|
{
|
||||||
const string& s = mySettings->getString(name);
|
const string& s = mySettings->getString(name);
|
||||||
|
@ -481,12 +537,12 @@ OSystem::openConsole(const FilesystemNode& romfile, string& md5)
|
||||||
// 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(!myPropSet->getMD5(cartmd5, props))
|
if(!propset.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());
|
||||||
myPropSet->insert(props, false);
|
propset.insert(props, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -115,7 +115,13 @@ class OSystem
|
||||||
|
|
||||||
@return The properties set object
|
@return The properties set object
|
||||||
*/
|
*/
|
||||||
PropertiesSet& propSet() const { return *myPropSet; }
|
PropertiesSet& propSet(const string& md5 = EmptyString);
|
||||||
|
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,
|
||||||
|
@ -454,6 +460,12 @@ 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;
|
||||||
|
|
||||||
|
@ -516,6 +528,7 @@ class OSystem
|
||||||
string myConfigFile;
|
string myConfigFile;
|
||||||
string myPaletteFile;
|
string myPaletteFile;
|
||||||
string myPropertiesFile;
|
string myPropertiesFile;
|
||||||
|
string myGamePropertiesFile;
|
||||||
|
|
||||||
FilesystemNode myRomFile;
|
FilesystemNode myRomFile;
|
||||||
string myRomMD5;
|
string myRomMD5;
|
||||||
|
|
|
@ -112,6 +112,11 @@ class PropertiesSet
|
||||||
*/
|
*/
|
||||||
void print() const;
|
void print() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Return the size of the myExternalProps list
|
||||||
|
*/
|
||||||
|
uInt32 size() { return myExternalProps.size(); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
using PropsList = std::map<string, Properties>;
|
using PropsList = std::map<string, Properties>;
|
||||||
|
|
||||||
|
|
|
@ -348,7 +348,7 @@ void GameInfoDialog::loadConfig()
|
||||||
const string& md5 = instance().launcher().selectedRomMD5();
|
const string& md5 = instance().launcher().selectedRomMD5();
|
||||||
if(md5 != "")
|
if(md5 != "")
|
||||||
{
|
{
|
||||||
instance().propSet().getMD5(md5, myGameProperties);
|
instance().propSet(md5).getMD5(md5, myGameProperties);
|
||||||
myPropertiesLoaded = true;
|
myPropertiesLoaded = true;
|
||||||
loadView();
|
loadView();
|
||||||
}
|
}
|
||||||
|
@ -486,10 +486,13 @@ void GameInfoDialog::saveConfig()
|
||||||
myPPBlend->getValueLabel());
|
myPPBlend->getValueLabel());
|
||||||
|
|
||||||
// Determine whether to add or remove an entry from the properties set
|
// Determine whether to add or remove an entry from the properties set
|
||||||
|
const string& md5 = myGameProperties.get(Cartridge_MD5);
|
||||||
if(myDefaultsSelected)
|
if(myDefaultsSelected)
|
||||||
instance().propSet().removeMD5(myGameProperties.get(Cartridge_MD5));
|
instance().propSet(md5).removeMD5(myGameProperties.get(Cartridge_MD5));
|
||||||
else
|
else
|
||||||
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())
|
||||||
|
@ -501,7 +504,7 @@ void GameInfoDialog::setDefaults()
|
||||||
{
|
{
|
||||||
// Load the default properties
|
// Load the default properties
|
||||||
string md5 = myGameProperties.get(Cartridge_MD5);
|
string md5 = myGameProperties.get(Cartridge_MD5);
|
||||||
instance().propSet().getMD5(md5, myGameProperties, true);
|
instance().propSet(md5).getMD5(md5, myGameProperties, true);
|
||||||
|
|
||||||
// Reload the current dialog
|
// Reload the current dialog
|
||||||
loadView();
|
loadView();
|
||||||
|
|
|
@ -349,7 +349,7 @@ void LauncherDialog::loadRomInfo()
|
||||||
|
|
||||||
// Get the properties for this entry
|
// Get the properties for this entry
|
||||||
Properties props;
|
Properties props;
|
||||||
instance().propSet().getMD5WithInsert(node, myGameList->md5(item), props);
|
instance().propSet(myGameList->md5(item), node).getMD5WithInsert(node, myGameList->md5(item), props);
|
||||||
|
|
||||||
myRomInfoWidget->setProperties(props);
|
myRomInfoWidget->setProperties(props);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue