/** * @brief Display the popup_homebase * @param[in] aircraft Pointer to aircraft we want to change homebase. * @param[in] alwaysDisplay False if popup should be displayed only if at least one base is available. * @return true if popup is displayed. */ qboolean CL_DisplayHomebasePopup (aircraft_t *aircraft, qboolean alwaysDisplay) { int homebase; int numAvailableBases = 0; baseCapacities_t capacity; linkedList_t* popupListText = NULL; base_t *base; assert(aircraft); capacity = AIR_GetCapacityByAircraftWeight(aircraft); LIST_Delete(&popupListData); popupNum = 0; homebase = -1; base = NULL; while ((base = B_GetNext(base)) != NULL) { char text[MAX_VAR]; char const* msg; if (base == aircraft->homebase) { msg = _("current homebase of aircraft"); LIST_Add(&popupListData, (byte *)&INVALID_BASE, sizeof(int)); homebase = popupNum; } else { msg = AIR_CheckMoveIntoNewHomebase(aircraft, base, capacity); if (!msg) { msg = _("base can hold aircraft"); LIST_Add(&popupListData, (byte *)&base->idx, sizeof(int)); numAvailableBases++; } else { LIST_Add(&popupListData, (byte *)&INVALID_BASE, sizeof(int)); } } Com_sprintf(text, sizeof(text), "%s\t%s", base->name, msg); LIST_AddString(&popupListText, text); popupNum++; } if (alwaysDisplay || numAvailableBases > 0) { CL_GameTimeStop(); popupListNode = UI_PopupList(_("Change homebase of aircraft"), _("Base\tStatus"), popupListText, "change_homebase <lineselected>;"); VectorSet(popupListNode->selectedColor, 0.0, 0.78, 0.0); /**< Set color for selected entry. */ popupListNode->selectedColor[3] = 1.0; UI_TextNodeSelectLine(popupListNode, homebase); MAP_SelectAircraft(aircraft); return qtrue; } return qfalse; }
/** * @brief Calls the script command for a text node that is clickable via right mouse button * @sa UI_TextNodeClick */ void uiTextNode::onRightClick (uiNode_t* node, int x, int y) { int line = UI_TextNodeGetLine(node, x, y); if (line < 0 || line >= EXTRADATA(node).super.scrollY.fullSize) return; UI_TextNodeSelectLine(node, line); if (node->onRightClick) UI_ExecuteEventActions(node, node->onRightClick); }