Quantcast

Merge commit 'b924bc15d6f87a49200205c38c7ae0a1de2b0955'

Steven Jackson [07-27-15 - 23:14]
Merge commit 'b924bc15d6f87a49200205c38c7ae0a1de2b0955'
Filename
SVUI_!Core/libs/_SVUI_Lib/Registry.lua
SVUI_!Core/system/dock.lua
SVUI_!Core/system/layout.lua
SVUI_!Core/system/slash.lua
diff --git a/SVUI_!Core/libs/_SVUI_Lib/Registry.lua b/SVUI_!Core/libs/_SVUI_Lib/Registry.lua
index bdcecdf..2f06980 100644
--- a/SVUI_!Core/libs/_SVUI_Lib/Registry.lua
+++ b/SVUI_!Core/libs/_SVUI_Lib/Registry.lua
@@ -279,6 +279,30 @@ local meta_database = {

 --REGISTRY LOCAL HELPERS

+local function LoadingProxy(schema, obj)
+    if(not obj) then print(schema .. ' not found') return end
+    lib.CURRENT_SCHEMA = schema;
+    if(not obj.initialized) then
+        if(obj.Load and type(obj.Load) == "function") then
+            local _, catch = pcall(obj.Load, obj)
+            if(catch) then
+                CoreObject:HandleError(schema, "Load", catch)
+            else
+                obj.initialized = true
+            end
+        end
+    else
+        if(obj.ReLoad and type(obj.ReLoad) == "function") then
+            --print(schema .. ' Reloading')
+            local _, catch = pcall(obj.ReLoad, obj)
+            if(catch) then
+                CoreObject:HandleError(schema, "ReLoad", catch)
+            end
+        end
+    end
+    lib.CURRENT_SCHEMA = 'GENERAL';
+end
+
 local function OptionsProxy(schema, obj)
     if(not obj) then return end
     if(not obj.optionsLoaded) then
@@ -405,38 +429,14 @@ end

 --REGISTRY PUBLIC METHODS

-function lib:LoadingProxy(schema, obj)
-    if(not obj) then print(schema .. ' not found') return end
-    self.CURRENT_SCHEMA = schema;
-    if(not obj.initialized) then
-        if(obj.Load and type(obj.Load) == "function") then
-            local _, catch = pcall(obj.Load, obj)
-            if(catch) then
-                CoreObject:HandleError(schema, "Load", catch)
-            else
-                obj.initialized = true
-            end
-        end
-    else
-        if(obj.ReLoad and type(obj.ReLoad) == "function") then
-            --print(schema .. ' Reloading')
-            local _, catch = pcall(obj.ReLoad, obj)
-            if(catch) then
-                CoreObject:HandleError(schema, "ReLoad", catch)
-            end
-        end
-    end
-    self.CURRENT_SCHEMA = 'GENERAL';
-end
-
 function lib:RefreshModule(schema)
     local obj = CoreObject[schema]
-    self:LoadingProxy(schema, obj)
+    LoadingProxy(schema, obj)
 end

 function lib:RefreshPlugin(schema)
     local obj = _G[schema]
-    self:LoadingProxy(schema, obj)
+    LoadingProxy(schema, obj)
 end

 function lib:RefreshAll()
@@ -445,7 +445,7 @@ function lib:RefreshAll()
             local schema = MODULES[i];
             local obj = CoreObject[schema];
             if(obj) then
-                self:LoadingProxy(schema, obj)
+                LoadingProxy(schema, obj)
             end
         end
     end
@@ -454,7 +454,7 @@ function lib:RefreshAll()
             local schema = PLUGINS[i];
             local obj = _G[schema];
             if(obj) then
-                self:LoadingProxy(schema, obj)
+                LoadingProxy(schema, obj)
             end
         end
     end
@@ -1130,7 +1130,7 @@ function lib:Launch()
                         end
                     end

-                    self:LoadingProxy(schema, obj)
+                    LoadingProxy(schema, obj)
                 end
             end
         end
@@ -1170,7 +1170,7 @@ function lib:Launch()
                 end

                 if(not halt) then
-                    self:LoadingProxy(schema, obj)
+                    LoadingProxy(schema, obj)
                 end
             end
         end
diff --git a/SVUI_!Core/system/dock.lua b/SVUI_!Core/system/dock.lua
index c10a9b4..90f3041 100644
--- a/SVUI_!Core/system/dock.lua
+++ b/SVUI_!Core/system/dock.lua
@@ -1476,6 +1476,7 @@ MOD.BottomCenter = _G["SVUI_DockBottomCenter"];
 -- end

 local DockAlert_Activate = function(self, child)
+	if(not self.backdrop) then return end
 	local size = SV.db.Dock.buttonSize or 22;
 	self:SetHeight(size)
 	self.backdrop:Show()
@@ -1484,6 +1485,7 @@ local DockAlert_Activate = function(self, child)
 end

 local DockAlert_Deactivate = function(self)
+	if(not self.backdrop) then return end
 	self.backdrop:Hide()
 	self:SetHeight(1)
 end
diff --git a/SVUI_!Core/system/layout.lua b/SVUI_!Core/system/layout.lua
index 281afa8..8f494aa 100644
--- a/SVUI_!Core/system/layout.lua
+++ b/SVUI_!Core/system/layout.lua
@@ -19,9 +19,9 @@ local tonumber  = _G.tonumber;
 local string 	= _G.string;
 local math 		= _G.math;
 --[[ STRING METHODS ]]--
-local format, split = string.format, string.split;
+local format, split, upper, lower = string.format, string.split, string.upper, string.lower;
 --[[ MATH METHODS ]]--
-local min, floor = math.min, math.floor;
+local min, floor, ceil = math.min, math.floor, math.ceil;
 local parsefloat = math.parsefloat;
 --BLIZZARD API
 local CreateFrame           = _G.CreateFrame;
@@ -58,6 +58,8 @@ Layout.Sections = {
 	['GENERAL'] = {}
 };

+local CLOAKED_BG = CreateFrame('Frame', nil, UIParent)
+
 local UIPanels = {};
 UIPanels["AchievementFrame"] 				= { moving = false, snapped = false, canupdate = false, cansetpoint = false, centered = false };
 UIPanels["AuctionFrame"] 					= { moving = false, snapped = false, canupdate = false, cansetpoint = false, centered = false };
@@ -605,7 +607,7 @@ function Layout:Movable_OnDragStop()
 end

 function Layout:Movable_OnShow()
-	self:SetBackdropBorderColor(0.5, 0.5, 0.5)
+	self:SetBackdropBorderColor(0, 0.25, 1, 0.5)
 end

 function Layout:Movable_OnEnter()
@@ -614,7 +616,7 @@ function Layout:Movable_OnEnter()
 	self:SetAlpha(1)
 	if(CurrentFrameTarget ~= self) then
 		self.text:SetTextColor(0, 1, 1)
-		self:SetBackdropBorderColor(0, 0.7, 1)
+		self:SetBackdropBorderColor(0, 0.7, 1, 1)
 	end
 	UpdateFrameTarget = self;
 	Layout.Portrait:SetTexture([[Interface\AddOns\SVUI_!Core\assets\textures\Doodads\MENTALO-ON]])
@@ -625,8 +627,8 @@ end
 function Layout:Movable_OnLeave()
 	if TheHand.UserHeld then return end
 	if(CurrentFrameTarget ~= self) then
-		self.text:SetTextColor(0.5, 0.5, 0.5)
-		self:SetBackdropBorderColor(0.5, 0.5, 0.5)
+		self.text:SetTextColor(1, 1, 1)
+		self:SetBackdropBorderColor(0, 0.25, 1, 0.5)
 	end
 	Layout.Portrait:SetTexture([[Interface\AddOns\SVUI_!Core\assets\textures\Doodads\MENTALO-OFF]])
 	TheHand:Hide()
@@ -647,7 +649,7 @@ function Layout:Movable_OnMouseDown(button)
 		if(not SVUI_LayoutPrecision) then return end;
 		CurrentFrameTarget = self
 		self.text:SetTextColor(0.2, 1, 0)
-		self:SetBackdropBorderColor(0, 1, 0)
+		self:SetBackdropBorderColor(0, 1, 0, 1)
 		Layout:Movable_OnUpdate()
 		SVUI_LayoutPrecision:Show()
 	end
@@ -675,7 +677,13 @@ local function SetNewAnchor(frame, moveName, title, postDragFunc)
 	}
 	Layout.Sections.ALL[moveName] = true;
 	local currentCategory = SVUILib.CURRENT_SCHEMA;
