コード例 #1
0
ファイル: Cv_SDL.cs プロジェクト: jocamar/Caravel
        public static unsafe int SDL_ShowMessageBox([In()] ref SDL_MessageBoxData messageboxdata, out int buttonid)
        {
            var data = new INTERNAL_SDL_MessageBoxData()
            {
                flags      = messageboxdata.flags,
                window     = messageboxdata.window,
                title      = INTERNAL_AllocUTF8(messageboxdata.title),
                message    = INTERNAL_AllocUTF8(messageboxdata.message),
                numbuttons = messageboxdata.numbuttons,
            };

            var buttons = new INTERNAL_SDL_MessageBoxButtonData[messageboxdata.numbuttons];

            for (int i = 0; i < messageboxdata.numbuttons; i++)
            {
                buttons[i] = new INTERNAL_SDL_MessageBoxButtonData()
                {
                    flags    = messageboxdata.buttons[i].flags,
                    buttonid = messageboxdata.buttons[i].buttonid,
                    text     = INTERNAL_AllocUTF8(messageboxdata.buttons[i].text),
                };
            }

            if (messageboxdata.colorScheme != null)
            {
                data.colorScheme = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(SDL_MessageBoxColorScheme)));
                Marshal.StructureToPtr(messageboxdata.colorScheme.Value, data.colorScheme, false);
            }

            int result;

            fixed(INTERNAL_SDL_MessageBoxButtonData *buttonsPtr = &buttons[0])
            {
                data.buttons = (IntPtr)buttonsPtr;
                result       = INTERNAL_SDL_ShowMessageBox(ref data, out buttonid);
            }

            Marshal.FreeHGlobal(data.colorScheme);
            for (int i = 0; i < messageboxdata.numbuttons; i++)
            {
                SDL_free(buttons[i].text);
            }
            SDL_free(data.message);
            SDL_free(data.title);

            return(result);
        }
コード例 #2
0
        public unsafe int Show()
        {
            SDL_MessageBoxData boxdata = new SDL_MessageBoxData();

            if (this.IconType == 1)
            {
                boxdata.flags = SDL_MessageBoxFlags.SDL_MESSAGEBOX_INFORMATION;
            }
            else if (this.IconType == 2)
            {
                boxdata.flags = SDL_MessageBoxFlags.SDL_MESSAGEBOX_WARNING;
            }
            else if (this.IconType == 3)
            {
                boxdata.flags = SDL_MessageBoxFlags.SDL_MESSAGEBOX_ERROR;
            }
            SDL_MessageBoxButtonData[] buttons = new SDL_MessageBoxButtonData[Buttons.Count];
            for (int i = 0; i < Buttons.Count; i++)
            {
                buttons[i]          = new SDL_MessageBoxButtonData();
                buttons[i].text     = StrToPtr(Buttons[i]);
                buttons[i].buttonid = 0;
                if (i == 0)
                {
                    buttons[i].flags = SDL_MessageBoxButtonFlags.SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT;
                }
                else if (i == Buttons.Count - 1)
                {
                    buttons[i].flags = SDL_MessageBoxButtonFlags.SDL_MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT;
                }
            }
            boxdata.message    = this.Message;
            boxdata.numbuttons = Buttons.Count;
            boxdata.title      = this.Title;
            boxdata.window     = this.Parent == null ? IntPtr.Zero : this.Parent.SDL_Window;
            int result = -1;

            fixed(SDL_MessageBoxButtonData *buttonptr = &buttons[0])
            {
                boxdata.buttons = (IntPtr)buttonptr;
            }

            SDL_ShowMessageBox(ref boxdata, out result);
            return(result);
        }
コード例 #3
0
        public bool DisplayErrorAppletDialog(string title, string message, string[] buttonsText)
        {
            SDL_MessageBoxData data = new SDL_MessageBoxData
            {
                title      = title,
                message    = message,
                buttons    = new SDL_MessageBoxButtonData[buttonsText.Length],
                numbuttons = buttonsText.Length,
                window     = WindowHandle
            };

            for (int i = 0; i < buttonsText.Length; i++)
            {
                data.buttons[i] = new SDL_MessageBoxButtonData
                {
                    buttonid = i,
                    text     = buttonsText[i]
                };
            }

            SDL_ShowMessageBox(ref data, out int _);

            return(true);
        }
コード例 #4
0
ファイル: SDL_messagebox.cs プロジェクト: bugbit/juegecitos
 public static int SDL_ShowMessageBox(ref SDL_MessageBoxData messageboxdata, ref int buttonid) => s_SDL_ShowMessageBox_SDL_MessageBoxData_int_t(ref messageboxdata, ref buttonid);