/** * @brief Prints a list of tab and newline separated string to keylist char array that hold the key and the command desc */ static void CLMN_InitKeyList_f (void) { linkedList_t *list = NULL; LIST_AddString(&list, _("^BGlobal bindings")); LIST_AddString(&list, ""); CLMN_AddBindings(&list, keyBindings); LIST_AddString(&list, ""); LIST_AddString(&list, ""); LIST_AddString(&list, _("^BMenu bindings")); LIST_AddString(&list, ""); CLMN_AddBindings(&list, menuKeyBindings); LIST_AddString(&list, ""); LIST_AddString(&list, ""); LIST_AddString(&list, _("^BBattlescape bindings")); LIST_AddString(&list, ""); CLMN_AddBindings(&list, battleKeyBindings); LIST_AddString(&list, ""); LIST_AddString(&list, ""); LIST_AddString(&list, _("^BUI bindings")); LIST_AddString(&list, ""); CLMN_AddUIBindings(&list); UI_RegisterLinkedListText(TEXT_LIST, list); }
/** * @brief Prints a list of tab and newline separated string to keylist char array that hold the key and the command desc */ static void CLMN_InitKeyList_f (void) { linkedList_t *list = NULL; CLMN_AddBindings(&list, keyBindings); CLMN_AddBindings(&list, menuKeyBindings); CLMN_AddBindings(&list, battleKeyBindings); UI_RegisterLinkedListText(TEXT_LIST, list); }
/** * Updates the material editor node for a given image and a given material stage * @param image The image to load into the material editor * @param materialStage The material stage to display */ static void UI_MaterialEditorUpdate (image_t *image, materialStage_t *materialStage) { linkedList_t *materialStagesList = NULL; if (image->normalmap == NULL) UI_ExecuteConfunc("hideshaders true 0 0 0 0"); else UI_ExecuteConfunc("hideshaders false %f %f %f %f", image->material.bump, image->material.hardness, image->material.parallax, image->material.specular); if (image->normalmap == NULL) Cvar_Set("me_imagename", image->name); else Cvar_Set("me_imagename", va("%s (nm)", image->name)); if (!image->material.num_stages) { UI_ExecuteConfunc("hidestages true"); } else { int i; if (materialStage) { const char *stageType = Cvar_GetString("me_stagetype"); if (stageType[0] == '\0') stageType = "stretch"; UI_ExecuteConfunc("hidestages false %s", stageType); } else Cvar_Set("me_stage_id", "-1"); for (i = 0; i < image->material.num_stages; i++) { const materialStage_t *stage = UI_MaterialEditorGetStage(&image->material, i); char stageName[MAX_VAR] = "stage "; if (stage == materialStage) { UI_ExecuteConfunc("updatestagevalues %f %f %f %f %f %f %f %f %f %f %f %f %f %f", stage->rotate.hz, stage->rotate.deg, stage->stretch.hz, stage->stretch.dhz, stage->stretch.amp, stage->stretch.damp, stage->pulse.hz, stage->pulse.dhz, stage->scroll.ds, stage->scroll.dt, stage->scroll.s, stage->scroll.t, stage->scale.s, stage->scale.t); } UI_MaterialEditorStagesToName(stage, stageName, sizeof(stageName) - 1); LIST_AddString(&materialStagesList, stageName); } } UI_RegisterLinkedListText(TEXT_MATERIAL_STAGES, materialStagesList); }
/** * @brief Generates a popup that contains a list of selectable choices. * @param[in] title Title of the popup. * @param[in] headline First line of text written in the popup. * @param[in] entries List of the selectables choices. * @param[in] clickAction Action to perform when one clicked on the popup. */ uiNode_t *UI_PopupList (const char *title, const char *headline, linkedList_t* entries, const char *clickAction) { uiNode_t* window; uiNode_t* listNode; Cvar_Set("ui_sys_popup_title", title); UI_RegisterText(TEXT_POPUP_INFO, headline); /* make sure, that we are using the linked list */ UI_ResetData(TEXT_LIST); UI_RegisterLinkedListText(TEXT_LIST, entries); window = UI_GetWindow(POPUPLIST_WINDOW_NAME); if (!window) Com_Error(ERR_FATAL, "Could not get "POPUPLIST_WINDOW_NAME" window"); listNode = UI_GetNode(window, POPUPLIST_NODE_NAME); if (!listNode) Com_Error(ERR_FATAL, "Could not get "POPUPLIST_NODE_NAME" node in "POPUPLIST_WINDOW_NAME" window"); /* free previous actions */ if (listNode->onClick) { assert(listNode->onClick->d.terminal.d1.data); Mem_Free(listNode->onClick->d.terminal.d1.data); Mem_Free(listNode->onClick); listNode->onClick = NULL; } if (clickAction) { UI_PoolAllocAction(&listNode->onClick, EA_CMD, clickAction); } else { listNode->onClick = NULL; } if (!UI_IsWindowOnStack(window->name)) UI_PushWindow(window->name, NULL, NULL); return listNode; }
/** * @brief Updates the Buy/Sell menu list. * @param[in] base Pointer to the base to buy/sell at * @sa BS_BuyType_f */ static void BS_BuyType (const base_t *base) { const objDef_t *od; int i, j = 0; char tmpbuf[MAX_VAR]; if (!base || buyCat >= MAX_FILTERTYPES || buyCat < 0) return; CP_UpdateCredits(ccs.credits); bsMarketNames = NULL; bsMarketStorage = NULL; bsMarketMarket = NULL; bsMarketPrices = NULL; UI_ResetData(TEXT_ITEMDESCRIPTION); /* hide autosell checkboxes by default */ for (i = 0; i < MAX_MARKET_MENU_ENTRIES; i++) { UI_ExecuteConfunc("buy_autoselli %i", i); } switch (buyCat) { case FILTER_AIRCRAFT: /* Aircraft */ { const aircraft_t *aircraftTemplate; for (i = 0, j = 0, aircraftTemplate = ccs.aircraftTemplates; i < ccs.numAircraftTemplates; i++, aircraftTemplate++) { if (!BS_AircraftIsOnMarket(aircraftTemplate)) continue; assert(aircraftTemplate->tech); if (BS_GetStorageAmountInBase(base, aircraftTemplate->id) + BS_GetAircraftOnMarket(aircraftTemplate) > 0) { if (j >= buyList.scroll && j < MAX_MARKET_MENU_ENTRIES) { UI_ExecuteConfunc("buy_show %i", j - buyList.scroll); } BS_AddToList(aircraftTemplate->name, BS_GetStorageAmountInBase(base, aircraftTemplate->id), BS_GetAircraftOnMarket(aircraftTemplate), BS_GetAircraftBuyingPrice(aircraftTemplate)); if (j >= MAX_BUYLIST) Com_Error(ERR_DROP, "Increase the MAX_BUYLIST value to handle that much items\n"); buyList.l[j].item = NULL; buyList.l[j].aircraft = aircraftTemplate; buyList.length = j + 1; BS_UpdateItem(base, j - buyList.scroll); j++; } } } break; case FILTER_CRAFTITEM: /* Aircraft items */ /* get item list */ for (i = 0, j = 0, od = csi.ods; i < csi.numODs; i++, od++) { if (!BS_IsOnMarket(od)) continue; /* Check whether the item matches the proper filter, storage in current base and market. */ if ((B_ItemInBase(od, base) || ccs.eMarket.numItems[i]) && INV_ItemMatchesFilter(od, FILTER_CRAFTITEM)) { if (j >= buyList.scroll && j < MAX_MARKET_MENU_ENTRIES) { const technology_t *tech = RS_GetTechForItem(od); UI_ExecuteConfunc("buy_show %i", j - buyList.scroll); if (RS_IsResearched_ptr(tech)) { if (ccs.eMarket.autosell[i]) UI_ExecuteConfunc("buy_autoselle %i", j - buyList.scroll); else UI_ExecuteConfunc("buy_autoselld %i", j - buyList.scroll); } } BS_AddToList(od->name, B_ItemInBase(od, base), ccs.eMarket.numItems[i], BS_GetItemBuyingPrice(od)); if (j >= MAX_BUYLIST) Com_Error(ERR_DROP, "Increase the MAX_FILTERLIST value to handle that much items\n"); buyList.l[j].item = od; buyList.l[j].aircraft = NULL; buyList.length = j + 1; BS_UpdateItem(base, j - buyList.scroll); j++; } } break; default: /* Normal items */ if (buyCat < MAX_SOLDIER_FILTERTYPES || buyCat == FILTER_DUMMY) { /* get item list */ for (i = 0, j = 0, od = csi.ods; i < csi.numODs; i++, od++) { if (!BS_IsOnMarket(od)) continue; /* Check whether the item matches the proper filter, storage in current base and market. */ if ((B_ItemInBase(od, base) || ccs.eMarket.numItems[i]) && INV_ItemMatchesFilter(od, buyCat)) { BS_AddToList(od->name, B_ItemInBase(od, base), ccs.eMarket.numItems[i], BS_GetItemBuyingPrice(od)); /* Set state of Autosell button. */ if (j >= buyList.scroll && j < MAX_MARKET_MENU_ENTRIES) { const technology_t *tech = RS_GetTechForItem(od); UI_ExecuteConfunc("buy_show %i", j - buyList.scroll); if (RS_IsResearched_ptr(tech)) { if (ccs.eMarket.autosell[i]) UI_ExecuteConfunc("buy_autoselle %i", j - buyList.scroll); else UI_ExecuteConfunc("buy_autoselld %i", j - buyList.scroll); } } if (j >= MAX_BUYLIST) Com_Error(ERR_DROP, "Increase the MAX_BUYLIST value to handle that much items\n"); buyList.l[j].item = od; buyList.l[j].aircraft = NULL; buyList.length = j + 1; BS_UpdateItem(base, j - buyList.scroll); j++; } } } break; } for (; j < MAX_MARKET_MENU_ENTRIES; j++) { /* Hide the rest of the entries. */ UI_ExecuteConfunc("buy_hide %i", j); } /* Update some menu cvars. */ /* Set up base capacities. */ Com_sprintf(tmpbuf, sizeof(tmpbuf), "%i/%i", CAP_GetCurrent(base, CAP_ITEMS), CAP_GetMax(base, CAP_ITEMS)); Cvar_Set("mn_bs_storage", tmpbuf); /* select first item */ if (buyList.length) { switch (buyCat) { /** @sa BS_MarketClick_f */ case FILTER_AIRCRAFT: BS_MarketAircraftDescription(buyList.l[0].aircraft); break; case FILTER_CRAFTITEM: Cvar_Set("mn_aircraftname", ""); /** @todo Use craftitem name here? See also BS_MarketClick_f */ /* Select current item or first one. */ if (currentSelectedMenuEntry) UP_AircraftItemDescription(currentSelectedMenuEntry); else UP_AircraftItemDescription(buyList.l[0].item); break; default: assert(buyCat != MAX_FILTERTYPES); /* Select current item or first one. */ if (currentSelectedMenuEntry) INV_ItemDescription(currentSelectedMenuEntry); else INV_ItemDescription(buyList.l[0].item); break; } } else { /* reset description */ INV_ItemDescription(NULL); } UI_RegisterLinkedListText(TEXT_MARKET_NAMES, bsMarketNames); UI_RegisterLinkedListText(TEXT_MARKET_STORAGE, bsMarketStorage); UI_RegisterLinkedListText(TEXT_MARKET_MARKET, bsMarketMarket); UI_RegisterLinkedListText(TEXT_MARKET_PRICES, bsMarketPrices); }