2015-05-23 22:55:12 -06:00
|
|
|
// Copyright 2008 Dolphin Emulator Project
|
2015-05-17 17:08:10 -06:00
|
|
|
// Licensed under GPLv2+
|
2013-04-17 21:43:35 -06:00
|
|
|
// Refer to the license.txt file included.
|
2008-12-07 22:30:24 -07:00
|
|
|
|
|
|
|
#include <algorithm>
|
2013-10-26 03:55:41 -06:00
|
|
|
#include <cinttypes>
|
2014-02-22 15:36:30 -07:00
|
|
|
#include <cstddef>
|
|
|
|
#include <cstdio>
|
|
|
|
#include <cstring>
|
2011-03-22 03:40:47 -06:00
|
|
|
#include <memory>
|
2014-02-22 15:36:30 -07:00
|
|
|
#include <string>
|
2016-08-14 13:54:01 -06:00
|
|
|
#include <utility>
|
2014-02-22 15:36:30 -07:00
|
|
|
#include <vector>
|
2016-05-29 08:49:11 -06:00
|
|
|
#include <wx/app.h>
|
2014-02-22 15:36:30 -07:00
|
|
|
#include <wx/bitmap.h>
|
|
|
|
#include <wx/buffer.h>
|
|
|
|
#include <wx/colour.h>
|
|
|
|
#include <wx/dirdlg.h>
|
|
|
|
#include <wx/filedlg.h>
|
|
|
|
#include <wx/filefn.h>
|
2014-02-18 18:56:29 -07:00
|
|
|
#include <wx/filename.h>
|
2015-12-19 03:34:01 -07:00
|
|
|
#include <wx/gdicmn.h>
|
2014-02-18 18:56:29 -07:00
|
|
|
#include <wx/imaglist.h>
|
2014-02-22 15:36:30 -07:00
|
|
|
#include <wx/listctrl.h>
|
|
|
|
#include <wx/menu.h>
|
|
|
|
#include <wx/msgdlg.h>
|
|
|
|
#include <wx/progdlg.h>
|
|
|
|
#include <wx/settings.h>
|
|
|
|
#include <wx/tipwin.h>
|
2015-10-10 20:44:53 -06:00
|
|
|
#include <wx/wxcrt.h>
|
2008-12-07 22:30:24 -07:00
|
|
|
|
2016-08-03 09:03:18 -06:00
|
|
|
#ifdef __WXMSW__
|
|
|
|
#include <CommCtrl.h>
|
|
|
|
#include <wx/msw/dc.h>
|
|
|
|
#endif
|
|
|
|
|
2014-02-17 03:18:15 -07:00
|
|
|
#include "Common/CDUtils.h"
|
2014-10-22 15:25:00 -06:00
|
|
|
#include "Common/CommonPaths.h"
|
2014-09-07 19:06:58 -06:00
|
|
|
#include "Common/CommonTypes.h"
|
2014-02-17 03:18:15 -07:00
|
|
|
#include "Common/FileUtil.h"
|
|
|
|
#include "Common/StringUtil.h"
|
2017-06-20 17:36:59 -06:00
|
|
|
#include "Common/Thread.h"
|
2016-06-24 02:43:46 -06:00
|
|
|
#include "Core/Boot/Boot.h"
|
2017-08-02 17:52:26 -06:00
|
|
|
#include "Core/Config/NetplaySettings.h"
|
2014-02-17 03:18:15 -07:00
|
|
|
#include "Core/ConfigManager.h"
|
|
|
|
#include "Core/Core.h"
|
2017-03-24 12:17:52 -06:00
|
|
|
#include "Core/HW/DVD/DVDInterface.h"
|
2014-09-07 07:57:49 -06:00
|
|
|
#include "Core/HW/WiiSaveCrypted.h"
|
2016-06-24 02:43:46 -06:00
|
|
|
#include "Core/Movie.h"
|
2018-03-11 04:43:54 -06:00
|
|
|
#include "Core/SysConf.h"
|
2017-05-15 08:26:22 -06:00
|
|
|
#include "Core/TitleDatabase.h"
|
2017-12-31 12:33:36 -07:00
|
|
|
#include "Core/WiiUtils.h"
|
2014-02-17 03:18:15 -07:00
|
|
|
#include "DiscIO/Blob.h"
|
2016-07-06 12:33:05 -06:00
|
|
|
#include "DiscIO/Enums.h"
|
2014-02-22 15:36:30 -07:00
|
|
|
#include "DiscIO/Volume.h"
|
|
|
|
#include "DolphinWX/Frame.h"
|
2014-02-17 03:18:15 -07:00
|
|
|
#include "DolphinWX/GameListCtrl.h"
|
|
|
|
#include "DolphinWX/Globals.h"
|
2016-11-12 18:51:08 -07:00
|
|
|
#include "DolphinWX/ISOProperties/ISOProperties.h"
|
2014-02-17 03:18:15 -07:00
|
|
|
#include "DolphinWX/Main.h"
|
2016-10-03 06:35:27 -06:00
|
|
|
#include "DolphinWX/NetPlay/NetPlayLauncher.h"
|
2014-02-17 03:18:15 -07:00
|
|
|
#include "DolphinWX/WxUtils.h"
|
2017-12-31 12:33:36 -07:00
|
|
|
#include "UICommon/GameFile.h"
|
|
|
|
#include "UICommon/GameFileCache.h"
|
|
|
|
#include "UICommon/UICommon.h"
|
2008-12-07 22:30:24 -07:00
|
|
|
|
2015-12-17 10:50:09 -07:00
|
|
|
struct CompressionProgress final
|
|
|
|
{
|
|
|
|
public:
|
2016-06-24 02:43:46 -06:00
|
|
|
CompressionProgress(int items_done_, int items_total_, const std::string& current_filename_,
|
|
|
|
wxProgressDialog* dialog_)
|
|
|
|
: items_done(items_done_), items_total(items_total_), current_filename(current_filename_),
|
|
|
|
dialog(dialog_)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
int items_done;
|
|
|
|
int items_total;
|
|
|
|
std::string current_filename;
|
|
|
|
wxProgressDialog* dialog;
|
2015-12-17 10:50:09 -07:00
|
|
|
};
|
|
|
|
|
2014-07-08 07:58:25 -06:00
|
|
|
static bool sorted = false;
|
2008-12-07 22:30:24 -07:00
|
|
|
|
2017-12-31 12:33:36 -07:00
|
|
|
static int CompareGameListItems(const UICommon::GameFile* iso1, const UICommon::GameFile* iso2,
|
2017-06-19 03:20:14 -06:00
|
|
|
long sortData = GameListCtrl::COLUMN_TITLE)
|
2008-12-07 22:30:24 -07:00
|
|
|
{
|
2016-06-24 02:43:46 -06:00
|
|
|
int t = 1;
|
|
|
|
|
|
|
|
if (sortData < 0)
|
|
|
|
{
|
|
|
|
t = -1;
|
|
|
|
sortData = -sortData;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (sortData)
|
|
|
|
{
|
2017-06-19 03:20:14 -06:00
|
|
|
case GameListCtrl::COLUMN_MAKER:
|
2017-07-14 16:17:52 -06:00
|
|
|
{
|
2017-12-31 12:33:36 -07:00
|
|
|
int maker_cmp = strcasecmp(iso1->GetMaker().c_str(), iso2->GetMaker().c_str()) * t;
|
2017-07-14 16:17:52 -06:00
|
|
|
if (maker_cmp != 0)
|
|
|
|
return maker_cmp;
|
|
|
|
break;
|
|
|
|
}
|
2017-06-19 03:20:14 -06:00
|
|
|
case GameListCtrl::COLUMN_FILENAME:
|
2017-12-31 12:33:36 -07:00
|
|
|
return wxStricmp(wxFileNameFromPath(iso1->GetFilePath()),
|
|
|
|
wxFileNameFromPath(iso2->GetFilePath())) *
|
2016-06-24 02:43:46 -06:00
|
|
|
t;
|
2017-06-19 03:20:14 -06:00
|
|
|
case GameListCtrl::COLUMN_ID:
|
2017-07-14 16:17:52 -06:00
|
|
|
{
|
|
|
|
int id_cmp = strcasecmp(iso1->GetGameID().c_str(), iso2->GetGameID().c_str()) * t;
|
|
|
|
if (id_cmp != 0)
|
|
|
|
return id_cmp;
|
|
|
|
break;
|
|
|
|
}
|
2017-06-19 03:20:14 -06:00
|
|
|
case GameListCtrl::COLUMN_COUNTRY:
|
2016-06-24 02:43:46 -06:00
|
|
|
if (iso1->GetCountry() > iso2->GetCountry())
|
|
|
|
return 1 * t;
|
|
|
|
if (iso1->GetCountry() < iso2->GetCountry())
|
|
|
|
return -1 * t;
|
2017-07-14 16:17:52 -06:00
|
|
|
break;
|
2017-06-19 03:20:14 -06:00
|
|
|
case GameListCtrl::COLUMN_SIZE:
|
2016-06-24 02:43:46 -06:00
|
|
|
if (iso1->GetFileSize() > iso2->GetFileSize())
|
|
|
|
return 1 * t;
|
|
|
|
if (iso1->GetFileSize() < iso2->GetFileSize())
|
|
|
|
return -1 * t;
|
2017-07-14 16:17:52 -06:00
|
|
|
break;
|
2017-06-19 03:20:14 -06:00
|
|
|
case GameListCtrl::COLUMN_PLATFORM:
|
2016-06-24 02:43:46 -06:00
|
|
|
if (iso1->GetPlatform() > iso2->GetPlatform())
|
|
|
|
return 1 * t;
|
|
|
|
if (iso1->GetPlatform() < iso2->GetPlatform())
|
|
|
|
return -1 * t;
|
2017-07-14 16:17:52 -06:00
|
|
|
break;
|
2016-06-24 02:43:46 -06:00
|
|
|
}
|
|
|
|
|
2017-07-14 16:17:52 -06:00
|
|
|
if (sortData != GameListCtrl::COLUMN_TITLE)
|
|
|
|
t = 1;
|
|
|
|
|
|
|
|
int name_cmp = strcasecmp(iso1->GetName().c_str(), iso2->GetName().c_str()) * t;
|
|
|
|
if (name_cmp != 0)
|
|
|
|
return name_cmp;
|
|
|
|
|
|
|
|
if (iso1->GetGameID() != iso2->GetGameID())
|
|
|
|
return t * (iso1->GetGameID() > iso2->GetGameID() ? 1 : -1);
|
|
|
|
if (iso1->GetRevision() != iso2->GetRevision())
|
|
|
|
return t * (iso1->GetRevision() > iso2->GetRevision() ? 1 : -1);
|
|
|
|
if (iso1->GetDiscNumber() != iso2->GetDiscNumber())
|
|
|
|
return t * (iso1->GetDiscNumber() > iso2->GetDiscNumber() ? 1 : -1);
|
|
|
|
|
2017-12-31 12:33:36 -07:00
|
|
|
wxString iso1_filename = wxFileNameFromPath(iso1->GetFilePath());
|
|
|
|
wxString iso2_filename = wxFileNameFromPath(iso2->GetFilePath());
|
2017-07-14 16:17:52 -06:00
|
|
|
|
|
|
|
if (iso1_filename != iso2_filename)
|
|
|
|
return t * wxStricmp(iso1_filename, iso2_filename);
|
|
|
|
|
2016-06-24 02:43:46 -06:00
|
|
|
return 0;
|
2008-12-07 22:30:24 -07:00
|
|
|
}
|
|
|
|
|
2017-12-31 12:33:36 -07:00
|
|
|
static bool ShouldDisplayGameListItem(const UICommon::GameFile& item)
|
2017-02-08 22:58:41 -07:00
|
|
|
{
|
|
|
|
const bool show_platform = [&item] {
|
|
|
|
switch (item.GetPlatform())
|
|
|
|
{
|
2018-03-31 06:04:13 -06:00
|
|
|
case DiscIO::Platform::GameCubeDisc:
|
2017-02-08 22:58:41 -07:00
|
|
|
return SConfig::GetInstance().m_ListGC;
|
2018-03-31 06:04:13 -06:00
|
|
|
case DiscIO::Platform::WiiDisc:
|
2017-02-08 22:58:41 -07:00
|
|
|
return SConfig::GetInstance().m_ListWii;
|
2018-03-31 06:04:13 -06:00
|
|
|
case DiscIO::Platform::WiiWAD:
|
2017-02-08 22:58:41 -07:00
|
|
|
return SConfig::GetInstance().m_ListWad;
|
2018-03-31 06:04:13 -06:00
|
|
|
case DiscIO::Platform::ELFOrDOL:
|
2017-02-08 22:58:41 -07:00
|
|
|
return SConfig::GetInstance().m_ListElfDol;
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}();
|
|
|
|
|
|
|
|
if (!show_platform)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
switch (item.GetCountry())
|
|
|
|
{
|
2018-03-31 06:04:13 -06:00
|
|
|
case DiscIO::Country::Australia:
|
2017-02-08 22:58:41 -07:00
|
|
|
return SConfig::GetInstance().m_ListAustralia;
|
2018-03-31 06:04:13 -06:00
|
|
|
case DiscIO::Country::Europe:
|
2017-02-08 22:58:41 -07:00
|
|
|
return SConfig::GetInstance().m_ListPal;
|
2018-03-31 06:04:13 -06:00
|
|
|
case DiscIO::Country::France:
|
2017-02-08 22:58:41 -07:00
|
|
|
return SConfig::GetInstance().m_ListFrance;
|
2018-03-31 06:04:13 -06:00
|
|
|
case DiscIO::Country::Germany:
|
2017-02-08 22:58:41 -07:00
|
|
|
return SConfig::GetInstance().m_ListGermany;
|
2018-03-31 06:04:13 -06:00
|
|
|
case DiscIO::Country::Italy:
|
2017-02-08 22:58:41 -07:00
|
|
|
return SConfig::GetInstance().m_ListItaly;
|
2018-03-31 06:04:13 -06:00
|
|
|
case DiscIO::Country::Japan:
|
2017-02-08 22:58:41 -07:00
|
|
|
return SConfig::GetInstance().m_ListJap;
|
2018-03-31 06:04:13 -06:00
|
|
|
case DiscIO::Country::Korea:
|
2017-02-08 22:58:41 -07:00
|
|
|
return SConfig::GetInstance().m_ListKorea;
|
2018-03-31 06:04:13 -06:00
|
|
|
case DiscIO::Country::Netherlands:
|
2017-02-08 22:58:41 -07:00
|
|
|
return SConfig::GetInstance().m_ListNetherlands;
|
2018-03-31 06:04:13 -06:00
|
|
|
case DiscIO::Country::Russia:
|
2017-02-08 22:58:41 -07:00
|
|
|
return SConfig::GetInstance().m_ListRussia;
|
2018-03-31 06:04:13 -06:00
|
|
|
case DiscIO::Country::Spain:
|
2017-02-08 22:58:41 -07:00
|
|
|
return SConfig::GetInstance().m_ListSpain;
|
2018-03-31 06:04:13 -06:00
|
|
|
case DiscIO::Country::Taiwan:
|
2017-02-08 22:58:41 -07:00
|
|
|
return SConfig::GetInstance().m_ListTaiwan;
|
2018-03-31 06:04:13 -06:00
|
|
|
case DiscIO::Country::USA:
|
2017-02-08 22:58:41 -07:00
|
|
|
return SConfig::GetInstance().m_ListUsa;
|
2018-03-31 06:04:13 -06:00
|
|
|
case DiscIO::Country::World:
|
2017-02-08 22:58:41 -07:00
|
|
|
return SConfig::GetInstance().m_ListWorld;
|
2018-03-31 06:04:13 -06:00
|
|
|
case DiscIO::Country::Unknown:
|
2017-02-08 22:58:41 -07:00
|
|
|
default:
|
|
|
|
return SConfig::GetInstance().m_ListUnknown;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-06-20 17:36:59 -06:00
|
|
|
wxDEFINE_EVENT(DOLPHIN_EVT_REFRESH_GAMELIST, wxCommandEvent);
|
|
|
|
wxDEFINE_EVENT(DOLPHIN_EVT_RESCAN_GAMELIST, wxCommandEvent);
|
2016-11-05 18:53:40 -06:00
|
|
|
|
2017-06-19 03:20:14 -06:00
|
|
|
struct GameListCtrl::ColumnInfo
|
2017-04-28 09:35:23 -06:00
|
|
|
{
|
|
|
|
const int id;
|
|
|
|
const int default_width;
|
|
|
|
const bool resizable;
|
|
|
|
bool& visible;
|
|
|
|
};
|
|
|
|
|
2017-06-20 17:36:59 -06:00
|
|
|
GameListCtrl::GameListCtrl(bool disable_scanning, wxWindow* parent, const wxWindowID id,
|
|
|
|
const wxPoint& pos, const wxSize& size, long style)
|
2017-06-15 20:29:26 -06:00
|
|
|
: wxListCtrl(parent, id, pos, size, style),
|
2017-04-28 09:35:23 -06:00
|
|
|
m_columns({// {COLUMN, {default_width (without platform padding), resizability, visibility}}
|
|
|
|
{COLUMN_PLATFORM, 32 + 1 /* icon padding */, false,
|
|
|
|
SConfig::GetInstance().m_showSystemColumn},
|
|
|
|
{COLUMN_BANNER, 96, false, SConfig::GetInstance().m_showBannerColumn},
|
|
|
|
{COLUMN_TITLE, 175, true, SConfig::GetInstance().m_showTitleColumn},
|
|
|
|
{COLUMN_MAKER, 150, true, SConfig::GetInstance().m_showMakerColumn},
|
|
|
|
{COLUMN_FILENAME, 100, true, SConfig::GetInstance().m_showFileNameColumn},
|
|
|
|
{COLUMN_ID, 75, false, SConfig::GetInstance().m_showIDColumn},
|
|
|
|
{COLUMN_COUNTRY, 32, false, SConfig::GetInstance().m_showRegionColumn},
|
|
|
|
{COLUMN_SIZE, wxLIST_AUTOSIZE, false, SConfig::GetInstance().m_showSizeColumn}})
|
2008-12-07 22:30:24 -07:00
|
|
|
{
|
2017-06-19 03:20:14 -06:00
|
|
|
Bind(wxEVT_SIZE, &GameListCtrl::OnSize, this);
|
|
|
|
Bind(wxEVT_RIGHT_DOWN, &GameListCtrl::OnRightClick, this);
|
|
|
|
Bind(wxEVT_LEFT_DOWN, &GameListCtrl::OnLeftClick, this);
|
|
|
|
Bind(wxEVT_LIST_KEY_DOWN, &GameListCtrl::OnKeyPress, this);
|
|
|
|
Bind(wxEVT_LIST_COL_BEGIN_DRAG, &GameListCtrl::OnColBeginDrag, this);
|
|
|
|
Bind(wxEVT_LIST_COL_CLICK, &GameListCtrl::OnColumnClick, this);
|
|
|
|
|
|
|
|
Bind(wxEVT_MENU, &GameListCtrl::OnProperties, this, IDM_PROPERTIES);
|
|
|
|
Bind(wxEVT_MENU, &GameListCtrl::OnWiki, this, IDM_GAME_WIKI);
|
|
|
|
Bind(wxEVT_MENU, &GameListCtrl::OnOpenContainingFolder, this, IDM_OPEN_CONTAINING_FOLDER);
|
|
|
|
Bind(wxEVT_MENU, &GameListCtrl::OnOpenSaveFolder, this, IDM_OPEN_SAVE_FOLDER);
|
|
|
|
Bind(wxEVT_MENU, &GameListCtrl::OnExportSave, this, IDM_EXPORT_SAVE);
|
|
|
|
Bind(wxEVT_MENU, &GameListCtrl::OnSetDefaultISO, this, IDM_SET_DEFAULT_ISO);
|
|
|
|
Bind(wxEVT_MENU, &GameListCtrl::OnCompressISO, this, IDM_COMPRESS_ISO);
|
|
|
|
Bind(wxEVT_MENU, &GameListCtrl::OnMultiCompressISO, this, IDM_MULTI_COMPRESS_ISO);
|
|
|
|
Bind(wxEVT_MENU, &GameListCtrl::OnMultiDecompressISO, this, IDM_MULTI_DECOMPRESS_ISO);
|
|
|
|
Bind(wxEVT_MENU, &GameListCtrl::OnDeleteISO, this, IDM_DELETE_ISO);
|
|
|
|
Bind(wxEVT_MENU, &GameListCtrl::OnChangeDisc, this, IDM_LIST_CHANGE_DISC);
|
|
|
|
Bind(wxEVT_MENU, &GameListCtrl::OnNetPlayHost, this, IDM_START_NETPLAY);
|
|
|
|
|
2017-06-20 17:36:59 -06:00
|
|
|
Bind(DOLPHIN_EVT_REFRESH_GAMELIST, &GameListCtrl::OnRefreshGameList, this);
|
|
|
|
Bind(DOLPHIN_EVT_RESCAN_GAMELIST, &GameListCtrl::OnRescanGameList, this);
|
2017-06-19 03:20:14 -06:00
|
|
|
|
|
|
|
wxTheApp->Bind(DOLPHIN_EVT_LOCAL_INI_CHANGED, &GameListCtrl::OnLocalIniModified, this);
|
2017-06-20 17:36:59 -06:00
|
|
|
|
|
|
|
if (!disable_scanning)
|
|
|
|
{
|
|
|
|
m_scan_thread = std::thread([&] {
|
2017-12-31 12:33:36 -07:00
|
|
|
Common::SetCurrentThreadName("Game list scanner");
|
2017-06-20 17:36:59 -06:00
|
|
|
|
2017-12-31 12:33:36 -07:00
|
|
|
if (m_cache.Load())
|
2017-06-20 17:36:59 -06:00
|
|
|
QueueEvent(new wxCommandEvent(DOLPHIN_EVT_REFRESH_GAMELIST));
|
|
|
|
|
2017-06-25 21:13:42 -06:00
|
|
|
// Always do an initial scan to catch new files and perform the more expensive per-file
|
|
|
|
// checks. TODO Make this safely cancellable if it becomes too slow?
|
|
|
|
RescanList();
|
2017-06-20 17:36:59 -06:00
|
|
|
|
|
|
|
m_scan_trigger.Wait();
|
|
|
|
while (!m_scan_exiting.IsSet())
|
|
|
|
{
|
|
|
|
RescanList();
|
|
|
|
m_scan_trigger.Wait();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
GameListCtrl::~GameListCtrl()
|
|
|
|
{
|
|
|
|
if (m_scan_thread.joinable())
|
|
|
|
{
|
|
|
|
m_scan_exiting.Set();
|
|
|
|
m_scan_trigger.Set();
|
|
|
|
m_scan_thread.join();
|
|
|
|
}
|
2008-12-07 22:30:24 -07:00
|
|
|
}
|
|
|
|
|
2016-07-06 12:33:05 -06:00
|
|
|
template <typename T>
|
2016-08-14 13:54:01 -06:00
|
|
|
static void InitBitmap(wxImageList* img_list, std::vector<int>* vector, wxWindow* context,
|
2017-06-02 14:38:56 -06:00
|
|
|
const wxSize& usable_size, T index, const std::string& name,
|
|
|
|
bool themed = false)
|
2008-12-07 22:30:24 -07:00
|
|
|
{
|
2016-08-14 13:54:01 -06:00
|
|
|
wxSize size = img_list->GetSize();
|
2017-06-02 14:38:56 -06:00
|
|
|
auto bitmap_fnc = themed ? WxUtils::LoadScaledThemeBitmap : WxUtils::LoadScaledResourceBitmap;
|
|
|
|
(*vector)[static_cast<size_t>(index)] = img_list->Add(
|
|
|
|
bitmap_fnc(name, context, size, usable_size, WxUtils::LSI_SCALE | WxUtils::LSI_ALIGN_VCENTER,
|
|
|
|
wxTransparentColour));
|
2016-07-06 12:33:05 -06:00
|
|
|
}
|
|
|
|
|
2017-06-19 03:20:14 -06:00
|
|
|
void GameListCtrl::InitBitmaps()
|
2016-07-06 12:33:05 -06:00
|
|
|
{
|
2016-08-14 13:54:01 -06:00
|
|
|
const wxSize size = FromDIP(wxSize(96, 32));
|
|
|
|
const wxSize flag_bmp_size = FromDIP(wxSize(32, 32));
|
|
|
|
const wxSize platform_bmp_size = flag_bmp_size;
|
|
|
|
wxImageList* img_list = new wxImageList(size.GetWidth(), size.GetHeight());
|
2016-06-24 02:43:46 -06:00
|
|
|
AssignImageList(img_list, wxIMAGE_LIST_SMALL);
|
|
|
|
|
2017-06-19 03:25:30 -06:00
|
|
|
auto& flag_indexes = m_image_indexes.flag;
|
2018-03-31 06:04:13 -06:00
|
|
|
flag_indexes.resize(static_cast<size_t>(DiscIO::Country::NumberOfCountries));
|
|
|
|
InitBitmap(img_list, &flag_indexes, this, flag_bmp_size, DiscIO::Country::Japan, "Flag_Japan");
|
|
|
|
InitBitmap(img_list, &flag_indexes, this, flag_bmp_size, DiscIO::Country::Europe, "Flag_Europe");
|
|
|
|
InitBitmap(img_list, &flag_indexes, this, flag_bmp_size, DiscIO::Country::USA, "Flag_USA");
|
|
|
|
InitBitmap(img_list, &flag_indexes, this, flag_bmp_size, DiscIO::Country::Australia,
|
2016-08-14 13:54:01 -06:00
|
|
|
"Flag_Australia");
|
2018-03-31 06:04:13 -06:00
|
|
|
InitBitmap(img_list, &flag_indexes, this, flag_bmp_size, DiscIO::Country::France, "Flag_France");
|
|
|
|
InitBitmap(img_list, &flag_indexes, this, flag_bmp_size, DiscIO::Country::Germany,
|
2016-08-14 13:54:01 -06:00
|
|
|
"Flag_Germany");
|
2018-03-31 06:04:13 -06:00
|
|
|
InitBitmap(img_list, &flag_indexes, this, flag_bmp_size, DiscIO::Country::Italy, "Flag_Italy");
|
|
|
|
InitBitmap(img_list, &flag_indexes, this, flag_bmp_size, DiscIO::Country::Korea, "Flag_Korea");
|
|
|
|
InitBitmap(img_list, &flag_indexes, this, flag_bmp_size, DiscIO::Country::Netherlands,
|
2016-08-14 13:54:01 -06:00
|
|
|
"Flag_Netherlands");
|
2018-03-31 06:04:13 -06:00
|
|
|
InitBitmap(img_list, &flag_indexes, this, flag_bmp_size, DiscIO::Country::Russia, "Flag_Russia");
|
|
|
|
InitBitmap(img_list, &flag_indexes, this, flag_bmp_size, DiscIO::Country::Spain, "Flag_Spain");
|
|
|
|
InitBitmap(img_list, &flag_indexes, this, flag_bmp_size, DiscIO::Country::Taiwan, "Flag_Taiwan");
|
|
|
|
InitBitmap(img_list, &flag_indexes, this, flag_bmp_size, DiscIO::Country::World,
|
2016-08-14 13:54:01 -06:00
|
|
|
"Flag_International");
|
2018-03-31 06:04:13 -06:00
|
|
|
InitBitmap(img_list, &flag_indexes, this, flag_bmp_size, DiscIO::Country::Unknown,
|
2016-08-14 13:54:01 -06:00
|
|
|
"Flag_Unknown");
|
2016-07-06 12:33:05 -06:00
|
|
|
|
2017-06-19 03:25:30 -06:00
|
|
|
auto& platform_indexes = m_image_indexes.platform;
|
2018-03-31 06:04:13 -06:00
|
|
|
platform_indexes.resize(static_cast<size_t>(DiscIO::Platform::NumberOfPlatforms));
|
|
|
|
InitBitmap(img_list, &platform_indexes, this, platform_bmp_size, DiscIO::Platform::GameCubeDisc,
|
2017-06-20 17:36:59 -06:00
|
|
|
"Platform_Gamecube");
|
2018-03-31 06:04:13 -06:00
|
|
|
InitBitmap(img_list, &platform_indexes, this, platform_bmp_size, DiscIO::Platform::WiiDisc,
|
2016-08-14 13:54:01 -06:00
|
|
|
"Platform_Wii");
|
2018-03-31 06:04:13 -06:00
|
|
|
InitBitmap(img_list, &platform_indexes, this, platform_bmp_size, DiscIO::Platform::WiiWAD,
|
2016-08-14 13:54:01 -06:00
|
|
|
"Platform_Wad");
|
2018-03-31 06:04:13 -06:00
|
|
|
InitBitmap(img_list, &platform_indexes, this, platform_bmp_size, DiscIO::Platform::ELFOrDOL,
|
2016-08-14 13:54:01 -06:00
|
|
|
"Platform_File");
|
2016-06-24 02:43:46 -06:00
|
|
|
|
2017-06-19 03:25:30 -06:00
|
|
|
auto& utility_banner_indexes = m_image_indexes.utility_banner;
|
|
|
|
utility_banner_indexes.resize(1);
|
|
|
|
InitBitmap(img_list, &utility_banner_indexes, this, size, 0, "nobanner");
|
2008-12-07 22:30:24 -07:00
|
|
|
}
|
|
|
|
|
2017-06-19 03:20:14 -06:00
|
|
|
void GameListCtrl::BrowseForDirectory()
|
2008-12-07 22:30:24 -07:00
|
|
|
{
|
2016-06-24 02:43:46 -06:00
|
|
|
wxString dirHome;
|
|
|
|
wxGetHomeDir(&dirHome);
|
|
|
|
|
|
|
|
// browse
|
|
|
|
wxDirDialog dialog(this, _("Browse for a directory to add"), dirHome,
|
|
|
|
wxDD_DEFAULT_STYLE | wxDD_DIR_MUST_EXIST);
|
|
|
|
|
|
|
|
if (dialog.ShowModal() == wxID_OK)
|
|
|
|
{
|
|
|
|
std::string sPath(WxStrToStr(dialog.GetPath()));
|
|
|
|
std::vector<std::string>::iterator itResult =
|
|
|
|
std::find(SConfig::GetInstance().m_ISOFolder.begin(),
|
|
|
|
SConfig::GetInstance().m_ISOFolder.end(), sPath);
|
|
|
|
|
|
|
|
if (itResult == SConfig::GetInstance().m_ISOFolder.end())
|
|
|
|
{
|
|
|
|
SConfig::GetInstance().m_ISOFolder.push_back(sPath);
|
|
|
|
SConfig::GetInstance().SaveSettings();
|
2017-06-20 17:36:59 -06:00
|
|
|
m_scan_trigger.Set();
|
2016-06-24 02:43:46 -06:00
|
|
|
}
|
|
|
|
}
|
2008-12-07 22:30:24 -07:00
|
|
|
}
|
|
|
|
|
2017-06-20 17:36:59 -06:00
|
|
|
void GameListCtrl::RefreshList()
|
2008-12-07 22:30:24 -07:00
|
|
|
{
|
2016-06-24 02:43:46 -06:00
|
|
|
int scrollPos = wxWindow::GetScrollPos(wxVERTICAL);
|
|
|
|
// Don't let the user refresh it while a game is running
|
2017-02-05 05:39:58 -07:00
|
|
|
if (Core::GetState() != Core::State::Uninitialized)
|
2016-06-24 02:43:46 -06:00
|
|
|
return;
|
|
|
|
|
2017-06-20 17:36:59 -06:00
|
|
|
m_shown_files.clear();
|
|
|
|
{
|
2017-06-25 21:13:42 -06:00
|
|
|
std::unique_lock<std::mutex> lk(m_cache_mutex);
|
2017-12-31 12:33:36 -07:00
|
|
|
m_cache.ForEach([this](const std::shared_ptr<const UICommon::GameFile>& game_file) {
|
|
|
|
if (ShouldDisplayGameListItem(*game_file))
|
|
|
|
m_shown_files.push_back(game_file);
|
|
|
|
});
|
2017-06-20 17:36:59 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
// Drives are not cached. Not sure if this is required, but better to err on the
|
|
|
|
// side of caution if cross-platform issues could come into play.
|
|
|
|
if (SConfig::GetInstance().m_ListDrives)
|
|
|
|
{
|
2017-06-25 21:13:42 -06:00
|
|
|
std::unique_lock<std::mutex> lk(m_title_database_mutex);
|
2017-06-20 17:36:59 -06:00
|
|
|
for (const auto& drive : cdio_get_devices())
|
|
|
|
{
|
2017-12-31 12:33:36 -07:00
|
|
|
auto file = std::make_shared<UICommon::GameFile>(drive);
|
2017-06-20 17:36:59 -06:00
|
|
|
if (file->IsValid())
|
2017-06-26 14:55:50 -06:00
|
|
|
{
|
|
|
|
if (file->CustomNameChanged(m_title_database))
|
|
|
|
file->CustomNameCommit();
|
2017-06-20 17:36:59 -06:00
|
|
|
m_shown_files.push_back(file);
|
2017-06-26 14:55:50 -06:00
|
|
|
}
|
2017-06-20 17:36:59 -06:00
|
|
|
}
|
|
|
|
}
|
2016-06-24 02:43:46 -06:00
|
|
|
|
|
|
|
Freeze();
|
|
|
|
ClearAll();
|
|
|
|
|
2017-06-20 17:36:59 -06:00
|
|
|
if (!m_shown_files.empty())
|
2016-06-24 02:43:46 -06:00
|
|
|
{
|
|
|
|
// Don't load bitmaps unless there are games to list
|
|
|
|
InitBitmaps();
|
|
|
|
|
|
|
|
// add columns
|
|
|
|
InsertColumn(COLUMN_DUMMY, "");
|
|
|
|
InsertColumn(COLUMN_PLATFORM, "");
|
|
|
|
InsertColumn(COLUMN_BANNER, _("Banner"));
|
|
|
|
InsertColumn(COLUMN_TITLE, _("Title"));
|
|
|
|
|
|
|
|
InsertColumn(COLUMN_MAKER, _("Maker"));
|
|
|
|
InsertColumn(COLUMN_FILENAME, _("File"));
|
|
|
|
InsertColumn(COLUMN_ID, _("ID"));
|
|
|
|
InsertColumn(COLUMN_COUNTRY, "");
|
|
|
|
InsertColumn(COLUMN_SIZE, _("Size"));
|
2011-12-18 05:58:44 -07:00
|
|
|
|
2012-03-22 19:45:11 -06:00
|
|
|
#ifdef __WXMSW__
|
2016-06-24 02:43:46 -06:00
|
|
|
const int platform_padding = 0;
|
2012-03-22 19:45:11 -06:00
|
|
|
#else
|
2016-06-24 02:43:46 -06:00
|
|
|
const int platform_padding = 8;
|
2012-03-22 19:45:11 -06:00
|
|
|
#endif
|
2016-06-24 02:43:46 -06:00
|
|
|
// set initial sizes for columns
|
|
|
|
SetColumnWidth(COLUMN_DUMMY, 0);
|
2017-04-28 09:35:23 -06:00
|
|
|
for (const auto& c : m_columns)
|
|
|
|
{
|
|
|
|
SetColumnWidth(c.id, c.visible ? FromDIP(c.default_width + platform_padding) : 0);
|
|
|
|
}
|
2016-06-24 02:43:46 -06:00
|
|
|
|
|
|
|
// add all items
|
2017-06-20 17:36:59 -06:00
|
|
|
for (int i = 0; i < (int)m_shown_files.size(); i++)
|
2016-06-24 02:43:46 -06:00
|
|
|
InsertItemInReportView(i);
|
2017-05-28 16:02:03 -06:00
|
|
|
SetColors();
|
2016-06-24 02:43:46 -06:00
|
|
|
|
|
|
|
// Sort items by Title
|
|
|
|
if (!sorted)
|
2017-06-19 03:25:30 -06:00
|
|
|
m_last_column = 0;
|
2016-06-24 02:43:46 -06:00
|
|
|
sorted = false;
|
|
|
|
wxListEvent event;
|
|
|
|
event.m_col = SConfig::GetInstance().m_ListSort2;
|
|
|
|
OnColumnClick(event);
|
|
|
|
|
|
|
|
event.m_col = SConfig::GetInstance().m_ListSort;
|
|
|
|
OnColumnClick(event);
|
|
|
|
sorted = true;
|
|
|
|
|
|
|
|
SetColumnWidth(COLUMN_SIZE, SConfig::GetInstance().m_showSizeColumn ? wxLIST_AUTOSIZE : 0);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Remove existing image list and replace it with the smallest possible one.
|
|
|
|
// The list needs an image list because it reserves screen pixels for the
|
|
|
|
// image even if we aren't going to use one. It uses the dimensions of the
|
|
|
|
// last non-null list so assigning nullptr doesn't work.
|
|
|
|
AssignImageList(new wxImageList(1, 1), wxIMAGE_LIST_SMALL);
|
|
|
|
|
|
|
|
wxString errorString;
|
|
|
|
// We just check for one hide setting to be enabled, as we may only
|
|
|
|
// have GC games for example, and hide them, so we should show the
|
|
|
|
// first message instead
|
|
|
|
if (IsHidingItems())
|
|
|
|
{
|
|
|
|
errorString =
|
|
|
|
_("Dolphin is currently set to hide all games. Double-click here to show all games...");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
errorString = _("Dolphin could not find any GameCube/Wii ISOs or WADs. Double-click here to "
|
|
|
|
"set a games directory...");
|
|
|
|
}
|
2017-06-19 03:25:30 -06:00
|
|
|
InsertColumn(COLUMN_DUMMY, "");
|
2016-06-24 02:43:46 -06:00
|
|
|
long index = InsertItem(0, errorString);
|
|
|
|
SetItemFont(index, *wxITALIC_FONT);
|
|
|
|
SetColumnWidth(0, wxLIST_AUTOSIZE);
|
|
|
|
}
|
|
|
|
if (GetSelectedISO() == nullptr)
|
|
|
|
main_frame->UpdateGUI();
|
|
|
|
// Thaw before calling AutomaticColumnWidth so that GetClientSize will
|
|
|
|
// correctly account for the width of scrollbars if they appear.
|
|
|
|
Thaw();
|
|
|
|
|
|
|
|
AutomaticColumnWidth();
|
|
|
|
ScrollLines(scrollPos);
|
|
|
|
SetFocus();
|
2008-12-07 22:30:24 -07:00
|
|
|
}
|
|
|
|
|
2017-06-20 17:36:59 -06:00
|
|
|
// Update the column content of the item at index
|
2017-06-19 03:20:14 -06:00
|
|
|
void GameListCtrl::UpdateItemAtColumn(long index, int column)
|
2015-10-08 07:27:28 -06:00
|
|
|
{
|
2017-06-19 03:25:30 -06:00
|
|
|
const auto& iso_file = *GetISO(GetItemData(index));
|
2016-06-24 02:43:46 -06:00
|
|
|
|
|
|
|
switch (column)
|
|
|
|
{
|
|
|
|
case COLUMN_PLATFORM:
|
|
|
|
{
|
2017-06-19 03:25:30 -06:00
|
|
|
SetItemColumnImage(index, COLUMN_PLATFORM,
|
2017-06-20 17:36:59 -06:00
|
|
|
m_image_indexes.platform[static_cast<size_t>(iso_file.GetPlatform())]);
|
2016-06-24 02:43:46 -06:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case COLUMN_BANNER:
|
|
|
|
{
|
2017-06-19 03:25:30 -06:00
|
|
|
int image_index = m_image_indexes.utility_banner[0]; // nobanner
|
2016-06-24 02:43:46 -06:00
|
|
|
|
2017-12-31 12:33:36 -07:00
|
|
|
wxImage banner = WxUtils::ToWxImage(iso_file.GetBannerImage());
|
|
|
|
if (banner.IsOk())
|
2016-08-03 05:14:52 -06:00
|
|
|
{
|
|
|
|
wxImageList* img_list = GetImageList(wxIMAGE_LIST_SMALL);
|
2017-12-31 12:33:36 -07:00
|
|
|
image_index = img_list->Add(WxUtils::ScaleImageToBitmap(banner, this, img_list->GetSize()));
|
2016-08-03 05:14:52 -06:00
|
|
|
}
|
2016-06-24 02:43:46 -06:00
|
|
|
|
2017-06-19 03:25:30 -06:00
|
|
|
SetItemColumnImage(index, COLUMN_BANNER, image_index);
|
2016-06-24 02:43:46 -06:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case COLUMN_TITLE:
|
|
|
|
{
|
2017-06-19 03:25:30 -06:00
|
|
|
wxString name = StrToWxStr(iso_file.GetName());
|
|
|
|
int disc_number = iso_file.GetDiscNumber() + 1;
|
2016-06-24 02:43:46 -06:00
|
|
|
|
|
|
|
if (disc_number > 1 &&
|
|
|
|
name.Lower().find(wxString::Format("disc %i", disc_number)) == std::string::npos &&
|
|
|
|
name.Lower().find(wxString::Format("disc%i", disc_number)) == std::string::npos)
|
|
|
|
{
|
|
|
|
name = wxString::Format(_("%s (Disc %i)"), name.c_str(), disc_number);
|
|
|
|
}
|
|
|
|
|
2017-06-19 03:25:30 -06:00
|
|
|
SetItem(index, COLUMN_TITLE, name, -1);
|
2016-06-24 02:43:46 -06:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case COLUMN_MAKER:
|
2017-12-31 12:33:36 -07:00
|
|
|
SetItem(index, COLUMN_MAKER, StrToWxStr(iso_file.GetMaker()), -1);
|
2016-06-24 02:43:46 -06:00
|
|
|
break;
|
|
|
|
case COLUMN_FILENAME:
|
2017-12-31 12:33:36 -07:00
|
|
|
SetItem(index, COLUMN_FILENAME, wxFileNameFromPath(StrToWxStr(iso_file.GetFilePath())), -1);
|
2016-06-24 02:43:46 -06:00
|
|
|
break;
|
|
|
|
case COLUMN_COUNTRY:
|
2017-06-19 03:25:30 -06:00
|
|
|
SetItemColumnImage(index, COLUMN_COUNTRY,
|
2017-06-20 17:36:59 -06:00
|
|
|
m_image_indexes.flag[static_cast<size_t>(iso_file.GetCountry())]);
|
2016-06-24 02:43:46 -06:00
|
|
|
break;
|
|
|
|
case COLUMN_SIZE:
|
2017-12-31 12:33:36 -07:00
|
|
|
SetItem(index, COLUMN_SIZE, UICommon::FormatSize(iso_file.GetFileSize()), -1);
|
2016-06-24 02:43:46 -06:00
|
|
|
break;
|
|
|
|
case COLUMN_ID:
|
2017-06-19 03:25:30 -06:00
|
|
|
SetItem(index, COLUMN_ID, iso_file.GetGameID(), -1);
|
2016-06-24 02:43:46 -06:00
|
|
|
break;
|
|
|
|
}
|
2015-10-08 07:27:28 -06:00
|
|
|
}
|
|
|
|
|
2017-06-19 03:20:14 -06:00
|
|
|
void GameListCtrl::InsertItemInReportView(long index)
|
2008-12-07 22:30:24 -07:00
|
|
|
{
|
2016-06-24 02:43:46 -06:00
|
|
|
// When using wxListCtrl, there is no hope of per-column text colors.
|
|
|
|
// But for reference, here are the old colors that were used: (BGR)
|
|
|
|
// title: 0xFF0000
|
|
|
|
// company: 0x007030
|
|
|
|
|
2017-06-19 03:25:30 -06:00
|
|
|
// Insert a first column (COLUMN_DUMMY) with nothing in it to use as the Index
|
2016-06-24 02:43:46 -06:00
|
|
|
long item_index;
|
|
|
|
{
|
|
|
|
wxListItem li;
|
|
|
|
li.SetId(index);
|
|
|
|
li.SetData(index);
|
|
|
|
li.SetMask(wxLIST_MASK_DATA);
|
|
|
|
item_index = InsertItem(li);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Iterate over all columns and fill them with content if they are visible
|
2017-06-19 03:25:30 -06:00
|
|
|
for (int i = FIRST_COLUMN_WITH_CONTENT; i < NUMBER_OF_COLUMN; i++)
|
2016-06-24 02:43:46 -06:00
|
|
|
{
|
|
|
|
if (GetColumnWidth(i) != 0)
|
|
|
|
UpdateItemAtColumn(item_index, i);
|
|
|
|
}
|
2008-12-07 22:30:24 -07:00
|
|
|
}
|
|
|
|
|
2014-07-08 06:29:26 -06:00
|
|
|
static wxColour blend50(const wxColour& c1, const wxColour& c2)
|
2008-12-07 22:30:24 -07:00
|
|
|
{
|
2016-06-24 02:43:46 -06:00
|
|
|
unsigned char r, g, b, a;
|
|
|
|
r = c1.Red() / 2 + c2.Red() / 2;
|
|
|
|
g = c1.Green() / 2 + c2.Green() / 2;
|
|
|
|
b = c1.Blue() / 2 + c2.Blue() / 2;
|
|
|
|
a = c1.Alpha() / 2 + c2.Alpha() / 2;
|
|
|
|
return a << 24 | b << 16 | g << 8 | r;
|
2008-12-07 22:30:24 -07:00
|
|
|
}
|
|
|
|
|
2017-02-19 01:02:00 -07:00
|
|
|
static wxColour ContrastText(const wxColour& bgc)
|
|
|
|
{
|
|
|
|
// Luminance threshold to determine whether to use black text on light background
|
|
|
|
static constexpr int LUM_THRESHOLD = 186;
|
|
|
|
int lum = 0.299 * bgc.Red() + 0.587 * bgc.Green() + 0.114 * bgc.Blue();
|
|
|
|
return (lum > LUM_THRESHOLD) ? *wxBLACK : *wxWHITE;
|
|
|
|
}
|
|
|
|
|
2017-06-19 03:20:14 -06:00
|
|
|
void GameListCtrl::SetColors()
|
2008-12-07 22:30:24 -07:00
|
|
|
{
|
2016-06-24 02:43:46 -06:00
|
|
|
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);
|
2017-05-28 16:02:03 -06:00
|
|
|
SetItemBackgroundColour(i, color);
|
2017-02-19 01:02:00 -07:00
|
|
|
SetItemTextColour(i, ContrastText(color));
|
2016-06-24 02:43:46 -06:00
|
|
|
}
|
2008-12-07 22:30:24 -07:00
|
|
|
}
|
|
|
|
|
2017-06-20 17:36:59 -06:00
|
|
|
void GameListCtrl::RescanList()
|
|
|
|
{
|
2017-06-22 01:53:02 -06:00
|
|
|
auto post_status = [&](const wxString& status) {
|
|
|
|
auto event = new wxCommandEvent(wxEVT_HOST_COMMAND, IDM_UPDATE_STATUS_BAR);
|
|
|
|
event->SetInt(0);
|
|
|
|
event->SetString(status);
|
|
|
|
QueueEvent(event);
|
|
|
|
};
|
|
|
|
|
|
|
|
post_status(_("Scanning..."));
|
|
|
|
|
2017-12-31 12:33:36 -07:00
|
|
|
const std::vector<std::string> game_paths = UICommon::FindAllGamePaths(
|
|
|
|
SConfig::GetInstance().m_ISOFolder, SConfig::GetInstance().m_RecursiveISOFolder);
|
2017-06-20 17:36:59 -06:00
|
|
|
|
2017-06-25 21:13:42 -06:00
|
|
|
// Reload the TitleDatabase
|
|
|
|
{
|
2017-12-31 12:33:36 -07:00
|
|
|
std::unique_lock<std::mutex> lock(m_title_database_mutex);
|
2017-06-25 21:13:42 -06:00
|
|
|
m_title_database = {};
|
|
|
|
}
|
|
|
|
|
|
|
|
bool cache_changed = false;
|
2017-12-31 12:33:36 -07:00
|
|
|
|
2017-06-20 17:36:59 -06:00
|
|
|
{
|
2017-06-25 21:13:42 -06:00
|
|
|
std::unique_lock<std::mutex> lk(m_cache_mutex);
|
2017-12-31 12:33:36 -07:00
|
|
|
if (m_cache.Update(game_paths))
|
2017-06-25 21:13:42 -06:00
|
|
|
{
|
2017-12-31 12:33:36 -07:00
|
|
|
cache_changed = true;
|
|
|
|
QueueEvent(new wxCommandEvent(DOLPHIN_EVT_REFRESH_GAMELIST));
|
2017-06-25 21:13:42 -06:00
|
|
|
}
|
2017-06-20 17:36:59 -06:00
|
|
|
}
|
2017-06-25 21:13:42 -06:00
|
|
|
|
2017-06-20 17:36:59 -06:00
|
|
|
{
|
2017-06-25 21:13:42 -06:00
|
|
|
std::unique_lock<std::mutex> lk(m_cache_mutex);
|
2017-12-31 12:33:36 -07:00
|
|
|
if (m_cache.UpdateAdditionalMetadata(m_title_database))
|
2017-06-25 21:13:42 -06:00
|
|
|
{
|
2017-12-31 12:33:36 -07:00
|
|
|
cache_changed = true;
|
|
|
|
QueueEvent(new wxCommandEvent(DOLPHIN_EVT_REFRESH_GAMELIST));
|
2017-06-25 21:13:42 -06:00
|
|
|
}
|
2017-06-20 17:36:59 -06:00
|
|
|
}
|
|
|
|
|
2017-06-25 21:13:42 -06:00
|
|
|
post_status("");
|
2017-06-20 17:36:59 -06:00
|
|
|
|
2017-06-25 21:13:42 -06:00
|
|
|
if (cache_changed)
|
2017-12-31 12:33:36 -07:00
|
|
|
m_cache.Save();
|
2008-12-07 22:30:24 -07:00
|
|
|
}
|
|
|
|
|
2017-06-20 17:36:59 -06:00
|
|
|
void GameListCtrl::OnRefreshGameList(wxCommandEvent& WXUNUSED(event))
|
2016-11-05 18:53:40 -06:00
|
|
|
{
|
2017-06-20 17:36:59 -06:00
|
|
|
RefreshList();
|
|
|
|
}
|
|
|
|
|
2017-06-25 21:13:42 -06:00
|
|
|
void GameListCtrl::OnRescanGameList(wxCommandEvent& event)
|
2017-06-20 17:36:59 -06:00
|
|
|
{
|
2017-06-25 21:13:42 -06:00
|
|
|
if (event.GetInt())
|
|
|
|
{
|
|
|
|
// Knock out the cache on a purge event
|
|
|
|
std::unique_lock<std::mutex> lk(m_cache_mutex);
|
2017-12-31 12:33:36 -07:00
|
|
|
m_cache.Clear();
|
2017-06-25 21:13:42 -06:00
|
|
|
}
|
2017-06-20 17:36:59 -06:00
|
|
|
m_scan_trigger.Set();
|
2016-11-05 18:53:40 -06:00
|
|
|
}
|
|
|
|
|
2017-06-19 03:20:14 -06:00
|
|
|
void GameListCtrl::OnLocalIniModified(wxCommandEvent& ev)
|
2016-05-29 08:49:11 -06:00
|
|
|
{
|
2016-06-24 02:43:46 -06:00
|
|
|
ev.Skip();
|
2017-06-20 17:36:59 -06:00
|
|
|
// We need show any changes to the ini which could impact our columns. Currently only the
|
|
|
|
// EmuState/Issues settings can do that. We also need to persist the changes to the cache - so
|
|
|
|
// just trigger a rescan which will sync the cache and then display the new values.
|
|
|
|
m_scan_trigger.Set();
|
2016-05-29 08:49:11 -06:00
|
|
|
}
|
|
|
|
|
2017-06-19 03:20:14 -06:00
|
|
|
void GameListCtrl::OnColBeginDrag(wxListEvent& event)
|
2008-12-07 22:30:24 -07:00
|
|
|
{
|
2016-06-24 02:43:46 -06:00
|
|
|
const int column_id = event.GetColumn();
|
2015-10-10 20:44:53 -06:00
|
|
|
|
2016-06-24 02:43:46 -06:00
|
|
|
if (column_id != COLUMN_TITLE && column_id != COLUMN_MAKER && column_id != COLUMN_FILENAME)
|
|
|
|
event.Veto();
|
2008-12-07 22:30:24 -07:00
|
|
|
}
|
|
|
|
|
2017-12-31 12:33:36 -07:00
|
|
|
const UICommon::GameFile* GameListCtrl::GetISO(size_t index) const
|
2008-12-07 22:30:24 -07:00
|
|
|
{
|
2017-06-20 17:36:59 -06:00
|
|
|
if (index < m_shown_files.size())
|
|
|
|
return m_shown_files[index].get();
|
2016-09-30 01:16:43 -06:00
|
|
|
|
|
|
|
return nullptr;
|
2008-12-07 22:30:24 -07:00
|
|
|
}
|
|
|
|
|
2017-06-19 03:20:14 -06:00
|
|
|
static GameListCtrl* caller;
|
2014-07-08 06:29:26 -06:00
|
|
|
static int wxCALLBACK wxListCompare(wxIntPtr item1, wxIntPtr item2, wxIntPtr sortData)
|
2008-12-07 22:30:24 -07:00
|
|
|
{
|
2016-06-24 02:43:46 -06:00
|
|
|
// return 1 if item1 > item2
|
|
|
|
// return -1 if item1 < item2
|
|
|
|
// return 0 for identity
|
2017-12-31 12:33:36 -07:00
|
|
|
const UICommon::GameFile* iso1 = caller->GetISO(item1);
|
|
|
|
const UICommon::GameFile* iso2 = caller->GetISO(item2);
|
2010-07-31 08:14:01 -06:00
|
|
|
|
2017-07-14 16:17:52 -06:00
|
|
|
if (iso1 == iso2)
|
|
|
|
return 0;
|
|
|
|
|
2016-06-24 02:43:46 -06:00
|
|
|
return CompareGameListItems(iso1, iso2, sortData);
|
2008-12-07 22:30:24 -07:00
|
|
|
}
|
|
|
|
|
2017-06-19 03:20:14 -06:00
|
|
|
void GameListCtrl::OnColumnClick(wxListEvent& event)
|
2008-12-07 22:30:24 -07:00
|
|
|
{
|
2016-06-24 02:43:46 -06:00
|
|
|
if (event.GetColumn() != COLUMN_BANNER)
|
|
|
|
{
|
|
|
|
int current_column = event.GetColumn();
|
|
|
|
if (sorted)
|
|
|
|
{
|
2017-06-19 03:25:30 -06:00
|
|
|
if (m_last_column == current_column)
|
2016-06-24 02:43:46 -06:00
|
|
|
{
|
2017-06-19 03:25:30 -06:00
|
|
|
m_last_sort = -m_last_sort;
|
2016-06-24 02:43:46 -06:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-06-19 03:25:30 -06:00
|
|
|
SConfig::GetInstance().m_ListSort2 = m_last_sort;
|
|
|
|
m_last_column = current_column;
|
|
|
|
m_last_sort = current_column;
|
2016-06-24 02:43:46 -06:00
|
|
|
}
|
2017-06-19 03:25:30 -06:00
|
|
|
SConfig::GetInstance().m_ListSort = m_last_sort;
|
2016-06-24 02:43:46 -06:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-06-19 03:25:30 -06:00
|
|
|
m_last_sort = current_column;
|
|
|
|
m_last_column = current_column;
|
2016-06-24 02:43:46 -06:00
|
|
|
}
|
|
|
|
caller = this;
|
2017-06-19 03:25:30 -06:00
|
|
|
SortItems(wxListCompare, m_last_sort);
|
2016-06-24 02:43:46 -06:00
|
|
|
}
|
|
|
|
|
2017-02-19 01:02:00 -07:00
|
|
|
SetColors();
|
2016-06-24 02:43:46 -06:00
|
|
|
|
|
|
|
event.Skip();
|
2008-12-07 22:30:24 -07:00
|
|
|
}
|
|
|
|
|
2009-09-25 10:29:00 -06:00
|
|
|
// This is used by keyboard gamelist search
|
2017-06-19 03:20:14 -06:00
|
|
|
void GameListCtrl::OnKeyPress(wxListEvent& event)
|
2009-09-25 10:29:00 -06:00
|
|
|
{
|
2016-06-24 02:43:46 -06:00
|
|
|
static int lastKey = 0, sLoop = 0;
|
|
|
|
int Loop = 0;
|
|
|
|
|
2017-06-20 17:36:59 -06:00
|
|
|
for (int i = 0; i < (int)m_shown_files.size(); i++)
|
2016-06-24 02:43:46 -06:00
|
|
|
{
|
|
|
|
// Easy way to get game string
|
|
|
|
wxListItem bleh;
|
|
|
|
bleh.SetId(i);
|
|
|
|
bleh.SetColumn(COLUMN_TITLE);
|
|
|
|
bleh.SetMask(wxLIST_MASK_TEXT);
|
|
|
|
GetItem(bleh);
|
|
|
|
|
|
|
|
wxString text = bleh.GetText();
|
|
|
|
|
|
|
|
if (text.MakeUpper()[0] == event.GetKeyCode())
|
|
|
|
{
|
|
|
|
if (lastKey == event.GetKeyCode() && Loop < sLoop)
|
|
|
|
{
|
|
|
|
Loop++;
|
2017-06-20 17:36:59 -06:00
|
|
|
if (i + 1 == (int)m_shown_files.size())
|
2016-06-24 02:43:46 -06:00
|
|
|
i = -1;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
else if (lastKey != event.GetKeyCode())
|
|
|
|
{
|
|
|
|
sLoop = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
lastKey = event.GetKeyCode();
|
|
|
|
sLoop++;
|
|
|
|
|
|
|
|
UnselectAll();
|
|
|
|
SetItemState(i, wxLIST_STATE_SELECTED | wxLIST_STATE_FOCUSED,
|
|
|
|
wxLIST_STATE_SELECTED | wxLIST_STATE_FOCUSED);
|
|
|
|
EnsureVisible(i);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
// If we get past the last game in the list,
|
|
|
|
// we'll have to go back to the first one.
|
2017-06-20 17:36:59 -06:00
|
|
|
if (i + 1 == (int)m_shown_files.size() && sLoop > 0 && Loop > 0)
|
2016-06-24 02:43:46 -06:00
|
|
|
i = -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
event.Skip();
|
2009-09-25 10:29:00 -06:00
|
|
|
}
|
|
|
|
|
2017-06-19 03:20:14 -06:00
|
|
|
void GameListCtrl::OnLeftClick(wxMouseEvent& event)
|
2010-01-19 06:43:51 -07:00
|
|
|
{
|
2016-06-24 02:43:46 -06:00
|
|
|
// Focus the clicked item.
|
|
|
|
int flags;
|
|
|
|
long item = HitTest(event.GetPosition(), flags);
|
|
|
|
if ((item != wxNOT_FOUND) && (GetSelectedItemCount() == 0) && (!event.ControlDown()) &&
|
|
|
|
(!event.ShiftDown()))
|
|
|
|
{
|
|
|
|
SetItemState(item, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED);
|
|
|
|
SetItemState(item, wxLIST_STATE_FOCUSED, wxLIST_STATE_FOCUSED);
|
|
|
|
wxGetApp().GetCFrame()->UpdateGUI();
|
|
|
|
}
|
|
|
|
|
|
|
|
event.Skip();
|
2010-01-19 06:43:51 -07:00
|
|
|
}
|
|
|
|
|
2017-06-19 03:20:14 -06:00
|
|
|
void GameListCtrl::OnRightClick(wxMouseEvent& event)
|
2013-10-28 23:23:17 -06:00
|
|
|
{
|
2016-06-24 02:43:46 -06:00
|
|
|
// Focus the clicked item.
|
|
|
|
int flags;
|
|
|
|
long item = HitTest(event.GetPosition(), flags);
|
|
|
|
if (item != wxNOT_FOUND)
|
|
|
|
{
|
|
|
|
if (GetItemState(item, wxLIST_STATE_SELECTED) != wxLIST_STATE_SELECTED)
|
|
|
|
{
|
|
|
|
UnselectAll();
|
|
|
|
SetItemState(item, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED);
|
|
|
|
}
|
|
|
|
SetItemState(item, wxLIST_STATE_FOCUSED, wxLIST_STATE_FOCUSED);
|
|
|
|
}
|
|
|
|
if (GetSelectedItemCount() == 1)
|
|
|
|
{
|
2017-12-31 12:33:36 -07:00
|
|
|
const UICommon::GameFile* selected_iso = GetSelectedISO();
|
2016-06-24 02:43:46 -06:00
|
|
|
if (selected_iso)
|
|
|
|
{
|
|
|
|
wxMenu popupMenu;
|
2016-07-06 12:33:05 -06:00
|
|
|
DiscIO::Platform platform = selected_iso->GetPlatform();
|
2016-06-24 02:43:46 -06:00
|
|
|
|
2018-03-31 06:04:13 -06:00
|
|
|
if (platform != DiscIO::Platform::ELFOrDOL)
|
2016-06-24 02:43:46 -06:00
|
|
|
{
|
|
|
|
popupMenu.Append(IDM_PROPERTIES, _("&Properties"));
|
|
|
|
popupMenu.Append(IDM_GAME_WIKI, _("&Wiki"));
|
|
|
|
popupMenu.AppendSeparator();
|
|
|
|
}
|
2018-03-31 06:04:13 -06:00
|
|
|
if (platform == DiscIO::Platform::WiiDisc || platform == DiscIO::Platform::WiiWAD)
|
2016-06-24 02:43:46 -06:00
|
|
|
{
|
2017-03-29 07:47:04 -06:00
|
|
|
auto* const open_save_folder_item =
|
|
|
|
popupMenu.Append(IDM_OPEN_SAVE_FOLDER, _("Open Wii &save folder"));
|
|
|
|
auto* const export_save_item =
|
|
|
|
popupMenu.Append(IDM_EXPORT_SAVE, _("Export Wii save (Experimental)"));
|
|
|
|
|
|
|
|
// We should not allow the user to mess with the save folder or export saves while
|
|
|
|
// emulation is running, because this could result in the exported save being in
|
|
|
|
// an inconsistent state; the emulated software can do *anything* to its data directory,
|
|
|
|
// and we definitely do not want the user to touch anything in there if it's running.
|
|
|
|
for (auto* menu_item : {open_save_folder_item, export_save_item})
|
2017-05-07 10:56:54 -06:00
|
|
|
{
|
|
|
|
menu_item->Enable((!Core::IsRunning() || !SConfig::GetInstance().bWii) &&
|
|
|
|
File::IsDirectory(selected_iso->GetWiiFSPath()));
|
|
|
|
}
|
2016-06-24 02:43:46 -06:00
|
|
|
}
|
|
|
|
popupMenu.Append(IDM_OPEN_CONTAINING_FOLDER, _("Open &containing folder"));
|
|
|
|
|
2018-03-31 06:04:13 -06:00
|
|
|
if (platform != DiscIO::Platform::ELFOrDOL)
|
2016-06-24 02:43:46 -06:00
|
|
|
popupMenu.AppendCheckItem(IDM_SET_DEFAULT_ISO, _("Set as &default ISO"));
|
|
|
|
|
|
|
|
// First we have to decide a starting value when we append it
|
2017-12-31 12:33:36 -07:00
|
|
|
if (selected_iso->GetFilePath() == SConfig::GetInstance().m_strDefaultISO)
|
2016-06-24 02:43:46 -06:00
|
|
|
popupMenu.FindItem(IDM_SET_DEFAULT_ISO)->Check();
|
|
|
|
|
|
|
|
popupMenu.AppendSeparator();
|
|
|
|
popupMenu.Append(IDM_DELETE_ISO, _("&Delete File..."));
|
|
|
|
|
2018-03-31 06:04:13 -06:00
|
|
|
if (platform == DiscIO::Platform::GameCubeDisc || platform == DiscIO::Platform::WiiDisc)
|
2016-06-24 02:43:46 -06:00
|
|
|
{
|
|
|
|
if (selected_iso->GetBlobType() == DiscIO::BlobType::GCZ)
|
|
|
|
popupMenu.Append(IDM_COMPRESS_ISO, _("Decompress ISO..."));
|
|
|
|
else if (selected_iso->GetBlobType() == DiscIO::BlobType::PLAIN)
|
|
|
|
popupMenu.Append(IDM_COMPRESS_ISO, _("Compress ISO..."));
|
|
|
|
|
|
|
|
wxMenuItem* changeDiscItem = popupMenu.Append(IDM_LIST_CHANGE_DISC, _("Change &Disc"));
|
|
|
|
changeDiscItem->Enable(Core::IsRunning());
|
|
|
|
}
|
|
|
|
|
2018-03-31 06:04:13 -06:00
|
|
|
if (platform == DiscIO::Platform::WiiDisc)
|
2017-07-04 10:23:25 -06:00
|
|
|
{
|
|
|
|
auto* const perform_update_item =
|
|
|
|
popupMenu.Append(IDM_LIST_PERFORM_DISC_UPDATE, _("Perform System Update"));
|
|
|
|
perform_update_item->Enable(!Core::IsRunning() || !SConfig::GetInstance().bWii);
|
|
|
|
}
|
|
|
|
|
2018-03-31 06:04:13 -06:00
|
|
|
if (platform == DiscIO::Platform::WiiWAD)
|
2017-03-29 07:47:04 -06:00
|
|
|
{
|
|
|
|
auto* const install_wad_item =
|
2017-04-25 15:29:48 -06:00
|
|
|
popupMenu.Append(IDM_LIST_INSTALL_WAD, _("Install to the NAND"));
|
|
|
|
auto* const uninstall_wad_item =
|
|
|
|
popupMenu.Append(IDM_LIST_UNINSTALL_WAD, _("Uninstall from the NAND"));
|
|
|
|
// These should not be allowed while emulation is running for safety reasons.
|
|
|
|
for (auto* menu_item : {install_wad_item, uninstall_wad_item})
|
|
|
|
menu_item->Enable(!Core::IsRunning() || !SConfig::GetInstance().bWii);
|
|
|
|
|
2017-12-31 12:33:36 -07:00
|
|
|
if (!WiiUtils::IsTitleInstalled(selected_iso->GetTitleID()))
|
2017-04-25 15:29:48 -06:00
|
|
|
uninstall_wad_item->Enable(false);
|
2017-03-29 07:47:04 -06:00
|
|
|
}
|
2016-06-24 02:43:46 -06:00
|
|
|
|
2016-10-03 06:35:27 -06:00
|
|
|
popupMenu.Append(IDM_START_NETPLAY, _("Host with Netplay"));
|
|
|
|
|
2016-06-24 02:43:46 -06:00
|
|
|
PopupMenu(&popupMenu);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (GetSelectedItemCount() > 1)
|
|
|
|
{
|
|
|
|
wxMenu popupMenu;
|
|
|
|
popupMenu.Append(IDM_DELETE_ISO, _("&Delete selected ISOs..."));
|
|
|
|
popupMenu.AppendSeparator();
|
|
|
|
popupMenu.Append(IDM_MULTI_COMPRESS_ISO, _("Compress selected ISOs..."));
|
|
|
|
popupMenu.Append(IDM_MULTI_DECOMPRESS_ISO, _("Decompress selected ISOs..."));
|
|
|
|
PopupMenu(&popupMenu);
|
|
|
|
}
|
2008-12-07 22:30:24 -07:00
|
|
|
}
|
|
|
|
|
2017-12-31 12:33:36 -07:00
|
|
|
const UICommon::GameFile* GameListCtrl::GetSelectedISO() const
|
2008-12-07 22:30:24 -07:00
|
|
|
{
|
2017-06-20 17:36:59 -06:00
|
|
|
if (m_shown_files.empty())
|
2016-06-24 02:43:46 -06:00
|
|
|
return nullptr;
|
2016-09-30 01:16:43 -06:00
|
|
|
|
|
|
|
if (GetSelectedItemCount() == 0)
|
2016-06-24 02:43:46 -06:00
|
|
|
return nullptr;
|
2016-09-30 01:16:43 -06:00
|
|
|
|
|
|
|
long item = GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
|
|
|
|
if (item == wxNOT_FOUND)
|
|
|
|
return nullptr;
|
|
|
|
|
2017-06-19 03:25:30 -06:00
|
|
|
return GetISO(GetItemData(item));
|
2015-12-17 04:39:32 -07:00
|
|
|
}
|
|
|
|
|
2017-12-31 12:33:36 -07:00
|
|
|
std::vector<const UICommon::GameFile*> GameListCtrl::GetAllSelectedISOs() const
|
2015-12-17 04:39:32 -07:00
|
|
|
{
|
2017-12-31 12:33:36 -07:00
|
|
|
std::vector<const UICommon::GameFile*> result;
|
2016-06-24 02:43:46 -06:00
|
|
|
long item = -1;
|
|
|
|
while (true)
|
|
|
|
{
|
|
|
|
item = GetNextItem(item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
|
|
|
|
if (item == wxNOT_FOUND)
|
|
|
|
return result;
|
2017-06-19 03:25:30 -06:00
|
|
|
result.push_back(GetISO(GetItemData(item)));
|
2016-06-24 02:43:46 -06:00
|
|
|
}
|
2008-12-07 22:30:24 -07:00
|
|
|
}
|
|
|
|
|
2017-06-19 03:20:14 -06:00
|
|
|
bool GameListCtrl::IsHidingItems()
|
2016-01-06 14:25:30 -07:00
|
|
|
{
|
2016-06-24 02:43:46 -06:00
|
|
|
return !(SConfig::GetInstance().m_ListGC && SConfig::GetInstance().m_ListWii &&
|
|
|
|
SConfig::GetInstance().m_ListWad && SConfig::GetInstance().m_ListElfDol &&
|
|
|
|
SConfig::GetInstance().m_ListJap && SConfig::GetInstance().m_ListUsa &&
|
|
|
|
SConfig::GetInstance().m_ListPal && SConfig::GetInstance().m_ListAustralia &&
|
|
|
|
SConfig::GetInstance().m_ListFrance && SConfig::GetInstance().m_ListGermany &&
|
|
|
|
SConfig::GetInstance().m_ListItaly && SConfig::GetInstance().m_ListKorea &&
|
|
|
|
SConfig::GetInstance().m_ListNetherlands && SConfig::GetInstance().m_ListRussia &&
|
|
|
|
SConfig::GetInstance().m_ListSpain && SConfig::GetInstance().m_ListTaiwan &&
|
|
|
|
SConfig::GetInstance().m_ListWorld && SConfig::GetInstance().m_ListUnknown);
|
2016-01-06 14:25:30 -07:00
|
|
|
}
|
|
|
|
|
2017-06-19 03:20:14 -06:00
|
|
|
void GameListCtrl::OnOpenContainingFolder(wxCommandEvent& WXUNUSED(event))
|
2008-12-07 22:30:24 -07:00
|
|
|
{
|
2017-12-31 12:33:36 -07:00
|
|
|
const UICommon::GameFile* iso = GetSelectedISO();
|
2016-06-24 02:43:46 -06:00
|
|
|
if (!iso)
|
|
|
|
return;
|
2013-01-11 09:24:52 -07:00
|
|
|
|
2017-12-31 12:33:36 -07:00
|
|
|
wxFileName path = wxFileName::FileName(StrToWxStr(iso->GetFilePath()));
|
2016-06-24 02:43:46 -06:00
|
|
|
path.MakeAbsolute();
|
|
|
|
WxUtils::Explore(WxStrToStr(path.GetPath()));
|
2008-12-07 22:30:24 -07:00
|
|
|
}
|
|
|
|
|
2017-06-19 03:20:14 -06:00
|
|
|
void GameListCtrl::OnOpenSaveFolder(wxCommandEvent& WXUNUSED(event))
|
2009-05-02 12:06:42 -06:00
|
|
|
{
|
2017-12-31 12:33:36 -07:00
|
|
|
const UICommon::GameFile* iso = GetSelectedISO();
|
2016-06-24 02:43:46 -06:00
|
|
|
if (!iso)
|
|
|
|
return;
|
|
|
|
std::string path = iso->GetWiiFSPath();
|
|
|
|
if (!path.empty())
|
|
|
|
WxUtils::Explore(path);
|
2009-05-02 12:06:42 -06:00
|
|
|
}
|
|
|
|
|
2017-06-19 03:20:14 -06:00
|
|
|
void GameListCtrl::OnExportSave(wxCommandEvent& WXUNUSED(event))
|
2010-01-14 00:19:10 -07:00
|
|
|
{
|
2017-12-31 12:33:36 -07:00
|
|
|
const UICommon::GameFile* iso = GetSelectedISO();
|
2017-05-06 09:08:18 -06:00
|
|
|
if (iso)
|
|
|
|
CWiiSaveCrypted::ExportWiiSave(iso->GetTitleID());
|
2010-01-14 00:19:10 -07:00
|
|
|
}
|
2008-12-07 22:30:24 -07:00
|
|
|
|
|
|
|
// Save this file as the default file
|
2017-06-19 03:20:14 -06:00
|
|
|
void GameListCtrl::OnSetDefaultISO(wxCommandEvent& event)
|
2008-12-07 22:30:24 -07:00
|
|
|
{
|
2017-12-31 12:33:36 -07:00
|
|
|
const UICommon::GameFile* iso = GetSelectedISO();
|
2016-06-24 02:43:46 -06:00
|
|
|
if (!iso)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (event.IsChecked())
|
|
|
|
{
|
|
|
|
// Write the new default value and save it the ini file
|
2017-12-31 12:33:36 -07:00
|
|
|
SConfig::GetInstance().m_strDefaultISO = iso->GetFilePath();
|
2016-06-24 02:43:46 -06:00
|
|
|
SConfig::GetInstance().SaveSettings();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Otherwise blank the value and save it
|
|
|
|
SConfig::GetInstance().m_strDefaultISO = "";
|
|
|
|
SConfig::GetInstance().SaveSettings();
|
|
|
|
}
|
2008-12-07 22:30:24 -07:00
|
|
|
}
|
|
|
|
|
2017-06-19 03:20:14 -06:00
|
|
|
void GameListCtrl::OnDeleteISO(wxCommandEvent& WXUNUSED(event))
|
2008-12-07 22:30:24 -07:00
|
|
|
{
|
2016-06-24 02:43:46 -06:00
|
|
|
const wxString message =
|
|
|
|
GetSelectedItemCount() == 1 ?
|
|
|
|
_("Are you sure you want to delete this file? It will be gone forever!") :
|
|
|
|
_("Are you sure you want to delete these files? They will be gone forever!");
|
|
|
|
|
|
|
|
if (wxMessageBox(message, _("Warning"), wxYES_NO | wxICON_EXCLAMATION) == wxYES)
|
|
|
|
{
|
2017-12-31 12:33:36 -07:00
|
|
|
for (const UICommon::GameFile* iso : GetAllSelectedISOs())
|
|
|
|
File::Delete(iso->GetFilePath());
|
2017-06-20 17:36:59 -06:00
|
|
|
m_scan_trigger.Set();
|
2016-06-24 02:43:46 -06:00
|
|
|
}
|
2008-12-07 22:30:24 -07:00
|
|
|
}
|
|
|
|
|
2017-06-19 03:20:14 -06:00
|
|
|
void GameListCtrl::OnProperties(wxCommandEvent& WXUNUSED(event))
|
2008-12-07 22:30:24 -07:00
|
|
|
{
|
2017-12-31 12:33:36 -07:00
|
|
|
const UICommon::GameFile* iso = GetSelectedISO();
|
2016-06-24 02:43:46 -06:00
|
|
|
if (!iso)
|
|
|
|
return;
|
2013-04-07 23:16:50 -06:00
|
|
|
|
2016-06-24 02:43:46 -06:00
|
|
|
CISOProperties* ISOProperties = new CISOProperties(*iso, this);
|
|
|
|
ISOProperties->Show();
|
2008-12-07 22:30:24 -07:00
|
|
|
}
|
|
|
|
|
2017-06-19 03:20:14 -06:00
|
|
|
void GameListCtrl::OnWiki(wxCommandEvent& WXUNUSED(event))
|
2011-02-25 16:33:11 -07:00
|
|
|
{
|
2017-12-31 12:33:36 -07:00
|
|
|
const UICommon::GameFile* iso = GetSelectedISO();
|
2016-06-24 02:43:46 -06:00
|
|
|
if (!iso)
|
|
|
|
return;
|
2011-02-25 16:33:11 -07:00
|
|
|
|
2016-06-24 02:43:46 -06:00
|
|
|
std::string wikiUrl =
|
2016-10-29 06:42:43 -06:00
|
|
|
"https://wiki.dolphin-emu.org/dolphin-redirect.php?gameid=" + iso->GetGameID();
|
2016-06-24 02:43:46 -06:00
|
|
|
WxUtils::Launch(wikiUrl);
|
2011-02-25 16:33:11 -07:00
|
|
|
}
|
|
|
|
|
2017-06-19 03:20:14 -06:00
|
|
|
void GameListCtrl::OnNetPlayHost(wxCommandEvent& WXUNUSED(event))
|
2016-10-03 06:35:27 -06:00
|
|
|
{
|
2017-12-31 12:33:36 -07:00
|
|
|
const UICommon::GameFile* iso = GetSelectedISO();
|
2016-10-03 06:35:27 -06:00
|
|
|
if (!iso)
|
|
|
|
return;
|
|
|
|
|
|
|
|
NetPlayHostConfig config;
|
2017-08-02 17:52:26 -06:00
|
|
|
config.FromConfig();
|
2016-10-03 06:35:27 -06:00
|
|
|
config.game_name = iso->GetUniqueIdentifier();
|
|
|
|
config.game_list_ctrl = this;
|
2017-08-02 17:51:05 -06:00
|
|
|
config.SetDialogInfo(m_parent);
|
2016-10-03 06:35:27 -06:00
|
|
|
|
2017-08-02 17:52:26 -06:00
|
|
|
Config::SetBaseOrCurrent(Config::NETPLAY_SELECTED_HOST_GAME, config.game_name);
|
2016-10-03 06:35:27 -06:00
|
|
|
NetPlayLauncher::Host(config);
|
|
|
|
}
|
|
|
|
|
2017-06-19 03:20:14 -06:00
|
|
|
bool GameListCtrl::MultiCompressCB(const std::string& text, float percent, void* arg)
|
2008-12-07 22:30:24 -07:00
|
|
|
{
|
2016-06-24 02:43:46 -06:00
|
|
|
CompressionProgress* progress = static_cast<CompressionProgress*>(arg);
|
2015-12-17 10:50:09 -07:00
|
|
|
|
2016-06-24 02:43:46 -06:00
|
|
|
float total_percent = ((float)progress->items_done + percent) / (float)progress->items_total;
|
|
|
|
wxString text_string(
|
|
|
|
StrToWxStr(StringFromFormat("%s (%i/%i) - %s", progress->current_filename.c_str(),
|
|
|
|
progress->items_done + 1, progress->items_total, text.c_str())));
|
2009-11-18 14:11:05 -07:00
|
|
|
|
2016-06-24 02:43:46 -06:00
|
|
|
return progress->dialog->Update(total_percent * progress->dialog->GetRange(), text_string);
|
2008-12-07 22:30:24 -07:00
|
|
|
}
|
|
|
|
|
2017-06-19 03:20:14 -06:00
|
|
|
void GameListCtrl::OnMultiCompressISO(wxCommandEvent& /*event*/)
|
2008-12-07 22:30:24 -07:00
|
|
|
{
|
2016-06-24 02:43:46 -06:00
|
|
|
CompressSelection(true);
|
2008-12-07 22:30:24 -07:00
|
|
|
}
|
|
|
|
|
2017-06-19 03:20:14 -06:00
|
|
|
void GameListCtrl::OnMultiDecompressISO(wxCommandEvent& /*event*/)
|
2008-12-07 22:30:24 -07:00
|
|
|
{
|
2016-06-24 02:43:46 -06:00
|
|
|
CompressSelection(false);
|
2008-12-07 22:30:24 -07:00
|
|
|
}
|
|
|
|
|
2017-06-19 03:20:14 -06:00
|
|
|
void GameListCtrl::CompressSelection(bool _compress)
|
2008-12-07 22:30:24 -07:00
|
|
|
{
|
2017-12-31 12:33:36 -07:00
|
|
|
std::vector<const UICommon::GameFile*> items_to_compress;
|
2016-06-24 02:43:46 -06:00
|
|
|
bool wii_compression_warning_accepted = false;
|
2017-12-31 12:33:36 -07:00
|
|
|
for (const UICommon::GameFile* iso : GetAllSelectedISOs())
|
2016-06-24 02:43:46 -06:00
|
|
|
{
|
|
|
|
// Don't include items that we can't do anything with
|
2018-03-31 06:04:13 -06:00
|
|
|
if (iso->GetPlatform() != DiscIO::Platform::GameCubeDisc &&
|
|
|
|
iso->GetPlatform() != DiscIO::Platform::WiiDisc)
|
2016-06-24 02:43:46 -06:00
|
|
|
continue;
|
|
|
|
if (iso->GetBlobType() != DiscIO::BlobType::PLAIN &&
|
|
|
|
iso->GetBlobType() != DiscIO::BlobType::GCZ)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
items_to_compress.push_back(iso);
|
|
|
|
|
|
|
|
// Show the Wii compression warning if it's relevant and it hasn't been shown already
|
2017-02-20 08:08:07 -07:00
|
|
|
if (!wii_compression_warning_accepted && _compress &&
|
|
|
|
iso->GetBlobType() != DiscIO::BlobType::GCZ &&
|
2018-03-31 06:04:13 -06:00
|
|
|
iso->GetPlatform() == DiscIO::Platform::WiiDisc)
|
2016-06-24 02:43:46 -06:00
|
|
|
{
|
|
|
|
if (WiiCompressWarning())
|
|
|
|
wii_compression_warning_accepted = true;
|
|
|
|
else
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
wxString dirHome;
|
|
|
|
wxGetHomeDir(&dirHome);
|
|
|
|
|
|
|
|
wxDirDialog browseDialog(this, _("Browse for output directory"), dirHome,
|
|
|
|
wxDD_DEFAULT_STYLE | wxDD_DIR_MUST_EXIST);
|
|
|
|
if (browseDialog.ShowModal() != wxID_OK)
|
|
|
|
return;
|
|
|
|
|
|
|
|
bool all_good = true;
|
|
|
|
|
|
|
|
{
|
|
|
|
wxProgressDialog progressDialog(
|
|
|
|
_compress ? _("Compressing ISO") : _("Decompressing ISO"), _("Working..."),
|
|
|
|
1000, // Arbitrary number that's larger than the dialog's width in pixels
|
2018-04-12 06:18:04 -06:00
|
|
|
this,
|
|
|
|
wxPD_APP_MODAL | wxPD_CAN_ABORT | wxPD_ELAPSED_TIME | wxPD_ESTIMATED_TIME |
|
|
|
|
wxPD_REMAINING_TIME | wxPD_SMOOTH);
|
2016-06-24 02:43:46 -06:00
|
|
|
|
|
|
|
CompressionProgress progress(0, items_to_compress.size(), "", &progressDialog);
|
|
|
|
|
2017-12-31 12:33:36 -07:00
|
|
|
for (const UICommon::GameFile* iso : items_to_compress)
|
2016-06-24 02:43:46 -06:00
|
|
|
{
|
2017-02-20 08:08:07 -07:00
|
|
|
if (iso->GetBlobType() != DiscIO::BlobType::GCZ && _compress)
|
2016-06-24 02:43:46 -06:00
|
|
|
{
|
|
|
|
std::string FileName;
|
2017-12-31 12:33:36 -07:00
|
|
|
SplitPath(iso->GetFilePath(), nullptr, &FileName, nullptr);
|
2016-06-24 02:43:46 -06:00
|
|
|
progress.current_filename = FileName;
|
|
|
|
FileName.append(".gcz");
|
|
|
|
|
|
|
|
std::string OutputFileName;
|
|
|
|
BuildCompleteFilename(OutputFileName, WxStrToStr(browseDialog.GetPath()), FileName);
|
|
|
|
|
|
|
|
if (File::Exists(OutputFileName) &&
|
|
|
|
wxMessageBox(
|
|
|
|
wxString::Format(_("The file %s already exists.\nDo you wish to replace it?"),
|
|
|
|
StrToWxStr(OutputFileName)),
|
|
|
|
_("Confirm File Overwrite"), wxYES_NO) == wxNO)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
all_good &=
|
2017-12-31 12:33:36 -07:00
|
|
|
DiscIO::CompressFileToBlob(iso->GetFilePath(), OutputFileName,
|
2018-03-31 06:04:13 -06:00
|
|
|
(iso->GetPlatform() == DiscIO::Platform::WiiDisc) ? 1 : 0,
|
2016-06-24 02:43:46 -06:00
|
|
|
16384, &MultiCompressCB, &progress);
|
|
|
|
}
|
2017-02-20 08:08:07 -07:00
|
|
|
else if (iso->GetBlobType() == DiscIO::BlobType::GCZ && !_compress)
|
2016-06-24 02:43:46 -06:00
|
|
|
{
|
|
|
|
std::string FileName;
|
2017-12-31 12:33:36 -07:00
|
|
|
SplitPath(iso->GetFilePath(), nullptr, &FileName, nullptr);
|
2016-06-24 02:43:46 -06:00
|
|
|
progress.current_filename = FileName;
|
2018-03-31 06:04:13 -06:00
|
|
|
if (iso->GetPlatform() == DiscIO::Platform::WiiDisc)
|
2016-06-24 02:43:46 -06:00
|
|
|
FileName.append(".iso");
|
|
|
|
else
|
|
|
|
FileName.append(".gcm");
|
|
|
|
|
|
|
|
std::string OutputFileName;
|
|
|
|
BuildCompleteFilename(OutputFileName, WxStrToStr(browseDialog.GetPath()), FileName);
|
|
|
|
|
|
|
|
if (File::Exists(OutputFileName) &&
|
|
|
|
wxMessageBox(
|
|
|
|
wxString::Format(_("The file %s already exists.\nDo you wish to replace it?"),
|
|
|
|
StrToWxStr(OutputFileName)),
|
|
|
|
_("Confirm File Overwrite"), wxYES_NO) == wxNO)
|
|
|
|
continue;
|
|
|
|
|
2017-12-31 12:33:36 -07:00
|
|
|
all_good &= DiscIO::DecompressBlobToFile(iso->GetFilePath().c_str(), OutputFileName.c_str(),
|
2016-06-24 02:43:46 -06:00
|
|
|
&MultiCompressCB, &progress);
|
|
|
|
}
|
|
|
|
|
|
|
|
progress.items_done++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!all_good)
|
|
|
|
WxUtils::ShowErrorDialog(_("Dolphin was unable to complete the requested action."));
|
|
|
|
|
2017-06-20 17:36:59 -06:00
|
|
|
m_scan_trigger.Set();
|
2008-12-07 22:30:24 -07:00
|
|
|
}
|
|
|
|
|
2017-06-19 03:20:14 -06:00
|
|
|
bool GameListCtrl::CompressCB(const std::string& text, float percent, void* arg)
|
2008-12-07 22:30:24 -07:00
|
|
|
{
|
2016-06-24 02:43:46 -06:00
|
|
|
return ((wxProgressDialog*)arg)->Update((int)(percent * 1000), StrToWxStr(text));
|
2008-12-07 22:30:24 -07:00
|
|
|
}
|
|
|
|
|
2017-06-19 03:20:14 -06:00
|
|
|
void GameListCtrl::OnCompressISO(wxCommandEvent& WXUNUSED(event))
|
2008-12-07 22:30:24 -07:00
|
|
|
{
|
2017-12-31 12:33:36 -07:00
|
|
|
const UICommon::GameFile* iso = GetSelectedISO();
|
2016-06-24 02:43:46 -06:00
|
|
|
if (!iso)
|
|
|
|
return;
|
|
|
|
|
|
|
|
bool is_compressed = iso->GetBlobType() == DiscIO::BlobType::GCZ;
|
|
|
|
wxString path;
|
|
|
|
|
|
|
|
std::string FileName, FilePath, FileExtension;
|
2017-12-31 12:33:36 -07:00
|
|
|
SplitPath(iso->GetFilePath(), &FilePath, &FileName, &FileExtension);
|
2016-06-24 02:43:46 -06:00
|
|
|
|
|
|
|
do
|
|
|
|
{
|
|
|
|
if (is_compressed)
|
|
|
|
{
|
|
|
|
wxString FileType;
|
2018-03-31 06:04:13 -06:00
|
|
|
if (iso->GetPlatform() == DiscIO::Platform::WiiDisc)
|
2016-06-24 02:43:46 -06:00
|
|
|
FileType = _("All Wii ISO files (iso)") + "|*.iso";
|
|
|
|
else
|
|
|
|
FileType = _("All GameCube GCM files (gcm)") + "|*.gcm";
|
|
|
|
|
|
|
|
path = wxFileSelector(_("Save decompressed GCM/ISO"), StrToWxStr(FilePath),
|
|
|
|
StrToWxStr(FileName) + FileType.After('*'), wxEmptyString,
|
|
|
|
FileType + "|" + wxGetTranslation(wxALL_FILES), wxFD_SAVE, this);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-03-31 06:04:13 -06:00
|
|
|
if (iso->GetPlatform() == DiscIO::Platform::WiiDisc && !WiiCompressWarning())
|
2016-06-24 02:43:46 -06:00
|
|
|
return;
|
|
|
|
|
|
|
|
path = wxFileSelector(_("Save compressed GCM/ISO"), StrToWxStr(FilePath),
|
|
|
|
StrToWxStr(FileName) + ".gcz", wxEmptyString,
|
|
|
|
_("All compressed GC/Wii ISO files (gcz)") +
|
|
|
|
wxString::Format("|*.gcz|%s", wxGetTranslation(wxALL_FILES)),
|
|
|
|
wxFD_SAVE, this);
|
|
|
|
}
|
|
|
|
if (!path)
|
|
|
|
return;
|
|
|
|
} while (
|
|
|
|
wxFileExists(path) &&
|
|
|
|
wxMessageBox(wxString::Format(_("The file %s already exists.\nDo you wish to replace it?"),
|
|
|
|
path.c_str()),
|
|
|
|
_("Confirm File Overwrite"), wxYES_NO) == wxNO);
|
|
|
|
|
|
|
|
bool all_good = false;
|
|
|
|
|
|
|
|
{
|
|
|
|
wxProgressDialog dialog(is_compressed ? _("Decompressing ISO") : _("Compressing ISO"),
|
|
|
|
_("Working..."), 1000, this,
|
|
|
|
wxPD_APP_MODAL | wxPD_CAN_ABORT | wxPD_ELAPSED_TIME |
|
|
|
|
wxPD_ESTIMATED_TIME | wxPD_REMAINING_TIME | wxPD_SMOOTH);
|
|
|
|
|
|
|
|
if (is_compressed)
|
|
|
|
all_good =
|
2017-12-31 12:33:36 -07:00
|
|
|
DiscIO::DecompressBlobToFile(iso->GetFilePath(), WxStrToStr(path), &CompressCB, &dialog);
|
2016-06-24 02:43:46 -06:00
|
|
|
else
|
|
|
|
all_good = DiscIO::CompressFileToBlob(
|
2017-12-31 12:33:36 -07:00
|
|
|
iso->GetFilePath(), WxStrToStr(path),
|
2018-03-31 06:04:13 -06:00
|
|
|
(iso->GetPlatform() == DiscIO::Platform::WiiDisc) ? 1 : 0, 16384, &CompressCB, &dialog);
|
2016-06-24 02:43:46 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!all_good)
|
|
|
|
WxUtils::ShowErrorDialog(_("Dolphin was unable to complete the requested action."));
|
|
|
|
|
2017-06-20 17:36:59 -06:00
|
|
|
m_scan_trigger.Set();
|
2008-12-07 22:30:24 -07:00
|
|
|
}
|
|
|
|
|
2017-06-19 03:20:14 -06:00
|
|
|
void GameListCtrl::OnChangeDisc(wxCommandEvent& WXUNUSED(event))
|
2014-06-23 22:07:46 -06:00
|
|
|
{
|
2017-12-31 12:33:36 -07:00
|
|
|
const UICommon::GameFile* iso = GetSelectedISO();
|
2016-06-24 02:43:46 -06:00
|
|
|
if (!iso || !Core::IsRunning())
|
|
|
|
return;
|
2017-12-31 12:33:36 -07:00
|
|
|
Core::RunAsCPUThread([&iso] { DVDInterface::ChangeDisc(WxStrToStr(iso->GetFilePath())); });
|
2014-06-23 22:07:46 -06:00
|
|
|
}
|
|
|
|
|
2017-06-19 03:20:14 -06:00
|
|
|
void GameListCtrl::OnSize(wxSizeEvent& event)
|
2008-12-07 22:30:24 -07:00
|
|
|
{
|
2016-06-24 02:43:46 -06:00
|
|
|
event.Skip();
|
2017-06-19 03:25:30 -06:00
|
|
|
if (m_lastpos == event.GetSize())
|
2016-06-24 02:43:46 -06:00
|
|
|
return;
|
2013-04-07 23:16:50 -06:00
|
|
|
|
2017-06-19 03:25:30 -06:00
|
|
|
m_lastpos = event.GetSize();
|
2016-06-24 02:43:46 -06:00
|
|
|
AutomaticColumnWidth();
|
2008-12-07 22:30:24 -07:00
|
|
|
}
|
|
|
|
|
2017-06-19 03:20:14 -06:00
|
|
|
void GameListCtrl::AutomaticColumnWidth()
|
2008-12-07 22:30:24 -07:00
|
|
|
{
|
2016-06-24 02:43:46 -06:00
|
|
|
wxRect rc(GetClientRect());
|
|
|
|
|
|
|
|
Freeze();
|
|
|
|
if (GetColumnCount() == 1)
|
|
|
|
{
|
|
|
|
SetColumnWidth(0, rc.GetWidth());
|
|
|
|
}
|
|
|
|
else if (GetColumnCount() > 0)
|
|
|
|
{
|
2017-04-28 09:35:23 -06:00
|
|
|
int remaining_width = rc.GetWidth();
|
|
|
|
std::vector<int> visible_columns;
|
|
|
|
|
|
|
|
for (const auto& c : m_columns)
|
2017-04-17 11:34:14 -06:00
|
|
|
{
|
2017-04-28 09:35:23 -06:00
|
|
|
if (c.visible)
|
|
|
|
{
|
|
|
|
if (c.resizable)
|
|
|
|
visible_columns.push_back(c.id);
|
|
|
|
else
|
2017-05-08 18:40:42 -06:00
|
|
|
remaining_width -= GetColumnWidth(c.id);
|
2017-04-28 09:35:23 -06:00
|
|
|
}
|
2017-04-17 11:34:14 -06:00
|
|
|
}
|
2017-04-28 09:35:23 -06:00
|
|
|
|
|
|
|
if (visible_columns.empty())
|
|
|
|
visible_columns.push_back(COLUMN_DUMMY);
|
|
|
|
|
|
|
|
for (const int column : visible_columns)
|
|
|
|
SetColumnWidth(column, static_cast<int>(remaining_width / visible_columns.size()));
|
2016-06-24 02:43:46 -06:00
|
|
|
}
|
|
|
|
Thaw();
|
2008-12-07 22:30:24 -07:00
|
|
|
}
|
|
|
|
|
2017-06-19 03:20:14 -06:00
|
|
|
void GameListCtrl::UnselectAll()
|
2008-12-07 22:30:24 -07:00
|
|
|
{
|
2016-06-24 02:43:46 -06:00
|
|
|
for (int i = 0; i < GetItemCount(); i++)
|
|
|
|
{
|
|
|
|
SetItemState(i, 0, wxLIST_STATE_SELECTED);
|
|
|
|
}
|
2008-12-07 22:30:24 -07:00
|
|
|
}
|
2017-06-19 03:20:14 -06:00
|
|
|
bool GameListCtrl::WiiCompressWarning()
|
2015-10-31 11:44:45 -06:00
|
|
|
{
|
2016-06-24 02:43:46 -06:00
|
|
|
return wxMessageBox(_("Compressing a Wii disc image will irreversibly change the compressed copy "
|
|
|
|
"by removing padding data. Your disc image will still work. Continue?"),
|
|
|
|
_("Warning"), wxYES_NO) == wxYES;
|
2015-10-31 11:44:45 -06:00
|
|
|
}
|
2016-08-03 09:03:18 -06:00
|
|
|
|
|
|
|
#ifdef __WXMSW__
|
|
|
|
// Windows draws vertical rules between columns when using UXTheme (e.g. Aero, Win10)
|
|
|
|
// This function paints over those lines which removes them.
|
|
|
|
// [The repaint background idea is ripped off from Eclipse SWT which does the same thing]
|
2017-06-19 03:20:14 -06:00
|
|
|
bool GameListCtrl::MSWOnNotify(int id, WXLPARAM lparam, WXLPARAM* result)
|
2016-08-03 09:03:18 -06:00
|
|
|
{
|
|
|
|
NMLVCUSTOMDRAW* nmlv = reinterpret_cast<NMLVCUSTOMDRAW*>(lparam);
|
|
|
|
// Intercept the NM_CUSTOMDRAW[CDDS_PREPAINT]
|
|
|
|
// This event occurs after the background has been painted before the content of the list
|
|
|
|
// is painted. We can repaint the background to eliminate the column lines here.
|
|
|
|
if (nmlv->nmcd.hdr.hwndFrom == GetHWND() && nmlv->nmcd.hdr.code == NM_CUSTOMDRAW &&
|
|
|
|
nmlv->nmcd.dwDrawStage == CDDS_PREPAINT)
|
|
|
|
{
|
|
|
|
// The column separators have already been painted, paint over them.
|
|
|
|
wxDCTemp dc(nmlv->nmcd.hdc);
|
|
|
|
dc.SetBrush(GetBackgroundColour());
|
|
|
|
dc.SetPen(*wxTRANSPARENT_PEN);
|
|
|
|
dc.DrawRectangle(nmlv->nmcd.rc.left, nmlv->nmcd.rc.top,
|
|
|
|
nmlv->nmcd.rc.right - nmlv->nmcd.rc.left,
|
|
|
|
nmlv->nmcd.rc.bottom - nmlv->nmcd.rc.top);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Defer to wxWidgets for normal processing.
|
|
|
|
return wxListCtrl::MSWOnNotify(id, lparam, result);
|
|
|
|
}
|
|
|
|
#endif
|