fixes a bit more ui

This commit is contained in:
georgemoralis 2026-04-07 17:55:01 +03:00
parent 0ba4e96b55
commit fd8d839763
4 changed files with 36 additions and 25 deletions

View File

@ -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;
}

View File

@ -48,7 +48,6 @@ struct OrbisNpProfileDialogParamA {
};
};
Libraries::CommonDialog::Error PS4_SYSV_ABI
sceNpProfileDialogOpen(OrbisNpProfileDialogParam* param);
Libraries::CommonDialog::Error PS4_SYSV_ABI sceNpProfileDialogClose();

View File

@ -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 <thread>
#include <utility>
#include <imgui.h>
#include <imgui/imgui_std.h>
#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
} // namespace Libraries::Np::NpProfileDialog

View File

@ -1,3 +1,6 @@
// SPDX-FileCopyrightText: Copyright 2026 shadPS4 Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
#include <string>
@ -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