@@ -44,13 +44,6 @@ SLuaWpnParams::~SLuaWpnParams() {}
44
44
45
45
CUIWpnParams::CUIWpnParams ()
46
46
{
47
- AttachChild (&m_Prop_line);
48
-
49
- AttachChild (&m_icon_acc);
50
- AttachChild (&m_icon_dam);
51
- AttachChild (&m_icon_han);
52
- AttachChild (&m_icon_rpm);
53
-
54
47
AttachChild (&m_textAccuracy);
55
48
AttachChild (&m_textDamage);
56
49
AttachChild (&m_textHandling);
@@ -60,24 +53,22 @@ CUIWpnParams::CUIWpnParams()
60
53
AttachChild (&m_progressDamage);
61
54
AttachChild (&m_progressHandling);
62
55
AttachChild (&m_progressRPM);
63
-
64
- AttachChild (&m_stAmmo);
65
- AttachChild (&m_textAmmoCount);
66
- AttachChild (&m_textAmmoCount2);
67
56
}
68
57
69
58
CUIWpnParams::~CUIWpnParams () {}
70
59
void CUIWpnParams::InitFromXml (CUIXml& xml_doc)
71
60
{
72
61
if (!xml_doc.NavigateToNode (" wpn_params" , 0 ))
73
62
return ;
63
+
74
64
CUIXmlInit::InitWindow (xml_doc, " wpn_params" , 0 , this );
75
- CUIXmlInit::InitStatic (xml_doc, " wpn_params:prop_line" , 0 , &m_Prop_line);
76
65
77
- CUIXmlInit::InitStatic (xml_doc, " wpn_params:static_accuracy" , 0 , &m_icon_acc);
78
- CUIXmlInit::InitStatic (xml_doc, " wpn_params:static_damage" , 0 , &m_icon_dam);
79
- CUIXmlInit::InitStatic (xml_doc, " wpn_params:static_handling" , 0 , &m_icon_han);
80
- CUIXmlInit::InitStatic (xml_doc, " wpn_params:static_rpm" , 0 , &m_icon_rpm);
66
+ m_Prop_line = UIHelper::CreateStatic (xml_doc, " wpn_params:prop_line" , this , false );
67
+
68
+ m_icon_acc = UIHelper::CreateStatic (xml_doc, " wpn_params:static_accuracy" , this , false );
69
+ m_icon_dam = UIHelper::CreateStatic (xml_doc, " wpn_params:static_damage" , this , false );
70
+ m_icon_han = UIHelper::CreateStatic (xml_doc, " wpn_params:static_handling" , this , false );
71
+ m_icon_rpm = UIHelper::CreateStatic (xml_doc, " wpn_params:static_rpm" , this , false );
81
72
82
73
CUIXmlInit::InitTextWnd (xml_doc, " wpn_params:cap_accuracy" , 0 , &m_textAccuracy);
83
74
CUIXmlInit::InitTextWnd (xml_doc, " wpn_params:cap_damage" , 0 , &m_textDamage);
@@ -91,9 +82,9 @@ void CUIWpnParams::InitFromXml(CUIXml& xml_doc)
91
82
92
83
if (IsGameTypeSingle ())
93
84
{
94
- CUIXmlInit::InitStatic (xml_doc, " wpn_params:static_ammo" , 0 , &m_stAmmo );
95
- CUIXmlInit::InitTextWnd (xml_doc, " wpn_params:cap_ammo_count" , 0 , &m_textAmmoCount );
96
- CUIXmlInit::InitTextWnd (xml_doc, " wpn_params:cap_ammo_count2" , 0 , &m_textAmmoCount2 );
85
+ m_stAmmo = UIHelper::CreateStatic (xml_doc, " wpn_params:static_ammo" , this , false );
86
+ m_textAmmoCount = UIHelper::CreateTextWnd (xml_doc, " wpn_params:cap_ammo_count" , this , false );
87
+ m_textAmmoCount2 = UIHelper::CreateTextWnd (xml_doc, " wpn_params:cap_ammo_count2" , this , false );
97
88
m_textAmmoTypes = UIHelper::CreateTextWnd (xml_doc, " wpn_params:cap_ammo_types" , this , false );
98
89
m_textAmmoUsedType = UIHelper::CreateTextWnd (xml_doc, " wpn_params:cap_ammo_used_type" , this , false );
99
90
m_stAmmoType1 = UIHelper::CreateStatic (xml_doc, " wpn_params:static_ammo_type1" , this , false );
@@ -172,23 +163,27 @@ void CUIWpnParams::SetInfo(CInventoryItem* slot_wpn, CInventoryItem& cur_wpn)
172
163
ammo_count2 = slot_weapon->GetAmmoMagSize ();
173
164
}
174
165
175
- if (ammo_count == ammo_count2)
176
- m_textAmmoCount2.SetTextColor (color_rgba (170 , 170 , 170 , 255 ));
177
- else if (ammo_count < ammo_count2)
178
- m_textAmmoCount2.SetTextColor (color_rgba (255 , 0 , 0 , 255 ));
179
- else
180
- m_textAmmoCount2.SetTextColor (color_rgba (0 , 255 , 0 , 255 ));
166
+ if (m_textAmmoCount2)
167
+ {
168
+ if (ammo_count == ammo_count2)
169
+ m_textAmmoCount2->SetTextColor (color_rgba (170 , 170 , 170 , 255 ));
170
+ else if (ammo_count < ammo_count2)
171
+ m_textAmmoCount2->SetTextColor (color_rgba (255 , 0 , 0 , 255 ));
172
+ else
173
+ m_textAmmoCount2->SetTextColor (color_rgba (0 , 255 , 0 , 255 ));
181
174
182
- string128 str;
183
- xr_sprintf (str, sizeof (str), " %d" , ammo_count);
184
- m_textAmmoCount2.SetText (str);
175
+ string128 str;
176
+ xr_sprintf (str, sizeof (str), " %d" , ammo_count);
177
+ m_textAmmoCount2->SetText (str);
178
+ }
185
179
186
180
const auto & ammo_types = weapon->m_ammoTypes ;
187
181
if (ammo_types.empty ())
188
182
return ;
189
183
190
184
if (m_textAmmoUsedType)
191
185
{
186
+ string128 str;
192
187
xr_sprintf (str, sizeof (str), " %s" , pSettings->r_string (ammo_types[0 ].c_str (), " inv_name_short" ));
193
188
m_textAmmoUsedType->SetTextST (str);
194
189
}
0 commit comments