Quantcast

new fun stuff

Munglunch [04-06-15 - 16:24]
new fun stuff
Filename
SVUI_!Core/system/_reports/experience.lua
SVUI_!Core/system/core.lua
SVUI_!Core/system/credits.lua
SVUI_!Options/UnitFrames.lua
diff --git a/SVUI_!Core/system/_reports/experience.lua b/SVUI_!Core/system/_reports/experience.lua
index 141518f..6364e70 100644
--- a/SVUI_!Core/system/_reports/experience.lua
+++ b/SVUI_!Core/system/_reports/experience.lua
@@ -3,7 +3,7 @@
 S V U I   By: Munglunch
 ##############################################################################

-##########################################################
+##########################################################
 LOCALIZED LUA FUNCTIONS
 ##########################################################
 ]]--
@@ -21,8 +21,8 @@ local min       = math.min
 local UnitXP    = _G.UnitXP;
 local UnitXPMax = _G.UnitXPMax;
 local GetXPExhaustion  = _G.GetXPExhaustion;
---[[
-##########################################################
+--[[
+##########################################################
 GET ADDON DATA
 ##########################################################
 ]]--
@@ -30,31 +30,59 @@ local SV = select(2, ...)
 local L = SV.L;
 local LSM = _G.LibStub("LibSharedMedia-3.0")
 local Reports = SV.Reports;
---[[
-##########################################################
+--[[
+##########################################################
 EXPERIENCE STATS
 ##########################################################
 ]]--
 local HEX_COLOR = "22FFFF";
 local TEXT_PATTERN = "|cff%s%s|r";
-
-local function FormatExp(value, maxValue)
-	local trunc, calc;
+local EXP_FORMAT = "%.?0+([kmb])$","%1";
+local function FormatExp(value, maxValue, r_value, exhaust)
+		local trunc, calc, r_trunc, r_calc;
     if value >= 1e9 then
-        trunc = ("%.1fb"):format(value/1e9):gsub("%.?0+([kmb])$","%1")
-    elseif value >= 1e6 then
-        trunc = ("%.1fm"):format(value/1e6):gsub("%.?0+([kmb])$","%1")
-    elseif value >= 1e3 or value <= -1e3 then
-        trunc = ("%.1fk"):format(value/1e3):gsub("%.?0+([kmb])$","%1")
-    else
+        trunc = ("%.1fb"):format(value/1e9):gsub(EXP_FORMAT)
+    elseif value >= 1e6 then
+        trunc = ("%.1fm"):format(value/1e6):gsub(EXP_FORMAT)
+    elseif value >= 1e3 or value <= -1e3 then
+        trunc = ("%.1fk"):format(value/1e3):gsub(EXP_FORMAT)
+    else
         trunc = value
     end
-    if((value > 0) and (maxValue > 0)) then
-    	calc = (value / maxValue) * 100
+
+		local remain = r_value or (maxValue - value);
+		if remain >= 1e9 then
+				r_trunc = ("%.1fb"):format(remain/1e9):gsub(EXP_FORMAT)
+    elseif remain >= 1e6 then
+				r_trunc = ("%.1fm"):format(remain/1e6):gsub(EXP_FORMAT)
+    elseif remain >= 1e3 or value <= -1e3 then
+				r_trunc = ("%.1fk"):format(remain/1e3):gsub(EXP_FORMAT)
     else
-    	calc = maxValue
+				r_trunc = remain
     end
-    return trunc, calc
+
+		if(exhaust and exhaust > 0) then
+			trunc = "|cff1188FF" .. trunc .. "|r";
+			r_trunc = "|cff1188FF" .. r_trunc .. "|r";
+		end
+
+    if(maxValue > 0) then
+			if(value > 0) then
+    		calc = (value / maxValue) * 100
+			else
+				calc = 100
+			end
+			if(remain > 0) then
+				r_calc = (remain / maxValue) * 100
+			else
+				r_calc = 100
+			end
+    else
+    	calc = 100
+			r_calc = 100
+    end
+
+    return trunc, calc, r_trunc, r_calc
 end

 local function FetchExperience()
@@ -73,10 +101,12 @@ local function FetchExperience()
 		exp = 0
 	end

-	return xp,mxp,exp
+	local rxp = mxp - xp;
+
+	return xp,mxp,exp,rxp
 end
---[[
-##########################################################
+--[[
+##########################################################
 STANDARD TYPE
 ##########################################################
 ]]--
@@ -94,31 +124,22 @@ Report.OnEvent = function(self, event, ...)
 		self.text:SetAllPoints(self)
 		self.text:SetJustifyH("CENTER")
 		self.barframe:Hide()
-	end
-
-	local XP, maxXP, exhaust = FetchExperience()
-	local string1, calc1 = FormatExp(XP, maxXP);
-	local text = "";
-
-	if(exhaust > 0) then
-		local string2, calc2 = FormatExp(exhaust, maxXP);
-		text = format("%s - %d%% R:%s [%d%%]", string1, calc1, string2, calc2)
-	else
-		text = format("%s - %d%%", string1, calc1)
 	end

+	local XP, maxXP, exhaust, remaining = FetchExperience();
+	local _, _, text, _ = FormatExp(XP, maxXP, remaining, exhaust);
+
 	self.text:SetText(text)
 end

 Report.OnEnter = function(self)
 	Reports:SetDataTip(self)
-	local XP, maxXP, exhaust = FetchExperience()
+	local XP, maxXP, exhaust, remaining = FetchExperience();
 	Reports.ToolTip:AddLine(L["Experience"])
 	Reports.ToolTip:AddLine(" ")

 	if((XP > 0) and (maxXP > 0)) then
 		local calc1 = (XP / maxXP) * 100;
-		local remaining = maxXP - XP;
 		local r_percent = (remaining / maxXP) * 100;
 		local r_bars = r_percent / 5;
 		Reports.ToolTip:AddDoubleLine(L["XP:"], (" %d  /  %d (%d%%)"):format(XP, maxXP, calc1), 1, 1, 1)
@@ -130,8 +151,8 @@ Report.OnEnter = function(self)
 	end
 	Reports:ShowDataTip()
 end
---[[
-##########################################################
+--[[
+##########################################################
 BAR TYPE
 ##########################################################
 ]]--
@@ -151,14 +172,14 @@ ReportBar.OnEvent = function(self, event, ...)
 	end
 	if not self.barframe.bar.extra:IsShown() then
 		self.barframe.bar.extra:Show()
-	end
+	end
 	local bar = self.barframe.bar;
 	local XP, maxXP, exhaust = FetchExperience()

 	bar:SetMinMaxValues(0, maxXP)
 	bar:SetValue(XP)
 	bar:SetStatusBarColor(0, 0.5, 1)
-
+
 	if(exhaust > 0) then
 		local exhaust_value = min(XP + exhaust, maxXP);
 		bar.extra:SetMinMaxValues(0, maxXP)
@@ -168,19 +189,18 @@ ReportBar.OnEvent = function(self, event, ...)
 	else
 		bar.extra:SetMinMaxValues(0, 1)
 		bar.extra:SetValue(0)
-	end
+	end
 	self.text:SetText("")
 end

 ReportBar.OnEnter = function(self)
 	Reports:SetDataTip(self)
-	local XP, maxXP, exhaust = FetchExperience()
+	local XP, maxXP, exhaust, remaining = FetchExperience()
 	Reports.ToolTip:AddLine(L["Experience"])
 	Reports.ToolTip:AddLine(" ")

 	if((XP > 0) and (maxXP > 0)) then
 		local calc1 = (XP / maxXP) * 100;
-		local remaining = maxXP - XP;
 		local r_percent = (remaining / maxXP) * 100;
 		local r_bars = r_percent / 5;
 		Reports.ToolTip:AddDoubleLine(L["XP:"], (" %d  /  %d (%d%%)"):format(XP, maxXP, calc1), 1, 1, 1)
@@ -191,4 +211,4 @@ ReportBar.OnEnter = function(self)
 		end
 	end
 	Reports:ShowDataTip()
-end
\ No newline at end of file
+end
diff --git a/SVUI_!Core/system/core.lua b/SVUI_!Core/system/core.lua
index cdcc5b5..392dfe9 100644
--- a/SVUI_!Core/system/core.lua
+++ b/SVUI_!Core/system/core.lua
@@ -873,7 +873,7 @@ function SV:Initialize()

     collectgarbage("collect");

-    self.Timers:ExecuteTimer(self.RollCredits, 10)
+    self.Timers:ExecuteTimer(self.FlashTitle, 10)
 end
 --[[
 ##########################################################
diff --git a/SVUI_!Core/system/credits.lua b/SVUI_!Core/system/credits.lua
index 052271f..55e1437 100644
--- a/SVUI_!Core/system/credits.lua
+++ b/SVUI_!Core/system/credits.lua
@@ -30,7 +30,14 @@ local PRINTED_TEMPLATE = [[
 |cff4f4f4f---------------------------------------------|r

 |cffFFFF00THE HIGH COUNCIL  (aka EXECUTIVES):|r
-%s
+|cff33FF33SINNISTERR|r - (My wife, the MOST ruthless Warlock you will ever meet!)
+|cff33FF33PENGUINSANE|r - (The ace up my sleeve)
+|cff33FF33BLOODEAGLE|r - (The artisan tester)
+|cff33FF33HOTLUCK|r - (The profiler)
+|cff33FF33CROMAX|r - (The relentless)
+|cff33FF33DOONGA|r - (The man who keeps me busy)
+|cff33FF33DAIGAN|r - (Quality control with NO MERCY!)
+|cff33FF33FAOLANKING|r - (King of the bug report portal)
 |cff4f4f4f---------------------------------------------|r

 |cff99ff33KINGPINS  (aka INVESTORS):|r
@@ -51,8 +58,8 @@ The Wowinterface Community
 ]];

 local CreditFrame = _G["SVUI_CreditFrame"];
-local CreditTitle = _G["SVUI_CreditFrameTitle"];
-local CreditList = _G["SVUI_CreditFrameList"];
+CreditFrame.Title = _G["SVUI_CreditFrameTitle"];
+CreditFrame.List  = _G["SVUI_CreditFrameList"];
 local playerName = UnitName("player");

 SV.Credits = {};
@@ -62,14 +69,14 @@ SV.Credits["author"] = {
 };

 SV.Credits["council"] = {
-  "|cff33FF33SINNISTERR|r - (My wife, the MOST ruthless Warlock you will ever meet!)",
-  "|cff33FF33PENGUINSANE|r - (The ace up my sleeve)",
-  "|cff33FF33BLOODEAGLE|r - (The artisan tester)",
-  "|cff33FF33HOTLUCK|r - (The profiler)",
-  "|cff33FF33CROMAX|r - (The relentless)",
-  "|cff33FF33DOONGA|r - (The man who keeps me busy)",
-  "|cff33FF33DAIGAN|r - (Quality control with NO MERCY!)",
-  "|cff33FF33FAOLANKING|r - (King of the bug report portal)"
+  "SINNISTERR",
+  "PENGUINSANE",
+  "BLOODEAGLE",
+  "HOTLUCK",
+  "CROMAX",
+  "DOONGA",
+  "DAIGAN",
+  "FAOLANKING"
 };

 SV.Credits["investors"] = {
@@ -95,58 +102,69 @@ SV.Credits["community"] = {
   "Shinzou", "Autolykus", "Taotao", "ColorsGaming", "Necroo"
 };

-local ShowNextCredit, CreditFrame_OnUpdate;
 local ROLLED_CREDITS = 1;
+local DELAY = 0;
 local CREDITS_DATA = {
   {"Produced By: ", "council"},
   {"Sponsored In Part By: ", "investors"},
   {"Contributions Provided By: ", "contributors"},
   {"Community Support From: ", "community"},
   {"Written and Directed By: ", "author"},
-  {"Starring: ", playerName},
 };

-function ShowNextCredit()
-  if(ROLLED_CREDITS <= 6) then
-    local credit = CREDITS_DATA[ROLLED_CREDITS]
-    local list = SV.Credits[credit[2]];
-    local name = list and list[random(1, #list)] or credit[2];
-    CreditTitle:SetText(credit[1]);
-    CreditList:SetText(name);
-    CreditFrame:FadeIn(1);
-    ROLLED_CREDITS = ROLLED_CREDITS + 1;
-    CreditFrame:SetScript("OnUpdate", CreditFrame_OnUpdate)
-  else
-    ROLLED_CREDITS = 1;
-    CreditFrame:Hide();
-  end
-end
-
-local DELAY = 0;
-function CreditFrame_OnUpdate(self, elapsed)
+local function CreditFrame_OnUpdate(self, elapsed)
   DELAY = DELAY + elapsed
   if(DELAY < 3) then return end
   if(DELAY <= 3.5) then
-    CreditFrame:FadeOut(1);
+    CreditFrame:FadeOut(1,1,0,true);
   elseif(DELAY >= 7) then
     DELAY = 0
     self:SetScript("OnUpdate", nil)
-    ShowNextCredit()
+    if(self.CallBack) then
+      self:CallBack()
+    end
+  end
+end
+
+function CreditFrame:ShowMessage(title, text)
+  self:SetAlpha(0);
+  self:Show();
+  self.Title:SetText(title);
+  self.List:SetText(text);
+  self:FadeIn(1);
+  DELAY = 0;
+  self:SetScript("OnUpdate", CreditFrame_OnUpdate)
+end
+
+local CreditFrame_CallBack = function(self)
+  if(ROLLED_CREDITS <= 5) then
+    local credit = CREDITS_DATA[ROLLED_CREDITS]
+    local list = SV.Credits[credit[2]];
+    local name = list and list[random(1, #list)] or credit[2];
+    ROLLED_CREDITS = ROLLED_CREDITS + 1;
+    self:ShowMessage(credit[1], name);
+  else
+    self.CallBack = nil;
+    self:Hide();
   end
 end

 function SV:PrintCredits()
-  local council, investors, contributors, community;
-  council = concat(self.Credits["council"]);
+  local investors, contributors, community;
   investors = concat(self.Credits["investors"]);
   contributors = concat(self.Credits["contributors"]);
   community = concat(self.Credits["community"]);
-  return PRINTED_TEMPLATE:format(council, investors, contributors, community)
+  return PRINTED_TEMPLATE:format(investors, contributors, community)
 end

-function SV:RollCredits()
+function SV:FlashTitle()
+  CreditFrame:ShowMessage("The Adventures of...", playerName);
+end
+
+local function RollCredits()
   ROLLED_CREDITS = 1;
-  CreditFrame:SetAlpha(0);
-  CreditFrame:Show();
-  ShowNextCredit();
+  CreditFrame.CallBack = CreditFrame_CallBack;
+  CreditFrame:CallBack()
 end
+
+SV:AddSlashCommand("credits", "Display some randomly selected SVUI credits", RollCredits);
diff --git a/SVUI_!Options/UnitFrames.lua b/SVUI_!Options/UnitFrames.lua
index 1f85048..a5f4e23 100644
--- a/SVUI_!Options/UnitFrames.lua
+++ b/SVUI_!Options/UnitFrames.lua
@@ -4929,7 +4929,7 @@ SV.Options.args[Schema] = {
 									set = function(key, value)
 										MOD:ChangeDBVar(value, key[#key], "tank", "grid");
 										MOD:SetGroupFrame("tank");
-										SV.Options.args.UnitFrames.args.commonGroup.args.tank.args.tabGroups.args.sizing = SVUIOptions:SetSizeConfigGroup(value, "tank");
+										SV.Options.args.UnitFrames.args.commonGroup.args.tank.args.commonGroup.args.sizing = SVUIOptions:SetSizeConfigGroup(value, "tank");
 									end,
 								},
 								invertGroupingOrder = {
@@ -4995,7 +4995,7 @@ SV.Options.args[Schema] = {
 									set = function(key, value)
 										MOD:ChangeDBVar(value, key[#key], "assist", "grid");
 										MOD:SetGroupFrame("assist");
-										SV.Options.args.UnitFrames.args.commonGroup.args.assist.args.tabGroups.args.sizing = SVUIOptions:SetSizeConfigGroup(value, "assist");
+										SV.Options.args.UnitFrames.args.commonGroup.args.assist.args.commonGroup.args.sizing = SVUIOptions:SetSizeConfigGroup(value, "assist");
 									end,
 								},
 								invertGroupingOrder = {