main.h 3.6 KB

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