Skip to content

Commit f7e484f

Browse files
committed
CUIXmlInitBase::GetColor can now accept full RGBA colors as default
Warning: behaviour change!
1 parent ba7b492 commit f7e484f

File tree

5 files changed

+27
-34
lines changed

5 files changed

+27
-34
lines changed

src/xrGame/ui/UICharacterInfo.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,7 @@ void CUICharacterInfo::InitCharacterInfo(Fvector2 pos, Fvector2 size, CUIXml* xm
4646

4747
m_original_color = m_icons[eIcon] ? m_icons[eIcon]->GetTextureColor() : color_xrgb(255, 255, 255);
4848

49-
m_deadbody_color = color_argb(160, 160, 160, 160);
50-
if (xml_doc->NavigateToNode("icon:deadbody", 0))
51-
{
52-
m_deadbody_color = CUIXmlInit::GetColor(*xml_doc, "icon:deadbody", 0, m_deadbody_color);
53-
}
49+
m_deadbody_color = CUIXmlInit::GetColor(*xml_doc, "icon:deadbody", 0, color_argb(160, 160, 160, 160));
5450

5551
Init_IconInfoItem(*xml_doc, "icon_over", eIconOver);
5652

src/xrGame/ui/UIInventoryUpgradeWnd_add.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ void CUIInventoryUpgradeWnd::LoadCellsBacks(CUIXml& uiXml)
2727
LPCSTR type = uiXml.Read("type", 0, "");
2828
LPCSTR txr = uiXml.Read("back_texture", 0, NULL);
2929
LPCSTR txr2 = uiXml.Read("point_texture", 0, NULL);
30-
u32 color = CUIXmlInit::GetColor(uiXml, "item_color", 0, 0);
30+
u32 color = CUIXmlInit::GetColor(uiXml, "item_color", 0, color_rgba(0, 0, 0, 255));
3131
LoadCellStates(type, txr, txr2, color);
3232

3333
uiXml.SetLocalRoot(node);

src/xrGame/ui/UIMapInfo.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ void CUIMapInfo::InitMap(LPCSTR map_name, LPCSTR map_ver)
8181
u32 txt_color;
8282
CGameFont* txt_font;
8383
CUIXmlInit::InitFont(xml_doc, "header", 0, header_color, txt_font);
84-
txt_color = CUIXmlInit::GetColor(xml_doc, "txt:text", 0, 0x00);
84+
txt_color = CUIXmlInit::GetColor(xml_doc, "txt:text", 0, color_rgba(0, 0, 0, 255));
8585
string64 txt_color_tag;
8686
xr_sprintf(txt_color_tag, "%s[%u,%u,%u,%u]", "%c", color_get_A(txt_color), color_get_R(txt_color),
8787
color_get_G(txt_color), color_get_B(txt_color));

src/xrGame/ui/UIRankingWnd.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ bool CUIRankingWnd::Init()
143143
xml.SetLocalRoot(node);
144144

145145
auto stat_count = xml.GetNodesNum(node, "stat");
146-
const u32 value_color = CUIXmlInit::GetColor(xml, "value", 0, 0xFFffffff);
146+
const u32 value_color = CUIXmlInit::GetColor(xml, "value", 0, 0xFFFFFFFF);
147147

148148
for (size_t i = 0; i < stat_count; ++i)
149149
{

src/xrUICore/XML/UIXmlInitBase.cpp

Lines changed: 23 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -223,28 +223,28 @@ bool CUIXmlInitBase::InitCheck(CUIXml& xml_doc, pcstr path, int index, CUICheckB
223223
strconcat(buf, path, ":text_color:e");
224224
if (xml_doc.NavigateToNode(buf, index))
225225
{
226-
color = GetColor(xml_doc, buf, index, 0x00);
226+
color = GetColor(xml_doc, buf, index, color_rgba(0, 0, 0, 255));
227227
pWnd->SetStateTextColor(color, S_Enabled);
228228
}
229229

230230
strconcat(buf, path, ":text_color:d");
231231
if (xml_doc.NavigateToNode(buf, index))
232232
{
233-
color = GetColor(xml_doc, buf, index, 0x00);
233+
color = GetColor(xml_doc, buf, index, color_rgba(0, 0, 0, 255));
234234
pWnd->SetStateTextColor(color, S_Disabled);
235235
}
236236

237237
strconcat(buf, path, ":text_color:t");
238238
if (xml_doc.NavigateToNode(buf, index))
239239
{
240-
color = GetColor(xml_doc, buf, index, 0x00);
240+
color = GetColor(xml_doc, buf, index, color_rgba(0, 0, 0, 255));
241241
pWnd->SetStateTextColor(color, S_Touched);
242242
}
243243

244244
strconcat(buf, path, ":text_color:h");
245245
if (xml_doc.NavigateToNode(buf, index))
246246
{
247-
color = GetColor(xml_doc, buf, index, 0x00);
247+
color = GetColor(xml_doc, buf, index, color_rgba(0, 0, 0, 255));
248248
pWnd->SetStateTextColor(color, S_Highlighted);
249249
}
250250

@@ -266,13 +266,13 @@ bool CUIXmlInitBase::InitSpin(CUIXml& xml_doc, pcstr path, int index, CUICustomS
266266
strconcat(foo, path, ":text_color:e");
267267
if (xml_doc.NavigateToNode(foo, index))
268268
{
269-
color = GetColor(xml_doc, foo, index, 0x00);
269+
color = GetColor(xml_doc, foo, index, color_rgba(0, 0, 0, 255));
270270
pWnd->SetTextColor(color);
271271
}
272272
strconcat(foo, path, ":text_color:d");
273273
if (xml_doc.NavigateToNode(foo, index))
274274
{
275-
color = GetColor(xml_doc, foo, index, 0x00);
275+
color = GetColor(xml_doc, foo, index, color_rgba(0, 0, 0, 255));
276276
pWnd->SetTextColorD(color);
277277
}
278278

@@ -354,28 +354,28 @@ bool CUIXmlInitBase::Init3tButton(CUIXml& xml_doc, pcstr path, int index, CUI3tB
354354
strconcat(buf, path, ":text_color:e");
355355
if (xml_doc.NavigateToNode(buf, index))
356356
{
357-
color = GetColor(xml_doc, buf, index, 0x00);
357+
color = GetColor(xml_doc, buf, index, color_rgba(0, 0, 0, 255));
358358
pWnd->SetStateTextColor(color, S_Enabled);
359359
}
360360

361361
strconcat(buf, path, ":text_color:d");
362362
if (xml_doc.NavigateToNode(buf, index))
363363
{
364-
color = GetColor(xml_doc, buf, index, 0x00);
364+
color = GetColor(xml_doc, buf, index, color_rgba(0, 0, 0, 255));
365365
pWnd->SetStateTextColor(color, S_Disabled);
366366
}
367367

368368
strconcat(buf, path, ":text_color:t");
369369
if (xml_doc.NavigateToNode(buf, index))
370370
{
371-
color = GetColor(xml_doc, buf, index, 0x00);
371+
color = GetColor(xml_doc, buf, index, color_rgba(0, 0, 0, 255));
372372
pWnd->SetStateTextColor(color, S_Touched);
373373
}
374374

375375
strconcat(buf, path, ":text_color:h");
376376
if (xml_doc.NavigateToNode(buf, index))
377377
{
378-
color = GetColor(xml_doc, buf, index, 0x00);
378+
color = GetColor(xml_doc, buf, index, color_rgba(0, 0, 0, 255));
379379
pWnd->SetStateTextColor(color, S_Highlighted);
380380
}
381381

@@ -521,17 +521,17 @@ bool CUIXmlInitBase::InitProgressBar(CUIXml& xml_doc, pcstr path, int index, CUI
521521
{
522522
pWnd->m_bUseColor = true;
523523

524-
pWnd->m_minColor = GetColor(xml_doc, buf, index, 0xff);
524+
pWnd->m_minColor = GetColor(xml_doc, buf, index, 0xFFFFFFFF);
525525

526526
strconcat(buf, path, ":middle_color");
527527
if (xml_doc.NavigateToNode(buf, 0))
528528
{
529-
pWnd->m_middleColor = GetColor(xml_doc, buf, index, 0xff);
529+
pWnd->m_middleColor = GetColor(xml_doc, buf, index, 0xFFFFFFFF);
530530
pWnd->m_bUseMiddleColor = true;
531531
}
532532

533533
strconcat(buf, path, ":max_color");
534-
pWnd->m_maxColor = GetColor(xml_doc, buf, index, 0xff);
534+
pWnd->m_maxColor = GetColor(xml_doc, buf, index, 0xFFFFFFFF);
535535
}
536536

537537
return true;
@@ -670,7 +670,7 @@ void CUIXmlInitBase::InitAutoFrameLineGroup(CUIXml& xml_doc, pcstr path, int ind
670670

671671
bool CUIXmlInitBase::InitFont(const CUIXml& xml_doc, pcstr path, int index, u32& color, CGameFont*& pFnt)
672672
{
673-
color = GetColor(xml_doc, path, index, 0xff);
673+
color = GetColor(xml_doc, path, index, 0xFFFFFFFF);
674674

675675
cpcstr font_name = xml_doc.ReadAttrib(path, index, "font", nullptr);
676676
if (!font_name)
@@ -830,7 +830,7 @@ bool CUIXmlInitBase::InitCustomEdit(CUIXml& xml_doc, pcstr path, int index, CUIC
830830
strconcat(foo, path, ":text_color:e");
831831
if (xml_doc.NavigateToNode(foo, index))
832832
{
833-
const u32 color = GetColor(xml_doc, foo, index, 0x00);
833+
const u32 color = GetColor(xml_doc, foo, index, color_rgba(0, 0, 0, 255));
834834
pWnd->TextItemControl()->SetTextColor(color);
835835
}
836836

@@ -926,7 +926,7 @@ bool CUIXmlInitBase::InitTexture(const CUIXml& xml_doc, pcstr path, int index, I
926926
const bool stretch_flag = xml_doc.ReadAttribInt(path, index, "stretch") ? true : false;
927927
pWnd->SetStretchTexture(stretch_flag);
928928

929-
const u32 color = GetColor(xml_doc, buf, index, 0xff);
929+
const u32 color = GetColor(xml_doc, buf, index, 0xFFFFFFFF);
930930
pWnd->SetTextureColor(color);
931931

932932
if (!fis_zero(rect.width()) && !fis_zero(rect.height()))
@@ -1325,14 +1325,14 @@ bool CUIXmlInitBase::InitComboBox(CUIXml& xml_doc, pcstr path, int index, CUICom
13251325
strconcat(_path, path, ":text_color:e");
13261326
if (xml_doc.NavigateToNode(_path, index))
13271327
{
1328-
color = GetColor(xml_doc, _path, index, 0x00);
1328+
color = GetColor(xml_doc, _path, index, color_rgba(0, 0, 0, 255));
13291329
pWnd->SetTextColor(color);
13301330
}
13311331

13321332
strconcat(_path, path, ":text_color:d");
13331333
if (xml_doc.NavigateToNode(_path, index))
13341334
{
1335-
color = GetColor(xml_doc, _path, index, 0x00);
1335+
color = GetColor(xml_doc, _path, index, color_rgba(0, 0, 0, 255));
13361336
pWnd->SetTextColorD(color);
13371337
}
13381338

@@ -1347,14 +1347,11 @@ u32 CUIXmlInitBase::GetColor(const CUIXml& xml_doc, pcstr path, int index, u32 d
13471347
VERIFY(GetColorDefs()->find(clr_def) != GetColorDefs()->end());
13481348
return (*m_pColorDefs)[clr_def];
13491349
}
1350-
else
1351-
{
1352-
const int r = xml_doc.ReadAttribInt(path, index, "r", def_clr);
1353-
const int g = xml_doc.ReadAttribInt(path, index, "g", def_clr);
1354-
const int b = xml_doc.ReadAttribInt(path, index, "b", def_clr);
1355-
const int a = xml_doc.ReadAttribInt(path, index, "a", 0xff);
1356-
return color_argb(a, r, g, b);
1357-
}
1350+
const int r = xml_doc.ReadAttribInt(path, index, "r", color_get_R(def_clr));
1351+
const int g = xml_doc.ReadAttribInt(path, index, "g", color_get_G(def_clr));
1352+
const int b = xml_doc.ReadAttribInt(path, index, "b", color_get_B(def_clr));
1353+
const int a = xml_doc.ReadAttribInt(path, index, "a", color_get_A(def_clr));
1354+
return color_argb(a, r, g, b);
13581355
}
13591356

13601357
bool CUIXmlInitBase::GetColor(pcstr color_name, u32& color)

0 commit comments

Comments
 (0)