diff options
| author | 3gg <3gg@shellblade.net> | 2025-12-27 12:03:39 -0800 |
|---|---|---|
| committer | 3gg <3gg@shellblade.net> | 2025-12-27 12:03:39 -0800 |
| commit | 5a079a2d114f96d4847d1ee305d5b7c16eeec50e (patch) | |
| tree | 8926ab44f168acf787d8e19608857b3af0f82758 /contrib/SDL-3.2.8/src/video/vita/SDL_vitamessagebox.c | |
Initial commit
Diffstat (limited to 'contrib/SDL-3.2.8/src/video/vita/SDL_vitamessagebox.c')
| -rw-r--r-- | contrib/SDL-3.2.8/src/video/vita/SDL_vitamessagebox.c | 125 |
1 files changed, 125 insertions, 0 deletions
diff --git a/contrib/SDL-3.2.8/src/video/vita/SDL_vitamessagebox.c b/contrib/SDL-3.2.8/src/video/vita/SDL_vitamessagebox.c new file mode 100644 index 0000000..a63e156 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/vita/SDL_vitamessagebox.c | |||
| @@ -0,0 +1,125 @@ | |||
| 1 | /* | ||
| 2 | Simple DirectMedia Layer | ||
| 3 | Copyright (C) 1997-2025 Sam Lantinga <slouken@libsdl.org> | ||
| 4 | |||
| 5 | This software is provided 'as-is', without any express or implied | ||
| 6 | warranty. In no event will the authors be held liable for any damages | ||
| 7 | arising from the use of this software. | ||
| 8 | |||
| 9 | Permission is granted to anyone to use this software for any purpose, | ||
| 10 | including commercial applications, and to alter it and redistribute it | ||
| 11 | freely, subject to the following restrictions: | ||
| 12 | |||
| 13 | 1. The origin of this software must not be misrepresented; you must not | ||
| 14 | claim that you wrote the original software. If you use this software | ||
| 15 | in a product, an acknowledgment in the product documentation would be | ||
| 16 | appreciated but is not required. | ||
| 17 | 2. Altered source versions must be plainly marked as such, and must not be | ||
| 18 | misrepresented as being the original software. | ||
| 19 | 3. This notice may not be removed or altered from any source distribution. | ||
| 20 | */ | ||
| 21 | #include "SDL_internal.h" | ||
| 22 | |||
| 23 | #ifdef SDL_VIDEO_DRIVER_VITA | ||
| 24 | |||
| 25 | #include "SDL_vitavideo.h" | ||
| 26 | #include "SDL_vitamessagebox.h" | ||
| 27 | #include <psp2/message_dialog.h> | ||
| 28 | |||
| 29 | #ifdef SDL_VIDEO_RENDER_VITA_GXM | ||
| 30 | #include "../../render/vitagxm/SDL_render_vita_gxm_tools.h" | ||
| 31 | #endif // SDL_VIDEO_RENDER_VITA_GXM | ||
| 32 | |||
| 33 | bool VITA_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonID) | ||
| 34 | { | ||
| 35 | #ifdef SDL_VIDEO_RENDER_VITA_GXM | ||
| 36 | SceMsgDialogParam param; | ||
| 37 | SceMsgDialogUserMessageParam msgParam; | ||
| 38 | SceMsgDialogButtonsParam buttonParam; | ||
| 39 | SceDisplayFrameBuf dispparam; | ||
| 40 | char message[512]; | ||
| 41 | |||
| 42 | SceMsgDialogResult dialog_result; | ||
| 43 | SceCommonDialogErrorCode init_result; | ||
| 44 | bool setup_minimal_gxm = false; | ||
| 45 | |||
| 46 | if (messageboxdata->numbuttons > 3) { | ||
| 47 | return false; | ||
| 48 | } | ||
| 49 | |||
| 50 | SDL_zero(param); | ||
| 51 | sceMsgDialogParamInit(¶m); | ||
| 52 | param.mode = SCE_MSG_DIALOG_MODE_USER_MSG; | ||
| 53 | |||
| 54 | SDL_zero(msgParam); | ||
| 55 | SDL_snprintf(message, sizeof(message), "%s\r\n\r\n%s", messageboxdata->title, messageboxdata->message); | ||
| 56 | |||
| 57 | msgParam.msg = (const SceChar8 *)message; | ||
| 58 | SDL_zero(buttonParam); | ||
| 59 | |||
| 60 | if (messageboxdata->numbuttons == 3) { | ||
| 61 | msgParam.buttonType = SCE_MSG_DIALOG_BUTTON_TYPE_3BUTTONS; | ||
| 62 | msgParam.buttonParam = &buttonParam; | ||
| 63 | buttonParam.msg1 = messageboxdata->buttons[0].text; | ||
| 64 | buttonParam.msg2 = messageboxdata->buttons[1].text; | ||
| 65 | buttonParam.msg3 = messageboxdata->buttons[2].text; | ||
| 66 | } else if (messageboxdata->numbuttons == 2) { | ||
| 67 | msgParam.buttonType = SCE_MSG_DIALOG_BUTTON_TYPE_YESNO; | ||
| 68 | } else if (messageboxdata->numbuttons == 1) { | ||
| 69 | msgParam.buttonType = SCE_MSG_DIALOG_BUTTON_TYPE_OK; | ||
| 70 | } | ||
| 71 | param.userMsgParam = &msgParam; | ||
| 72 | |||
| 73 | dispparam.size = sizeof(dispparam); | ||
| 74 | |||
| 75 | init_result = sceMsgDialogInit(¶m); | ||
| 76 | |||
| 77 | // Setup display if it hasn't been initialized before | ||
| 78 | if (init_result == SCE_COMMON_DIALOG_ERROR_GXM_IS_UNINITIALIZED) { | ||
| 79 | gxm_minimal_init_for_common_dialog(); | ||
| 80 | init_result = sceMsgDialogInit(¶m); | ||
| 81 | setup_minimal_gxm = true; | ||
| 82 | } | ||
| 83 | |||
| 84 | gxm_init_for_common_dialog(); | ||
| 85 | |||
| 86 | if (init_result >= 0) { | ||
| 87 | while (sceMsgDialogGetStatus() == SCE_COMMON_DIALOG_STATUS_RUNNING) { | ||
| 88 | gxm_swap_for_common_dialog(); | ||
| 89 | } | ||
| 90 | SDL_zero(dialog_result); | ||
| 91 | sceMsgDialogGetResult(&dialog_result); | ||
| 92 | |||
| 93 | if (dialog_result.buttonId == SCE_MSG_DIALOG_BUTTON_ID_BUTTON1) { | ||
| 94 | *buttonID = messageboxdata->buttons[0].buttonID; | ||
| 95 | } else if (dialog_result.buttonId == SCE_MSG_DIALOG_BUTTON_ID_BUTTON2) { | ||
| 96 | *buttonID = messageboxdata->buttons[1].buttonID; | ||
| 97 | } else if (dialog_result.buttonId == SCE_MSG_DIALOG_BUTTON_ID_BUTTON3) { | ||
| 98 | *buttonID = messageboxdata->buttons[2].buttonID; | ||
| 99 | } else if (dialog_result.buttonId == SCE_MSG_DIALOG_BUTTON_ID_YES) { | ||
| 100 | *buttonID = messageboxdata->buttons[0].buttonID; | ||
| 101 | } else if (dialog_result.buttonId == SCE_MSG_DIALOG_BUTTON_ID_NO) { | ||
| 102 | *buttonID = messageboxdata->buttons[1].buttonID; | ||
| 103 | } else if (dialog_result.buttonId == SCE_MSG_DIALOG_BUTTON_ID_OK) { | ||
| 104 | *buttonID = messageboxdata->buttons[0].buttonID; | ||
| 105 | } | ||
| 106 | sceMsgDialogTerm(); | ||
| 107 | } else { | ||
| 108 | return false; | ||
| 109 | } | ||
| 110 | |||
| 111 | gxm_term_for_common_dialog(); | ||
| 112 | |||
| 113 | if (setup_minimal_gxm) { | ||
| 114 | gxm_minimal_term_for_common_dialog(); | ||
| 115 | } | ||
| 116 | |||
| 117 | return true; | ||
| 118 | #else | ||
| 119 | (void)messageboxdata; | ||
| 120 | (void)buttonID; | ||
| 121 | return SDL_Unsupported(); | ||
| 122 | #endif // SDL_VIDEO_RENDER_VITA_GXM | ||
| 123 | } | ||
| 124 | |||
| 125 | #endif // SDL_VIDEO_DRIVER_VITA | ||
