MCPcopy Create free account
hub / github.com/OpenDUNE/OpenDUNE / GUI_DisplayModalMessage

Function GUI_DisplayModalMessage

src/gui/gui.c:775–864  ·  view source on GitHub ↗

* Displays a message and waits for a user action. * @param str The text to display. * @param spriteID The sprite to draw (0xFFFF for none). * @param ... The args for the text. * @return ?? */

Source from the content-addressed store, hash-verified

773 * @return ??
774 */
775uint16 GUI_DisplayModalMessage(const char *str, unsigned int spriteID, ...)
776{
777 static char textBuffer[768];
778
779 va_list ap;
780 uint16 oldWidgetId;
781 uint16 ret;
782 Screen oldScreenID;
783 uint8 *screenBackup = NULL;
784
785 va_start(ap, spriteID);
786 vsnprintf(textBuffer, sizeof(textBuffer), str, ap);
787 va_end(ap);
788
789 GUI_Mouse_Hide_Safe();
790
791 oldScreenID = GFX_Screen_SetActive(SCREEN_0);
792
793 GUI_DrawText_Wrapper(NULL, 0, 0, 0, 0, 0x22);
794
795 oldWidgetId = Widget_SetCurrentWidget(1);
796
797 g_widgetProperties[1].height = g_fontCurrent->height * max(GUI_SplitText(textBuffer, ((g_curWidgetWidth - ((spriteID == 0xFFFF) ? 2 : 7)) << 3) - 6, '\r'), 3) + 18;
798
799 Widget_SetCurrentWidget(1);
800
801 screenBackup = malloc(GFX_GetSize(g_curWidgetWidth * 8, g_curWidgetHeight));
802
803 if (screenBackup != NULL) {
804 GFX_CopyToBuffer(g_curWidgetXBase * 8, g_curWidgetYBase, g_curWidgetWidth * 8, g_curWidgetHeight, screenBackup);
805 }
806
807 GUI_Widget_DrawBorder(1, 1, 1);
808
809 if (spriteID != 0xFFFF) {
810 GUI_DrawSprite(SCREEN_ACTIVE, g_sprites[spriteID], 7, 8, 1, DRAWSPRITE_FLAG_WIDGETPOS);
811 GUI_Widget_SetProperties(1, g_curWidgetXBase + 5, g_curWidgetYBase + 8, g_curWidgetWidth - 7, g_curWidgetHeight - 16);
812 } else {
813 GUI_Widget_SetProperties(1, g_curWidgetXBase + 1, g_curWidgetYBase + 8, g_curWidgetWidth - 2, g_curWidgetHeight - 16);
814 }
815
816 g_curWidgetFGColourNormal = 0;
817
818 GUI_DrawText(textBuffer, g_curWidgetXBase << 3, g_curWidgetYBase, g_curWidgetFGColourBlink, g_curWidgetFGColourNormal);
819
820 GFX_SetPalette(g_palette1);
821
822 GUI_Mouse_Show_Safe();
823
824 for (g_timerTimeout = 30; g_timerTimeout != 0; sleepIdle()) {
825 GUI_PaletteAnimate();
826 }
827
828 Input_History_Clear();
829
830 do {
831 GUI_PaletteAnimate();
832

Callers 6

Load_MainFunction · 0.85
GameLoop_LevelEndFunction · 0.85
Game_LoadScenarioFunction · 0.85
GUI_DisplayHintFunction · 0.85

Calls 15

vsnprintfFunction · 0.85
GUI_Mouse_Hide_SafeFunction · 0.85
GFX_Screen_SetActiveFunction · 0.85
GUI_DrawText_WrapperFunction · 0.85
Widget_SetCurrentWidgetFunction · 0.85
GUI_SplitTextFunction · 0.85
GFX_GetSizeFunction · 0.85
GFX_CopyToBufferFunction · 0.85
GUI_Widget_DrawBorderFunction · 0.85
GUI_DrawSpriteFunction · 0.85
GUI_Widget_SetPropertiesFunction · 0.85
GUI_DrawTextFunction · 0.85

Tested by

no test coverage detected