DiscIO: Don't use all uppercase for enum values

Also removing some prefixes that we don't need now that we're
using enum classes instead of plain enums.
This commit is contained in:
JosJuice
2018-03-31 14:04:13 +02:00
parent c3398c9e2c
commit 4387432436
22 changed files with 254 additions and 267 deletions

View File

@ -153,7 +153,7 @@ void ExportDirectory(const Volume& volume, const Partition& partition, const Fil
bool ExportWiiUnencryptedHeader(const Volume& volume, const std::string& export_filename)
{
if (volume.GetVolumeType() != Platform::WII_DISC)
if (volume.GetVolumeType() != Platform::WiiDisc)
return false;
return ExportData(volume, PARTITION_NONE, 0, 0x100, export_filename);
@ -161,7 +161,7 @@ bool ExportWiiUnencryptedHeader(const Volume& volume, const std::string& export_
bool ExportWiiRegionData(const Volume& volume, const std::string& export_filename)
{
if (volume.GetVolumeType() != Platform::WII_DISC)
if (volume.GetVolumeType() != Platform::WiiDisc)
return false;
return ExportData(volume, PARTITION_NONE, 0x4E000, 0x20, export_filename);
@ -170,7 +170,7 @@ bool ExportWiiRegionData(const Volume& volume, const std::string& export_filenam
bool ExportTicket(const Volume& volume, const Partition& partition,
const std::string& export_filename)
{
if (volume.GetVolumeType() != Platform::WII_DISC)
if (volume.GetVolumeType() != Platform::WiiDisc)
return false;
return ExportData(volume, PARTITION_NONE, partition.offset, 0x2a4, export_filename);
@ -178,7 +178,7 @@ bool ExportTicket(const Volume& volume, const Partition& partition,
bool ExportTMD(const Volume& volume, const Partition& partition, const std::string& export_filename)
{
if (volume.GetVolumeType() != Platform::WII_DISC)
if (volume.GetVolumeType() != Platform::WiiDisc)
return false;
const std::optional<u32> size = volume.ReadSwapped<u32>(partition.offset + 0x2a4, PARTITION_NONE);
@ -193,7 +193,7 @@ bool ExportTMD(const Volume& volume, const Partition& partition, const std::stri
bool ExportCertificateChain(const Volume& volume, const Partition& partition,
const std::string& export_filename)
{
if (volume.GetVolumeType() != Platform::WII_DISC)
if (volume.GetVolumeType() != Platform::WiiDisc)
return false;
const std::optional<u32> size = volume.ReadSwapped<u32>(partition.offset + 0x2ac, PARTITION_NONE);
@ -208,7 +208,7 @@ bool ExportCertificateChain(const Volume& volume, const Partition& partition,
bool ExportH3Hashes(const Volume& volume, const Partition& partition,
const std::string& export_filename)
{
if (volume.GetVolumeType() != Platform::WII_DISC)
if (volume.GetVolumeType() != Platform::WiiDisc)
return false;
const std::optional<u64> offset =
@ -351,7 +351,7 @@ bool ExportSystemData(const Volume& volume, const Partition& partition,
success &= ExportDOL(volume, partition, export_folder + "/sys/main.dol");
success &= ExportFST(volume, partition, export_folder + "/sys/fst.bin");
if (volume.GetVolumeType() == Platform::WII_DISC)
if (volume.GetVolumeType() == Platform::WiiDisc)
{
File::CreateFullPath(export_folder + "/disc/");
success &= ExportWiiUnencryptedHeader(volume, export_folder + "/disc/header.bin");

View File

@ -20,43 +20,43 @@ std::string GetName(Country country, bool translate)
switch (country)
{
case Country::COUNTRY_EUROPE:
case Country::Europe:
name = _trans("Europe");
break;
case Country::COUNTRY_JAPAN:
case Country::Japan:
name = _trans("Japan");
break;
case Country::COUNTRY_USA:
case Country::USA:
name = _trans("USA");
break;
case Country::COUNTRY_AUSTRALIA:
case Country::Australia:
name = _trans("Australia");
break;
case Country::COUNTRY_FRANCE:
case Country::France:
name = _trans("France");
break;
case Country::COUNTRY_GERMANY:
case Country::Germany:
name = _trans("Germany");
break;
case Country::COUNTRY_ITALY:
case Country::Italy:
name = _trans("Italy");
break;
case Country::COUNTRY_KOREA:
case Country::Korea:
name = _trans("Korea");
break;
case Country::COUNTRY_NETHERLANDS:
case Country::Netherlands:
name = _trans("Netherlands");
break;
case Country::COUNTRY_RUSSIA:
case Country::Russia:
name = _trans("Russia");
break;
case Country::COUNTRY_SPAIN:
case Country::Spain:
name = _trans("Spain");
break;
case Country::COUNTRY_TAIWAN:
case Country::Taiwan:
name = _trans("Taiwan");
break;
case Country::COUNTRY_WORLD:
case Country::World:
name = _trans("World");
break;
default:
@ -73,34 +73,34 @@ std::string GetName(Language language, bool translate)
switch (language)
{
case Language::LANGUAGE_JAPANESE:
case Language::Japanese:
name = _trans("Japanese");
break;
case Language::LANGUAGE_ENGLISH:
case Language::English:
name = _trans("English");
break;
case Language::LANGUAGE_GERMAN:
case Language::German:
name = _trans("German");
break;
case Language::LANGUAGE_FRENCH:
case Language::French:
name = _trans("French");
break;
case Language::LANGUAGE_SPANISH:
case Language::Spanish:
name = _trans("Spanish");
break;
case Language::LANGUAGE_ITALIAN:
case Language::Italian:
name = _trans("Italian");
break;
case Language::LANGUAGE_DUTCH:
case Language::Dutch:
name = _trans("Dutch");
break;
case Language::LANGUAGE_SIMPLIFIED_CHINESE:
case Language::SimplifiedChinese:
name = _trans("Simplified Chinese");
break;
case Language::LANGUAGE_TRADITIONAL_CHINESE:
case Language::TraditionalChinese:
name = _trans("Traditional Chinese");
break;
case Language::LANGUAGE_KOREAN:
case Language::Korean:
name = _trans("Korean");
break;
default:
@ -113,12 +113,12 @@ std::string GetName(Language language, bool translate)
bool IsDisc(Platform volume_type)
{
return volume_type == Platform::GAMECUBE_DISC || volume_type == Platform::WII_DISC;
return volume_type == Platform::GameCubeDisc || volume_type == Platform::WiiDisc;
}
bool IsWii(Platform volume_type)
{
return volume_type == Platform::WII_DISC || volume_type == Platform::WII_WAD;
return volume_type == Platform::WiiDisc || volume_type == Platform::WiiWAD;
}
bool IsNTSC(Region region)
@ -133,15 +133,15 @@ Country TypicalCountryForRegion(Region region)
switch (region)
{
case Region::NTSC_J:
return Country::COUNTRY_JAPAN;
return Country::Japan;
case Region::NTSC_U:
return Country::COUNTRY_USA;
return Country::USA;
case Region::PAL:
return Country::COUNTRY_EUROPE;
return Country::Europe;
case Region::NTSC_K:
return Country::COUNTRY_KOREA;
return Country::Korea;
default:
return Country::COUNTRY_UNKNOWN;
return Country::Unknown;
}
}
@ -185,7 +185,7 @@ Region RegionSwitchWii(u8 country_code)
return Region::NTSC_K;
default:
return Region::UNKNOWN_REGION;
return Region::Unknown;
}
}
@ -195,66 +195,66 @@ Country CountrySwitch(u8 country_code)
{
// Worldwide
case 'A':
return Country::COUNTRY_WORLD;
return Country::World;
// PAL
case 'D':
return Country::COUNTRY_GERMANY;
return Country::Germany;
case 'X': // Used by a couple PAL games
case 'Y': // German, French
case 'L': // Japanese import to PAL regions
case 'M': // Japanese import to PAL regions
case 'P':
return Country::COUNTRY_EUROPE;
return Country::Europe;
case 'U':
return Country::COUNTRY_AUSTRALIA;
return Country::Australia;
case 'F':
return Country::COUNTRY_FRANCE;
return Country::France;
case 'I':
return Country::COUNTRY_ITALY;
return Country::Italy;
case 'H':
return Country::COUNTRY_NETHERLANDS;
return Country::Netherlands;
case 'R':
return Country::COUNTRY_RUSSIA;
return Country::Russia;
case 'S':
return Country::COUNTRY_SPAIN;
return Country::Spain;
// NTSC
case 'E':
case 'N': // Japanese import to USA and other NTSC regions
case 'Z': // Prince of Persia - The Forgotten Sands (Wii)
case 'B': // Ufouria: The Saga (Virtual Console)
return Country::COUNTRY_USA;
return Country::USA;
case 'J':
return Country::COUNTRY_JAPAN;
return Country::Japan;
case 'K':
case 'Q': // Korea with Japanese language
case 'T': // Korea with English language
return Country::COUNTRY_KOREA;
return Country::Korea;
case 'W':
return Country::COUNTRY_TAIWAN;
return Country::Taiwan;
default:
if (country_code > 'A') // Silently ignore IOS wads
WARN_LOG(DISCIO, "Unknown Country Code! %c", country_code);
return Country::COUNTRY_UNKNOWN;
return Country::Unknown;
}
}
Region GetSysMenuRegion(u16 title_version)
{
if (title_version == 33)
return Region::UNKNOWN_REGION; // 1.0 uses 33 as the version number in all regions
return Region::Unknown; // 1.0 uses 33 as the version number in all regions
switch (title_version & 0xf)
{
@ -267,7 +267,7 @@ Region GetSysMenuRegion(u16 title_version)
case 6:
return Region::NTSC_K;
default:
return Region::UNKNOWN_REGION;
return Region::Unknown;
}
}
@ -292,7 +292,7 @@ std::string GetSysMenuVersionString(u16 title_version)
case Region::NTSC_K:
region_letter = "K";
break;
case Region::UNKNOWN_REGION:
case Region::Unknown:
WARN_LOG(DISCIO, "Unknown region for Wii Menu version %u", title_version);
break;
}

View File

@ -14,40 +14,40 @@ namespace DiscIO
enum class Platform
{
GAMECUBE_DISC = 0,
WII_DISC,
WII_WAD,
ELF_DOL,
NUMBER_OF_PLATFORMS
GameCubeDisc = 0,
WiiDisc,
WiiWAD,
ELFOrDOL,
NumberOfPlatforms
};
enum class Country
{
COUNTRY_EUROPE = 0,
COUNTRY_JAPAN,
COUNTRY_USA,
COUNTRY_AUSTRALIA,
COUNTRY_FRANCE,
COUNTRY_GERMANY,
COUNTRY_ITALY,
COUNTRY_KOREA,
COUNTRY_NETHERLANDS,
COUNTRY_RUSSIA,
COUNTRY_SPAIN,
COUNTRY_TAIWAN,
COUNTRY_WORLD,
COUNTRY_UNKNOWN,
NUMBER_OF_COUNTRIES
Europe = 0,
Japan,
USA,
Australia,
France,
Germany,
Italy,
Korea,
Netherlands,
Russia,
Spain,
Taiwan,
World,
Unknown,
NumberOfCountries
};
// Regions 0 - 2 and 4 match Nintendo's GameCube/Wii region numbering.
enum class Region
{
NTSC_J = 0, // Japan and Taiwan (and South Korea for GameCube only)
NTSC_U = 1, // Mainly North America
PAL = 2, // Mainly Europe and Oceania
UNKNOWN_REGION = 3, // 3 seems to be unused? Anyway, we need an UNKNOWN_REGION. Let's put it here
NTSC_K = 4 // South Korea (Wii only)
NTSC_J = 0, // Japan and Taiwan (and South Korea for GameCube only)
NTSC_U = 1, // Mainly North America
PAL = 2, // Mainly Europe and Oceania
Unknown = 3, // 3 seems to be unused? Anyway, we need an Unknown entry. Let's put it here
NTSC_K = 4 // South Korea (Wii only)
};
// Languages 0 - 9 match Nintendo's Wii language numbering.
@ -55,17 +55,17 @@ enum class Region
// NTSC GameCubes only support one language and thus don't number languages.
enum class Language
{
LANGUAGE_JAPANESE = 0,
LANGUAGE_ENGLISH = 1,
LANGUAGE_GERMAN = 2,
LANGUAGE_FRENCH = 3,
LANGUAGE_SPANISH = 4,
LANGUAGE_ITALIAN = 5,
LANGUAGE_DUTCH = 6,
LANGUAGE_SIMPLIFIED_CHINESE = 7,
LANGUAGE_TRADITIONAL_CHINESE = 8,
LANGUAGE_KOREAN = 9,
LANGUAGE_UNKNOWN
Japanese = 0,
English = 1,
German = 2,
French = 3,
Spanish = 4,
Italian = 5,
Dutch = 6,
SimplifiedChinese = 7,
TraditionalChinese = 8,
Korean = 9,
Unknown
};
std::string GetName(Country country, bool translate);

View File

@ -76,14 +76,14 @@ Region VolumeGC::GetRegion() const
{
const std::optional<u32> region_code = ReadSwapped<u32>(0x458, PARTITION_NONE);
if (!region_code)
return Region::UNKNOWN_REGION;
return Region::Unknown;
const Region region = static_cast<Region>(*region_code);
return region <= Region::PAL ? region : Region::UNKNOWN_REGION;
return region <= Region::PAL ? region : Region::Unknown;
}
Country VolumeGC::GetCountry(const Partition& partition) const
{
// The 0 that we use as a default value is mapped to COUNTRY_UNKNOWN and UNKNOWN_REGION
// The 0 that we use as a default value is mapped to Country::Unknown and Region::Unknown
const u8 country = ReadSwapped<u8>(3, partition).value_or(0);
const Region region = GetRegion();
@ -93,7 +93,7 @@ Country VolumeGC::GetCountry(const Partition& partition) const
// W means Taiwan for Wii games, but on the GC, it's used for English-language Korean releases.
// (There doesn't seem to be any pattern to which of E and W is used for Korean GC releases.)
if (region == Region::NTSC_J && (country == 'E' || country == 'K' || country == 'W'))
return Country::COUNTRY_KOREA;
return Country::Korea;
if (RegionSwitchGC(country) != region)
return TypicalCountryForRegion(region);
@ -188,7 +188,7 @@ std::optional<u8> VolumeGC::GetDiscNumber(const Partition& partition) const
Platform VolumeGC::GetVolumeType() const
{
return Platform::GAMECUBE_DISC;
return Platform::GameCubeDisc;
}
VolumeGC::ConvertedGCBanner VolumeGC::LoadBannerFile() const
@ -228,18 +228,17 @@ VolumeGC::ConvertedGCBanner VolumeGC::ExtractBannerInformation(const GCBanner& b
ConvertedGCBanner banner;
u32 number_of_languages = 0;
Language start_language = Language::LANGUAGE_UNKNOWN;
Language start_language = Language::Unknown;
if (is_bnr1) // NTSC
{
bool is_japanese = GetRegion() == Region::NTSC_J;
number_of_languages = 1;
start_language = is_japanese ? Language::LANGUAGE_JAPANESE : Language::LANGUAGE_ENGLISH;
start_language = GetRegion() == Region::NTSC_J ? Language::Japanese : Language::English;
}
else // PAL
{
number_of_languages = 6;
start_language = Language::LANGUAGE_ENGLISH;
start_language = Language::English;
}
banner.image_width = GC_BANNER_WIDTH;

View File

@ -75,14 +75,14 @@ const FileSystem* VolumeWAD::GetFileSystem(const Partition& partition) const
Region VolumeWAD::GetRegion() const
{
if (!m_tmd.IsValid())
return Region::UNKNOWN_REGION;
return Region::Unknown;
return m_tmd.GetRegion();
}
Country VolumeWAD::GetCountry(const Partition& partition) const
{
if (!m_tmd.IsValid())
return Country::COUNTRY_UNKNOWN;
return Country::Unknown;
u8 country_code = static_cast<u8>(m_tmd.GetTitleId() & 0xff);
if (country_code == 2) // SYSMENU
@ -130,7 +130,7 @@ std::optional<u16> VolumeWAD::GetRevision(const Partition& partition) const
Platform VolumeWAD::GetVolumeType() const
{
return Platform::WII_WAD;
return Platform::WiiWAD;
}
std::map<Language, std::string> VolumeWAD::GetLongNames() const

View File

@ -48,7 +48,7 @@ public:
return "";
}
Platform GetVolumeType() const override;
// Provides a best guess for the region. Might be inaccurate or UNKNOWN_REGION.
// Provides a best guess for the region. Might be inaccurate or Region::Unknown.
Region GetRegion() const override;
Country GetCountry(const Partition& partition = PARTITION_NONE) const override;

View File

@ -258,14 +258,14 @@ Region VolumeWii::GetRegion() const
{
const std::optional<u32> region_code = m_pReader->ReadSwapped<u32>(0x4E000);
if (!region_code)
return Region::UNKNOWN_REGION;
return Region::Unknown;
const Region region = static_cast<Region>(*region_code);
return region <= Region::NTSC_K ? region : Region::UNKNOWN_REGION;
return region <= Region::NTSC_K ? region : Region::Unknown;
}
Country VolumeWii::GetCountry(const Partition& partition) const
{
// The 0 that we use as a default value is mapped to COUNTRY_UNKNOWN and UNKNOWN_REGION
// The 0 that we use as a default value is mapped to Country::Unknown and Region::Unknown
u8 country_byte = ReadSwapped<u8>(3, partition).value_or(0);
const Region region = GetRegion();
@ -332,7 +332,7 @@ std::string VolumeWii::GetApploaderDate(const Partition& partition) const
Platform VolumeWii::GetVolumeType() const
{
return Platform::WII_DISC;
return Platform::WiiDisc;
}
std::optional<u8> VolumeWii::GetDiscNumber(const Partition& partition) const