summaryrefslogtreecommitdiff
path: root/Source/Core/DolphinWX/GameListCtrl.h
blob: 03aa01c93f48a4a13c70e3dec4c9f61ea162236f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
// Copyright 2013 Dolphin Emulator Project
// Licensed under GPLv2
// Refer to the license.txt file included.

#pragma once

#include <cstddef>
#include <string>
#include <vector>

#include <wx/event.h>
#include <wx/gdicmn.h>
#include <wx/listctrl.h>
#include <wx/string.h>
#include <wx/tipwin.h>
#include <wx/windowid.h>

#include "DolphinWX/ISOFile.h"

class wxListEvent;
class wxWindow;

class wxEmuStateTip : public wxTipWindow
{
public:
	wxEmuStateTip(wxWindow* parent, const wxString& text, wxEmuStateTip** windowPtr)
		: wxTipWindow(parent, text, 70, (wxTipWindow**)windowPtr) {}
	// wxTipWindow doesn't correctly handle KeyEvents and crashes... we must overload that.
	void OnKeyDown(wxKeyEvent& event) { event.StopPropagation(); Close(); }
private:
	DECLARE_EVENT_TABLE()
};

class CGameListCtrl : public wxListCtrl
{
public:

	CGameListCtrl(wxWindow* parent, const wxWindowID id, const wxPoint& pos, const wxSize& size, long style);
	~CGameListCtrl();

	void Update() override;

	void BrowseForDirectory();
	const GameListItem *GetSelectedISO();
	const GameListItem *GetISO(size_t index) const;

	enum
	{
		COLUMN_DUMMY = 0,
		COLUMN_PLATFORM,
		COLUMN_BANNER,
		COLUMN_TITLE,
		COLUMN_NOTES,
		COLUMN_ID,
		COLUMN_COUNTRY,
		COLUMN_SIZE,
		COLUMN_EMULATION_STATE,
		NUMBER_OF_COLUMN
	};

private:

	std::vector<int> m_FlagImageIndex;
	std::vector<int> m_PlatformImageIndex;
	std::vector<int> m_EmuStateImageIndex;
	std::vector<GameListItem*> m_ISOFiles;

	void ClearIsoFiles()
	{
		while (!m_ISOFiles.empty()) // so lazy
		{
			delete m_ISOFiles.back();
			m_ISOFiles.pop_back();
		}
	}

	int last_column;
	int last_sort;
	wxSize lastpos;
	wxEmuStateTip *toolTip;
	void InitBitmaps();
	void InsertItemInReportView(long _Index);
	void SetBackgroundColor();
	void ScanForISOs();

	DECLARE_EVENT_TABLE()

	// events
	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);
	void OnOpenContainingFolder(wxCommandEvent& event);
	void OnOpenSaveFolder(wxCommandEvent& event);
	void OnExportSave(wxCommandEvent& event);
	void OnSetDefaultGCM(wxCommandEvent& event);
	void OnDeleteGCM(wxCommandEvent& event);
	void OnCompressGCM(wxCommandEvent& event);
	void OnMultiCompressGCM(wxCommandEvent& event);
	void OnMultiDecompressGCM(wxCommandEvent& event);
	void OnInstallWAD(wxCommandEvent& event);
	void OnChangeDisc(wxCommandEvent& event);

	void CompressSelection(bool _compress);
	void AutomaticColumnWidth();
	void UnselectAll();

	static size_t m_currentItem;
	static std::string m_currentFilename;
	static size_t m_numberItem;
	static void CompressCB(const std::string& text, float percent, void* arg);
	static void MultiCompressCB(const std::string& text, float percent, void* arg);
};