diff --git a/src/xrGame/ui/UIWpnParams.cpp b/src/xrGame/ui/UIWpnParams.cpp index 6e7617310fc..046fcf04923 100644 --- a/src/xrGame/ui/UIWpnParams.cpp +++ b/src/xrGame/ui/UIWpnParams.cpp @@ -44,13 +44,6 @@ SLuaWpnParams::~SLuaWpnParams() {} CUIWpnParams::CUIWpnParams() { - AttachChild(&m_Prop_line); - - AttachChild(&m_icon_acc); - AttachChild(&m_icon_dam); - AttachChild(&m_icon_han); - AttachChild(&m_icon_rpm); - AttachChild(&m_textAccuracy); AttachChild(&m_textDamage); AttachChild(&m_textHandling); @@ -60,10 +53,6 @@ CUIWpnParams::CUIWpnParams() AttachChild(&m_progressDamage); AttachChild(&m_progressHandling); AttachChild(&m_progressRPM); - - AttachChild(&m_stAmmo); - AttachChild(&m_textAmmoCount); - AttachChild(&m_textAmmoCount2); } CUIWpnParams::~CUIWpnParams() {} @@ -71,13 +60,15 @@ void CUIWpnParams::InitFromXml(CUIXml& xml_doc) { if (!xml_doc.NavigateToNode("wpn_params", 0)) return; + CUIXmlInit::InitWindow(xml_doc, "wpn_params", 0, this); - CUIXmlInit::InitStatic(xml_doc, "wpn_params:prop_line", 0, &m_Prop_line); - CUIXmlInit::InitStatic(xml_doc, "wpn_params:static_accuracy", 0, &m_icon_acc); - CUIXmlInit::InitStatic(xml_doc, "wpn_params:static_damage", 0, &m_icon_dam); - CUIXmlInit::InitStatic(xml_doc, "wpn_params:static_handling", 0, &m_icon_han); - CUIXmlInit::InitStatic(xml_doc, "wpn_params:static_rpm", 0, &m_icon_rpm); + m_Prop_line = UIHelper::CreateStatic(xml_doc, "wpn_params:prop_line", this, false); + + m_icon_acc = UIHelper::CreateStatic(xml_doc, "wpn_params:static_accuracy", this, false); + m_icon_dam = UIHelper::CreateStatic(xml_doc, "wpn_params:static_damage", this, false); + m_icon_han = UIHelper::CreateStatic(xml_doc, "wpn_params:static_handling", this, false); + m_icon_rpm = UIHelper::CreateStatic(xml_doc, "wpn_params:static_rpm", this, false); CUIXmlInit::InitTextWnd(xml_doc, "wpn_params:cap_accuracy", 0, &m_textAccuracy); CUIXmlInit::InitTextWnd(xml_doc, "wpn_params:cap_damage", 0, &m_textDamage); @@ -91,9 +82,9 @@ void CUIWpnParams::InitFromXml(CUIXml& xml_doc) if (IsGameTypeSingle()) { - CUIXmlInit::InitStatic(xml_doc, "wpn_params:static_ammo", 0, &m_stAmmo); - CUIXmlInit::InitTextWnd(xml_doc, "wpn_params:cap_ammo_count", 0, &m_textAmmoCount); - CUIXmlInit::InitTextWnd(xml_doc, "wpn_params:cap_ammo_count2", 0, &m_textAmmoCount2); + m_stAmmo = UIHelper::CreateStatic(xml_doc, "wpn_params:static_ammo", this, false); + m_textAmmoCount = UIHelper::CreateTextWnd(xml_doc, "wpn_params:cap_ammo_count", this, false); + m_textAmmoCount2 = UIHelper::CreateTextWnd(xml_doc, "wpn_params:cap_ammo_count2", this, false); m_textAmmoTypes = UIHelper::CreateTextWnd(xml_doc, "wpn_params:cap_ammo_types", this, false); m_textAmmoUsedType = UIHelper::CreateTextWnd(xml_doc, "wpn_params:cap_ammo_used_type", this, false); m_stAmmoType1 = UIHelper::CreateStatic(xml_doc, "wpn_params:static_ammo_type1", this, false); @@ -172,16 +163,19 @@ void CUIWpnParams::SetInfo(CInventoryItem* slot_wpn, CInventoryItem& cur_wpn) ammo_count2 = slot_weapon->GetAmmoMagSize(); } - if (ammo_count == ammo_count2) - m_textAmmoCount2.SetTextColor(color_rgba(170, 170, 170, 255)); - else if (ammo_count < ammo_count2) - m_textAmmoCount2.SetTextColor(color_rgba(255, 0, 0, 255)); - else - m_textAmmoCount2.SetTextColor(color_rgba(0, 255, 0, 255)); + if (m_textAmmoCount2) + { + if (ammo_count == ammo_count2) + m_textAmmoCount2->SetTextColor(color_rgba(170, 170, 170, 255)); + else if (ammo_count < ammo_count2) + m_textAmmoCount2->SetTextColor(color_rgba(255, 0, 0, 255)); + else + m_textAmmoCount2->SetTextColor(color_rgba(0, 255, 0, 255)); - string128 str; - xr_sprintf(str, sizeof(str), "%d", ammo_count); - m_textAmmoCount2.SetText(str); + string128 str; + xr_sprintf(str, sizeof(str), "%d", ammo_count); + m_textAmmoCount2->SetText(str); + } const auto& ammo_types = weapon->m_ammoTypes; if (ammo_types.empty()) @@ -189,6 +183,7 @@ void CUIWpnParams::SetInfo(CInventoryItem* slot_wpn, CInventoryItem& cur_wpn) if (m_textAmmoUsedType) { + string128 str; xr_sprintf(str, sizeof(str), "%s", pSettings->r_string(ammo_types[0].c_str(), "inv_name_short")); m_textAmmoUsedType->SetTextST(str); } diff --git a/src/xrGame/ui/UIWpnParams.h b/src/xrGame/ui/UIWpnParams.h index 39396581be4..d1a3ee8a9e3 100644 --- a/src/xrGame/ui/UIWpnParams.h +++ b/src/xrGame/ui/UIWpnParams.h @@ -23,23 +23,23 @@ class CUIWpnParams : public CUIWindow CUIDoubleProgressBar m_progressDamage; CUIDoubleProgressBar m_progressRPM; - CUIStatic m_icon_acc; - CUIStatic m_icon_dam; - CUIStatic m_icon_han; - CUIStatic m_icon_rpm; + CUIStatic* m_icon_acc; + CUIStatic* m_icon_dam; + CUIStatic* m_icon_han; + CUIStatic* m_icon_rpm; - CUIStatic m_stAmmo; + CUIStatic* m_stAmmo; CUITextWnd m_textAccuracy; CUITextWnd m_textHandling; CUITextWnd m_textDamage; CUITextWnd m_textRPM; CUITextWnd* m_textAmmoTypes; CUITextWnd* m_textAmmoUsedType; - CUITextWnd m_textAmmoCount; - CUITextWnd m_textAmmoCount2; + CUITextWnd* m_textAmmoCount; + CUITextWnd* m_textAmmoCount2; CUIStatic* m_stAmmoType1; CUIStatic* m_stAmmoType2; - CUIStatic m_Prop_line; + CUIStatic* m_Prop_line; }; // -------------------------------------------------------------------------------------------------