From f97afb03fcd8ace5c51ecd464a451d29ecae591e Mon Sep 17 00:00:00 2001 From: georgemoralis Date: Tue, 7 Apr 2026 10:49:05 +0300 Subject: [PATCH 1/9] better transaction handling --- src/core/libraries/np/np_profile_dialog.cpp | 57 ++++++++++++++----- src/core/libraries/np/np_profile_dialog.h | 13 +++-- .../web_browser_dialog/webbrowserdialog.cpp | 27 ++++++--- .../web_browser_dialog/webbrowserdialog.h | 4 +- 4 files changed, 70 insertions(+), 31 deletions(-) diff --git a/src/core/libraries/np/np_profile_dialog.cpp b/src/core/libraries/np/np_profile_dialog.cpp index 6ae1ed26c..11dad6992 100644 --- a/src/core/libraries/np/np_profile_dialog.cpp +++ b/src/core/libraries/np/np_profile_dialog.cpp @@ -1,16 +1,25 @@ -// SPDX-FileCopyrightText: Copyright 2025 shadPS4 Emulator Project +// SPDX-FileCopyrightText: Copyright 2025-2026 shadPS4 Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later +#include #include "common/logging/log.h" #include "core/libraries/error_codes.h" #include "core/libraries/libs.h" #include "core/libraries/np/np_profile_dialog.h" +#include "magic_enum/magic_enum.hpp" namespace Libraries::Np::NpProfileDialog { -s32 PS4_SYSV_ABI sceNpProfileDialogOpen() { +static auto g_status = Libraries::CommonDialog::Status::NONE; + +Libraries::CommonDialog::Error PS4_SYSV_ABI sceNpProfileDialogOpen() { + if (g_status != Libraries::CommonDialog::Status::INITIALIZED && + g_status != Libraries::CommonDialog::Status::FINISHED) { + LOG_INFO(Lib_MsgDlg, "called without initialize"); + return Libraries::CommonDialog::Error::INVALID_STATE; + } LOG_ERROR(Lib_NpProfileDialog, "(STUBBED) called"); - return ORBIS_OK; + return Libraries::CommonDialog::Error::OK; } s32 PS4_SYSV_ABI sceNpProfileDialogClose() { @@ -23,14 +32,25 @@ s32 PS4_SYSV_ABI sceNpProfileDialogGetResult() { return ORBIS_OK; } -s32 PS4_SYSV_ABI sceNpProfileDialogGetStatus() { - LOG_ERROR(Lib_NpProfileDialog, "(STUBBED) called"); - return ORBIS_OK; +Libraries::CommonDialog::Status PS4_SYSV_ABI sceNpProfileDialogGetStatus() { + LOG_TRACE(Lib_MsgDlg, "called status={}", magic_enum::enum_name(g_status)); + return g_status; } -s32 PS4_SYSV_ABI sceNpProfileDialogInitialize() { - LOG_ERROR(Lib_NpProfileDialog, "(STUBBED) called"); - return ORBIS_OK; +Libraries::CommonDialog::Error PS4_SYSV_ABI sceNpProfileDialogInitialize() { + if (!CommonDialog::g_isInitialized) { + return Libraries::CommonDialog::Error::NOT_SYSTEM_INITIALIZED; + } + if (g_status != Libraries::CommonDialog::Status::NONE) { + LOG_INFO(Lib_NpProfileDialog, "already initialized"); + return Libraries::CommonDialog::Error::ALREADY_INITIALIZED; + } + if (CommonDialog::g_isUsed) { + return Libraries::CommonDialog::Error::BUSY; + } + g_status = Libraries::CommonDialog::Status::INITIALIZED; + CommonDialog::g_isUsed = true; + return Libraries::CommonDialog::Error::OK; } s32 PS4_SYSV_ABI sceNpProfileDialogOpenA() { @@ -38,14 +58,21 @@ s32 PS4_SYSV_ABI sceNpProfileDialogOpenA() { return ORBIS_OK; } -s32 PS4_SYSV_ABI sceNpProfileDialogTerminate() { - LOG_ERROR(Lib_NpProfileDialog, "(STUBBED) called"); - return ORBIS_OK; +Libraries::CommonDialog::Error sceNpProfileDialogTerminate() { + if (g_status == Libraries::CommonDialog::Status::RUNNING) { + LOG_ERROR(Lib_NpProfileDialog, "CloseProfile Dialog unimplemented"); + } + if (g_status == Libraries::CommonDialog::Status::NONE) { + return Libraries::CommonDialog::Error::NOT_INITIALIZED; + } + g_status = Libraries::CommonDialog::Status::NONE; + CommonDialog::g_isUsed = false; + return Libraries::CommonDialog::Error::OK; } -s32 PS4_SYSV_ABI sceNpProfileDialogUpdateStatus() { - LOG_DEBUG(Lib_NpProfileDialog, "(STUBBED) called"); - return ORBIS_OK; +Libraries::CommonDialog::Status PS4_SYSV_ABI sceNpProfileDialogUpdateStatus() { + LOG_TRACE(Lib_MsgDlg, "called status={}", magic_enum::enum_name(g_status)); + return g_status; } void RegisterLib(Core::Loader::SymbolsResolver* sym) { diff --git a/src/core/libraries/np/np_profile_dialog.h b/src/core/libraries/np/np_profile_dialog.h index ca1126d57..775549a47 100644 --- a/src/core/libraries/np/np_profile_dialog.h +++ b/src/core/libraries/np/np_profile_dialog.h @@ -1,8 +1,9 @@ -// SPDX-FileCopyrightText: Copyright 2025 shadPS4 Emulator Project +// SPDX-FileCopyrightText: Copyright 2025-2026 shadPS4 Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later #pragma once +#include #include "common/types.h" namespace Core::Loader { @@ -11,14 +12,14 @@ class SymbolsResolver; namespace Libraries::Np::NpProfileDialog { -s32 PS4_SYSV_ABI sceNpProfileDialogOpen(); +Libraries::CommonDialog::Error PS4_SYSV_ABI sceNpProfileDialogOpen(); s32 PS4_SYSV_ABI sceNpProfileDialogClose(); s32 PS4_SYSV_ABI sceNpProfileDialogGetResult(); -s32 PS4_SYSV_ABI sceNpProfileDialogGetStatus(); -s32 PS4_SYSV_ABI sceNpProfileDialogInitialize(); +Libraries::CommonDialog::Status PS4_SYSV_ABI sceNpProfileDialogGetStatus(); +Libraries::CommonDialog::Error PS4_SYSV_ABI sceNpProfileDialogInitialize(); s32 PS4_SYSV_ABI sceNpProfileDialogOpenA(); -s32 PS4_SYSV_ABI sceNpProfileDialogTerminate(); -s32 PS4_SYSV_ABI sceNpProfileDialogUpdateStatus(); +Libraries::CommonDialog::Error PS4_SYSV_ABI sceNpProfileDialogTerminate(); +Libraries::CommonDialog::Status PS4_SYSV_ABI sceNpProfileDialogUpdateStatus(); void RegisterLib(Core::Loader::SymbolsResolver* sym); } // namespace Libraries::Np::NpProfileDialog \ No newline at end of file diff --git a/src/core/libraries/web_browser_dialog/webbrowserdialog.cpp b/src/core/libraries/web_browser_dialog/webbrowserdialog.cpp index 5844affa2..ce15aed46 100644 --- a/src/core/libraries/web_browser_dialog/webbrowserdialog.cpp +++ b/src/core/libraries/web_browser_dialog/webbrowserdialog.cpp @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project +// SPDX-FileCopyrightText: Copyright 2024-2026 shadPS4 Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later #include "common/logging/log.h" @@ -32,12 +32,18 @@ Libraries::CommonDialog::Status PS4_SYSV_ABI sceWebBrowserDialogGetStatus() { } Libraries::CommonDialog::Error PS4_SYSV_ABI sceWebBrowserDialogInitialize() { - if (CommonDialog::g_isInitialized) { - LOG_INFO(Lib_WebBrowserDialog, "already initialized"); - return Libraries::CommonDialog::Error::ALREADY_SYSTEM_INITIALIZED; + if (!CommonDialog::g_isInitialized) { + return Libraries::CommonDialog::Error::NOT_SYSTEM_INITIALIZED; } - LOG_DEBUG(Lib_WebBrowserDialog, "initialized"); - CommonDialog::g_isInitialized = true; + if (g_status != Libraries::CommonDialog::Status::NONE) { + LOG_ERROR(Lib_WebBrowserDialog, "already initialized"); + return Libraries::CommonDialog::Error::ALREADY_INITIALIZED; + } + if (CommonDialog::g_isUsed) { + return Libraries::CommonDialog::Error::BUSY; + } + g_status = Libraries::CommonDialog::Status::INITIALIZED; + CommonDialog::g_isUsed = true; return Libraries::CommonDialog::Error::OK; } @@ -46,9 +52,14 @@ s32 PS4_SYSV_ABI sceWebBrowserDialogNavigate() { return ORBIS_OK; } -s32 PS4_SYSV_ABI sceWebBrowserDialogOpen() { +Libraries::CommonDialog::Error PS4_SYSV_ABI sceWebBrowserDialogOpen() { + if (g_status != Libraries::CommonDialog::Status::INITIALIZED && + g_status != Libraries::CommonDialog::Status::FINISHED) { + LOG_INFO(Lib_MsgDlg, "called without initialize"); + return Libraries::CommonDialog::Error::INVALID_STATE; + } LOG_ERROR(Lib_WebBrowserDialog, "(STUBBED) called"); - return ORBIS_OK; + return Libraries::CommonDialog::Error::OK; } s32 PS4_SYSV_ABI sceWebBrowserDialogOpenForPredeterminedContent() { diff --git a/src/core/libraries/web_browser_dialog/webbrowserdialog.h b/src/core/libraries/web_browser_dialog/webbrowserdialog.h index 3dad7e1e9..b836ba39c 100644 --- a/src/core/libraries/web_browser_dialog/webbrowserdialog.h +++ b/src/core/libraries/web_browser_dialog/webbrowserdialog.h @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project +// SPDX-FileCopyrightText: Copyright 2024-2026 shadPS4 Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later #pragma once @@ -18,7 +18,7 @@ s32 PS4_SYSV_ABI sceWebBrowserDialogGetResult(); Libraries::CommonDialog::Status PS4_SYSV_ABI sceWebBrowserDialogGetStatus(); Libraries::CommonDialog::Error PS4_SYSV_ABI sceWebBrowserDialogInitialize(); s32 PS4_SYSV_ABI sceWebBrowserDialogNavigate(); -s32 PS4_SYSV_ABI sceWebBrowserDialogOpen(); +Libraries::CommonDialog::Error PS4_SYSV_ABI sceWebBrowserDialogOpen(); s32 PS4_SYSV_ABI sceWebBrowserDialogOpenForPredeterminedContent(); s32 PS4_SYSV_ABI sceWebBrowserDialogResetCookie(); s32 PS4_SYSV_ABI sceWebBrowserDialogSetCookie(); From 71dadac5d0f5f9da010b308b218d19659f2232dd Mon Sep 17 00:00:00 2001 From: georgemoralis Date: Tue, 7 Apr 2026 12:26:08 +0300 Subject: [PATCH 2/9] more fixup --- src/core/libraries/np/np_profile_dialog.cpp | 29 ++++++++++++------- src/core/libraries/np/np_profile_dialog.h | 4 +-- .../web_browser_dialog/webbrowserdialog.cpp | 18 ++++++++---- .../web_browser_dialog/webbrowserdialog.h | 2 +- 4 files changed, 35 insertions(+), 18 deletions(-) diff --git a/src/core/libraries/np/np_profile_dialog.cpp b/src/core/libraries/np/np_profile_dialog.cpp index 11dad6992..f21056a18 100644 --- a/src/core/libraries/np/np_profile_dialog.cpp +++ b/src/core/libraries/np/np_profile_dialog.cpp @@ -12,19 +12,24 @@ namespace Libraries::Np::NpProfileDialog { static auto g_status = Libraries::CommonDialog::Status::NONE; -Libraries::CommonDialog::Error PS4_SYSV_ABI sceNpProfileDialogOpen() { +Libraries::CommonDialog::Error PS4_SYSV_ABI sceNpProfileDialogOpen(void* param) { if (g_status != Libraries::CommonDialog::Status::INITIALIZED && g_status != Libraries::CommonDialog::Status::FINISHED) { - LOG_INFO(Lib_MsgDlg, "called without initialize"); + LOG_INFO(Lib_NpProfileDialog, "called without initialize"); return Libraries::CommonDialog::Error::INVALID_STATE; } - LOG_ERROR(Lib_NpProfileDialog, "(STUBBED) called"); + LOG_ERROR(Lib_NpProfileDialog, "(STUBBED) called"); // TODO open ui dialog + g_status = Libraries::CommonDialog::Status::RUNNING; return Libraries::CommonDialog::Error::OK; } -s32 PS4_SYSV_ABI sceNpProfileDialogClose() { - LOG_ERROR(Lib_NpProfileDialog, "(STUBBED) called"); - return ORBIS_OK; +Libraries::CommonDialog::Error PS4_SYSV_ABI sceNpProfileDialogClose() { + LOG_DEBUG(Lib_NpProfileDialog, "called"); + if (g_status != Libraries::CommonDialog::Status::RUNNING) { + return Libraries::CommonDialog::Error::NOT_RUNNING; + } + LOG_INFO(Lib_NpProfileDialog, "TODO: close npprofile ui dialog"); // TODO close Ui dialog + return Libraries::CommonDialog::Error::OK; } s32 PS4_SYSV_ABI sceNpProfileDialogGetResult() { @@ -33,7 +38,7 @@ s32 PS4_SYSV_ABI sceNpProfileDialogGetResult() { } Libraries::CommonDialog::Status PS4_SYSV_ABI sceNpProfileDialogGetStatus() { - LOG_TRACE(Lib_MsgDlg, "called status={}", magic_enum::enum_name(g_status)); + LOG_TRACE(Lib_NpProfileDialog, "called status={}", magic_enum::enum_name(g_status)); return g_status; } @@ -58,9 +63,9 @@ s32 PS4_SYSV_ABI sceNpProfileDialogOpenA() { return ORBIS_OK; } -Libraries::CommonDialog::Error sceNpProfileDialogTerminate() { +Libraries::CommonDialog::Error PS4_SYSV_ABI sceNpProfileDialogTerminate() { if (g_status == Libraries::CommonDialog::Status::RUNNING) { - LOG_ERROR(Lib_NpProfileDialog, "CloseProfile Dialog unimplemented"); + sceNpProfileDialogClose(); } if (g_status == Libraries::CommonDialog::Status::NONE) { return Libraries::CommonDialog::Error::NOT_INITIALIZED; @@ -71,7 +76,11 @@ Libraries::CommonDialog::Error sceNpProfileDialogTerminate() { } Libraries::CommonDialog::Status PS4_SYSV_ABI sceNpProfileDialogUpdateStatus() { - LOG_TRACE(Lib_MsgDlg, "called status={}", magic_enum::enum_name(g_status)); + if (g_status == Libraries::CommonDialog::Status::RUNNING) { + g_status = Libraries::CommonDialog::Status::FINISHED; // TODO removed it when implementing + // real dialog + } + LOG_TRACE(Lib_NpProfileDialog, "called status={}", magic_enum::enum_name(g_status)); return g_status; } diff --git a/src/core/libraries/np/np_profile_dialog.h b/src/core/libraries/np/np_profile_dialog.h index 775549a47..d991ce68c 100644 --- a/src/core/libraries/np/np_profile_dialog.h +++ b/src/core/libraries/np/np_profile_dialog.h @@ -12,8 +12,8 @@ class SymbolsResolver; namespace Libraries::Np::NpProfileDialog { -Libraries::CommonDialog::Error PS4_SYSV_ABI sceNpProfileDialogOpen(); -s32 PS4_SYSV_ABI sceNpProfileDialogClose(); +Libraries::CommonDialog::Error PS4_SYSV_ABI sceNpProfileDialogOpen(void* param); +Libraries::CommonDialog::Error PS4_SYSV_ABI sceNpProfileDialogClose(); s32 PS4_SYSV_ABI sceNpProfileDialogGetResult(); Libraries::CommonDialog::Status PS4_SYSV_ABI sceNpProfileDialogGetStatus(); Libraries::CommonDialog::Error PS4_SYSV_ABI sceNpProfileDialogInitialize(); diff --git a/src/core/libraries/web_browser_dialog/webbrowserdialog.cpp b/src/core/libraries/web_browser_dialog/webbrowserdialog.cpp index ce15aed46..2bb01c035 100644 --- a/src/core/libraries/web_browser_dialog/webbrowserdialog.cpp +++ b/src/core/libraries/web_browser_dialog/webbrowserdialog.cpp @@ -11,9 +11,13 @@ namespace Libraries::WebBrowserDialog { static auto g_status = Libraries::CommonDialog::Status::NONE; -s32 PS4_SYSV_ABI sceWebBrowserDialogClose() { +Libraries::CommonDialog::Error PS4_SYSV_ABI sceWebBrowserDialogClose() { LOG_ERROR(Lib_WebBrowserDialog, "(STUBBED) called"); - return ORBIS_OK; + if (g_status != Libraries::CommonDialog::Status::RUNNING) { + return Libraries::CommonDialog::Error::NOT_RUNNING; + } + LOG_INFO(Lib_NpProfileDialog, "TODO: close npprofile ui dialog"); // TODO close Ui dialog + return Libraries::CommonDialog::Error::OK; } s32 PS4_SYSV_ABI sceWebBrowserDialogGetEvent() { @@ -58,7 +62,8 @@ Libraries::CommonDialog::Error PS4_SYSV_ABI sceWebBrowserDialogOpen() { LOG_INFO(Lib_MsgDlg, "called without initialize"); return Libraries::CommonDialog::Error::INVALID_STATE; } - LOG_ERROR(Lib_WebBrowserDialog, "(STUBBED) called"); + LOG_ERROR(Lib_WebBrowserDialog, "(STUBBED) called"); // TODO open ui dialog + g_status = Libraries::CommonDialog::Status::RUNNING; return Libraries::CommonDialog::Error::OK; } @@ -84,8 +89,7 @@ s32 PS4_SYSV_ABI sceWebBrowserDialogSetZoom() { Libraries::CommonDialog::Error PS4_SYSV_ABI sceWebBrowserDialogTerminate() { if (g_status == Libraries::CommonDialog::Status::RUNNING) { - LOG_ERROR(Lib_WebBrowserDialog, - "CloseWebBrowser Dialog unimplemented"); // sceWebBrowserDialogClose(); + sceWebBrowserDialogClose(); } if (g_status == Libraries::CommonDialog::Status::NONE) { return Libraries::CommonDialog::Error::NOT_INITIALIZED; @@ -97,6 +101,10 @@ Libraries::CommonDialog::Error PS4_SYSV_ABI sceWebBrowserDialogTerminate() { Libraries::CommonDialog::Status PS4_SYSV_ABI sceWebBrowserDialogUpdateStatus() { LOG_TRACE(Lib_MsgDlg, "called status={}", magic_enum::enum_name(g_status)); + if (g_status == Libraries::CommonDialog::Status::RUNNING) { + g_status = Libraries::CommonDialog::Status::FINISHED; // TODO removed it when implementing + // real dialog + } return g_status; } diff --git a/src/core/libraries/web_browser_dialog/webbrowserdialog.h b/src/core/libraries/web_browser_dialog/webbrowserdialog.h index b836ba39c..4fac2a3f0 100644 --- a/src/core/libraries/web_browser_dialog/webbrowserdialog.h +++ b/src/core/libraries/web_browser_dialog/webbrowserdialog.h @@ -12,7 +12,7 @@ class SymbolsResolver; namespace Libraries::WebBrowserDialog { -s32 PS4_SYSV_ABI sceWebBrowserDialogClose(); +Libraries::CommonDialog::Error PS4_SYSV_ABI sceWebBrowserDialogClose(); s32 PS4_SYSV_ABI sceWebBrowserDialogGetEvent(); s32 PS4_SYSV_ABI sceWebBrowserDialogGetResult(); Libraries::CommonDialog::Status PS4_SYSV_ABI sceWebBrowserDialogGetStatus(); From 93d93e05620d47431d94e013a7bdda1bf9ee16e7 Mon Sep 17 00:00:00 2001 From: georgemoralis Date: Tue, 7 Apr 2026 12:34:17 +0300 Subject: [PATCH 3/9] fixup some logs --- src/core/libraries/web_browser_dialog/webbrowserdialog.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/core/libraries/web_browser_dialog/webbrowserdialog.cpp b/src/core/libraries/web_browser_dialog/webbrowserdialog.cpp index 2bb01c035..4c39a69d6 100644 --- a/src/core/libraries/web_browser_dialog/webbrowserdialog.cpp +++ b/src/core/libraries/web_browser_dialog/webbrowserdialog.cpp @@ -31,7 +31,7 @@ s32 PS4_SYSV_ABI sceWebBrowserDialogGetResult() { } Libraries::CommonDialog::Status PS4_SYSV_ABI sceWebBrowserDialogGetStatus() { - LOG_TRACE(Lib_MsgDlg, "called status={}", magic_enum::enum_name(g_status)); + LOG_TRACE(Lib_WebBrowserDialog, "called status={}", magic_enum::enum_name(g_status)); return g_status; } @@ -59,7 +59,7 @@ s32 PS4_SYSV_ABI sceWebBrowserDialogNavigate() { Libraries::CommonDialog::Error PS4_SYSV_ABI sceWebBrowserDialogOpen() { if (g_status != Libraries::CommonDialog::Status::INITIALIZED && g_status != Libraries::CommonDialog::Status::FINISHED) { - LOG_INFO(Lib_MsgDlg, "called without initialize"); + LOG_INFO(Lib_WebBrowserDialog, "called without initialize"); return Libraries::CommonDialog::Error::INVALID_STATE; } LOG_ERROR(Lib_WebBrowserDialog, "(STUBBED) called"); // TODO open ui dialog @@ -100,7 +100,7 @@ Libraries::CommonDialog::Error PS4_SYSV_ABI sceWebBrowserDialogTerminate() { } Libraries::CommonDialog::Status PS4_SYSV_ABI sceWebBrowserDialogUpdateStatus() { - LOG_TRACE(Lib_MsgDlg, "called status={}", magic_enum::enum_name(g_status)); + LOG_TRACE(Lib_WebBrowserDialog, "called status={}", magic_enum::enum_name(g_status)); if (g_status == Libraries::CommonDialog::Status::RUNNING) { g_status = Libraries::CommonDialog::Status::FINISHED; // TODO removed it when implementing // real dialog From cab04cad6eaf85774719c67dd4f9413dbfe773cd Mon Sep 17 00:00:00 2001 From: georgemoralis Date: Tue, 7 Apr 2026 12:54:22 +0300 Subject: [PATCH 4/9] refactor : move np_profile_dialog to it's own folder --- CMakeLists.txt | 4 ++-- src/core/libraries/libs.cpp | 2 +- .../np/{ => np_profile_dialog}/np_profile_dialog.cpp | 2 +- .../libraries/np/{ => np_profile_dialog}/np_profile_dialog.h | 0 4 files changed, 4 insertions(+), 4 deletions(-) rename src/core/libraries/np/{ => np_profile_dialog}/np_profile_dialog.cpp (98%) rename src/core/libraries/np/{ => np_profile_dialog}/np_profile_dialog.h (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 147903a7e..8efb569f4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -623,8 +623,8 @@ set(NP_LIBS src/core/libraries/np/np_error.h src/core/libraries/np/np_party.h src/core/libraries/np/np_auth.cpp src/core/libraries/np/np_auth.h - src/core/libraries/np/np_profile_dialog.cpp - src/core/libraries/np/np_profile_dialog.h + src/core/libraries/np/np_profile_dialog/np_profile_dialog.cpp + src/core/libraries/np/np_profile_dialog/np_profile_dialog.h src/core/libraries/np/np_sns_facebook_dialog.cpp src/core/libraries/np/np_sns_facebook_dialog.h src/core/libraries/np/np_partner.cpp diff --git a/src/core/libraries/libs.cpp b/src/core/libraries/libs.cpp index 762753fd1..d207126bc 100644 --- a/src/core/libraries/libs.cpp +++ b/src/core/libraries/libs.cpp @@ -38,7 +38,7 @@ #include "core/libraries/np/np_matching2.h" #include "core/libraries/np/np_partner.h" #include "core/libraries/np/np_party.h" -#include "core/libraries/np/np_profile_dialog.h" +#include "core/libraries/np/np_profile_dialog/np_profile_dialog.h" #include "core/libraries/np/np_score.h" #include "core/libraries/np/np_sns_facebook_dialog.h" #include "core/libraries/np/np_trophy.h" diff --git a/src/core/libraries/np/np_profile_dialog.cpp b/src/core/libraries/np/np_profile_dialog/np_profile_dialog.cpp similarity index 98% rename from src/core/libraries/np/np_profile_dialog.cpp rename to src/core/libraries/np/np_profile_dialog/np_profile_dialog.cpp index f21056a18..0382d223c 100644 --- a/src/core/libraries/np/np_profile_dialog.cpp +++ b/src/core/libraries/np/np_profile_dialog/np_profile_dialog.cpp @@ -5,8 +5,8 @@ #include "common/logging/log.h" #include "core/libraries/error_codes.h" #include "core/libraries/libs.h" -#include "core/libraries/np/np_profile_dialog.h" #include "magic_enum/magic_enum.hpp" +#include "np_profile_dialog.h" namespace Libraries::Np::NpProfileDialog { diff --git a/src/core/libraries/np/np_profile_dialog.h b/src/core/libraries/np/np_profile_dialog/np_profile_dialog.h similarity index 100% rename from src/core/libraries/np/np_profile_dialog.h rename to src/core/libraries/np/np_profile_dialog/np_profile_dialog.h From 0ba4e96b55869bdf7205a5391ddc2532c4db9088 Mon Sep 17 00:00:00 2001 From: georgemoralis Date: Tue, 7 Apr 2026 16:27:39 +0300 Subject: [PATCH 5/9] initial np_profile_dialog_ui --- .../np_profile_dialog/np_profile_dialog.cpp | 15 ++- .../np/np_profile_dialog/np_profile_dialog.h | 42 +++++++- .../np_profile_dialog_ui.cpp | 97 +++++++++++++++++++ .../np_profile_dialog/np_profile_dialog_ui.h | 37 +++++++ 4 files changed, 187 insertions(+), 4 deletions(-) create mode 100644 src/core/libraries/np/np_profile_dialog/np_profile_dialog_ui.cpp create mode 100644 src/core/libraries/np/np_profile_dialog/np_profile_dialog_ui.h diff --git a/src/core/libraries/np/np_profile_dialog/np_profile_dialog.cpp b/src/core/libraries/np/np_profile_dialog/np_profile_dialog.cpp index 0382d223c..6163a7096 100644 --- a/src/core/libraries/np/np_profile_dialog/np_profile_dialog.cpp +++ b/src/core/libraries/np/np_profile_dialog/np_profile_dialog.cpp @@ -7,19 +7,30 @@ #include "core/libraries/libs.h" #include "magic_enum/magic_enum.hpp" #include "np_profile_dialog.h" +#include "np_profile_dialog_ui.h" namespace Libraries::Np::NpProfileDialog { static auto g_status = Libraries::CommonDialog::Status::NONE; +static NpProfileDialogState g_state{}; +// static DialogResult g_result{}; +static int g_result = 0; // TODO use real result when implementing dialog +static NpProfileDialogUi g_profile_dialog_ui; -Libraries::CommonDialog::Error PS4_SYSV_ABI sceNpProfileDialogOpen(void* param) { +Libraries::CommonDialog::Error PS4_SYSV_ABI +sceNpProfileDialogOpen(OrbisNpProfileDialogParam* param) { if (g_status != Libraries::CommonDialog::Status::INITIALIZED && g_status != Libraries::CommonDialog::Status::FINISHED) { LOG_INFO(Lib_NpProfileDialog, "called without initialize"); return Libraries::CommonDialog::Error::INVALID_STATE; } LOG_ERROR(Lib_NpProfileDialog, "(STUBBED) called"); // TODO open ui dialog + NpProfileDialogState state{}; + state.onlineId = std::string(param->targetOnlineId.data); + state.userId = param->userId; + g_state = state; g_status = Libraries::CommonDialog::Status::RUNNING; + g_profile_dialog_ui = NpProfileDialogUi(&g_state, &g_result); return Libraries::CommonDialog::Error::OK; } @@ -58,7 +69,7 @@ Libraries::CommonDialog::Error PS4_SYSV_ABI sceNpProfileDialogInitialize() { return Libraries::CommonDialog::Error::OK; } -s32 PS4_SYSV_ABI sceNpProfileDialogOpenA() { +s32 PS4_SYSV_ABI sceNpProfileDialogOpenA(OrbisNpProfileDialogParamA* param) { LOG_ERROR(Lib_NpProfileDialog, "(STUBBED) called"); return ORBIS_OK; } diff --git a/src/core/libraries/np/np_profile_dialog/np_profile_dialog.h b/src/core/libraries/np/np_profile_dialog/np_profile_dialog.h index d991ce68c..db27d1e3f 100644 --- a/src/core/libraries/np/np_profile_dialog/np_profile_dialog.h +++ b/src/core/libraries/np/np_profile_dialog/np_profile_dialog.h @@ -4,7 +4,9 @@ #pragma once #include +#include #include "common/types.h" +#include "core/libraries/np/np_types.h" namespace Core::Loader { class SymbolsResolver; @@ -12,12 +14,48 @@ class SymbolsResolver; namespace Libraries::Np::NpProfileDialog { -Libraries::CommonDialog::Error PS4_SYSV_ABI sceNpProfileDialogOpen(void* param); +enum class OrbisNpProfileDialogMode : u32 { + ORBIS_NP_PROFILE_DIALOG_MODE_INVALID = 0, + ORBIS_NP_PROFILE_DIALOG_MODE_NORMAL = 1, +}; + +struct OrbisNpProfileDialogParam { + CommonDialog::BaseParam baseParam; + u64 size; + OrbisNpProfileDialogMode mode; + Libraries::UserService::OrbisUserServiceUserId userId; + Libraries::Np::OrbisNpOnlineId targetOnlineId; + void* userData; + u8 reserved[32]; +}; + +struct OrbisNpProfileGriefReportParam { + s32 reportItem; + u8 reserved[28]; +}; + +struct OrbisNpProfileDialogParamA { + CommonDialog::BaseParam baseParam; + u64 size; + OrbisNpProfileDialogMode mode; + Libraries::UserService::OrbisUserServiceUserId userId; + Libraries::Np::OrbisNpAccountId targetAccountId; + int : 32; + void* userData; + union { + uint8_t reserved[32]; + OrbisNpProfileGriefReportParam griefReportParam; + }; +}; + + +Libraries::CommonDialog::Error PS4_SYSV_ABI +sceNpProfileDialogOpen(OrbisNpProfileDialogParam* param); Libraries::CommonDialog::Error PS4_SYSV_ABI sceNpProfileDialogClose(); s32 PS4_SYSV_ABI sceNpProfileDialogGetResult(); Libraries::CommonDialog::Status PS4_SYSV_ABI sceNpProfileDialogGetStatus(); Libraries::CommonDialog::Error PS4_SYSV_ABI sceNpProfileDialogInitialize(); -s32 PS4_SYSV_ABI sceNpProfileDialogOpenA(); +s32 PS4_SYSV_ABI sceNpProfileDialogOpenA(OrbisNpProfileDialogParamA* param); Libraries::CommonDialog::Error PS4_SYSV_ABI sceNpProfileDialogTerminate(); Libraries::CommonDialog::Status PS4_SYSV_ABI sceNpProfileDialogUpdateStatus(); diff --git a/src/core/libraries/np/np_profile_dialog/np_profile_dialog_ui.cpp b/src/core/libraries/np/np_profile_dialog/np_profile_dialog_ui.cpp new file mode 100644 index 000000000..1febed259 --- /dev/null +++ b/src/core/libraries/np/np_profile_dialog/np_profile_dialog_ui.cpp @@ -0,0 +1,97 @@ +#include "common/logging/log.h" // optional, for debug +#include "np_profile_dialog_ui.h" +#include +#include + +#include +#include +using namespace ImGui; + +namespace Libraries::Np::NpProfileDialog { + +static constexpr ImVec2 BUTTON_SIZE{100.0f, 30.0f}; + +NpProfileDialogUi::NpProfileDialogUi(NpProfileDialogState* state, int* result) + : state(state), result(result) { + if (state) { + first_render = true; + AddLayer(this); // register in Layer system + } +} + +NpProfileDialogUi::~NpProfileDialogUi() { + Finish(0); +} + +NpProfileDialogUi::NpProfileDialogUi(NpProfileDialogUi&& other) noexcept + : Layer(other), state(other.state), result(other.result) { + other.state = nullptr; + other.result = nullptr; +} + +NpProfileDialogUi& NpProfileDialogUi::operator=(NpProfileDialogUi other) { + using std::swap; + swap(state, other.state); + swap(result, other.result); + if (state) { + first_render = true; + AddLayer(this); + } + return *this; +} + +void NpProfileDialogUi::Finish(int result_code) { + if (result) { + *result = result_code; // 0 = OK + } + state = nullptr; + result = nullptr; + RemoveLayer(this); // unregister from Layer system +} + +void NpProfileDialogUi::Draw() { + if (!state) + return; + + const auto& io = GetIO(); + ImVec2 window_size{std::min(io.DisplaySize.x, 400.0f), std::min(io.DisplaySize.y, 200.0f)}; + + CentralizeNextWindow(); + SetNextWindowSize(window_size); + SetNextWindowCollapsed(false); + if (first_render || !io.NavActive) { + SetNextWindowFocus(); + } + KeepNavHighlight(); + + if (Begin("NP Profile##NpProfileDialog", nullptr, + ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_NoSavedSettings)) { + + Text("Player Profile"); + Separator(); + Spacing(); + + Text("Online ID:"); + Text("%s", state->onlineId.c_str()); + + Spacing(); + SetCursorPos({ + window_size.x / 2.0f - BUTTON_SIZE.x / 2.0f, + window_size.y - 10.0f - BUTTON_SIZE.y, + }); + + if (Button("OK", BUTTON_SIZE)) { + Finish(0); + } + + if (first_render) { + SetItemCurrentNavFocus(); + } + } + + End(); + + first_render = false; +} + +} // namespace Libraries::Np::NpProfileDialog \ No newline at end of file diff --git a/src/core/libraries/np/np_profile_dialog/np_profile_dialog_ui.h b/src/core/libraries/np/np_profile_dialog/np_profile_dialog_ui.h new file mode 100644 index 000000000..d3efd1346 --- /dev/null +++ b/src/core/libraries/np/np_profile_dialog/np_profile_dialog_ui.h @@ -0,0 +1,37 @@ +#pragma once + +#include +#include + +#include "common/fixed_value.h" +#include "common/types.h" +#include "core/libraries/system/commondialog.h" +#include "imgui/imgui_layer.h" + +namespace Libraries::Np::NpProfileDialog { + +struct NpProfileDialogState { + std::string onlineId; + int userId{}; +}; + +class NpProfileDialogUi : public ImGui::Layer { +public: + explicit NpProfileDialogUi(NpProfileDialogState* state = nullptr, int* result = nullptr); + ~NpProfileDialogUi(); + + NpProfileDialogUi(const NpProfileDialogUi& other) = delete; + NpProfileDialogUi(NpProfileDialogUi&& other) noexcept; + NpProfileDialogUi& operator=(NpProfileDialogUi other); + + void Draw() override; + +private: + void Finish(int result_code); + + NpProfileDialogState* state{}; + int* result{}; + bool first_render{true}; +}; + +} // namespace Libraries::Np::NpProfileDialog From fd8d839763b1a4e002ca1849de73f0d01b1fb6c7 Mon Sep 17 00:00:00 2001 From: georgemoralis Date: Tue, 7 Apr 2026 17:55:01 +0300 Subject: [PATCH 6/9] fixes a bit more ui --- .../np_profile_dialog/np_profile_dialog.cpp | 10 ++---- .../np/np_profile_dialog/np_profile_dialog.h | 1 - .../np_profile_dialog_ui.cpp | 35 ++++++++++++------- .../np_profile_dialog/np_profile_dialog_ui.h | 15 +++++--- 4 files changed, 36 insertions(+), 25 deletions(-) diff --git a/src/core/libraries/np/np_profile_dialog/np_profile_dialog.cpp b/src/core/libraries/np/np_profile_dialog/np_profile_dialog.cpp index 6163a7096..06b7af5d0 100644 --- a/src/core/libraries/np/np_profile_dialog/np_profile_dialog.cpp +++ b/src/core/libraries/np/np_profile_dialog/np_profile_dialog.cpp @@ -24,13 +24,13 @@ sceNpProfileDialogOpen(OrbisNpProfileDialogParam* param) { LOG_INFO(Lib_NpProfileDialog, "called without initialize"); return Libraries::CommonDialog::Error::INVALID_STATE; } - LOG_ERROR(Lib_NpProfileDialog, "(STUBBED) called"); // TODO open ui dialog + LOG_ERROR(Lib_NpProfileDialog, "(STUBBED) called"); NpProfileDialogState state{}; state.onlineId = std::string(param->targetOnlineId.data); state.userId = param->userId; g_state = state; g_status = Libraries::CommonDialog::Status::RUNNING; - g_profile_dialog_ui = NpProfileDialogUi(&g_state, &g_result); + g_profile_dialog_ui = NpProfileDialogUi(&g_state, &g_status, &g_result); return Libraries::CommonDialog::Error::OK; } @@ -39,7 +39,7 @@ Libraries::CommonDialog::Error PS4_SYSV_ABI sceNpProfileDialogClose() { if (g_status != Libraries::CommonDialog::Status::RUNNING) { return Libraries::CommonDialog::Error::NOT_RUNNING; } - LOG_INFO(Lib_NpProfileDialog, "TODO: close npprofile ui dialog"); // TODO close Ui dialog + g_profile_dialog_ui.Finish(0); return Libraries::CommonDialog::Error::OK; } @@ -87,10 +87,6 @@ Libraries::CommonDialog::Error PS4_SYSV_ABI sceNpProfileDialogTerminate() { } Libraries::CommonDialog::Status PS4_SYSV_ABI sceNpProfileDialogUpdateStatus() { - if (g_status == Libraries::CommonDialog::Status::RUNNING) { - g_status = Libraries::CommonDialog::Status::FINISHED; // TODO removed it when implementing - // real dialog - } LOG_TRACE(Lib_NpProfileDialog, "called status={}", magic_enum::enum_name(g_status)); return g_status; } diff --git a/src/core/libraries/np/np_profile_dialog/np_profile_dialog.h b/src/core/libraries/np/np_profile_dialog/np_profile_dialog.h index db27d1e3f..b09870f2e 100644 --- a/src/core/libraries/np/np_profile_dialog/np_profile_dialog.h +++ b/src/core/libraries/np/np_profile_dialog/np_profile_dialog.h @@ -48,7 +48,6 @@ struct OrbisNpProfileDialogParamA { }; }; - Libraries::CommonDialog::Error PS4_SYSV_ABI sceNpProfileDialogOpen(OrbisNpProfileDialogParam* param); Libraries::CommonDialog::Error PS4_SYSV_ABI sceNpProfileDialogClose(); diff --git a/src/core/libraries/np/np_profile_dialog/np_profile_dialog_ui.cpp b/src/core/libraries/np/np_profile_dialog/np_profile_dialog_ui.cpp index 1febed259..67a702910 100644 --- a/src/core/libraries/np/np_profile_dialog/np_profile_dialog_ui.cpp +++ b/src/core/libraries/np/np_profile_dialog/np_profile_dialog_ui.cpp @@ -1,21 +1,25 @@ -#include "common/logging/log.h" // optional, for debug -#include "np_profile_dialog_ui.h" +// SPDX-FileCopyrightText: Copyright 2025-2026 shadPS4 Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + #include #include #include #include +#include "np_profile_dialog_ui.h" + using namespace ImGui; +using namespace Libraries::CommonDialog; namespace Libraries::Np::NpProfileDialog { static constexpr ImVec2 BUTTON_SIZE{100.0f, 30.0f}; -NpProfileDialogUi::NpProfileDialogUi(NpProfileDialogState* state, int* result) - : state(state), result(result) { - if (state) { +NpProfileDialogUi::NpProfileDialogUi(NpProfileDialogState* state, Status* status, int* result) + : state(state), status(status), result(result) { + if (status && *status == Status::RUNNING) { first_render = true; - AddLayer(this); // register in Layer system + AddLayer(this); } } @@ -24,16 +28,18 @@ NpProfileDialogUi::~NpProfileDialogUi() { } NpProfileDialogUi::NpProfileDialogUi(NpProfileDialogUi&& other) noexcept - : Layer(other), state(other.state), result(other.result) { + : Layer(other), state(other.state), status(other.status), result(other.result) { other.state = nullptr; + other.status = nullptr; other.result = nullptr; } NpProfileDialogUi& NpProfileDialogUi::operator=(NpProfileDialogUi other) { using std::swap; swap(state, other.state); + swap(status, other.status); swap(result, other.result); - if (state) { + if (status && *status == Status::RUNNING) { first_render = true; AddLayer(this); } @@ -42,16 +48,21 @@ NpProfileDialogUi& NpProfileDialogUi::operator=(NpProfileDialogUi other) { void NpProfileDialogUi::Finish(int result_code) { if (result) { - *result = result_code; // 0 = OK + *result = result_code; + } + if (status) { + *status = Status::FINISHED; } state = nullptr; + status = nullptr; result = nullptr; - RemoveLayer(this); // unregister from Layer system + RemoveLayer(this); } void NpProfileDialogUi::Draw() { - if (!state) + if (status == nullptr || *status != Status::RUNNING) { return; + } const auto& io = GetIO(); ImVec2 window_size{std::min(io.DisplaySize.x, 400.0f), std::min(io.DisplaySize.y, 200.0f)}; @@ -94,4 +105,4 @@ void NpProfileDialogUi::Draw() { first_render = false; } -} // namespace Libraries::Np::NpProfileDialog \ No newline at end of file +} // namespace Libraries::Np::NpProfileDialog diff --git a/src/core/libraries/np/np_profile_dialog/np_profile_dialog_ui.h b/src/core/libraries/np/np_profile_dialog/np_profile_dialog_ui.h index d3efd1346..1c5c5491b 100644 --- a/src/core/libraries/np/np_profile_dialog/np_profile_dialog_ui.h +++ b/src/core/libraries/np/np_profile_dialog/np_profile_dialog_ui.h @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: Copyright 2026 shadPS4 Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + #pragma once #include @@ -17,21 +20,23 @@ struct NpProfileDialogState { class NpProfileDialogUi : public ImGui::Layer { public: - explicit NpProfileDialogUi(NpProfileDialogState* state = nullptr, int* result = nullptr); - ~NpProfileDialogUi(); + explicit NpProfileDialogUi(NpProfileDialogState* state = nullptr, + CommonDialog::Status* status = nullptr, int* result = nullptr); + ~NpProfileDialogUi() override; NpProfileDialogUi(const NpProfileDialogUi& other) = delete; NpProfileDialogUi(NpProfileDialogUi&& other) noexcept; NpProfileDialogUi& operator=(NpProfileDialogUi other); + void Finish(int result_code); + void Draw() override; private: - void Finish(int result_code); - NpProfileDialogState* state{}; + CommonDialog::Status* status{}; int* result{}; - bool first_render{true}; + bool first_render{false}; }; } // namespace Libraries::Np::NpProfileDialog From bd4824f0bdaf625675465d542fc41f3436ad9ff2 Mon Sep 17 00:00:00 2001 From: georgemoralis Date: Tue, 7 Apr 2026 19:00:04 +0300 Subject: [PATCH 7/9] more fixups --- .../np_profile_dialog/np_profile_dialog.cpp | 40 ++++++++++++++----- .../np/np_profile_dialog/np_profile_dialog.h | 13 +++++- .../np_profile_dialog_ui.cpp | 23 +++++++---- .../np_profile_dialog/np_profile_dialog_ui.h | 10 +++-- 4 files changed, 64 insertions(+), 22 deletions(-) diff --git a/src/core/libraries/np/np_profile_dialog/np_profile_dialog.cpp b/src/core/libraries/np/np_profile_dialog/np_profile_dialog.cpp index 06b7af5d0..f35f484b6 100644 --- a/src/core/libraries/np/np_profile_dialog/np_profile_dialog.cpp +++ b/src/core/libraries/np/np_profile_dialog/np_profile_dialog.cpp @@ -13,8 +13,7 @@ namespace Libraries::Np::NpProfileDialog { static auto g_status = Libraries::CommonDialog::Status::NONE; static NpProfileDialogState g_state{}; -// static DialogResult g_result{}; -static int g_result = 0; // TODO use real result when implementing dialog +static OrbisNpProfileDialogResult g_result{}; static NpProfileDialogUi g_profile_dialog_ui; Libraries::CommonDialog::Error PS4_SYSV_ABI @@ -27,8 +26,11 @@ sceNpProfileDialogOpen(OrbisNpProfileDialogParam* param) { LOG_ERROR(Lib_NpProfileDialog, "(STUBBED) called"); NpProfileDialogState state{}; state.onlineId = std::string(param->targetOnlineId.data); + state.hasAccountId = false; state.userId = param->userId; g_state = state; + g_result = {}; + g_result.userData = param->userData; g_status = Libraries::CommonDialog::Status::RUNNING; g_profile_dialog_ui = NpProfileDialogUi(&g_state, &g_status, &g_result); return Libraries::CommonDialog::Error::OK; @@ -39,13 +41,18 @@ Libraries::CommonDialog::Error PS4_SYSV_ABI sceNpProfileDialogClose() { if (g_status != Libraries::CommonDialog::Status::RUNNING) { return Libraries::CommonDialog::Error::NOT_RUNNING; } - g_profile_dialog_ui.Finish(0); + g_profile_dialog_ui.Finish(Libraries::CommonDialog::Result::OK); return Libraries::CommonDialog::Error::OK; } -s32 PS4_SYSV_ABI sceNpProfileDialogGetResult() { - LOG_ERROR(Lib_NpProfileDialog, "(STUBBED) called"); - return ORBIS_OK; +Libraries::CommonDialog::Error PS4_SYSV_ABI +sceNpProfileDialogGetResult(OrbisNpProfileDialogResult* result) { + LOG_DEBUG(Lib_NpProfileDialog, "called"); + if (result == nullptr) { + return Libraries::CommonDialog::Error::PARAM_INVALID; + } + *result = g_result; + return Libraries::CommonDialog::Error::OK; } Libraries::CommonDialog::Status PS4_SYSV_ABI sceNpProfileDialogGetStatus() { @@ -69,9 +76,24 @@ Libraries::CommonDialog::Error PS4_SYSV_ABI sceNpProfileDialogInitialize() { return Libraries::CommonDialog::Error::OK; } -s32 PS4_SYSV_ABI sceNpProfileDialogOpenA(OrbisNpProfileDialogParamA* param) { +Libraries::CommonDialog::Error PS4_SYSV_ABI +sceNpProfileDialogOpenA(OrbisNpProfileDialogParamA* param) { + if (g_status != Libraries::CommonDialog::Status::INITIALIZED && + g_status != Libraries::CommonDialog::Status::FINISHED) { + LOG_INFO(Lib_NpProfileDialog, "called without initialize"); + return Libraries::CommonDialog::Error::INVALID_STATE; + } LOG_ERROR(Lib_NpProfileDialog, "(STUBBED) called"); - return ORBIS_OK; + NpProfileDialogState state{}; + state.accountId = param->targetAccountId; + state.hasAccountId = true; + state.userId = param->userId; + g_state = state; + g_result = {}; + g_result.userData = param->userData; + g_status = Libraries::CommonDialog::Status::RUNNING; + g_profile_dialog_ui = NpProfileDialogUi(&g_state, &g_status, &g_result); + return Libraries::CommonDialog::Error::OK; } Libraries::CommonDialog::Error PS4_SYSV_ABI sceNpProfileDialogTerminate() { @@ -112,4 +134,4 @@ void RegisterLib(Core::Loader::SymbolsResolver* sym) { sceNpProfileDialogUpdateStatus); }; -} // namespace Libraries::Np::NpProfileDialog \ No newline at end of file +} // namespace Libraries::Np::NpProfileDialog diff --git a/src/core/libraries/np/np_profile_dialog/np_profile_dialog.h b/src/core/libraries/np/np_profile_dialog/np_profile_dialog.h index b09870f2e..5c7ae66eb 100644 --- a/src/core/libraries/np/np_profile_dialog/np_profile_dialog.h +++ b/src/core/libraries/np/np_profile_dialog/np_profile_dialog.h @@ -48,13 +48,22 @@ struct OrbisNpProfileDialogParamA { }; }; +struct OrbisNpProfileDialogResult { + s32 result; + CommonDialog::Result userAction; + void* userData; + u8 reserved[32]; +}; + Libraries::CommonDialog::Error PS4_SYSV_ABI sceNpProfileDialogOpen(OrbisNpProfileDialogParam* param); Libraries::CommonDialog::Error PS4_SYSV_ABI sceNpProfileDialogClose(); -s32 PS4_SYSV_ABI sceNpProfileDialogGetResult(); +Libraries::CommonDialog::Error PS4_SYSV_ABI +sceNpProfileDialogGetResult(OrbisNpProfileDialogResult* result); Libraries::CommonDialog::Status PS4_SYSV_ABI sceNpProfileDialogGetStatus(); Libraries::CommonDialog::Error PS4_SYSV_ABI sceNpProfileDialogInitialize(); -s32 PS4_SYSV_ABI sceNpProfileDialogOpenA(OrbisNpProfileDialogParamA* param); +Libraries::CommonDialog::Error PS4_SYSV_ABI +sceNpProfileDialogOpenA(OrbisNpProfileDialogParamA* param); Libraries::CommonDialog::Error PS4_SYSV_ABI sceNpProfileDialogTerminate(); Libraries::CommonDialog::Status PS4_SYSV_ABI sceNpProfileDialogUpdateStatus(); diff --git a/src/core/libraries/np/np_profile_dialog/np_profile_dialog_ui.cpp b/src/core/libraries/np/np_profile_dialog/np_profile_dialog_ui.cpp index 67a702910..23d6b21e6 100644 --- a/src/core/libraries/np/np_profile_dialog/np_profile_dialog_ui.cpp +++ b/src/core/libraries/np/np_profile_dialog/np_profile_dialog_ui.cpp @@ -1,9 +1,9 @@ // SPDX-FileCopyrightText: Copyright 2025-2026 shadPS4 Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later +#include #include #include - #include #include #include "np_profile_dialog_ui.h" @@ -15,7 +15,8 @@ namespace Libraries::Np::NpProfileDialog { static constexpr ImVec2 BUTTON_SIZE{100.0f, 30.0f}; -NpProfileDialogUi::NpProfileDialogUi(NpProfileDialogState* state, Status* status, int* result) +NpProfileDialogUi::NpProfileDialogUi(NpProfileDialogState* state, Status* status, + OrbisNpProfileDialogResult* result) : state(state), status(status), result(result) { if (status && *status == Status::RUNNING) { first_render = true; @@ -24,7 +25,7 @@ NpProfileDialogUi::NpProfileDialogUi(NpProfileDialogState* state, Status* status } NpProfileDialogUi::~NpProfileDialogUi() { - Finish(0); + Finish(Result::USER_CANCELED); } NpProfileDialogUi::NpProfileDialogUi(NpProfileDialogUi&& other) noexcept @@ -46,9 +47,10 @@ NpProfileDialogUi& NpProfileDialogUi::operator=(NpProfileDialogUi other) { return *this; } -void NpProfileDialogUi::Finish(int result_code) { +void NpProfileDialogUi::Finish(Result user_action) { if (result) { - *result = result_code; + result->result = 0; // ORBIS_OK for normal termination + result->userAction = user_action; } if (status) { *status = Status::FINISHED; @@ -82,8 +84,13 @@ void NpProfileDialogUi::Draw() { Separator(); Spacing(); - Text("Online ID:"); - Text("%s", state->onlineId.c_str()); + if (state->hasAccountId) { + Text("Account ID:"); + Text("%" PRIu64, state->accountId); + } else { + Text("Online ID:"); + Text("%s", state->onlineId.c_str()); + } Spacing(); SetCursorPos({ @@ -92,7 +99,7 @@ void NpProfileDialogUi::Draw() { }); if (Button("OK", BUTTON_SIZE)) { - Finish(0); + Finish(Result::USER_CANCELED); } if (first_render) { diff --git a/src/core/libraries/np/np_profile_dialog/np_profile_dialog_ui.h b/src/core/libraries/np/np_profile_dialog/np_profile_dialog_ui.h index 1c5c5491b..6f035b13c 100644 --- a/src/core/libraries/np/np_profile_dialog/np_profile_dialog_ui.h +++ b/src/core/libraries/np/np_profile_dialog/np_profile_dialog_ui.h @@ -10,32 +10,36 @@ #include "common/types.h" #include "core/libraries/system/commondialog.h" #include "imgui/imgui_layer.h" +#include "np_profile_dialog.h" namespace Libraries::Np::NpProfileDialog { struct NpProfileDialogState { std::string onlineId; + OrbisNpAccountId accountId{}; + bool hasAccountId{false}; int userId{}; }; class NpProfileDialogUi : public ImGui::Layer { public: explicit NpProfileDialogUi(NpProfileDialogState* state = nullptr, - CommonDialog::Status* status = nullptr, int* result = nullptr); + CommonDialog::Status* status = nullptr, + OrbisNpProfileDialogResult* result = nullptr); ~NpProfileDialogUi() override; NpProfileDialogUi(const NpProfileDialogUi& other) = delete; NpProfileDialogUi(NpProfileDialogUi&& other) noexcept; NpProfileDialogUi& operator=(NpProfileDialogUi other); - void Finish(int result_code); + void Finish(CommonDialog::Result user_action); void Draw() override; private: NpProfileDialogState* state{}; CommonDialog::Status* status{}; - int* result{}; + OrbisNpProfileDialogResult* result{}; bool first_render{false}; }; From 77f9275d82ce01d523b47ef7fc7b44410bdf3d60 Mon Sep 17 00:00:00 2001 From: georgemoralis Date: Tue, 7 Apr 2026 20:42:59 +0300 Subject: [PATCH 8/9] forgot cmakelists :D --- CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8efb569f4..3d69da660 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -625,6 +625,8 @@ set(NP_LIBS src/core/libraries/np/np_error.h src/core/libraries/np/np_auth.h src/core/libraries/np/np_profile_dialog/np_profile_dialog.cpp src/core/libraries/np/np_profile_dialog/np_profile_dialog.h + src/core/libraries/np/np_profile_dialog/np_profile_dialog_ui.cpp + src/core/libraries/np/np_profile_dialog/np_profile_dialog_ui.h src/core/libraries/np/np_sns_facebook_dialog.cpp src/core/libraries/np/np_sns_facebook_dialog.h src/core/libraries/np/np_partner.cpp From f696b8de1a6a1c701a275344809c8dafeb88485a Mon Sep 17 00:00:00 2001 From: georgemoralis Date: Wed, 8 Apr 2026 17:50:17 +0300 Subject: [PATCH 9/9] improvements in np profile dialog + UI --- .../np_profile_dialog/np_profile_dialog.cpp | 20 +- .../np/np_profile_dialog/np_profile_dialog.h | 17 +- .../np_profile_dialog_ui.cpp | 210 ++++++++++++++++-- .../np_profile_dialog/np_profile_dialog_ui.h | 3 +- 4 files changed, 224 insertions(+), 26 deletions(-) diff --git a/src/core/libraries/np/np_profile_dialog/np_profile_dialog.cpp b/src/core/libraries/np/np_profile_dialog/np_profile_dialog.cpp index f35f484b6..823616cc3 100644 --- a/src/core/libraries/np/np_profile_dialog/np_profile_dialog.cpp +++ b/src/core/libraries/np/np_profile_dialog/np_profile_dialog.cpp @@ -1,6 +1,7 @@ // SPDX-FileCopyrightText: Copyright 2025-2026 shadPS4 Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later +#include #include #include "common/logging/log.h" #include "core/libraries/error_codes.h" @@ -23,10 +24,14 @@ sceNpProfileDialogOpen(OrbisNpProfileDialogParam* param) { LOG_INFO(Lib_NpProfileDialog, "called without initialize"); return Libraries::CommonDialog::Error::INVALID_STATE; } + if (param == nullptr) { + return Libraries::CommonDialog::Error::ARG_NULL; + } LOG_ERROR(Lib_NpProfileDialog, "(STUBBED) called"); NpProfileDialogState state{}; state.onlineId = std::string(param->targetOnlineId.data); state.hasAccountId = false; + state.mode = param->mode; state.userId = param->userId; g_state = state; g_result = {}; @@ -38,6 +43,9 @@ sceNpProfileDialogOpen(OrbisNpProfileDialogParam* param) { Libraries::CommonDialog::Error PS4_SYSV_ABI sceNpProfileDialogClose() { LOG_DEBUG(Lib_NpProfileDialog, "called"); + if (g_status == Libraries::CommonDialog::Status::NONE) { + return Libraries::CommonDialog::Error::NOT_INITIALIZED; + } if (g_status != Libraries::CommonDialog::Status::RUNNING) { return Libraries::CommonDialog::Error::NOT_RUNNING; } @@ -48,8 +56,14 @@ Libraries::CommonDialog::Error PS4_SYSV_ABI sceNpProfileDialogClose() { Libraries::CommonDialog::Error PS4_SYSV_ABI sceNpProfileDialogGetResult(OrbisNpProfileDialogResult* result) { LOG_DEBUG(Lib_NpProfileDialog, "called"); + if (g_status == Libraries::CommonDialog::Status::NONE) { + return Libraries::CommonDialog::Error::NOT_INITIALIZED; + } if (result == nullptr) { - return Libraries::CommonDialog::Error::PARAM_INVALID; + return Libraries::CommonDialog::Error::ARG_NULL; + } + if (g_status != Libraries::CommonDialog::Status::FINISHED) { + return Libraries::CommonDialog::Error::NOT_FINISHED; } *result = g_result; return Libraries::CommonDialog::Error::OK; @@ -83,10 +97,14 @@ sceNpProfileDialogOpenA(OrbisNpProfileDialogParamA* param) { LOG_INFO(Lib_NpProfileDialog, "called without initialize"); return Libraries::CommonDialog::Error::INVALID_STATE; } + if (param == nullptr) { + return Libraries::CommonDialog::Error::ARG_NULL; + } LOG_ERROR(Lib_NpProfileDialog, "(STUBBED) called"); NpProfileDialogState state{}; state.accountId = param->targetAccountId; state.hasAccountId = true; + state.mode = param->mode; state.userId = param->userId; g_state = state; g_result = {}; diff --git a/src/core/libraries/np/np_profile_dialog/np_profile_dialog.h b/src/core/libraries/np/np_profile_dialog/np_profile_dialog.h index 5c7ae66eb..075f78aaf 100644 --- a/src/core/libraries/np/np_profile_dialog/np_profile_dialog.h +++ b/src/core/libraries/np/np_profile_dialog/np_profile_dialog.h @@ -17,8 +17,23 @@ namespace Libraries::Np::NpProfileDialog { enum class OrbisNpProfileDialogMode : u32 { ORBIS_NP_PROFILE_DIALOG_MODE_INVALID = 0, ORBIS_NP_PROFILE_DIALOG_MODE_NORMAL = 1, + ORBIS_NP_PROFILE_DIALOG_MODE_FRIEND_REQUEST = 2, + ORBIS_NP_PROFILE_DIALOG_MODE_ADD_TO_BLOCK_LIST = 3, + ORBIS_NP_PROFILE_DIALOG_MODE_GRIEF_REPORT = 4, }; +using OrbisNpProfileGriefReportItem = s32; +static constexpr OrbisNpProfileGriefReportItem + ORBIS_NP_PROFILE_DIALOG_MENU_GRIEF_REPORT_ITEM_INVALID = 0x00000000; +static constexpr OrbisNpProfileGriefReportItem + ORBIS_NP_PROFILE_DIALOG_MENU_GRIEF_REPORT_ITEM_ONLINE_ID = 0x00000001; +static constexpr OrbisNpProfileGriefReportItem ORBIS_NP_PROFILE_DIALOG_MENU_GRIEF_REPORT_ITEM_NAME = + 0x00000002; +static constexpr OrbisNpProfileGriefReportItem + ORBIS_NP_PROFILE_DIALOG_MENU_GRIEF_REPORT_ITEM_PICTURE = 0x00000004; +static constexpr OrbisNpProfileGriefReportItem + ORBIS_NP_PROFILE_DIALOG_MENU_GRIEF_REPORT_ITEM_ABOUT_ME = 0x00000008; + struct OrbisNpProfileDialogParam { CommonDialog::BaseParam baseParam; u64 size; @@ -68,4 +83,4 @@ Libraries::CommonDialog::Error PS4_SYSV_ABI sceNpProfileDialogTerminate(); Libraries::CommonDialog::Status PS4_SYSV_ABI sceNpProfileDialogUpdateStatus(); void RegisterLib(Core::Loader::SymbolsResolver* sym); -} // namespace Libraries::Np::NpProfileDialog \ No newline at end of file +} // namespace Libraries::Np::NpProfileDialog diff --git a/src/core/libraries/np/np_profile_dialog/np_profile_dialog_ui.cpp b/src/core/libraries/np/np_profile_dialog/np_profile_dialog_ui.cpp index 23d6b21e6..b96d1879f 100644 --- a/src/core/libraries/np/np_profile_dialog/np_profile_dialog_ui.cpp +++ b/src/core/libraries/np/np_profile_dialog/np_profile_dialog_ui.cpp @@ -2,8 +2,10 @@ // SPDX-License-Identifier: GPL-2.0-or-later #include +#include #include #include + #include #include #include "np_profile_dialog_ui.h" @@ -13,13 +15,98 @@ using namespace Libraries::CommonDialog; namespace Libraries::Np::NpProfileDialog { -static constexpr ImVec2 BUTTON_SIZE{100.0f, 30.0f}; +// PS4 color palette +static constexpr ImVec4 COL_OVERLAY = {0.00f, 0.00f, 0.00f, 0.65f}; +static constexpr ImVec4 COL_HEADER_TOP = {0.00f, 0.34f, 0.62f, 1.00f}; +static constexpr ImVec4 COL_HEADER_BOT = {0.00f, 0.22f, 0.42f, 1.00f}; +static constexpr ImVec4 COL_CARD_BG = {0.11f, 0.11f, 0.12f, 1.00f}; +static constexpr ImVec4 COL_SEPARATOR = {0.22f, 0.22f, 0.24f, 1.00f}; +static constexpr ImVec4 COL_AVATAR_BG = {0.18f, 0.18f, 0.20f, 1.00f}; +static constexpr ImVec4 COL_AVATAR_OUTLINE = {0.00f, 0.44f, 0.75f, 1.00f}; +static constexpr ImVec4 COL_TEXT_PRIMARY = {1.00f, 1.00f, 1.00f, 1.00f}; +static constexpr ImVec4 COL_TEXT_SECONDARY = {0.65f, 0.65f, 0.68f, 1.00f}; +static constexpr ImVec4 COL_BUTTON_NORMAL = {0.18f, 0.18f, 0.20f, 1.00f}; +static constexpr ImVec4 COL_BUTTON_HOVERED = {0.00f, 0.44f, 0.75f, 1.00f}; +static constexpr ImVec4 COL_BUTTON_ACTIVE = {0.00f, 0.33f, 0.60f, 1.00f}; +static constexpr ImVec4 COL_BUTTON_BORDER = {0.32f, 0.32f, 0.35f, 1.00f}; + +static constexpr float CARD_WIDTH = 480.0f; +static constexpr float CARD_HEIGHT = 330.0f; +static constexpr float HEADER_HEIGHT = 44.0f; +static constexpr float FOOTER_HEIGHT = 56.0f; +static constexpr float AVATAR_RADIUS = 44.0f; +static constexpr float AVATAR_REL_X = CARD_WIDTH * 0.5f; +static constexpr float AVATAR_REL_Y = HEADER_HEIGHT + AVATAR_RADIUS + 16.0f; +static constexpr float FADE_SPEED = 8.0f; +static constexpr ImVec2 CLOSE_BUTTON_SIZE = {110.0f, 34.0f}; + +static ImU32 AlphaScale(ImVec4 col, float alpha) { + col.w *= alpha; + return GetColorU32(col); +} + +static void DrawCardShadow(ImDrawList* dl, ImVec2 min, ImVec2 max, float alpha) { + for (int i = 0; i < 6; ++i) { + const float spread = (float)(i + 1) * 3.5f; + const float a = alpha * (0.28f - (float)i * 0.04f); + if (a <= 0.0f) + break; + dl->AddRectFilled({min.x - spread, min.y + spread}, {max.x + spread, max.y + spread * 1.5f}, + IM_COL32(0, 0, 0, (int)(a * 255.0f)), 8.0f + spread); + } +} + +static void DrawAvatarPlaceholder(ImDrawList* dl, ImVec2 center, float radius, float alpha) { + const ImU32 bg_col = AlphaScale(COL_AVATAR_BG, alpha); + const ImU32 outline_col = AlphaScale(COL_AVATAR_OUTLINE, alpha); + const ImU32 silhouette = IM_COL32(90, 90, 96, (int)(alpha * 255.0f)); + + dl->AddCircleFilled(center, radius, bg_col, 64); + + dl->AddCircleFilled({center.x, center.y - radius * 0.18f}, radius * 0.32f, silhouette, 32); + + dl->AddCircleFilled({center.x, center.y + radius * 0.45f}, radius * 0.55f, silhouette, 48); + + // Outline drawn last — sits on top of silhouette + dl->AddCircle(center, radius, outline_col, 64, 2.5f); +} + +static const char* GetModeTitle(OrbisNpProfileDialogMode mode) { + switch (mode) { + case OrbisNpProfileDialogMode::ORBIS_NP_PROFILE_DIALOG_MODE_NORMAL: + return "Profile"; + case OrbisNpProfileDialogMode::ORBIS_NP_PROFILE_DIALOG_MODE_FRIEND_REQUEST: + return "Friend Request"; + case OrbisNpProfileDialogMode::ORBIS_NP_PROFILE_DIALOG_MODE_ADD_TO_BLOCK_LIST: + return "Block List"; + case OrbisNpProfileDialogMode::ORBIS_NP_PROFILE_DIALOG_MODE_GRIEF_REPORT: + return "Report"; + default: + return "Profile"; + } +} + +static const char* GetModeSubtitle(OrbisNpProfileDialogMode mode) { + switch (mode) { + case OrbisNpProfileDialogMode::ORBIS_NP_PROFILE_DIALOG_MODE_NORMAL: + return "Player Profile"; + case OrbisNpProfileDialogMode::ORBIS_NP_PROFILE_DIALOG_MODE_FRIEND_REQUEST: + return "Send Friend Request"; + case OrbisNpProfileDialogMode::ORBIS_NP_PROFILE_DIALOG_MODE_ADD_TO_BLOCK_LIST: + return "Add to Block List"; + case OrbisNpProfileDialogMode::ORBIS_NP_PROFILE_DIALOG_MODE_GRIEF_REPORT: + return "Report Player"; + default: + return "Player Profile"; + } +} NpProfileDialogUi::NpProfileDialogUi(NpProfileDialogState* state, Status* status, OrbisNpProfileDialogResult* result) : state(state), status(status), result(result) { if (status && *status == Status::RUNNING) { first_render = true; + open_alpha = 0.0f; AddLayer(this); } } @@ -29,10 +116,12 @@ NpProfileDialogUi::~NpProfileDialogUi() { } NpProfileDialogUi::NpProfileDialogUi(NpProfileDialogUi&& other) noexcept - : Layer(other), state(other.state), status(other.status), result(other.result) { + : Layer(other), state(other.state), status(other.status), result(other.result), + open_alpha(other.open_alpha) { other.state = nullptr; other.status = nullptr; other.result = nullptr; + other.open_alpha = 0.0f; } NpProfileDialogUi& NpProfileDialogUi::operator=(NpProfileDialogUi other) { @@ -40,8 +129,10 @@ NpProfileDialogUi& NpProfileDialogUi::operator=(NpProfileDialogUi other) { swap(state, other.state); swap(status, other.status); swap(result, other.result); + swap(open_alpha, other.open_alpha); if (status && *status == Status::RUNNING) { first_render = true; + open_alpha = 0.0f; AddLayer(this); } return *this; @@ -49,7 +140,7 @@ NpProfileDialogUi& NpProfileDialogUi::operator=(NpProfileDialogUi other) { void NpProfileDialogUi::Finish(Result user_action) { if (result) { - result->result = 0; // ORBIS_OK for normal termination + result->result = 0; // ORBIS_OK result->userAction = user_action; } if (status) { @@ -67,48 +158,121 @@ void NpProfileDialogUi::Draw() { } const auto& io = GetIO(); - ImVec2 window_size{std::min(io.DisplaySize.x, 400.0f), std::min(io.DisplaySize.y, 200.0f)}; + open_alpha = std::fmin(open_alpha + io.DeltaTime * FADE_SPEED, 1.0f); - CentralizeNextWindow(); - SetNextWindowSize(window_size); + const float card_x = (io.DisplaySize.x - CARD_WIDTH) * 0.5f; + const float card_y = (io.DisplaySize.y - CARD_HEIGHT) * 0.5f; + const ImVec2 card_min = {card_x, card_y}; + const ImVec2 card_max = {card_x + CARD_WIDTH, card_y + CARD_HEIGHT}; + + SetNextWindowPos({0, 0}); + SetNextWindowSize(io.DisplaySize); + PushStyleColor(ImGuiCol_WindowBg, AlphaScale(COL_OVERLAY, open_alpha)); + PushStyleVar(ImGuiStyleVar_WindowPadding, {0.0f, 0.0f}); + Begin("##NpProfileDialogOverlay", nullptr, + ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_NoSavedSettings | + ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoInputs | ImGuiWindowFlags_NoNav | + ImGuiWindowFlags_NoBringToFrontOnFocus | ImGuiWindowFlags_NoFocusOnAppearing); + End(); + PopStyleVar(); + PopStyleColor(); + + SetNextWindowPos(card_min); + SetNextWindowSize({CARD_WIDTH, CARD_HEIGHT}); SetNextWindowCollapsed(false); if (first_render || !io.NavActive) { SetNextWindowFocus(); } KeepNavHighlight(); - if (Begin("NP Profile##NpProfileDialog", nullptr, - ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_NoSavedSettings)) { + PushStyleColor(ImGuiCol_WindowBg, AlphaScale(COL_CARD_BG, open_alpha)); + PushStyleColor(ImGuiCol_Border, AlphaScale(COL_SEPARATOR, open_alpha)); + PushStyleColor(ImGuiCol_Text, AlphaScale(COL_TEXT_PRIMARY, open_alpha)); + PushStyleColor(ImGuiCol_Button, AlphaScale(COL_BUTTON_NORMAL, open_alpha)); + PushStyleColor(ImGuiCol_ButtonHovered, AlphaScale(COL_BUTTON_HOVERED, open_alpha)); + PushStyleColor(ImGuiCol_ButtonActive, AlphaScale(COL_BUTTON_ACTIVE, open_alpha)); + PushStyleVar(ImGuiStyleVar_WindowPadding, {0.0f, 0.0f}); + PushStyleVar(ImGuiStyleVar_WindowRounding, 6.0f); + PushStyleVar(ImGuiStyleVar_FrameRounding, 4.0f); + PushStyleVar(ImGuiStyleVar_WindowBorderSize, 1.0f); - Text("Player Profile"); - Separator(); - Spacing(); + if (Begin("##NpProfileDialog", nullptr, + ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_NoSavedSettings | + ImGuiWindowFlags_NoMove)) { + ImDrawList* dl = GetWindowDrawList(); + const ImVec2 win_pos = GetWindowPos(); + + DrawCardShadow(dl, card_min, card_max, open_alpha); + + const ImVec2 hdr_min = win_pos; + const ImVec2 hdr_max = {win_pos.x + CARD_WIDTH, win_pos.y + HEADER_HEIGHT}; + dl->AddRectFilledMultiColor(hdr_min, hdr_max, AlphaScale(COL_HEADER_TOP, open_alpha), + AlphaScale(COL_HEADER_TOP, open_alpha), + AlphaScale(COL_HEADER_BOT, open_alpha), + AlphaScale(COL_HEADER_BOT, open_alpha)); + dl->AddRectFilled({hdr_min.x, hdr_max.y - 6.0f}, hdr_max, + AlphaScale(COL_HEADER_BOT, open_alpha)); + + dl->AddLine({hdr_min.x + 6.0f, hdr_min.y + 1.0f}, {hdr_max.x - 6.0f, hdr_min.y + 1.0f}, + IM_COL32(255, 255, 255, (int)(open_alpha * 40.0f)), 1.0f); + + // Footer separator + const float footer_top_screen = win_pos.y + CARD_HEIGHT - FOOTER_HEIGHT; + dl->AddLine({win_pos.x, footer_top_screen}, {win_pos.x + CARD_WIDTH, footer_top_screen}, + AlphaScale(COL_SEPARATOR, open_alpha), 1.0f); + + // Avatar + const ImVec2 avatar_screen = {win_pos.x + AVATAR_REL_X, win_pos.y + AVATAR_REL_Y}; + DrawAvatarPlaceholder(dl, avatar_screen, AVATAR_RADIUS, open_alpha); + + // Header title + const char* title = GetModeTitle(state->mode); + const ImVec2 title_sz = CalcTextSize(title); + SetCursorPos({(CARD_WIDTH - title_sz.x) * 0.5f, (HEADER_HEIGHT - title_sz.y) * 0.5f}); + TextUnformatted(title); + + // Online ID / Account ID + char id_buf[32]{}; + const char* id_str = state->onlineId.c_str(); if (state->hasAccountId) { - Text("Account ID:"); - Text("%" PRIu64, state->accountId); - } else { - Text("Online ID:"); - Text("%s", state->onlineId.c_str()); + snprintf(id_buf, sizeof(id_buf), "%" PRIu64, state->accountId); + id_str = id_buf; } + const float id_y = AVATAR_REL_Y + AVATAR_RADIUS + 14.0f; + const ImVec2 id_sz = CalcTextSize(id_str); + SetCursorPos({(CARD_WIDTH - id_sz.x) * 0.5f, id_y}); + TextUnformatted(id_str); - Spacing(); - SetCursorPos({ - window_size.x / 2.0f - BUTTON_SIZE.x / 2.0f, - window_size.y - 10.0f - BUTTON_SIZE.y, - }); + // Mode subtitle + PushStyleColor(ImGuiCol_Text, AlphaScale(COL_TEXT_SECONDARY, open_alpha)); + const char* subtitle = GetModeSubtitle(state->mode); + const ImVec2 sub_sz = CalcTextSize(subtitle); + SetCursorPos({(CARD_WIDTH - sub_sz.x) * 0.5f, id_y + id_sz.y + 5.0f}); + TextUnformatted(subtitle); + PopStyleColor(); - if (Button("OK", BUTTON_SIZE)) { + const float footer_y_local = CARD_HEIGHT - FOOTER_HEIGHT; + + PushStyleColor(ImGuiCol_Border, AlphaScale(COL_BUTTON_BORDER, open_alpha)); + PushStyleVar(ImGuiStyleVar_FrameBorderSize, 1.0f); + SetCursorPos({CARD_WIDTH - CLOSE_BUTTON_SIZE.x - 16.0f, + footer_y_local + (FOOTER_HEIGHT - CLOSE_BUTTON_SIZE.y) * 0.5f}); + if (Button("Close##btn", CLOSE_BUTTON_SIZE)) { Finish(Result::USER_CANCELED); } + PopStyleVar(); + PopStyleColor(); if (first_render) { SetItemCurrentNavFocus(); } } - End(); + PopStyleVar(4); + PopStyleColor(6); + first_render = false; } diff --git a/src/core/libraries/np/np_profile_dialog/np_profile_dialog_ui.h b/src/core/libraries/np/np_profile_dialog/np_profile_dialog_ui.h index 6f035b13c..6206ca066 100644 --- a/src/core/libraries/np/np_profile_dialog/np_profile_dialog_ui.h +++ b/src/core/libraries/np/np_profile_dialog/np_profile_dialog_ui.h @@ -5,7 +5,6 @@ #include #include - #include "common/fixed_value.h" #include "common/types.h" #include "core/libraries/system/commondialog.h" @@ -18,6 +17,7 @@ struct NpProfileDialogState { std::string onlineId; OrbisNpAccountId accountId{}; bool hasAccountId{false}; + OrbisNpProfileDialogMode mode{OrbisNpProfileDialogMode::ORBIS_NP_PROFILE_DIALOG_MODE_INVALID}; int userId{}; }; @@ -41,6 +41,7 @@ private: CommonDialog::Status* status{}; OrbisNpProfileDialogResult* result{}; bool first_render{false}; + float open_alpha{0.0f}; }; } // namespace Libraries::Np::NpProfileDialog