main.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  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 InitializeDebugMenuActions();
  57. void InitializeRecentFileMenuActions();
  58. void InitializeHotkeys();
  59. void SetDefaultUIGeometry();
  60. void RestoreUIState();
  61. void ConnectWidgetEvents();
  62. /**
  63. * Initializes the emulation system.
  64. * @param system_mode The system mode with which to intialize the kernel.
  65. * @returns Whether the system was properly initialized.
  66. */
  67. bool InitializeSystem(u32 system_mode);
  68. bool LoadROM(const std::string& filename);
  69. void BootGame(const std::string& filename);
  70. void ShutdownGame();
  71. /**
  72. * Stores the filename in the recently loaded files list.
  73. * The new filename is stored at the beginning of the recently loaded files list.
  74. * After inserting the new entry, duplicates are removed meaning that if
  75. * this was inserted from \a OnMenuRecentFile(), the entry will be put on top
  76. * and remove from its previous position.
  77. *
  78. * Finally, this function calls \a UpdateRecentFiles() to update the UI.
  79. *
  80. * @param filename the filename to store
  81. */
  82. void StoreRecentFile(const std::string& filename);
  83. /**
  84. * Updates the recent files menu.
  85. * Menu entries are rebuilt from the configuration file.
  86. * If there is no entry in the menu, the menu is greyed out.
  87. */
  88. void UpdateRecentFiles();
  89. /**
  90. * If the emulation is running,
  91. * asks the user if he really want to close the emulator
  92. *
  93. * @return true if the user confirmed
  94. */
  95. bool ConfirmClose();
  96. bool ConfirmChangeGame();
  97. void closeEvent(QCloseEvent* event) override;
  98. private slots:
  99. void OnStartGame();
  100. void OnPauseGame();
  101. void OnStopGame();
  102. /// Called whenever a user selects a game in the game list widget.
  103. void OnGameListLoadFile(QString game_path);
  104. void OnGameListOpenSaveFolder(u64 program_id);
  105. void OnMenuLoadFile();
  106. void OnMenuLoadSymbolMap();
  107. /// Called whenever a user selects the "File->Select Game List Root" menu item
  108. void OnMenuSelectGameListRoot();
  109. void OnMenuRecentFile();
  110. void OnSwapScreens();
  111. void OnConfigure();
  112. void OnDisplayTitleBars(bool);
  113. void ToggleWindowMode();
  114. void OnCreateGraphicsSurfaceViewer();
  115. private:
  116. Ui::MainWindow ui;
  117. GRenderWindow* render_window;
  118. GameList* game_list;
  119. std::unique_ptr<Config> config;
  120. // Whether emulation is currently running in Citra.
  121. bool emulation_running = false;
  122. std::unique_ptr<EmuThread> emu_thread;
  123. ProfilerWidget* profilerWidget;
  124. MicroProfileDialog* microProfileDialog;
  125. DisassemblerWidget* disasmWidget;
  126. RegistersWidget* registersWidget;
  127. CallstackWidget* callstackWidget;
  128. GPUCommandStreamWidget* graphicsWidget;
  129. GPUCommandListWidget* graphicsCommandsWidget;
  130. GraphicsBreakPointsWidget* graphicsBreakpointsWidget;
  131. GraphicsVertexShaderWidget* graphicsVertexShaderWidget;
  132. GraphicsTracingWidget* graphicsTracingWidget;
  133. WaitTreeWidget* waitTreeWidget;
  134. QAction* actions_recent_files[max_recent_files_item];
  135. protected:
  136. void dropEvent(QDropEvent* event) override;
  137. void dragEnterEvent(QDragEnterEvent* event) override;
  138. void dragMoveEvent(QDragMoveEvent* event) override;
  139. };
  140. #endif // _CITRA_QT_MAIN_HXX_