From cb54d8ae6d91af1b0bd3eb63f4648d2376e5dff2 Mon Sep 17 00:00:00 2001 From: Aloshi Date: Mon, 26 May 2014 17:31:16 -0500 Subject: [PATCH] Changed "platform IDs" to just "platform", and now names are used instead of numerical IDs. Check src/PlatformIds.cpp for a complete list. --- CMakeLists.txt | 1 + README.md | 4 +- src/PlatformId.cpp | 76 +++++++++++++++++++++++++++++++++ src/PlatformId.h | 65 +++++++++++++++------------- src/SystemData.cpp | 13 +++++- src/guis/GuiScraperStart.cpp | 2 +- src/scrapers/GamesDBScraper.cpp | 2 + 7 files changed, 129 insertions(+), 34 deletions(-) create mode 100644 src/PlatformId.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 7981c873b..6c0171d9b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -241,6 +241,7 @@ set(ES_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src/MathExp.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/MetaData.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/platform.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/src/PlatformId.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/Renderer_draw_gl.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/Renderer_init.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/ScraperCmdLine.cpp diff --git a/README.md b/README.md index 2fd0e5150..57695ee04 100644 --- a/README.md +++ b/README.md @@ -154,8 +154,8 @@ All systems must be contained within the tag.--> snesemulator %ROM% - - 42 + + snes ``` diff --git a/src/PlatformId.cpp b/src/PlatformId.cpp new file mode 100644 index 000000000..0ab9d180c --- /dev/null +++ b/src/PlatformId.cpp @@ -0,0 +1,76 @@ +#include "PlatformId.h" + +namespace PlatformIds +{ + const char* PlatformNames[PLATFORM_COUNT + 1] = { + "unknown", // = 0, + + "3do", // = 1, + "amiga", // = 2, + "arcade", // = 3, + "atari2600", // = 4, + "atari5200", // = 5, + "atari7800", // = 6, + "atariJaguar", // = 7, + "atariJaguarCD", // = 8, + "atariXE", // = 9, + "colecovision", // = 10, + "commodore64", // = 11, + "intellivision", // = 12, + "mac", // = 13, + "xbox", // = 14, + "xbox360", // = 15, + "neogeo", // = 16, + "ngp", // = 17, + "ngpc", // = 18, + "n3ds", // = 19, + "n64", // = 20, + "nds", // = 21, + "nes", // = 22, + "gb", // = 23, + "gba", // = 24, + "gbc", // = 25, + "gamecube", // = 26, + "wii", // = 27, + "wiiu", // = 28, + "pc", // = 29, + "sega32x", // = 30, + "segacd", // = 31, + "dreamcast", // = 32, + "gamegear", // = 33, + "genesis", // = 34, + "mastersystem", // = 35, + "megadrive", // = 36, + "saturn", // = 37, + "psx", // = 38, + "ps2", // = 39, + "ps3", // = 40, + "ps4", // = 41, + "psvita", // = 42, + "psp", // = 43, + "snes", // = 44, + "pcengine", // = 45, + "zxspectrum", // = 46, + + "invalid" // = 47 + }; + + PlatformId getPlatformId(const char* str) + { + if(str == NULL) + return PLATFORM_UNKNOWN; + + for(unsigned int i = 1; i < PLATFORM_COUNT; i++) + { + if(strcmp(PlatformNames[i], str) == 0) + return (PlatformId)i; + } + + return PLATFORM_UNKNOWN; + } + + const char* getPlatformName(PlatformId id) + { + return PlatformNames[id]; + } +} diff --git a/src/PlatformId.h b/src/PlatformId.h index ca22fe511..45659def1 100644 --- a/src/PlatformId.h +++ b/src/PlatformId.h @@ -1,5 +1,7 @@ #pragma once +#include + namespace PlatformIds { enum PlatformId : unsigned int @@ -22,35 +24,40 @@ namespace PlatformIds XBOX = 14, XBOX_360 = 15, NEOGEO = 16, - NINTENDO_3DS = 17, - NINTENDO_64 = 18, - NINTENDO_DS = 19, - NINTENDO_ENTERTAINMENT_SYSTEM = 20, - GAME_BOY = 21, - GAME_BOY_ADVANCE = 22, - GAME_BOY_COLOR = 23, - NINTENDO_GAMECUBE = 24, - NINTENDO_WII = 25, - NINTENDO_WII_U = 26, - PC = 27, - SEGA_32X = 28, - SEGA_CD = 29, - SEGA_DREAMCAST = 30, - SEGA_GAME_GEAR = 31, - SEGA_GENESIS = 32, - SEGA_MASTER_SYSTEM = 33, - SEGA_MEGA_DRIVE = 34, - SEGA_SATURN = 35, - PLAYSTATION = 36, - PLAYSTATION_2 = 37, - PLAYSTATION_3 = 38, - PLAYSTATION_4 = 39, - PLAYSTATION_VITA = 40, - PLAYSTATION_PORTABLE = 41, - SUPER_NINTENDO = 42, - TURBOGRAFX_16 = 43, - ZX_SPECTRUM = 44, + NEOGEO_POCKET = 17, + NEOGEO_POCKET_COLOR = 18, + NINTENDO_3DS = 19, + NINTENDO_64 = 20, + NINTENDO_DS = 21, + NINTENDO_ENTERTAINMENT_SYSTEM = 22, + GAME_BOY = 23, + GAME_BOY_ADVANCE = 24, + GAME_BOY_COLOR = 25, + NINTENDO_GAMECUBE = 26, + NINTENDO_WII = 27, + NINTENDO_WII_U = 28, + PC = 29, + SEGA_32X = 30, + SEGA_CD = 31, + SEGA_DREAMCAST = 32, + SEGA_GAME_GEAR = 33, + SEGA_GENESIS = 34, + SEGA_MASTER_SYSTEM = 35, + SEGA_MEGA_DRIVE = 36, + SEGA_SATURN = 37, + PLAYSTATION = 38, + PLAYSTATION_2 = 39, + PLAYSTATION_3 = 40, + PLAYSTATION_4 = 41, + PLAYSTATION_VITA = 42, + PLAYSTATION_PORTABLE = 43, + SUPER_NINTENDO = 44, + TURBOGRAFX_16 = 45, + ZX_SPECTRUM = 46, - PLATFORM_COUNT = 45 + PLATFORM_COUNT = 47 }; + + PlatformId getPlatformId(const char* str); + const char* getPlatformName(PlatformId id); } diff --git a/src/SystemData.cpp b/src/SystemData.cpp index 988477071..0cc3b4613 100644 --- a/src/SystemData.cpp +++ b/src/SystemData.cpp @@ -257,7 +257,13 @@ bool SystemData::loadConfig() } cmd = system.child("command").text().get(); - platformId = (PlatformIds::PlatformId)system.child("platformid").text().as_uint(PlatformIds::PLATFORM_UNKNOWN); + + const char* platformIdString = system.child("platform").text().as_string(); + platformId = PlatformIds::getPlatformId(platformIdString); + + // if there appears to be an actual platform ID supplied but it didn't match the list, warn + if(platformIdString != NULL && platformIdString[0] != '\0' && platformId == PlatformIds::PLATFORM_UNKNOWN) + LOG(LogWarning) << " Unknown platform for system \"" << name << "\" (platform \"" << platformIdString << "\")"; //validate if(name.empty() || path.empty() || extensions.empty() || cmd.empty()) @@ -300,7 +306,7 @@ void SystemData::writeExampleConfig(const std::string& path) " \n" " Nintendo Entertainment System\n" "\n" - " \n" + " \n" " ~/roms/nes\n" "\n" " \n" @@ -312,6 +318,9 @@ void SystemData::writeExampleConfig(const std::string& path) " %ROM_RAW% is the raw, unescaped path to the ROM. -->\n" " retroarch -L ~/cores/libretro-fceumm.so %ROM%\n" "\n" + " \n" + " nes\n" + "\n" " \n" "\n"; diff --git a/src/guis/GuiScraperStart.cpp b/src/guis/GuiScraperStart.cpp index fc7afd651..9b382d2a9 100644 --- a/src/guis/GuiScraperStart.cpp +++ b/src/guis/GuiScraperStart.cpp @@ -44,7 +44,7 @@ void GuiScraperStart::pressedStart() if((*it)->getPlatformId() == PlatformIds::PLATFORM_UNKNOWN) { mWindow->pushGui(new GuiMsgBox(mWindow, - strToUpper("Warning: some of your selected systems do not have a platform ID set. Results may be even more inaccurate than usual!\nContinue anyway?"), + strToUpper("Warning: some of your selected systems do not have a platform set. Results may be even more inaccurate than usual!\nContinue anyway?"), "YES", std::bind(&GuiScraperStart::start, this), "NO", nullptr)); return; diff --git a/src/scrapers/GamesDBScraper.cpp b/src/scrapers/GamesDBScraper.cpp index 10be75df4..88a5526c6 100644 --- a/src/scrapers/GamesDBScraper.cpp +++ b/src/scrapers/GamesDBScraper.cpp @@ -27,6 +27,8 @@ const std::map gamesdb_platformid_map = boost::assign:: (XBOX, "Microsoft Xbox") (XBOX_360, "Microsoft Xbox 360") (NEOGEO, "NeoGeo") + (NEOGEO_POCKET, "Neo Geo Pocket") + (NEOGEO_POCKET_COLOR, "Neo Geo Pocket Color") (NINTENDO_3DS, "Nintendo 3DS") (NINTENDO_64, "Nintendo 64") (NINTENDO_DS, "Nintendo DS")