main.h 3.8 KB

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