diff --git a/CHANGELOG.txt b/CHANGELOG.txt index dcc7702..0d22ad1 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -1,12 +1,16 @@ ## Version History +#### 0.7.1 +Update width when attached to playerframe +Add Bliz-like option to text to match blizzard layout. + #### 0.7.0 -Alter events we act on -Fix [mana regen in combat bug](https://github.com/tekHudson/DruidBarClassic/issues/2) -Little more code cleanup +Alter events we act on. +Fix [mana regen in combat bug](https://github.com/tekHudson/DruidBarClassic/issues/2). +Little more code cleanup. #### 0.6.0 -Change versioning +Change versioning. #### 0.5 Update Icon to use LibDBIcon. diff --git a/DruidBar.lua b/DruidBar.lua index 502d168..c2f148e 100644 --- a/DruidBar.lua +++ b/DruidBar.lua @@ -111,13 +111,13 @@ function DruidBar_OnUpdate(self, elapsed) end --Graphics OFF else - dbarhide(DruidBarFrame); - dbarhide(DruidBarReplaceText); + dbarHide(DruidBarFrame); + dbarHide(DruidBarReplaceText); if PlayerFrameManaBar:GetWidth() < 100 then PlayerFrameManaBar:SetWidth(120); end end else - dbarhide(DruidBarFrame); - dbarhide(DruidBarUpdateFrame); + dbarHide(DruidBarFrame); + dbarHide(DruidBarUpdateFrame); end end @@ -260,19 +260,19 @@ function DruidBar_ChangeForm(id) end end -function dbarhide(frame) +function dbarHide(frame) if frame:IsVisible() then frame:Hide(); end end -function dbarshow(frame) +function dbarShow(frame) if not frame:IsVisible() then frame:Show(); end end -function dbarlen() +function dbarLength() if not DruidBarKey.xvar then DruidBarKey.xvar = 170; end if DruidBarFrame:GetWidth() ~= DruidBarKey.xvar then @@ -285,7 +285,7 @@ function dbarlen() DruidBarDontMove:SetWidth(DruidBarKey.xvar*0.95); end -function dbarhei() +function dbarHeight() if not DruidBarKey.yvar then DruidBarKey.yvar = 18; end if DruidBarFrame:GetHeight() ~= DruidBarKey.yvar then @@ -298,91 +298,122 @@ function dbarhei() DruidBarDontMove:SetHeight(DruidBarKey.yvar*(2/3)); end -function DruidBar_MainGraphics() - local str; - - -- If we are ucung percent, calculate percentage - if DruidBarKey.Percent and DruidBarKey.Percent == 1 then - str = "|CFFFFFFFF"..floor(DruidBarKey.currentmana / DruidBarKey.maxmana * 100).."%|r"; - elseif DruidBarKey.Percent then - str = "|CFFFFFFFF"..floor(DruidBarKey.currentmana).."/"..floor(DruidBarKey.maxmana).."|r"; - else - str = "|CFFFFFFFF"..floor(DruidBarKey.currentmana).."/"..floor(DruidBarKey.maxmana).." "..floor(DruidBarKey.currentmana / DruidBarKey.maxmana * 100).."%|r"; - end - - dbarhide(DruidBarReplaceText); - - if PlayerFrameManaBar:GetWidth() < 100 then PlayerFrameManaBar:SetWidth(120); end - +function Minimap_Button_Renderer() -- If Minimap Icon should show based on settings if DruidBarKey.Minimap then DruidBar_MinimapButton:Show("DruidBarMinimapIcon"); else DruidBar_MinimapButton:Hide("DruidBarMinimapIcon"); end - -- If DruidBar should show based on settings +end + +function DruidBar_MainGraphics() + dbarHide(DruidBarReplaceText); + Minimap_Button_Renderer() + + if PlayerFrameManaBar:GetWidth() < 100 then PlayerFrameManaBar:SetWidth(120); end + + -- If DruidBar should render based on settings if DruidBar_ShouldBeVisible() then - -- Render DruidBar - dbarshow(DruidBarFrame); - dbarshow(DruidBarManaBackground); - dbarshow(DruidBarBorder); - - -- Text options -- - if (DruidBarKey.Text and DruidBarKey.Text == 1) or (not DruidBarKey.Text and MouseIsOver(DruidBarDontMove)) then - dbarshow(DruidBarText1); - dbarhide(DruidBarText); - DruidBarText1:SetText(str); - elseif DruidBarKey.Text then - dbarshow(DruidBarText); - dbarhide(DruidBarText1); - DruidBarText:SetText(str); - else - dbarhide(DruidBarText); - dbarhide(DruidBarText1); - end + -- Render DruidBar Frame, Background, and Border + dbarShow(DruidBarFrame); + dbarShow(DruidBarManaBackground); + dbarShow(DruidBarBorder); - dbarlen(); - dbarhei(); + DruidBar_TextRenderer(); + dbarLength(); + dbarHeight(); + + -- Set location of DruidBar if DruidBarKey.Player then DruidBarFrame:ClearAllPoints(); - DruidBarFrame:SetPoint("TOPLEFT","PlayerFrame","TOPLEFT", 80, -63); - -- PlayerFrame:SetFrameLevel("1"); - -- DruidBarFrame:SetFrameLevel("1"); - -- DruidBarMana:SetFrameLevel("1"); + DruidBarFrame:SetPoint("TOPRIGHT","PlayerFrame","BOTTOMRIGHT", -3, 35); DruidBar_Anchored = true; elseif DruidBar_Anchored then DruidBarFrame:ClearAllPoints(); DruidBarFrame:SetPoint("CENTER","UIParent","CENTER", 0, 0); - -- PlayerFrame:SetFrameLevel("1") - -- DruidBarFrame:SetFrameLevel("1"); - -- DruidBarMana:SetFrameLevel("1"); DruidBar_Anchored = nil; end if DruidBarKey.Lock then - dbarshow(DruidBarDontMove); + dbarShow(DruidBarDontMove); DruidBarFrame:EnableMouse(0); else - dbarhide(DruidBarDontMove); + dbarHide(DruidBarDontMove); DruidBarFrame:EnableMouse(1); end else - dbarhide(DruidBarFrame); - dbarhide(DruidBarDontMove); + dbarHide(DruidBarFrame); + dbarHide(DruidBarDontMove); + end +end + +function DruidBar_TextRenderer() + dbarHide(DruidBarTextLeft); + dbarHide(DruidBarTextCenter); + dbarHide(DruidBarTextRight); + + -- Text options -- + if DruidBarKey.Text or (not DruidBarKey.Text and MouseIsOver(DruidBarDontMove)) then + if DruidBarKey.Percent then + if DruidBarKey.Percent == 0 then -- Numbers + dbarShow(DruidBarTextCenter); + DruidBarTextCenter:SetText(ManaValues()); + DruidBarTextCenter:SetTextColor(1,1,1,1); + elseif DruidBarKey.Percent == 1 then -- Percent + dbarShow(DruidBarTextCenter); + DruidBarTextCenter:SetText(ManaPercentage()); + DruidBarTextCenter:SetTextColor(1,1,1,1); + elseif DruidBarKey.Percent == 2 then -- Bliz-Like + dbarShow(DruidBarTextLeft); + dbarShow(DruidBarTextRight); + DruidBarTextLeft:SetText(ManaPercentage()); + DruidBarTextRight:SetText(ManaValues()); + DruidBarTextLeft:SetTextColor(1,1,1,1); + DruidBarTextRight:SetTextColor(1,1,1,1); + end + else -- Both + dbarShow(DruidBarTextCenter); + DruidBarTextCenter:SetText(ManaValuesAndPercentage()); + DruidBarTextCenter:SetTextColor(1,1,1,1); + end + + if DruidBarKey.Text == 0 then + DruidBarTextLeft:SetFontObject("GameTooltipTextSmall"); + DruidBarTextCenter:SetFontObject("GameTooltipTextSmall"); + DruidBarTextRight:SetFontObject("GameTooltipTextSmall"); + elseif DruidBarKey.Text == 1 then + DruidBarTextLeft:SetFontObject("TextStatusBarText"); + DruidBarTextCenter:SetFontObject("TextStatusBarText"); + DruidBarTextRight:SetFontObject("TextStatusBarText"); + end end end +function ManaValuesAndPercentage() + return ManaValues().." "..ManaPercentage(); +end + +function ManaValues() + return floor(DruidBarKey.currentmana).."/"..floor(DruidBarKey.maxmana); +end + +function ManaPercentage() + return floor(DruidBarKey.currentmana / DruidBarKey.maxmana * 100).."%"; +end + function DruidBar_ReplaceGraphics() if UnitPowerType("player") ~= 0 then - dbarshow(DruidBarFrame); - dbarhide(DruidBarManaBackground); - dbarhide(DruidBarDontMove); - dbarhide(DruidBarBorder); - dbarhide(DruidBarText); - dbarhide(DruidBarText1); - dbarhide(PlayerFrameManaBarText); - dbarshow(DruidBarReplaceText); + dbarShow(DruidBarFrame); + dbarHide(DruidBarManaBackground); + dbarHide(DruidBarDontMove); + dbarHide(DruidBarBorder); + dbarHide(DruidBarTextLeft); + dbarHide(DruidBarTextCenter); + dbarHide(DruidBarTextRight); + dbarHide(PlayerFrameManaBarText); + dbarShow(DruidBarReplaceText); PlayerFrameManaBar:SetWidth(60); DruidBarFrame:ClearAllPoints(); DruidBarFrame:SetPoint("TOPLEFT","PlayerFrame","TOPLEFT", 116, -50); @@ -400,32 +431,32 @@ function DruidBar_ReplaceGraphics() end -- DruidBarReplaceText:SetFrameLevel("2"); if (DruidBarKey.Text and DruidBarKey.Text == 1) or (not DruidBarKey.Text and (MouseIsOver(DruidBarFrame) or MouseIsOver(PlayerFrameManaBar)))then - dbarshow(DEnergyText1); - dbarshow(DManaText1); - dbarhide(DManaText); - dbarhide(DEnergyText); + dbarShow(DEnergyText1); + dbarShow(DManaText1); + dbarHide(DManaText); + dbarHide(DEnergyText); DEnergyText1:SetText(str); DManaText1:SetText(str1); elseif DruidBarKey.Text then - dbarshow(DEnergyText); - dbarhide(DEnergyText1); - dbarshow(DManaText); - dbarhide(DManaText1); + dbarShow(DEnergyText); + dbarHide(DEnergyText1); + dbarShow(DManaText); + dbarHide(DManaText1); DEnergyText:SetText(str); DManaText:SetText(str1); else - dbarhide(DEnergyText); - dbarhide(DEnergyText1); - dbarhide(DManaText); - dbarhide(DManaText1); + dbarHide(DEnergyText); + dbarHide(DEnergyText1); + dbarHide(DManaText); + dbarHide(DManaText1); end else - dbarhide(DruidBarFrame); - dbarhide(DEnergyText); - dbarhide(DEnergyText1); - dbarhide(DManaText); - dbarhide(DManaText1); - dbarhide(DruidBarReplaceText); + dbarHide(DruidBarFrame); + dbarHide(DEnergyText); + dbarHide(DEnergyText1); + dbarHide(DManaText); + dbarHide(DManaText1); + dbarHide(DruidBarReplaceText); PlayerFrameManaBar:SetWidth(120); end end diff --git a/DruidBar.xml b/DruidBar.xml index 42c0381..511591e 100644 --- a/DruidBar.xml +++ b/DruidBar.xml @@ -40,16 +40,20 @@ </Layer> <Layer level="OVERLAY"> - <FontString name="DruidBarText" inherits="GameFontNormalSmall" wraponspaces="true"> + <FontString name="DruidBarTextLeft" inherits="GameFontNormalSmall" wraponspaces="true"> <Size> <AbsDimension x="0" y="60"/> </Size> <Anchors> - <Anchor point="CENTER" relativeTo="$Parent" relativePoint="CENTER"/> + <Anchor point="LEFT" relativeTo="$Parent" relativePoint="LEFT"> + <Offset> + <AbsDimension x="5" y="0"/> + </Offset> + </Anchor> </Anchors> </FontString> - <FontString name="DruidBarText1" inherits="TextStatusBarText" wraponspaces="true"> + <FontString name="DruidBarTextCenter" inherits="GameFontNormalSmall" wraponspaces="true"> <Size> <AbsDimension x="0" y="60"/> </Size> @@ -57,6 +61,19 @@ <Anchor point="CENTER" relativeTo="$Parent" relativePoint="CENTER"/> </Anchors> </FontString> + + <FontString name="DruidBarTextRight" inherits="GameFontNormalSmall" wraponspaces="true"> + <Size> + <AbsDimension x="0" y="60"/> + </Size> + <Anchors> + <Anchor point="RIGHT" relativeTo="$Parent" relativePoint="RIGHT"> + <Offset> + <AbsDimension x="-5" y="0"/> + </Offset> + </Anchor> + </Anchors> + </FontString> </Layer> </Layers> diff --git a/DruidBarClassic.toc b/DruidBarClassic.toc index 35ee745..960850b 100644 --- a/DruidBarClassic.toc +++ b/DruidBarClassic.toc @@ -4,7 +4,7 @@ ## Current Author: Tek (port to WoW Classic Beta) ## Original Authors: SkaDemon (GUI: DiabloHu) ## SavedVariables: DruidBarKey -## Version: 0.7.0 +## Version: 0.7.1 ## X-Curse-Project-ID: 334762 ## X-WoWI-ID: 25036 diff --git a/Options.lua b/Options.lua index c3eabb7..9b213a1 100644 --- a/Options.lua +++ b/Options.lua @@ -71,6 +71,24 @@ function DRUIDBAROptions_Minimap() DRUIDBAR_FrameSet(); end +function DRUIDBAROptions_HideInCaster() + if(DruidBarKey.HideInCaster) then + DruidBarKey.HideInCaster = false; + else + DruidBarKey.HideInCaster = true; + end + DRUIDBAR_FrameSet(); +end + +function DRUIDBAROptions_Full() + if(DruidBarKey.HideWhenFull) then + DruidBarKey.HideWhenFull = false; + else + DruidBarKey.HideWhenFull = true; + end + DRUIDBAR_FrameSet(); +end + function DRUIDBAROptions_Replace() DruidBarKey.Replace = true; DruidBarKey.Player = false; @@ -84,7 +102,7 @@ function DRUIDBAROptions_Player() DruidBarKey.Player = true; DruidBarKey.Custom = false; --Assign value that default to match player frame - DruidBarKey.xvar = 150; + DruidBarKey.xvar = 125; DruidBarKey.yvar = 18; DruidBarKey.Lock = true; DRUIDBAR_FrameSet(); @@ -109,24 +127,6 @@ function DRUIDBAROptions_Lock() DRUIDBAR_FrameSet(); end -function DRUIDBAROptions_HideInCaster() - if(DruidBarKey.HideInCaster) then - DruidBarKey.HideInCaster = false; - else - DruidBarKey.HideInCaster = true; - end - DRUIDBAR_FrameSet(); -end - -function DRUIDBAROptions_Full() - if(DruidBarKey.HideWhenFull) then - DruidBarKey.HideWhenFull = false; - else - DruidBarKey.HideWhenFull = true; - end - DRUIDBAR_FrameSet(); -end - function DRUIDBAROptions_Text_Initialize() local info; for i = 0, 2, 1 do @@ -167,7 +167,7 @@ end function DRUIDBAROptions_Percent_Initialize() local info; - for i = 0, 2, 1 do + for i = 0, 3, 1 do info = { }; info.text = DRUIDBAR_OPTIONS_DROP.Percent[i]; info.func = DRUIDBAROptions_Percent_OnClick; @@ -183,20 +183,24 @@ function DRUIDBAROptions_Percent_OnShow() UIDropDownMenu_SetSelectedID(DRUIDBAROptionsPercentDropDown, 2); elseif( DruidBarKey.Percent == nil ) then UIDropDownMenu_SetSelectedID(DRUIDBAROptionsPercentDropDown, 3); + elseif( DruidBarKey.Percent == 2 ) then + UIDropDownMenu_SetSelectedID(DRUIDBAROptionsPercentDropDown, 4); end - UIDropDownMenu_SetWidth(DRUIDBAROptionsPercentDropDown, 112); + UIDropDownMenu_SetWidth(DRUIDBAROptionsPercentDropDown, 100); end function DRUIDBAROptions_Percent_OnClick(self) i = self:GetID(); UIDropDownMenu_SetSelectedID(DRUIDBAROptionsPercentDropDown, i); - if(i == 1) then + if(i == 1) then -- Numbers DruidBarKey.Percent = 0; - elseif(i == 2) then + elseif(i == 2) then -- Percent DruidBarKey.Percent = 1; - elseif(i == 3) then + elseif(i == 3) then -- Both DruidBarKey.Percent = nil; + elseif(i == 4) then -- Bliz-like + DruidBarKey.Percent = 2; end end diff --git a/localization.lua b/localization.lua index 957cbac..58e02ae 100644 --- a/localization.lua +++ b/localization.lua @@ -57,12 +57,13 @@ DRUIDBAR_OPTIONS_DROP = { ["Text"] = { [0] = "Original"; [1] = "New"; - [2] = "No Text"; + [2] = "Mouseover"; }; ["Percent"] = { [0] = "Raw numbers"; [1] = "Percentages"; - [2] = "Both above"; + [2] = "Both"; + [3] = "Bliz-like"; }; ["Message"] = { [0] = "SAY";