main.h 4.9 KB

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