mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2026-06-03 14:14:59 -06:00
more fixups
This commit is contained in:
parent
fd8d839763
commit
bd4824f0bd
@ -13,8 +13,7 @@ namespace Libraries::Np::NpProfileDialog {
|
|||||||
|
|
||||||
static auto g_status = Libraries::CommonDialog::Status::NONE;
|
static auto g_status = Libraries::CommonDialog::Status::NONE;
|
||||||
static NpProfileDialogState g_state{};
|
static NpProfileDialogState g_state{};
|
||||||
// static DialogResult g_result{};
|
static OrbisNpProfileDialogResult g_result{};
|
||||||
static int g_result = 0; // TODO use real result when implementing dialog
|
|
||||||
static NpProfileDialogUi g_profile_dialog_ui;
|
static NpProfileDialogUi g_profile_dialog_ui;
|
||||||
|
|
||||||
Libraries::CommonDialog::Error PS4_SYSV_ABI
|
Libraries::CommonDialog::Error PS4_SYSV_ABI
|
||||||
@ -27,8 +26,11 @@ sceNpProfileDialogOpen(OrbisNpProfileDialogParam* param) {
|
|||||||
LOG_ERROR(Lib_NpProfileDialog, "(STUBBED) called");
|
LOG_ERROR(Lib_NpProfileDialog, "(STUBBED) called");
|
||||||
NpProfileDialogState state{};
|
NpProfileDialogState state{};
|
||||||
state.onlineId = std::string(param->targetOnlineId.data);
|
state.onlineId = std::string(param->targetOnlineId.data);
|
||||||
|
state.hasAccountId = false;
|
||||||
state.userId = param->userId;
|
state.userId = param->userId;
|
||||||
g_state = state;
|
g_state = state;
|
||||||
|
g_result = {};
|
||||||
|
g_result.userData = param->userData;
|
||||||
g_status = Libraries::CommonDialog::Status::RUNNING;
|
g_status = Libraries::CommonDialog::Status::RUNNING;
|
||||||
g_profile_dialog_ui = NpProfileDialogUi(&g_state, &g_status, &g_result);
|
g_profile_dialog_ui = NpProfileDialogUi(&g_state, &g_status, &g_result);
|
||||||
return Libraries::CommonDialog::Error::OK;
|
return Libraries::CommonDialog::Error::OK;
|
||||||
@ -39,13 +41,18 @@ Libraries::CommonDialog::Error PS4_SYSV_ABI sceNpProfileDialogClose() {
|
|||||||
if (g_status != Libraries::CommonDialog::Status::RUNNING) {
|
if (g_status != Libraries::CommonDialog::Status::RUNNING) {
|
||||||
return Libraries::CommonDialog::Error::NOT_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;
|
return Libraries::CommonDialog::Error::OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
s32 PS4_SYSV_ABI sceNpProfileDialogGetResult() {
|
Libraries::CommonDialog::Error PS4_SYSV_ABI
|
||||||
LOG_ERROR(Lib_NpProfileDialog, "(STUBBED) called");
|
sceNpProfileDialogGetResult(OrbisNpProfileDialogResult* result) {
|
||||||
return ORBIS_OK;
|
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() {
|
Libraries::CommonDialog::Status PS4_SYSV_ABI sceNpProfileDialogGetStatus() {
|
||||||
@ -69,9 +76,24 @@ Libraries::CommonDialog::Error PS4_SYSV_ABI sceNpProfileDialogInitialize() {
|
|||||||
return Libraries::CommonDialog::Error::OK;
|
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");
|
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() {
|
Libraries::CommonDialog::Error PS4_SYSV_ABI sceNpProfileDialogTerminate() {
|
||||||
@ -112,4 +134,4 @@ void RegisterLib(Core::Loader::SymbolsResolver* sym) {
|
|||||||
sceNpProfileDialogUpdateStatus);
|
sceNpProfileDialogUpdateStatus);
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Libraries::Np::NpProfileDialog
|
} // namespace Libraries::Np::NpProfileDialog
|
||||||
|
|||||||
@ -48,13 +48,22 @@ struct OrbisNpProfileDialogParamA {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct OrbisNpProfileDialogResult {
|
||||||
|
s32 result;
|
||||||
|
CommonDialog::Result userAction;
|
||||||
|
void* userData;
|
||||||
|
u8 reserved[32];
|
||||||
|
};
|
||||||
|
|
||||||
Libraries::CommonDialog::Error PS4_SYSV_ABI
|
Libraries::CommonDialog::Error PS4_SYSV_ABI
|
||||||
sceNpProfileDialogOpen(OrbisNpProfileDialogParam* param);
|
sceNpProfileDialogOpen(OrbisNpProfileDialogParam* param);
|
||||||
Libraries::CommonDialog::Error PS4_SYSV_ABI sceNpProfileDialogClose();
|
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::Status PS4_SYSV_ABI sceNpProfileDialogGetStatus();
|
||||||
Libraries::CommonDialog::Error PS4_SYSV_ABI sceNpProfileDialogInitialize();
|
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::Error PS4_SYSV_ABI sceNpProfileDialogTerminate();
|
||||||
Libraries::CommonDialog::Status PS4_SYSV_ABI sceNpProfileDialogUpdateStatus();
|
Libraries::CommonDialog::Status PS4_SYSV_ABI sceNpProfileDialogUpdateStatus();
|
||||||
|
|
||||||
|
|||||||
@ -1,9 +1,9 @@
|
|||||||
// SPDX-FileCopyrightText: Copyright 2025-2026 shadPS4 Emulator Project
|
// SPDX-FileCopyrightText: Copyright 2025-2026 shadPS4 Emulator Project
|
||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
|
#include <cinttypes>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
#include <imgui.h>
|
#include <imgui.h>
|
||||||
#include <imgui/imgui_std.h>
|
#include <imgui/imgui_std.h>
|
||||||
#include "np_profile_dialog_ui.h"
|
#include "np_profile_dialog_ui.h"
|
||||||
@ -15,7 +15,8 @@ namespace Libraries::Np::NpProfileDialog {
|
|||||||
|
|
||||||
static constexpr ImVec2 BUTTON_SIZE{100.0f, 30.0f};
|
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) {
|
: state(state), status(status), result(result) {
|
||||||
if (status && *status == Status::RUNNING) {
|
if (status && *status == Status::RUNNING) {
|
||||||
first_render = true;
|
first_render = true;
|
||||||
@ -24,7 +25,7 @@ NpProfileDialogUi::NpProfileDialogUi(NpProfileDialogState* state, Status* status
|
|||||||
}
|
}
|
||||||
|
|
||||||
NpProfileDialogUi::~NpProfileDialogUi() {
|
NpProfileDialogUi::~NpProfileDialogUi() {
|
||||||
Finish(0);
|
Finish(Result::USER_CANCELED);
|
||||||
}
|
}
|
||||||
|
|
||||||
NpProfileDialogUi::NpProfileDialogUi(NpProfileDialogUi&& other) noexcept
|
NpProfileDialogUi::NpProfileDialogUi(NpProfileDialogUi&& other) noexcept
|
||||||
@ -46,9 +47,10 @@ NpProfileDialogUi& NpProfileDialogUi::operator=(NpProfileDialogUi other) {
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
void NpProfileDialogUi::Finish(int result_code) {
|
void NpProfileDialogUi::Finish(Result user_action) {
|
||||||
if (result) {
|
if (result) {
|
||||||
*result = result_code;
|
result->result = 0; // ORBIS_OK for normal termination
|
||||||
|
result->userAction = user_action;
|
||||||
}
|
}
|
||||||
if (status) {
|
if (status) {
|
||||||
*status = Status::FINISHED;
|
*status = Status::FINISHED;
|
||||||
@ -82,8 +84,13 @@ void NpProfileDialogUi::Draw() {
|
|||||||
Separator();
|
Separator();
|
||||||
Spacing();
|
Spacing();
|
||||||
|
|
||||||
Text("Online ID:");
|
if (state->hasAccountId) {
|
||||||
Text("%s", state->onlineId.c_str());
|
Text("Account ID:");
|
||||||
|
Text("%" PRIu64, state->accountId);
|
||||||
|
} else {
|
||||||
|
Text("Online ID:");
|
||||||
|
Text("%s", state->onlineId.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
Spacing();
|
Spacing();
|
||||||
SetCursorPos({
|
SetCursorPos({
|
||||||
@ -92,7 +99,7 @@ void NpProfileDialogUi::Draw() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (Button("OK", BUTTON_SIZE)) {
|
if (Button("OK", BUTTON_SIZE)) {
|
||||||
Finish(0);
|
Finish(Result::USER_CANCELED);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (first_render) {
|
if (first_render) {
|
||||||
|
|||||||
@ -10,32 +10,36 @@
|
|||||||
#include "common/types.h"
|
#include "common/types.h"
|
||||||
#include "core/libraries/system/commondialog.h"
|
#include "core/libraries/system/commondialog.h"
|
||||||
#include "imgui/imgui_layer.h"
|
#include "imgui/imgui_layer.h"
|
||||||
|
#include "np_profile_dialog.h"
|
||||||
|
|
||||||
namespace Libraries::Np::NpProfileDialog {
|
namespace Libraries::Np::NpProfileDialog {
|
||||||
|
|
||||||
struct NpProfileDialogState {
|
struct NpProfileDialogState {
|
||||||
std::string onlineId;
|
std::string onlineId;
|
||||||
|
OrbisNpAccountId accountId{};
|
||||||
|
bool hasAccountId{false};
|
||||||
int userId{};
|
int userId{};
|
||||||
};
|
};
|
||||||
|
|
||||||
class NpProfileDialogUi : public ImGui::Layer {
|
class NpProfileDialogUi : public ImGui::Layer {
|
||||||
public:
|
public:
|
||||||
explicit NpProfileDialogUi(NpProfileDialogState* state = nullptr,
|
explicit NpProfileDialogUi(NpProfileDialogState* state = nullptr,
|
||||||
CommonDialog::Status* status = nullptr, int* result = nullptr);
|
CommonDialog::Status* status = nullptr,
|
||||||
|
OrbisNpProfileDialogResult* result = nullptr);
|
||||||
~NpProfileDialogUi() override;
|
~NpProfileDialogUi() override;
|
||||||
|
|
||||||
NpProfileDialogUi(const NpProfileDialogUi& other) = delete;
|
NpProfileDialogUi(const NpProfileDialogUi& other) = delete;
|
||||||
NpProfileDialogUi(NpProfileDialogUi&& other) noexcept;
|
NpProfileDialogUi(NpProfileDialogUi&& other) noexcept;
|
||||||
NpProfileDialogUi& operator=(NpProfileDialogUi other);
|
NpProfileDialogUi& operator=(NpProfileDialogUi other);
|
||||||
|
|
||||||
void Finish(int result_code);
|
void Finish(CommonDialog::Result user_action);
|
||||||
|
|
||||||
void Draw() override;
|
void Draw() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
NpProfileDialogState* state{};
|
NpProfileDialogState* state{};
|
||||||
CommonDialog::Status* status{};
|
CommonDialog::Status* status{};
|
||||||
int* result{};
|
OrbisNpProfileDialogResult* result{};
|
||||||
bool first_render{false};
|
bool first_render{false};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user