diff KBF.lua @ 54:c4324144d380

start adding configuration - options to toggle consolidated buff support. pkgmeta and embeds updates for the extra libs
author Chris Mellon <arkanes@gmail.com>
date Wed, 13 Jul 2011 21:30:32 -0500
parents 7d961c698b71
children 4d359ee4649c
line wrap: on
line diff
--- a/KBF.lua	Wed Jun 29 09:02:24 2011 -0500
+++ b/KBF.lua	Wed Jul 13 21:30:32 2011 -0500
@@ -6,15 +6,12 @@
 
 
 function kbf:OnInitialize()
+	-- config settings - account wide shared profile by default
+	self.db = LibStub("AceDB-3.0"):New("KBFSavedVars", self.defaultConfig, true)
 	-- create frames here so that they will be correctly stored in location cache by 
 	-- the UI.
 	self.anchor, self.secureHeader, self.consolidateHeader, self.consolidateProxy = self:CreateCoreFrames()
     self.debuffFrames = {}
-   	local defaultSettings = {
-		-- global bar settings
-		-- overrides for buffs
-		-- overrides for debuffs
-   	}
     self:RegisterEvent("UNIT_AURA")
     self:RegisterEvent("UNIT_ENTERING_VEHICLE", "PollForVehicleChange")
     self:RegisterEvent("UNIT_EXITING_VEHICLE", "PollForVehicleChange")
@@ -391,8 +388,8 @@
     local texture = "Interface\\TargetingFrame\\UI-StatusBar"
     -- Because of secureframe suckiness, these height & width numbers
     -- have to be consistent with the stuff in KBF.xml
-    local height = 16
-    local width = 200 -- this is the width *without* the icon
+    local height = self.staticConfig.BAR_HEIGHT
+    local width = self.staticConfig.BAR_WIDTH -- this is the width *without* the icon
     local font, _, style = GameFontHighlight:GetFont()
     local r = r or 0
     local g = g or 1
@@ -405,8 +402,8 @@
     local timertextcolor = {1, 1, 1, 1}
     if not frame then
         frame = CreateFrame("Button", nil, UIParent) -- the "top level" frame that represents the bar as a whole
-        frame:SetHeight(16)
-        frame:SetWidth(200 + 16)    
+        frame:SetHeight(height)
+        frame:SetWidth(width + height)
     end
     local bar = frame
     bar.icon = CreateFrame("Button", nil, bar) -- the icon
@@ -464,11 +461,13 @@
 function kbf:CreateCoreFrames()
 	-- this is the visible anchor frame that the user interacts with 
 	-- to move the buffs around
+	local height = self.staticConfig.BAR_HEIGHT
+    local width = self.staticConfig.BAR_WIDTH -- this is the width *without* the icon
     local anchor = CreateFrame("FRAME", "KBFAnchorFrame", UIParent)
     anchor:SetClampedToScreen(true)
     anchor:SetBackdrop({bgFile = "Interface/Tooltips/UI-Tooltip-Background", 
                          edgeFile = "Interface/Tooltips/UI-Tooltip-Border", 
-                         tile = true, tileSize = 16, edgeSize = 12,
+                         tile = true, tileSize = height, edgeSize = 12,
                          insets = { left = 4, right = 4, top = 4, bottom = 4 },
                          })
     local text = anchor:CreateFontString(nil, "OVERLAY") -- the label text
@@ -477,8 +476,8 @@
     text:SetPoint("TOPLEFT", anchor, "TOPLEFT", 0, 0)
     text:SetPoint("BOTTOMRIGHT", anchor, "BOTTOMRIGHT", 0, 0)
     text:SetText("KBF ANCHOR")
-    anchor:SetWidth(200 +16)
-    anchor:SetHeight(16)
+    anchor:SetWidth(height + width)
+    anchor:SetHeight(height)
     -- movability
     anchor:EnableMouse(true)
     anchor:SetMovable(true)
@@ -492,7 +491,9 @@
     
 	local secureHeader = CreateFrame("FRAME", "KBFBuffFrame", UIParent, "SecureAuraHeaderTemplate")
 	self:SetCommonSecureHeaderAttributes(secureHeader)
-    secureHeader:SetAttribute("consolidateTo", 99)
+	if self.db.profile.consolidateBuffs then
+	    secureHeader:SetAttribute("consolidateTo", 99)
+	end
     secureHeader:SetPoint("TOP", anchor, "TOP", 0, 0)
     
     -- this is the "button" in the aura flow that represents the consolidated buffs.
@@ -522,8 +523,8 @@
 	
 	-- position it relative to the proxy, so it can appear where we want it
     consolidateHeader:SetPoint("TOPRIGHT", anchor, "TOPLEFT", 0, 0)
-	consolidateHeader:SetWidth(200 +16)
-	consolidateHeader:SetHeight(16)
+	consolidateHeader:SetWidth(height + width)
+	consolidateHeader:SetHeight(height)
 	consolidateHeader:Show()
 	
     return anchor, secureHeader, consolidateHeader, consolidateProxy