2020-12-05 13:08:24 +01:00
|
|
|
#pragma once
|
2019-06-18 04:02:06 +02:00
|
|
|
|
2020-12-22 09:42:57 +01:00
|
|
|
#include "util/types.hpp"
|
2022-06-24 19:58:26 +02:00
|
|
|
#include "util/atomic.hpp"
|
2019-06-18 04:02:06 +02:00
|
|
|
|
2019-06-21 13:33:32 +02:00
|
|
|
#include <QApplication>
|
2020-02-22 20:42:49 +01:00
|
|
|
#include <QElapsedTimer>
|
2020-04-28 19:12:36 +02:00
|
|
|
#include <QTimer>
|
2020-02-22 20:42:49 +01:00
|
|
|
#include <QTranslator>
|
2021-05-22 10:42:05 +02:00
|
|
|
#include <QSoundEffect>
|
2019-06-21 13:33:32 +02:00
|
|
|
|
|
|
|
|
#include "main_application.h"
|
2020-02-22 20:42:49 +01:00
|
|
|
|
2023-07-07 09:31:35 +02:00
|
|
|
#include "Emu/System.h"
|
|
|
|
|
|
2020-12-22 09:42:57 +01:00
|
|
|
#include <memory>
|
|
|
|
|
#include <functional>
|
|
|
|
|
|
2020-02-22 20:42:49 +01:00
|
|
|
class gs_frame;
|
|
|
|
|
class main_window;
|
|
|
|
|
class gui_settings;
|
|
|
|
|
class emu_settings;
|
|
|
|
|
class persistent_settings;
|
2019-06-18 04:02:06 +02:00
|
|
|
|
2019-07-11 23:11:52 +02:00
|
|
|
/** RPCS3 GUI Application Class
|
|
|
|
|
* The main point of this class is to do application initialization, to hold the main and game windows and to initialize callbacks.
|
|
|
|
|
*/
|
2019-06-18 04:02:06 +02:00
|
|
|
class gui_application : public QApplication, public main_application
|
|
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
public:
|
|
|
|
|
gui_application(int& argc, char** argv);
|
2019-08-25 11:51:13 +02:00
|
|
|
~gui_application();
|
2019-06-18 04:02:06 +02:00
|
|
|
|
2019-09-08 18:27:36 +02:00
|
|
|
void SetShowGui(bool show_gui = true)
|
|
|
|
|
{
|
|
|
|
|
m_show_gui = show_gui;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SetUseCliStyle(bool use_cli_style = false)
|
|
|
|
|
{
|
|
|
|
|
m_use_cli_style = use_cli_style;
|
|
|
|
|
}
|
|
|
|
|
|
2021-03-25 22:55:06 +01:00
|
|
|
void SetWithCliBoot(bool with_cli_boot = false)
|
|
|
|
|
{
|
|
|
|
|
m_with_cli_boot = with_cli_boot;
|
|
|
|
|
}
|
|
|
|
|
|
2023-02-13 20:57:25 +01:00
|
|
|
void SetStartGamesFullscreen(bool start_games_fullscreen = false)
|
|
|
|
|
{
|
|
|
|
|
m_start_games_fullscreen = start_games_fullscreen;
|
|
|
|
|
}
|
|
|
|
|
|
2023-02-13 21:12:15 +01:00
|
|
|
void SetGameScreenIndex(int screen_index = -1)
|
|
|
|
|
{
|
|
|
|
|
m_game_screen_index = screen_index;
|
|
|
|
|
}
|
|
|
|
|
|
2019-06-18 04:02:06 +02:00
|
|
|
/** Call this method before calling app.exec */
|
2021-02-05 15:36:57 +01:00
|
|
|
bool Init() override;
|
2019-06-18 04:02:06 +02:00
|
|
|
|
|
|
|
|
std::unique_ptr<gs_frame> get_gs_frame();
|
|
|
|
|
|
|
|
|
|
main_window* m_main_window = nullptr;
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
QThread* get_thread() override
|
|
|
|
|
{
|
|
|
|
|
return thread();
|
|
|
|
|
}
|
|
|
|
|
|
2020-02-05 11:07:34 +01:00
|
|
|
void SwitchTranslator(QTranslator& translator, const QString& filename, const QString& language_code);
|
|
|
|
|
void LoadLanguage(const QString& language_code);
|
2021-04-07 23:05:18 +02:00
|
|
|
static QStringList GetAvailableLanguageCodes();
|
2020-02-03 23:43:11 +01:00
|
|
|
|
2019-06-18 04:02:06 +02:00
|
|
|
void InitializeCallbacks();
|
|
|
|
|
void InitializeConnects();
|
|
|
|
|
|
2020-02-07 21:55:29 +01:00
|
|
|
void StartPlaytime(bool start_playtime);
|
2020-04-28 19:12:36 +02:00
|
|
|
void UpdatePlaytime();
|
2019-10-31 07:59:37 +01:00
|
|
|
void StopPlaytime();
|
|
|
|
|
|
2020-02-03 23:43:11 +01:00
|
|
|
QTranslator m_translator;
|
|
|
|
|
QTranslator m_translator_qt;
|
2020-02-05 11:07:34 +01:00
|
|
|
QString m_language_code;
|
2020-02-03 23:43:11 +01:00
|
|
|
|
2020-04-28 19:12:36 +02:00
|
|
|
QTimer m_timer;
|
2019-10-31 07:59:37 +01:00
|
|
|
QElapsedTimer m_timer_playtime;
|
|
|
|
|
|
2021-05-22 10:42:05 +02:00
|
|
|
QSoundEffect m_sound_effect{};
|
|
|
|
|
|
2019-06-18 04:02:06 +02:00
|
|
|
std::shared_ptr<emu_settings> m_emu_settings;
|
|
|
|
|
std::shared_ptr<gui_settings> m_gui_settings;
|
2020-01-12 22:17:01 +01:00
|
|
|
std::shared_ptr<persistent_settings> m_persistent_settings;
|
2019-06-18 04:02:06 +02:00
|
|
|
|
2019-08-25 11:51:13 +02:00
|
|
|
bool m_show_gui = true;
|
2019-09-08 18:27:36 +02:00
|
|
|
bool m_use_cli_style = false;
|
2021-03-25 22:55:06 +01:00
|
|
|
bool m_with_cli_boot = false;
|
2023-02-13 20:57:25 +01:00
|
|
|
bool m_start_games_fullscreen = false;
|
2023-02-13 21:12:15 +01:00
|
|
|
int m_game_screen_index = -1;
|
2019-08-25 11:51:13 +02:00
|
|
|
|
2023-07-07 09:31:35 +02:00
|
|
|
u64 m_pause_amend_time_on_focus_loss = umax;
|
|
|
|
|
u64 m_pause_delayed_tag = 0;
|
|
|
|
|
typename Emulator::stop_counter_t m_emu_focus_out_emulation_id{};
|
|
|
|
|
bool m_is_pause_on_focus_loss_active = false;
|
|
|
|
|
|
2019-06-18 04:02:06 +02:00
|
|
|
private Q_SLOTS:
|
2021-02-07 13:14:36 +01:00
|
|
|
void OnChangeStyleSheetRequest();
|
2023-07-07 09:31:35 +02:00
|
|
|
void OnAppStateChanged(Qt::ApplicationState state);
|
2019-06-18 04:02:06 +02:00
|
|
|
|
|
|
|
|
Q_SIGNALS:
|
2020-02-07 21:55:29 +01:00
|
|
|
void OnEmulatorRun(bool start_playtime);
|
2019-06-18 04:02:06 +02:00
|
|
|
void OnEmulatorPause();
|
2020-02-07 21:55:29 +01:00
|
|
|
void OnEmulatorResume(bool start_playtime);
|
2019-06-18 04:02:06 +02:00
|
|
|
void OnEmulatorStop();
|
|
|
|
|
void OnEmulatorReady();
|
2022-06-21 22:13:22 +02:00
|
|
|
void OnEnableDiscEject(bool enabled);
|
|
|
|
|
void OnEnableDiscInsert(bool enabled);
|
2019-06-18 04:02:06 +02:00
|
|
|
|
2022-06-24 19:58:26 +02:00
|
|
|
void RequestCallFromMainThread(std::function<void()> func, atomic_t<bool>* wake_up);
|
2019-06-18 04:02:06 +02:00
|
|
|
|
|
|
|
|
private Q_SLOTS:
|
2022-06-24 19:58:26 +02:00
|
|
|
static void CallFromMainThread(const std::function<void()>& func, atomic_t<bool>* wake_up);
|
2019-06-18 04:02:06 +02:00
|
|
|
};
|