mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2026-04-08 10:01:28 -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 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
|
||||
} // 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
|
||||
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();
|
||||
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
// SPDX-FileCopyrightText: Copyright 2025-2026 shadPS4 Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#include <cinttypes>
|
||||
#include <thread>
|
||||
#include <utility>
|
||||
|
||||
#include <imgui.h>
|
||||
#include <imgui/imgui_std.h>
|
||||
#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) {
|
||||
|
||||
@ -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};
|
||||
};
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user