mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-08-03 07:52:31 +00:00
system/MsgDialog: Progress bar dialog
This commit is contained in:
parent
ad57ab8fee
commit
6fdfde7649
@ -82,19 +82,48 @@ Error PS4_SYSV_ABI sceMsgDialogOpen(const Param* param) {
|
|||||||
return Error::OK;
|
return Error::OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
int PS4_SYSV_ABI sceMsgDialogProgressBarInc() {
|
Error PS4_SYSV_ABI sceMsgDialogProgressBarInc(OrbisMsgDialogProgressBarTarget target, u32 delta) {
|
||||||
LOG_ERROR(Lib_MsgDlg, "(STUBBED) called");
|
if (g_status != Status::RUNNING) {
|
||||||
return ORBIS_OK;
|
return Error::NOT_RUNNING;
|
||||||
|
}
|
||||||
|
if (g_param.mode != MsgDialogMode::PROGRESS_BAR) {
|
||||||
|
return Error::NOT_SUPPORTED;
|
||||||
|
}
|
||||||
|
if (target != OrbisMsgDialogProgressBarTarget::DEFAULT) {
|
||||||
|
return Error::PARAM_INVALID;
|
||||||
|
}
|
||||||
|
g_msg_dialog_ui.SetProgressBarValue(delta, true);
|
||||||
|
return Error::OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
int PS4_SYSV_ABI sceMsgDialogProgressBarSetMsg() {
|
Error PS4_SYSV_ABI sceMsgDialogProgressBarSetMsg(OrbisMsgDialogProgressBarTarget target,
|
||||||
LOG_ERROR(Lib_MsgDlg, "(STUBBED) called");
|
const char* msg) {
|
||||||
return ORBIS_OK;
|
if (g_status != Status::RUNNING) {
|
||||||
|
return Error::NOT_RUNNING;
|
||||||
|
}
|
||||||
|
if (g_param.mode != MsgDialogMode::PROGRESS_BAR) {
|
||||||
|
return Error::NOT_SUPPORTED;
|
||||||
|
}
|
||||||
|
if (target != OrbisMsgDialogProgressBarTarget::DEFAULT) {
|
||||||
|
return Error::PARAM_INVALID;
|
||||||
|
}
|
||||||
|
g_param.progBarParam->msg = msg;
|
||||||
|
return Error::OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
int PS4_SYSV_ABI sceMsgDialogProgressBarSetValue() {
|
Error PS4_SYSV_ABI sceMsgDialogProgressBarSetValue(OrbisMsgDialogProgressBarTarget target,
|
||||||
LOG_ERROR(Lib_MsgDlg, "(STUBBED) called");
|
u32 value) {
|
||||||
return ORBIS_OK;
|
if (g_status != Status::RUNNING) {
|
||||||
|
return Error::NOT_RUNNING;
|
||||||
|
}
|
||||||
|
if (g_param.mode != MsgDialogMode::PROGRESS_BAR) {
|
||||||
|
return Error::NOT_SUPPORTED;
|
||||||
|
}
|
||||||
|
if (target != OrbisMsgDialogProgressBarTarget::DEFAULT) {
|
||||||
|
return Error::PARAM_INVALID;
|
||||||
|
}
|
||||||
|
g_msg_dialog_ui.SetProgressBarValue(value, false);
|
||||||
|
return Error::OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
Error PS4_SYSV_ABI sceMsgDialogTerminate() {
|
Error PS4_SYSV_ABI sceMsgDialogTerminate() {
|
||||||
|
@ -56,6 +56,10 @@ enum class SystemMessageType : u32 {
|
|||||||
WARNING_PROFILE_PICTURE_AND_NAME_NOT_SHARED = 5,
|
WARNING_PROFILE_PICTURE_AND_NAME_NOT_SHARED = 5,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum class OrbisMsgDialogProgressBarTarget : u32 {
|
||||||
|
DEFAULT = 0,
|
||||||
|
};
|
||||||
|
|
||||||
struct ButtonsParam {
|
struct ButtonsParam {
|
||||||
const char* msg1{};
|
const char* msg1{};
|
||||||
const char* msg2{};
|
const char* msg2{};
|
||||||
@ -107,6 +111,7 @@ class MsgDialogUi final : public ImGui::Layer {
|
|||||||
const Param* param{};
|
const Param* param{};
|
||||||
CommonDialog::Status* status{};
|
CommonDialog::Status* status{};
|
||||||
MsgDialogResult* result{};
|
MsgDialogResult* result{};
|
||||||
|
u32 progress_bar_value{};
|
||||||
|
|
||||||
void DrawUser();
|
void DrawUser();
|
||||||
void DrawProgressBar();
|
void DrawProgressBar();
|
||||||
@ -120,7 +125,9 @@ public:
|
|||||||
MsgDialogUi(MsgDialogUi&& other) noexcept;
|
MsgDialogUi(MsgDialogUi&& other) noexcept;
|
||||||
MsgDialogUi& operator=(MsgDialogUi other);
|
MsgDialogUi& operator=(MsgDialogUi other);
|
||||||
|
|
||||||
void Finish(ButtonId buttonId);
|
void Finish(ButtonId buttonId, CommonDialog::Result r = CommonDialog::Result::OK);
|
||||||
|
|
||||||
|
void SetProgressBarValue(u32 value, bool increment);
|
||||||
|
|
||||||
void Draw() override;
|
void Draw() override;
|
||||||
|
|
||||||
@ -134,9 +141,12 @@ CommonDialog::Error PS4_SYSV_ABI sceMsgDialogGetResult(MsgDialogResult* result);
|
|||||||
CommonDialog::Status PS4_SYSV_ABI sceMsgDialogGetStatus();
|
CommonDialog::Status PS4_SYSV_ABI sceMsgDialogGetStatus();
|
||||||
CommonDialog::Error PS4_SYSV_ABI sceMsgDialogInitialize();
|
CommonDialog::Error PS4_SYSV_ABI sceMsgDialogInitialize();
|
||||||
CommonDialog::Error PS4_SYSV_ABI sceMsgDialogOpen(const Param* param);
|
CommonDialog::Error PS4_SYSV_ABI sceMsgDialogOpen(const Param* param);
|
||||||
int PS4_SYSV_ABI sceMsgDialogProgressBarInc();
|
CommonDialog::Error PS4_SYSV_ABI sceMsgDialogProgressBarInc(OrbisMsgDialogProgressBarTarget,
|
||||||
int PS4_SYSV_ABI sceMsgDialogProgressBarSetMsg();
|
u32 delta);
|
||||||
int PS4_SYSV_ABI sceMsgDialogProgressBarSetValue();
|
CommonDialog::Error PS4_SYSV_ABI sceMsgDialogProgressBarSetMsg(OrbisMsgDialogProgressBarTarget,
|
||||||
|
const char* msg);
|
||||||
|
CommonDialog::Error PS4_SYSV_ABI sceMsgDialogProgressBarSetValue(OrbisMsgDialogProgressBarTarget,
|
||||||
|
u32 value);
|
||||||
CommonDialog::Error PS4_SYSV_ABI sceMsgDialogTerminate();
|
CommonDialog::Error PS4_SYSV_ABI sceMsgDialogTerminate();
|
||||||
CommonDialog::Status PS4_SYSV_ABI sceMsgDialogUpdateStatus();
|
CommonDialog::Status PS4_SYSV_ABI sceMsgDialogUpdateStatus();
|
||||||
|
|
||||||
|
@ -12,6 +12,7 @@ using namespace Libraries::CommonDialog;
|
|||||||
using namespace Libraries::MsgDialog;
|
using namespace Libraries::MsgDialog;
|
||||||
|
|
||||||
static constexpr ImVec2 BUTTON_SIZE{100.0f, 30.0f};
|
static constexpr ImVec2 BUTTON_SIZE{100.0f, 30.0f};
|
||||||
|
static constexpr float PROGRESS_BAR_WIDTH{0.8f};
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
int count = 0;
|
int count = 0;
|
||||||
@ -62,7 +63,16 @@ void MsgDialogUi::DrawUser() {
|
|||||||
if (count == 2) {
|
if (count == 2) {
|
||||||
PushID(2);
|
PushID(2);
|
||||||
if (Button(text2, BUTTON_SIZE)) {
|
if (Button(text2, BUTTON_SIZE)) {
|
||||||
Finish(ButtonId::BUTTON2);
|
switch (button_type) {
|
||||||
|
case ButtonType::OK_CANCEL:
|
||||||
|
case ButtonType::WAIT_CANCEL:
|
||||||
|
case ButtonType::OK_CANCEL_FOCUS_CANCEL:
|
||||||
|
Finish(ButtonId::INVALID, Result::USER_CANCELED);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
Finish(ButtonId::BUTTON2);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (!focus_first) {
|
if (!focus_first) {
|
||||||
SetItemDefaultNav();
|
SetItemDefaultNav();
|
||||||
@ -83,7 +93,29 @@ void MsgDialogUi::DrawUser() {
|
|||||||
EndGroup();
|
EndGroup();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MsgDialogUi::DrawProgressBar() {}
|
void MsgDialogUi::DrawProgressBar() {
|
||||||
|
const auto& [bar_type, msg, _] = *param->progBarParam;
|
||||||
|
DrawCenteredText(msg);
|
||||||
|
const auto ws = GetWindowSize();
|
||||||
|
SetCursorPos({
|
||||||
|
ws.x * ((1 - PROGRESS_BAR_WIDTH) / 2.0f),
|
||||||
|
ws.y - 10.0f - BUTTON_SIZE.y,
|
||||||
|
});
|
||||||
|
bool has_cancel = bar_type == ProgressBarType::PERCENTAGE_CANCEL;
|
||||||
|
float bar_width = PROGRESS_BAR_WIDTH * ws.x;
|
||||||
|
if (has_cancel) {
|
||||||
|
bar_width -= BUTTON_SIZE.x - 10.0f;
|
||||||
|
}
|
||||||
|
BeginGroup();
|
||||||
|
ProgressBar((float)progress_bar_value / 100.0f, {bar_width, BUTTON_SIZE.y});
|
||||||
|
if (has_cancel) {
|
||||||
|
SameLine();
|
||||||
|
if (Button("Cancel", BUTTON_SIZE)) {
|
||||||
|
Finish(ButtonId::INVALID, Result::USER_CANCELED);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
EndGroup();
|
||||||
|
}
|
||||||
|
|
||||||
void MsgDialogUi::DrawSystemMessage() {}
|
void MsgDialogUi::DrawSystemMessage() {}
|
||||||
|
|
||||||
@ -120,8 +152,9 @@ MsgDialogUi& MsgDialogUi::operator=(MsgDialogUi other) {
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MsgDialogUi::Finish(ButtonId buttonId) {
|
void MsgDialogUi::Finish(ButtonId buttonId, Result r) {
|
||||||
if (result) {
|
if (result) {
|
||||||
|
result->result = r;
|
||||||
result->buttonId = buttonId;
|
result->buttonId = buttonId;
|
||||||
}
|
}
|
||||||
if (status) {
|
if (status) {
|
||||||
@ -133,6 +166,14 @@ void MsgDialogUi::Finish(ButtonId buttonId) {
|
|||||||
RemoveLayer(this);
|
RemoveLayer(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MsgDialogUi::SetProgressBarValue(u32 value, bool increment) {
|
||||||
|
if (increment) {
|
||||||
|
progress_bar_value += value;
|
||||||
|
} else {
|
||||||
|
progress_bar_value = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void MsgDialogUi::Draw() {
|
void MsgDialogUi::Draw() {
|
||||||
if (status == nullptr || *status != Status::RUNNING) {
|
if (status == nullptr || *status != Status::RUNNING) {
|
||||||
return;
|
return;
|
||||||
|
Loading…
Reference in New Issue
Block a user