main.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  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 Config;
  10. class GameList;
  11. class GImageInfo;
  12. class GRenderWindow;
  13. class EmuThread;
  14. class ProfilerWidget;
  15. class MicroProfileDialog;
  16. class DisassemblerWidget;
  17. class RegistersWidget;
  18. class CallstackWidget;
  19. class GPUCommandStreamWidget;
  20. class GPUCommandListWidget;
  21. class WaitTreeWidget;
  22. class GMainWindow : public QMainWindow {
  23. Q_OBJECT
  24. /// Max number of recently loaded items to keep track of
  25. static const int max_recent_files_item = 10;
  26. // TODO: Make use of this!
  27. enum {
  28. UI_IDLE,
  29. UI_EMU_BOOTING,
  30. UI_EMU_RUNNING,
  31. UI_EMU_STOPPING,
  32. };
  33. public:
  34. GMainWindow();
  35. ~GMainWindow();
  36. signals:
  37. /**
  38. * Signal that is emitted when a new EmuThread has been created and an emulation session is
  39. * about to start. At this time, the core system emulation has been initialized, and all
  40. * emulation handles and memory should be valid.
  41. *
  42. * @param emu_thread Pointer to the newly created EmuThread (to be used by widgets that need to
  43. * access/change emulation state).
  44. */
  45. void EmulationStarting(EmuThread* emu_thread);
  46. /**
  47. * Signal that is emitted when emulation is about to stop. At this time, the EmuThread and core
  48. * system emulation handles and memory are still valid, but are about become invalid.
  49. */
  50. void EmulationStopping();
  51. private:
  52. /**
  53. * Initializes the emulation system.
  54. * @param system_mode The system mode with which to intialize the kernel.
  55. * @returns Whether the system was properly initialized.
  56. */
  57. bool InitializeSystem(u32 system_mode);
  58. bool LoadROM(const std::string& filename);
  59. void BootGame(const std::string& filename);
  60. void ShutdownGame();
  61. /**
  62. * Stores the filename in the recently loaded files list.
  63. * The new filename is stored at the beginning of the recently loaded files list.
  64. * After inserting the new entry, duplicates are removed meaning that if
  65. * this was inserted from \a OnMenuRecentFile(), the entry will be put on top
  66. * and remove from its previous position.
  67. *
  68. * Finally, this function calls \a UpdateRecentFiles() to update the UI.
  69. *
  70. * @param filename the filename to store
  71. */
  72. void StoreRecentFile(const std::string& filename);
  73. /**
  74. * Updates the recent files menu.
  75. * Menu entries are rebuilt from the configuration file.
  76. * If there is no entry in the menu, the menu is greyed out.
  77. */
  78. void UpdateRecentFiles();
  79. /**
  80. * If the emulation is running,
  81. * asks the user if he really want to close the emulator
  82. *
  83. * @return true if the user confirmed
  84. */
  85. bool ConfirmClose();
  86. void closeEvent(QCloseEvent* event) override;
  87. private slots:
  88. void OnStartGame();
  89. void OnPauseGame();
  90. void OnStopGame();
  91. /// Called whenever a user selects a game in the game list widget.
  92. void OnGameListLoadFile(QString game_path);
  93. void OnGameListOpenSaveFolder(u64 program_id);
  94. void OnMenuLoadFile();
  95. void OnMenuLoadSymbolMap();
  96. /// Called whenever a user selects the "File->Select Game List Root" menu item
  97. void OnMenuSelectGameListRoot();
  98. void OnMenuRecentFile();
  99. void OnSwapScreens();
  100. void OnConfigure();
  101. void OnDisplayTitleBars(bool);
  102. void ToggleWindowMode();
  103. void OnCreateGraphicsSurfaceViewer();
  104. private:
  105. Ui::MainWindow ui;
  106. GRenderWindow* render_window;
  107. GameList* game_list;
  108. std::unique_ptr<Config> config;
  109. // Whether emulation is currently running in Citra.
  110. bool emulation_running = false;
  111. std::unique_ptr<EmuThread> emu_thread;
  112. ProfilerWidget* profilerWidget;
  113. MicroProfileDialog* microProfileDialog;
  114. DisassemblerWidget* disasmWidget;
  115. RegistersWidget* registersWidget;
  116. CallstackWidget* callstackWidget;
  117. GPUCommandStreamWidget* graphicsWidget;
  118. GPUCommandListWidget* graphicsCommandsWidget;
  119. WaitTreeWidget* waitTreeWidget;
  120. QAction* actions_recent_files[max_recent_files_item];
  121. };
  122. #endif // _CITRA_QT_MAIN_HXX_