DiscIO: Add convenience methods IsDisc and IsWii for Platform enum

This commit is contained in:
JosJuice 2017-06-17 12:26:32 +02:00
parent e14a82a87e
commit 23bb029250
5 changed files with 19 additions and 7 deletions

View File

@ -11,6 +11,16 @@
namespace DiscIO
{
bool IsDisc(Platform volume_type)
{
return volume_type == Platform::GAMECUBE_DISC || volume_type == Platform::WII_DISC;
}
bool IsWii(Platform volume_type)
{
return volume_type == Platform::WII_DISC || volume_type == Platform::WII_WAD;
}
bool IsNTSC(Region region)
{
return region == Region::NTSC_J || region == Region::NTSC_U || region == Region::NTSC_K;

View File

@ -68,6 +68,8 @@ enum class Language
LANGUAGE_UNKNOWN
};
bool IsDisc(Platform volume_type);
bool IsWii(Platform volume_type);
bool IsNTSC(Region region);
Country TypicalCountryForRegion(Region region);
Region RegionSwitchGC(u8 country_code);

View File

@ -259,7 +259,7 @@ bool GameListItem::BannerChanged()
if (!m_volume_banner.empty())
return false;
if (m_platform != DiscIO::Platform::WII_DISC && m_platform != DiscIO::Platform::WII_WAD)
if (!DiscIO::IsWii(m_platform))
return false;
auto& banner = m_pending.volume_banner;
@ -286,7 +286,7 @@ std::string GameListItem::GetDescription(DiscIO::Language language) const
std::string GameListItem::GetDescription() const
{
bool wii = m_platform != DiscIO::Platform::GAMECUBE_DISC;
const bool wii = DiscIO::IsWii(m_platform);
return GetDescription(SConfig::GetInstance().GetCurrentLanguage(wii));
}
@ -300,7 +300,7 @@ std::string GameListItem::GetName() const
if (!m_custom_name.empty())
return m_custom_name;
bool wii = m_platform != DiscIO::Platform::GAMECUBE_DISC;
const bool wii = DiscIO::IsWii(m_platform);
std::string name = GetName(SConfig::GetInstance().GetCurrentLanguage(wii));
if (!name.empty())
return name;
@ -356,7 +356,7 @@ std::vector<DiscIO::Language> GameListItem::GetLanguages() const
const std::string GameListItem::GetWiiFSPath() const
{
if (m_platform != DiscIO::Platform::WII_DISC && m_platform != DiscIO::Platform::WII_WAD)
if (!DiscIO::IsWii(m_platform))
return "";
const std::string path = Common::GetTitleDataPath(m_title_id, Common::FROM_CONFIGURED_ROOT);

View File

@ -430,7 +430,7 @@ void CISOProperties::CreateGUIControls()
gecko_layout->Add(m_geckocode_panel, 1, wxEXPAND);
gecko_cheat_page->SetSizer(gecko_layout);
if (m_open_iso->GetVolumeType() != DiscIO::Platform::WII_WAD)
if (DiscIO::IsDisc(m_open_iso->GetVolumeType()))
{
m_Notebook->AddPage(new FilesystemPanel(m_Notebook, ID_FILESYSTEM, m_open_iso),
_("Filesystem"));

View File

@ -198,7 +198,7 @@ void InfoPanel::LoadBannerDetails()
{
LoadBannerImage();
const bool is_wii = m_opened_iso->GetVolumeType() != DiscIO::Platform::GAMECUBE_DISC;
const bool is_wii = DiscIO::IsWii(m_opened_iso->GetVolumeType());
ChangeBannerDetails(SConfig::GetInstance().GetCurrentLanguage(is_wii));
}
@ -311,7 +311,7 @@ wxStaticBoxSizer* InfoPanel::CreateBannerDetailsSizer()
wxChoice* InfoPanel::CreateCommentLanguageChoice()
{
const auto languages = m_game_list_item.GetLanguages();
const bool is_wii = m_opened_iso->GetVolumeType() != DiscIO::Platform::GAMECUBE_DISC;
const bool is_wii = DiscIO::IsWii(m_opened_iso->GetVolumeType());
const auto preferred_language = SConfig::GetInstance().GetCurrentLanguage(is_wii);
const int preferred_language_index = FindPreferredLanguageIndex(preferred_language, languages);
const auto choices = GetLanguageChoiceStrings(languages);