main.h 4.6 KB

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