Quantcast

Fix some drycode mistakes

Andrew Mordecai [07-15-16 - 15:06]
Fix some drycode mistakes
Filename
Config.lua
Functions.lua
Layout.lua
README.md
diff --git a/Config.lua b/Config.lua
index dd368dd..1f58cee 100644
--- a/Config.lua
+++ b/Config.lua
@@ -54,5 +54,6 @@ Stardust.colors = {
 	}
 }

-setmetatable(Stardust.colors, oUF.colors)
-setmetatable(Stardust.colors.power, oUF.colors.power)
+setmetatable(Stardust.colors, { __index = oUF.colors })
+setmetatable(Stardust.colors.power, { __index = oUF.colors.power })
+
diff --git a/Functions.lua b/Functions.lua
index c28a09b..6ffe6e6 100644
--- a/Functions.lua
+++ b/Functions.lua
@@ -7,12 +7,32 @@
 local _, Stardust = ...

 ---------------------------
+-- General utility functions
+---------------------------
+
+local function abbrev(n)
+	if n > 1000000000 then
+		return format("%.0fb", n / 1000000000)
+	elseif n > 10000000 then
+		return format("%.0fm", n / 1000000)
+	elseif n > 1000000 then
+		return format("%.1fm", n / 1000000)
+	elseif n > 10000 then
+		return format("%.0fk", n / 1000)
+	elseif n > 1000 then
+		return format("%.1fk", n / 1000)
+	else
+		return n
+	end
+end
+
+---------------------------
 -- Health
 ---------------------------

 function Stardust.PostUpdateHealth(self, unit, cur, max)
 	self:SetValue(max - cur)
-	self.text:SetText(cur < max and -max + cur or "")
+	self.value:SetText(cur < max and abbrev(-max + cur) or "")
 	self.bg:SetVertexColor(0.15, 0.15, 0.15)
 end

@@ -24,8 +44,8 @@ end

 function Stardust.PostUpdatePower(self, unit, cur, max)
 	self:SetShown(max > 0)
-	self.text:SetText(cur)
-end
+	self.value:SetText(abbrev(cur))
+end

 ---------------------------
 -- ClassIcons
@@ -112,28 +132,34 @@ end

 function Stardust.PostUpdateStatusIcon(self)
 	if not self:IsShown() then return end
-	local icons, last = self.__owner.StatusIcons
+	local icons, x = self.__owner.StatusIcons, 2
 	for i = 1, #icons do
 		local icon = icons[i]
 		if icon == self then
 			break
-		elseif icon:IsShown() then
-			last = icon
+		elseif icon:IsShown() and icon:GetTexture() then
+			x = x + icon:GetWidth()
 		end
 	end
-	if last then
-		self:SetPoint("LEFT", last, "RIGHT", 0, 0)
-	else
-		self:SetPoint("LEFT", self.__owner.Health, "TOPLEFT", 3, 0)
-	end
+	self:SetPoint("LEFT", self.__owner.Health, "TOPLEFT", x + self.offsetX, 0 + self.offsetY)
 end

+local updatingCombatOrResting
+
 function Stardust.PostUpdateCombat(self)
-	self.__owner.Resting:ForceUpdate()
+	if not updatingCombatOrResting then
+		updatingCombatOrResting = true
+		self.__owner.Resting:ForceUpdate()
+		updatingCombatOrResting = nil
+	end
 end

 function Stardust.PostUpdateResting(self)
-	self.__owner.Combat:ForceUpdate()
+	if not updatingCombatOrResting then
+		updatingCombatOrResting = true
+		self.__owner.Combat:ForceUpdate()
+		updatingCombatOrResting = nil
+	end
 end

 ---------------------------
@@ -151,28 +177,29 @@ local GLOW_SEGMENTS = {
 	{ "LEFT", 0, 1/3, 1/3, 2/3, -1, 0 },
 }

-function Stardust.SetGlowColor(self, r, g, b, a)
+local function SetGlowColor(self, r, g, b, a)
 	for i = 1, #self.Glow do
 		self.Glow[i]:SetVertexColor(r, g, b, a)
 	end
 end

-function Stardust.SetGlowSize(self, size, offset)
+local function SetGlowSize(self, size, offset)
 	local Glow = self.Glow
 	for i = 1, #Glow do
 		Glow[i]:SetSize(size, size)
 	end

-	local d = d or floor(size * 2 / 3 + 0.5)
+	local d = offset or floor(size * 2 / 3 + 0.5)
 	Glow[1]:SetPoint("TOPLEFT", -d, d)
 	Glow[2]:SetPoint("TOPRIGHT", d, d)
 	Glow[3]:SetPoint("BOTTOMRIGHT", d, -d)
 	Glow[4]:SetPoint("BOTTOMLEFT", -d, -d)
