/** * Draw a text button widget to the display, relative to its parent. * * @param w The widget (which is a button) to draw. */ void GUI_Widget_TextButton_Draw(Widget *w) { Screen oldScreenID; uint16 positionX, positionY; uint16 width, height; uint16 state; uint8 colour; if (w == NULL) return; oldScreenID = GFX_Screen_SetActive(SCREEN_1); positionX = w->offsetX + (g_widgetProperties[w->parentID].xBase << 3); positionY = w->offsetY + g_widgetProperties[w->parentID].yBase; width = w->width; height = w->height; g_widgetProperties[19].xBase = positionX >> 3; g_widgetProperties[19].yBase = positionY; g_widgetProperties[19].width = width >> 3; g_widgetProperties[19].height = height; state = (w->state.s.selected) ? 0 : 2; colour = (w->state.s.hover2) ? 231 : 232; GUI_Widget_DrawBorder(19, state, 1); if (w->stringID == STR_CANCEL || w->stringID == STR_PREVIOUS || w->stringID == STR_YES || w->stringID == STR_NO) { GUI_DrawText_Wrapper(GUI_String_Get_ByIndex(w->stringID), positionX + (width / 2), positionY + 2, colour, 0, 0x122); } else { GUI_DrawText_Wrapper(GUI_String_Get_ByIndex(w->stringID), positionX + 3, positionY + 2, colour, 0, 0x22); } if (oldScreenID == SCREEN_0) { GUI_Mouse_Hide_InRegion(positionX, positionY, positionX + width, positionY + height); GUI_Screen_Copy(positionX >> 3, positionY, positionX >> 3, positionY, width >> 3, height, SCREEN_1, SCREEN_0); GUI_Mouse_Show_InRegion(); }
/** * Intro menu. */ static void GameLoop_GameIntroAnimationMenu(void) { static const uint16 mainMenuStrings[][6] = { {STR_PLAY_A_GAME, STR_REPLAY_INTRODUCTION, STR_EXIT_GAME, STR_NULL, STR_NULL, STR_NULL}, /* Neither HOF nor save. */ {STR_PLAY_A_GAME, STR_REPLAY_INTRODUCTION, STR_LOAD_GAME, STR_EXIT_GAME, STR_NULL, STR_NULL}, /* Has a save game. */ {STR_PLAY_A_GAME, STR_REPLAY_INTRODUCTION, STR_EXIT_GAME, STR_HALL_OF_FAME, STR_NULL, STR_NULL}, /* Has a HOF. */ {STR_PLAY_A_GAME, STR_REPLAY_INTRODUCTION, STR_LOAD_GAME, STR_EXIT_GAME, STR_HALL_OF_FAME, STR_NULL} /* Has a HOF and a save game. */ }; bool loadGame = false; static bool drawMenu = true; static uint16 stringID = STR_REPLAY_INTRODUCTION; uint16 maxWidth; static bool hasSave = false; static bool hasFame = false; static const char *strings[6]; static uint16 index = 0xFFFF; if (index == 0xFFFF) { hasSave = File_Exists("_save000.dat"); hasFame = File_Exists("SAVEFAME.DAT"); index = (hasFame ? 2 : 0) + (hasSave ? 1 : 0); } if (hasSave || File_Exists("ONETIME.DAT")) g_canSkipIntro = true; switch (stringID) { case STR_REPLAY_INTRODUCTION: Music_Play(0); free(g_readBuffer); g_readBufferSize = (g_enableVoices == 0) ? 12000 : 28000; g_readBuffer = calloc(1, g_readBufferSize); GUI_Mouse_Hide_Safe(); Driver_Music_FadeOut(); GameLoop_GameIntroAnimation(); Sound_Output_Feedback(0xFFFE); File_ReadBlockFile("IBM.PAL", g_palette_998A, 256 * 3); memmove(g_palette1, g_palette_998A, 256 * 3); if (!g_canSkipIntro) { File_Create("ONETIME.DAT"); g_canSkipIntro = true; } Music_Play(0); free(g_readBuffer); g_readBufferSize = (g_enableVoices == 0) ? 12000 : 20000; g_readBuffer = calloc(1, g_readBufferSize); GUI_Mouse_Show_Safe(); Music_Play(28); drawMenu = true; break; case STR_EXIT_GAME: g_running = false; return; case STR_HALL_OF_FAME: GUI_HallOfFame_Show(0xFFFF); GFX_SetPalette(g_palette2); hasFame = File_Exists("SAVEFAME.DAT"); drawMenu = true; break; case STR_LOAD_GAME: GUI_Mouse_Hide_Safe(); GUI_SetPaletteAnimated(g_palette2, 30); GUI_ClearScreen(SCREEN_0); GUI_Mouse_Show_Safe(); GFX_SetPalette(g_palette1); if (GUI_Widget_SaveLoad_Click(false)) { loadGame = true; if (g_gameMode == GM_RESTART) break; g_gameMode = GM_NORMAL; } else { GFX_SetPalette(g_palette2); drawMenu = true; } break; default: break; } if (drawMenu) { uint16 i; g_widgetProperties[21].height = 0; for (i = 0; i < 6; i++) { strings[i] = NULL; if (mainMenuStrings[index][i] == 0) { if (g_widgetProperties[21].height == 0) g_widgetProperties[21].height = i; continue; } strings[i] = String_Get_ByIndex(mainMenuStrings[index][i]); } GUI_DrawText_Wrapper(NULL, 0, 0, 0, 0, 0x22); maxWidth = 0; for (i = 0; i < g_widgetProperties[21].height; i++) { if (Font_GetStringWidth(strings[i]) <= maxWidth) continue; maxWidth = Font_GetStringWidth(strings[i]); } maxWidth += 7; g_widgetProperties[21].width = maxWidth >> 3; g_widgetProperties[13].width = g_widgetProperties[21].width + 2; g_widgetProperties[13].xBase = 19 - (maxWidth >> 4); g_widgetProperties[13].yBase = 160 - ((g_widgetProperties[21].height * g_fontCurrent->height) >> 1); g_widgetProperties[13].height = (g_widgetProperties[21].height * g_fontCurrent->height) + 11; Sprites_LoadImage(String_GenerateFilename("TITLE"), SCREEN_1, NULL); GUI_Mouse_Hide_Safe(); GUI_ClearScreen(SCREEN_0); GUI_Screen_Copy(0, 0, 0, 0, SCREEN_WIDTH / 8, SCREEN_HEIGHT, SCREEN_1, SCREEN_0); GUI_SetPaletteAnimated(g_palette1, 30); GUI_DrawText_Wrapper("V1.07", 319, 192, 133, 0, 0x231, 0x39); GUI_DrawText_Wrapper(NULL, 0, 0, 0, 0, 0x22); Widget_SetCurrentWidget(13); GUI_Widget_DrawBorder(13, 2, 1); GameLoop_DrawMenu(strings); GUI_Mouse_Show_Safe(); drawMenu = false; } if (loadGame) return; stringID = GameLoop_HandleEvents(strings); if (stringID != 0xFFFF) stringID = mainMenuStrings[index][stringID]; GUI_PaletteAnimate(); if (stringID == STR_PLAY_A_GAME) g_gameMode = GM_PICKHOUSE; }
static void GUI_Window_Create(WindowDesc *desc) { uint8 i; if (desc == NULL) return; g_widgetLinkedListTail = NULL; GFX_Screen_SetActive(SCREEN_1); Widget_SetCurrentWidget(desc->index); GUI_Widget_DrawBorder(g_curWidgetIndex, 2, true); if (GUI_String_Get_ByIndex(desc->stringID) != NULL) { GUI_DrawText_Wrapper(GUI_String_Get_ByIndex(desc->stringID), (g_curWidgetXBase << 3) + (g_curWidgetWidth << 2), g_curWidgetYBase + 6 + ((desc == &g_yesNoWindowDesc) ? 2 : 0), 238, 0, 0x122); } if (GUI_String_Get_ByIndex(desc->widgets[0].stringID) == NULL) { GUI_DrawText_Wrapper(String_Get_ByIndex(STR_THERE_ARE_NO_SAVED_GAMES_TO_LOAD), (g_curWidgetXBase + 2) << 3, g_curWidgetYBase + 42, 232, 0, 0x22); } for (i = 0; i < desc->widgetCount; i++) { Widget *w = &g_table_windowWidgets[i]; if (GUI_String_Get_ByIndex(desc->widgets[i].stringID) == NULL) continue; w->next = NULL; w->offsetX = desc->widgets[i].offsetX; w->offsetY = desc->widgets[i].offsetY; w->width = desc->widgets[i].width; w->height = desc->widgets[i].height; w->shortcut = 0; w->shortcut2 = 0; if (desc != &g_savegameNameWindowDesc) { if (desc->widgets[i].labelStringId != STR_NULL) { w->shortcut = GUI_Widget_GetShortcut(*GUI_String_Get_ByIndex(desc->widgets[i].labelStringId)); } else { w->shortcut = GUI_Widget_GetShortcut(*GUI_String_Get_ByIndex(desc->widgets[i].stringID)); } } w->shortcut2 = desc->widgets[i].shortcut2; if (w->shortcut == 0x1B) { w->shortcut2 = 0x13; } w->stringID = desc->widgets[i].stringID; w->drawModeNormal = DRAW_MODE_CUSTOM_PROC; w->drawModeSelected = DRAW_MODE_CUSTOM_PROC; w->drawModeDown = DRAW_MODE_CUSTOM_PROC; w->drawParameterNormal.proc = &GUI_Widget_TextButton_Draw; w->drawParameterSelected.proc = &GUI_Widget_TextButton_Draw; w->drawParameterDown.proc = &GUI_Widget_TextButton_Draw; w->parentID = desc->index; memset(&w->state, 0, sizeof(w->state)); g_widgetLinkedListTail = GUI_Widget_Link(g_widgetLinkedListTail, w); GUI_Widget_MakeVisible(w); GUI_Widget_MakeNormal(w, false); GUI_Widget_Draw(w); if (desc->widgets[i].labelStringId == STR_NULL) continue; if (g_config.language == LANGUAGE_FRENCH) { GUI_DrawText_Wrapper(GUI_String_Get_ByIndex(desc->widgets[i].labelStringId), (g_widgetProperties[w->parentID].xBase << 3) + 40, w->offsetY + g_widgetProperties[w->parentID].yBase + 3, 232, 0, 0x22); } else { GUI_DrawText_Wrapper(GUI_String_Get_ByIndex(desc->widgets[i].labelStringId), w->offsetX + (g_widgetProperties[w->parentID].xBase << 3) - 10, w->offsetY + g_widgetProperties[w->parentID].yBase + 3, 232, 0, 0x222); } } if (s_savegameCountOnDisk >= 5 && desc->addArrows) { Widget *w = &g_table_windowWidgets[7]; w->drawParameterNormal.sprite = g_sprites[59]; w->drawParameterSelected.sprite = g_sprites[60]; w->drawParameterDown.sprite = g_sprites[60]; w->next = NULL; w->parentID = desc->index; GUI_Widget_MakeNormal(w, false); GUI_Widget_MakeInvisible(w); GUI_Widget_Undraw(w, 233); g_widgetLinkedListTail = GUI_Widget_Link(g_widgetLinkedListTail, w); w = &g_table_windowWidgets[8]; w->drawParameterNormal.sprite = g_sprites[61]; w->drawParameterSelected.sprite = g_sprites[62]; w->drawParameterDown.sprite = g_sprites[62]; w->next = NULL; w->parentID = desc->index; GUI_Widget_MakeNormal(w, false); GUI_Widget_MakeInvisible(w); GUI_Widget_Undraw(w, 233); g_widgetLinkedListTail = GUI_Widget_Link(g_widgetLinkedListTail, w); } GUI_Mouse_Hide_Safe(); Widget_SetCurrentWidget(desc->index); GUI_Screen_Copy(g_curWidgetXBase, g_curWidgetYBase, g_curWidgetXBase, g_curWidgetYBase, g_curWidgetWidth, g_curWidgetHeight, SCREEN_1, SCREEN_0); GUI_Mouse_Show_Safe(); GFX_Screen_SetActive(SCREEN_0); }