Commit 0047c670 authored by Ivaria's avatar Ivaria

Added overshield bar to display excess absorption amount

parent 18d2e04a
......@@ -111,6 +111,7 @@ end
local tIncColor = { ["useBackground"] = true };
local tShieldColor = { ["useBackground"] = true };
local tOvershieldColor = { ["useBackground"] = true };
......@@ -134,6 +135,22 @@ end
--
local tOpacity;
local function VUHDO_setTextureColor(aTexture, aColor)
tOpacity = aColor["useOpacity"] and aColor["O"] or nil;
if aColor["useBackground"] then
aTexture:SetVertexColor(aColor["R"], aColor["G"], aColor["B"], tOpacity);
elseif tOpacity then
aTexture:SetAlpha(tOpacity);
end
end
--
local function VUHDO_getKiloText(aNumber, aMaxNumber, aSetup)
return aSetup["LIFE_TEXT"]["verbose"] and aNumber
......@@ -166,12 +183,16 @@ end
--
local tInfo;
local tAllButtons;
local tAbsorbAmount;
local tOpacity;
local tHealthBar;
local tIncBar;
function VUHDO_updateShieldBar(aUnit, aHealthPlusIncQuota)
if not VUHDO_CONFIG["SHOW_SHIELD_BAR"] then return; end
local tAbsorbAmount, tOverallShieldRemain;
local tShieldOpacity, tOvershieldOpacity;
local tHealthBar, tHealthBarWidth, tHealthBarHeight, tHealthDeficit;
local tOvershieldBar, tOvershieldBarSize, tOvershieldBarSizePercent, tOvershieldBarOffset, tOvershieldBarOffsetPercent;
local tVisibleAmountInc;
local tOrientation;
function VUHDO_updateShieldBar(aUnit, aHealthPlusIncQuota, aAmountInc)
if not VUHDO_CONFIG["SHOW_SHIELD_BAR"] then
return;
end
tInfo = VUHDO_RAID[aUnit];
tAllButtons = VUHDO_getUnitButtons(VUHDO_resolveVehicleUnit(aUnit));
......@@ -179,26 +200,107 @@ function VUHDO_updateShieldBar(aUnit, aHealthPlusIncQuota)
if not tInfo or not tAllButtons or not tInfo["connected"] or tInfo["dead"] or tInfo["healthmax"] <= 0 then
return;
end
aHealthPlusIncQuota = aHealthPlusIncQuota and aHealthPlusIncQuota or VUHDO_getHealthPlusIncQuota(aUnit);
tAbsorbAmount = VUHDO_getUnitOverallShieldRemain(aUnit) / tInfo["healthmax"];
for _, tButton in pairs(tAllButtons) do
tShieldBar = VUHDO_getHealthBar(tButton, 19);
tOrientation = VUHDO_getStatusbarOrientationString("HEALTH_BAR");
if not aHealthPlusIncQuota or not aAmountInc then
aHealthPlusIncQuota, aAmountInc = VUHDO_getHealthPlusIncQuota(aUnit);
end
tOverallShieldRemain = VUHDO_getUnitOverallShieldRemain(aUnit);
tAbsorbAmount = tOverallShieldRemain / tInfo["healthmax"];
tHealthDeficit = tInfo["healthmax"] - tInfo["health"];
tVisibleAmountInc = (aAmountInc <= tHealthDeficit) and aAmountInc or 0;
tOverallShieldRemain = (tOverallShieldRemain < tInfo["healthmax"]) and tOverallShieldRemain or tInfo["healthmax"];
if tAbsorbAmount > 0 then
tOvershieldBarSizePercent = (tOverallShieldRemain - tHealthDeficit + tVisibleAmountInc) / tInfo["healthmax"];
tOvershieldBarOffsetPercent = (tHealthDeficit - tVisibleAmountInc) / tInfo["healthmax"];
for _, tButton in pairs(tAllButtons) do
tHealthBar = VUHDO_getHealthBar(tButton, 1);
tShieldBar = VUHDO_getHealthBar(tButton, 19);
if tAbsorbAmount > 0 then
tShieldBar:SetValueRange(aHealthPlusIncQuota, aHealthPlusIncQuota + tAbsorbAmount);
tHealthBar = VUHDO_getHealthBar(tButton, 1);
tShieldColor["R"], tShieldColor["G"], tShieldColor["B"], tOpacity = tHealthBar:GetStatusBarColor();
tShieldColor["R"], tShieldColor["G"], tShieldColor["B"], tShieldOpacity = tHealthBar:GetStatusBarColor();
tShieldColor = VUHDO_getDiffColor(tShieldColor, VUHDO_PANEL_SETUP["BAR_COLORS"]["SHIELD"]);
if tShieldColor["O"] and tOpacity then
tShieldColor["O"] = tShieldColor["O"] * tOpacity * (tHealthBar:GetAlpha() or 1);
end
if tShieldColor["O"] and tShieldOpacity then
tShieldColor["O"] = tShieldColor["O"] * tShieldOpacity * (tHealthBar:GetAlpha() or 1);
end
VUHDO_setStatusBarColor(tShieldBar, tShieldColor);
else
tShieldBar:SetValueRange(0,0);
end
end
VUHDO_setStatusBarColor(tShieldBar, tShieldColor);
else
tShieldBar:SetValueRange(0,0);
end
tOvershieldBar = VUHDO_getOvershieldBarTexture(tHealthBar);
if VUHDO_CONFIG["SHOW_OVERSHIELD_BAR"] and (tOverallShieldRemain > tHealthDeficit) then
tOvershieldBar.tileSize = 32;
tOvershieldBar:SetParent(tHealthBar);
tOvershieldBar:ClearAllPoints();
tOvershieldColor["R"], tOvershieldColor["G"], tOvershieldColor["B"], tOvershieldOpacity = tHealthBar:GetStatusBarColor();
tOvershieldColor = VUHDO_getDiffColor(tOvershieldColor, VUHDO_PANEL_SETUP["BAR_COLORS"]["OVERSHIELD"]);
if tOvershieldColor["O"] and tOvershieldOpacity then
tOvershieldColor["O"] = tOvershieldColor["O"] * tOvershieldOpacity * (tHealthBar:GetAlpha() or 1);
end
VUHDO_setTextureColor(tOvershieldBar, tOvershieldColor);
tHealthBarWidth, tHealthBarHeight = tHealthBar:GetSize();
if (not sIsInvertGrowth and tOrientation == "HORIZONTAL") or (sIsInvertGrowth and tOrientation == "HORIZONTAL_INV") then
-- VUHDO_STATUSBAR_LEFT_TO_RIGHT
tOvershieldBarSize = tOvershieldBarSizePercent * tHealthBarWidth;
tOvershieldBarOffset = tOvershieldBarOffsetPercent * tHealthBarWidth;
tOvershieldBar:SetPoint("TOPRIGHT", tHealthBar, "TOPRIGHT", tOvershieldBarOffset * -1, 0);
tOvershieldBar:SetPoint("BOTTOMRIGHT", tHealthBar, "BOTTOMRIGHT", tOvershieldBarOffset * -1, 0);
tOvershieldBar:SetWidth(tOvershieldBarSize);
tOvershieldBar:SetTexCoord(0, tOvershieldBarSize / tOvershieldBar.tileSize, 0, tHealthBarHeight / tOvershieldBar.tileSize);
elseif (not sIsInvertGrowth and tOrientation == "HORIZONTAL_INV") or (sIsInvertGrowth and tOrientation == "HORIZONTAL") then
-- VUHDO_STATUSBAR_RIGHT_TO_LEFT
tOvershieldBarSize = tOvershieldBarSizePercent * tHealthBarWidth;
tOvershieldBarOffset = tOvershieldBarOffsetPercent * tHealthBarWidth;
tOvershieldBar:SetPoint("TOPLEFT", tHealthBar, "TOPLEFT", tOvershieldBarOffset, 0);
tOvershieldBar:SetPoint("BOTTOMLEFT", tHealthBar, "BOTTOMLEFT", tOvershieldBarOffset, 0);
tOvershieldBar:SetWidth(tOvershieldBarSize);
tOvershieldBar:SetTexCoord(0, tOvershieldBarSize / tOvershieldBar.tileSize, 0, tHealthBarHeight / tOvershieldBar.tileSize);
elseif (not sIsInvertGrowth and tOrientation == "VERTICAL") or (sIsInvertGrowth and tOrientation == "VERTICAL_INV") then
-- VUHDO_STATUSBAR_BOTTOM_TO_TOP
tOvershieldBarSize = tOvershieldBarSizePercent * tHealthBarHeight;
tOvershieldBarOffset = tOvershieldBarOffsetPercent * tHealthBarHeight;
tOvershieldBar:SetPoint("TOPLEFT", tHealthBar, "TOPLEFT", 0, tOvershieldBarOffset * -1);
tOvershieldBar:SetPoint("TOPRIGHT", tHealthBar, "TOPRIGHT", 0, tOvershieldBarOffset * -1);
tOvershieldBar:SetHeight(tOvershieldBarSize);
tOvershieldBar:SetTexCoord(0, tHealthBarWidth / tOvershieldBar.tileSize, 0, tOvershieldBarSize / tOvershieldBar.tileSize);
else -- not sIsInvertGrowth and tOrientation == "VERTICAL_INV"
-- VUHDO_STATUSBAR_TOP_TO_BOTTOM
tOvershieldBarSize = tOvershieldBarSizePercent * tHealthBarHeight;
tOvershieldBarOffset = tOvershieldBarOffsetPercent * tHealthBarHeight;
tOvershieldBar:SetPoint("BOTTOMLEFT", tHealthBar, "BOTTOMLEFT", 0, tOvershieldBarOffset);
tOvershieldBar:SetPoint("BOTTOMRIGHT", tHealthBar, "BOTTOMRIGHT", 0, tOvershieldBarOffset);
tOvershieldBar:SetHeight(tOvershieldBarSize);
tOvershieldBar:SetTexCoord(0, tHealthBarWidth / tOvershieldBar.tileSize, 0, tOvershieldBarSize / tOvershieldBar.tileSize);
end
tOvershieldBar:Show();
else
tOvershieldBar:Hide();
end
end
end
local VUHDO_updateShieldBar = VUHDO_updateShieldBar;
......@@ -239,7 +341,7 @@ local function VUHDO_updateIncHeal(aUnit)
end
end
VUHDO_updateShieldBar(aUnit, tHealthPlusInc);
VUHDO_updateShieldBar(aUnit, tHealthPlusInc, tAmountInc);
end
......
......@@ -542,6 +542,7 @@ local VUHDO_DEFAULT_CONFIG = {
["SHOW_OWN_INCOMING"] = true,
["SHOW_TEXT_OVERHEAL"] = true,
["SHOW_SHIELD_BAR"] = true,
["SHOW_OVERSHIELD_BAR"] = false,
["RANGE_CHECK_DELAY"] = 260,
......@@ -2296,6 +2297,11 @@ local VUHDO_DEFAULT_PANEL_SETUP = {
["TR"] = 0.35, ["TG"] = 0.52, ["TB"] = 1, ["TO"] = 1,
["useText"] = false, ["useBackground"] = true, ["useOpacity"] = true,
},
["OVERSHIELD"] = {
["R"] = 0.35, ["G"] = 0.52, ["B"] = 1, ["O"] = 1,
["TR"] = 0.35, ["TG"] = 0.52, ["TB"] = 1, ["TO"] = 1,
["useText"] = false, ["useBackground"] = true, ["useOpacity"] = true,
},
["DIRECTION"] = {
["R"] = 1, ["G"] = 0.4, ["B"] = 0.4, ["O"] = 1,
["useBackground"] = true,
......
......@@ -1143,3 +1143,5 @@ VUHDO_I18N_NICKNAME = "Details!\nNickname"
VUHDO_I18N_DEBUFF_SHOW_ONLY_FOR_FRIENDLY_TEXT = "Show only\nfor friendly";
VUHDO_I18N_DEBUFF_SHOW_ONLY_FOR_FRIENDLY_TOOLTIP = "Shows debuffs only for friendly units";
VUHDO_I18N_SHOW_OVERSHIELD = "Show\nOvershield";
......@@ -1143,3 +1143,5 @@ VUHDO_I18N_NICKNAME = "Details!\nNickname"
VUHDO_I18N_DEBUFF_SHOW_ONLY_FOR_FRIENDLY_TEXT = "Show only\nfor friendly";
VUHDO_I18N_DEBUFF_SHOW_ONLY_FOR_FRIENDLY_TOOLTIP = "Shows debuffs only for friendly units";
VUHDO_I18N_SHOW_OVERSHIELD = "Show\nOvershield";
......@@ -1158,3 +1158,5 @@ VUHDO_I18N_NICKNAME = "Details!\nNickname"
VUHDO_I18N_DEBUFF_SHOW_ONLY_FOR_FRIENDLY_TEXT = "Show only\nfor friendly";
VUHDO_I18N_DEBUFF_SHOW_ONLY_FOR_FRIENDLY_TOOLTIP = "Shows debuffs only for friendly units";
VUHDO_I18N_SHOW_OVERSHIELD = "Show\nOvershield";
......@@ -1159,3 +1159,5 @@ VUHDO_I18N_NICKNAME = "Details!\nNickname"
VUHDO_I18N_DEBUFF_SHOW_ONLY_FOR_FRIENDLY_TEXT = "Show only\nfor friendly";
VUHDO_I18N_DEBUFF_SHOW_ONLY_FOR_FRIENDLY_TOOLTIP = "Shows debuffs only for friendly units";
VUHDO_I18N_SHOW_OVERSHIELD = "Show\nOvershield";
......@@ -1149,3 +1149,5 @@ VUHDO_I18N_NICKNAME = "Details!\nNickname"
VUHDO_I18N_DEBUFF_SHOW_ONLY_FOR_FRIENDLY_TEXT = "Show only\nfor friendly";
VUHDO_I18N_DEBUFF_SHOW_ONLY_FOR_FRIENDLY_TOOLTIP = "Shows debuffs only for friendly units";
VUHDO_I18N_SHOW_OVERSHIELD = "Show\nOvershield";
......@@ -1323,3 +1323,5 @@ VUHDO_I18N_NICKNAME = "Details!\nNickname"
VUHDO_I18N_DEBUFF_SHOW_ONLY_FOR_FRIENDLY_TEXT = "Показывать только\nдля дружественных";
VUHDO_I18N_DEBUFF_SHOW_ONLY_FOR_FRIENDLY_TOOLTIP = "Показывать дэбафы только для дружественных юнитов";
VUHDO_I18N_SHOW_OVERSHIELD = "Show\nOvershield";
......@@ -1145,3 +1145,5 @@ VUHDO_I18N_NICKNAME = "Details!\n昵称"
VUHDO_I18N_DEBUFF_SHOW_ONLY_FOR_FRIENDLY_TEXT = "Show only\nfor friendly";
VUHDO_I18N_DEBUFF_SHOW_ONLY_FOR_FRIENDLY_TOOLTIP = "Shows debuffs only for friendly units";
VUHDO_I18N_SHOW_OVERSHIELD = "Show\nOvershield";
......@@ -1145,3 +1145,5 @@ VUHDO_I18N_NICKNAME = "Details!\nNickname"
VUHDO_I18N_DEBUFF_SHOW_ONLY_FOR_FRIENDLY_TEXT = "Show only\nfor friendly";
VUHDO_I18N_DEBUFF_SHOW_ONLY_FOR_FRIENDLY_TOOLTIP = "Shows debuffs only for friendly units";
VUHDO_I18N_SHOW_OVERSHIELD = "Show\nOvershield";
......@@ -8,7 +8,7 @@
<Anchors>
<Anchor point="TOPLEFT">
<Offset>
<AbsDimension x="20" y="-250" />
<AbsDimension x="20" y="-288" />
</Offset>
</Anchor>
</Anchors>
......@@ -66,7 +66,7 @@
<Anchors>
<Anchor point="TOPLEFT">
<Offset>
<AbsDimension x="230" y="-230" />
<AbsDimension x="230" y="-268" />
</Offset>
</Anchor>
</Anchors>
......@@ -155,7 +155,7 @@
<Frame name="$parentNormalModePanel" inherits="VuhDoPanelTemplate">
<Size>
<AbsDimension x="321" y="207" />
<AbsDimension x="321" y="245" />
</Size>
<Anchors>
<Anchor point="TOPLEFT">
......@@ -227,7 +227,7 @@
<Anchors>
<Anchor point="TOPLEFT">
<Offset>
<AbsDimension x="247" y="-162" />
<AbsDimension x="247" y="-200" />
</Offset>
</Anchor>
</Anchors>
......@@ -242,7 +242,7 @@
<Anchors>
<Anchor point="TOPLEFT">
<Offset>
<AbsDimension x="192" y="-162" />
<AbsDimension x="192" y="-200" />
</Offset>
</Anchor>
</Anchors>
......@@ -257,7 +257,7 @@
<Anchors>
<Anchor point="TOPLEFT">
<Offset>
<AbsDimension x="136" y="-162" />
<AbsDimension x="136" y="-200" />
</Offset>
</Anchor>
</Anchors>
......@@ -268,6 +268,52 @@
</Scripts>
</CheckButton>
<CheckButton name="$parentOvershieldOpacCheckBox" inherits="VuhDoCheckBoxTemplate">
<Anchors>
<Anchor point="TOPLEFT">
<Offset>
<AbsDimension x="247" y="-162" />
</Offset>
</Anchor>
</Anchors>
<Scripts>
<OnLoad>
VUHDO_lnfSetModel(self, "VUHDO_PANEL_SETUP.BAR_COLORS.OVERSHIELD.useOpacity");
</OnLoad>
</Scripts>
</CheckButton>
<CheckButton name="$parentOvershieldTextCheckBox" inherits="VuhDoCheckBoxTemplate">
<Anchors>
<Anchor point="TOPLEFT">
<Offset>
<AbsDimension x="192" y="-162" />
</Offset>
</Anchor>
</Anchors>
<Scripts>
<OnLoad>
VUHDO_lnfSetModel(self, "VUHDO_PANEL_SETUP.BAR_COLORS.OVERSHIELD.useText");
</OnLoad>
</Scripts>
</CheckButton>
<CheckButton name="$parentOvershieldBackCheckBox" inherits="VuhDoCheckBoxTemplate">
<Anchors>
<Anchor point="TOPLEFT">
<Offset>
<AbsDimension x="136" y="-162" />
</Offset>
</Anchor>
</Anchors>
<Scripts>
<OnLoad>
VUHDO_lnfSetModel(self, "VUHDO_PANEL_SETUP.BAR_COLORS.OVERSHIELD.useBackground");
</OnLoad>
</Scripts>
</CheckButton>
<CheckButton name="$parentShieldOpacCheckBox" inherits="VuhDoCheckBoxTemplate">
<Anchors>
<Anchor point="TOPLEFT">
......@@ -445,7 +491,7 @@
</OnLoad>
</Scripts>
</Frame>
<Frame name="$parentShielTexture" inherits="VuhDoContextColorSwatchTexture">
<Frame name="$parentShieldTexture" inherits="VuhDoContextColorSwatchTexture">
<Anchors>
<Anchor point="TOPLEFT">
<Offset>
......@@ -462,7 +508,7 @@
</Scripts>
</Frame>
<Frame name="$parentRangeTexture" inherits="VuhDoContextColorSwatchTexture">
<Frame name="$parentOvershieldTexture" inherits="VuhDoContextColorSwatchTexture">
<Anchors>
<Anchor point="TOPLEFT">
<Offset>
......@@ -470,6 +516,23 @@
</Offset>
</Anchor>
</Anchors>
<Scripts>
<OnLoad>
VUHDO_lnfSetModel(self, "VUHDO_PANEL_SETUP.BAR_COLORS.OVERSHIELD");
VUHDO_lnfInitColorSwatch(self, "Overshield Bar", "Overshield Bar");
VUHDO_lnfSetTooltip(self, nil);
</OnLoad>
</Scripts>
</Frame>
<Frame name="$parentRangeTexture" inherits="VuhDoContextColorSwatchTexture">
<Anchors>
<Anchor point="TOPLEFT">
<Offset>
<AbsDimension x="13" y="-200" />
</Offset>
</Anchor>
</Anchors>
<Scripts>
<OnLoad>
VUHDO_lnfSetModel(self, "VUHDO_PANEL_SETUP.BAR_COLORS.OUTRANGED");
......
......@@ -158,7 +158,7 @@
<Frame name="$parentShieldPanel" inherits="VuhDoPanelTemplate">
<Size>
<AbsDimension x="126" y="74" />
<AbsDimension x="126" y="113" />
</Size>
<Anchors>
<Anchor point="TOPLEFT">
......@@ -169,7 +169,7 @@
</Anchors>
<Frames>
<CheckButton name="$parentShielBarCheckButton" text="VUHDO_I18N_ENABLE" inherits="VuhDoCheckButtonTemplate">
<CheckButton name="$parentShieldBarCheckButton" text="VUHDO_I18N_ENABLE" inherits="VuhDoCheckButtonTemplate">
<Anchors>
<Anchor point="TOPLEFT">
<Offset>
......@@ -185,6 +185,23 @@
</Scripts>
</CheckButton>
<CheckButton name="$parentOvershieldBarCheckButton" text="VUHDO_I18N_SHOW_OVERSHIELD" inherits="VuhDoCheckButtonTemplate">
<Anchors>
<Anchor point="TOPLEFT">
<Offset>
<AbsDimension x="13" y="-70" />
</Offset>
</Anchor>
</Anchors>
<Scripts>
<OnLoad>
VUHDO_lnfSetModel(self, "VUHDO_CONFIG.SHOW_OVERSHIELD_BAR");
VUHDO_lnfSetTooltip(self, nil);
VUHDO_lnfAddConstraint(self, VUHDO_LF_CONSTRAINT_DISABLE, "VUHDO_CONFIG.SHOW_SHIELD_BAR", false);
</OnLoad>
</Scripts>
</CheckButton>
<Frame name="$parentTitleLabel" inherits="VuhDoLabelFrameTemplate">
<Layers>
<Layer>
......
......@@ -450,7 +450,10 @@
</Frames>
<Layers>
<Layer level="OVERLAY">
<Layer level="OVERLAY" textureSubLevel="5">
<Texture name="$parentOvsBar" hidden="true" file="Interface\AddOns\VuhDo\Images\overshield_bar" hWrapMode="REPEAT" vWrapMode="REPEAT"> </Texture>
</Layer>
<Layer level="OVERLAY" textureSubLevel="6">
<Texture name="$parentAggro" hidden="true" file="Interface\AddOns\VuhDo\Images\aggro">
<Size>
<AbsDimension x="10" y="20" />
......
......@@ -455,6 +455,15 @@ end
--
function VUHDO_getOvershieldBarTexture(aHealthBar)
return _G[aHealthBar:GetName() .. "OvsBar"];
end
--
local VUHDO_STATUSBAR_LEFT_TO_RIGHT = 1;
local VUHDO_STATUSBAR_RIGHT_TO_LEFT = 2;
......
......@@ -293,7 +293,6 @@ end
--
local tSummeLeft;
function VUHDO_getUnitOverallShieldRemain(aUnit)
return UnitGetTotalAbsorbs(aUnit) or 0;
end
......
......@@ -15,6 +15,7 @@ Bugfixes:
Improvements:
-- Added overshield bar to display excess absorption amount
--------------------------------------------------------------
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment