Use GetClientRect in the GameListCtrl OnSize function, but removed the +5 padding. This seems to look best on windows and linux. Unfortunately wxWidgets on linux doesn't account for visibility of the vertical scrollbar in this or any calculation I have found.

Also fixed an issue with the saving of the log/console window size.


git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@6013 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
Glenn Rice 2010-07-31 14:14:01 +00:00
parent c88689381f
commit 840bd3613f
4 changed files with 358 additions and 260 deletions

View File

@ -597,7 +597,7 @@ void CFrame::OnDropDownToolbarSelect(wxCommandEvent& event)
Tmp.Name = dlg.GetValue().mb_str(); Tmp.Name = dlg.GetValue().mb_str();
Tmp.Perspective = m_Mgr->SavePerspective(); Tmp.Perspective = m_Mgr->SavePerspective();
ActivePerspective = Perspectives.size(); ActivePerspective = (u32)Perspectives.size();
Perspectives.push_back(Tmp); Perspectives.push_back(Tmp);
UpdateCurrentPerspective(); UpdateCurrentPerspective();

View File

@ -60,32 +60,50 @@ bool operator < (const GameListItem &one, const GameListItem &other)
switch (one.GetCountry()) switch (one.GetCountry())
{ {
case DiscIO::IVolume::COUNTRY_JAPAN:; case DiscIO::IVolume::COUNTRY_JAPAN:
case DiscIO::IVolume::COUNTRY_USA:indexOne = 0; break; case DiscIO::IVolume::COUNTRY_USA:
default: indexOne = (int)SConfig::GetInstance().m_InterfaceLanguage; indexOne = 0;
break;
default:
indexOne = SConfig::GetInstance().m_InterfaceLanguage;
} }
switch (other.GetCountry()) switch (other.GetCountry())
{ {
case DiscIO::IVolume::COUNTRY_JAPAN:; case DiscIO::IVolume::COUNTRY_JAPAN:
case DiscIO::IVolume::COUNTRY_USA:indexOther = 0; break; case DiscIO::IVolume::COUNTRY_USA:
default: indexOther = (int)SConfig::GetInstance().m_InterfaceLanguage; indexOther = 0;
break;
default:
indexOther = SConfig::GetInstance().m_InterfaceLanguage;
} }
switch(currentColumn) switch(currentColumn)
{ {
case CGameListCtrl::COLUMN_TITLE: return strcasecmp(one.GetName(indexOne).c_str(), other.GetName(indexOther).c_str()) < 0; case CGameListCtrl::COLUMN_TITLE:
return strcasecmp(one.GetName(indexOne).c_str(),
other.GetName(indexOther).c_str()) < 0;
case CGameListCtrl::COLUMN_NOTES: case CGameListCtrl::COLUMN_NOTES:
{ {
// On Gamecube we show the company string, while it's empty on other platforms, so we show the description instead // On Gamecube we show the company string, while it's empty on
std::string cmp1 = (one.GetPlatform() == GameListItem::GAMECUBE_DISC) ? one.GetCompany() : one.GetDescription(indexOne); // other platforms, so we show the description instead
std::string cmp2 = (other.GetPlatform() == GameListItem::GAMECUBE_DISC) ? other.GetCompany() : other.GetDescription(indexOther); std::string cmp1 =
(one.GetPlatform() == GameListItem::GAMECUBE_DISC) ?
one.GetCompany() : one.GetDescription(indexOne);
std::string cmp2 =
(other.GetPlatform() == GameListItem::GAMECUBE_DISC) ?
other.GetCompany() : other.GetDescription(indexOther);
return strcasecmp(cmp1.c_str(), cmp2.c_str()) < 0; return strcasecmp(cmp1.c_str(), cmp2.c_str()) < 0;
} }
case CGameListCtrl::COLUMN_COUNTRY: return (one.GetCountry() < other.GetCountry()); case CGameListCtrl::COLUMN_COUNTRY:
case CGameListCtrl::COLUMN_SIZE: return (one.GetFileSize() < other.GetFileSize()); return (one.GetCountry() < other.GetCountry());
case CGameListCtrl::COLUMN_PLATFORM: return (one.GetPlatform() < other.GetPlatform()); case CGameListCtrl::COLUMN_SIZE:
default: return strcasecmp(one.GetName(indexOne).c_str(), other.GetName(indexOther).c_str()) < 0; return (one.GetFileSize() < other.GetFileSize());
case CGameListCtrl::COLUMN_PLATFORM:
return (one.GetPlatform() < other.GetPlatform());
default:
return strcasecmp(one.GetName(indexOne).c_str(),
other.GetName(indexOther).c_str()) < 0;
} }
} }
@ -118,7 +136,8 @@ BEGIN_EVENT_TABLE(CGameListCtrl, wxListCtrl)
END_EVENT_TABLE() END_EVENT_TABLE()
CGameListCtrl::CGameListCtrl(wxWindow* parent, const wxWindowID id, const wxPoint& pos, const wxSize& size, long style) CGameListCtrl::CGameListCtrl(wxWindow* parent, const wxWindowID id, const
wxPoint& pos, const wxSize& size, long style)
: wxListCtrl(parent, id, pos, size, style), toolTip(0) : wxListCtrl(parent, id, pos, size, style), toolTip(0)
{ {
} }
@ -183,14 +202,15 @@ void CGameListCtrl::BrowseForDirectory()
wxGetHomeDir(&dirHome); wxGetHomeDir(&dirHome);
// browse // browse
wxDirDialog dialog(this, _("Browse for a directory to add"), dirHome, wxDD_DEFAULT_STYLE | wxDD_DIR_MUST_EXIST); wxDirDialog dialog(this, _("Browse for a directory to add"), dirHome,
wxDD_DEFAULT_STYLE | wxDD_DIR_MUST_EXIST);
if (dialog.ShowModal() == wxID_OK) if (dialog.ShowModal() == wxID_OK)
{ {
std::string sPath(dialog.GetPath().mb_str()); std::string sPath(dialog.GetPath().mb_str());
std::vector<std::string>::iterator itResult = std::find( std::vector<std::string>::iterator itResult = std::find(
SConfig::GetInstance().m_ISOFolder.begin(), SConfig::GetInstance().m_ISOFolder.end(), sPath SConfig::GetInstance().m_ISOFolder.begin(),
); SConfig::GetInstance().m_ISOFolder.end(), sPath);
if (itResult == SConfig::GetInstance().m_ISOFolder.end()) if (itResult == SConfig::GetInstance().m_ISOFolder.end())
{ {
@ -234,8 +254,9 @@ void CGameListCtrl::Update()
InsertColumn(COLUMN_BANNER, _("Banner")); InsertColumn(COLUMN_BANNER, _("Banner"));
InsertColumn(COLUMN_TITLE, _("Title")); InsertColumn(COLUMN_TITLE, _("Title"));
// Instead of showing the notes + the company, which is unknown with wii titles // Instead of showing the notes + the company, which is unknown with
// We show in the same column : company for GC games and description for wii/wad games // wii titles We show in the same column : company for GC games and
// description for wii/wad games
InsertColumn(COLUMN_NOTES, _("Notes")); InsertColumn(COLUMN_NOTES, _("Notes"));
InsertColumn(COLUMN_COUNTRY, _("")); InsertColumn(COLUMN_COUNTRY, _(""));
InsertColumn(COLUMN_SIZE, _("Size")); InsertColumn(COLUMN_SIZE, _("Size"));
@ -268,8 +289,9 @@ void CGameListCtrl::Update()
else else
{ {
wxString errorString; wxString errorString;
// We just check for one hide setting to be enabled, as we may only have GC games // We just check for one hide setting to be enabled, as we may only
// for example, and hide them, so we should show the second message instead // have GC games for example, and hide them, so we should show the
// second message instead
if ((SConfig::GetInstance().m_ListGC && if ((SConfig::GetInstance().m_ListGC &&
SConfig::GetInstance().m_ListWii && SConfig::GetInstance().m_ListWii &&
SConfig::GetInstance().m_ListWad) && SConfig::GetInstance().m_ListWad) &&
@ -277,11 +299,13 @@ void CGameListCtrl::Update()
SConfig::GetInstance().m_ListUsa && SConfig::GetInstance().m_ListUsa &&
SConfig::GetInstance().m_ListPal)) SConfig::GetInstance().m_ListPal))
{ {
errorString = _("Dolphin could not find any GC/Wii ISOs. Doubleclick here to browse for files..."); errorString = wxT("Dolphin could not find any GC/Wii ISOs. ")
wxT("Doubleclick here to browse for files...");
} }
else else
{ {
errorString = _("Dolphin is currently set to hide all games. Doubleclick here to show all games..."); errorString = wxT("Dolphin is currently set to hide all games. ")
wxT("Doubleclick here to show all games...");
} }
InsertColumn(0, _("No ISOs or WADS found")); InsertColumn(0, _("No ISOs or WADS found"));
long index = InsertItem(0, errorString); long index = InsertItem(0, errorString);
@ -342,7 +366,8 @@ void CGameListCtrl::OnPaintDrawImages(wxPaintEvent& event)
{ {
// Retrieve the topmost shown item and get drawing offsets // Retrieve the topmost shown item and get drawing offsets
long top = GetTopItem(); long top = GetTopItem();
int flagOffset = GetColumnWidth(0) + GetColumnWidth(1) + GetColumnWidth(2) + GetColumnWidth(3); int flagOffset = GetColumnWidth(0) + GetColumnWidth(1) +
GetColumnWidth(2) + GetColumnWidth(3);
int stateOffset = flagOffset + GetColumnWidth(4) + GetColumnWidth(5); int stateOffset = flagOffset + GetColumnWidth(4) + GetColumnWidth(5);
// Only redraw shown lines // Only redraw shown lines
@ -353,12 +378,16 @@ void CGameListCtrl::OnPaintDrawImages(wxPaintEvent& event)
int itemY = itemRect.GetTop(); int itemY = itemRect.GetTop();
const GameListItem& rISOFile = m_ISOFiles[GetItemData(i)]; const GameListItem& rISOFile = m_ISOFiles[GetItemData(i)];
m_imageListSmall->Draw(m_PlatformImageIndex[rISOFile.GetPlatform()], dc, itemRect.GetX()+3, itemY); m_imageListSmall->Draw(m_PlatformImageIndex[rISOFile.GetPlatform()],
m_imageListSmall->Draw(m_FlagImageIndex[rISOFile.GetCountry()], dc, flagOffset, itemY); dc, itemRect.GetX()+3, itemY);
m_imageListSmall->Draw(m_FlagImageIndex[rISOFile.GetCountry()],
dc, flagOffset, itemY);
ini.Load((std::string(File::GetUserPath(D_GAMECONFIG_IDX)) + (rISOFile.GetUniqueID()) + ".ini").c_str()); ini.Load((std::string(File::GetUserPath(D_GAMECONFIG_IDX)) +
(rISOFile.GetUniqueID()) + ".ini").c_str());
ini.Get("EmuState", "EmulationStateId", &nState); ini.Get("EmuState", "EmulationStateId", &nState);
m_imageListSmall->Draw(m_EmuStateImageIndex[nState], dc, stateOffset, itemY); m_imageListSmall->Draw(m_EmuStateImageIndex[nState],
dc, stateOffset, itemY);
} }
} }
} }
@ -382,7 +411,8 @@ void CGameListCtrl::InsertItemInReportView(long _Index)
// Insert a first row with the platform image, that will be used as the Index // Insert a first row with the platform image, that will be used as the Index
#ifndef _WIN32 #ifndef _WIN32
long ItemIndex = InsertItem(_Index, wxEmptyString, m_PlatformImageIndex[rISOFile.GetPlatform()]); long ItemIndex = InsertItem(_Index, wxEmptyString,
m_PlatformImageIndex[rISOFile.GetPlatform()]);
#else #else
long ItemIndex = InsertItem(_Index, wxEmptyString, -1); long ItemIndex = InsertItem(_Index, wxEmptyString, -1);
#endif #endif
@ -408,9 +438,11 @@ void CGameListCtrl::InsertItemInReportView(long _Index)
case DiscIO::IVolume::COUNTRY_JAPAN: case DiscIO::IVolume::COUNTRY_JAPAN:
{ {
wxString name = wxString(rISOFile.GetName(0).c_str(), SJISConv); wxString name = wxString(rISOFile.GetName(0).c_str(), SJISConv);
m_gameList.append(StringFromFormat("%s (J)\n", (const char*)name.c_str())); m_gameList.append(StringFromFormat("%s (J)\n", name.c_str()));
SetItem(_Index, COLUMN_TITLE, name, -1); SetItem(_Index, COLUMN_TITLE, name, -1);
SetItem(_Index, COLUMN_NOTES, wxString(company.size() ? company.c_str() : rISOFile.GetDescription(0).c_str(), SJISConv), -1); SetItem(_Index, COLUMN_NOTES, wxString(company.size() ?
company.c_str() : rISOFile.GetDescription(0).c_str(),
SJISConv), -1);
} }
break; break;
case DiscIO::IVolume::COUNTRY_USA: case DiscIO::IVolume::COUNTRY_USA:
@ -418,28 +450,38 @@ void CGameListCtrl::InsertItemInReportView(long _Index)
SetItem(_Index, COLUMN_TITLE, SetItem(_Index, COLUMN_TITLE,
wxString::From8BitData(rISOFile.GetName(0).c_str()), -1); wxString::From8BitData(rISOFile.GetName(0).c_str()), -1);
SetItem(_Index, COLUMN_NOTES, SetItem(_Index, COLUMN_NOTES,
wxString::From8BitData(company.size() ? company.c_str() : rISOFile.GetDescription(0).c_str()), -1); wxString::From8BitData(company.size() ?
company.c_str() : rISOFile.GetDescription(0).c_str()), -1);
break; break;
default: default:
m_gameList.append(StringFromFormat("%s (E)\n", rISOFile.GetName((int)SConfig::GetInstance().m_InterfaceLanguage).c_str())); m_gameList.append(StringFromFormat("%s (E)\n",
rISOFile.GetName(SConfig::GetInstance().m_InterfaceLanguage).c_str()));
SetItem(_Index, COLUMN_TITLE, SetItem(_Index, COLUMN_TITLE,
wxString::From8BitData(rISOFile.GetName((int)SConfig::GetInstance().m_InterfaceLanguage).c_str()), -1); wxString::From8BitData(
SetItem(_Index, COLUMN_NOTES, wxString::From8BitData( rISOFile.GetName(SConfig::GetInstance().m_InterfaceLanguage).c_str()),
company.size() ? company.c_str() : rISOFile.GetDescription((int)SConfig::GetInstance().m_InterfaceLanguage).c_str()), -1); -1);
SetItem(_Index, COLUMN_NOTES,
wxString::From8BitData(company.size() ?
company.c_str() :
rISOFile.GetDescription(SConfig::GetInstance().m_InterfaceLanguage).c_str()),
-1);
break; break;
} }
} }
else // It's a Wad file else // It's a Wad file
{ {
m_gameList.append(StringFromFormat("%s (WAD)\n", rISOFile.GetName(0).c_str())); m_gameList.append(StringFromFormat("%s (WAD)\n", rISOFile.GetName(0).c_str()));
SetItem(_Index, COLUMN_TITLE, wxString(rISOFile.GetName(0).c_str(), SJISConv), -1); SetItem(_Index, COLUMN_TITLE,
SetItem(_Index, COLUMN_NOTES, wxString(rISOFile.GetDescription(0).c_str(), SJISConv), -1); wxString(rISOFile.GetName(0).c_str(), SJISConv), -1);
SetItem(_Index, COLUMN_NOTES,
wxString(rISOFile.GetDescription(0).c_str(), SJISConv), -1);
} }
#ifndef _WIN32 #ifndef _WIN32
// Load the INI file for columns that read from it // Load the INI file for columns that read from it
IniFile ini; IniFile ini;
ini.Load((std::string(File::GetUserPath(D_GAMECONFIG_IDX)) + (rISOFile.GetUniqueID()) + ".ini").c_str()); ini.Load((std::string(File::GetUserPath(D_GAMECONFIG_IDX)) +
(rISOFile.GetUniqueID()) + ".ini").c_str());
// Emulation status // Emulation status
int nState; int nState;
@ -476,7 +518,10 @@ void CGameListCtrl::SetBackgroundColor()
{ {
for(long i = 0; i < GetItemCount(); i++) for(long i = 0; i < GetItemCount(); i++)
{ {
wxColour color = (i & 1) ? blend50(wxSystemSettings::GetColour(wxSYS_COLOUR_3DLIGHT), wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW)) : wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW); wxColour color = (i & 1) ?
blend50(wxSystemSettings::GetColour(wxSYS_COLOUR_3DLIGHT),
wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW)) :
wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW);
CGameListCtrl::SetItemBackgroundColour(i, color); CGameListCtrl::SetItemBackgroundColour(i, color);
} }
} }
@ -501,14 +546,16 @@ void CGameListCtrl::ScanForISOs()
for (u32 k = 0; k < Directories.size(); k++) for (u32 k = 0; k < Directories.size(); k++)
{ {
NormalizeDirSep(&Directories.at(k)); NormalizeDirSep(&Directories.at(k));
if (strcmp(Directories.at(k).c_str(), FST_Temp.children.at(j).physicalName.c_str()) == 0) if (strcmp(Directories.at(k).c_str(),
FST_Temp.children.at(j).physicalName.c_str()) == 0)
{ {
duplicate = true; duplicate = true;
break; break;
} }
} }
if (!duplicate) if (!duplicate)
Directories.push_back(FST_Temp.children.at(j).physicalName.c_str()); Directories.push_back(
FST_Temp.children.at(j).physicalName.c_str());
} }
} }
} }
@ -536,7 +583,6 @@ void CGameListCtrl::ScanForISOs()
(int)rFilenames.size(), // range (int)rFilenames.size(), // range
this, // parent this, // parent
wxPD_APP_MODAL | wxPD_APP_MODAL |
// wxPD_AUTO_HIDE | -- try this as well
wxPD_ELAPSED_TIME | wxPD_ELAPSED_TIME |
wxPD_ESTIMATED_TIME | wxPD_ESTIMATED_TIME |
wxPD_REMAINING_TIME | wxPD_REMAINING_TIME |
@ -559,9 +605,7 @@ void CGameListCtrl::ScanForISOs()
// Update with the progress (i) and the message (msg) // Update with the progress (i) and the message (msg)
bool Cont = dialog.Update(i, msg); bool Cont = dialog.Update(i, msg);
if (!Cont) if (!Cont)
{
break; break;
}
#endif #endif
GameListItem ISOFile(rFilenames[i]); GameListItem ISOFile(rFilenames[i]);
if (ISOFile.IsValid()) if (ISOFile.IsValid())
@ -615,7 +659,8 @@ void CGameListCtrl::ScanForISOs()
break; break;
} }
if (list) m_ISOFiles.push_back(ISOFile); if (list)
m_ISOFiles.push_back(ISOFile);
} }
} }
} }
@ -628,7 +673,8 @@ void CGameListCtrl::ScanForISOs()
for (u32 i = 0; i < drives.size() && i < 24; i++) for (u32 i = 0; i < drives.size() && i < 24; i++)
{ {
Drive[i] = new GameListItem(drives[i].c_str()); Drive[i] = new GameListItem(drives[i].c_str());
if (Drive[i]->IsValid()) m_ISOFiles.push_back(*Drive[i]); if (Drive[i]->IsValid())
m_ISOFiles.push_back(*Drive[i]);
} }
} }
@ -649,9 +695,9 @@ const GameListItem *CGameListCtrl::GetISO(int index) const
CGameListCtrl *caller; CGameListCtrl *caller;
int wxCALLBACK wxListCompare(long item1, long item2, long sortData) int wxCALLBACK wxListCompare(long item1, long item2, long sortData)
{ {
//return 1 if item1 > item2 // return 1 if item1 > item2
//return -1 if item1 < item2 // return -1 if item1 < item2
//0 for identity // return 0 for identity
const GameListItem *iso1 = caller->GetISO(item1); const GameListItem *iso1 = caller->GetISO(item1);
const GameListItem *iso2 = caller->GetISO(item2); const GameListItem *iso2 = caller->GetISO(item2);
@ -668,52 +714,74 @@ int wxCALLBACK wxListCompare(long item1, long item2, long sortData)
switch (iso1->GetCountry()) switch (iso1->GetCountry())
{ {
case DiscIO::IVolume::COUNTRY_JAPAN:; case DiscIO::IVolume::COUNTRY_JAPAN:
case DiscIO::IVolume::COUNTRY_USA:indexOne = 0; break; case DiscIO::IVolume::COUNTRY_USA:
default: indexOne = (int)SConfig::GetInstance().m_InterfaceLanguage; indexOne = 0;
break;
default:
indexOne = SConfig::GetInstance().m_InterfaceLanguage;
} }
switch (iso2->GetCountry()) switch (iso2->GetCountry())
{ {
case DiscIO::IVolume::COUNTRY_JAPAN:; case DiscIO::IVolume::COUNTRY_JAPAN:
case DiscIO::IVolume::COUNTRY_USA:indexOther = 0; break; case DiscIO::IVolume::COUNTRY_USA:
default: indexOther = (int)SConfig::GetInstance().m_InterfaceLanguage; indexOther = 0;
break;
default:
indexOther = SConfig::GetInstance().m_InterfaceLanguage;
} }
switch(sortData) switch(sortData)
{ {
case CGameListCtrl::COLUMN_TITLE: case CGameListCtrl::COLUMN_TITLE:
return strcasecmp(iso1->GetName(indexOne).c_str(),iso2->GetName(indexOther).c_str()) *t; return strcasecmp(iso1->GetName(indexOne).c_str(),
iso2->GetName(indexOther).c_str()) * t;
case CGameListCtrl::COLUMN_NOTES: case CGameListCtrl::COLUMN_NOTES:
{ {
std::string cmp1 = (iso1->GetPlatform() == GameListItem::GAMECUBE_DISC) ? iso1->GetCompany() : iso1->GetDescription(indexOne); std::string cmp1 =
std::string cmp2 = (iso2->GetPlatform() == GameListItem::GAMECUBE_DISC) ? iso2->GetCompany() : iso2->GetDescription(indexOther); (iso1->GetPlatform() == GameListItem::GAMECUBE_DISC) ?
return strcasecmp(cmp1.c_str(), cmp2.c_str()) *t; iso1->GetCompany() : iso1->GetDescription(indexOne);
std::string cmp2 =
(iso2->GetPlatform() == GameListItem::GAMECUBE_DISC) ?
iso2->GetCompany() : iso2->GetDescription(indexOther);
return strcasecmp(cmp1.c_str(), cmp2.c_str()) * t;
} }
case CGameListCtrl::COLUMN_COUNTRY: case CGameListCtrl::COLUMN_COUNTRY:
if(iso1->GetCountry() > iso2->GetCountry()) return 1 *t; if(iso1->GetCountry() > iso2->GetCountry())
if(iso1->GetCountry() < iso2->GetCountry()) return -1 *t; return 1 * t;
if(iso1->GetCountry() < iso2->GetCountry())
return -1 * t;
return 0; return 0;
case CGameListCtrl::COLUMN_SIZE: case CGameListCtrl::COLUMN_SIZE:
if (iso1->GetFileSize() > iso2->GetFileSize()) return 1 *t; if (iso1->GetFileSize() > iso2->GetFileSize())
if (iso1->GetFileSize() < iso2->GetFileSize()) return -1 *t; return 1 * t;
if (iso1->GetFileSize() < iso2->GetFileSize())
return -1 * t;
return 0; return 0;
case CGameListCtrl::COLUMN_PLATFORM: case CGameListCtrl::COLUMN_PLATFORM:
if(iso1->GetPlatform() > iso2->GetPlatform()) return 1 *t; if(iso1->GetPlatform() > iso2->GetPlatform())
if(iso1->GetPlatform() < iso2->GetPlatform()) return -1 *t; return 1 * t;
if(iso1->GetPlatform() < iso2->GetPlatform())
return -1 * t;
return 0; return 0;
case CGameListCtrl::COLUMN_EMULATION_STATE: case CGameListCtrl::COLUMN_EMULATION_STATE:
IniFile ini; int nState1 = 0, nState2 = 0; IniFile ini;
std::string GameIni1 = std::string(File::GetUserPath(D_GAMECONFIG_IDX)) + iso1->GetUniqueID() + ".ini"; int nState1 = 0, nState2 = 0;
std::string GameIni2 = std::string(File::GetUserPath(D_GAMECONFIG_IDX)) + iso2->GetUniqueID() + ".ini"; std::string GameIni1 = std::string(File::GetUserPath(D_GAMECONFIG_IDX)) +
iso1->GetUniqueID() + ".ini";
std::string GameIni2 = std::string(File::GetUserPath(D_GAMECONFIG_IDX)) +
iso2->GetUniqueID() + ".ini";
ini.Load(GameIni1.c_str()); ini.Load(GameIni1.c_str());
ini.Get("EmuState", "EmulationStateId", &nState1); ini.Get("EmuState", "EmulationStateId", &nState1);
ini.Load(GameIni2.c_str()); ini.Load(GameIni2.c_str());
ini.Get("EmuState", "EmulationStateId", &nState2); ini.Get("EmuState", "EmulationStateId", &nState2);
if(nState1 > nState2) return 1 *t; if(nState1 > nState2)
if(nState1 < nState2) return -1 *t; return 1 * t;
if(nState1 < nState2)
return -1 * t;
return 0; return 0;
} }
@ -778,12 +846,14 @@ void CGameListCtrl::OnKeyPress(wxListEvent& event)
sLoop++; sLoop++;
UnselectAll(); UnselectAll();
SetItemState(i, wxLIST_STATE_SELECTED|wxLIST_STATE_FOCUSED, wxLIST_STATE_SELECTED|wxLIST_STATE_FOCUSED); SetItemState(i, wxLIST_STATE_SELECTED|wxLIST_STATE_FOCUSED,
wxLIST_STATE_SELECTED|wxLIST_STATE_FOCUSED);
EnsureVisible(i); EnsureVisible(i);
break; break;
} }
// If we get past the last game in the list, we'll have to go back to the first one. // If we get past the last game in the list,
// we'll have to go back to the first one.
if (i+1 == (int)m_ISOFiles.size() && sLoop > 0 && Loop > 0) if (i+1 == (int)m_ISOFiles.size() && sLoop > 0 && Loop > 0)
i = -1; i = -1;
} }
@ -794,7 +864,8 @@ void CGameListCtrl::OnKeyPress(wxListEvent& event)
// This shows a little tooltip with the current Game's emulation state // This shows a little tooltip with the current Game's emulation state
void CGameListCtrl::OnMouseMotion(wxMouseEvent& event) void CGameListCtrl::OnMouseMotion(wxMouseEvent& event)
{ {
int flags; long subitem = 0; int flags;
long subitem = 0;
long item = HitTest(event.GetPosition(), flags, &subitem); long item = HitTest(event.GetPosition(), flags, &subitem);
static int lastItem = -1; static int lastItem = -1;
@ -802,7 +873,8 @@ void CGameListCtrl::OnMouseMotion(wxMouseEvent& event)
{ {
if (subitem == COLUMN_EMULATION_STATE) if (subitem == COLUMN_EMULATION_STATE)
{ {
if (toolTip || lastItem == item || this != FindFocus()) { if (toolTip || lastItem == item || this != FindFocus())
{
event.Skip(); event.Skip();
return; return;
} }
@ -810,10 +882,18 @@ void CGameListCtrl::OnMouseMotion(wxMouseEvent& event)
const GameListItem& rISO = m_ISOFiles[GetItemData(item)]; const GameListItem& rISO = m_ISOFiles[GetItemData(item)];
IniFile ini; IniFile ini;
ini.Load((std::string(File::GetUserPath(D_GAMECONFIG_IDX)) + (rISO.GetUniqueID()) + ".ini").c_str()); ini.Load((std::string(File::GetUserPath(D_GAMECONFIG_IDX)) +
(rISO.GetUniqueID()) + ".ini").c_str());
// Emulation status // Emulation status
std::string emuState[5] = {"Broken", "Intro", "In-Game", "Playable", "Perfect"}, issues; std::string emuState[5] = {
"Broken",
"Intro",
"In-Game",
"Playable",
"Perfect"
};
std::string issues;
int nState; int nState;
ini.Get("EmuState", "EmulationStateId", &nState); ini.Get("EmuState", "EmulationStateId", &nState);
@ -830,14 +910,17 @@ void CGameListCtrl::OnMouseMotion(wxMouseEvent& event)
if (nState > 0 && nState < 6) if (nState > 0 && nState < 6)
{ {
char temp[2048]; char temp[2048];
sprintf(temp, "^ %s%s%s", emuState[nState -1].c_str(), issues.size() > 0 ? " :\n" : "", issues.c_str()); sprintf(temp, "^ %s%s%s", emuState[nState -1].c_str(),
issues.size() > 0 ? " :\n" : "", issues.c_str());
toolTip = new wxEmuStateTip(this, wxString(temp, *wxConvCurrent), &toolTip); toolTip = new wxEmuStateTip(this, wxString(temp, *wxConvCurrent), &toolTip);
} }
else else
toolTip = new wxEmuStateTip(this, wxT("Not Set"), &toolTip); toolTip = new wxEmuStateTip(this, wxT("Not Set"), &toolTip);
toolTip->SetBoundingRect(wxRect(mx - GetColumnWidth(subitem), my, GetColumnWidth(subitem), Rect.GetHeight())); toolTip->SetBoundingRect(wxRect(mx - GetColumnWidth(subitem),
toolTip->SetPosition(wxPoint(mx - GetColumnWidth(subitem), my - 5 + Rect.GetHeight())); my, GetColumnWidth(subitem), Rect.GetHeight()));
toolTip->SetPosition(wxPoint(mx - GetColumnWidth(subitem),
my - 5 + Rect.GetHeight()));
lastItem = item; lastItem = item;
} }
@ -851,7 +934,8 @@ void CGameListCtrl::OnLeftClick(wxMouseEvent& event)
// Focus the clicked item. // Focus the clicked item.
int flags; int flags;
long item = HitTest(event.GetPosition(), flags); long item = HitTest(event.GetPosition(), flags);
if ((item != wxNOT_FOUND) && (GetSelectedItemCount() == 0) && (!event.ControlDown()) && (!event.ShiftDown())) if ((item != wxNOT_FOUND) && (GetSelectedItemCount() == 0) &&
(!event.ControlDown()) && (!event.ShiftDown()))
{ {
SetItemState(item, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED ); SetItemState(item, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED );
SetItemState(item, wxLIST_STATE_FOCUSED, wxLIST_STATE_FOCUSED); SetItemState(item, wxLIST_STATE_FOCUSED, wxLIST_STATE_FOCUSED);
@ -927,13 +1011,9 @@ void CGameListCtrl::OnRightClick(wxMouseEvent& event)
const GameListItem * CGameListCtrl::GetSelectedISO() const GameListItem * CGameListCtrl::GetSelectedISO()
{ {
if (m_ISOFiles.size() == 0) if (m_ISOFiles.size() == 0)
{
return NULL; return NULL;
}
else if (GetSelectedItemCount() == 0) else if (GetSelectedItemCount() == 0)
{
return NULL; return NULL;
}
else else
{ {
long item = GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED); long item = GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
@ -991,27 +1071,26 @@ void CGameListCtrl::OnExportSave(wxCommandEvent& WXUNUSED (event))
} }
} }
// =======================================================
// Save this file as the default file // Save this file as the default file
// -------------
void CGameListCtrl::OnSetDefaultGCM(wxCommandEvent& event) void CGameListCtrl::OnSetDefaultGCM(wxCommandEvent& event)
{ {
const GameListItem *iso = GetSelectedISO(); const GameListItem *iso = GetSelectedISO();
if (!iso) return; if (!iso) return;
if (event.IsChecked()) // Write the new default value and save it the ini file if (event.IsChecked())
{ {
SConfig::GetInstance().m_LocalCoreStartupParameter.m_strDefaultGCM = iso->GetFileName(); // Write the new default value and save it the ini file
SConfig::GetInstance().m_LocalCoreStartupParameter.m_strDefaultGCM =
iso->GetFileName();
SConfig::GetInstance().SaveSettings(); SConfig::GetInstance().SaveSettings();
} }
else // Othwerise blank the value and save it else
{ {
// Othwerise blank the value and save it
SConfig::GetInstance().m_LocalCoreStartupParameter.m_strDefaultGCM = ""; SConfig::GetInstance().m_LocalCoreStartupParameter.m_strDefaultGCM = "";
SConfig::GetInstance().SaveSettings(); SConfig::GetInstance().SaveSettings();
} }
} }
// =============
void CGameListCtrl::OnDeleteGCM(wxCommandEvent& WXUNUSED (event)) void CGameListCtrl::OnDeleteGCM(wxCommandEvent& WXUNUSED (event))
{ {
@ -1020,7 +1099,8 @@ void CGameListCtrl::OnDeleteGCM(wxCommandEvent& WXUNUSED (event))
const GameListItem *iso = GetSelectedISO(); const GameListItem *iso = GetSelectedISO();
if (!iso) if (!iso)
return; return;
if (wxMessageBox(_("Are you sure you want to delete this file?\nIt will be gone forever!"), if (wxMessageBox(wxT("Are you sure you want to delete this file?\n")
wxT("It will be gone forever!"),
wxMessageBoxCaptionStr, wxYES_NO | wxICON_EXCLAMATION) == wxYES) wxMessageBoxCaptionStr, wxYES_NO | wxICON_EXCLAMATION) == wxYES)
{ {
File::Delete(iso->GetFileName().c_str()); File::Delete(iso->GetFileName().c_str());
@ -1029,7 +1109,8 @@ void CGameListCtrl::OnDeleteGCM(wxCommandEvent& WXUNUSED (event))
} }
else else
{ {
if (wxMessageBox(_("Are you sure you want to delete these files?\nThey will be gone forever!"), if (wxMessageBox(wxT("Are you sure you want to delete these files?\n")
wxT("They will be gone forever!"),
wxMessageBoxCaptionStr, wxYES_NO | wxICON_EXCLAMATION) == wxYES) wxMessageBoxCaptionStr, wxYES_NO | wxICON_EXCLAMATION) == wxYES)
{ {
int selected = GetSelectedItemCount(); int selected = GetSelectedItemCount();
@ -1066,7 +1147,6 @@ void CGameListCtrl::OnInstallWAD(wxCommandEvent& WXUNUSED (event))
1000, // range 1000, // range
this, // parent this, // parent
wxPD_APP_MODAL | wxPD_APP_MODAL |
// wxPD_AUTO_HIDE | -- try this as well
wxPD_ELAPSED_TIME | wxPD_ELAPSED_TIME |
wxPD_ESTIMATED_TIME | wxPD_ESTIMATED_TIME |
wxPD_REMAINING_TIME | wxPD_REMAINING_TIME |
@ -1081,7 +1161,9 @@ void CGameListCtrl::OnInstallWAD(wxCommandEvent& WXUNUSED (event))
void CGameListCtrl::MultiCompressCB(const char* text, float percent, void* arg) void CGameListCtrl::MultiCompressCB(const char* text, float percent, void* arg)
{ {
percent = (((float)m_currentItem) + percent) / (float)m_numberItem; percent = (((float)m_currentItem) + percent) / (float)m_numberItem;
wxString textString(StringFromFormat("%s (%i/%i) - %s", m_currentFilename.c_str(), (int)m_currentItem+1, (int)m_numberItem, text).c_str(), *wxConvCurrent); wxString textString(StringFromFormat("%s (%i/%i) - %s",
m_currentFilename.c_str(), (int)m_currentItem+1,
(int)m_numberItem, text).c_str(), *wxConvCurrent);
((wxProgressDialog*)arg)->Update((int)(percent*1000), textString); ((wxProgressDialog*)arg)->Update((int)(percent*1000), textString);
} }
@ -1101,16 +1183,17 @@ void CGameListCtrl::CompressSelection(bool _compress)
wxString dirHome; wxString dirHome;
wxGetHomeDir(&dirHome); wxGetHomeDir(&dirHome);
wxDirDialog browseDialog(this, _("Browse for output directory"), dirHome, wxDD_DEFAULT_STYLE | wxDD_DIR_MUST_EXIST); wxDirDialog browseDialog(this, _("Browse for output directory"), dirHome,
wxDD_DEFAULT_STYLE | wxDD_DIR_MUST_EXIST);
if (browseDialog.ShowModal() != wxID_OK) if (browseDialog.ShowModal() != wxID_OK)
return; return;
wxProgressDialog progressDialog(_compress ? _("Compressing ISO") : _("Decompressing ISO"), wxProgressDialog progressDialog(_compress ?
_("Compressing ISO") : _("Decompressing ISO"),
_("Working..."), _("Working..."),
1000, // range 1000, // range
this, // parent this, // parent
wxPD_APP_MODAL | wxPD_APP_MODAL |
// wxPD_AUTO_HIDE | -- try this as well
wxPD_ELAPSED_TIME | wxPD_ELAPSED_TIME |
wxPD_ESTIMATED_TIME | wxPD_ESTIMATED_TIME |
wxPD_REMAINING_TIME | wxPD_REMAINING_TIME |
@ -1134,9 +1217,14 @@ void CGameListCtrl::CompressSelection(bool _compress)
FileName.append(".gcz"); FileName.append(".gcz");
std::string OutputFileName; std::string OutputFileName;
BuildCompleteFilename(OutputFileName, (const char *)browseDialog.GetPath().mb_str(wxConvUTF8), FileName); BuildCompleteFilename(OutputFileName,
(const char *)browseDialog.GetPath().mb_str(wxConvUTF8),
FileName);
DiscIO::CompressFileToBlob(iso->GetFileName().c_str(), OutputFileName.c_str(), (iso->GetPlatform() == GameListItem::WII_DISC) ? 1 : 0, 16384, &MultiCompressCB, &progressDialog); DiscIO::CompressFileToBlob(iso->GetFileName().c_str(),
OutputFileName.c_str(),
(iso->GetPlatform() == GameListItem::WII_DISC) ? 1 : 0,
16384, &MultiCompressCB, &progressDialog);
} }
else if (iso->IsCompressed() && !_compress) else if (iso->IsCompressed() && !_compress)
{ {
@ -1144,18 +1232,17 @@ void CGameListCtrl::CompressSelection(bool _compress)
SplitPath(iso->GetFileName(), NULL, &FileName, NULL); SplitPath(iso->GetFileName(), NULL, &FileName, NULL);
m_currentFilename = FileName; m_currentFilename = FileName;
if (iso->GetPlatform() == GameListItem::WII_DISC) if (iso->GetPlatform() == GameListItem::WII_DISC)
{
FileName.append(".iso"); FileName.append(".iso");
}
else else
{
FileName.append(".gcm"); FileName.append(".gcm");
}
std::string OutputFileName; std::string OutputFileName;
BuildCompleteFilename(OutputFileName, (const char *)browseDialog.GetPath().mb_str(wxConvUTF8), FileName); BuildCompleteFilename(OutputFileName,
(const char *)browseDialog.GetPath().mb_str(wxConvUTF8),
FileName);
DiscIO::DecompressBlobToFile(iso->GetFileName().c_str(), OutputFileName.c_str(), &MultiCompressCB, &progressDialog); DiscIO::DecompressBlobToFile(iso->GetFileName().c_str(),
OutputFileName.c_str(), &MultiCompressCB, &progressDialog);
} }
m_currentItem++; m_currentItem++;
} }
@ -1164,7 +1251,8 @@ void CGameListCtrl::CompressSelection(bool _compress)
void CGameListCtrl::CompressCB(const char* text, float percent, void* arg) void CGameListCtrl::CompressCB(const char* text, float percent, void* arg)
{ {
((wxProgressDialog*)arg)->Update((int)(percent*1000), wxString(text, *wxConvCurrent)); ((wxProgressDialog*)arg)->
Update((int)(percent*1000), wxString(text, *wxConvCurrent));
} }
void CGameListCtrl::OnCompressGCM(wxCommandEvent& WXUNUSED (event)) void CGameListCtrl::OnCompressGCM(wxCommandEvent& WXUNUSED (event))
@ -1181,13 +1269,10 @@ void CGameListCtrl::OnCompressGCM(wxCommandEvent& WXUNUSED (event))
if (iso->IsCompressed()) if (iso->IsCompressed())
{ {
if (iso->GetPlatform() == GameListItem::WII_DISC) if (iso->GetPlatform() == GameListItem::WII_DISC)
{
Ext = wxT("*.iso"); Ext = wxT("*.iso");
}
else else
{
Ext = wxT("*.gcm"); Ext = wxT("*.gcm");
}
path = wxFileSelector( path = wxFileSelector(
_T("Save decompressed ISO"), _T("Save decompressed ISO"),
wxEmptyString, wxString(FileName.c_str(), *wxConvCurrent), wxEmptyString, wxEmptyString, wxString(FileName.c_str(), *wxConvCurrent), wxEmptyString,
@ -1203,10 +1288,8 @@ void CGameListCtrl::OnCompressGCM(wxCommandEvent& WXUNUSED (event))
this); this);
if (!path) if (!path)
{
return; return;
} }
}
else else
{ {
path = wxFileSelector( path = wxFileSelector(
@ -1222,17 +1305,15 @@ void CGameListCtrl::OnCompressGCM(wxCommandEvent& WXUNUSED (event))
this); this);
if (!path) if (!path)
{
return; return;
} }
}
wxProgressDialog dialog(iso->IsCompressed() ? _T("Decompressing ISO") : _T("Compressing ISO"), wxProgressDialog dialog(iso->IsCompressed() ?
_T("Decompressing ISO") : _T("Compressing ISO"),
_T("Working..."), _T("Working..."),
1000, // range 1000, // range
this, // parent this, // parent
wxPD_APP_MODAL | wxPD_APP_MODAL |
// wxPD_AUTO_HIDE | -- try this as well
wxPD_ELAPSED_TIME | wxPD_ELAPSED_TIME |
wxPD_ESTIMATED_TIME | wxPD_ESTIMATED_TIME |
wxPD_REMAINING_TIME | wxPD_REMAINING_TIME |
@ -1243,9 +1324,13 @@ void CGameListCtrl::OnCompressGCM(wxCommandEvent& WXUNUSED (event))
dialog.CenterOnParent(); dialog.CenterOnParent();
if (iso->IsCompressed()) if (iso->IsCompressed())
DiscIO::DecompressBlobToFile(iso->GetFileName().c_str(), path.char_str(), &CompressCB, &dialog); DiscIO::DecompressBlobToFile(iso->GetFileName().c_str(),
path.char_str(), &CompressCB, &dialog);
else else
DiscIO::CompressFileToBlob(iso->GetFileName().c_str(), path.char_str(), (iso->GetPlatform() == GameListItem::WII_DISC) ? 1 : 0, 16384, &CompressCB, &dialog); DiscIO::CompressFileToBlob(iso->GetFileName().c_str(),
path.char_str(),
(iso->GetPlatform() == GameListItem::WII_DISC) ? 1 : 0,
16384, &CompressCB, &dialog);
Update(); Update();
} }
@ -1261,12 +1346,10 @@ void CGameListCtrl::OnSize(wxSizeEvent& event)
void CGameListCtrl::AutomaticColumnWidth() void CGameListCtrl::AutomaticColumnWidth()
{ {
wxRect rc(GetParent()->GetRect()); wxRect rc(GetClientRect());
if (GetColumnCount() == 1) if (GetColumnCount() == 1)
{
SetColumnWidth(0, rc.GetWidth()); SetColumnWidth(0, rc.GetWidth());
}
else if (GetColumnCount() > 4) else if (GetColumnCount() > 4)
{ {
int resizable = rc.GetWidth() - ( int resizable = rc.GetWidth() - (
@ -1274,11 +1357,10 @@ void CGameListCtrl::AutomaticColumnWidth()
+ GetColumnWidth(COLUMN_COUNTRY) + GetColumnWidth(COLUMN_COUNTRY)
+ GetColumnWidth(COLUMN_SIZE) + GetColumnWidth(COLUMN_SIZE)
+ GetColumnWidth(COLUMN_EMULATION_STATE) + GetColumnWidth(COLUMN_EMULATION_STATE)
+ GetColumnWidth(COLUMN_PLATFORM) + GetColumnWidth(COLUMN_PLATFORM));
+ 5); // some pad to keep the horizontal scrollbar away :)
// We hide the Company column if the window is too small // We hide the Notes column if the window is too small
if (resizable / 2 > 200) if (resizable > 400)
{ {
SetColumnWidth(COLUMN_TITLE, resizable / 2); SetColumnWidth(COLUMN_TITLE, resizable / 2);
SetColumnWidth(COLUMN_NOTES, resizable / 2); SetColumnWidth(COLUMN_NOTES, resizable / 2);

View File

@ -46,6 +46,7 @@ BEGIN_EVENT_TABLE(CLogWindow, wxPanel)
EVT_CHECKBOX(IDM_WRITEWINDOW, CLogWindow::OnOptionsCheck) EVT_CHECKBOX(IDM_WRITEWINDOW, CLogWindow::OnOptionsCheck)
EVT_CHECKLISTBOX(IDM_LOGCHECKS, CLogWindow::OnLogCheck) EVT_CHECKLISTBOX(IDM_LOGCHECKS, CLogWindow::OnLogCheck)
EVT_TIMER(IDTM_UPDATELOG, CLogWindow::OnLogTimer) EVT_TIMER(IDTM_UPDATELOG, CLogWindow::OnLogTimer)
EVT_SIZE(CLogWindow::OnSize)
END_EVENT_TABLE() END_EVENT_TABLE()
CLogWindow::CLogWindow(CFrame *parent, wxWindowID id, const wxPoint& pos, CLogWindow::CLogWindow(CFrame *parent, wxWindowID id, const wxPoint& pos,
@ -170,14 +171,28 @@ void CLogWindow::OnClose(wxCloseEvent& event)
event.Skip(); event.Skip();
} }
void CLogWindow::OnSize(wxSizeEvent& event)
{
if (!Parent->g_pCodeWindow &&
Parent->m_Mgr->GetPane(wxT("Pane 1")).IsShown())
{
x = Parent->m_Mgr->GetPane(wxT("Pane 1")).rect.GetWidth();
y = Parent->m_Mgr->GetPane(wxT("Pane 1")).rect.GetHeight();
winpos = Parent->m_Mgr->GetPane(wxT("Pane 1")).dock_direction;
}
event.Skip();
}
void CLogWindow::SaveSettings() void CLogWindow::SaveSettings()
{ {
IniFile ini; IniFile ini;
ini.Load(File::GetUserPath(F_LOGGERCONFIG_IDX));
if (!Parent->g_pCodeWindow) if (!Parent->g_pCodeWindow)
{ {
ini.Set("LogWindow", "x", Parent->m_Mgr->GetPane(wxT("Pane 1")).rect.GetWidth()); ini.Set("LogWindow", "x", x);
ini.Set("LogWindow", "y", Parent->m_Mgr->GetPane(wxT("Pane 1")).rect.GetHeight()); ini.Set("LogWindow", "y", y);
ini.Set("LogWindow", "pos", Parent->m_Mgr->GetPane(wxT("Pane 1")).dock_direction); ini.Set("LogWindow", "pos", winpos);
} }
ini.Set("Options", "Verbosity", m_verbosity->GetSelection() + 1); ini.Set("Options", "Verbosity", m_verbosity->GetSelection() + 1);
ini.Set("Options", "Font", m_FontChoice->GetSelection()); ini.Set("Options", "Font", m_FontChoice->GetSelection());

View File

@ -97,6 +97,7 @@ private:
void CreateGUIControls(); void CreateGUIControls();
void PopulateRight(); void UnPopulateRight(); void PopulateRight(); void UnPopulateRight();
void OnClose(wxCloseEvent& event); void OnClose(wxCloseEvent& event);
void OnSize(wxSizeEvent& event);
void OnSubmit(wxCommandEvent& event); void OnSubmit(wxCommandEvent& event);
void OnOptionsCheck(wxCommandEvent& event); void OnOptionsCheck(wxCommandEvent& event);
void OnLogCheck(wxCommandEvent& event); void OnLogCheck(wxCommandEvent& event);