static void UpdateArrows(bool save, bool force) { static uint16 previousIndex = 0; Widget *w; if (!force && s_savegameIndexBase == previousIndex) return; previousIndex = s_savegameIndexBase; w = &g_table_windowWidgets[8]; if (s_savegameIndexBase >= 5) { GUI_Widget_MakeVisible(w); } else { GUI_Widget_MakeInvisible(w); GUI_Widget_Undraw(w, 233); } w = &g_table_windowWidgets[7]; if (s_savegameCountOnDisk - (save ? 0 : 1) > s_savegameIndexBase) { GUI_Widget_MakeVisible(w); } else { GUI_Widget_MakeInvisible(w); GUI_Widget_Undraw(w, 233); } }
/** * Handles Click event for the "Build this" button in production window. * * @return True, always. */ bool GUI_Production_BuildThis_Click(Widget *w) { if (g_factoryWindowStarport) { if (g_factoryWindowOrdered == 0) { GUI_Widget_MakeInvisible(w); GUI_Purchase_ShowInvoice(); GUI_Widget_MakeVisible(w); } else { g_factoryWindowResult = FACTORY_BUY; } } else { FactoryWindowItem *item; ObjectInfo *oi; item = GUI_FactoryWindow_GetItem(g_factoryWindowSelected); oi = item->objectInfo; if (oi->available > 0) { item->amount = 1; g_factoryWindowResult = FACTORY_BUY; } } GUI_Widget_MakeNormal(w, false); return true; }
/** * Handles Click event for the "Invoice" button in starport window. * * @return True, always. */ bool GUI_Purchase_Invoice_Click(Widget *w) { GUI_Widget_MakeInvisible(w); GUI_Purchase_ShowInvoice(); GUI_Widget_MakeVisible(w); GUI_Widget_MakeNormal(w, false); return true; }
/** Create the widgets of the mentat help screen. */ void GUI_Mentat_Create_HelpScreen_Widgets(void) { static char empty[2] = ""; uint16 ypos; Widget *w; int i; if (g_widgetMentatScrollbar != NULL) { GUI_Widget_Free_WithScrollbar(g_widgetMentatScrollbar); g_widgetMentatScrollbar = NULL; } free(g_widgetMentatScrollUp); g_widgetMentatScrollUp = NULL; free(g_widgetMentatScrollDown); g_widgetMentatScrollDown = NULL; g_widgetMentatTail = NULL; ypos = 8; w = (Widget *)GFX_Screen_Get_ByIndex(SCREEN_2); memset(w, 0, 13 * sizeof(Widget)); for (i = 0; i < 13; i++) { w->index = i + 2; memset(&w->flags, 0, sizeof(w->flags)); w->flags.buttonFilterLeft = 9; w->flags.buttonFilterRight = 1; w->clickProc = &GUI_Mentat_List_Click; w->drawParameterDown.text = empty; w->drawParameterSelected.text = empty; w->drawParameterNormal.text = empty; w->drawModeNormal = DRAW_MODE_TEXT; memset(&w->state, 0, sizeof(w->state)); w->offsetX = 24; w->offsetY = ypos; w->width = 0x88; w->height = 8; w->parentID = 8; if (g_widgetMentatTail != NULL) { g_widgetMentatTail = GUI_Widget_Link(g_widgetMentatTail, w); } else { g_widgetMentatTail = w; } ypos += 8; w++; } GUI_Widget_MakeInvisible(g_widgetMentatTail); GUI_Widget_MakeInvisible(w - 1); g_widgetMentatScrollbar = GUI_Widget_Allocate_WithScrollbar(15, 8, 168, 24, 8, 72, &GUI_Mentat_ScrollBar_Draw); g_widgetMentatTail = GUI_Widget_Link(g_widgetMentatTail, g_widgetMentatScrollbar); g_widgetMentatScrollDown = GUI_Widget_Allocate3(16, 0, 168, 96, g_sprites[385], g_sprites[386], GUI_Widget_Get_ByIndex(g_widgetMentatTail, 15), 1); g_widgetMentatScrollDown->shortcut = 0; g_widgetMentatScrollDown->shortcut2 = 0; g_widgetMentatScrollDown->parentID = 8; g_widgetMentatTail = GUI_Widget_Link(g_widgetMentatTail, g_widgetMentatScrollDown); g_widgetMentatScrollUp = GUI_Widget_Allocate3(17, 0, 168, 16, g_sprites[383], g_sprites[384], GUI_Widget_Get_ByIndex(g_widgetMentatTail, 15), 0); g_widgetMentatScrollUp->shortcut = 0; g_widgetMentatScrollUp->shortcut2 = 0; g_widgetMentatScrollUp->parentID = 8; g_widgetMentatTail = GUI_Widget_Link(g_widgetMentatTail, g_widgetMentatScrollUp); g_widgetMentatTail = GUI_Widget_Link(g_widgetMentatTail, g_widgetMentatFirst); GUI_Widget_Draw(g_widgetMentatFirst); }
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); }