Removed hard dependency on Skada:FormatNumber from gui.
Peter Eliasson [01-17-15 - 14:03]
Removed hard dependency on Skada:FormatNumber from gui.
- gui will now use a default implementation if Skada is not enabled.
- Added addon version name to the gui title.
- Fixed implementation of CloseSpecialWindows not acting as it should.
diff --git a/src/gui.lua b/src/gui.lua
index 30c9eee..60fad70 100644
--- a/src/gui.lua
+++ b/src/gui.lua
@@ -16,6 +16,20 @@ local AceGUI = LibStub("AceGUI-3.0");
local classIdToClassName = {};
FillLocalizedClassList(classIdToClassName);
+
+function gui:FormatNumber(number)
+ if Skada and Skada.FormatNumber then
+ return Skada:FormatNumber(number)
+ else
+ -- Default to Skada's implementation with numberformat enabled
+ if number > 1000000 then
+ return ("%02.2fM"):format(number / 1000000)
+ else
+ return ("%02.1fK"):format(number / 1000)
+ end
+ end
+end
+
function gui:CreateHighScoreParseEntry(parse, role, rank)
local entryWidget = AceGUI:Create("SimpleGroup");
entryWidget:SetFullWidth(true);
@@ -34,7 +48,7 @@ function gui:CreateHighScoreParseEntry(parse, role, rank)
rankLabel:SetRelativeWidth(relativeWidth);
local dpsHpsLabel = AceGUI:Create("Label");
- local dpsHps = Skada:FormatNumber((role == "HEALER") and parse.hps or parse.dps);
+ local dpsHps = self:FormatNumber((role == "HEALER") and parse.hps or parse.dps);
dpsHpsLabel:SetText(dpsHps);
dpsHpsLabel:SetFontObject(GameFontHighlightSmall);
dpsHpsLabel:SetRelativeWidth(relativeWidth);
@@ -228,7 +242,7 @@ function gui:CreateMainFrame()
frame:Hide()
frame:SetWidth(800)
frame:SetHeight(600)
- frame:SetTitle("Guild Skada High Score")
+ frame:SetTitle(format("Guild Skada High Score (%s)", addon.versionName));
frame:SetLayout("Flow")
frame:SetCallback("OnClose", function()
gui:HideMainFrame()
@@ -409,17 +423,17 @@ function gui:HideMainFrame()
end
function gui:OnCloseSpecialWindows()
+ local found;
if self.mainFrame then
self:HideMainFrame()
- return true
- else
- return self.hooks["CloseSpecialWindows"]();
+ found = 1
end
+ return self.hooks["CloseSpecialWindows"]() or found;
end
function gui:OnEnable()
- self:RawHook("CloseSpecialWindows", "OnCloseSpecialWindows");
+ self:RawHook("CloseSpecialWindows", "OnCloseSpecialWindows", true);
end
function gui:OnDisable()
diff --git a/src/main.lua b/src/main.lua
index 197cd99..3f496b5 100644
--- a/src/main.lua
+++ b/src/main.lua
@@ -7,7 +7,13 @@ local tremove = tremove;
local addon = LibStub("AceAddon-3.0"):NewAddon(addonName, "AceConsole-3.0", "AceEvent-3.0")
tinsert(addonTable, addon);
-_G[addonName] = addon
+_G[addonName] = addon;
+
+-- Grab the current version string
+addon.versionName = GetAddOnMetadata(addonName, "Version");
+--@debug@
+addon.versionName = '0.0.0-debug';
+--@end-debug@
-- Set up a default prototype for all modules
local modPrototype = { Debug = function(self, ...) addon:Debug(...) end }