mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-04-21 20:14:45 +00:00
system/MsgDialog: Progress bar dialog
This commit is contained in:
parent
ad57ab8fee
commit
6fdfde7649
3 changed files with 96 additions and 16 deletions
|
@ -82,19 +82,48 @@ Error PS4_SYSV_ABI sceMsgDialogOpen(const Param* param) {
|
|||
return Error::OK;
|
||||
}
|
||||
|
||||
int PS4_SYSV_ABI sceMsgDialogProgressBarInc() {
|
||||
LOG_ERROR(Lib_MsgDlg, "(STUBBED) called");
|
||||
return ORBIS_OK;
|
||||
Error PS4_SYSV_ABI sceMsgDialogProgressBarInc(OrbisMsgDialogProgressBarTarget target, u32 delta) {
|
||||
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(delta, true);
|
||||
return Error::OK;
|
||||
}
|
||||
|
||||
int PS4_SYSV_ABI sceMsgDialogProgressBarSetMsg() {
|
||||
LOG_ERROR(Lib_MsgDlg, "(STUBBED) called");
|
||||
return ORBIS_OK;
|
||||
Error PS4_SYSV_ABI sceMsgDialogProgressBarSetMsg(OrbisMsgDialogProgressBarTarget target,
|
||||
const char* msg) {
|
||||
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() {
|
||||
LOG_ERROR(Lib_MsgDlg, "(STUBBED) called");
|
||||
return ORBIS_OK;
|
||||
Error PS4_SYSV_ABI sceMsgDialogProgressBarSetValue(OrbisMsgDialogProgressBarTarget target,
|
||||
u32 value) {
|
||||
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() {
|
||||
|
|
|
@ -56,6 +56,10 @@ enum class SystemMessageType : u32 {
|
|||
WARNING_PROFILE_PICTURE_AND_NAME_NOT_SHARED = 5,
|
||||
};
|
||||
|
||||
enum class OrbisMsgDialogProgressBarTarget : u32 {
|
||||
DEFAULT = 0,
|
||||
};
|
||||
|
||||
struct ButtonsParam {
|
||||
const char* msg1{};
|
||||
const char* msg2{};
|
||||
|
@ -107,6 +111,7 @@ class MsgDialogUi final : public ImGui::Layer {
|
|||
const Param* param{};
|
||||
CommonDialog::Status* status{};
|
||||
MsgDialogResult* result{};
|
||||
u32 progress_bar_value{};
|
||||
|
||||
void DrawUser();
|
||||
void DrawProgressBar();
|
||||
|
@ -120,7 +125,9 @@ public:
|
|||
MsgDialogUi(MsgDialogUi&& other) noexcept;
|
||||
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;
|
||||
|
||||
|
@ -134,9 +141,12 @@ CommonDialog::Error PS4_SYSV_ABI sceMsgDialogGetResult(MsgDialogResult* result);
|
|||
CommonDialog::Status PS4_SYSV_ABI sceMsgDialogGetStatus();
|
||||
CommonDialog::Error PS4_SYSV_ABI sceMsgDialogInitialize();
|
||||
CommonDialog::Error PS4_SYSV_ABI sceMsgDialogOpen(const Param* param);
|
||||
int PS4_SYSV_ABI sceMsgDialogProgressBarInc();
|
||||
int PS4_SYSV_ABI sceMsgDialogProgressBarSetMsg();
|
||||
int PS4_SYSV_ABI sceMsgDialogProgressBarSetValue();
|
||||
CommonDialog::Error PS4_SYSV_ABI sceMsgDialogProgressBarInc(OrbisMsgDialogProgressBarTarget,
|
||||
u32 delta);
|
||||
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::Status PS4_SYSV_ABI sceMsgDialogUpdateStatus();
|
||||
|
||||
|
|
|
@ -12,6 +12,7 @@ using namespace Libraries::CommonDialog;
|
|||
using namespace Libraries::MsgDialog;
|
||||
|
||||
static constexpr ImVec2 BUTTON_SIZE{100.0f, 30.0f};
|
||||
static constexpr float PROGRESS_BAR_WIDTH{0.8f};
|
||||
|
||||
struct {
|
||||
int count = 0;
|
||||
|
@ -62,7 +63,16 @@ void MsgDialogUi::DrawUser() {
|
|||
if (count == 2) {
|
||||
PushID(2);
|
||||
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) {
|
||||
SetItemDefaultNav();
|
||||
|
@ -83,7 +93,29 @@ void MsgDialogUi::DrawUser() {
|
|||
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() {}
|
||||
|
||||
|
@ -120,8 +152,9 @@ MsgDialogUi& MsgDialogUi::operator=(MsgDialogUi other) {
|
|||
return *this;
|
||||
}
|
||||
|
||||
void MsgDialogUi::Finish(ButtonId buttonId) {
|
||||
void MsgDialogUi::Finish(ButtonId buttonId, Result r) {
|
||||
if (result) {
|
||||
result->result = r;
|
||||
result->buttonId = buttonId;
|
||||
}
|
||||
if (status) {
|
||||
|
@ -133,6 +166,14 @@ void MsgDialogUi::Finish(ButtonId buttonId) {
|
|||
RemoveLayer(this);
|
||||
}
|
||||
|
||||
void MsgDialogUi::SetProgressBarValue(u32 value, bool increment) {
|
||||
if (increment) {
|
||||
progress_bar_value += value;
|
||||
} else {
|
||||
progress_bar_value = value;
|
||||
}
|
||||
}
|
||||
|
||||
void MsgDialogUi::Draw() {
|
||||
if (status == nullptr || *status != Status::RUNNING) {
|
||||
return;
|
||||
|
|
Loading…
Add table
Reference in a new issue