mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-07-04 22:11:26 +12:00
Add Emu.HasGui() to properly hide Qt dialogs in no-gui mode
This commit is contained in:
parent
84f9911163
commit
46ca39ec4d
10 changed files with 26 additions and 10 deletions
|
@ -1,4 +1,4 @@
|
||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
#include "Emu/System.h"
|
#include "Emu/System.h"
|
||||||
#include "Emu/IdManager.h"
|
#include "Emu/IdManager.h"
|
||||||
#include "Emu/Cell/PPUModule.h"
|
#include "Emu/Cell/PPUModule.h"
|
||||||
|
|
|
@ -250,6 +250,7 @@ class Emulator final
|
||||||
u32 m_usrid{1};
|
u32 m_usrid{1};
|
||||||
|
|
||||||
bool m_force_boot = false;
|
bool m_force_boot = false;
|
||||||
|
bool m_has_gui = true;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Emulator() = default;
|
Emulator() = default;
|
||||||
|
@ -372,6 +373,9 @@ public:
|
||||||
bool IsStopped() const { return m_state == system_state::stopped; }
|
bool IsStopped() const { return m_state == system_state::stopped; }
|
||||||
bool IsReady() const { return m_state == system_state::ready; }
|
bool IsReady() const { return m_state == system_state::ready; }
|
||||||
auto GetStatus() const { return m_state.load(); }
|
auto GetStatus() const { return m_state.load(); }
|
||||||
|
|
||||||
|
bool HasGui() const { return m_has_gui; }
|
||||||
|
void SetHasGui(bool has_gui) { m_has_gui = has_gui; }
|
||||||
};
|
};
|
||||||
|
|
||||||
extern Emulator Emu;
|
extern Emulator Emu;
|
||||||
|
|
|
@ -14,7 +14,7 @@ headless_application::headless_application(int& argc, char** argv) : QCoreApplic
|
||||||
void headless_application::Init()
|
void headless_application::Init()
|
||||||
{
|
{
|
||||||
// Force init the emulator
|
// Force init the emulator
|
||||||
InitializeEmulator("1", true); // TODO: get user from cli args if possible
|
InitializeEmulator("1", true, false); // TODO: get user from cli args if possible
|
||||||
|
|
||||||
// Create callbacks from the emulator, which reference the handlers.
|
// Create callbacks from the emulator, which reference the handlers.
|
||||||
InitializeCallbacks();
|
InitializeCallbacks();
|
||||||
|
|
|
@ -44,8 +44,10 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/** Emu.Init() wrapper for user manager */
|
/** Emu.Init() wrapper for user manager */
|
||||||
bool main_application::InitializeEmulator(const std::string& user, bool force_init)
|
bool main_application::InitializeEmulator(const std::string& user, bool force_init, bool show_gui)
|
||||||
{
|
{
|
||||||
|
Emu.SetHasGui(show_gui);
|
||||||
|
|
||||||
// try to set a new user
|
// try to set a new user
|
||||||
const bool user_was_set = Emu.SetUsr(user);
|
const bool user_was_set = Emu.SetUsr(user);
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@ class main_application
|
||||||
public:
|
public:
|
||||||
virtual void Init() = 0;
|
virtual void Init() = 0;
|
||||||
|
|
||||||
static bool InitializeEmulator(const std::string& user, bool force_init);
|
static bool InitializeEmulator(const std::string& user, bool force_init, bool show_gui);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual QThread* get_thread() = 0;
|
virtual QThread* get_thread() = 0;
|
||||||
|
|
|
@ -37,7 +37,7 @@ void gui_application::Init()
|
||||||
m_gui_settings.reset(new gui_settings());
|
m_gui_settings.reset(new gui_settings());
|
||||||
|
|
||||||
// Force init the emulator
|
// Force init the emulator
|
||||||
InitializeEmulator(m_gui_settings->GetCurrentUser().toStdString(), true);
|
InitializeEmulator(m_gui_settings->GetCurrentUser().toStdString(), true, m_show_gui);
|
||||||
|
|
||||||
// Create the main window
|
// Create the main window
|
||||||
if (m_show_gui)
|
if (m_show_gui)
|
||||||
|
@ -182,8 +182,8 @@ void gui_application::InitializeCallbacks()
|
||||||
callbacks.get_gs_frame = [this]() -> std::unique_ptr<GSFrameBase> { return get_gs_frame(); };
|
callbacks.get_gs_frame = [this]() -> std::unique_ptr<GSFrameBase> { return get_gs_frame(); };
|
||||||
callbacks.get_msg_dialog = [this]() -> std::shared_ptr<MsgDialogBase> { return m_show_gui ? std::make_shared<msg_dialog_frame>() : nullptr; };
|
callbacks.get_msg_dialog = [this]() -> std::shared_ptr<MsgDialogBase> { return m_show_gui ? std::make_shared<msg_dialog_frame>() : nullptr; };
|
||||||
callbacks.get_osk_dialog = [this]() -> std::shared_ptr<OskDialogBase> { return m_show_gui ? std::make_shared<osk_dialog_frame>() : nullptr; };
|
callbacks.get_osk_dialog = [this]() -> std::shared_ptr<OskDialogBase> { return m_show_gui ? std::make_shared<osk_dialog_frame>() : nullptr; };
|
||||||
callbacks.get_save_dialog = [this]() -> std::unique_ptr<SaveDialogBase> { return m_show_gui ? std::make_unique<save_data_dialog>() : nullptr; };
|
callbacks.get_save_dialog = []() -> std::unique_ptr<SaveDialogBase> { return std::make_unique<save_data_dialog>(); };
|
||||||
callbacks.get_trophy_notification_dialog = [this]() -> std::unique_ptr<TrophyNotificationBase> { return m_show_gui ? std::make_unique<trophy_notification_helper>(m_game_window) : nullptr; };
|
callbacks.get_trophy_notification_dialog = [this]() -> std::unique_ptr<TrophyNotificationBase> { return std::make_unique<trophy_notification_helper>(m_game_window); };
|
||||||
|
|
||||||
callbacks.on_run = [=]() { OnEmulatorRun(); };
|
callbacks.on_run = [=]() { OnEmulatorRun(); };
|
||||||
callbacks.on_pause = [=]() { OnEmulatorPause(); };
|
callbacks.on_pause = [=]() { OnEmulatorPause(); };
|
||||||
|
|
|
@ -14,6 +14,11 @@ s32 save_data_dialog::ShowSaveDataList(std::vector<SaveDataEntry>& save_entries,
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!Emu.HasGui())
|
||||||
|
{
|
||||||
|
return -2;
|
||||||
|
}
|
||||||
|
|
||||||
// Fall back to front-end GUI
|
// Fall back to front-end GUI
|
||||||
atomic_t<bool> dlg_result(false);
|
atomic_t<bool> dlg_result(false);
|
||||||
atomic_t<s32> selection;
|
atomic_t<s32> selection;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#include "trophy_notification_helper.h"
|
#include "trophy_notification_helper.h"
|
||||||
|
|
||||||
#include "trophy_notification_frame.h"
|
#include "trophy_notification_frame.h"
|
||||||
|
|
||||||
|
@ -12,6 +12,11 @@ s32 trophy_notification_helper::ShowTrophyNotification(const SceNpTrophyDetails&
|
||||||
return manager->create<rsx::overlays::trophy_notification>()->show(trophy, trophy_icon_buffer);
|
return manager->create<rsx::overlays::trophy_notification>()->show(trophy, trophy_icon_buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!Emu.HasGui())
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
Emu.CallAfter([=]
|
Emu.CallAfter([=]
|
||||||
{
|
{
|
||||||
trophy_notification_frame* trophy_notification = new trophy_notification_frame(trophy_icon_buffer, trophy, m_game_window->frameGeometry().height() / 10);
|
trophy_notification_frame* trophy_notification = new trophy_notification_frame(trophy_icon_buffer, trophy, m_game_window->frameGeometry().height() / 10);
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
#include "Emu/Memory/vm.h"
|
#include "Emu/Memory/vm.h"
|
||||||
|
|
|
@ -368,7 +368,7 @@ void user_manager_dialog::OnUserLogin()
|
||||||
const u32 key = GetUserKey();
|
const u32 key = GetUserKey();
|
||||||
const std::string new_user = m_user_list[key].GetUserId();
|
const std::string new_user = m_user_list[key].GetUserId();
|
||||||
|
|
||||||
if (!main_application::InitializeEmulator(new_user, false))
|
if (!main_application::InitializeEmulator(new_user, false, Emu.HasGui()))
|
||||||
{
|
{
|
||||||
LOG_FATAL(GENERAL, "Failed to login user! username=%s key=%d", new_user, key);
|
LOG_FATAL(GENERAL, "Failed to login user! username=%s key=%d", new_user, key);
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue