Materials Display In-Town & In a Mission
This commit is contained in:
14
README.md
Normal file
14
README.md
Normal file
@@ -0,0 +1,14 @@
|
||||

|
||||
|
||||
## MxHoH2
|
||||
Official **Heroes of Hammerwatch II** Mod.
|
||||
|
||||
## Features
|
||||
- Show current materials on the Main HUD in-town and in a mission.
|
||||
|
||||
## How-To Install
|
||||
1. Download the latest zip.
|
||||
2. Copy the "MxHoH2" folder to your *game root dir*\mods directory.
|
||||
3. If the "mods" directory does not exists, create it.
|
||||
4. Start the game, enable mods in profil and enable "MxHoH2".
|
||||
5. Enjoy!
|
||||
162
gui/hud_components/player_info.gui
Normal file
162
gui/hud_components/player_info.gui
Normal file
@@ -0,0 +1,162 @@
|
||||
<gui>
|
||||
<sprites>
|
||||
<sprite name="background" texture="gui/hud.png"><frame>0 64 186 33</frame></sprite>
|
||||
<sprite name="portrait_background" texture="gui/panelstyles.png"><frame>321 390 32 32</frame></sprite>
|
||||
|
||||
<sprite name="skill-first" texture="gui/hud.png"><frame>186 64 32 33</frame></sprite>
|
||||
<sprite name="skill-mid" texture="gui/hud.png"><frame>218 64 31 33</frame></sprite>
|
||||
<sprite name="skill-last" texture="gui/hud.png"><frame>249 64 32 33</frame></sprite>
|
||||
|
||||
<sprite name="potion" texture="gui/hud.png"><frame>316 32 10 14</frame></sprite>
|
||||
<sprite name="potion-empty" texture="gui/hud.png"><frame>316 46 10 14</frame></sprite>
|
||||
<sprite name="exp" texture="gui/hud.png"><frame>448 0 32 32</frame></sprite>
|
||||
|
||||
<sprite name="bar-bg" texture="gui/hud.png"><frame>326 32 81 5</frame></sprite>
|
||||
|
||||
<sprite name="hand-left" texture="gui/hud.png"><frame>326 37 9 11</frame></sprite>
|
||||
<sprite name="hand-right" texture="gui/hud.png"><frame>335 37 9 11</frame></sprite>
|
||||
|
||||
<sprite name="portrait-body" texture="gui/portrait.tif"><frame>0 0 31 27</frame></sprite>
|
||||
<sprite name="portrait-bg" texture="gui/hud.png"><frame>482 18 28 28</frame></sprite>
|
||||
<sprite name="portrait-clipping" texture="gui/hud.png"><frame>482 18 28 28</frame></sprite>
|
||||
<sprite name="portrait-shadow" texture="gui/hud.png"><frame>448 32 28 28</frame></sprite>
|
||||
|
||||
<sprite name="skill-frame" texture="gui/gui.png"><frame>284 219 28 28</frame></sprite>
|
||||
<sprite name="skill-background" texture="gui/gui.png"><frame>292 247 24 24</frame></sprite>
|
||||
<sprite name="skill-clipping" texture="gui/gui.png"><frame>316 247 24 24</frame></sprite>
|
||||
<sprite name="skill-cooldown" texture="gui/gui.png"><frame>256 219 28 28</frame></sprite>
|
||||
|
||||
<sprite name="skill-weapon-frame" texture="gui/hud.png"><frame>418 34 28 28</frame></sprite>
|
||||
<sprite name="skill-weapon-cooldown" texture="gui/gui.png"><frame>76 210 28 28</frame></sprite>
|
||||
|
||||
<sprite name="dash-one" texture="gui/hud.png"><frame>206 97 15 6</frame></sprite>
|
||||
<sprite name="dash-first" texture="gui/hud.png"><frame>221 97 10 6</frame></sprite>
|
||||
<sprite name="dash-mid" texture="gui/hud.png"><frame>232 97 10 6</frame></sprite>
|
||||
<sprite name="dash-last" texture="gui/hud.png"><frame>243 97 13 6</frame></sprite>
|
||||
<sprite name="dash-max" texture="gui/hud.png"><frame>257 97 11 6</frame></sprite>
|
||||
|
||||
%include "gui/icons.inc"
|
||||
</sprites>
|
||||
|
||||
<doc>
|
||||
<group>
|
||||
<rect id="background-rect" anchor="0.5 1" offset="0 1" height="46" width="248" flow="hbox">
|
||||
<group id="background" width="186">
|
||||
<sprite src="portrait-bg" offset="2 16" />
|
||||
<portrait id="portrait" offset="1 13" body-sprite="portrait-body" body-offset="1 5" clipping-sprite="portrait-clipping" clipping-offset="1 3" background-sprite="portrait_background" >
|
||||
<sprite src="portrait-shadow" offset="1 3" />
|
||||
</portrait>
|
||||
|
||||
<rect id="dash-bar-bg" offset="101 18" width="0" height="4" color="0c120fff"/>
|
||||
<scalingbar id="dash-bar" offset="101 11" orientation="horizontal" value-align="left" height="19" width="52" scale="1" value-padding="0 7" spriteset-variation="2" spriteset-value="gui/value_bar_hori.sval" />
|
||||
|
||||
<!-- <sprite src="bar-bg" offset="61 -14" anchor="0.5 1" /> -->
|
||||
<sprite src="bar-bg" offset="105 24" />
|
||||
<sprite src="bar-bg" offset="105 30" />
|
||||
<sprite src="bar-bg" offset="105 39" />
|
||||
|
||||
<scalingbar id="combo-bar" offset="109 16" orientation="horizontal" value-align="left" height="19" width="75" scale="1" value-padding="0 7" spriteset-variation="3" spriteset-value="gui/value_bar_hori.sval" />
|
||||
<scalingbar id="combo-bar-highlight" offset="109 16" orientation="horizontal" value-align="left" height="19" width="75" scale="1" value-padding="0 7" spriteset-variation="14" spriteset-value="gui/value_bar_hori.sval" />
|
||||
<playerhpbar id="health-bar" offset="109 23" orientation="horizontal" value-align="left" height="19" width="75" scale="1" value-padding="0 7" health-variation="0" alt-variation="4" spriteset-value="gui/value_bar_hori.sval" />
|
||||
<scalingbar id="mana-bar" offset="109 32" orientation="horizontal" value-align="left" height="19" width="75" scale="1" value-padding="0 7" spriteset-variation="1" spriteset-value="gui/value_bar_hori.sval" />
|
||||
|
||||
<sprite id="background" src="background" offset="0 14" visible="true" />
|
||||
|
||||
<group id="dashes" offset="101 16" flow="hbox">
|
||||
</group>
|
||||
|
||||
<radialsprite id="exp" src="exp" offset="0 14" scale="0.45" scale-offset="0.125"/>
|
||||
|
||||
<group offset="109 29" height="7" width="75" color="#ff0000">
|
||||
<text id="health" font="gui/fonts/hw8.fnt" anchor="0 1" offset="3 1" text="100/100" color="#BF0000ff" />
|
||||
</group>
|
||||
<group offset="109 38" height="7" width="75" color="#0000ff">
|
||||
<text id="mana" font="gui/fonts/hw8.fnt" anchor="0 1" offset="3 1" text="100/100" color="#009FC8ff" />
|
||||
</group>
|
||||
|
||||
<rect id="main-hand-slot" offset="33 16" width="28" height="28" />
|
||||
<rect id="off-hand-slot" offset="64 16" width="28" height="28" />
|
||||
|
||||
<group id="hands" visible="false">
|
||||
<sprite src="hand-left" offset="34 32" visible="true" />
|
||||
<sprite src="hand-right" offset="82 32" visible="true" />
|
||||
</group>
|
||||
|
||||
<!-- MxHoH2 - Mission Materials Display -->
|
||||
<rect offset="265 30" width="10" height="14">
|
||||
<sprite src="icon-gold" offset="-10 0" anchor="0.5 0" />
|
||||
<text id="mission-gold" font="gui/fonts/hw8.fnt" anchor="0 1" offset="3 -2" text="100/100" color="#DAA520" />
|
||||
|
||||
<sprite src="icon-wood" offset="40 0" anchor="0.5 0" />
|
||||
<text id="mission-wood" font="gui/fonts/hw8.fnt" anchor="0 1" offset="53 -2" text="100/100" color="#855E42" />
|
||||
|
||||
<sprite src="icon-stone" offset="80 0" anchor="0.5 0" />
|
||||
<text id="mission-stone" font="gui/fonts/hw8.fnt" anchor="0 1" offset="93 -2" text="100/100" color="#888C8D" />
|
||||
|
||||
<sprite src="icon-iron" offset="120 0" anchor="0.5 0" />
|
||||
<text id="mission-iron" font="gui/fonts/hw8.fnt" anchor="0 1" offset="133 -2" text="100/100" color="#61666A" />
|
||||
|
||||
<sprite src="icon-crys" offset="160 0" anchor="0.5 0" />
|
||||
<text id="mission-crys" font="gui/fonts/hw8.fnt" anchor="0 1" offset="173 -2" text="100/100" color="#a7d8de" />
|
||||
|
||||
<sprite src="icon-dust" offset="200 0" anchor="0.5 0" />
|
||||
<text id="mission-dust" font="gui/fonts/hw8.fnt" anchor="0 1" offset="213 -2" text="100/100" color="#fd3f3f" />
|
||||
|
||||
<sprite src="icon-ore" offset="240 0" anchor="0.5 0" />
|
||||
<text id="mission-ore" font="gui/fonts/hw8.fnt" anchor="0 1" offset="253 -2" text="100/100" color="#B87333" />
|
||||
</rect>
|
||||
|
||||
<rect offset="95 29" width="10" height="14">
|
||||
<sprite src="potion" id="potion-icon" offset="0 0" />
|
||||
<sprite src="potion-empty" id="potion-empty-icon" offset="0 0" visible="false" />
|
||||
<text id="potion-charges" offset="1 -14" anchor="0.5 1" font="gui/fonts/hw8.fnt" text="3" color="#ffd700ff" />
|
||||
</rect>
|
||||
</group>
|
||||
|
||||
<group id="skill2" width="62" visible="true">
|
||||
<sprite src="skill-first" offset="0 14" />
|
||||
<sprite src="skill-last" offset="32 14" />
|
||||
|
||||
<rect id="skill-slot" offset="3 16" width="28" height="28" />
|
||||
<rect id="skill-slot" offset="34 16" width="28" height="28" />
|
||||
</group>
|
||||
|
||||
<group id="skill3" width="93" visible="false">
|
||||
<sprite src="skill-first" offset="0 14" />
|
||||
<sprite src="skill-mid" offset="32 14" />
|
||||
<sprite src="skill-last" offset="63 14" />
|
||||
|
||||
<rect id="skill-slot" offset="3 16" width="28" height="28" />
|
||||
<rect id="skill-slot" offset="34 16" width="28" height="28" />
|
||||
<rect id="skill-slot" offset="65 16" width="28" height="28" />
|
||||
</group>
|
||||
|
||||
<group id="skill4" width="124" visible="false">
|
||||
<sprite src="skill-first" offset="0 14" />
|
||||
<sprite src="skill-mid" offset="32 14" />
|
||||
<sprite src="skill-mid" offset="63 14" />
|
||||
<sprite src="skill-last" offset="94 14" />
|
||||
|
||||
<rect id="skill-slot" offset="3 16" width="28" height="28" />
|
||||
<rect id="skill-slot" offset="34 16" width="28" height="28" />
|
||||
<rect id="skill-slot" offset="65 16" width="28" height="28" />
|
||||
<rect id="skill-slot" offset="96 16" width="28" height="28" />
|
||||
</group>
|
||||
</rect>
|
||||
|
||||
<sprite id="dash-one" visible="false" src="dash-one" offset="0 0" />
|
||||
<sprite id="dash-first" visible="false" src="dash-first" offset="0 0" width="8" />
|
||||
<sprite id="dash-mid" visible="false" src="dash-mid" offset="0 0" width="7" />
|
||||
<sprite id="dash-last" visible="false" src="dash-last" offset="0 0" width="10" />
|
||||
<sprite id="dash-max" visible="false" src="dash-max" offset="0 0" width="10" />
|
||||
|
||||
<skill id="skill-template" width="28" visible="false" clipping="skill-clipping" frame="skill-frame" background="skill-background" frame-cooldown="skill-cooldown" off-cooldown-shine="true">
|
||||
<text text="" id="binding" align="center" anchor="0.5 1" offset="1 12" font="gui/fonts/arial11.fnt" />
|
||||
</skill>
|
||||
|
||||
<skill id="skill-weapon-template" width="28" visible="false" clipping="skill-weapon-clipping" frame="skill-weapon-frame" background="skill-weapon-background" frame-cooldown="skill-weapon-cooldown">
|
||||
<text text="" id="binding" align="center" anchor="0.5 1" offset="1 12" font="gui/fonts/arial11.fnt" />
|
||||
</skill>
|
||||
</group>
|
||||
</doc>
|
||||
</gui>
|
||||
5
info.xml
Normal file
5
info.xml
Normal file
@@ -0,0 +1,5 @@
|
||||
<dict>
|
||||
<string name="name">MxHoH2</string>
|
||||
<string name="author">mikx</string>
|
||||
<string name="description">HoH2 mikx's Tweaks Collection.</string>
|
||||
</dict>
|
||||
434
scripts/GUI/HUD/Components/HUDPlayer.as
Normal file
434
scripts/GUI/HUD/Components/HUDPlayer.as
Normal file
@@ -0,0 +1,434 @@
|
||||
float GetExperienceProgressToLevel(PlayerRecord@ record)
|
||||
{
|
||||
int64 xpStart = record.LevelExperience(record.level - 1);
|
||||
int64 xpEnd = record.LevelExperience(record.level) - xpStart;
|
||||
int64 xpNow = record.experience - xpStart;
|
||||
|
||||
if (record.local && g_myTownRecord !is null && g_myTownRecord.m_accomplishmentRewards !is null)
|
||||
xpNow += g_myTownRecord.m_accomplishmentRewards.m_rExp;
|
||||
|
||||
if (double(xpEnd) == 0)
|
||||
return 0.0f;
|
||||
|
||||
return xpNow / double(xpEnd);
|
||||
}
|
||||
|
||||
float GetExperience(PlayerRecord@ record)
|
||||
{
|
||||
int64 xpStart = record.LevelExperience(record.level - 1);
|
||||
int64 xpEnd = record.LevelExperience(record.level) - xpStart;
|
||||
int64 xpNow = record.experience - xpStart;
|
||||
|
||||
if (record.local && g_myTownRecord !is null && g_myTownRecord.m_accomplishmentRewards !is null)
|
||||
xpNow += g_myTownRecord.m_accomplishmentRewards.m_rExp;
|
||||
|
||||
return xpNow;
|
||||
}
|
||||
|
||||
class HUDPlayer : HUDComponent
|
||||
{
|
||||
PortraitWidget@ m_wPortrait;
|
||||
|
||||
RectWidget@ m_wBackgroundRect;
|
||||
Widget@ m_wBackground;
|
||||
Widget@ m_wLeftBackground2;
|
||||
Widget@ m_wLeftBackground3;
|
||||
Widget@ m_wLeftBackground4;
|
||||
|
||||
TextWidget@ m_wMissionGold;
|
||||
TextWidget@ m_wMissionWood;
|
||||
TextWidget@ m_wMissionStone;
|
||||
TextWidget@ m_wMissionIron;
|
||||
TextWidget@ m_wMissionCrystal;
|
||||
TextWidget@ m_wMissionDust;
|
||||
TextWidget@ m_wMissionOre;
|
||||
|
||||
TextWidget@ m_wPotCharges;
|
||||
SpriteWidget@ m_wPotIcon;
|
||||
SpriteWidget@ m_wPotEmptyIcon;
|
||||
vec4 m_potTextColFull;
|
||||
vec4 m_potTextColEmpty;
|
||||
vec4 m_potTextColDrinkable;
|
||||
|
||||
PlayerHealthBarWidget@ m_wBarHealth;
|
||||
TextWidget@ m_wHealth;
|
||||
|
||||
ScalingBarWidget@ m_wBarMana;
|
||||
TextWidget@ m_wMana;
|
||||
|
||||
ScalingBarWidget@ m_wBarDash;
|
||||
Widget@ m_wBarDashBg;
|
||||
Widget@ m_wDashSegOne;
|
||||
Widget@ m_wDashSegFirst;
|
||||
Widget@ m_wDashSegMid;
|
||||
Widget@ m_wDashSegLast;
|
||||
Widget@ m_wDashSegMax;
|
||||
Widget@ m_wDashes;
|
||||
|
||||
Widget@ m_wHandIcons;
|
||||
|
||||
ScalingBarWidget@ m_wBarCombo;
|
||||
ScalingBarWidget@ m_wBarComboH;
|
||||
RadialSpriteWidget@ m_wRadialExp;
|
||||
|
||||
SkillWidget@ m_wSkillTemplate;
|
||||
SkillWidget@ m_wSkillWeaponTemplate;
|
||||
array<Widget@> m_skillSlots;
|
||||
Widget@ m_wMainHandSkillSlot;
|
||||
Widget@ m_wOffHandSkillSlot;
|
||||
|
||||
int m_maxDashCharges;
|
||||
|
||||
HUDPlayer(GUIBuilder@ b)
|
||||
{
|
||||
super(b, "gui/hud_components/player_info.gui");
|
||||
|
||||
@m_wBackgroundRect = cast<RectWidget>(m_widget.GetWidgetById("background-rect"));
|
||||
@m_wBackground = m_widget.GetWidgetById("background");
|
||||
@m_wLeftBackground2 = m_widget.GetWidgetById("skill2");
|
||||
@m_wLeftBackground3 = m_widget.GetWidgetById("skill3");
|
||||
@m_wLeftBackground4 = m_widget.GetWidgetById("skill4");
|
||||
|
||||
@m_wPortrait = cast<PortraitWidget>(m_widget.GetWidgetById("portrait"));
|
||||
|
||||
@m_wMissionGold = cast<TextWidget>(m_widget.GetWidgetById("mission-gold"));
|
||||
@m_wMissionWood = cast<TextWidget>(m_widget.GetWidgetById("mission-wood"));
|
||||
@m_wMissionStone = cast<TextWidget>(m_widget.GetWidgetById("mission-stone"));
|
||||
@m_wMissionIron = cast<TextWidget>(m_widget.GetWidgetById("mission-iron"));
|
||||
@m_wMissionCrystal = cast<TextWidget>(m_widget.GetWidgetById("mission-crys"));
|
||||
@m_wMissionDust = cast<TextWidget>(m_widget.GetWidgetById("mission-dust"));
|
||||
@m_wMissionOre = cast<TextWidget>(m_widget.GetWidgetById("mission-ore"));
|
||||
|
||||
@m_wPotCharges = cast<TextWidget>(m_widget.GetWidgetById("potion-charges"));
|
||||
@m_wPotIcon = cast<SpriteWidget>(m_widget.GetWidgetById("potion-icon"));
|
||||
@m_wPotEmptyIcon = cast<SpriteWidget>(m_widget.GetWidgetById("potion-empty-icon"));
|
||||
|
||||
@m_wBarHealth = cast<PlayerHealthBarWidget>(m_widget.GetWidgetById("health-bar"));
|
||||
@m_wHealth = cast<TextWidget>(m_widget.GetWidgetById("health"));
|
||||
|
||||
@m_wBarMana = cast<ScalingBarWidget>(m_widget.GetWidgetById("mana-bar"));
|
||||
@m_wMana = cast<TextWidget>(m_widget.GetWidgetById("mana"));
|
||||
|
||||
@m_wBarCombo = cast<ScalingBarWidget>(m_widget.GetWidgetById("combo-bar"));
|
||||
@m_wBarComboH = cast<ScalingBarWidget>(m_widget.GetWidgetById("combo-bar-highlight"));
|
||||
|
||||
@m_wBarDash = cast<ScalingBarWidget>(m_widget.GetWidgetById("dash-bar"));
|
||||
@m_wRadialExp = cast<RadialSpriteWidget>(m_widget.GetWidgetById("exp"));
|
||||
|
||||
@m_wSkillTemplate = cast<SkillWidget>(m_widget.GetWidgetById("skill-template"));
|
||||
@m_wSkillWeaponTemplate = cast<SkillWidget>(m_widget.GetWidgetById("skill-weapon-template"));
|
||||
@m_wMainHandSkillSlot = m_widget.GetWidgetById("main-hand-slot");
|
||||
@m_wOffHandSkillSlot = m_widget.GetWidgetById("off-hand-slot");
|
||||
|
||||
@m_wDashSegOne = m_widget.GetWidgetById("dash-one");
|
||||
@m_wDashSegFirst = m_widget.GetWidgetById("dash-first");
|
||||
@m_wDashSegMid = m_widget.GetWidgetById("dash-mid");
|
||||
@m_wDashSegLast = m_widget.GetWidgetById("dash-last");
|
||||
@m_wDashSegMax = m_widget.GetWidgetById("dash-max");
|
||||
@m_wDashes = m_widget.GetWidgetById("dashes");
|
||||
@m_wBarDashBg = m_widget.GetWidgetById("dash-bar-bg");
|
||||
|
||||
@m_wHandIcons = m_widget.GetWidgetById("hands");
|
||||
|
||||
m_potTextColFull = ParseColorRGBA("#00ff00ff");
|
||||
m_potTextColEmpty = vec4(0.1f, 0.1f, 0.1f, 1.0f);
|
||||
m_potTextColDrinkable = ParseColorRGBA("#ffd700ff");
|
||||
|
||||
m_wBarCombo.m_scale = 0.0f;
|
||||
m_wBarComboH.m_scale = 0.0f;
|
||||
m_wBarDash.SetScale(0.0f);
|
||||
}
|
||||
|
||||
void GetSkillSlots(Widget@ w)
|
||||
{
|
||||
m_skillSlots.resize(0);
|
||||
GetSkillSlots(w, HashString("skill-slot"));
|
||||
}
|
||||
|
||||
void GetSkillSlots(Widget@ w, uint id)
|
||||
{
|
||||
for (uint i = 0; i < w.m_children.length(); i++)
|
||||
{
|
||||
if (w.m_children[i].m_idHash == id)
|
||||
m_skillSlots.insertLast(w.m_children[i]);
|
||||
|
||||
GetSkillSlots(w.m_children[i], id);
|
||||
}
|
||||
}
|
||||
|
||||
void Update(int dt, PlayerRecord@ record) override
|
||||
{
|
||||
HUDComponent::Update(dt, record);
|
||||
|
||||
if (!m_visible || record is null)
|
||||
return;
|
||||
|
||||
// Materials Tracking
|
||||
int goldCount = record.GetMaterial(MaterialType::Gold);
|
||||
int woodCount = record.GetMaterial(MaterialType::Wood);
|
||||
int stoneCount = record.GetMaterial(MaterialType::Wood);
|
||||
int ironCount = record.GetMaterial(MaterialType::Iron);
|
||||
int crysCount = record.GetMaterial(MaterialType::Crystals);
|
||||
int dustCount = record.GetMaterial(MaterialType::Dust);
|
||||
int oreCount = record.GetMaterial(MaterialType::Ore);
|
||||
m_wMissionGold.SetText(goldCount);
|
||||
m_wMissionWood.SetText(woodCount);
|
||||
m_wMissionStone.SetText(stoneCount);
|
||||
m_wMissionIron.SetText(ironCount);
|
||||
m_wMissionCrystal.SetText(crysCount);
|
||||
m_wMissionDust.SetText(dustCount);
|
||||
m_wMissionOre.SetText(oreCount);
|
||||
|
||||
// Potion
|
||||
int charges = record.currStats.PotionCharges - record.potionChargesUsed;
|
||||
if (charges == 0)
|
||||
m_wPotCharges.SetColor(m_potTextColEmpty);
|
||||
else if (record.potionChargesUsed == 0)
|
||||
m_wPotCharges.SetColor(m_potTextColFull);
|
||||
else
|
||||
m_wPotCharges.SetColor(m_potTextColDrinkable);
|
||||
|
||||
m_wPotCharges.SetText("" + charges);
|
||||
m_wPotIcon.m_visible = (charges > 0);
|
||||
m_wPotEmptyIcon.m_visible = (charges == 0 && record.currStats.PotionCharges > 0);
|
||||
|
||||
// Health
|
||||
m_wBarHealth.CalculateScales(record);
|
||||
if (record.IsDead())
|
||||
m_wHealth.SetText("" + 0 + "/" + record.MaxHealth());
|
||||
else
|
||||
m_wHealth.SetText("" + int(ceil(record.hp * record.MaxHealth())) + "/" + record.MaxHealth());
|
||||
|
||||
// Mana
|
||||
m_wBarMana.SetScale(record.mana);
|
||||
m_wMana.SetText("" + int(floor(record.mana * record.MaxMana())) + "/" + record.MaxMana());
|
||||
|
||||
// Experience
|
||||
m_wRadialExp.m_scale = GetExperienceProgressToLevel(record);
|
||||
|
||||
// Dash charges
|
||||
if (record.currStats.MaxDashes == 0 || record.dashCharges == 0)
|
||||
m_wBarDash.SetScale(0.0f);
|
||||
else if (record.dashCharges == record.currStats.MaxDashes)
|
||||
m_wBarDash.SetScale(1.0f);
|
||||
else
|
||||
{
|
||||
if (record.currStats.MaxDashes > 2)
|
||||
{
|
||||
float mid = float((record.dashCharges - 1) * m_wDashSegMid.m_width) / float(m_wBarDash.m_width);
|
||||
float first = float(m_wDashSegFirst.m_width) / float(m_wBarDash.m_width);
|
||||
|
||||
m_wBarDash.SetScale(first + mid);
|
||||
}
|
||||
else
|
||||
m_wBarDash.SetScale(float(record.dashCharges) / float(record.currStats.MaxDashes));
|
||||
}
|
||||
|
||||
if (record.currStats.MaxDashes != m_maxDashCharges)
|
||||
UpdateDashMaxCharges(record);
|
||||
|
||||
auto plr = cast<Player>(record.actor);
|
||||
if (record.currStats.ComboCountMax > 0 && plr !is null)
|
||||
{
|
||||
m_wBarCombo.m_scale = min(1.0f, float(plr.m_comboCount) / float(record.currStats.ComboCountMax));
|
||||
int resetTime = plr.m_comboActive ? record.currStats.ComboSustainResetTime : record.currStats.ComboObtainResetTime;
|
||||
m_wBarComboH.m_scale = m_wBarCombo.m_scale * (1.0f - float(plr.m_comboC) / float(resetTime));
|
||||
}
|
||||
else
|
||||
{
|
||||
m_wBarCombo.m_scale = 0.0f;
|
||||
m_wBarComboH.m_scale = 0.0f;
|
||||
}
|
||||
}
|
||||
|
||||
void UpdateDashMaxCharges(PlayerRecord@ record)
|
||||
{
|
||||
if (record is null)
|
||||
return;
|
||||
|
||||
m_wDashes.ClearChildren();
|
||||
int width = -3;
|
||||
|
||||
if (record.currStats.MaxDashes == 1)
|
||||
{
|
||||
auto seg = m_wDashSegOne.Clone();
|
||||
seg.m_visible = true;
|
||||
width += seg.m_width;
|
||||
m_wDashes.AddChild(seg);
|
||||
}
|
||||
else if (record.currStats.MaxDashes == 2)
|
||||
{
|
||||
auto seg1 = m_wDashSegFirst.Clone();
|
||||
auto seg2 = m_wDashSegLast.Clone();
|
||||
seg1.m_visible = true;
|
||||
seg2.m_visible = true;
|
||||
width += seg1.m_width + seg2.m_width;
|
||||
|
||||
m_wDashes.AddChild(seg1);
|
||||
m_wDashes.AddChild(seg2);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (uint i = 0; i < record.currStats.MaxDashes; i++)
|
||||
{
|
||||
Widget@ seg;
|
||||
if (i == 0)
|
||||
@seg = m_wDashSegFirst.Clone();
|
||||
else if (i == record.currStats.MaxDashes - 1)
|
||||
{
|
||||
if (i >= 8)
|
||||
@seg = m_wDashSegMax.Clone();
|
||||
else
|
||||
{
|
||||
@seg = m_wDashSegLast.Clone();
|
||||
}
|
||||
}
|
||||
else
|
||||
@seg = m_wDashSegMid.Clone();
|
||||
|
||||
seg.m_visible = true;
|
||||
width += seg.m_width;
|
||||
m_wDashes.AddChild(seg);
|
||||
}
|
||||
}
|
||||
|
||||
m_wBarDash.m_width = width;
|
||||
m_wBarDashBg.m_width = width;
|
||||
m_maxDashCharges = record.currStats.MaxDashes;
|
||||
}
|
||||
|
||||
void Refresh(PlayerRecord@ record) override
|
||||
{
|
||||
RefreshPotions(record);
|
||||
RefreshSkills(record);
|
||||
RefreshPortrait(record);
|
||||
}
|
||||
|
||||
void RefreshPotions(PlayerRecord@ record)
|
||||
{
|
||||
if (record is null)
|
||||
return;
|
||||
|
||||
Invalidate();
|
||||
}
|
||||
|
||||
void RefreshPortrait(PlayerRecord@ record)
|
||||
{
|
||||
m_wPortrait.SetPortrait(record.portrait);
|
||||
|
||||
m_wPortrait.m_visible = record.level > 0;
|
||||
if (record.skinColor is null)
|
||||
return;
|
||||
|
||||
array<PlayerColors@> col;
|
||||
PlayerColors::GetPlayerColors(col, record);
|
||||
m_wPortrait.SetColors(col);
|
||||
}
|
||||
|
||||
void RefreshSkills(PlayerRecord@ record)
|
||||
{
|
||||
array<Skills::Skill@>@ playerSkills;
|
||||
|
||||
auto player = cast<PlayerBase>(record.actor);
|
||||
if (player !is null)
|
||||
@playerSkills = player.m_skills;
|
||||
else
|
||||
@playerSkills = PlayerHelper::GetDeadSkillList(record);
|
||||
|
||||
auto mainHandWeapon = record.equipped.m_items[EquippedItemsSlots::MainHand];
|
||||
auto offHandWeapon = record.equipped.m_items[EquippedItemsSlots::OffHand];
|
||||
m_wHandIcons.m_visible = mainHandWeapon !is null && mainHandWeapon.GetSlot() == Equipment::Slot::TwoHanded;
|
||||
|
||||
for (uint i = 0; i < m_skillSlots.length(); i++)
|
||||
m_skillSlots[i].ClearChildren();
|
||||
|
||||
m_wMainHandSkillSlot.ClearChildren();
|
||||
m_wOffHandSkillSlot.ClearChildren();
|
||||
|
||||
Skills::Skill@ mainHandSkill;
|
||||
Skills::Skill@ offHandSkill;
|
||||
array<Skills::Skill@> skills = array<Skills::Skill@>();
|
||||
|
||||
for (uint i = 0; i < playerSkills.length(); i++)
|
||||
{
|
||||
if (playerSkills[i].GetTargetingMode() == Skills::TargetingMode::Passive)
|
||||
continue;
|
||||
|
||||
if (playerSkills[i].m_type == PlayerSkillType::MainHand)
|
||||
@mainHandSkill = playerSkills[i];
|
||||
else if (playerSkills[i].m_type == PlayerSkillType::OffHand)
|
||||
@offHandSkill = playerSkills[i];
|
||||
else if (playerSkills[i].m_type != PlayerSkillType::Dash)
|
||||
skills.insertLast(playerSkills[i]);
|
||||
}
|
||||
|
||||
if (skills.length() <= 2)
|
||||
{
|
||||
m_wLeftBackground2.m_visible = true;
|
||||
m_wLeftBackground3.m_visible = false;
|
||||
m_wLeftBackground4.m_visible = false;
|
||||
|
||||
m_wBackgroundRect.m_width = m_wBackground.m_width + m_wLeftBackground2.m_width;
|
||||
GetSkillSlots(m_wLeftBackground2);
|
||||
}
|
||||
else if (skills.length() == 3)
|
||||
{
|
||||
m_wLeftBackground2.m_visible = false;
|
||||
m_wLeftBackground3.m_visible = true;
|
||||
m_wLeftBackground4.m_visible = false;
|
||||
|
||||
m_wBackgroundRect.m_width = m_wBackground.m_width + m_wLeftBackground3.m_width;
|
||||
GetSkillSlots(m_wLeftBackground3);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_wLeftBackground2.m_visible = false;
|
||||
m_wLeftBackground3.m_visible = false;
|
||||
m_wLeftBackground4.m_visible = true;
|
||||
|
||||
m_wBackgroundRect.m_width = m_wBackground.m_width + m_wLeftBackground4.m_width;
|
||||
GetSkillSlots(m_wLeftBackground4);
|
||||
}
|
||||
|
||||
if (m_wMainHandSkillSlot !is null && mainHandSkill !is null)
|
||||
{
|
||||
auto newSkill = cast<SkillWidget>(m_wSkillWeaponTemplate.Clone());
|
||||
newSkill.SetID("");
|
||||
newSkill.m_visible = true;
|
||||
newSkill.SetSkill(mainHandSkill, mainHandWeapon);
|
||||
|
||||
auto bindingW = cast<TextWidget>(newSkill.GetWidgetById("binding"));
|
||||
bindingW.SetText("");
|
||||
|
||||
m_wMainHandSkillSlot.AddChild(newSkill);
|
||||
}
|
||||
|
||||
if (m_wOffHandSkillSlot !is null && offHandSkill !is null)
|
||||
{
|
||||
auto newSkill = cast<SkillWidget>(m_wSkillWeaponTemplate.Clone());
|
||||
newSkill.SetID("");
|
||||
newSkill.m_visible = true;
|
||||
newSkill.SetSkill(offHandSkill, m_wHandIcons.m_visible ? mainHandWeapon : offHandWeapon, m_wHandIcons.m_visible);
|
||||
|
||||
auto bindingW = cast<TextWidget>(newSkill.GetWidgetById("binding"));
|
||||
bindingW.SetText("");
|
||||
|
||||
m_wOffHandSkillSlot.AddChild(newSkill);
|
||||
}
|
||||
|
||||
for (uint i = 0; i < m_skillSlots.length() && i < skills.length(); i++)
|
||||
{
|
||||
auto newSkill = cast<SkillWidget>(m_wSkillTemplate.Clone());
|
||||
newSkill.SetID("");
|
||||
newSkill.m_visible = true;
|
||||
newSkill.SetSkill(skills[i]);
|
||||
|
||||
auto bindingW = cast<TextWidget>(newSkill.GetWidgetById("binding"));
|
||||
bindingW.SetText("");
|
||||
|
||||
m_skillSlots[i].AddChild(newSkill);
|
||||
}
|
||||
|
||||
Invalidate();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user