main.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. // Copyright 2014 Citra Emulator Project
  2. // Licensed under GPLv2 or any later version
  3. // Refer to the license.txt file included.
  4. #ifndef _CITRA_QT_MAIN_HXX_
  5. #define _CITRA_QT_MAIN_HXX_
  6. #include <memory>
  7. #include <QMainWindow>
  8. #include <QTimer>
  9. #include "ui_main.h"
  10. class CallstackWidget;
  11. class Config;
  12. class EmuThread;
  13. class GameList;
  14. class GImageInfo;
  15. class GPUCommandStreamWidget;
  16. class GPUCommandListWidget;
  17. class GraphicsBreakPointsWidget;
  18. class GraphicsTracingWidget;
  19. class GraphicsVertexShaderWidget;
  20. class GRenderWindow;
  21. class MicroProfileDialog;
  22. class ProfilerWidget;
  23. class RegistersWidget;
  24. class WaitTreeWidget;
  25. class GMainWindow : public QMainWindow {
  26. Q_OBJECT
  27. /// Max number of recently loaded items to keep track of
  28. static const int max_recent_files_item = 10;
  29. // TODO: Make use of this!
  30. enum {
  31. UI_IDLE,
  32. UI_EMU_BOOTING,
  33. UI_EMU_RUNNING,
  34. UI_EMU_STOPPING,
  35. };
  36. public:
  37. void filterBarSetChecked(bool state);
  38. GMainWindow();
  39. ~GMainWindow();
  40. signals:
  41. /**
  42. * Signal that is emitted when a new EmuThread has been created and an emulation session is
  43. * about to start. At this time, the core system emulation has been initialized, and all
  44. * emulation handles and memory should be valid.
  45. *
  46. * @param emu_thread Pointer to the newly created EmuThread (to be used by widgets that need to
  47. * access/change emulation state).
  48. */
  49. void EmulationStarting(EmuThread* emu_thread);
  50. /**
  51. * Signal that is emitted when emulation is about to stop. At this time, the EmuThread and core
  52. * system emulation handles and memory are still valid, but are about become invalid.
  53. */
  54. void EmulationStopping();
  55. private:
  56. void InitializeWidgets();
  57. void InitializeDebugWidgets();
  58. void InitializeRecentFileMenuActions();
  59. void InitializeHotkeys();
  60. void SetDefaultUIGeometry();
  61. void RestoreUIState();
  62. void ConnectWidgetEvents();
  63. void ConnectMenuEvents();
  64. bool LoadROM(const QString& filename);
  65. void BootGame(const QString& filename);
  66. void ShutdownGame();
  67. /**
  68. * Stores the filename in the recently loaded files list.
  69. * The new filename is stored at the beginning of the recently loaded files list.
  70. * After inserting the new entry, duplicates are removed meaning that if
  71. * this was inserted from \a OnMenuRecentFile(), the entry will be put on top
  72. * and remove from its previous position.
  73. *
  74. * Finally, this function calls \a UpdateRecentFiles() to update the UI.
  75. *
  76. * @param filename the filename to store
  77. */
  78. void StoreRecentFile(const QString& filename);
  79. /**
  80. * Updates the recent files menu.
  81. * Menu entries are rebuilt from the configuration file.
  82. * If there is no entry in the menu, the menu is greyed out.
  83. */
  84. void UpdateRecentFiles();
  85. /**
  86. * If the emulation is running,
  87. * asks the user if he really want to close the emulator
  88. *
  89. * @return true if the user confirmed
  90. */
  91. bool ConfirmClose();
  92. bool ConfirmChangeGame();
  93. void closeEvent(QCloseEvent* event) override;
  94. private slots:
  95. void OnStartGame();
  96. void OnPauseGame();
  97. void OnStopGame();
  98. /// Called whenever a user selects a game in the game list widget.
  99. void OnGameListLoadFile(QString game_path);
  100. void OnGameListOpenSaveFolder(u64 program_id);
  101. void OnMenuLoadFile();
  102. void OnMenuLoadSymbolMap();
  103. /// Called whenever a user selects the "File->Select Game List Root" menu item
  104. void OnMenuSelectGameListRoot();
  105. void OnMenuRecentFile();
  106. void OnSwapScreens();
  107. void OnConfigure();
  108. void OnToggleFilterBar();
  109. void OnDisplayTitleBars(bool);
  110. void ToggleWindowMode();
  111. void OnCreateGraphicsSurfaceViewer();
  112. private:
  113. void UpdateStatusBar();
  114. Ui::MainWindow ui;
  115. GRenderWindow* render_window;
  116. GameList* game_list;
  117. // Status bar elements
  118. QLabel* emu_speed_label = nullptr;
  119. QLabel* game_fps_label = nullptr;
  120. QLabel* emu_frametime_label = nullptr;
  121. QTimer status_bar_update_timer;
  122. std::unique_ptr<Config> config;
  123. // Whether emulation is currently running in Citra.
  124. bool emulation_running = false;
  125. std::unique_ptr<EmuThread> emu_thread;
  126. // Debugger panes
  127. ProfilerWidget* profilerWidget;
  128. MicroProfileDialog* microProfileDialog;
  129. RegistersWidget* registersWidget;
  130. CallstackWidget* callstackWidget;
  131. GPUCommandStreamWidget* graphicsWidget;
  132. GPUCommandListWidget* graphicsCommandsWidget;
  133. GraphicsBreakPointsWidget* graphicsBreakpointsWidget;
  134. GraphicsVertexShaderWidget* graphicsVertexShaderWidget;
  135. GraphicsTracingWidget* graphicsTracingWidget;
  136. WaitTreeWidget* waitTreeWidget;
  137. QAction* actions_recent_files[max_recent_files_item];
  138. protected:
  139. void dropEvent(QDropEvent* event) override;
  140. void dragEnterEvent(QDragEnterEvent* event) override;
  141. void dragMoveEvent(QDragMoveEvent* event) override;
  142. };
  143. #endif // _CITRA_QT_MAIN_HXX_