-	Layout.Sections[currentCategory][moveName] = true;
+	if(currentCategory) then
+		currentCategory = upper(currentCategory)
+		if(not Layout.Sections[currentCategory]) then
+			Layout.Sections[currentCategory] = {}
+		end
+		Layout.Sections[currentCategory][moveName] = true;
+	end

 	local grip = CreateFrame("Button", moveName, SV.Screen)
 	grip:SetFrameLevel(frame:GetFrameLevel() + 1)
@@ -712,7 +720,7 @@ local function SetNewAnchor(frame, moveName, title, postDragFunc)
 	mtext:SetJustifyH("CENTER")
 	mtext:SetPoint("CENTER")
 	mtext:SetText(title or moveName)
-	mtext:SetTextColor(0.5, 0.5, 0.5)
+	mtext:SetTextColor(1, 1, 1)

 	grip:SetFontString(mtext)
 	grip.text = mtext;
@@ -792,7 +800,7 @@ function Layout:Update()
 	end
 end

-function Layout:Toggle(category)
+function Layout:Toggle(arg)
 	if(InCombatLockdown()) then return end
 	local enabled = false;
 	local aceConfig = LibStub("AceConfigDialog-1.0")
@@ -806,15 +814,31 @@ function Layout:Toggle(category)
 		if(frame) then frame:Hide() end
 	end
 	if(self:IsShown()) then