-
+--[[
 	Glow[5]:SetShown(Glow[2]:GetLeft() > Glow[1]:GetRight())
 	Glow[6]:SetShown(Glow[2]:GetBottom() > Glow[3]:GetTop())
 	Glow[7]:SetShown(Glow[3]:GetLeft() > Glow[4]:GetLeft())
 	Glow[8]:SetShown(Glow[1]:GetBottom() > Glow[4]:GetTop())
+]]
 end

 function Stardust.CreateGlow(self)
@@ -197,17 +224,16 @@ function Stardust.CreateGlow(self)
 	-- BOTTOM
 	Glow[7]:SetPoint("LEFT", Glow[4], "RIGHT")
 	Glow[7]:SetPoint("RIGHT", Glow[3], "LEFT")
-
+
 	-- LEFT
 	Glow[8]:SetPoint("TOP", Glow[1], "BOTTOM")
 	Glow[8]:SetPoint("BOTTOM", Glow[4], "TOP")

-	SetGlowSize(self, 12)
-
 	self.Glow = Glow
 	self.SetBackdropBorderColor = SetGlowColor
 	self.SetGlowColor = SetGlowColor
 	self.SetGlowSize = SetGlowSize
+
 	return Glow
 end

diff --git a/Layout.lua b/Layout.lua
index 869fe4d..7f7828a 100644
--- a/Layout.lua
+++ b/Layout.lua
@@ -23,7 +23,7 @@ local function NewStatusBar(parent, textFont, textSize, noBG, noBackdrop)

 	if textFont and textSize then
 		bar.value = bar:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
-		bar.value:SetFont(LibSharedMedia:Fetch("font", textSize))
+		bar.value:SetFont(LibSharedMedia:Fetch("font", config.textFont), textSize)
 		bar.value:SetPoint("CENTER")
 	end

@@ -35,7 +35,7 @@ local function NewStatusBar(parent, textFont, textSize, noBG, noBackdrop)
 	end

 	if not noBackdrop then
-		bar.backdrop = Health:CreateTexture(nil, "BACKDROP")
+		bar.backdrop = bar:CreateTexture(nil, "BACKGROUND")
 		bar.backdrop:SetPoint("BOTTOMLEFT", -1, -1)
 		bar.backdrop:SetPoint("TOPRIGHT", 1, 1)
 		bar.backdrop:SetTexture(0, 0, 0)
@@ -75,7 +75,7 @@ local function NewBarGroup(parent, count, width, height)
 	return group
 end

-local function AddStatusIcon(self, element, size)
+local function AddStatusIcon(self, element, size, offsetX, offsetY)
 	local icon = self.Health:CreateTexture(nil, "OVERLAY")
 	icon:SetPoint("LEFT", self.Health, "TOPLEFT", 3, 0)
 	icon:SetSize(size or 16, size or 16)
@@ -83,6 +83,8 @@ local function AddStatusIcon(self, element, size)
 	self.StatusIcons = self.StatusIcons or {}
 	tinsert(self.StatusIcons, icon)

+	icon.offsetX = offsetX or 0
+	icon.offsetY = offsetY or 0
 	icon.PostUpdate = Stardust.PostUpdateStatusIcon
 	self[element] = icon
 	return icon
@@ -114,7 +116,7 @@ local function ApplyStyle(self, unit, isSingle)
 	-- Outer glow
 	---------------------------

-	self.Glow = CreateGlow(self)
+	self.Glow = Stardust.CreateGlow(self)

 	---------------------------
 	-- Health bar
@@ -147,6 +149,7 @@ local function ApplyStyle(self, unit, isSingle)

 	Power.colorDisconnected = true
 	Power.colorPower = true
+	Power.frequentUpdates = true
 	Power.PostUpdate = Stardust.PostUpdatePower
 	self.Power = Power

@@ -199,7 +202,7 @@ local function ApplyStyle(self, unit, isSingle)
 				local r, g, b = color[1], color[2], color[3]
 				totem:SetStatusBarColor(r, g, b)
 				totem.bg:SetVertexColor(r * mu, b * mu, g * mu)
-
+
 				local value = totem:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
 				value:SetFont(LibSharedMedia:Fetch("font", config.numberFont), 15)
 				value:SetPoint("CENTER")
@@ -215,7 +218,7 @@ local function ApplyStyle(self, unit, isSingle)
 	-- Druid mana
 	-- Warlock demonic fury
 	---------------------------
