mirror of https://github.com/stella-emu/stella.git
Partially revert previous commit: fix ROM launcher not showing properties in certain cases.
This commit is contained in:
parent
308cc97974
commit
a618d27f01
|
@ -648,35 +648,8 @@ ByteBuffer OSystem::openROM(const FilesystemNode& rom, string& md5, size_t& size
|
||||||
if(md5 == "")
|
if(md5 == "")
|
||||||
md5 = MD5::hash(image, size);
|
md5 = MD5::hash(image, size);
|
||||||
|
|
||||||
// Handle ROM properties, do some error checking
|
// Make sure to load a per-ROM properties entry, if one exists
|
||||||
// Only add to the database when necessary
|
myPropSet->loadPerROM(rom, md5);
|
||||||
bool toInsert = false;
|
|
||||||
|
|
||||||
// First, does this ROM have a per-ROM properties entry?
|
|
||||||
// If so, load it into the database
|
|
||||||
FilesystemNode propsNode(rom.getPathWithExt(".pro"));
|
|
||||||
if(propsNode.exists() && propsNode.isFile())
|
|
||||||
{
|
|
||||||
Logger::info("Loading per-ROM properties: " + propsNode.getShortPath());
|
|
||||||
myPropSet->load(propsNode.getPath(), false);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Next, make sure we have a valid md5 and name
|
|
||||||
Properties props;
|
|
||||||
if(!myPropSet->getMD5(md5, props))
|
|
||||||
{
|
|
||||||
props.set(PropType::Cart_MD5, md5);
|
|
||||||
toInsert = true;
|
|
||||||
}
|
|
||||||
if(toInsert || props.get(PropType::Cart_Name) == EmptyString)
|
|
||||||
{
|
|
||||||
props.set(PropType::Cart_Name, rom.getNameWithExt(""));
|
|
||||||
toInsert = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Finally, insert properties if any info was missing
|
|
||||||
if(toInsert)
|
|
||||||
myPropSet->insert(props, false);
|
|
||||||
|
|
||||||
return image;
|
return image;
|
||||||
}
|
}
|
||||||
|
|
|
@ -156,6 +156,37 @@ void PropertiesSet::insert(const Properties& properties, bool save)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
void PropertiesSet::loadPerROM(const FilesystemNode& rom, const string& md5)
|
||||||
|
{
|
||||||
|
// Handle ROM properties, do some error checking
|
||||||
|
// Only add to the database when necessary
|
||||||
|
bool toInsert = false;
|
||||||
|
|
||||||
|
// First, does this ROM have a per-ROM properties entry?
|
||||||
|
// If so, load it into the database
|
||||||
|
FilesystemNode propsNode(rom.getPathWithExt(".pro"));
|
||||||
|
if(propsNode.exists() && propsNode.isFile())
|
||||||
|
load(propsNode.getPath(), false);
|
||||||
|
|
||||||
|
// Next, make sure we have a valid md5 and name
|
||||||
|
Properties props;
|
||||||
|
if(!getMD5(md5, props))
|
||||||
|
{
|
||||||
|
props.set(PropType::Cart_MD5, md5);
|
||||||
|
toInsert = true;
|
||||||
|
}
|
||||||
|
if(toInsert || props.get(PropType::Cart_Name) == EmptyString)
|
||||||
|
{
|
||||||
|
props.set(PropType::Cart_Name, rom.getNameWithExt(""));
|
||||||
|
toInsert = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Finally, insert properties if any info was missing
|
||||||
|
if(toInsert)
|
||||||
|
insert(props, false);
|
||||||
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
void PropertiesSet::print() const
|
void PropertiesSet::print() const
|
||||||
{
|
{
|
||||||
|
|
|
@ -90,6 +90,21 @@ class PropertiesSet
|
||||||
*/
|
*/
|
||||||
void insert(const Properties& properties, bool save = true);
|
void insert(const Properties& properties, bool save = true);
|
||||||
|
|
||||||
|
/**
|
||||||
|
Load properties for a specific ROM from a per-ROM properties file,
|
||||||
|
if it exists. In any event, also do some error checking, like making
|
||||||
|
sure that the properties have a valid name, etc.
|
||||||
|
|
||||||
|
NOTE: This method is meant to be called only when starting Stella
|
||||||
|
and loading a ROM for the first time. Currently, that means
|
||||||
|
only from the ROM launcher or when actually opening the ROM.
|
||||||
|
*** FOR ALL OTHER CASES, USE getMD5() ***
|
||||||
|
|
||||||
|
@param rom The node representing the rom file
|
||||||
|
@param md5 The md5 of the property to get
|
||||||
|
*/
|
||||||
|
void loadPerROM(const FilesystemNode& rom, const string& md5);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Prints the contents of the PropertiesSet as a flat file.
|
Prints the contents of the PropertiesSet as a flat file.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -48,6 +48,11 @@ RomInfoWidget::RomInfoWidget(GuiObject* boss, const GUI::Font& font,
|
||||||
void RomInfoWidget::setProperties(const FilesystemNode& node, const string& md5)
|
void RomInfoWidget::setProperties(const FilesystemNode& node, const string& md5)
|
||||||
{
|
{
|
||||||
myHaveProperties = true;
|
myHaveProperties = true;
|
||||||
|
|
||||||
|
// Make sure to load a per-ROM properties entry, if one exists
|
||||||
|
instance().propSet().loadPerROM(node, md5);
|
||||||
|
|
||||||
|
// And now get the properties for this ROM
|
||||||
instance().propSet().getMD5(md5, myProperties);
|
instance().propSet().getMD5(md5, myProperties);
|
||||||
|
|
||||||
// Decide whether the information should be shown immediately
|
// Decide whether the information should be shown immediately
|
||||||
|
|
Loading…
Reference in New Issue