added sorting to gamelistctrl (thanks a lot to gigaherz)

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@547 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
Shawn Hoffman 2008-09-17 05:57:43 +00:00
parent e4ca998ff8
commit afc6bf15ab
8 changed files with 504 additions and 62 deletions

View File

@ -0,0 +1,202 @@
// Copyright (C) 2003-2008 Dolphin Project.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, version 2.0.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License 2.0 for more details.
// A copy of the GPL 2.0 should have been included with the program.
// If not, see http://www.gnu.org/licenses/
// Official SVN repository and contact information can be found at
// http://code.google.com/p/dolphin-emu/
#include "Globals.h"
//#include "VolumeCreator.h"
//#include "Filesystem.h"
//#include "BannerLoader.h"
#include "FilesystemViewer.h"
BEGIN_EVENT_TABLE(CFilesystemViewer, wxDialog)
EVT_CLOSE(CFilesystemViewer::OnClose)
EVT_RIGHT_DOWN(CFilesystemViewer::OnRightClick)
EVT_TREE_ITEM_RIGHT_CLICK(ID_TREECTRL,CFilesystemViewer::OnRightClickOnTree)
EVT_BUTTON(ID_CLOSE,CFilesystemViewer::OnCloseClick)
EVT_BUTTON(ID_SAVEBNR,CFilesystemViewer::OnSaveBNRClick)
EVT_MENU(IDM_BNRSAVEAS, CFilesystemViewer::OnBannerImageSave)
EVT_MENU(IDM_EXTRACTFILE, CFilesystemViewer::OnExtractFile)
EVT_MENU(IDM_REPLACEFILE, CFilesystemViewer::OnReplaceFile)
EVT_MENU(IDM_RENAMEFILE, CFilesystemViewer::OnRenameFile)
END_EVENT_TABLE()
CFilesystemViewer::CFilesystemViewer(const std::string fileName, wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& position, const wxSize& size, long style)
: wxDialog(parent, id, title, position, size, style)
{
/*DiscIO::IVolume* pVolume = DiscIO::CreateVolumeFromFilename(fileName);
DiscIO::IFileSystem* pFileSystem = DiscIO::CreateFileSystem(*pVolume);
pFileSystem->*/
CreateGUIControls();
}
CFilesystemViewer::~CFilesystemViewer()
{
}
void CFilesystemViewer::CreateGUIControls()
{
m_Close = new wxButton(this, ID_CLOSE, wxT("Close"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
// ISO Details
sbISODetails = new wxStaticBoxSizer(wxVERTICAL, this, wxT("ISO Details:"));
sISODetails = new wxGridBagSizer(0, 0);
m_NameText = new wxStaticText(this, ID_NAME_TEXT, wxT("Name:"), wxDefaultPosition, wxDefaultSize);
m_Name = new wxTextCtrl(this, ID_NAME, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_READONLY);
m_SerialText = new wxStaticText(this, ID_SERIAL_TEXT, wxT("Serial:"), wxDefaultPosition, wxDefaultSize);
m_Serial = new wxTextCtrl(this, ID_SERIAL, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_READONLY);
m_CountryText = new wxStaticText(this, ID_COUNTRY_TEXT, wxT("Country:"), wxDefaultPosition, wxDefaultSize);
m_Country = new wxTextCtrl(this, ID_COUNTRY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_READONLY);
m_MakerIDText = new wxStaticText(this, ID_MAKERID_TEXT, wxT("Maker ID:"), wxDefaultPosition, wxDefaultSize);
m_MakerID = new wxTextCtrl(this, ID_MAKERID, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_READONLY);
m_DateText = new wxStaticText(this, ID_DATE_TEXT, wxT("Date:"), wxDefaultPosition, wxDefaultSize);
m_Date = new wxTextCtrl(this, ID_DATE, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_READONLY);
m_TOCText = new wxStaticText(this, ID_TOC_TEXT, wxT("TOC Size:"), wxDefaultPosition, wxDefaultSize);
m_TOC = new wxTextCtrl(this, ID_TOC, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_READONLY);
sISODetails->Add(m_NameText, wxGBPosition(0, 0), wxGBSpan(1, 1), wxALL, 5);
sISODetails->Add(m_Name, wxGBPosition(0, 1), wxGBSpan(1, 1), wxEXPAND|wxALL, 5);
sISODetails->Add(m_SerialText, wxGBPosition(1, 0), wxGBSpan(1, 1), wxALL, 5);
sISODetails->Add(m_Serial, wxGBPosition(1, 1), wxGBSpan(1, 1), wxEXPAND|wxALL, 5);
sISODetails->Add(m_CountryText, wxGBPosition(2, 0), wxGBSpan(1, 1), wxALL, 5);
sISODetails->Add(m_Country, wxGBPosition(2, 1), wxGBSpan(1, 1), wxEXPAND|wxALL, 5);
sISODetails->Add(m_MakerIDText, wxGBPosition(3, 0), wxGBSpan(1, 1), wxALL, 5);
sISODetails->Add(m_MakerID, wxGBPosition(3, 1), wxGBSpan(1, 1), wxEXPAND|wxALL, 5);
sISODetails->Add(m_DateText, wxGBPosition(4, 0), wxGBSpan(1, 1), wxALL, 5);
sISODetails->Add(m_Date, wxGBPosition(4, 1), wxGBSpan(1, 1), wxEXPAND|wxALL, 5);
sISODetails->Add(m_TOCText, wxGBPosition(5, 0), wxGBSpan(1, 1), wxALL, 5);
sISODetails->Add(m_TOC, wxGBPosition(5, 1), wxGBSpan(1, 1), wxEXPAND|wxALL, 5);
sbISODetails->Add(sISODetails, 0, wxEXPAND, 5);
// Banner Details
wxArrayString arrayStringFor_Lang;
sbBannerDetails = new wxStaticBoxSizer(wxVERTICAL, this, wxT("Banner Details:"));
sBannerDetails = new wxGridBagSizer(0, 0);
m_VersionText = new wxStaticText(this, ID_VERSION_TEXT, wxT("Version:"), wxDefaultPosition, wxDefaultSize);
m_Version = new wxTextCtrl(this, ID_VERSION, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_READONLY);
m_LangText = new wxStaticText(this, ID_LANG_TEXT, wxT("Show Language:"), wxDefaultPosition, wxDefaultSize);
m_Lang = new wxChoice(this, ID_LANG, wxDefaultPosition, wxDefaultSize, arrayStringFor_Lang, 0, wxDefaultValidator);
m_ShortText = new wxStaticText(this, ID_SHORTNAME_TEXT, wxT("Short Name:"), wxDefaultPosition, wxDefaultSize);
m_ShortName = new wxTextCtrl(this, ID_SHORTNAME, wxEmptyString, wxDefaultPosition, wxDefaultSize);
m_LongText = new wxStaticText(this, ID_LONGNAME_TEXT, wxT("Long Name:"), wxDefaultPosition, wxDefaultSize);
m_LongName = new wxTextCtrl(this, ID_LONGNAME, wxEmptyString, wxDefaultPosition, wxDefaultSize);
m_MakerText = new wxStaticText(this, ID_MAKER_TEXT, wxT("Maker:"), wxDefaultPosition, wxDefaultSize);
m_Maker = new wxTextCtrl(this, ID_MAKER, wxEmptyString, wxDefaultPosition, wxDefaultSize);
m_CommentText = new wxStaticText(this, ID_COMMENT_TEXT, wxT("Comment:"), wxDefaultPosition, wxDefaultSize);
m_Comment = new wxTextCtrl(this, ID_COMMENT, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE);
m_BannerText = new wxStaticText(this, ID_BANNER_TEXT, wxT("Banner:"), wxDefaultPosition, wxDefaultSize);
//needs to be image:
m_Banner = new wxTextCtrl(this, ID_BANNER, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE);
m_SaveBNR = new wxButton(this, ID_SAVEBNR, wxT("Save Changes to BNR"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
m_SaveBNR->Disable();
sBannerDetails->Add(m_VersionText, wxGBPosition(0, 0), wxGBSpan(1, 1), wxALL, 5);
sBannerDetails->Add(m_Version, wxGBPosition(0, 1), wxGBSpan(1, 1), wxEXPAND|wxALL, 5);
sBannerDetails->Add(m_LangText, wxGBPosition(0, 2), wxGBSpan(1, 1), wxALL, 5);
sBannerDetails->Add(m_Lang, wxGBPosition(0, 3), wxGBSpan(1, 1), wxEXPAND|wxALL, 5);
sBannerDetails->Add(m_ShortText, wxGBPosition(1, 0), wxGBSpan(1, 1), wxALL, 5);
sBannerDetails->Add(m_ShortName, wxGBPosition(1, 1), wxGBSpan(1, 3), wxEXPAND|wxALL, 5);
sBannerDetails->Add(m_LongText, wxGBPosition(2, 0), wxGBSpan(1, 1), wxALL, 5);
sBannerDetails->Add(m_LongName, wxGBPosition(2, 1), wxGBSpan(1, 3), wxEXPAND|wxALL, 5);
sBannerDetails->Add(m_MakerText, wxGBPosition(3, 0), wxGBSpan(1, 1), wxALL, 5);
sBannerDetails->Add(m_Maker, wxGBPosition(3, 1), wxGBSpan(1, 3), wxEXPAND|wxALL, 5);
sBannerDetails->Add(m_CommentText, wxGBPosition(4, 0), wxGBSpan(1, 1), wxALL, 5);
sBannerDetails->Add(m_Comment, wxGBPosition(4, 1), wxGBSpan(1, 3), wxEXPAND|wxALL, 5);
sBannerDetails->Add(m_BannerText, wxGBPosition(5, 0), wxGBSpan(1, 1), wxALL, 5);
sBannerDetails->Add(m_Banner, wxGBPosition(5, 1), wxGBSpan(1, 1), wxEXPAND|wxALL, 5);
sBannerDetails->Add(m_SaveBNR, wxGBPosition(5, 2), wxGBSpan(1, 2), wxEXPAND|wxALL, 5);
sbBannerDetails->Add(sBannerDetails, 0, wxEXPAND, 0);
// Filesystem tree
sbTreectrl = new wxStaticBoxSizer(wxVERTICAL, this, wxT("Filesytem:"));
m_Treectrl = new wxTreeCtrl(this, ID_TREECTRL, wxDefaultPosition, wxSize(350, 450)/*wxDefaultSize*/, wxTR_DEFAULT_STYLE, wxDefaultValidator);
sbTreectrl->Add(m_Treectrl, 1, wxEXPAND);
m_Treectrl->AddRoot(wxT("Root"), -1, -1, 0);
/////////////
wxGridBagSizer* sMain;
sMain = new wxGridBagSizer(0, 0);
sMain->Add(sbISODetails, wxGBPosition(0, 0), wxGBSpan(1, 1), wxEXPAND|wxALL, 5);
sMain->Add(sbBannerDetails, wxGBPosition(1, 0), wxGBSpan(1, 1), wxEXPAND|wxALL, 5);
sMain->Add(sbTreectrl, wxGBPosition(0, 1), wxGBSpan(2, 1), wxALL, 5);
sMain->Add(m_Close, wxGBPosition(2, 1), wxGBSpan(1, 1), wxALL|wxALIGN_RIGHT, 5);
this->SetSizer(sMain);
this->Layout();
Fit();
}
void CFilesystemViewer::OnClose(wxCloseEvent& WXUNUSED (event))
{
Destroy();
}
void CFilesystemViewer::OnCloseClick(wxCommandEvent& WXUNUSED (event))
{
Close();
}
void CFilesystemViewer::OnRightClick(wxMouseEvent& WXUNUSED (event))
{
//check for right click on banner image
//if(event.GetId() == ID_SAVEBNR)
//{
// //on banner then save as.
// wxMenu popupMenu;
// popupMenu.Append(IDM_BNRSAVEAS, wxString::FromAscii("Save as..."));
// PopupMenu(&popupMenu);
//}
//event.Skip();
}
void CFilesystemViewer::OnRightClickOnTree(wxTreeEvent& event)
{
wxMenu popupMenu;
popupMenu.Append(IDM_EXTRACTFILE, wxString::FromAscii("Extract File..."));
popupMenu.Append(IDM_REPLACEFILE, wxString::FromAscii("Replace File..."));
popupMenu.Append(IDM_RENAMEFILE, wxString::FromAscii("Rename File..."));
PopupMenu(&popupMenu);
event.Skip();
}
void CFilesystemViewer::OnSaveBNRClick(wxCommandEvent& WXUNUSED (event))
{
}
void CFilesystemViewer::OnBannerImageSave(wxCommandEvent& WXUNUSED (event))
{
}
void CFilesystemViewer::OnExtractFile(wxCommandEvent& WXUNUSED (event))
{
}
void CFilesystemViewer::OnReplaceFile(wxCommandEvent& WXUNUSED (event))
{
}
void CFilesystemViewer::OnRenameFile(wxCommandEvent& WXUNUSED (event))
{
}

View File

@ -0,0 +1,136 @@
// Copyright (C) 2003-2008 Dolphin Project.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, version 2.0.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License 2.0 for more details.
// A copy of the GPL 2.0 should have been included with the program.
// If not, see http://www.gnu.org/licenses/
// Official SVN repository and contact information can be found at
// http://code.google.com/p/dolphin-emu/
#ifndef __FILESYSTEM_VIEWER_h__
#define __FILESYSTEM_VIEWER_h__
#include <wx/sizer.h>
#include <wx/filepicker.h>
#include <wx/statbmp.h>
#include <wx/imaglist.h>
#include <wx/treectrl.h>
#include <wx/gbsizer.h>
#undef FILESYSTEM_VIEWER_STYLE
#define FILESYSTEM_VIEWER_STYLE wxCAPTION | wxSYSTEM_MENU | wxDIALOG_NO_PARENT | wxCLOSE_BOX
class CFilesystemViewer : public wxDialog
{
public:
CFilesystemViewer(const std::string fileName, wxWindow* parent, wxWindowID id = 1, const wxString& title = wxT("Filesystem Viewer"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = FILESYSTEM_VIEWER_STYLE);
virtual ~CFilesystemViewer();
private:
DECLARE_EVENT_TABLE();
wxStaticBoxSizer *sbISODetails;
wxGridBagSizer *sISODetails;
wxStaticBoxSizer *sbBannerDetails;
wxGridBagSizer *sBannerDetails;
wxStaticBoxSizer *sbTreectrl;
wxTreeCtrl *m_Treectrl;
wxButton *m_Close;
wxStaticText *m_NameText;
wxStaticText *m_SerialText;
wxStaticText *m_CountryText;
wxStaticText *m_MakerIDText;
wxStaticText *m_DateText;
wxStaticText *m_TOCText;
wxStaticText *m_VersionText;
wxStaticText *m_LangText;
wxStaticText *m_ShortText;
wxStaticText *m_LongText;
wxStaticText *m_MakerText;
wxStaticText *m_CommentText;
wxStaticText *m_BannerText;
wxTextCtrl *m_Name;
wxTextCtrl *m_Serial;
wxTextCtrl *m_Country;
wxTextCtrl *m_MakerID;
wxTextCtrl *m_Date;
wxTextCtrl *m_TOC;
wxTextCtrl *m_Version;
wxTextCtrl *m_ShortName;
wxTextCtrl *m_LongName;
wxTextCtrl *m_Maker;
wxTextCtrl *m_Comment;
wxTextCtrl *m_Banner;
wxChoice *m_Lang;
wxButton *m_SaveBNR;
enum
{
ID_CLOSE = 1000,
ID_TREECTRL,
ID_NAME_TEXT,
ID_SERIAL_TEXT,
ID_COUNTRY_TEXT,
ID_MAKERID_TEXT,
ID_DATE_TEXT,
ID_TOC_TEXT,
ID_VERSION_TEXT,
ID_LANG_TEXT,
ID_SHORTNAME_TEXT,
ID_LONGNAME_TEXT,
ID_MAKER_TEXT,
ID_COMMENT_TEXT,
ID_BANNER_TEXT,
ID_NAME,
ID_SERIAL,
ID_COUNTRY,
ID_MAKERID,
ID_DATE,
ID_TOC,
ID_VERSION,
ID_LANG,
ID_SHORTNAME,
ID_LONGNAME,
ID_MAKER,
ID_COMMENT,
ID_BANNER,
ID_SAVEBNR,
IDM_EXTRACTFILE,
IDM_REPLACEFILE,
IDM_RENAMEFILE,
IDM_BNRSAVEAS,
ID_DUMMY_VALUE_ //don't remove this value unless you have other enum values
};
void CreateGUIControls();
void OnClose(wxCloseEvent& event);
void OnCloseClick(wxCommandEvent& event);
void OnRightClick(wxMouseEvent& event);
void OnRightClickOnTree(wxTreeEvent& event);
void OnSaveBNRClick(wxCommandEvent& event);
void OnBannerImageSave(wxCommandEvent& event);
void OnExtractFile(wxCommandEvent& event);
void OnReplaceFile(wxCommandEvent& event);
void OnRenameFile(wxCommandEvent& event);
};
#endif

View File

@ -86,7 +86,6 @@ EVT_MENU(IDM_HELPGOOGLECODE, CFrame::OnHelp)
EVT_MENU(IDM_HELPABOUT, CFrame::OnHelp)
EVT_MENU(wxID_REFRESH, CFrame::OnRefresh)
EVT_MENU(IDM_PLAY, CFrame::OnPlay)
EVT_MENU(IDM_PAUSE, CFrame::OnPlay)
EVT_MENU(IDM_STOP, CFrame::OnStop)
EVT_MENU(IDM_PLUGIN_OPTIONS, CFrame::OnPluginOptions)
EVT_MENU(IDM_CONFIG_GFX_PLUGIN, CFrame::OnPluginGFX)

View File

@ -27,6 +27,7 @@
#include "Config.h"
#include "GameListCtrl.h"
#include "Blob.h"
#include "FilesystemViewer.h"
#if USE_XPM_BITMAPS
#include "../resources/Flag_Europe.xpm"
@ -35,6 +36,22 @@
#include "../resources/Flag_USA.xpm"
#endif // USE_XPM_BITMAPS
/////////////////////////////////
int currentColumn ;
bool operator < (const CISOFile &one, const CISOFile &other)
{
switch(currentColumn)
{
case CGameListCtrl::COLUMN_TITLE: return strcasecmp(one.GetName().c_str(), other.GetName().c_str()) < 0;
case CGameListCtrl::COLUMN_COMPANY: return strcasecmp(one.GetCompany().c_str(), other.GetCompany().c_str()) < 0;
case CGameListCtrl::COLUMN_NOTES: return strcasecmp(one.GetDescription().c_str(), other.GetDescription().c_str()) < 0;
case CGameListCtrl::COLUMN_COUNTRY: return (one.GetCountry() < other.GetCountry());
case CGameListCtrl::COLUMN_SIZE: return (one.GetFileSize() < other.GetFileSize());
default: return strcasecmp(one.GetName().c_str(), other.GetName().c_str()) < 0;
}
}
/////////////////////////////////
BEGIN_EVENT_TABLE(CGameListCtrl, wxListCtrl)
EVT_SIZE(CGameListCtrl::OnSize)
@ -42,10 +59,12 @@ EVT_RIGHT_DOWN(CGameListCtrl::OnRightClick)
EVT_LIST_COL_BEGIN_DRAG(LIST_CTRL, CGameListCtrl::OnColBeginDrag)
EVT_LIST_ITEM_SELECTED(LIST_CTRL, CGameListCtrl::OnSelected)
EVT_LIST_ITEM_ACTIVATED(LIST_CTRL, CGameListCtrl::OnActivated)
EVT_LIST_COL_CLICK(LIST_CTRL, CGameListCtrl::OnColumnClick)
EVT_LIST_COL_END_DRAG(LIST_CTRL, CGameListCtrl::OnColEndDrag)
EVT_MENU(IDM_EDITPATCHFILE, CGameListCtrl::OnEditPatchFile)
EVT_MENU(IDM_OPENCONTAININGFOLDER, CGameListCtrl::OnOpenContainingFolder)
EVT_MENU(IDM_SETDEFAULTGCM, CGameListCtrl::OnSetDefaultGCM)
EVT_MENU(IDM_FILESYSTEMVIEWER, CGameListCtrl::OnFilesystemViewer)
EVT_MENU(IDM_COMPRESSGCM, CGameListCtrl::OnCompressGCM)
END_EVENT_TABLE()
@ -142,13 +161,6 @@ void CGameListCtrl::Update()
Show();
}
#ifdef _WIN32
wxColour blend50(const wxColour& c1, const wxColour& c2)
{
return(((c1.GetPixel() & 0xFEFEFE) >> 1) + ((c2.GetPixel() & 0xFEFEFE) >> 1) + 0x010101);
}
#endif
wxString NiceSizeFormat(s64 _size)
{
const char* sizes[] = {"b", "KB", "MB", "GB", "TB", "PB", "EB"};
@ -185,18 +197,15 @@ void CGameListCtrl::InsertItemInReportView(long _Index)
// data
wxString buf;
long ItemIndex = InsertItem(_Index, buf, ImageIndex);
#ifdef _WIN32
wxColour color = (_Index & 1) ? blend50(GetSysColor(COLOR_3DLIGHT), GetSysColor(COLOR_WINDOW)) : GetSysColor(COLOR_WINDOW);
#else
wxColour color = (_Index & 1) ? 0xFFFFFF : 0xEEEEEE;
#endif
// background color
{
SetBackgroundColor(); //temp fix so we can colorize background after sorting
/*{
wxListItem item;
item.SetId(ItemIndex);
item.SetBackgroundColour(color);
SetItem(item);
}
}*/
// title
{
@ -259,6 +268,50 @@ void CGameListCtrl::InsertItemInReportView(long _Index)
SetItemData(ItemIndex, _Index);
}
bool CGameListCtrl::MSWDrawSubItem(wxPaintDC& rPaintDC, int item, int subitem)
{
bool Result = false;
#ifdef __WXMSW__
switch (subitem)
{
case COLUMN_COUNTRY:
{
size_t Index = GetItemData(item);
if (Index < m_ISOFiles.size())
{
const CISOFile& rISO = m_ISOFiles[Index];
wxRect SubItemRect;
this->GetSubItemRect(item, subitem, SubItemRect);
m_imageListSmall->Draw(m_FlagImageIndex[rISO.GetCountry()], rPaintDC, SubItemRect.GetLeft(), SubItemRect.GetTop());
}
}
}
#endif
return(Result);
}
#ifdef _WIN32
wxColour blend50(const wxColour& c1, const wxColour& c2)
{
return(((c1.GetPixel() & 0xFEFEFE) >> 1) + ((c2.GetPixel() & 0xFEFEFE) >> 1) + 0x010101);
}
#endif
void CGameListCtrl::SetBackgroundColor()
{
for(long i = 0; i <= GetItemCount(); i++)
{
#ifdef _WIN32
wxColour color = (i & 1) ? blend50(GetSysColor(COLOR_3DLIGHT), GetSysColor(COLOR_WINDOW)) : GetSysColor(COLOR_WINDOW);
#else
wxColour color = (i & 1) ? 0xFFFFFF : 0xEEEEEE;
#endif
CGameListCtrl::SetItemBackgroundColour(i, color);
}
}
void CGameListCtrl::ScanForISOs()
{
m_ISOFiles.clear();
@ -325,6 +378,74 @@ void CGameListCtrl::OnColBeginDrag(wxListEvent& event)
event.Veto();
}
const CISOFile * CGameListCtrl::GetISO(int index) const
{
return &m_ISOFiles[index];
}
CGameListCtrl *caller;
int wxCALLBACK wxListCompare(long item1, long item2, long sortData)
{
//return 1 if item1 > item2
//return -1 if item1 < item2
//0 for identity
const CISOFile *iso1 = caller->GetISO(item1);
const CISOFile *iso2 = caller->GetISO(item2);
int t = 1;
if(sortData<0)
{
t=-1;
sortData = -sortData;
}
switch(sortData)
{
case CGameListCtrl::COLUMN_TITLE:
return strcasecmp(iso1->GetName().c_str(),iso2->GetName().c_str()) *t;
case CGameListCtrl::COLUMN_COMPANY:
return strcasecmp(iso1->GetCompany().c_str(),iso2->GetCompany().c_str()) *t;
case CGameListCtrl::COLUMN_NOTES:
return strcasecmp(iso1->GetDescription().c_str(),iso2->GetDescription().c_str()) *t;
case CGameListCtrl::COLUMN_COUNTRY:
if(iso1->GetCountry() > iso2->GetCountry()) return 1 *t;
if(iso1->GetCountry() < iso2->GetCountry()) return -1 *t;
return 0;
case CGameListCtrl::COLUMN_SIZE:
if (iso1->GetFileSize() > iso2->GetFileSize()) return 1 *t;
if (iso1->GetFileSize() < iso2->GetFileSize()) return -1 *t;
return 0;
}
return 0;
}
void CGameListCtrl::OnColumnClick(wxListEvent& event)
{
if(event.GetColumn() != COLUMN_BANNER && event.GetColumn() != COLUMN_EMULATION_STATE)
{
int current_column = event.GetColumn();
if(last_column == current_column)
{
last_sort = -last_sort;
}
else
{
last_column = current_column;
last_sort = current_column;
}
caller = this;
SortItems(wxListCompare, last_sort);
}
SetBackgroundColor();
event.Skip();
}
void CGameListCtrl::OnColEndDrag(wxListEvent& WXUNUSED (event))
{
}
@ -346,9 +467,10 @@ void CGameListCtrl::OnRightClick(wxMouseEvent& event)
popupMenu.Append(IDM_EDITPATCHFILE, wxString::FromAscii(menu_text.c_str())); //Pretty much everything in wxwidgets is a wxString, try to convert to those first!
popupMenu.Append(IDM_OPENCONTAININGFOLDER, wxString::FromAscii("Open &containing folder"));
popupMenu.Append(IDM_SETDEFAULTGCM, wxString::FromAscii("Set as &default ISO"));
//popupMenu.Append(IDM_FILESYSTEMVIEWER, wxString::FromAscii("Open in ISO viewer/dumper"));
/* F|RES: compression doesn't work and will be rewritten ... if it is done reactivated this code the gui is ready :D
if (selected_iso->IsCompressed())
// F|RES: compression doesn't work and will be rewritten ... if it is fixed the gui is ready :D
/*if (selected_iso->IsCompressed())
popupMenu.Append(IDM_COMPRESSGCM, wxString::FromAscii("Decompress ISO... (UNTESTED)"));
else
popupMenu.Append(IDM_COMPRESSGCM, wxString::FromAscii("Compress ISO... (UNTESTED)"));
@ -401,6 +523,14 @@ void CGameListCtrl::OnSetDefaultGCM(wxCommandEvent& WXUNUSED (event)) {
SConfig::GetInstance().SaveSettings();
}
void CGameListCtrl::OnFilesystemViewer(wxCommandEvent& WXUNUSED (event)) {
const CISOFile *iso = GetSelectedISO();
if (!iso)
return;
CFilesystemViewer FSViewer(iso->GetFileName(), this);
FSViewer.ShowModal();
}
void CGameListCtrl::CompressCB(const char* text, float percent, void* arg)
{
wxProgressDialog* pDialog = (wxProgressDialog*)arg;
@ -505,30 +635,6 @@ void CGameListCtrl::OnSize(wxSizeEvent& event)
event.Skip();
}
bool CGameListCtrl::MSWDrawSubItem(wxPaintDC& rPaintDC, int item, int subitem)
{
bool Result = false;
#ifdef __WXMSW__
switch (subitem)
{
case COLUMN_COUNTRY:
{
size_t Index = GetItemData(item);
if (Index < m_ISOFiles.size())
{
const CISOFile& rISO = m_ISOFiles[Index];
wxRect SubItemRect;
this->GetSubItemRect(item, subitem, SubItemRect);
m_imageListSmall->Draw(m_FlagImageIndex[rISO.GetCountry()], rPaintDC, SubItemRect.GetLeft(), SubItemRect.GetTop());
}
}
}
#endif
return(Result);
}
void CGameListCtrl::AutomaticColumnWidth()
{
wxRect rc(GetClientRect());

View File

@ -32,8 +32,7 @@ class CGameListCtrl : public wxListCtrl
void Update();
void BrowseForDirectory();
const CISOFile *GetSelectedISO() const;
private:
const CISOFile *GetISO(int index) const;
enum
{
@ -47,20 +46,24 @@ class CGameListCtrl : public wxListCtrl
NUMBER_OF_COLUMN
};
std::vector<int>m_FlagImageIndex;
private:
bool m_test;
std::vector<int>m_FlagImageIndex;
std::vector<CISOFile> m_ISOFiles;
int last_column;
int last_sort;
void InitBitmaps();
void InsertItemInReportView(long _Index);
void SetBackgroundColor();
void ScanForISOs();
DECLARE_EVENT_TABLE()
// events
void OnRightClick(wxMouseEvent& event);
void OnColumnClick(wxListEvent& event);
void OnColBeginDrag(wxListEvent& event);
void OnColEndDrag(wxListEvent& event);
void OnSelected(wxListEvent& event);
@ -70,6 +73,7 @@ class CGameListCtrl : public wxListCtrl
void OnOpenContainingFolder(wxCommandEvent& event);
void OnSetDefaultGCM(wxCommandEvent& event);
void OnCompressGCM(wxCommandEvent& event);
void OnFilesystemViewer(wxCommandEvent& event);
virtual bool MSWDrawSubItem(wxPaintDC& rPaintDC, int item, int subitem);

View File

@ -43,13 +43,13 @@ enum
IDM_LOADSLOT9,
IDM_LOADSLOT10,
IDM_PLAY,
IDM_PAUSE,
IDM_STOP,
IDM_BROWSE,
IDM_MEMCARD,
IDM_EDITPATCHFILE,
IDM_OPENCONTAININGFOLDER,
IDM_SETDEFAULTGCM,
IDM_FILESYSTEMVIEWER,
IDM_COMPRESSGCM,
IDM_PLUGIN_OPTIONS,
IDM_CONFIG_GFX_PLUGIN,

View File

@ -47,11 +47,6 @@ class CISOFile
const wxImage& GetImage() const {return(m_Image);}
bool operator < (const CISOFile &other) const {
// HACK - they end up in reverse order in the list view
return strcasecmp(m_Name.c_str(), other.m_Name.c_str()) < 0;
}
private:
std::string m_FileName;

View File

@ -46,13 +46,13 @@ extern "C" {
#endif
// plugin types
#define PLUGIN_TYPE_VIDEO 1
#define PLUGIN_TYPE_DVD 2
#define PLUGIN_TYPE_PAD 3
#define PLUGIN_TYPE_AUDIO 4
#define PLUGIN_TYPE_COMPILER 5
#define PLUGIN_TYPE_DSP 6
#define PLUGIN_TYPE_WIIMOTE 7
#define PLUGIN_TYPE_VIDEO 1
#define PLUGIN_TYPE_DVD 2
#define PLUGIN_TYPE_PAD 3
#define PLUGIN_TYPE_AUDIO 4
#define PLUGIN_TYPE_COMPILER 5
#define PLUGIN_TYPE_DSP 6
#define PLUGIN_TYPE_WIIMOTE 7
#define STATE_MODE_READ 1
#define STATE_MODE_WRITE 2
@ -61,9 +61,9 @@ extern "C" {
typedef struct
{
u16 Version; // Set to 0x0100
u16 Type; // Set to PLUGIN_TYPE_DVD
char Name[100]; // Name of the DLL
u16 Version; // Set to 0x0100
u16 Type; // Set to PLUGIN_TYPE_DVD
char Name[100]; // Name of the DLL
} PLUGIN_INFO;
typedef struct