GameListCtrl.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. // Copyright 2008 Dolphin Emulator Project
  2. // Licensed under GPLv2+
  3. // Refer to the license.txt file included.
  4. #pragma once
  5. #include <cstddef>
  6. #include <string>
  7. #include <vector>
  8. #include <wx/listctrl.h>
  9. #include <wx/tipwin.h>
  10. #include "DolphinWX/ISOFile.h"
  11. class wxEmuStateTip : public wxTipWindow
  12. {
  13. public:
  14. wxEmuStateTip(wxWindow* parent, const wxString& text, wxEmuStateTip** windowPtr)
  15. : wxTipWindow(parent, text, 70, (wxTipWindow**)windowPtr)
  16. {
  17. Bind(wxEVT_KEY_DOWN, &wxEmuStateTip::OnKeyDown, this);
  18. }
  19. // wxTipWindow doesn't correctly handle KeyEvents and crashes... we must overload that.
  20. void OnKeyDown(wxKeyEvent& event) { event.StopPropagation(); Close(); }
  21. };
  22. class CGameListCtrl : public wxListCtrl
  23. {
  24. public:
  25. CGameListCtrl(wxWindow* parent, const wxWindowID id, const wxPoint& pos, const wxSize& size, long style);
  26. ~CGameListCtrl();
  27. void Update() override;
  28. void BrowseForDirectory();
  29. const GameListItem *GetSelectedISO();
  30. const GameListItem *GetISO(size_t index) const;
  31. enum
  32. {
  33. COLUMN_DUMMY = 0,
  34. COLUMN_PLATFORM,
  35. COLUMN_BANNER,
  36. COLUMN_TITLE,
  37. COLUMN_MAKER,
  38. COLUMN_ID,
  39. COLUMN_COUNTRY,
  40. COLUMN_SIZE,
  41. COLUMN_EMULATION_STATE,
  42. NUMBER_OF_COLUMN
  43. };
  44. private:
  45. std::vector<int> m_FlagImageIndex;
  46. std::vector<int> m_PlatformImageIndex;
  47. std::vector<int> m_EmuStateImageIndex;
  48. std::vector<GameListItem*> m_ISOFiles;
  49. void ClearIsoFiles()
  50. {
  51. while (!m_ISOFiles.empty()) // so lazy
  52. {
  53. delete m_ISOFiles.back();
  54. m_ISOFiles.pop_back();
  55. }
  56. }
  57. int last_column;
  58. int last_sort;
  59. wxSize lastpos;
  60. wxEmuStateTip *toolTip;
  61. void InitBitmaps();
  62. void InsertItemInReportView(long _Index);
  63. void SetBackgroundColor();
  64. void ScanForISOs();
  65. // events
  66. void OnLeftClick(wxMouseEvent& event);
  67. void OnRightClick(wxMouseEvent& event);
  68. void OnMouseMotion(wxMouseEvent& event);
  69. void OnColumnClick(wxListEvent& event);
  70. void OnColBeginDrag(wxListEvent& event);
  71. void OnKeyPress(wxListEvent& event);
  72. void OnSize(wxSizeEvent& event);
  73. void OnProperties(wxCommandEvent& event);
  74. void OnWiki(wxCommandEvent& event);
  75. void OnOpenContainingFolder(wxCommandEvent& event);
  76. void OnOpenSaveFolder(wxCommandEvent& event);
  77. void OnExportSave(wxCommandEvent& event);
  78. void OnSetDefaultISO(wxCommandEvent& event);
  79. void OnDeleteISO(wxCommandEvent& event);
  80. void OnCompressISO(wxCommandEvent& event);
  81. void OnMultiCompressISO(wxCommandEvent& event);
  82. void OnMultiDecompressISO(wxCommandEvent& event);
  83. void OnInstallWAD(wxCommandEvent& event);
  84. void OnChangeDisc(wxCommandEvent& event);
  85. void CompressSelection(bool _compress);
  86. void AutomaticColumnWidth();
  87. void UnselectAll();
  88. static size_t m_currentItem;
  89. static std::string m_currentFilename;
  90. static size_t m_numberItem;
  91. static bool CompressCB(const std::string& text, float percent, void* arg);
  92. static bool MultiCompressCB(const std::string& text, float percent, void* arg);
  93. };