+		SV:AddonMessage('Frames are now locked!')
 		self:Hide()
 	else
-		local list = self.Sections[category] or self.Sections.ALL
-		for frameName, _ in pairs(list) do
-			local frame = _G[frameName];
-			if(frame) then frame:Show() end
+		--print(arg)
+		arg = arg or 'ALL';
+		local category = upper(arg);
+		if(category == 'HELP') then
+			SV:AddonMessage('You can use the following commands to specify which frame-groups you want to move at a time.')
+			for section,_ in pairs(self.Sections) do
+		        print('/sv move |cff00FF00' .. lower(section) .. '|r')
+			end
+		else
+			SV:AddonMessage('Frames are now unlocked!')
+			SV:AddonMessage('To see move commands type |cff00FF00/sv move help|r.')
+			local list = self.Sections[category]
+			for frameName, _ in pairs(list) do
+				local frame = _G[frameName];
+				if(frame) then frame:Show() end
+			end
+			self:Show()
 		end
-		self:Show()
 	end
+	-- for section, _ in pairs(self.Sections) do
+	-- 	print(section)
+	-- end
 end
 --[[
 ##########################################################
@@ -835,62 +859,47 @@ function Graph:Toggle(enabled)
 end

 function Graph:UpdateAllReports()
+	-- for the record, this SUCKED trying to optimize the math
 	local cellSize = SV.db.general.graphSize
 	self.CellSize = cellSize

 	self.Grid = CreateFrame('Frame', nil, UIParent)
 	self.Grid:SetAllPoints(SV.Screen)
+	self.Grid:SetFrameStrata('BACKGROUND')
+	self.Grid:SetFrameLevel(1)
+
+	local width = SV.Screen:GetWidth();
+	local height = SV.Screen:GetHeight();
+	local ratio = width / height;
+	local size = height * ratio;
+	local interval = size / cellSize;
+	local halfWidth = ceil(cellSize * 0.5);
+	local halfHeight = floor((height / interval) * 0.5);
+	--print('-------')print(width)print(height)
+	--print('-------')print(cellSize)
+	--print('-------')print(size)print(interval)
+	--print('-------')print(halfWidth)print(halfHeight)

-	local size = 1
-	local width = GetScreenWidth()
-	local baseHeight = GetScreenHeight()
-	local ratio = width / baseHeight
-	local height = baseHeight * ratio
-
-	local wStep = width / cellSize
-	local hStep = height / cellSize
-
-	local halfCell = cellSize * 0.5;
 	for i = 0, cellSize do
-		local xW = i*wStep;
+		local mod = i*interval;

-		local tx = self.Grid:CreateTexture(nil, 'BACKGROUND')
-		if(i == halfCell) then
-			tx:SetTexture(0, 1, 0, 0.8)
+		local xGrid = self.Grid:CreateTexture(nil, 'BACKGROUND')
+		local yGrid = self.Grid:CreateTexture(nil, 'BACKGROUND')
+		if(i == halfWidth) then
+			xGrid:SetTexture(0, 1, 0, 0.8)
 		else
-			tx:SetTexture(0, 0, 0, 0.8)
+			xGrid:SetTexture(0.1, 0.1, 0.1, 0.8)
+		end
+		if(i == halfHeight) then
+			yGrid:SetTexture(0, 1, 0, 0.8)
+		else
+			yGrid:SetTexture(0.1, 0.1, 0.1, 0.8)
 		end

-		tx:SetPoint("TOPLEFT", self.Grid, "TOPLEFT", (xW - 0.5), 0)
-		tx:SetPoint('BOTTOMRIGHT', self.Grid, 'BOTTOMLEFT', (xW + 0.5), 0)
-	end
-
-	height = GetScreenHeight()
-
-	do
-		local yW = (height * 0.5) + 0.5;
-		local tx = self.Grid:CreateTexture(nil, 'BACKGROUND')
-		tx:SetTexture(0, 1, 0, 0.8)
-		tx:SetPoint("TOPLEFT", self.Grid, "TOPLEFT", 0, (-(height * 0.5) + 0.5))
-		tx:SetPoint('BOTTOMRIGHT', self.Grid, 'TOPRIGHT', 0, -((height * 0.5) + 0.5))
-	end
-
-	for i = 1, floor(((height * 0.5) / hStep)) do
-		local tx = self.Grid:CreateTexture(nil, 'BACKGROUND')
-		tx:SetTexture(0, 0, 0, 0.8)
-
-		local y1 = -((height * 0.5) + (i * hStep)) + 0.5;
-		local y2 = -(((height * 0.5) + (i * hStep)) + 0.5);
-		tx:SetPoint("TOPLEFT", self.Grid, "TOPLEFT", 0, y1)
-		tx:SetPoint('BOTTOMRIGHT', self.Grid, 'TOPRIGHT', 0, y2)
-
-		tx = self.Grid:CreateTexture(nil, 'BACKGROUND')
-		tx:SetTexture(0, 0, 0, 0.8)
-
-		y1 = -((height * 0.5) + (i * hStep)) + 0.5;
-		y2 = -(((height * 0.5) + (i * hStep)) + 0.5);
-		tx:SetPoint("TOPLEFT", self.Grid, "TOPLEFT", 0, y1)
-		tx:SetPoint('BOTTOMRIGHT', self.Grid, 'TOPRIGHT', 0, y2)
+		xGrid:SetPoint("TOPLEFT", self.Grid, "TOPLEFT", (mod - 0.5), 0)
+		xGrid:SetPoint('BOTTOMRIGHT', self.Grid, 'BOTTOMLEFT', (mod + 0.5), 0)
+		yGrid:SetPoint("TOPLEFT", self.Grid, "TOPLEFT", 0, -mod + 0.5)
+		yGrid:SetPoint('BOTTOMRIGHT', self.Grid, 'TOPRIGHT', 0, -(mod + 0.5))
 	end

 	self.Grid:Hide()
@@ -1230,6 +1239,26 @@ LOAD BY TRIGGER
 ##########################################################
 ]]--
 local function InitializeMovables()
