mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2024-11-22 14:15:38 +00:00
Alternative emulators now work correctly when games are launched from collection systems.
This commit is contained in:
parent
f1ceb1c2fe
commit
0c3a7d7d94
|
@ -746,14 +746,26 @@ void FileData::launchGame(Window* window)
|
||||||
{
|
{
|
||||||
LOG(LogInfo) << "Launching game \"" << this->metadata.get("name") << "\"...";
|
LOG(LogInfo) << "Launching game \"" << this->metadata.get("name") << "\"...";
|
||||||
|
|
||||||
|
SystemData* gameSystem = nullptr;
|
||||||
std::string command = "";
|
std::string command = "";
|
||||||
std::string alternativeEmulator = getSystem()->getAlternativeEmulator();
|
std::string alternativeEmulator;
|
||||||
|
|
||||||
|
if (mSystem->isCollection())
|
||||||
|
gameSystem = SystemData::getSystemByName(mSystemName);
|
||||||
|
else
|
||||||
|
gameSystem = mSystem;
|
||||||
|
|
||||||
|
// This is just a precaution as getSystemByName() should always return a valid result.
|
||||||
|
if (gameSystem == nullptr)
|
||||||
|
gameSystem = mSystem;
|
||||||
|
|
||||||
|
alternativeEmulator = gameSystem->getAlternativeEmulator();
|
||||||
|
|
||||||
// Check if there is a game-specific alternative emulator configured.
|
// Check if there is a game-specific alternative emulator configured.
|
||||||
// This takes precedence over any system-wide alternative emulator configuration.
|
// This takes precedence over any system-wide alternative emulator configuration.
|
||||||
if (Settings::getInstance()->getBool("AlternativeEmulatorPerGame") &&
|
if (Settings::getInstance()->getBool("AlternativeEmulatorPerGame") &&
|
||||||
!metadata.get("altemulator").empty()) {
|
!metadata.get("altemulator").empty()) {
|
||||||
command = getSystem()->getLaunchCommandFromLabel(metadata.get("altemulator"));
|
command = gameSystem->getLaunchCommandFromLabel(metadata.get("altemulator"));
|
||||||
if (command == "") {
|
if (command == "") {
|
||||||
LOG(LogWarning) << "Invalid alternative emulator \"" << metadata.get("altemulator")
|
LOG(LogWarning) << "Invalid alternative emulator \"" << metadata.get("altemulator")
|
||||||
<< "\" configured for game";
|
<< "\" configured for game";
|
||||||
|
@ -767,16 +779,16 @@ void FileData::launchGame(Window* window)
|
||||||
|
|
||||||
// Check if there is a system-wide alternative emulator configured.
|
// Check if there is a system-wide alternative emulator configured.
|
||||||
if (command == "" && alternativeEmulator != "") {
|
if (command == "" && alternativeEmulator != "") {
|
||||||
command = getSystem()->getLaunchCommandFromLabel(alternativeEmulator);
|
command = gameSystem->getLaunchCommandFromLabel(alternativeEmulator);
|
||||||
if (command == "") {
|
if (command == "") {
|
||||||
LOG(LogWarning) << "Invalid alternative emulator \""
|
LOG(LogWarning) << "Invalid alternative emulator \""
|
||||||
<< alternativeEmulator.substr(9, alternativeEmulator.length() - 9)
|
<< alternativeEmulator.substr(9, alternativeEmulator.length() - 9)
|
||||||
<< "\" configured for system \"" << getSystem()->getName() << "\"";
|
<< "\" configured for system \"" << gameSystem->getName() << "\"";
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
LOG(LogDebug) << "FileData::launchGame(): Using alternative emulator \""
|
LOG(LogDebug) << "FileData::launchGame(): Using alternative emulator \""
|
||||||
<< getSystem()->getAlternativeEmulator() << "\""
|
<< gameSystem->getAlternativeEmulator() << "\""
|
||||||
<< " as configured for system \"" << this->getSystem()->getName() << "\"";
|
<< " as configured for system \"" << gameSystem->getName() << "\"";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -969,6 +969,16 @@ bool SystemData::isVisible()
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SystemData* SystemData::getSystemByName(const std::string& systemName)
|
||||||
|
{
|
||||||
|
for (auto it : sSystemVector) {
|
||||||
|
if ((*it).getName() == systemName)
|
||||||
|
return it;
|
||||||
|
}
|
||||||
|
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
SystemData* SystemData::getNext() const
|
SystemData* SystemData::getNext() const
|
||||||
{
|
{
|
||||||
std::vector<SystemData*>::const_iterator it = getIterator();
|
std::vector<SystemData*>::const_iterator it = getIterator();
|
||||||
|
|
|
@ -131,6 +131,7 @@ public:
|
||||||
|
|
||||||
bool isVisible();
|
bool isVisible();
|
||||||
|
|
||||||
|
static SystemData* getSystemByName(const std::string& systemName);
|
||||||
SystemData* getNext() const;
|
SystemData* getNext() const;
|
||||||
SystemData* getPrev() const;
|
SystemData* getPrev() const;
|
||||||
static SystemData* getRandomSystem(const SystemData* currentSystem);
|
static SystemData* getRandomSystem(const SystemData* currentSystem);
|
||||||
|
|
Loading…
Reference in a new issue