CUIDragItem* CUIWeaponCellItem::CreateDragItem() { CUIDragItem* i = inherited::CreateDragItem(); CUIStatic* s = NULL; if(GetIcon(eSilencer)) { s = new CUIStatic(); s->SetAutoDelete(true); s->SetShader (InventoryUtilities::GetEquipmentIconsShader()); InitAddon (s, *object()->GetSilencerName(), m_addon_offset[eSilencer], false); s->SetColor (i->wnd()->GetColor()); i->wnd ()->AttachChild (s); } if(GetIcon(eScope)) { s = new CUIStatic(); s->SetAutoDelete(true); s->SetShader (InventoryUtilities::GetEquipmentIconsShader()); InitAddon (s, *object()->GetScopeName(), m_addon_offset[eScope], false); s->SetColor (i->wnd()->GetColor()); i->wnd ()->AttachChild (s); } if(GetIcon(eLauncher)) { s = new CUIStatic(); s->SetAutoDelete(true); s->SetShader (InventoryUtilities::GetEquipmentIconsShader()); InitAddon (s, *object()->GetGrenadeLauncherName(),m_addon_offset[eLauncher], false); s->SetColor (i->wnd()->GetColor()); i->wnd ()->AttachChild (s); } return i; }
void CUIStatsPlayerList::InitHeader(CUIXml& xml_doc, LPCSTR path) { string256 _path; CUIXmlInit::InitStatic(xml_doc, strconcat(sizeof(_path),_path, path, ":list_header"), 0, m_header); m_header->SetWidth(this->GetDesiredChildWidth()); m_h.h = m_header->GetHeight(); CUIXmlInit::InitFont(xml_doc, strconcat(sizeof(_path),_path, path, ":list_header:text_format"), 0, m_h.c, m_h.f); float indent = 5; if (!m_bSpectator || m_bStatus_mode) { for (u32 i = 0; i<m_field_info.size(); ++i) { CUIStatic* st = new CUIStatic(); st->SetAutoDelete(true); st->SetWndPos(Fvector2().set(indent,10.0f)); st->SetWndSize(Fvector2().set(m_field_info[i].width, m_header->GetHeight())); indent += m_field_info[i].width; if (0 == xr_strcmp(m_field_info[i].name, "rank")) st->SetText(""); else if (0 == xr_strcmp(m_field_info[i].name, "death_atf")) st->SetText(""); else { st->SetTextST(GetST_entry(*m_field_info[i].name)); } if (m_h.f) st->SetFont(m_h.f); st->SetTextColor(m_h.c); st->SetTextComplexMode(false); if (0 != i) st->SetTextAlignment(CGameFont::alCenter); m_header->AttachChild(st); } } else { CUIStatic* st = new CUIStatic(); st->SetAutoDelete (true); st->SetWndPos (Fvector2().set(10,0)); st->SetWndSize (Fvector2().set(this->GetDesiredChildWidth(),m_h.h)); if (m_h.f) m_header->SetFont (m_h.f); st->SetTextColor (m_h.c); st->SetVTextAlignment (valCenter); st->SetTextComplexMode (false); st->SetTextST ("mp_spectators"); m_header->AttachChild (st); } }
void CUIDebugFonts::FillUpList(){ CFontManager::FONTS_VEC& v = UI()->Font()->m_all_fonts; CFontManager::FONTS_VEC_IT it = v.begin(); CFontManager::FONTS_VEC_IT it_e = v.end(); Fvector2 pos, sz; pos.set (0,0); sz.set (UI_BASE_WIDTH,UI_BASE_HEIGHT); string256 str; for(;it!=it_e;++it){ CGameFont* F = *(*it); CUIStatic* pItem = xr_new<CUIStatic>(); pItem->SetWndPos (pos); pItem->SetWndSize (sz); sprintf_s (str, "%s:%s", *F->m_font_name, *CStringTable().translate("Test_Font_String")); pItem->SetFont (F); pItem->SetText (str); pItem->SetTextComplexMode(false); pItem->SetVTextAlignment(valCenter); pItem->SetTextAlignment (CGameFont::alCenter); pItem->AdjustHeightToText(); pos.y += pItem->GetHeight()+20.0f; pItem->SetAutoDelete (true); AttachChild (pItem); } }
void CUIStatsPlayerList::InitTeamHeader(CUIXml& xml_doc, LPCSTR path){ string256 _path; m_header_team = new CUIWindow(); m_header_team->SetAutoDelete(true); CUIXmlInit::InitWindow(xml_doc, strconcat(sizeof(_path),_path, path, ":team_header"), 0, m_header_team); m_header_team->SetWidth(this->GetDesiredChildWidth()); CUIStatic* logo = new CUIStatic(); logo->SetAutoDelete(true); CUIXmlInit::InitStatic(xml_doc, strconcat(sizeof(_path),_path, path, ":team_header:logo"), 0, logo); m_header_team->AttachChild(logo); if (1 == m_CurTeam) logo->InitTexture(pSettings->r_string("team_logo_small", "team1")); else if (2 == m_CurTeam) logo->InitTexture(pSettings->r_string("team_logo_small", "team2")); else R_ASSERT2(false, "invalid team"); S_ELEMENT t; CUIXmlInit::InitFont(xml_doc, strconcat(sizeof(_path),_path, path, ":team_header:text_format"), 0, t.c, t.f); t.h = m_header_team->GetHeight(); m_header_text = new CUIStatic(); m_header_text->SetAutoDelete(true); CUIXmlInit::InitStatic(xml_doc, strconcat(sizeof(_path),_path, path, ":team_header:header"), 0, m_header_text); m_header_text->SetWidth(GetDesiredChildWidth()); m_header_text->SetVTextAlignment(valCenter); m_header_team->AttachChild(m_header_text); if (t.f) m_header_text->SetFont(t.f); m_header_text->SetTextColor(t.c); }
CUIStatic* CScriptXmlInit::InitStatic(LPCSTR path, CUIWindow* parent){ CUIStatic* pWnd = xr_new<CUIStatic>(); CUIXmlInit::InitStatic(m_xml, path, 0, pWnd); pWnd->SetAutoDelete(true); _attach_child(pWnd, parent); //. if(parent) parent->AttachChild(pWnd); return pWnd; }
CUIStatic* UIHelper::CreateStatic( CUIXml& xml, LPCSTR ui_path, CUIWindow* parent ) { CUIStatic* ui = new CUIStatic(); parent->AttachChild ( ui ); ui->SetAutoDelete ( true ); CUIXmlInit::InitStatic ( xml, ui_path, 0, ui ); return ui; }
void CUICharacterInfo::Init_StrInfoItem( CUIXml& xml_doc, LPCSTR item_str, UIItemType type ) { if ( xml_doc.NavigateToNode( item_str, 0 ) ) { CUIStatic* pItem = m_icons[type] = xr_new<CUIStatic>(); CUIXmlInit::InitStatic( xml_doc, item_str, 0, pItem ); AttachChild( pItem ); pItem->SetAutoDelete( true ); } }
void CUIRankIndicator::InitFromXml(CUIXml& xml_doc) { CUIXmlInit::InitWindow(xml_doc, "rank_wnd", 0, this); string256 str; for(u8 i=0; i<max_rank;++i){ CUIStatic*& s = m_ranks[i]; s = xr_new<CUIStatic>(); xr_sprintf(str, "rank_wnd:rank_%d", i); CUIXmlInit::InitStatic(xml_doc, str, 0, s); } CUIStatic* back = xr_new<CUIStatic>(); back->SetAutoDelete(true); CUIXmlInit::InitStatic(xml_doc, "rank_wnd:background", 0, back); AttachChild (back); }
void CUIArtefactDetectorElite::construct(CEliteDetector* p) { m_parent = p; CUIXml uiXml; uiXml.Load (CONFIG_PATH, UI_PATH, "ui_detector_artefact.xml"); CUIXmlInit xml_init; string512 buff; xr_strcpy (buff, p->ui_xml_tag()); xml_init.InitWindow (uiXml, buff, 0, this); m_wrk_area = xr_new<CUIWindow>(); xr_sprintf (buff, "%s:wrk_area", p->ui_xml_tag()); xml_init.InitWindow (uiXml, buff, 0, m_wrk_area); m_wrk_area->SetAutoDelete (true); AttachChild (m_wrk_area); xr_sprintf (buff, "%s", p->ui_xml_tag()); int num = uiXml.GetNodesNum (buff,0,"palette"); XML_NODE* pStoredRoot = uiXml.GetLocalRoot(); uiXml.SetLocalRoot (uiXml.NavigateToNode(buff,0)); for(int idx=0; idx<num;++idx) { CUIStatic* S = xr_new<CUIStatic>(); shared_str name = uiXml.ReadAttrib("palette",idx,"id"); m_palette[name] = S; xml_init.InitStatic (uiXml, "palette", idx, S); S->SetAutoDelete (true); m_wrk_area->AttachChild (S); S->SetCustomDraw (true); } uiXml.SetLocalRoot (pStoredRoot); Fvector _map_attach_p = pSettings->r_fvector3(m_parent->cNameSect(), "ui_p"); Fvector _map_attach_r = pSettings->r_fvector3(m_parent->cNameSect(), "ui_r"); _map_attach_r.mul (PI/180.f); m_map_attach_offset.setHPB (_map_attach_r.x, _map_attach_r.y, _map_attach_r.z); m_map_attach_offset.translate_over (_map_attach_p); }
void RearrangeTabButtons(CUITabControl* pTab, xr_vector<Fvector2>& vec_sign_places) { TABS_VECTOR * btn_vec = pTab->GetButtonsVector(); TABS_VECTOR::iterator it = btn_vec->begin(); TABS_VECTOR::iterator it_e = btn_vec->end(); vec_sign_places.clear (); vec_sign_places.resize (btn_vec->size()); Fvector2 pos; pos.set ((*it)->GetWndPos()); Fvector2 sign_sz; sign_sz.set (9.0f+3.0f, 11.0f); u32 idx = 0; float btn_text_len = 0.0f; CUIStatic* st = NULL; for(;it!=it_e;++it,++idx) { if(idx!=0) { st = xr_new<CUIStatic>(); st->SetAutoDelete(true);pTab->AttachChild(st); st->SetFont((*it)->GetFont()); st->SetTextColor (color_rgba(90,90,90,255)); st->SetText("//"); st->SetWndSize ((*it)->GetWndSize()); st->AdjustWidthToText(); st->SetWndPos (pos); pos.x += st->GetWndSize().x; } vec_sign_places[idx].set(pos); vec_sign_places[idx].y += iFloor(((*it)->GetWndSize().y - sign_sz.y)/2.0f); vec_sign_places[idx].y = (float)iFloor(vec_sign_places[idx].y); pos.x += sign_sz.x; (*it)->SetWndPos (pos); (*it)->AdjustWidthToText(); btn_text_len = (*it)->GetWndSize().x; pos.x += btn_text_len+3.0f; } }
CUIStatic* init_addon( CUIWeaponCellItem *cell_item, LPCSTR sect, float scale, float scale_x, eAddonType idx) { CUIStatic *addon = xr_new<CUIStatic>(); addon->SetAutoDelete(true); auto pos = cell_item->get_addon_offset(idx); pos.x *= scale*scale_x; pos.y *= scale; auto width = (float)pSettings->r_u32(sect, "inv_grid_width")*INV_GRID_WIDTH; auto height = (float)pSettings->r_u32(sect, "inv_grid_height")*INV_GRID_HEIGHT; auto tex_x = (float)pSettings->r_u32(sect, "inv_grid_x")*INV_GRID_WIDTH; auto tex_y = (float)pSettings->r_u32(sect, "inv_grid_y")*INV_GRID_HEIGHT; addon->SetStretchTexture (true); addon->InitTexture ("ui\\ui_icon_equipment"); addon->SetOriginalRect (tex_x, tex_y, width, height); addon->SetWndRect (pos.x, pos.y, width*scale*scale_x, height*scale); addon->SetColor (color_rgba(255,255,255,192)); return addon; }