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::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); } }
CUIStatic* CUIGameLog::AddLogMessage(LPCSTR msg) { CUIStatic* pItem = NULL; ADD_TEXT_TO_VIEW3 (msg, pItem, this); pItem->SetTextComplexMode (true); pItem->SetFont (GetFont()); pItem->SetTextColor (txt_color); pItem->SetClrAnimDelay (5000.0f); pItem->SetClrLightAnim (CHAT_LOG_ITEMS_ANIMATION, false, true, true, true); ForceUpdate (); return pItem; }
CUIStatic* CUIListBoxItem::AddField(LPCSTR txt, float len, LPCSTR key) { fields.push_back (xr_new<CUIStatic>()); CUIStatic* st = fields.back(); AttachChild (st); st->Init (FieldsLength(),0, GetWidth(), len); st->SetFont (GetFont()); st->SetTextAlignment (GetTextAlignment()); st->SetVTextAlignment (m_lines.GetVTextAlignment()); st->SetTextColor (GetTextColor()); st->SetText (txt); st->SetWindowName (key); return st; }
void CUIGameLog::AddChatMessage(LPCSTR msg, LPCSTR author){ string256 fullLine; sprintf_s(fullLine, "%s %s", author, msg); _TrimRight (fullLine); CUIStatic* pItem = NULL; pItem = xr_new<CUIStatic>(); pItem->SetTextComplexMode (true); pItem->SetText(fullLine); pItem->m_pLines->SetCutWordsMode(true); pItem->SetFont(GetFont()); pItem->SetTextColor(txt_color); pItem->SetClrAnimDelay(5000.0f); pItem->SetClrLightAnim(CHAT_LOG_ITEMS_ANIMATION, false, true, true, true); pItem->SetWidth(this->GetDesiredChildWidth()); pItem->AdjustHeightToText(); AddWindow(pItem, true); }
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; } }
void CUIMMShniaga::CreateList(xr_vector<CUIStatic*>& lst, CUIXml& xml_doc, LPCSTR path){ CGameFont* pF; u32 color; float button_height = xml_doc.ReadAttribFlt("button", 0, "h"); R_ASSERT (button_height); CUIXmlInit::InitFont (xml_doc, path, 0, color, pF); R_ASSERT (pF); int nodes_num = xml_doc.GetNodesNum(path, 0, "btn"); XML_NODE* tab_node = xml_doc.NavigateToNode(path,0); xml_doc.SetLocalRoot (tab_node); CUIStatic* st; for (int i = 0; i < nodes_num; ++i) { st = new CUIStatic(); st->SetWndPos (Fvector2().set(0,0)); st->SetWndSize (Fvector2().set(m_view->GetDesiredChildWidth(), button_height)); st->SetTextComplexMode (false); st->SetTextST (xml_doc.ReadAttrib ("btn", i, "caption")); if (pF) st->SetFont (pF); float font_height = st->GetFont()->GetHeight(); UI()->ClientToScreenScaledHeight(font_height); st->SetTextY ( (button_height-font_height)/2.0f ); st->SetTextColor (color); st->SetTextAlignment (CGameFont::alCenter); st->SetWindowName (xml_doc.ReadAttrib("btn", i, "name")); st->SetMessageTarget (this); lst.push_back(st); } xml_doc.SetLocalRoot(xml_doc.GetRoot()); }
void CUIItemInfo::InitItem(CInventoryItem* pInvItem) { m_pInvItem = pInvItem; if(!m_pInvItem) return; string256 str; if(UIName) { UIName->SetText (pInvItem->Name()); } if(UIWeight) { sprintf_s (str, "%3.2f kg", pInvItem->Weight()); UIWeight->SetText (str); } if( UICost && IsGameTypeSingle() ) { sprintf_s (str, "%d %s", pInvItem->Cost(),*CStringTable().translate("ui_st_money_regional")); // will be owerwritten in multiplayer UICost->SetText (str); } if(UICondProgresBar) { float cond = pInvItem->GetConditionToShow(); UICondProgresBar->Show (true); UICondProgresBar->SetProgressPos ( cond*100.0f+1.0f-EPS ); } if(UIDesc) { UIDesc->Clear (); VERIFY (0==UIDesc->GetSize()); TryAddWpnInfo (pInvItem->object().cNameSect()); TryAddArtefactInfo (pInvItem->object().cNameSect()); if(m_desc_info.bShowDescrText) { CUIStatic* pItem = xr_new<CUIStatic>(); pItem->SetTextColor (m_desc_info.uDescClr); pItem->SetFont (m_desc_info.pDescFont); pItem->SetWidth (UIDesc->GetDesiredChildWidth()); pItem->SetTextComplexMode (true); pItem->SetText (*pInvItem->ItemDescription()); pItem->AdjustHeightToText (); UIDesc->AddWindow (pItem, true); } UIDesc->ScrollToBegin (); } if(UIItemImage) { // Загружаем картинку UIItemImage->SetShader (InventoryUtilities::GetEquipmentIconsShader()); int iGridWidth = pInvItem->GetGridWidth(); int iGridHeight = pInvItem->GetGridHeight(); int iXPos = pInvItem->GetXPos(); int iYPos = pInvItem->GetYPos(); UIItemImage->GetUIStaticItem().SetOriginalRect( float(iXPos*INV_GRID_WIDTH), float(iYPos*INV_GRID_HEIGHT), float(iGridWidth*INV_GRID_WIDTH), float(iGridHeight*INV_GRID_HEIGHT)); UIItemImage->TextureOn (); UIItemImage->ClipperOn (); UIItemImage->SetStretchTexture (true); Frect v_r = { 0.0f, 0.0f, float(iGridWidth*INV_GRID_WIDTH), float(iGridHeight*INV_GRID_HEIGHT)}; if(UI()->is_16_9_mode()) v_r.x2 /= 1.328f; UIItemImage->GetUIStaticItem().SetRect (v_r); UIItemImage->SetWidth (_min(v_r.width(), UIItemImageSize.x)); UIItemImage->SetHeight (_min(v_r.height(), UIItemImageSize.y)); } }