+	CLOAKED_BG:SetAllPoints(SV.Screen);
+	CLOAKED_BG:SetParent(Layout);
+	CLOAKED_BG:SetFrameStrata('BACKGROUND')
+	CLOAKED_BG:SetFrameLevel(0)
+	CLOAKED_BG:SetBackdrop({
+		bgFile = [[Interface\BUTTONS\WHITE8X8]],
+	    tile = false,
+	    tileSize = 0,
+	    edgeFile = [[Interface\AddOns\SVUI_!Core\assets\textures\EMPTY]],
+	    edgeSize = 1,
+	    insets =
+	    {
+	        left = 0,
+	        right = 0,
+	        top = 0,
+	        bottom = 0,
+	    },
+	});
+	CLOAKED_BG:SetBackdropColor(0,0,0,0.8);
+
 	Layout.Anchors = SV.db.LAYOUT or {}
 	--Layout:SetPanelColor("yellow")
 	Layout:RegisterForDrag("LeftButton")
@@ -1239,14 +1268,14 @@ local function InitializeMovables()

 	SVUI_LayoutLockButton:SetSize(110, 25)
 	SVUI_LayoutLockButton.Left:SetAlpha(0)
-  SVUI_LayoutLockButton.Middle:SetAlpha(0)
-  SVUI_LayoutLockButton.Right:SetAlpha(0)
-  SVUI_LayoutLockButton:SetNormalTexture("")
-  SVUI_LayoutLockButton:SetPushedTexture("")
-  SVUI_LayoutLockButton:SetPushedTexture("")
-  SVUI_LayoutLockButton:SetDisabledTexture("")
-  SVUI_LayoutLockButton:RemoveTextures()
-  SVUI_LayoutLockButton:SetFrameLevel(SVUI_LayoutLockButton:GetFrameLevel() + 1)
+	SVUI_LayoutLockButton.Middle:SetAlpha(0)
+	SVUI_LayoutLockButton.Right:SetAlpha(0)
+	SVUI_LayoutLockButton:SetNormalTexture("")
+	SVUI_LayoutLockButton:SetPushedTexture("")
+	SVUI_LayoutLockButton:SetPushedTexture("")
+	SVUI_LayoutLockButton:SetDisabledTexture("")
+	SVUI_LayoutLockButton:RemoveTextures()
+	SVUI_LayoutLockButton:SetFrameLevel(SVUI_LayoutLockButton:GetFrameLevel() + 1)
 	SVUI_LayoutLockButton.texture = SVUI_LayoutLockButton:CreateTexture(nil, "BORDER")
 	SVUI_LayoutLockButton.texture:SetSize(110, 50)
 	SVUI_LayoutLockButton.texture:SetPoint("CENTER", SVUI_LayoutLockButton, "CENTER", 0, -4)
