Atlas - SDL_vitamessagebox.c

Home / ext / SDL / src / video / vita Lines: 3 | Size: 4432 bytes [Download] [Show on GitHub] [Search similar files] [Raw] [Raw (proxy)]
[FILE BEGIN]
1/* 2 Simple DirectMedia Layer 3 Copyright (C) 1997-2025 Sam Lantinga <[email protected]> 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 33bool 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(&param); 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(&param); 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(&param); 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 126
[FILE END]
(C) 2025 0x4248 (C) 2025 4248 Media and 4248 Systems, All part of 0x4248 See LICENCE files for more information. Not all files are by 0x4248 always check Licencing.