main.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  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 "core/core.h"
  10. #include "ui_main.h"
  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. void UpdateUITheme();
  39. GMainWindow();
  40. ~GMainWindow();
  41. signals:
  42. /**
  43. * Signal that is emitted when a new EmuThread has been created and an emulation session is
  44. * about to start. At this time, the core system emulation has been initialized, and all
  45. * emulation handles and memory should be valid.
  46. *
  47. * @param emu_thread Pointer to the newly created EmuThread (to be used by widgets that need to
  48. * access/change emulation state).
  49. */
  50. void EmulationStarting(EmuThread* emu_thread);
  51. /**
  52. * Signal that is emitted when emulation is about to stop. At this time, the EmuThread and core
  53. * system emulation handles and memory are still valid, but are about become invalid.
  54. */
  55. void EmulationStopping();
  56. private:
  57. void InitializeWidgets();
  58. void InitializeDebugWidgets();
  59. void InitializeRecentFileMenuActions();
  60. void InitializeHotkeys();
  61. void SetDefaultUIGeometry();
  62. void RestoreUIState();
  63. void ConnectWidgetEvents();
  64. void ConnectMenuEvents();
  65. bool LoadROM(const QString& filename);
  66. void BootGame(const QString& filename);
  67. void ShutdownGame();
  68. void ShowCallouts();
  69. /**
  70. * Stores the filename in the recently loaded files list.
  71. * The new filename is stored at the beginning of the recently loaded files list.
  72. * After inserting the new entry, duplicates are removed meaning that if
  73. * this was inserted from \a OnMenuRecentFile(), the entry will be put on top
  74. * and remove from its previous position.
  75. *
  76. * Finally, this function calls \a UpdateRecentFiles() to update the UI.
  77. *
  78. * @param filename the filename to store
  79. */
  80. void StoreRecentFile(const QString& filename);
  81. /**
  82. * Updates the recent files menu.
  83. * Menu entries are rebuilt from the configuration file.
  84. * If there is no entry in the menu, the menu is greyed out.
  85. */
  86. void UpdateRecentFiles();
  87. /**
  88. * If the emulation is running,
  89. * asks the user if he really want to close the emulator
  90. *
  91. * @return true if the user confirmed
  92. */
  93. bool ConfirmClose();
  94. bool ConfirmChangeGame();
  95. void closeEvent(QCloseEvent* event) override;
  96. private slots:
  97. void OnStartGame();
  98. void OnPauseGame();
  99. void OnStopGame();
  100. /// Called whenever a user selects a game in the game list widget.
  101. void OnGameListLoadFile(QString game_path);
  102. void OnGameListOpenSaveFolder(u64 program_id);
  103. void OnMenuLoadFile();
  104. /// Called whenever a user selects the "File->Select Game List Root" menu item
  105. void OnMenuSelectGameListRoot();
  106. void OnMenuRecentFile();
  107. void OnSwapScreens();
  108. void OnConfigure();
  109. void OnToggleFilterBar();
  110. void OnDisplayTitleBars(bool);
  111. void ToggleWindowMode();
  112. void OnCreateGraphicsSurfaceViewer();
  113. void OnCoreError(Core::System::ResultStatus, std::string);
  114. private:
  115. void UpdateStatusBar();
  116. Ui::MainWindow ui;
  117. GRenderWindow* render_window;
  118. GameList* game_list;
  119. // Status bar elements
  120. QLabel* message_label = nullptr;
  121. QLabel* emu_speed_label = nullptr;
  122. QLabel* game_fps_label = nullptr;
  123. QLabel* emu_frametime_label = nullptr;
  124. QTimer status_bar_update_timer;
  125. std::unique_ptr<Config> config;
  126. // Whether emulation is currently running in Citra.
  127. bool emulation_running = false;
  128. std::unique_ptr<EmuThread> emu_thread;
  129. // Debugger panes
  130. ProfilerWidget* profilerWidget;
  131. MicroProfileDialog* microProfileDialog;
  132. RegistersWidget* registersWidget;
  133. GPUCommandStreamWidget* graphicsWidget;
  134. GPUCommandListWidget* graphicsCommandsWidget;
  135. GraphicsBreakPointsWidget* graphicsBreakpointsWidget;
  136. GraphicsVertexShaderWidget* graphicsVertexShaderWidget;
  137. GraphicsTracingWidget* graphicsTracingWidget;
  138. WaitTreeWidget* waitTreeWidget;
  139. QAction* actions_recent_files[max_recent_files_item];
  140. protected:
  141. void dropEvent(QDropEvent* event) override;
  142. void dragEnterEvent(QDragEnterEvent* event) override;
  143. void dragMoveEvent(QDragMoveEvent* event) override;
  144. };
  145. #endif // _CITRA_QT_MAIN_HXX_