2015-05-24 04:55:12 +00:00
|
|
|
// Copyright 2008 Dolphin Emulator Project
|
2015-05-17 23:08:10 +00:00
|
|
|
// Licensed under GPLv2+
|
2013-04-18 03:43:35 +00:00
|
|
|
// Refer to the license.txt file included.
|
2008-12-08 04:46:09 +00:00
|
|
|
|
2014-02-10 18:54:46 +00:00
|
|
|
#pragma once
|
2008-12-08 04:46:09 +00:00
|
|
|
|
2014-02-22 22:36:30 +00:00
|
|
|
#include <cstddef>
|
2016-09-30 07:13:12 +00:00
|
|
|
#include <memory>
|
2014-02-22 22:36:30 +00:00
|
|
|
#include <string>
|
2017-06-21 04:24:26 +00:00
|
|
|
#include <thread>
|
2008-12-08 04:46:09 +00:00
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
#include <wx/listctrl.h>
|
2009-09-25 16:29:00 +00:00
|
|
|
#include <wx/tipwin.h>
|
2008-12-08 04:46:09 +00:00
|
|
|
|
2017-06-20 23:36:59 +00:00
|
|
|
#include "Common/ChunkFile.h"
|
|
|
|
#include "Common/Event.h"
|
2017-06-21 04:24:26 +00:00
|
|
|
#include "Common/Flag.h"
|
2017-12-31 19:33:36 +00:00
|
|
|
#include "UICommon/GameFileCache.h"
|
|
|
|
|
|
|
|
namespace UICommon
|
|
|
|
{
|
|
|
|
class GameFile;
|
|
|
|
}
|
2014-02-22 22:36:30 +00:00
|
|
|
|
2009-09-25 16:29:00 +00:00
|
|
|
class wxEmuStateTip : public wxTipWindow
|
|
|
|
{
|
|
|
|
public:
|
2016-06-24 08:43:46 +00:00
|
|
|
wxEmuStateTip(wxWindow* parent, const wxString& text, wxEmuStateTip** windowPtr)
|
|
|
|
: wxTipWindow(parent, text, 70, (wxTipWindow**)windowPtr)
|
|
|
|
{
|
|
|
|
Bind(wxEVT_KEY_DOWN, &wxEmuStateTip::OnKeyDown, this);
|
|
|
|
}
|
|
|
|
|
|
|
|
// wxTipWindow doesn't correctly handle KeyEvents and crashes... we must overload that.
|
|
|
|
void OnKeyDown(wxKeyEvent& event)
|
|
|
|
{
|
|
|
|
event.StopPropagation();
|
|
|
|
Close();
|
|
|
|
}
|
2009-09-25 16:29:00 +00:00
|
|
|
};
|
|
|
|
|
2017-06-20 23:36:59 +00:00
|
|
|
wxDECLARE_EVENT(DOLPHIN_EVT_REFRESH_GAMELIST, wxCommandEvent);
|
|
|
|
wxDECLARE_EVENT(DOLPHIN_EVT_RESCAN_GAMELIST, wxCommandEvent);
|
2016-11-06 00:53:40 +00:00
|
|
|
|
2017-06-19 09:20:14 +00:00
|
|
|
class GameListCtrl : public wxListCtrl
|
2008-12-08 04:46:09 +00:00
|
|
|
{
|
|
|
|
public:
|
2017-06-20 23:36:59 +00:00
|
|
|
GameListCtrl(bool disable_scanning, wxWindow* parent, const wxWindowID id, const wxPoint& pos,
|
|
|
|
const wxSize& size, long style);
|
|
|
|
~GameListCtrl();
|
2016-06-24 08:43:46 +00:00
|
|
|
|
|
|
|
void BrowseForDirectory();
|
2017-12-31 19:33:36 +00:00
|
|
|
const UICommon::GameFile* GetISO(size_t index) const;
|
|
|
|
const UICommon::GameFile* GetSelectedISO() const;
|
2016-06-24 08:43:46 +00:00
|
|
|
|
|
|
|
static bool IsHidingItems();
|
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
COLUMN_DUMMY = 0,
|
2017-06-19 09:25:30 +00:00
|
|
|
FIRST_COLUMN_WITH_CONTENT,
|
|
|
|
COLUMN_PLATFORM = FIRST_COLUMN_WITH_CONTENT,
|
2016-06-24 08:43:46 +00:00
|
|
|
COLUMN_BANNER,
|
|
|
|
COLUMN_TITLE,
|
|
|
|
COLUMN_MAKER,
|
|
|
|
COLUMN_FILENAME,
|
|
|
|
COLUMN_ID,
|
|
|
|
COLUMN_COUNTRY,
|
|
|
|
COLUMN_SIZE,
|
|
|
|
COLUMN_EMULATION_STATE,
|
|
|
|
NUMBER_OF_COLUMN
|
|
|
|
};
|
2008-12-08 04:46:09 +00:00
|
|
|
|
2016-08-03 15:03:18 +00:00
|
|
|
#ifdef __WXMSW__
|
|
|
|
bool MSWOnNotify(int id, WXLPARAM lparam, WXLPARAM* result) override;
|
|
|
|
#endif
|
|
|
|
|
2008-12-08 04:46:09 +00:00
|
|
|
private:
|
2017-04-28 15:35:23 +00:00
|
|
|
struct ColumnInfo;
|
|
|
|
|
2016-06-24 08:43:46 +00:00
|
|
|
void InitBitmaps();
|
2017-06-19 09:25:30 +00:00
|
|
|
void UpdateItemAtColumn(long index, int column);
|
|
|
|
void InsertItemInReportView(long index);
|
2017-02-19 08:02:00 +00:00
|
|
|
void SetColors();
|
2017-06-20 23:36:59 +00:00
|
|
|
void RefreshList();
|
|
|
|
void RescanList();
|
2017-12-31 19:33:36 +00:00
|
|
|
std::vector<const UICommon::GameFile*> GetAllSelectedISOs() const;
|
2016-06-24 08:43:46 +00:00
|
|
|
|
|
|
|
// events
|
2017-06-20 23:36:59 +00:00
|
|
|
void OnRefreshGameList(wxCommandEvent& event);
|
|
|
|
void OnRescanGameList(wxCommandEvent& event);
|
2016-06-24 08:43:46 +00:00
|
|
|
void OnLeftClick(wxMouseEvent& event);
|
|
|
|
void OnRightClick(wxMouseEvent& event);
|
|
|
|
void OnMouseMotion(wxMouseEvent& event);
|
|
|
|
void OnColumnClick(wxListEvent& event);
|
|
|
|
void OnColBeginDrag(wxListEvent& event);
|
|
|
|
void OnKeyPress(wxListEvent& event);
|
|
|
|
void OnSize(wxSizeEvent& event);
|
|
|
|
void OnProperties(wxCommandEvent& event);
|
|
|
|
void OnWiki(wxCommandEvent& event);
|
2016-10-03 12:35:27 +00:00
|
|
|
void OnNetPlayHost(wxCommandEvent& event);
|
2016-06-24 08:43:46 +00:00
|
|
|
void OnOpenContainingFolder(wxCommandEvent& event);
|
|
|
|
void OnOpenSaveFolder(wxCommandEvent& event);
|
|
|
|
void OnExportSave(wxCommandEvent& event);
|
|
|
|
void OnSetDefaultISO(wxCommandEvent& event);
|
|
|
|
void OnDeleteISO(wxCommandEvent& event);
|
|
|
|
void OnCompressISO(wxCommandEvent& event);
|
|
|
|
void OnMultiCompressISO(wxCommandEvent& event);
|
|
|
|
void OnMultiDecompressISO(wxCommandEvent& event);
|
|
|
|
void OnChangeDisc(wxCommandEvent& event);
|
|
|
|
void OnLocalIniModified(wxCommandEvent& event);
|
|
|
|
|
|
|
|
void CompressSelection(bool _compress);
|
|
|
|
void AutomaticColumnWidth();
|
|
|
|
void UnselectAll();
|
|
|
|
|
|
|
|
static bool CompressCB(const std::string& text, float percent, void* arg);
|
|
|
|
static bool MultiCompressCB(const std::string& text, float percent, void* arg);
|
|
|
|
static bool WiiCompressWarning();
|
2016-11-06 00:53:40 +00:00
|
|
|
|
2017-06-20 23:36:59 +00:00
|
|
|
struct
|
|
|
|
{
|
2017-06-19 09:25:30 +00:00
|
|
|
std::vector<int> flag;
|
|
|
|
std::vector<int> platform;
|
|
|
|
std::vector<int> utility_banner;
|
|
|
|
std::vector<int> emu_state;
|
|
|
|
} m_image_indexes;
|
|
|
|
|
2017-12-31 19:33:36 +00:00
|
|
|
// Actual backing GameFiles are maintained in a background thread and cached to file
|
|
|
|
UICommon::GameFileCache m_cache;
|
|
|
|
// Locks the cache object, not the shared_ptr<GameFile>s obtained from it
|
2017-06-26 03:13:42 +00:00
|
|
|
std::mutex m_cache_mutex;
|
|
|
|
Core::TitleDatabase m_title_database;
|
|
|
|
std::mutex m_title_database_mutex;
|
2017-06-20 23:36:59 +00:00
|
|
|
std::thread m_scan_thread;
|
|
|
|
Common::Event m_scan_trigger;
|
|
|
|
Common::Flag m_scan_exiting;
|
|
|
|
// UI thread's view into the cache
|
2017-12-31 19:33:36 +00:00
|
|
|
std::vector<std::shared_ptr<const UICommon::GameFile>> m_shown_files;
|
2017-06-20 23:36:59 +00:00
|
|
|
|
2017-06-19 09:25:30 +00:00
|
|
|
int m_last_column;
|
|
|
|
int m_last_sort;
|
|
|
|
wxSize m_lastpos;
|
|
|
|
wxEmuStateTip* m_tooltip;
|
2017-04-28 15:35:23 +00:00
|
|
|
|
|
|
|
std::vector<ColumnInfo> m_columns;
|
2008-12-08 04:46:09 +00:00
|
|
|
};
|