mirror of
https://github.com/boykopovar/AnyPS5.git
synced 2026-12-05 17:11:09 +00:00
MsgDialog::BuildRequest turns a parsed user message with button type 0, 1, 3 or 4 into a ModalDialogRequest: OK; Yes and No; OK and Cancel; Yes and No with the focus on No. The cancel input picks the last button. Dialogs without a message pointer, in progress bar or system message mode, without buttons or with a button type outside those four are not presented, so their callers keep the automatic answer. The button id of a choice is its index plus one.
49 lines
1.3 KiB
C++
49 lines
1.3 KiB
C++
#ifndef CORE_LIBS_PRX_LIBSCEMSGDIALOG_INCLUDE_MSGDIALOGREQUEST_HPP
|
|
#define CORE_LIBS_PRX_LIBSCEMSGDIALOG_INCLUDE_MSGDIALOGREQUEST_HPP
|
|
|
|
#include <cstddef>
|
|
#include <utility>
|
|
|
|
#include "prx/libSceIme/include/ModalDialog.hpp"
|
|
#include "prx/libSceMsgDialog/include/MsgDialogParam.hpp"
|
|
#include "prx/libSceMsgDialog/include/MsgDialogText.hpp"
|
|
|
|
namespace MsgDialog {
|
|
|
|
inline bool BuildRequest(const ParsedParam& parsed, ModalDialogRequest& request) {
|
|
if (parsed.mode != ModeUserMsg || !parsed.hasUserMessage || !parsed.hasText) return false;
|
|
ModalDialogRequest built;
|
|
switch (parsed.buttonType) {
|
|
case ButtonTypeOk:
|
|
built.buttons = {u"OK"};
|
|
built.cancel = 0;
|
|
break;
|
|
case ButtonTypeYesNo:
|
|
built.buttons = {u"Yes", u"No"};
|
|
built.cancel = 1;
|
|
break;
|
|
case ButtonTypeOkCancel:
|
|
built.buttons = {u"OK", u"Cancel"};
|
|
built.cancel = 1;
|
|
break;
|
|
case ButtonTypeYesNoFocusNo:
|
|
built.buttons = {u"Yes", u"No"};
|
|
built.focus = 1;
|
|
built.cancel = 1;
|
|
break;
|
|
default:
|
|
return false;
|
|
}
|
|
built.message = DecodeUtf8(parsed.text);
|
|
request = std::move(built);
|
|
return true;
|
|
}
|
|
|
|
inline int ButtonIdOf(std::size_t index) {
|
|
return static_cast<int>(index) + 1;
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|