Quantcast

Make position configurable

Scott Sibley [09-11-10 - 22:57]
Make position configurable
Filename
Display.lua
config.lua
diff --git a/Display.lua b/Display.lua
index adabc9e..eaf3e44 100644
--- a/Display.lua
+++ b/Display.lua
@@ -21,6 +21,24 @@ Resources:New(resources)
 local _G = _G
 local GameTooltip = _G.GameTooltip

+local anchors = {
+	"TOP",
+	"TOPRIGHT",
+	"TOPLEFT",
+	"BOTTOM",
+	"BOTTOMRIGHT",
+	"BOTTOMLEFT",
+	"RIGHT",
+	"LEFT",
+	"CENTER"
+}
+
+local anchorsDict = {}
+
+for i, v in ipairs(anchors) do
+	anchorsDict[v] = i
+end
+
 local function copy(tbl)
 	local new = {}
 	for k, v in pairs(tbl) do
@@ -102,7 +120,7 @@ function mod:RebuildOpts()
 		name = "Add Display",
 		type = "input",
 		set = function(info, v)
-			self.db.profile.config["display_" .. v] = {name = v, layouts = {}, widgets = {}}
+			self.db.profile.config["display_" .. v] = {name = v, layouts = {}, widgets = {}, point = {"TOPLEFT", "UiParent", "BOTTOMLEFT", 0, -50}}
 			LCD4WoW:RebuildOpts()
 		end,
 		order = 1
@@ -213,6 +231,7 @@ function mod:RebuildOpts()
 		}
 	}
 	for k, v in pairs(self.db.profile.config) do
+		local db = v
 		if k:match("^display_.*") then
 			options.displays.args[k:gsub(" ", "_")] = {
 				name = k:gsub("display_", ""),
@@ -251,6 +270,53 @@ function mod:RebuildOpts()
 						end,
 						order = 3
 					},
+					point = {
+						name = "Anchor Points",
+						desc = "This histogram's anchor point. These arguments are passed to bar:SetPoint()",
+						type = "group",
+						args = {
+							point = {
+								name = "Bar anchor",
+								type = "select",
+								values = anchors,
+								get = function() return anchorsDict[db.point[1] or 1] end,
+								set = function(info, v) db.point[1] = anchors[v];clearHistograms();createHistograms() end,
+								order = 1
+							},
+							relativeFrame = {
+								name = "Relative Frame",
+								type = "input",
+								get = function() return db.point[2] end,
+								set = function(info, v) db.point[2] = v; clearHistograms(); createHistograms() end,
+								order = 2
+							},
+							relativePoint = {
+								name = "Relative Point",
+								type = "select",
+								values = anchors,
+								get = function() return anchorsDict[db.point[3] or 1] end,
+								set = function(info, v) db.point[3] = anchors[v]; clearHistograms(); createHistograms() end,
+								order = 3
+							},
+							xOfs = {
+								name = "X Offset",
+								type = "input",
+								pattern = "%d",
+								get = function() return tostring(db.point[4] or 0) end,
+								set = function(info, v) db.point[4] = tonumber(v); clearHistograms(); createHistograms() end,
+								order = 4
+							},
+							yOfs = {
+								name = "Y Offset",
+								type = "input",
+								pattern = "%d",
+								get = function() return tostring(db.point[5] or 0) end,
+								set = function(info, v) db.point[5] = tonumber(v); clearHistograms();createHistograms() end,
+								order = 4
+							}
+						},
+						order = 7
+					},
 					delete = {
 						name = "Delete",
 						type = "execute",
diff --git a/config.lua b/config.lua
index 7b531a8..7ee6165 100644
--- a/config.lua
+++ b/config.lua
@@ -15,7 +15,7 @@ local foo = 100
 LCD4WoW.config = {
     ["display_startip"] = {
 		["addon"] = "LCD4WoW",
-		["enabled"] = true,
+		["enabled"] = false,
 		["driver"] = "qtip",
 		["layers"] = 2,
 		["background"] = "d9ccf16f",
@@ -29,6 +29,7 @@ LCD4WoW.config = {
 		["widgets"] = {"widget_key_up", "widget_key_down", "widget_resources_timer"},
 		["layouts"] = {"layout_lcd4wow", "layout_histogram_cpu", "layout_histogram_mem"},
 		["font"] = {normal="Interface\\AddOns\\LCD4WoW\\Fonts\\ttf-bitstream-vera-1.10\\VeraMo.ttf", bold="Interface\\AddOns\\LCD4WoW\\Fonts\\ttf-bitstream-vera-1.10\\VeraMoBd.ttf", size=12},
+		["point"] = {"CENTER", "UIParent", "CENTER", 0, 200}
     },
     ["display_character"] = {
 		["addon"] = "LCD4WoW",
@@ -46,10 +47,11 @@ LCD4WoW.config = {
 		["transition_speed"] = 50,
 		["widgets"] = {"widget_key_up", "widget_key_down", "widget_resources_timer"},
 		["layouts"] = {"layout_tiny"},
+		["point"] = {"CENTER", "UIParent", "CENTER", 0, -50}
     },
 	["display_icon"] = {
 		["addon"] = "LCD4WoW",
-		["enabled"] = true,
+		["enabled"] = false,
 		["driver"] = "qtip",
 		["layers"] = 1,
 		["row"] = 0,
@@ -59,6 +61,21 @@ LCD4WoW.config = {
 		["layouts"] = {"layout_icon"},
 		["widgets"] = {},
 		["font"] = {normal="Interface\\AddOns\\LCD4WoW\\Fonts\\ttf-bitstream-vera-1.10\\VeraMo.ttf", size=1},
+		["point"] = {"TOPLEFT", "GameTooltip", "BOTTOMLEFT", 0, -100},
+		["parent"] = "GameTooltip"
+	},
+	["display_mana"] = {
+		["addon"] = "LCD4WoW",
+		["enabled"] = true,
+		["driver"] = "character",
+		["pixel"] = 1,
+		["layers"] = 1,
+		["rows"] = 1,
+		["cols"] = 9,
+		["layouts"] = {"layout_mana"},
+		["widgets"] = {},
+		["point"] = {"TOPLEFT", "GameTooltip", "BOTTOMLEFT", 0, -130},
+		["parent"] = "GameTooltip"
 	},
 	["widget_resources_timer"] = {
         type = "timer",
@@ -69,6 +86,13 @@ if ResourceServer then self.timer:Stop(); return end
 Update()
 ]]
 	},
+	["layout_mana"] = {
+		[1] = {
+			[1] = {
+				[1] = "widget_text_mana",
+			}
+		}
+	},
 	["layout_icon"] = {
 		[1] = {
 			[1] = {
@@ -170,6 +194,14 @@ Update()
 		["transition"] = TRANSITION_CHECKERBOARD,
 		["timeout"] = 2000
 	},
+	["widget_text_mana"] = {
+		type = "text",
+		value = 'return "Rage: " .. (UnitMana("player") / UnitManaMax("player") * 100)',
+		align = ALIGN_LEFT,
+		cols = 9,
+		update = 1000,
+		dontRtrim = true
+	},
 	["widget_name_label"] = {
 		type = "text",
 		value = 'return "Name:"',