Eliminate ini file loading in the paint, sort, and tooltip events.
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@7403 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
parent
668d335181
commit
c990f12932
|
@ -30,7 +30,6 @@
|
|||
#include "Blob.h"
|
||||
#include "Core.h"
|
||||
#include "ISOProperties.h"
|
||||
#include "IniFile.h"
|
||||
#include "FileUtil.h"
|
||||
#include "CDUtils.h"
|
||||
#include "WxUtils.h"
|
||||
|
@ -149,11 +148,7 @@ CGameListCtrl::~CGameListCtrl()
|
|||
if (m_imageListSmall)
|
||||
delete m_imageListSmall;
|
||||
|
||||
while (!m_ISOFiles.empty()) // so lazy
|
||||
{
|
||||
delete m_ISOFiles.back();
|
||||
m_ISOFiles.pop_back();
|
||||
}
|
||||
ClearIsoFiles();
|
||||
}
|
||||
|
||||
void CGameListCtrl::InitBitmaps()
|
||||
|
@ -359,43 +354,39 @@ std::string CGameListCtrl::GetGameNames() const
|
|||
// This draws our icons on top of the gamelist, it's only used on Windows
|
||||
void CGameListCtrl::OnPaintDrawImages(wxPaintEvent& event)
|
||||
{
|
||||
int i = 0, nState = 0;
|
||||
IniFile ini;
|
||||
wxRect itemRect;
|
||||
wxPaintDC dc(this);
|
||||
|
||||
// Calls the default drawing code
|
||||
wxControl::OnPaint(event);
|
||||
|
||||
// Draw the flags, platform icons and emustate icons on top if there's games to show
|
||||
if (m_ISOFiles.size() != 0)
|
||||
{
|
||||
|
||||
// Retrieve the topmost shown item and get drawing offsets
|
||||
long top = GetTopItem();
|
||||
const long
|
||||
top_item = GetTopItem(),
|
||||
bottom_item = std::min(top_item + GetCountPerPage() + 2, (long)GetItemCount());
|
||||
|
||||
int flagOffset = GetColumnWidth(0) + GetColumnWidth(1) +
|
||||
GetColumnWidth(2) + GetColumnWidth(3);
|
||||
int stateOffset = flagOffset + GetColumnWidth(4) + GetColumnWidth(5);
|
||||
|
||||
// Only redraw shown lines
|
||||
for (i = top; i < top + GetCountPerPage() + 2; i++)
|
||||
for (long i = top_item; i != bottom_item; ++i)
|
||||
{
|
||||
wxRect itemRect;
|
||||
if (GetItemRect(i, itemRect))
|
||||
{
|
||||
int itemY = itemRect.GetTop();
|
||||
const int itemY = itemRect.GetTop();
|
||||
const GameListItem& rISOFile = *m_ISOFiles[GetItemData(i)];
|
||||
|
||||
m_imageListSmall->Draw(m_PlatformImageIndex[rISOFile.GetPlatform()],
|
||||
dc, itemRect.GetX()+3, itemY);
|
||||
m_imageListSmall->Draw(m_FlagImageIndex[rISOFile.GetCountry()],
|
||||
dc, flagOffset, itemY);
|
||||
|
||||
ini.Load(File::GetUserPath(D_GAMECONFIG_IDX) + rISOFile.GetUniqueID() + ".ini");
|
||||
ini.Get("EmuState", "EmulationStateId", &nState);
|
||||
m_imageListSmall->Draw(m_EmuStateImageIndex[nState],
|
||||
m_imageListSmall->Draw(m_EmuStateImageIndex[rISOFile.GetEmuState()],
|
||||
dc, stateOffset, itemY);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -494,16 +485,8 @@ void CGameListCtrl::InsertItemInReportView(long _Index)
|
|||
}
|
||||
|
||||
#ifndef _WIN32
|
||||
// Load the INI file for columns that read from it
|
||||
IniFile ini;
|
||||
ini.Load(File::GetUserPath(D_GAMECONFIG_IDX) + rISOFile.GetUniqueID() + ".ini");
|
||||
|
||||
// Emulation status
|
||||
int nState;
|
||||
ini.Get("EmuState", "EmulationStateId", &nState);
|
||||
|
||||
// Emulation state
|
||||
SetItemColumnImage(_Index, COLUMN_EMULATION_STATE, m_EmuStateImageIndex[nState]);
|
||||
SetItemColumnImage(_Index, COLUMN_EMULATION_STATE, m_EmuStateImageIndex[rISOFile.GetEmuState()]);
|
||||
|
||||
// Country
|
||||
SetItemColumnImage(_Index, COLUMN_COUNTRY, m_FlagImageIndex[rISOFile.GetCountry()]);
|
||||
|
@ -543,7 +526,8 @@ void CGameListCtrl::SetBackgroundColor()
|
|||
|
||||
void CGameListCtrl::ScanForISOs()
|
||||
{
|
||||
m_ISOFiles.clear();
|
||||
ClearIsoFiles();
|
||||
|
||||
CFileSearch::XStringVector Directories(SConfig::GetInstance().m_ISOFolder);
|
||||
|
||||
if (SConfig::GetInstance().m_RecursiveISOFolder)
|
||||
|
@ -619,7 +603,7 @@ void CGameListCtrl::ScanForISOs()
|
|||
if (!Cont)
|
||||
break;
|
||||
|
||||
GameListItem* const iso_file = new GameListItem(rFilenames[i]);
|
||||
std::auto_ptr<GameListItem> iso_file(new GameListItem(rFilenames[i]));
|
||||
const GameListItem& ISOFile = *iso_file;
|
||||
|
||||
if (ISOFile.IsValid())
|
||||
|
@ -674,7 +658,7 @@ void CGameListCtrl::ScanForISOs()
|
|||
}
|
||||
|
||||
if (list)
|
||||
m_ISOFiles.push_back(iso_file);
|
||||
m_ISOFiles.push_back(iso_file.release());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -786,25 +770,22 @@ int wxCALLBACK wxListCompare(long item1, long item2, long sortData)
|
|||
if(iso1->GetPlatform() < iso2->GetPlatform())
|
||||
return -1 * t;
|
||||
return 0;
|
||||
|
||||
case CGameListCtrl::COLUMN_EMULATION_STATE:
|
||||
IniFile ini;
|
||||
int nState1 = 0, nState2 = 0;
|
||||
std::string GameIni1 = File::GetUserPath(D_GAMECONFIG_IDX) +
|
||||
iso1->GetUniqueID() + ".ini";
|
||||
std::string GameIni2 = File::GetUserPath(D_GAMECONFIG_IDX) +
|
||||
iso2->GetUniqueID() + ".ini";
|
||||
{
|
||||
const int
|
||||
nState1 = iso1->GetEmuState(),
|
||||
nState2 = iso2->GetEmuState();
|
||||
|
||||
ini.Load(GameIni1.c_str());
|
||||
ini.Get("EmuState", "EmulationStateId", &nState1);
|
||||
ini.Load(GameIni2.c_str());
|
||||
ini.Get("EmuState", "EmulationStateId", &nState2);
|
||||
|
||||
if(nState1 > nState2)
|
||||
if (nState1 > nState2)
|
||||
return 1 * t;
|
||||
if(nState1 < nState2)
|
||||
if (nState1 < nState2)
|
||||
return -1 * t;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -891,7 +872,7 @@ void CGameListCtrl::OnMouseMotion(wxMouseEvent& event)
|
|||
{
|
||||
int flags;
|
||||
long subitem = 0;
|
||||
long item = HitTest(event.GetPosition(), flags, &subitem);
|
||||
const long item = HitTest(event.GetPosition(), flags, &subitem);
|
||||
static int lastItem = -1;
|
||||
|
||||
if (GetColumnCount() <= 1)
|
||||
|
@ -917,30 +898,19 @@ void CGameListCtrl::OnMouseMotion(wxMouseEvent& event)
|
|||
return;
|
||||
}
|
||||
|
||||
// Emulation status
|
||||
static const char* const emuState[] = { "Broken", "Intro", "In-Game", "Playable", "Perfect" };
|
||||
|
||||
const GameListItem& rISO = *m_ISOFiles[GetItemData(item)];
|
||||
|
||||
IniFile ini;
|
||||
ini.Load(File::GetUserPath(D_GAMECONFIG_IDX) + rISO.GetUniqueID() + ".ini");
|
||||
|
||||
// Emulation status
|
||||
std::string emuState[5] = {
|
||||
"Broken",
|
||||
"Intro",
|
||||
"In-Game",
|
||||
"Playable",
|
||||
"Perfect"
|
||||
};
|
||||
std::string issues;
|
||||
|
||||
int nState;
|
||||
ini.Get("EmuState", "EmulationStateId", &nState);
|
||||
ini.Get("EmuState", "EmulationIssues", &issues, "");
|
||||
const int emu_state = rISO.GetEmuState();
|
||||
const std::string& issues = rISO.GetIssues();
|
||||
|
||||
// Show a tooltip containing the EmuState and the state description
|
||||
if (nState > 0 && nState < 6)
|
||||
if (emu_state > 0 && emu_state < 6)
|
||||
{
|
||||
char temp[2048];
|
||||
sprintf(temp, "^ %s%s%s", emuState[nState -1].c_str(),
|
||||
sprintf(temp, "^ %s%s%s", emuState[emu_state - 1],
|
||||
issues.size() > 0 ? " :\n" : "", issues.c_str());
|
||||
toolTip = new wxEmuStateTip(this, wxString(temp, *wxConvCurrent), &toolTip);
|
||||
}
|
||||
|
@ -1062,7 +1032,7 @@ const GameListItem * CGameListCtrl::GetSelectedISO()
|
|||
{
|
||||
long item = GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
|
||||
if (item == wxNOT_FOUND)
|
||||
return new GameListItem("");
|
||||
return new GameListItem(""); // TODO: wtf is this
|
||||
else
|
||||
{
|
||||
// Here is a little workaround for multiselections:
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
#ifndef __GAMELIST_CTRL_H_
|
||||
#define __GAMELIST_CTRL_H_
|
||||
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
#include <wx/listctrl.h>
|
||||
|
@ -73,6 +74,15 @@ private:
|
|||
std::vector<int> m_EmuStateImageIndex;
|
||||
std::vector<GameListItem*> m_ISOFiles;
|
||||
|
||||
void ClearIsoFiles()
|
||||
{
|
||||
while (!m_ISOFiles.empty()) // so lazy
|
||||
{
|
||||
delete m_ISOFiles.back();
|
||||
m_ISOFiles.pop_back();
|
||||
}
|
||||
}
|
||||
|
||||
// NetPlay string for the gamelist
|
||||
std::string m_gameList;
|
||||
std::string m_gamePath;
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
#include "ISOFile.h"
|
||||
#include "StringUtil.h"
|
||||
#include "Hash.h"
|
||||
#include "IniFile.h"
|
||||
|
||||
#include "Filesystem.h"
|
||||
#include "BannerLoader.h"
|
||||
|
@ -47,6 +48,7 @@ GameListItem::GameListItem(const std::string& _rFileName)
|
|||
, m_FileSize(0)
|
||||
, m_Valid(false)
|
||||
, m_BlobCompressed(false)
|
||||
, m_emu_state(0)
|
||||
{
|
||||
if (LoadFromCache())
|
||||
{
|
||||
|
@ -126,6 +128,14 @@ GameListItem::GameListItem(const std::string& _rFileName)
|
|||
}
|
||||
}
|
||||
|
||||
if (IsValid())
|
||||
{
|
||||
IniFile ini;
|
||||
ini.Load(File::GetUserPath(D_GAMECONFIG_IDX) + m_UniqueID + ".ini");
|
||||
ini.Get("EmuState", "EmulationStateId", &m_emu_state);
|
||||
ini.Get("EmuState", "EmulationIssues", &m_issues);
|
||||
}
|
||||
|
||||
if (!m_pImage.empty())
|
||||
{
|
||||
m_Image.Create(DVD_BANNER_WIDTH, DVD_BANNER_HEIGHT, &m_pImage[0], true);
|
||||
|
|
|
@ -41,7 +41,8 @@ public:
|
|||
const std::string GetWiiFSPath() const;
|
||||
DiscIO::IVolume::ECountry GetCountry() const {return m_Country;}
|
||||
int GetPlatform() const {return m_Platform;}
|
||||
const std::string& GetIssues() const {return m_Issues;}
|
||||
const std::string& GetIssues() const { return m_issues; }
|
||||
int GetEmuState() const { return m_emu_state; }
|
||||
bool IsCompressed() const {return m_BlobCompressed;}
|
||||
u64 GetFileSize() const {return m_FileSize;}
|
||||
u64 GetVolumeSize() const {return m_VolumeSize;}
|
||||
|
@ -65,7 +66,9 @@ private:
|
|||
std::string m_Company;
|
||||
std::string m_Description[6];
|
||||
std::string m_UniqueID;
|
||||
std::string m_Issues;
|
||||
|
||||
std::string m_issues;
|
||||
int m_emu_state;
|
||||
|
||||
u64 m_FileSize;
|
||||
u64 m_VolumeSize;
|
||||
|
|
Loading…
Reference in New Issue