MCPcopy Create free account
hub / github.com/OGSR/OGSR-Engine / load_shared

Method load_shared

ogsr_engine/xrGame/encyclopedia_article.cpp:51–138  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

49}
50
51void CEncyclopediaArticle::load_shared(LPCSTR)
52{
53 const ITEM_DATA& item_data = *id_to_index::GetById(m_ArticleId);
54
55 CUIXml* pXML = item_data._xml;
56 pXML->SetLocalRoot(pXML->GetRoot());
57
58 // loading from XML
59 XML_NODE* pNode = pXML->NavigateToNode(id_to_index::tag_name, item_data.pos_in_file);
60 THROW3(pNode, "encyclopedia article id=", *item_data.id);
61
62 //текст
63 data()->text = pXML->Read(pNode, "text", 0, "");
64 //имя
65 data()->name = pXML->ReadAttrib(pNode, "name", "");
66 //группа
67 data()->group = pXML->ReadAttrib(pNode, "group", "");
68 //секция ltx, откуда читать данные
69 LPCSTR ltx = pXML->Read(pNode, "ltx", 0, NULL);
70
71 if (ltx)
72 {
73 CIconParams params(ltx);
74 params.set_shader(&(data()->image));
75 data()->image.ClipperOn();
76 data()->image.TextureAvailable(true);
77 }
78 else
79 {
80 if (pXML->NavigateToNode(pNode, "texture", 0))
81 {
82 pXML->SetLocalRoot(pNode);
83 CUIXmlInit::InitTexture(*pXML, "", 0, &data()->image);
84 pXML->SetLocalRoot(pXML->GetRoot());
85 }
86 }
87
88 if (data()->image.TextureAvailable())
89 {
90 Frect r = data()->image.GetUIStaticItem().GetOriginalRect();
91 data()->image.SetAutoDelete(false);
92
93 const int minSize = 65;
94
95 // Сначала устанавливаем если надо минимально допустимые размеры иконки
96 if (r.width() < minSize)
97 {
98 float dx = minSize - r.width();
99 r.x2 += dx;
100 data()->image.SetTextureOffset(dx / 2, data()->image.GetTextureOffeset()[1]);
101 }
102
103 if (r.height() < minSize)
104 {
105 float dy = minSize - r.height();
106 r.y2 += dy;
107 data()->image.SetTextureOffset(data()->image.GetTextureOffeset()[0], dy / 2);
108 }

Callers

nothing calls this directly

Calls 13

MsgFunction · 0.85
NavigateToNodeMethod · 0.80
ReadAttribMethod · 0.80
set_shaderMethod · 0.80
ClipperOnMethod · 0.80
GetOriginalRectMethod · 0.80
ReadAttribIntMethod · 0.80
ReadMethod · 0.45
widthMethod · 0.45
SetTextureOffsetMethod · 0.45
heightMethod · 0.45
SetWndRectMethod · 0.45

Tested by

no test coverage detected