@@ -1270,14 +1299,14 @@ local function InitializeMovables()

 	SVUI_LayoutGridButton:SetSize(110, 25)
 	SVUI_LayoutGridButton.Left:SetAlpha(0)
-  SVUI_LayoutGridButton.Middle:SetAlpha(0)
-  SVUI_LayoutGridButton.Right:SetAlpha(0)
-  SVUI_LayoutGridButton:SetNormalTexture("")
-  SVUI_LayoutGridButton:SetPushedTexture("")
-  SVUI_LayoutGridButton:SetPushedTexture("")
-  SVUI_LayoutGridButton:SetDisabledTexture("")
-  SVUI_LayoutGridButton:RemoveTextures()
-  SVUI_LayoutGridButton:SetFrameLevel(SVUI_LayoutGridButton:GetFrameLevel() + 1)
+	SVUI_LayoutGridButton.Middle:SetAlpha(0)
+	SVUI_LayoutGridButton.Right:SetAlpha(0)
+	SVUI_LayoutGridButton:SetNormalTexture("")
+	SVUI_LayoutGridButton:SetPushedTexture("")
+	SVUI_LayoutGridButton:SetPushedTexture("")
+	SVUI_LayoutGridButton:SetDisabledTexture("")
+	SVUI_LayoutGridButton:RemoveTextures()
+	SVUI_LayoutGridButton:SetFrameLevel(SVUI_LayoutGridButton:GetFrameLevel() + 1)
 	SVUI_LayoutGridButton.texture = SVUI_LayoutGridButton:CreateTexture(nil, "BORDER")
 	SVUI_LayoutGridButton.texture:SetSize(110, 50)
 	SVUI_LayoutGridButton.texture:SetPoint("CENTER", SVUI_LayoutGridButton, "CENTER", 0, -4)
@@ -1325,8 +1354,8 @@ local function InitializeMovables()

 	SVUI_LayoutPrecision:SetScript("OnHide", function()
 		if(not CurrentFrameTarget) then return end
-		CurrentFrameTarget.text:SetTextColor(0.5, 0.5, 0.5)
-		CurrentFrameTarget:SetBackdropBorderColor(0.5, 0.5, 0.5)
+		CurrentFrameTarget.text:SetTextColor(0.8, 0.4, 0)
+		CurrentFrameTarget:SetBackdropBorderColor(0.8, 0.4, 0)
 		CurrentFrameTarget = nil
 	end)

diff --git a/SVUI_!Core/system/slash.lua b/SVUI_!Core/system/slash.lua
index caec8d5..9684b0c 100644
--- a/SVUI_!Core/system/slash.lua
+++ b/SVUI_!Core/system/slash.lua
@@ -19,7 +19,7 @@ local table   		= _G.table;
 local GetTime 		= _G.GetTime;
 --[[ STRING METHODS ]]--
 local format = string.format;
-local lower, trim = string.lower, string.trim
+local lower, trim, split = string.lower, string.trim, string.split
 --[[ MATH METHODS ]]--
 local floor, modf = math.floor, math.modf;
 --[[ TABLE METHODS ]]--
@@ -65,11 +65,15 @@ function SV:AddSlashCommand(cmd, desc, fn)
     SVUI_SLASH_COMMAND_INFO[cmd] = desc;
 end

-local function SVUIMasterCommand(msg)
-	if msg then
-		msg = lower(trim(msg))
+local function SVUIMasterCommand(args)
+	if args then
+		-- print(args)
+		local arg1, arg2 = split(" ", args)
+		-- print(arg1)
+		-- print(arg2)
+		local msg = lower(trim(arg1))
 		if(SVUI_SLASH_COMMANDS[msg] and (type(SVUI_SLASH_COMMANDS[msg]) == 'function')) then
-			SVUI_SLASH_COMMANDS[msg]()
+			SVUI_SLASH_COMMANDS[msg](SV, arg2)
 		else
 			SV:ToggleConfig()
 		end