Skip to content

Commit

Permalink
DolphinWX: Don't use IsElfOrDol outside of ISOFile
Browse files Browse the repository at this point in the history
It's redundant because GetPlatform can do the same thing.
  • Loading branch information
JosJuice committed Sep 6, 2015
1 parent ad97812 commit cb3b1b6
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 27 deletions.
16 changes: 8 additions & 8 deletions Source/Core/DolphinWX/GameListCtrl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -843,44 +843,44 @@ void CGameListCtrl::OnRightClick(wxMouseEvent& event)
if (selected_iso)
{
wxMenu popupMenu;
DiscIO::IVolume::EPlatform platform = selected_iso->GetPlatform();

if (!selected_iso->IsElfOrDol())
if (platform != DiscIO::IVolume::ELF_DOL)
{
popupMenu.Append(IDM_PROPERTIES, _("&Properties"));
popupMenu.Append(IDM_GAME_WIKI, _("&Wiki"));
popupMenu.AppendSeparator();
}
if (selected_iso->GetPlatform() != DiscIO::IVolume::GAMECUBE_DISC && !selected_iso->IsElfOrDol())
if (platform == DiscIO::IVolume::WII_DISC || platform == DiscIO::IVolume::WII_WAD)
{
popupMenu.Append(IDM_OPEN_SAVE_FOLDER, _("Open Wii &save folder"));
popupMenu.Append(IDM_EXPORT_SAVE, _("Export Wii save (Experimental)"));
}
popupMenu.Append(IDM_OPEN_CONTAINING_FOLDER, _("Open &containing folder"));

if (!selected_iso->IsElfOrDol())
if (platform != DiscIO::IVolume::ELF_DOL)
popupMenu.AppendCheckItem(IDM_SET_DEFAULT_ISO, _("Set as &default ISO"));

// First we have to decide a starting value when we append it
if (selected_iso->GetFileName() == SConfig::GetInstance().m_strDefaultISO)
if (platform == SConfig::GetInstance().m_strDefaultISO)
popupMenu.FindItem(IDM_SET_DEFAULT_ISO)->Check();

popupMenu.AppendSeparator();
popupMenu.Append(IDM_DELETE_ISO, _("&Delete File..."));

if (selected_iso->GetPlatform() != DiscIO::IVolume::WII_WAD && !selected_iso->IsElfOrDol())
if (platform == DiscIO::IVolume::GAMECUBE_DISC || platform == DiscIO::IVolume::WII_DISC)
{
if (selected_iso->IsCompressed())
popupMenu.Append(IDM_COMPRESS_ISO, _("Decompress ISO..."));
else if (selected_iso->GetFileName().substr(selected_iso->GetFileName().find_last_of(".")) != ".ciso" &&
selected_iso->GetFileName().substr(selected_iso->GetFileName().find_last_of(".")) != ".wbfs")
popupMenu.Append(IDM_COMPRESS_ISO, _("Compress ISO..."));
}
else if (!selected_iso->IsElfOrDol())
if (platform == DiscIO::IVolume::WII_WAD)
{
popupMenu.Append(IDM_LIST_INSTALL_WAD, _("Install to Wii Menu"));
}
if (selected_iso->GetPlatform() == DiscIO::IVolume::GAMECUBE_DISC ||
selected_iso->GetPlatform() == DiscIO::IVolume::WII_DISC)
if (platform == DiscIO::IVolume::GAMECUBE_DISC || platform == DiscIO::IVolume::WII_DISC)
{
wxMenuItem* changeDiscItem = popupMenu.Append(IDM_LIST_CHANGE_DISC, _("Change &Disc"));
changeDiscItem->Enable(Core::IsRunning());
Expand Down
34 changes: 17 additions & 17 deletions Source/Core/DolphinWX/ISOFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// Licensed under GPLv2+
// Refer to the license.txt file included.

#include <algorithm>
#include <cinttypes>
#include <cstdio>
#include <cstring>
Expand Down Expand Up @@ -193,7 +194,22 @@ void GameListItem::DoState(PointerWrap &p)
p.Do(m_Revision);
}

std::string GameListItem::CreateCacheFilename()
bool GameListItem::IsElfOrDol() const
{
const std::string name = GetName();
const size_t pos = name.rfind('.');

if (pos != std::string::npos)
{
std::string ext = name.substr(pos);
std::transform(ext.begin(), ext.end(), ext.begin(), ::tolower);

return ext == ".elf" || ext == ".dol";
}
return false;
}

std::string GameListItem::CreateCacheFilename() const
{
std::string Filename, LegalPathname, extension;
SplitPath(m_FileName, &LegalPathname, &Filename, &extension);
Expand Down Expand Up @@ -294,19 +310,3 @@ const std::string GameListItem::GetWiiFSPath() const

return ret;
}

bool GameListItem::IsElfOrDol() const
{
const std::string name = GetName();
const size_t pos = name.rfind('.');

if (pos != std::string::npos)
{
std::string ext = name.substr(pos);
std::transform(ext.begin(), ext.end(), ext.begin(), ::tolower);

return ext == ".elf" ||
ext == ".dol";
}
return false;
}
4 changes: 2 additions & 2 deletions Source/Core/DolphinWX/ISOFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ class GameListItem : NonCopyable
u64 GetVolumeSize() const {return m_VolumeSize;}
// 0 is the first disc, 1 is the second disc
u8 GetDiscNumber() const { return m_disc_number; }
bool IsElfOrDol() const;

#if defined(HAVE_WX) && HAVE_WX
const wxBitmap& GetBitmap() const {return m_Bitmap;}
Expand Down Expand Up @@ -82,7 +81,8 @@ class GameListItem : NonCopyable
bool LoadFromCache();
void SaveToCache();

std::string CreateCacheFilename();
bool IsElfOrDol() const;
std::string CreateCacheFilename() const;

void ReadBanner(const DiscIO::IVolume& volume);
};

0 comments on commit cb3b1b6

Please sign in to comment.