-
+
 	if class == "DRUID" or class == "WARLOCK" then
 		local bar = NewStatusBar(Health)
 		bar:SetPoint("TOPLEFT", 3, -3)
@@ -260,12 +263,12 @@ local function ApplyStyle(self, unit, isSingle)
 	-- Group status icons
 	---------------------------

-	AddStatusIcon("LFDRole")
-	AddStatusIcon("RaidRole") -- maintank, mainassist
-	AddStatusIcon("Leader")
-	AddStatusIcon("Assistant")
-	AddStatusIcon("MasterLooter")
-	AddStatusIcon("PvP")
+	AddStatusIcon(self, "LFDRole", 24)
+	AddStatusIcon(self, "RaidRole") -- maintank, mainassist
+	AddStatusIcon(self, "Leader")
+	AddStatusIcon(self, "Assistant")
+	AddStatusIcon(self, "MasterLooter", nil, 0, 1)
+	AddStatusIcon(self, "PvP", 32, 0, -5) -- TODO: move it somewhere else?

 	---------------------------
 	-- Combat icon
@@ -366,11 +369,26 @@ local function ApplyStyle(self, unit, isSingle)
 		insideAlpha = 1,
 		outsideAlpha = 0.5
 	}
+
+	---------------------------
+	-- oUF_SmoothUpdate plugin support
+	---------------------------
+
+	if self.SmoothBar then
+		self:SmoothBar(self.Health)
+		self:SmoothBar(self.Power)
+		if self.DemonicFury then
+			self:SmoothBar(self.DemonicFury)
+		end
+		if self.DruidMana then
+			self:SmoothBar(self.DruidMana)
+		end
+	end
 end

 oUF:Factory(function(self)
 	self:RegisterStyle("Stardust", ApplyStyle)
-	self:SetActiveStyle("Stardust")
+	self:SetActiveStyle("Stardust")

 	local player = self:Spawn("player")
 	player:SetPoint("BOTTOMRIGHT", UIParent, "BOTTOM", -175, 235)
diff --git a/README.md b/README.md
index 07962b8..4201bfc 100644
--- a/README.md
+++ b/README.md
@@ -1,19 +1,21 @@
 oUF Stardust
 ============

-oUF Stardust is a layout for Haste's oUF unit frame framework. The look is
+oUF Stardust is a layout for Haste's oUF unit frame framework. The look is
 mainly inspired by oUF Qulight, and some code is borrowed from oUF Phanx.

 - **Supported units:** player, pet, target, targettarget, focus, focustarget
 - **Standard features:** health, power, combo points, threat glow, all the usual
   status icons
-- **Secondary resources:** demonic fury, soul shards, druid mana, holy power,
-  runes, shadow orbs, totems (including ghouls and mushrooms)
-- **Supported plugins:** oUF MovableFrames, oUF Smooth (install them separately)
+- **Secondary resources:** burning embers, demonic fury, soul shards, druid mana,
+  holy power, runes, shadow orbs, totems (including ghouls and mushrooms)

 Some configuration is available by editing the `config.lua` file. If WoW is
 open, you'll need to `/reload` the UI after saving your changes.

+You can use [oUF MovableFrames](http://www.wowinterface.com/downloads/info15425-oUFMovableFrames.html)
+to move the frames around.
+

 Unfinished / Missing Features
 -----------------------------
@@ -23,7 +25,6 @@ Many features aren't finished yet, or haven't been tested much (or at all).

 **Unfinished**, but will be added sooner or later, in roughly this order:

-- burning embers
 - casting bars
 - selected auras (boss debuffs, dispellable debuffs, important class auras)
 - party and partypet frames
@@ -45,15 +46,17 @@ Contributing
 ------------

 If you've discovered a bug in oUF Stardust, the preferred way to let me know
-about it is by opening an issue ticket on the [GitLab project page][1]. You
-can also log into GitLab using your Google, Twitter, or GitHub account.
+about it is by opening an issue ticket on the [GitLab project page][(https://gitlab.com/armordecai/ouf-stardust/issues).
+You don't need to create an account — you can log into GitLab with your Google
+or Twitter account!

-    [1]: https://gitlab.com/armordecai/ouf-stardust/issues
+You can also [email me](mailto:armordecai@protonmail.ch) or send me (Akkorian)
+a private message on WoWInterface.com instead.


 Legal
 -----

-oUF Stardust is published under the zlib/libpng license. See the included
+oUF Stardust is published under the zlib/libpng license. See the included
 LICENSE.txt file for more details.