2020-09-21 17:17:34 +00:00
|
|
|
// SPDX-License-Identifier: MIT
|
2020-06-06 11:10:33 +00:00
|
|
|
//
|
2020-09-21 17:17:34 +00:00
|
|
|
// EmulationStation Desktop Edition
|
2020-06-21 12:25:28 +00:00
|
|
|
// MameNames.h
|
2020-06-06 11:10:33 +00:00
|
|
|
//
|
2020-06-21 12:25:28 +00:00
|
|
|
// Provides expanded game names based on short MAME name arguments. Also contains
|
|
|
|
// functions to check whether a passed argument is a MAME BIOS or a MAME device.
|
|
|
|
// The data sources are stored in the .emulationstation/resources directory
|
|
|
|
// as the files mamebioses.xml, mamedevices.xml and mamenames.xml.
|
2020-06-06 11:10:33 +00:00
|
|
|
//
|
|
|
|
|
2018-02-09 17:23:58 +00:00
|
|
|
#ifndef ES_CORE_MAMENAMES_H
|
|
|
|
#define ES_CORE_MAMENAMES_H
|
|
|
|
|
2021-11-17 20:32:40 +00:00
|
|
|
#include "utils/StringUtil.h"
|
|
|
|
|
|
|
|
#include <algorithm>
|
2018-02-09 17:23:58 +00:00
|
|
|
#include <string>
|
2021-11-17 20:38:27 +00:00
|
|
|
#include <unordered_map>
|
2018-02-09 17:23:58 +00:00
|
|
|
#include <vector>
|
|
|
|
|
2021-11-17 20:32:40 +00:00
|
|
|
// Expand MAME names to full game names and lookup device and BIOS entries.
|
2018-02-09 17:23:58 +00:00
|
|
|
class MameNames
|
|
|
|
{
|
|
|
|
public:
|
2021-11-17 20:32:40 +00:00
|
|
|
static MameNames& getInstance();
|
|
|
|
|
|
|
|
std::string getRealName(const std::string& mameName)
|
2021-07-07 18:31:46 +00:00
|
|
|
{
|
2021-11-17 20:32:40 +00:00
|
|
|
std::string name = mNamePairs[mameName];
|
|
|
|
if (name == "")
|
|
|
|
return mameName;
|
|
|
|
else
|
|
|
|
return name;
|
2021-07-07 18:31:46 +00:00
|
|
|
}
|
2021-11-17 20:32:40 +00:00
|
|
|
|
|
|
|
std::string getCleanName(const std::string& mameName)
|
2021-07-07 18:31:46 +00:00
|
|
|
{
|
2021-11-17 20:32:40 +00:00
|
|
|
return Utils::String::removeParenthesis(getRealName(mameName));
|
2021-07-07 18:31:46 +00:00
|
|
|
}
|
2018-02-09 17:23:58 +00:00
|
|
|
|
2021-11-17 20:32:40 +00:00
|
|
|
const bool isBios(const std::string& biosName)
|
|
|
|
{
|
|
|
|
return std::find(mMameBioses.cbegin(), mMameBioses.cend(), biosName) != mMameBioses.cend();
|
|
|
|
}
|
2018-02-09 17:23:58 +00:00
|
|
|
|
2021-11-17 20:32:40 +00:00
|
|
|
const bool isDevice(const std::string& deviceName)
|
|
|
|
{
|
|
|
|
return std::find(mMameDevices.cbegin(), mMameDevices.cend(), deviceName) !=
|
|
|
|
mMameDevices.cend();
|
|
|
|
}
|
2018-02-09 17:23:58 +00:00
|
|
|
|
2021-11-17 20:32:40 +00:00
|
|
|
private:
|
2021-07-07 18:31:46 +00:00
|
|
|
MameNames();
|
2018-02-09 17:23:58 +00:00
|
|
|
|
2021-11-17 20:32:40 +00:00
|
|
|
std::unordered_map<std::string, std::string> mNamePairs;
|
2020-06-21 12:25:28 +00:00
|
|
|
std::vector<std::string> mMameBioses;
|
|
|
|
std::vector<std::string> mMameDevices;
|
2020-06-26 15:17:35 +00:00
|
|
|
};
|
2018-02-09 17:23:58 +00:00
|
|
|
|
|
|
|
#endif // ES_CORE_MAMENAMES_H
|