From ac0b61e455a72d7773838144550f46b9b4932abb Mon Sep 17 00:00:00 2001
From: Amx545 <41252768+Amx545@users.noreply.github.com>
Date: Sun, 9 Jun 2024 13:23:56 +0300
Subject: [PATCH 1/5] Changing booster_indicator
Dynamic position of boost icons
---
res/gamedata/configs/ui/maingame.xml | 194 +++++++++++++++++++++
res/gamedata/configs/ui/maingame_16.xml | 198 ++++++++++++++++++++++
src/xrGame/ui/UIBoostStatesWnd.cpp | 102 ++++++++++++
src/xrGame/ui/UIBoostStatesWnd.h | 22 +++
src/xrGame/ui/UIMainIngameWnd.cpp | 213 ++----------------------
src/xrGame/ui/UIMainIngameWnd.h | 12 +-
src/xrGame/xrGame.vcxproj | 2 +
src/xrGame/xrGame.vcxproj.filters | 6 +
8 files changed, 536 insertions(+), 213 deletions(-)
create mode 100644 res/gamedata/configs/ui/maingame.xml
create mode 100644 res/gamedata/configs/ui/maingame_16.xml
create mode 100644 src/xrGame/ui/UIBoostStatesWnd.cpp
create mode 100644 src/xrGame/ui/UIBoostStatesWnd.h
diff --git a/res/gamedata/configs/ui/maingame.xml b/res/gamedata/configs/ui/maingame.xml
new file mode 100644
index 00000000000..d6a9f76fa4d
--- /dev/null
+++ b/res/gamedata/configs/ui/maingame.xml
@@ -0,0 +1,194 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+ ui_hud_icon_weapon
+
+
+
+
+
+
+
+
+
+
+
+
+ ui_inGame2_shield_Psy
+
+
+ ui_inGame2_shield_Radiation
+
+
+ ui_inGame2_shield_biological
+
+
+ ui_inGame2_shield_blood
+
+
+ ui_inGame2_shield_force
+
+
+ ui_inGame2_shield_health
+
+
+ ui_inGame2_shield_stamina
+
+
+ ui_inGame2_shield_radiation_cleanup
+
+
+
+
+ ui_hud_icon_goodmode
+
+
+
+ ui_hud_icon_artefact
+
+
+
+
+
+
+
+
+ ui_hud_icon_PDA
+
+
+
+
+
+ detectors\contact_1
+
+
+
+ counter
+ ui_item_count_back
+
+
+
+ ui_inGame2_Patroni_HUD_active_items_icon
+
+
+
+
+ counter
+ ui_item_count_back
+
+
+
+ ui_inGame2_Patroni_HUD_active_items_icon
+
+
+
+
+ counter
+ ui_item_count_back
+
+
+
+ ui_inGame2_Patroni_HUD_active_items_icon
+
+
+
+
+ counter
+ ui_item_count_back
+
+
+
+ ui_inGame2_Patroni_HUD_active_items_icon
+
+
+
+ quick_use_str_1
+
+
+ quick_use_str_2
+
+
+ quick_use_str_3
+
+
+ quick_use_str_4
+
+
+
+
+
+
+
+
+
+
+
+ ui_inGame2_Patroni_HUD_main_window
+
+
+
+
+
+
+
+
+
+
+ ammo
+
+
+
+ fmj
+
+
+
+ ap
+
+
+
+ gr
+
+
+
+
+
+
+
+
+
+
+
diff --git a/res/gamedata/configs/ui/maingame_16.xml b/res/gamedata/configs/ui/maingame_16.xml
new file mode 100644
index 00000000000..1b9ca2a0bc8
--- /dev/null
+++ b/res/gamedata/configs/ui/maingame_16.xml
@@ -0,0 +1,198 @@
+
+
+ <_auto_static x="512" y="384" width="115" height="115" alignment="c" stretch="1" heading="1" xform_anim="xfrom_rotate_3sec" xform_anim_cyclic="1">
+ ui_icons_newPDA_Crclbig_h
+
+
+
+
+
+
+
+
+
+
+
+
+
+ ui_hud_icon_weapon
+
+
+
+
+
+
+
+
+
+
+
+
+ ui_inGame2_shield_Psy
+
+
+ ui_inGame2_shield_Radiation
+
+
+ ui_inGame2_shield_biological
+
+
+ ui_inGame2_shield_blood
+
+
+ ui_inGame2_shield_force
+
+
+ ui_inGame2_shield_health
+
+
+ ui_inGame2_shield_stamina
+
+
+ ui_inGame2_shield_radiation_cleanup
+
+
+
+
+ ui_hud_icon_goodmode
+
+
+
+ ui_hud_icon_artefact
+
+
+
+
+
+
+
+
+ ui_hud_icon_PDA
+
+
+
+
+
+ detectors\contact_1
+
+
+
+ counter
+ ui_item_count_back
+
+
+
+ ui_inGame2_Patroni_HUD_active_items_icon
+
+
+
+
+ counter
+ ui_item_count_back
+
+
+
+ ui_inGame2_Patroni_HUD_active_items_icon
+
+
+
+
+ counter
+ ui_item_count_back
+
+
+
+ ui_inGame2_Patroni_HUD_active_items_icon
+
+
+
+
+ counter
+ ui_item_count_back
+
+
+
+ ui_inGame2_Patroni_HUD_active_items_icon
+
+
+
+ quick_use_str_1
+
+
+ quick_use_str_2
+
+
+ quick_use_str_3
+
+
+ quick_use_str_4
+
+
+
+
+
+
+
+
+
+
+ ui_inGame2_Patroni_HUD_main_window
+
+
+
+
+
+
+
+
+
+
+
+ ammo
+
+
+
+ fmj
+
+
+
+ ap
+
+
+
+ gr
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/xrGame/ui/UIBoostStatesWnd.cpp b/src/xrGame/ui/UIBoostStatesWnd.cpp
new file mode 100644
index 00000000000..2222da203f1
--- /dev/null
+++ b/src/xrGame/ui/UIBoostStatesWnd.cpp
@@ -0,0 +1,102 @@
+#include "StdAfx.h"
+#include "UIBoostStatesWnd.h"
+#include "UIHelper.h"
+
+CUIBoostStatesWnd::CUIBoostStatesWnd()
+ : CUIWindow(CUIBoostStatesWnd::GetDebugType()) {}
+
+void CUIBoostStatesWnd::InitFromXml(CUIXml& xml, LPCSTR path)
+{
+ ZoneScoped;
+
+ CUIXmlInit::InitWindow(xml, path, 0, this);
+ XML_NODE stored_root = xml.GetLocalRoot();
+
+ XML_NODE new_root = xml.NavigateToNode(path, 0);
+ xml.SetLocalRoot(new_root);
+ dx = CUIBoostStatesWnd::GetWidth();
+ dy = CUIBoostStatesWnd::GetHeight();
+ constexpr std::tuple booster_list[] = {
+ {eBoostHpRestore, "indicator_booster_health"},
+ {eBoostPowerRestore, "indicator_booster_power"},
+ {eBoostRadiationRestore, "indicator_booster_rad"},
+ {eBoostBleedingRestore, "indicator_booster_wound"},
+ {eBoostMaxWeight, "indicator_booster_weight"},
+ {eBoostRadiationProtection, "indicator_booster_radia"},
+ {eBoostTelepaticProtection, "indicator_booster_psy"},
+ {eBoostChemicalBurnProtection, "indicator_booster_chem"}
+ };
+ for (auto [type, tpath] : booster_list)
+ {
+ CUIStatic* booster;
+ booster = UIHelper::CreateStatic(xml, tpath, this, false);
+ m_ind_boost_state.emplace(type, booster);
+ }
+ xml.SetLocalRoot(stored_root);
+}
+
+void CUIBoostStatesWnd::DrawBoosterIndicators()
+{
+ for (const auto& Iter : m_ind_boost_state)
+ {
+ if (Iter.second && Iter.second->IsShown())
+ {
+ Iter.second->Update();
+ Iter.second->Draw();
+ }
+ }
+}
+
+void CUIBoostStatesWnd::UpdateBoosterIndicators(const CEntityCondition::BOOSTER_MAP& influences)
+{
+ LPCSTR str_flag = "ui_slow_blinking_alpha";
+ u8 flags = 0;
+ flags |= LA_CYCLIC;
+ flags |= LA_ONLYALPHA;
+ flags |= LA_TEXTURECOLOR;
+
+ for (const auto& [type, item] : m_ind_boost_state)
+ {
+ if (influences.count(type) && !influences.empty())
+ {
+ if (!m_ind_boost_state[type]->IsShown())
+ {
+ m_ind_boost_pos.push_back(type);
+ m_ind_boost_state[type]->Show(true);
+ }
+ if (influences.find(type)->second.fBoostTime <= 3.0f)
+ {
+ m_ind_boost_state[type]->SetColorAnimation(str_flag, flags);
+ }
+ else
+ {
+ m_ind_boost_state[type]->ResetColorAnimation();
+ }
+ }
+ else
+ {
+ m_ind_boost_state[type]->Show(false);
+ }
+ }
+ if (!m_ind_boost_pos.empty())
+ {
+ bool rev_add = false;
+ int i = 0;
+ Fvector2 p = pos;
+ for (auto It = m_ind_boost_pos.begin(); It != m_ind_boost_pos.end(); It++)
+ {
+ if (m_ind_boost_state[*It]->IsShown())
+ {
+ m_ind_boost_state[*It]->SetWndPos({p.x + dx * i, p.y});
+ i++;
+ m_ind_boost_state[*It]->Update();
+ m_ind_boost_state[*It]->Draw();
+ }
+ else
+ {
+ m_ind_boost_pos.erase(It);
+ It--;
+ }
+ }
+ }
+}
diff --git a/src/xrGame/ui/UIBoostStatesWnd.h b/src/xrGame/ui/UIBoostStatesWnd.h
new file mode 100644
index 00000000000..9c065321d19
--- /dev/null
+++ b/src/xrGame/ui/UIBoostStatesWnd.h
@@ -0,0 +1,22 @@
+#pragma once
+#include "xrUICore/Windows/UIWindow.h"
+#include "EntityCondition.h"
+
+
+class CUIStatic;
+class CUIXml;
+
+class CUIBoostStatesWnd final : public CUIWindow
+{
+public:
+ CUIBoostStatesWnd();
+ void InitFromXml(CUIXml& xml, LPCSTR path);
+ void DrawBoosterIndicators();
+ void UpdateBoosterIndicators(const CEntityCondition::BOOSTER_MAP& influences);
+
+private:
+ float dx, dy = 0.f;
+ Fvector2 pos = {0.f, 0.f};
+ xr_vector m_ind_boost_pos;
+ xr_map m_ind_boost_state;
+};
diff --git a/src/xrGame/ui/UIMainIngameWnd.cpp b/src/xrGame/ui/UIMainIngameWnd.cpp
index ce485230f4d..85c15baf03c 100644
--- a/src/xrGame/ui/UIMainIngameWnd.cpp
+++ b/src/xrGame/ui/UIMainIngameWnd.cpp
@@ -43,6 +43,7 @@
#include "UIActorMenu.h"
#include "xrUICore/ProgressBar/UIProgressShape.h"
#include "UIArtefactPanel.h"
+#include "UIBoostStatesWnd.h"
#include "Include/xrRender/Kinematics.h"
@@ -120,29 +121,6 @@ void CUIMainIngameWnd::Init()
m_ind_outfit_broken = UIHelper::CreateStatic(uiXml, "indicator_outfit_broken", this, false);
m_ind_overweight = UIHelper::CreateStatic(uiXml, "indicator_overweight", this, false);
- if ((m_ind_boost_psy = UIHelper::CreateStatic(uiXml, "indicator_booster_psy", this, false)))
- m_ind_boost_psy->Show(false);
-
- if ((m_ind_boost_radia = UIHelper::CreateStatic(uiXml, "indicator_booster_radia", this, false)))
- m_ind_boost_radia->Show(false);
-
- if ((m_ind_boost_chem = UIHelper::CreateStatic(uiXml, "indicator_booster_chem", this, false)))
- m_ind_boost_chem->Show(false);
-
- if ((m_ind_boost_wound = UIHelper::CreateStatic(uiXml, "indicator_booster_wound", this, false)))
- m_ind_boost_wound->Show(false);
-
- if ((m_ind_boost_weight = UIHelper::CreateStatic(uiXml, "indicator_booster_weight", this, false)))
- m_ind_boost_weight->Show(false);
-
- if ((m_ind_boost_health = UIHelper::CreateStatic(uiXml, "indicator_booster_health", this, false)))
- m_ind_boost_health->Show(false);
-
- if ((m_ind_boost_power = UIHelper::CreateStatic(uiXml, "indicator_booster_power", this, false)))
- m_ind_boost_power->Show(false);
-
- if ((m_ind_boost_rad = UIHelper::CreateStatic(uiXml, "indicator_booster_rad", this, false)))
- m_ind_boost_rad->Show(false);
// Загружаем иконки
/* if ( IsGameTypeSingle() )
@@ -255,6 +233,11 @@ void CUIMainIngameWnd::Init()
i++;
}
+ m_ui_boost_states = xr_new();
+ m_ui_boost_states->SetAutoDelete(true);
+ AttachChild(m_ui_boost_states);
+ m_ui_boost_states->InitFromXml(uiXml, "booster_states");
+
HUD_SOUND_ITEM::LoadSound("maingame_ui", "snd_new_contact", m_contactSnd, SOUND_TYPE_IDLE);
}
@@ -891,193 +874,17 @@ void CUIMainIngameWnd::DrawMainIndicatorsForInventory()
return;
UpdateQuickSlots();
- UpdateBoosterIndicators(pActor->conditions().GetCurBoosterInfluences());
+ m_ui_boost_states->UpdateBoosterIndicators(pActor->conditions().GetCurBoosterInfluences());
for (const auto& slot : m_quick_slots_icons)
slot->Draw();
for (const auto& slot : m_quick_slots_texts)
slot->Draw();
-
- if (m_ind_boost_psy && m_ind_boost_psy->IsShown())
- {
- m_ind_boost_psy->Update();
- m_ind_boost_psy->Draw();
- }
-
- if (m_ind_boost_radia && m_ind_boost_radia->IsShown())
- {
- m_ind_boost_radia->Update();
- m_ind_boost_radia->Draw();
- }
-
- if (m_ind_boost_chem && m_ind_boost_chem->IsShown())
- {
- m_ind_boost_chem->Update();
- m_ind_boost_chem->Draw();
- }
-
- if (m_ind_boost_wound && m_ind_boost_wound->IsShown())
- {
- m_ind_boost_wound->Update();
- m_ind_boost_wound->Draw();
- }
-
- if (m_ind_boost_weight && m_ind_boost_weight->IsShown())
- {
- m_ind_boost_weight->Update();
- m_ind_boost_weight->Draw();
- }
-
- if (m_ind_boost_health && m_ind_boost_health->IsShown())
- {
- m_ind_boost_health->Update();
- m_ind_boost_health->Draw();
- }
-
- if (m_ind_boost_power && m_ind_boost_power->IsShown())
- {
- m_ind_boost_power->Update();
- m_ind_boost_power->Draw();
- }
-
- if (m_ind_boost_rad && m_ind_boost_rad->IsShown())
- {
- m_ind_boost_rad->Update();
- m_ind_boost_rad->Draw();
- }
-
+ m_ui_boost_states->DrawBoosterIndicators();
m_ui_hud_states->DrawZoneIndicators();
}
-
-void CUIMainIngameWnd::UpdateBoosterIndicators(const CEntityCondition::BOOSTER_MAP& influences)
+void CUIMainIngameWnd::UpdateBoosterIndicators(const CEntityCondition::BOOSTER_MAP& influences)
{
- if (m_ind_boost_psy)
- m_ind_boost_psy->Show(false);
- if (m_ind_boost_radia)
- m_ind_boost_radia->Show(false);
- if (m_ind_boost_chem)
- m_ind_boost_chem->Show(false);
- if (m_ind_boost_wound)
- m_ind_boost_wound->Show(false);
- if (m_ind_boost_weight)
- m_ind_boost_weight->Show(false);
- if (m_ind_boost_health)
- m_ind_boost_health->Show(false);
- if (m_ind_boost_power)
- m_ind_boost_power->Show(false);
- if (m_ind_boost_rad)
- m_ind_boost_rad->Show(false);
-
- LPCSTR str_flag = "ui_slow_blinking_alpha";
- u8 flags = 0;
- flags |= LA_CYCLIC;
- flags |= LA_ONLYALPHA;
- flags |= LA_TEXTURECOLOR;
-
- for(const auto& [_, booster] : influences)
- {
- switch (booster.m_type)
- {
- case eBoostHpRestore:
- {
- if (m_ind_boost_health)
- {
- m_ind_boost_health->Show(true);
- if (booster.fBoostTime <= 3.0f)
- m_ind_boost_health->SetColorAnimation(str_flag, flags);
- else
- m_ind_boost_health->ResetColorAnimation();
- }
- break;
- }
- case eBoostPowerRestore:
- {
- if (m_ind_boost_power)
- {
- m_ind_boost_power->Show(true);
- if (booster.fBoostTime <= 3.0f)
- m_ind_boost_power->SetColorAnimation(str_flag, flags);
- else
- m_ind_boost_power->ResetColorAnimation();
- }
- break;
- }
- case eBoostRadiationRestore:
- {
- if (m_ind_boost_rad)
- {
- m_ind_boost_rad->Show(true);
- if (booster.fBoostTime <= 3.0f)
- m_ind_boost_rad->SetColorAnimation(str_flag, flags);
- else
- m_ind_boost_rad->ResetColorAnimation();
- }
- break;
- }
- case eBoostBleedingRestore:
- {
- if (m_ind_boost_wound)
- {
- m_ind_boost_wound->Show(true);
- if (booster.fBoostTime <= 3.0f)
- m_ind_boost_wound->SetColorAnimation(str_flag, flags);
- else
- m_ind_boost_wound->ResetColorAnimation();
- }
- break;
- }
- case eBoostMaxWeight:
- {
- if (m_ind_boost_weight)
- {
- m_ind_boost_weight->Show(true);
- if (booster.fBoostTime <= 3.0f)
- m_ind_boost_weight->SetColorAnimation(str_flag, flags);
- else
- m_ind_boost_weight->ResetColorAnimation();
- }
- break;
- }
- case eBoostRadiationImmunity:
- case eBoostRadiationProtection:
- {
- if (m_ind_boost_radia)
- {
- m_ind_boost_radia->Show(true);
- if (booster.fBoostTime <= 3.0f)
- m_ind_boost_radia->SetColorAnimation(str_flag, flags);
- else
- m_ind_boost_radia->ResetColorAnimation();
- }
- break;
- }
- case eBoostTelepaticImmunity:
- case eBoostTelepaticProtection:
- {
- if (m_ind_boost_psy)
- {
- m_ind_boost_psy->Show(true);
- if (booster.fBoostTime <= 3.0f)
- m_ind_boost_psy->SetColorAnimation(str_flag, flags);
- else
- m_ind_boost_psy->ResetColorAnimation();
- }
- break;
- }
- case eBoostChemicalBurnImmunity:
- case eBoostChemicalBurnProtection:
- {
- if (m_ind_boost_chem)
- {
- m_ind_boost_chem->Show(true);
- if (booster.fBoostTime <= 3.0f)
- m_ind_boost_chem->SetColorAnimation(str_flag, flags);
- else
- m_ind_boost_chem->ResetColorAnimation();
- }
- break;
- }
- }
- }
+ m_ui_boost_states->UpdateBoosterIndicators(influences);
}
diff --git a/src/xrGame/ui/UIMainIngameWnd.h b/src/xrGame/ui/UIMainIngameWnd.h
index ee25106e5c9..325f38993a3 100644
--- a/src/xrGame/ui/UIMainIngameWnd.h
+++ b/src/xrGame/ui/UIMainIngameWnd.h
@@ -14,7 +14,7 @@ class CInventoryItem;
class CUIHudStatesWnd;
class CUIMotionIcon;
class CUIArtefactPanel;
-
+class CUIBoostStatesWnd;
class CUIMainIngameWnd final : public CUIWindow
{
public:
@@ -34,6 +34,7 @@ class CUIMainIngameWnd final : public CUIWindow
CUIZoneMap* UIZoneMap{};
CUIHudStatesWnd* m_ui_hud_states{};
+ CUIBoostStatesWnd* m_ui_boost_states{};
CUIStatic* m_ind_bleeding{};
CUIStatic* m_ind_radiation{};
@@ -44,15 +45,6 @@ class CUIMainIngameWnd final : public CUIWindow
CUIStatic* m_ind_overweight{};
public:
- CUIStatic* m_ind_boost_psy{};
- CUIStatic* m_ind_boost_radia{};
- CUIStatic* m_ind_boost_chem{};
- CUIStatic* m_ind_boost_wound{};
- CUIStatic* m_ind_boost_weight{};
- CUIStatic* m_ind_boost_health{};
- CUIStatic* m_ind_boost_power{};
- CUIStatic* m_ind_boost_rad{};
-
CUIArtefactPanel* UIArtefactPanel{};
void ShowZoneMap(bool status);
diff --git a/src/xrGame/xrGame.vcxproj b/src/xrGame/xrGame.vcxproj
index 762c7b46e36..fb3520cbd77 100644
--- a/src/xrGame/xrGame.vcxproj
+++ b/src/xrGame/xrGame.vcxproj
@@ -1307,6 +1307,7 @@
+
@@ -3227,6 +3228,7 @@
+
diff --git a/src/xrGame/xrGame.vcxproj.filters b/src/xrGame/xrGame.vcxproj.filters
index ba820c81759..a973f949968 100644
--- a/src/xrGame/xrGame.vcxproj.filters
+++ b/src/xrGame/xrGame.vcxproj.filters
@@ -6495,6 +6495,9 @@
Core\Client\Objects\items & weapons\HudItem
+
+ UI\Common\MainIngame
+
@@ -9854,6 +9857,9 @@
UI\Common\PDA\Tasks
+
+ UI\Common\MainIngame
+
From e14b5b7d04c27de5bc3eef68acd5aa9c3e5f91fb Mon Sep 17 00:00:00 2001
From: Amx545 <41252768+Amx545@users.noreply.github.com>
Date: Mon, 10 Jun 2024 20:04:55 +0300
Subject: [PATCH 2/5] Changing booster_indicator
Added settings:
Distance from indicators
Vertical/horizontal alignment
Inversion insert
Maximum number of indicators in a row (column if vertical)
---
res/gamedata/configs/ui/maingame.xml | 1 +
res/gamedata/configs/ui/maingame_16.xml | 1 +
src/xrGame/ui/UIBoostStatesWnd.cpp | 98 +++++++++++++++++++------
src/xrGame/ui/UIBoostStatesWnd.h | 5 +-
4 files changed, 81 insertions(+), 24 deletions(-)
diff --git a/res/gamedata/configs/ui/maingame.xml b/res/gamedata/configs/ui/maingame.xml
index d6a9f76fa4d..48f638506f8 100644
--- a/res/gamedata/configs/ui/maingame.xml
+++ b/res/gamedata/configs/ui/maingame.xml
@@ -23,6 +23,7 @@
+
ui_inGame2_shield_Psy
diff --git a/res/gamedata/configs/ui/maingame_16.xml b/res/gamedata/configs/ui/maingame_16.xml
index 1b9ca2a0bc8..fd37c9b1117 100644
--- a/res/gamedata/configs/ui/maingame_16.xml
+++ b/res/gamedata/configs/ui/maingame_16.xml
@@ -27,6 +27,7 @@
+
ui_inGame2_shield_Psy
diff --git a/src/xrGame/ui/UIBoostStatesWnd.cpp b/src/xrGame/ui/UIBoostStatesWnd.cpp
index 2222da203f1..212cdcae8de 100644
--- a/src/xrGame/ui/UIBoostStatesWnd.cpp
+++ b/src/xrGame/ui/UIBoostStatesWnd.cpp
@@ -3,7 +3,14 @@
#include "UIHelper.h"
CUIBoostStatesWnd::CUIBoostStatesWnd()
- : CUIWindow(CUIBoostStatesWnd::GetDebugType()) {}
+ : CUIWindow(CUIBoostStatesWnd::GetDebugType())
+{
+ bHorizontal = true;
+ bInverse = false;
+ dx = 0.f;
+ dy = 0.f;
+ max_item = 8;
+}
void CUIBoostStatesWnd::InitFromXml(CUIXml& xml, LPCSTR path)
{
@@ -14,8 +21,12 @@ void CUIBoostStatesWnd::InitFromXml(CUIXml& xml, LPCSTR path)
XML_NODE new_root = xml.NavigateToNode(path, 0);
xml.SetLocalRoot(new_root);
- dx = CUIBoostStatesWnd::GetWidth();
- dy = CUIBoostStatesWnd::GetHeight();
+
+ dx = xml.ReadAttribFlt("settings", 0, "dx", GetWidth());
+ dy = xml.ReadAttribFlt("settings", 0, "dy", GetHeight());
+ bHorizontal = (xml.ReadAttribInt("settings", 0, "horz_align", 1) == 1);
+ bInverse = (xml.ReadAttribInt("settings", 0, "inverse", 0) == 1);
+ max_item = xml.ReadAttribInt("settings", 0, "max_item", 8);
constexpr std::tuple booster_list[] = {
{eBoostHpRestore, "indicator_booster_health"},
{eBoostPowerRestore, "indicator_booster_power"},
@@ -57,45 +68,88 @@ void CUIBoostStatesWnd::UpdateBoosterIndicators(const CEntityCondition::BOOSTER_
for (const auto& [type, item] : m_ind_boost_state)
{
- if (influences.count(type) && !influences.empty())
+ if (influences.empty())
+ {
+ item->Show(false);
+ continue;
+ }
+ CEntityCondition::BOOSTER_MAP::const_iterator It = influences.find(type);
+ if (It != influences.end())
{
- if (!m_ind_boost_state[type]->IsShown())
+ if (!item->IsShown())
{
m_ind_boost_pos.push_back(type);
- m_ind_boost_state[type]->Show(true);
+ item->Show(true);
}
- if (influences.find(type)->second.fBoostTime <= 3.0f)
+ if (It->second.fBoostTime <= 3.0f)
{
- m_ind_boost_state[type]->SetColorAnimation(str_flag, flags);
+ item->SetColorAnimation(str_flag, flags);
}
else
{
- m_ind_boost_state[type]->ResetColorAnimation();
+ item->ResetColorAnimation();
}
}
else
{
- m_ind_boost_state[type]->Show(false);
+ item->Show(false);
}
}
+
if (!m_ind_boost_pos.empty())
{
- bool rev_add = false;
- int i = 0;
- Fvector2 p = pos;
- for (auto It = m_ind_boost_pos.begin(); It != m_ind_boost_pos.end(); It++)
+ u8 i = 0,j = 0,max = max_item - 1;
+ if (bInverse)
{
- if (m_ind_boost_state[*It]->IsShown())
+ for (auto It = m_ind_boost_pos.end() - 1; It >= m_ind_boost_pos.begin(); It--)
{
- m_ind_boost_state[*It]->SetWndPos({p.x + dx * i, p.y});
- i++;
- m_ind_boost_state[*It]->Update();
- m_ind_boost_state[*It]->Draw();
+ if (m_ind_boost_state[*It]->IsShown())
+ {
+ (bHorizontal ? m_ind_boost_state[*It]->SetWndPos({dx * i, dy * j}) :
+ m_ind_boost_state[*It]->SetWndPos({dx * j, dy * i}));
+ if (i >= max_item)
+ {
+ i = 0;
+ j++;
+ }
+ else
+ {
+ i++;
+ }
+ m_ind_boost_state[*It]->Update();
+ m_ind_boost_state[*It]->Draw();
+ }
+ else
+ {
+ m_ind_boost_pos.erase(It);
+ }
}
- else
+ }
+ else
+ {
+ for (auto It = m_ind_boost_pos.begin(); It != m_ind_boost_pos.end(); It++)
{
- m_ind_boost_pos.erase(It);
- It--;
+ if (m_ind_boost_state[*It]->IsShown())
+ {
+ (bHorizontal ? m_ind_boost_state[*It]->SetWndPos({dx * i, dy * j}) :
+ m_ind_boost_state[*It]->SetWndPos({dx * j, dy * i}));
+ if (i >= max)
+ {
+ i = 0;
+ j++;
+ }
+ else
+ {
+ i++;
+ }
+ m_ind_boost_state[*It]->Update();
+ m_ind_boost_state[*It]->Draw();
+ }
+ else
+ {
+ m_ind_boost_pos.erase(It);
+ It--;
+ }
}
}
}
diff --git a/src/xrGame/ui/UIBoostStatesWnd.h b/src/xrGame/ui/UIBoostStatesWnd.h
index 9c065321d19..dd98d690dce 100644
--- a/src/xrGame/ui/UIBoostStatesWnd.h
+++ b/src/xrGame/ui/UIBoostStatesWnd.h
@@ -15,8 +15,9 @@ class CUIBoostStatesWnd final : public CUIWindow
void UpdateBoosterIndicators(const CEntityCondition::BOOSTER_MAP& influences);
private:
- float dx, dy = 0.f;
- Fvector2 pos = {0.f, 0.f};
+ bool bHorizontal, bInverse;
+ float dx, dy;
+ u8 max_item;
xr_vector m_ind_boost_pos;
xr_map m_ind_boost_state;
};
From ac865dfee75e0dd2c407088031957635e49ce4ff Mon Sep 17 00:00:00 2001
From: Amx545 <41252768+Amx545@users.noreply.github.com>
Date: Sun, 16 Jun 2024 17:04:05 +0300
Subject: [PATCH 3/5] Bug fix
fix bug when level changing
---
src/xrGame/ui/UIBoostStatesWnd.cpp | 118 +++++++++++++++++------------
src/xrGame/ui/UIBoostStatesWnd.h | 1 +
2 files changed, 70 insertions(+), 49 deletions(-)
diff --git a/src/xrGame/ui/UIBoostStatesWnd.cpp b/src/xrGame/ui/UIBoostStatesWnd.cpp
index 212cdcae8de..50fba3d19b7 100644
--- a/src/xrGame/ui/UIBoostStatesWnd.cpp
+++ b/src/xrGame/ui/UIBoostStatesWnd.cpp
@@ -46,14 +46,16 @@ void CUIBoostStatesWnd::InitFromXml(CUIXml& xml, LPCSTR path)
xml.SetLocalRoot(stored_root);
}
-void CUIBoostStatesWnd::DrawBoosterIndicators()
+void CUIBoostStatesWnd::DrawBoosterIndicators()
{
- for (const auto& Iter : m_ind_boost_state)
+ if (m_ind_boost_pos.empty())
+ return;
+ for (const auto& [type, Item] : m_ind_boost_state)
{
- if (Iter.second && Iter.second->IsShown())
+ if (Item && Item->IsShown())
{
- Iter.second->Update();
- Iter.second->Draw();
+ Item->Update();
+ Item->Draw();
}
}
}
@@ -66,90 +68,108 @@ void CUIBoostStatesWnd::UpdateBoosterIndicators(const CEntityCondition::BOOSTER_
flags |= LA_ONLYALPHA;
flags |= LA_TEXTURECOLOR;
- for (const auto& [type, item] : m_ind_boost_state)
+ for (const auto& [type, Item] : m_ind_boost_state)
{
if (influences.empty())
{
- item->Show(false);
+ Item->Show(false);
continue;
}
CEntityCondition::BOOSTER_MAP::const_iterator It = influences.find(type);
if (It != influences.end())
{
- if (!item->IsShown())
+ if (!Item->IsShown())
{
m_ind_boost_pos.push_back(type);
- item->Show(true);
+ Item->Show(true);
}
if (It->second.fBoostTime <= 3.0f)
{
- item->SetColorAnimation(str_flag, flags);
+ Item->SetColorAnimation(str_flag, flags);
}
else
{
- item->ResetColorAnimation();
+ Item->ResetColorAnimation();
}
}
else
{
- item->Show(false);
+ Item->Show(false);
}
}
+ if(!influences.empty() || !m_ind_boost_pos.empty())
+ {
+ UpdateBoosterPosition(influences);
+ }
+}
- if (!m_ind_boost_pos.empty())
+void CUIBoostStatesWnd::UpdateBoosterPosition(const CEntityCondition::BOOSTER_MAP& influences)
+{
+ if (m_ind_boost_pos.empty() && !influences.empty())
+ {
+ for (const auto& [type, Item] : m_ind_boost_state)
+ {
+ if (Item && Item->IsShown())
+ {
+ Item->Show(false);
+ }
+ }
+ }
+ if (m_ind_boost_pos.empty())
+ return;
+ u8 i = 0, j = 0, max = max_item - 1;
+ if (bInverse)
{
- u8 i = 0,j = 0,max = max_item - 1;
- if (bInverse)
+ for (auto It = m_ind_boost_pos.end() - 1; It >= m_ind_boost_pos.begin(); It--)
{
- for (auto It = m_ind_boost_pos.end() - 1; It >= m_ind_boost_pos.begin(); It--)
+ xr_map::const_iterator Item = m_ind_boost_state.find(*It);
+ if (Item->second->IsShown())
{
- if (m_ind_boost_state[*It]->IsShown())
+ (bHorizontal ? Item->second->SetWndPos({dx * i, dy * j}) :
+ Item->second->SetWndPos({dx * j, dy * i}));
+ if (i >= max_item)
{
- (bHorizontal ? m_ind_boost_state[*It]->SetWndPos({dx * i, dy * j}) :
- m_ind_boost_state[*It]->SetWndPos({dx * j, dy * i}));
- if (i >= max_item)
- {
- i = 0;
- j++;
- }
- else
- {
- i++;
- }
- m_ind_boost_state[*It]->Update();
- m_ind_boost_state[*It]->Draw();
+ i = 0;
+ j++;
}
else
{
- m_ind_boost_pos.erase(It);
+ i++;
}
+ Item->second->Update();
+ Item->second->Draw();
+ }
+ else
+ {
+ m_ind_boost_pos.erase(It);
}
}
- else
+ }
+ else
+ {
+ for (auto It = m_ind_boost_pos.begin(); It != m_ind_boost_pos.end(); It++)
{
- for (auto It = m_ind_boost_pos.begin(); It != m_ind_boost_pos.end(); It++)
+ xr_map::const_iterator Item = m_ind_boost_state.find(*It);
+ if (Item->second->IsShown())
{
- if (m_ind_boost_state[*It]->IsShown())
+ (bHorizontal ? Item->second->SetWndPos({dx * i, dy * j}) :
+ Item->second->SetWndPos({dx * j, dy * i}));
+ if (i >= max)
{
- (bHorizontal ? m_ind_boost_state[*It]->SetWndPos({dx * i, dy * j}) :
- m_ind_boost_state[*It]->SetWndPos({dx * j, dy * i}));
- if (i >= max)
- {
- i = 0;
- j++;
- }
- else
- {
- i++;
- }
- m_ind_boost_state[*It]->Update();
- m_ind_boost_state[*It]->Draw();
+ i = 0;
+ j++;
}
else
{
- m_ind_boost_pos.erase(It);
- It--;
+ i++;
}
+ Item->second->Update();
+ Item->second->Draw();
+ }
+ else
+ {
+ m_ind_boost_pos.erase(It);
+ It--;
}
}
}
diff --git a/src/xrGame/ui/UIBoostStatesWnd.h b/src/xrGame/ui/UIBoostStatesWnd.h
index dd98d690dce..7c3c00986d7 100644
--- a/src/xrGame/ui/UIBoostStatesWnd.h
+++ b/src/xrGame/ui/UIBoostStatesWnd.h
@@ -13,6 +13,7 @@ class CUIBoostStatesWnd final : public CUIWindow
void InitFromXml(CUIXml& xml, LPCSTR path);
void DrawBoosterIndicators();
void UpdateBoosterIndicators(const CEntityCondition::BOOSTER_MAP& influences);
+ void UpdateBoosterPosition(const CEntityCondition::BOOSTER_MAP& influences);
private:
bool bHorizontal, bInverse;
From 2f516a0a0043c2b4491dc84f0ea985cb6582d50c Mon Sep 17 00:00:00 2001
From: Amx545 <41252768+Amx545@users.noreply.github.com>
Date: Mon, 17 Jun 2024 09:42:35 +0300
Subject: [PATCH 4/5] updating code
---
src/xrGame/ui/UIBoostStatesWnd.cpp | 88 +++++++++++++++---------------
src/xrGame/ui/UIBoostStatesWnd.h | 6 +-
2 files changed, 47 insertions(+), 47 deletions(-)
diff --git a/src/xrGame/ui/UIBoostStatesWnd.cpp b/src/xrGame/ui/UIBoostStatesWnd.cpp
index 50fba3d19b7..f2574a306bb 100644
--- a/src/xrGame/ui/UIBoostStatesWnd.cpp
+++ b/src/xrGame/ui/UIBoostStatesWnd.cpp
@@ -9,7 +9,7 @@ CUIBoostStatesWnd::CUIBoostStatesWnd()
bInverse = false;
dx = 0.f;
dy = 0.f;
- max_item = 8;
+ maxItem = 8;
}
void CUIBoostStatesWnd::InitFromXml(CUIXml& xml, LPCSTR path)
@@ -26,7 +26,7 @@ void CUIBoostStatesWnd::InitFromXml(CUIXml& xml, LPCSTR path)
dy = xml.ReadAttribFlt("settings", 0, "dy", GetHeight());
bHorizontal = (xml.ReadAttribInt("settings", 0, "horz_align", 1) == 1);
bInverse = (xml.ReadAttribInt("settings", 0, "inverse", 0) == 1);
- max_item = xml.ReadAttribInt("settings", 0, "max_item", 8);
+ maxItem = xml.ReadAttribInt("settings", 0, "max_item", 8);
constexpr std::tuple booster_list[] = {
{eBoostHpRestore, "indicator_booster_health"},
{eBoostPowerRestore, "indicator_booster_power"},
@@ -41,21 +41,21 @@ void CUIBoostStatesWnd::InitFromXml(CUIXml& xml, LPCSTR path)
{
CUIStatic* booster;
booster = UIHelper::CreateStatic(xml, tpath, this, false);
- m_ind_boost_state.emplace(type, booster);
+ indBoostState.emplace(type, booster);
}
xml.SetLocalRoot(stored_root);
}
void CUIBoostStatesWnd::DrawBoosterIndicators()
{
- if (m_ind_boost_pos.empty())
+ if (indBoostPos.empty())
return;
- for (const auto& [type, Item] : m_ind_boost_state)
+ for (const auto& [type, item] : indBoostState)
{
- if (Item && Item->IsShown())
+ if (item && item->IsShown())
{
- Item->Update();
- Item->Draw();
+ item->Update();
+ item->Draw();
}
}
}
@@ -68,36 +68,36 @@ void CUIBoostStatesWnd::UpdateBoosterIndicators(const CEntityCondition::BOOSTER_
flags |= LA_ONLYALPHA;
flags |= LA_TEXTURECOLOR;
- for (const auto& [type, Item] : m_ind_boost_state)
+ for (const auto& [type, item] : indBoostState)
{
if (influences.empty())
{
- Item->Show(false);
+ item->Show(false);
continue;
}
- CEntityCondition::BOOSTER_MAP::const_iterator It = influences.find(type);
- if (It != influences.end())
+ CEntityCondition::BOOSTER_MAP::const_iterator it = influences.find(type);
+ if (it != influences.end())
{
- if (!Item->IsShown())
+ if (!item->IsShown())
{
- m_ind_boost_pos.push_back(type);
- Item->Show(true);
+ indBoostPos.push_back(type);
+ item->Show(true);
}
- if (It->second.fBoostTime <= 3.0f)
+ if (it->second.fBoostTime <= 3.0f)
{
- Item->SetColorAnimation(str_flag, flags);
+ item->SetColorAnimation(str_flag, flags);
}
else
{
- Item->ResetColorAnimation();
+ item->ResetColorAnimation();
}
}
else
{
- Item->Show(false);
+ item->Show(false);
}
}
- if(!influences.empty() || !m_ind_boost_pos.empty())
+ if (!influences.empty() || !indBoostPos.empty())
{
UpdateBoosterPosition(influences);
}
@@ -105,29 +105,29 @@ void CUIBoostStatesWnd::UpdateBoosterIndicators(const CEntityCondition::BOOSTER_
void CUIBoostStatesWnd::UpdateBoosterPosition(const CEntityCondition::BOOSTER_MAP& influences)
{
- if (m_ind_boost_pos.empty() && !influences.empty())
+ if (indBoostPos.empty() && !influences.empty())
{
- for (const auto& [type, Item] : m_ind_boost_state)
+ for (const auto& [type, item] : indBoostState)
{
- if (Item && Item->IsShown())
+ if (item && item->IsShown())
{
- Item->Show(false);
+ item->Show(false);
}
}
}
- if (m_ind_boost_pos.empty())
+ if (indBoostPos.empty())
return;
- u8 i = 0, j = 0, max = max_item - 1;
+ u8 i = 0, j = 0, max = maxItem - 1;
if (bInverse)
{
- for (auto It = m_ind_boost_pos.end() - 1; It >= m_ind_boost_pos.begin(); It--)
+ for (auto it = indBoostPos.end() - 1; it >= indBoostPos.begin(); it--)
{
- xr_map::const_iterator Item = m_ind_boost_state.find(*It);
- if (Item->second->IsShown())
+ xr_map::const_iterator item = indBoostState.find(*it);
+ if (item->second->IsShown())
{
- (bHorizontal ? Item->second->SetWndPos({dx * i, dy * j}) :
- Item->second->SetWndPos({dx * j, dy * i}));
- if (i >= max_item)
+ (bHorizontal ? item->second->SetWndPos({dx * i, dy * j}) :
+ item->second->SetWndPos({dx * j, dy * i}));
+ if (i >= maxItem)
{
i = 0;
j++;
@@ -136,24 +136,24 @@ void CUIBoostStatesWnd::UpdateBoosterPosition(const CEntityCondition::BOOSTER_MA
{
i++;
}
- Item->second->Update();
- Item->second->Draw();
+ item->second->Update();
+ item->second->Draw();
}
else
{
- m_ind_boost_pos.erase(It);
+ indBoostPos.erase(it);
}
}
}
else
{
- for (auto It = m_ind_boost_pos.begin(); It != m_ind_boost_pos.end(); It++)
+ for (auto it = indBoostPos.begin(); it != indBoostPos.end(); it++)
{
- xr_map::const_iterator Item = m_ind_boost_state.find(*It);
- if (Item->second->IsShown())
+ xr_map::const_iterator item = indBoostState.find(*it);
+ if (item->second->IsShown())
{
- (bHorizontal ? Item->second->SetWndPos({dx * i, dy * j}) :
- Item->second->SetWndPos({dx * j, dy * i}));
+ (bHorizontal ? item->second->SetWndPos({dx * i, dy * j}) :
+ item->second->SetWndPos({dx * j, dy * i}));
if (i >= max)
{
i = 0;
@@ -163,13 +163,13 @@ void CUIBoostStatesWnd::UpdateBoosterPosition(const CEntityCondition::BOOSTER_MA
{
i++;
}
- Item->second->Update();
- Item->second->Draw();
+ item->second->Update();
+ item->second->Draw();
}
else
{
- m_ind_boost_pos.erase(It);
- It--;
+ indBoostPos.erase(it);
+ it--;
}
}
}
diff --git a/src/xrGame/ui/UIBoostStatesWnd.h b/src/xrGame/ui/UIBoostStatesWnd.h
index 7c3c00986d7..cc8f18abeb9 100644
--- a/src/xrGame/ui/UIBoostStatesWnd.h
+++ b/src/xrGame/ui/UIBoostStatesWnd.h
@@ -18,7 +18,7 @@ class CUIBoostStatesWnd final : public CUIWindow
private:
bool bHorizontal, bInverse;
float dx, dy;
- u8 max_item;
- xr_vector m_ind_boost_pos;
- xr_map m_ind_boost_state;
+ u8 maxItem;
+ xr_vector indBoostPos;
+ xr_map indBoostState;
};
From 146fb0562bf3a57360a5f413ec22d146ba4b5a3b Mon Sep 17 00:00:00 2001
From: Amx545 <41252768+Amx545@users.noreply.github.com>
Date: Sat, 13 Jul 2024 10:38:05 +0300
Subject: [PATCH 5/5] Update src/xrGame/ui/UIBoostStatesWnd.cpp
Co-authored-by: Hleb Valoshka <375gnu@gmail.com>
---
src/xrGame/ui/UIBoostStatesWnd.cpp | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/src/xrGame/ui/UIBoostStatesWnd.cpp b/src/xrGame/ui/UIBoostStatesWnd.cpp
index f2574a306bb..711199acd2a 100644
--- a/src/xrGame/ui/UIBoostStatesWnd.cpp
+++ b/src/xrGame/ui/UIBoostStatesWnd.cpp
@@ -3,13 +3,13 @@
#include "UIHelper.h"
CUIBoostStatesWnd::CUIBoostStatesWnd()
- : CUIWindow(CUIBoostStatesWnd::GetDebugType())
+ : CUIWindow(CUIBoostStatesWnd::GetDebugType()),
+ bHorizontal(true),
+ bInverse(false),
+ dx(0.f),
+ dy(0.f),
+ maxItem(8)
{
- bHorizontal = true;
- bInverse = false;
- dx = 0.f;
- dy = 0.f;
- maxItem = 8;
}
void CUIBoostStatesWnd::InitFromXml(CUIXml& xml, LPCSTR path)