void refresh_Commander_SingleSelection() { int object_id = cl.selection.array[0]; if (object_id < CL_MAX_CLIENTS) { corec.GUI_Exec("hide selection_panel; hide commander_building_info_panel; show commander_unit_info_panel; show commander_generic_info_panel"); } else if (IsBuildingType(cl.objects[object_id].base.type)) { corec.GUI_Exec("show commander_building_info_panel; hide selection_panel; hide commander_unit_info_panel; show commander_generic_info_panel"); } else { corec.GUI_Exec("select unit0_name; param text "); corec.GUI_Exec("select unit0_goal; param text "); corec.GUI_Exec("select unit0_gold; param text "); corec.GUI_Exec("select unit0_level; param text "); corec.GUI_Exec("select unit0_kills; param text "); corec.GUI_Exec("select unit0_loyaltypoints; param text "); corec.GUI_Exec("hide unit0_loyaltypoints_label; hide unit0_kills_label; hide unit0_goldicon; hide unit0_level_label"); corec.GUI_Exec("hide selection_panel; hide commander_building_info_panel; show commander_unit_info_panel; show commander_generic_info_panel"); //GUI_Graphic_ShowInt(unit0_percentComplete, MAX_PERCENTCOMPLETE - cl.objects[object_id].base.percentToComplete); } }
bool operator()(const CUnit *const unit) const { if (unit->Type->CanAttack == false) { return *enemy == NULL; } if (FIND_TYPE == AIATTACK_RANGE) { *enemy = AttackUnitsInReactRange(*unit); } else if (FIND_TYPE == AIATTACK_ALLMAP) { *enemy = AttackUnitsInDistance(*unit, MaxMapWidth); } else if (FIND_TYPE == AIATTACK_BUILDING) { *enemy = AttackUnitsInDistance(*unit, MaxMapWidth, IsBuildingType()); Assert(!*enemy); if (*enemy == NULL || !(*enemy)->Type->Building) { *enemy = AttackUnitsInDistance(*unit, MaxMapWidth); } } else if (FIND_TYPE == AIATTACK_AGRESSIVE) { *enemy = AttackUnitsInDistance(*unit, MaxMapWidth, IsAggresiveUnit()); Assert(!*enemy || (*enemy)->IsAgressive()); if (*enemy == NULL) { *enemy = AttackUnitsInDistance(*unit, MaxMapWidth); } } return *enemy == NULL; }
// UTTAR: Now, this function is called SYSTEMATICALLY, while the other one is called on-request when the selection changes void refresh_Commander_SingleSelectionFrame() { int level, money, loyalty, kills, i = 0, j = 0; char *goal; float fullhealth; int object_id = cl.selection.array[0]; if (object_id < 0) return; if (object_id < CL_MAX_CLIENTS) { corec.GUI_Exec(fmt("select unit0_name; param text %s", cl.clients[object_id].info.name)); if (cl.clients[object_id].waypoint.active) goal = CL_GetGoalString(cl.clients[object_id].waypoint.goal); else goal = "No task"; corec.GUI_Exec(fmt("select unit0_goal; param text %s", goal)); level = cl.clients[object_id].score.level; money = cl.clients[object_id].score.money; loyalty = cl.clients[object_id].score.loyalty; kills = cl.clients[object_id].score.kills; corec.GUI_Exec(fmt("select unit0_gold; param text %i", money)); corec.GUI_Exec(fmt("select unit0_level; param text %i", money)); corec.GUI_Exec(fmt("select unit0_kills; param text %i", money)); corec.GUI_Exec(fmt("select unit0_loyaltypoints; param text %i", money)); corec.GUI_Exec("show unit0_loyaltypoints_label; show unit0_kills_label; show unit0_goldicon; show unit0_level_label"); } else if (IsBuildingType(cl.objects[object_id].base.type)) { // UTTAR: Support for team upgrades researching if(cl.objects[object_id].itemConstruction >= MAX_OBJECT_TYPES && cl.objects[object_id].itemConstruction < MAX_TECHTREE_ITEMS) { teamUpgrade_t *tu = GetTUByType((byte)(cl.objects[object_id].itemConstruction-MAX_OBJECT_TYPES)); if (cl.objects[object_id].base.percentToComplete > 0 && cl.objects[object_id].itemConstruction && !(cl.objects[object_id].base.flags & BASEOBJ_UNDER_CONSTRUCTION)) { corec.GUI_Exec(fmt("select building0_currentResearchItem; param up_image %s.s2g", tu->icon)); corec.GUI_Exec("show building0_currentResearchItem"); corec.GUI_Exec("show building0_currentResearchItem_label"); } else { corec.GUI_Exec("hide building0_currentResearchItem"); corec.GUI_Exec("hide building0_currentResearchItem_label"); } } else { objectData_t *obj = CL_ObjectTypeT(cl.info ? cl.info->team : 0, cl.objects[object_id].itemConstruction); if (cl.objects[object_id].base.percentToComplete > 0 && cl.objects[object_id].itemConstruction && !(cl.objects[object_id].base.flags & BASEOBJ_UNDER_CONSTRUCTION)) { corec.GUI_Exec(fmt("select building0_currentResearchItem; param up_image %s.s2g", obj->icon)); corec.GUI_Exec("show building0_currentResearchItem"); corec.GUI_Exec("show building0_currentResearchItem_label"); } else { corec.GUI_Exec("hide building0_currentResearchItem"); corec.GUI_Exec("hide building0_currentResearchItem_label"); } } corec.GUI_Exec(fmt("select building0_type; param text %s", CL_ObjectTypeAdv(cl.objects[object_id].visual)->description)); for (i = 0; i < MAX_CLIENT_QUEUED_RESEARCH; i++) { if (cl.objects[object_id].researchQueue[i] > 0 && i < cl.objects[object_id].numQueuedResearch) { // UTTAR: Support for team upgrades if(cl.objects[object_id].researchQueue[i] < MAX_OBJECT_TYPES) { corec.GUI_Exec(fmt("select building0_item%i; param up_image %s.s2g", i, CL_ObjectTypeT(cl.info ? cl.info->team : 0, cl.objects[object_id].researchQueue[i])->icon)); corec.GUI_Exec(fmt("show building0_item%i", i)); } else if(cl.objects[object_id].researchQueue[i] < MAX_TECHTREE_ITEMS) { corec.GUI_Exec(fmt("select building0_item%i; param up_image %s.s2g", i, GetTUByType((byte)(cl.objects[object_id].researchQueue[i]-MAX_OBJECT_TYPES))->icon)); corec.GUI_Exec(fmt("show building0_item%i", i)); } else { corec.GUI_Exec(fmt("hide building0_item%i", i)); } } else { corec.GUI_Exec(fmt("hide building0_item%i", i)); } } } else { } // UTTAR: Support for items showing the owner here too if(CL_ObjectTypeAdv(cl.objects[object_id].visual)->objclass == OBJCLASS_ITEM && cl.objects[object_id].base.owner < CL_MAX_CLIENTS) corec.GUI_Exec(fmt("select unit0_name; param text %s", cl.clients[cl.objects[object_id].base.owner].info.name)); corec.GUI_Exec(fmt("select unit0_type; param text %s", CL_ObjectTypeAdv(cl.objects[object_id].base)->description)); fullhealth = cl.objects[object_id].visual.fullhealth; if (fullhealth > 0) { corec.Cvar_SetVarValue(&unit_healthpercent, 100 * cl.objects[object_id].base.health / fullhealth); } // UTTAR: Added check cause it didn't seem to work if(object_id < CL_MAX_CLIENTS && !CL_ObjectTypeAdv(cl.objects[object_id].base)->isSiegeWeapon && cl.objects[object_id].base.team == cl.info->team) { for (i = 1, j = 0; i < MAX_STATES && j < MAX_VISIBLE_STATES; i++) { if (!stateData[i].active) break; if (cl.objects[cl.selection.array[0]].base.states[i]) { corec.GUI_Exec(fmt("select unit0_effect%i; param up_image %s", j, stateData[cl.objects[cl.selection.array[0]].base.states[i]].icon)); corec.GUI_Exec(fmt("show unit0_effect%i", j)); j++; } } } else j = 0; while (j < MAX_VISIBLE_STATES) { corec.GUI_Exec(fmt("hide unit0_effect%i", j)); j++; } }
void CMDR_RefreshSelectionIcons() { int i = 0; gui_element_t *widget, *widgetg; char *name; if (cl.selection.numSelected > 1) { corec.GUI_Exec("hide commander_unit_panel"); for (i = 0; i < cl.selection.numSelected; i++) { widget = corec.GUI_GetObject(fmt("selection_panel:object%i", i)); widgetg = corec.GUI_GetObject(fmt("selection_panel:object%ig", i)); if (widget) { objectData_t *obj = CL_ObjectTypeAdv(cl.objects[cl.selection.array[i]].base); if (cl.selection.array[i] < CL_MAX_CLIENTS) { name = cl.clients[cl.selection.array[i]].info.name; } // UTTAR: Support for items showing the owner here too else if(CL_ObjectTypeAdv(cl.objects[cl.selection.array[i]].visual)->objclass == OBJCLASS_ITEM) { char *loc; name = fmt(cl.clients[cl.objects[cl.selection.array[i]].base.owner].info.name); loc = name; loc += strlen(cl.clients[cl.objects[cl.selection.array[i]].base.owner].info.name); // We love the english language - right, right? if(*(loc-1) == 's') { strcpy(loc, "' "); loc += 2; } else { strcpy(loc, "'s "); loc += 3; } strcpy(loc, CL_ObjectTypeAdv(cl.objects[cl.selection.array[i]].base)->description); } else name = obj->description; corec.GUI_Select(widget); corec.Cmd_Exec(fmt("param mouseover_command " "\"" "show multiunit_highlight_popup; " "select multiunit_highlight_popup:multiunit_name; " "param text \\\"%s\\\"\"", name)); corec.Cmd_Exec("param mouseaway_command \"hide grid_popup_panel\"");// #cl_gridPopupFadeTime#\"");*/ corec.Cmd_Exec("param mouseaway_command \"hide multiunit_highlight_popup\""); corec.Cmd_Exec(fmt("param command \"selectUnits %i\"", cl.selection.array[i])); if (corec.Cvar_GetInteger("cl_3dLoadout")) { corec.Cmd_Exec("param up_image \"\""); corec.Cmd_Exec("param up_hover_image /textures/core/1_nl_over.s2g"); corec.Cmd_Exec("param down_image \"\""); corec.Cmd_Exec(fmt("select selection_panel:object%ig; param cloneobj %i", i, cl.selection.array[i])); if (!IsBuildingType(cl.objects[cl.selection.array[i]].base.type)) corec.Cmd_Exec("param yaw 0"); corec.Cmd_Exec(fmt("select selection_panel:object%i", i)); } else { corec.Cmd_Exec(fmt("select selection_panel:object%ig; param cloneobj -1; select selection_panel:object%i", i, i)); corec.Cmd_Exec(fmt("param up_image %s.s2g", obj->icon)); corec.Cmd_Exec(fmt("param up_hover_image %s_over.s2g", obj->icon)); corec.Cmd_Exec(fmt("param down_image %s_down.s2g", obj->icon)); } corec.GUI_Show(widgetg); corec.GUI_Show(widget); } widget = corec.GUI_GetObject(fmt("selection_panel:object%i_health", i)); if (widget) corec.GUI_Show(widget); } } else { corec.GUI_Exec("show commander_unit_panel"); } for (; i < MAX_SELECTABLE_UNITS; i++) { corec.Cmd_Exec(fmt("hide selection_panel:object%i", i)); corec.Cmd_Exec(fmt("hide selection_panel:object%i_health", i)); corec.Cmd_Exec(fmt("hide selection_panel:object%ig", i)); } }