diff --git a/Modules/Bars.lua b/Modules/Bars.lua index 6f0c7b0..6d8587b 100644 --- a/Modules/Bars.lua +++ b/Modules/Bars.lua @@ -69,10 +69,11 @@ else end ]], height = 6, - point = {"BOTTOMLEFT", "GameTooltip", "TOPLEFT"}, + points = {{"BOTTOMLEFT", "GameTooltip", "TOPLEFT", 0, 0}, {"LEFT", "GameTooltip", "LEFT", 5, 0}, {"RIGHT", "GameTooltip", "RIGHT", -5, 0}}, texture1 = LSM:GetDefault("statusbar"), enabled = true, - layer = 1 + layer = 1, + level = 100 }, [2] = { name = "Mana Bar", @@ -87,10 +88,11 @@ return UnitMana(unit) return PowerColor(nil, unit) ]], height = 6, - point = {"TOPLEFT", "GameTooltip", "BOTTOMLEFT"}, + points = {{"TOPLEFT", "GameTooltip", "BOTTOMLEFT", 0, 0}, {"LEFT", "GameTooltip", "LEFT", 5, 0}, {"RIGHT", "GameTooltip", "RIGHT", -5, 0}}, texture1 = LSM:GetDefault("statusbar"), enabled = true, - layer = 1 + layer = 1, + level = 100 }, @@ -115,7 +117,9 @@ local optionsDefaults = { min = "return 0", max = "return 100", height = 6, - point = {"BOTTOMLEFT", "GameTooltip", "TOPLEFT"}, + points = {{"BOTTOMLEFT", "GameTooltip", "TOPLEFT", 0, 0}}, + level = 100, + strata = 1, texture = LSM:GetDefault("statusbar"), expression = "", custom = true @@ -180,17 +184,22 @@ end local defaultPoint = {"BOTTOMLEFT", "GameTooltip", "TOPLEFT"} local strataNameList = { - "BACKGROUND", "LOW", "MEDIUM", "HIGH", "DIALOG", "FULLSCREEN", "FULLSCREEN_DIALOG", "TOOLTIP" + "TOOLTIP", "FULLSCREEN_DIALOG", "FULLSCREEN", "DIALOG", "HIGH", "MEDIUM", "LOW", "BACKGROUND" } -local strataLocaleList = {"Background", "Low", "Medium", "High", "Dialog", "Fullscreen", "Fullscreen Dialog", "Tooltip"} +local strataLocaleList = { + "Tooltip", "Fullscreen Dialog", "Fullscreen", "Dialog", "High", "Medium", "Low", "Background" +} local function clearBar(obj) obj = mod.bars and mod.bars[obj] if not obj then return end + obj.bar:ClearAllPoints() + obj.bar:Hide() del(obj.bar) obj:Del() if obj.secondBar then + obj.secondBar.bar:Hide() del(obj.secondBar.bar) obj.secondBar:Del() end @@ -212,23 +221,21 @@ local function createBars() local widget = mod.bars[v] if not widget then local bar = new() - widget = mod.bars[v] or WidgetBar:New(mod.core, v.name, v, v.row or 0, v.col or 0, v.layer or 0, StarTip.db.profile.errorLevel, updateBar, bar) + widget = WidgetBar:New(mod.core, v.name, v, v.row or 0, v.col or 0, v.layer or 0, StarTip.db.profile.errorLevel, updateBar, bar) bar:SetStatusBarTexture(LSM:Fetch("statusbar", v.texture1)) bar:ClearAllPoints() - local arg1, arg2, arg3, arg4, arg5 = unpack(v.point) - arg4 = (arg4 or 0) - arg5 = (arg5 or 0) - bar:SetPoint(arg1, arg2, arg3, arg4, arg5) - if type(v.width) == "number" then - bar:SetWidth(v.width) - else - bar:SetPoint("LEFT", GameTooltip, "LEFT") - bar:SetPoint("RIGHT", GameTooltip, "RIGHT") + for j, point in ipairs(v.points) do + local arg1, arg2, arg3, arg4, arg5 = unpack(point) + arg4 = (arg4 or 0) + arg5 = (arg5 or 0) + bar:SetPoint(arg1, arg2, arg3, arg4, arg5) end + bar:SetWidth(v.width or 20) bar:SetHeight(v.height) bar:SetMinMaxValues(0, 100) bar:Show() - bar:SetFrameStrata(strataNameList[widget.layer]) + bar:SetFrameStrata(strataNameList[v.layer]) + bar:SetFrameLevel(v.level) widget.bar1 = true widget.bar = bar mod.bars[v] = widget @@ -238,24 +245,22 @@ local function createBars() widget = WidgetBar:New(mod.core, v.name, v, v.row or 0, v.col or 0, v.layer or 0, StarTip.db.profile.errorLevel, updateBar, bar) bar:SetStatusBarTexture(LSM:Fetch("statusbar", v.texture2 or v.texutre1 or "Blizzard")) bar:ClearAllPoints() - local arg1, arg2, arg3, arg4, arg5 = unpack(v.point) - arg4 = (arg4 or 0) - if v.top then - arg5 = (arg5 or 0) - (v.height or 12) - else - arg5 = (arg5 or 0) + (v.height or 12) - end - bar:SetPoint(arg1, arg2, arg3, arg4, arg5) - if type(v.width) == "number" then - bar:SetWidth(v.width) - else - bar:SetPoint("LEFT", GameTooltip, "LEFT") - bar:SetPoint("RIGHT", GameTooltip, "RIGHT") + for i, point in ipairs(v.points) do + local arg1, arg2, arg3, arg4, arg5 = unpack(point) + arg4 = (arg4 or 0) + if v.top then + arg5 = (arg5 or 0) - (v.height or 12) + else + arg5 = (arg5 or 0) + (v.height or 12) + end + bar:SetPoint(arg1, arg2, arg3, arg4, arg5) end + bar:SetWidth(v.width or 10) bar:SetHeight(v.height) bar:SetMinMaxValues(0, 100) bar:Show() bar:SetFrameStrata(strataNameList[widget.layer]) + bar:SetFrameLevel(v.level) mod.bars[v].secondBar = widget end end @@ -391,7 +396,7 @@ end function mod:RebuildOpts() local defaults = WidgetBar.defaults - + self:ClearBars() wipe(options) for k, v in pairs(optionsDefaults) do options[k] = v @@ -402,264 +407,40 @@ function mod:RebuildOpts() name = db.name, type="group", order = i, - args={ - enabled = { - name = "Enabled", - desc = "Whether this bar is enabled or not", - type = "toggle", - get = function() return db.enabled end, - set = function(info, v) - db.enabled = v - db["enabledDirty"] = true - self:ClearBars() - end, - order = 1 - }, - height = { - name = "Bar height", - desc = "Enter the bar's height", - type = "input", - pattern = "%d", - get = function() return tostring(db.height or defaults.height) end, - set = function(info, v) - db.height = tonumber(v); - db["heightDirty"] = true - self:ClearBars() - end, - order = 2 - }, - update = { - name = "Bar update rate", - desc = "Enter the bar's refresh rate", - type = "input", - pattern = "%d", - get = function() return tostring(db.update or defaults.update) end, - set = function(info, v) - db.update = tonumber(v); - db["updateDirty"] = true - self:ClearBars() - end, - order = 3 - }, - --[[direction = { - name = "Bar direction", - type = "select", - values = WidgetBar.directionList, - get = function() return db.direction or defaults.direction end, - set = function(info, v) db.direction = v; end, - order = 4 - }, - style = { - name = "Bar Style", - type = "select", - values = WidgetBar.styleList, - get = function() return db.style or defaults.style end, - set = function(info, v) db.style = v; end, - order = 5 - },]] - texture1 = { - name = "Texture #1", - desc = "The bar's first texture", - type = "select", - values = LSM:List("statusbar"), - get = function() - return StarTip:GetLSMIndexByName("statusbar", db.texture1 or "Blizzard") - end, - set = function(info, v) - db.texture1 = LSM:List("statusbar")[v] - db["texture1Dirty"] = true - self:ClearBars() - end, - order = 4 - }, - texture2 = { - name = "Texture #2", - desc = "The bar's second texture", - type = "select", - values = LSM:List("statusbar"), - get = function() - return db.texture2 or db.texture1 or "Blizzard" - end, - set = function(info, v) - db.texture2 = LSM:List("statusbar")[v] - db["texture2Dirty"] = true - self:ClearBars() - end, - order = 5 - }, - strata = { - name = "Strata", - type = "select", - values = strataLocaleList, - get = function() return db.strata end, - set = function(info, v) db.strata = v; self:ClearBars() end, - order = 6 - }, - point = { - name = "Anchor Points", - desc = "This bar'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]; self:ClearBars() end, - order = 1 - }, - relativeFrame = { - name = "Relative Frame", - type = "input", - get = function() return db.point[2] end, - set = function(info, v) db.point[2] = v; self:ClearBars() 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]; self:ClearBars() 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(anchors[v]); self:ClearBars() 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(anchors[v]); self:ClearBars() end, - order = 4 - } - }, - order = 7 - }, - top = { - name = "First is Top", - desc = "Toggle whether to place the first bar on top", - type = "toggle", - get = function() return db.top end, - set = function(info, v) - db.top = v; - db["topDirty"] = true - self:ClearBars() - end, - order = 8 - }, - expression = { - name = "Bar expression", - desc = "Enter the bar's first expression", - type = "input", - multiline = true, - width = "full", - get = function() return db.expression end, - set = function(info, v) - db.expression = v; - db["expressionDirty"] = true - self:ClearBars() - end, - order = 9 - }, - expression2 = { - name = "Bar second expression", - desc = "Enter the bar's second expression", - type = "input", - multiline = true, - width = "full", - get = function() return db.expression2 end, - set = function(info, v) - db.expression2 = v ; - db["expression2Dirty"] = true - self:ClearBars() - end, - order = 10 - }, - min = { - name = "Bar min expression", - desc = "Enter the bar's minimum expression", - type = "input", - multiline = true, - width = "full", - get = function() return db.min end, - set = function(info, v) - db.min = v; - db["minDirty"] = true - self:ClearBars() - end, - order = 11 - - }, - max = { - name = "Bar max expression", - desc = "Enter the bar's maximum expression", - type = "input", - multiline = true, - width = "full", - get = function() return db.max end, - set = function(info, v) - db.max = v; - db["maxDirty"] = true - self:ClearBars() - end, - order = 12 - }, - color1 = { - name = "First bar color script", - desc = "Enter the bar's first color script", - type = "input", - multiline = true, - width = "full", - get = function() return db.color1 end, - set = function(info, v) - db.color1 = v; - db["color1Dirty"] = true - self:ClearBars() - end, - order = 13 - }, - color2 = { - name = "Second bar color script", - desc = "Enter the bar's second color script", - type = "input", - multiline = true, - width = "full", - get = function() return db.color2 end, - set = function(info, v) - db.color2 = v; - db["color2Dirty"] = true - self:ClearBars() - end, - order = 13 - }, - delete = { - name = "Delete", - type = "execute", - func = function() - local delete = true - for i, v in ipairs(defaultWidgets) do - if db.name == v.name then - db.deleted = true - delete = false - end - end - if delete then - self.db.profile.bars[i] = nil - end - self:ClearBars() - StarTip:RebuildOpts() - end, - order = 100 - } - } + args = WidgetBar:GetOptions(db, StarTip.RebuildOpts, StarTip), + } + options[db.name:gsub(" ", "_")].args.delete = { + name = "Delete", + type = "execute", + func = function() + local delete = true + for i, v in ipairs(defaultWidgets) do + if db.name == v.name then + db.deleted = true + delete = false + end + end + if delete then + tremove(self.db.profile.bars, i) + end + self:ClearTexts() + StarTip:RebuildOpts() + end, + order = 100 + } + options[db.name:gsub(" ", "_")].args.enabled = { + name = "Enabled", + desc = "Whether the histogram's enabled or not", + type = "toggle", + get = function() return db.enabled end, + set = function(info, v) + db.enabled = v; + db["enabledDirty"] = true + self:ClearBars() + end, + order = 1 } + end end diff --git a/Modules/Histograms.lua b/Modules/Histograms.lua index f03c0d7..bcf7d64 100644 --- a/Modules/Histograms.lua +++ b/Modules/Histograms.lua @@ -61,7 +61,7 @@ local defaultWidgets = { enabled = true, width = 10, height = 50, - point = {"TOPLEFT", "GameTooltip", "BOTTOMLEFT", 0, -12}, + points = {{"TOPLEFT", "GameTooltip", "BOTTOMLEFT", 0, -12}}, color = [[ return HPColor(UnitHealth(unit), UnitHealthMax(unit)) ]], @@ -76,7 +76,7 @@ return HPColor(UnitHealth(unit), UnitHealthMax(unit)) enabled = true, width = 10, height = 50, - point = {"TOPRIGHT", "GameTooltip", "BOTTOMRIGHT", -100, -12}, + points = {{"TOPRIGHT", "GameTooltip", "BOTTOMRIGHT", -100, -12}}, color = [[ return PowerColor("RAGE", unit) ]], @@ -110,7 +110,7 @@ end char = "0", width = 10, height = 50, - point = {"TOPLEFT", "GameTooltip", "BOTTOMLEFT", 0, -77}, + points = {{"TOPLEFT", "GameTooltip", "BOTTOMLEFT", 0, -77}}, layer = 1, update = 1000, persistent = true @@ -140,7 +140,7 @@ end char = "0", width = 10, height = 50, - point = {"TOPRIGHT", "GameTooltip", "BOTTOMRIGHT", -100, -77}, + points = {{"TOPRIGHT", "GameTooltip", "BOTTOMRIGHT", -100, -77}}, layer = 1, update = 1000, persistent = true @@ -169,7 +169,7 @@ local optionsDefaults = { height = WidgetHistogram.defaults.height, width = WidgetHistogram.defaults.width, enabled = true, - point = {"TOPLEFT", "GameTooltip", "BOTTOMLEFT", 0, -50}, + points = {{"TOPLEFT", "GameTooltip", "BOTTOMLEFT", 0, -50}}, texture = LSM:GetDefault("statusbar"), expression = "return random(100)", color = "return 0, 0, 1", @@ -235,6 +235,7 @@ local function clearHistogram(obj) if not obj then return end for k, v in pairs(obj.bars) do del(v) + v:Hide() end obj:Del() end @@ -281,14 +282,16 @@ local function createHistograms() local bar = new() bar:SetStatusBarTexture(LSM:Fetch("statusbar", v.texture)) bar:ClearAllPoints() - local arg1, arg2, arg3, arg4, arg5 = unpack(v.point)-- or {"BOTTOMLEFT", "GameTooltip", "TOPLEFT"}) - if (v.width > 100) then - arg4 = (arg4 or 0) + i * (v.width / 100) - else - arg4 = (arg4 or 0) + i * v.width + for _, point in ipairs(v.points) do + local arg1, arg2, arg3, arg4, arg5 = unpack(point) + if (v.width > 100) then + arg4 = (arg4 or 0) + i * (v.width / 100) + else + arg4 = (arg4 or 0) + i * v.width + end + arg5 = (arg5 or 0) + bar:SetPoint(arg1, arg2, arg3, arg4, arg5) end - arg5 = (arg5 or 0) - bar:SetPoint(arg1, arg2, arg3, arg4, arg5) if v.width then if (v.width > 100) then bar:SetWidth(v.width / 100) @@ -446,235 +449,39 @@ function mod:RebuildOpts() name = db.name, type="group", order = i, - args={ - enabled = { - name = "Enable", - desc = "Toggle whether this histogram is enabled or not", - type = "toggle", - get = function() return db.enabled end, - set = function(info, v) - db.enabled = v - db["enabledDirty"] = true - self:ClearHistograms() - end, - order = 1 - }, - height = { - name = "Histogram height", - desc = "Enter the histogram's height", - type = "input", - pattern = "%d", - get = function() return tostring(db.height or defaults.height) end, - set = function(info, v) - db.height = tonumber(v); - db["heightDirty"] = true - self:ClearHistograms() - end, - order = 2 - }, - width = { - name = "Histogram width", - desc = "Enter the histogram's width", - type = "input", - pattern = "%d", - get = function() return tostring(db.width or defaults.width) end, - set = function(info, v) - db.width = tonumber(v) - db["widthDirty"] = true - self:ClearHistograms() - end, - order = 3 - }, - layer = { - name = "Histogram Layer", - desc = "Enter the histogram's layer", - type = "input", - pattern = "%d", - get = function() return tostring(db.layer or 0) end, - set = function(info, v) db.layer = tonumber(v) end, - order = 4 - }, - update = { - name = "Histogram update rate", - desc = "Enter the histogram's refresh rate", - type = "input", - pattern = "%d", - get = function() return tostring(db.update or defaults.update) end, - set = function(info, v) - db.update = tonumber(v); - db["updateDirty"] = true - self:ClearHistograms() - end, - order = 5 - }, - --[[direction = { - name = "Histogram direction", - type = "select", - values = WidgetHistogram.directionList, - get = function() return db.direction or defaults.direction end, - set = function(info, v) db.direction = v; createHistograms()StarTip:RebuildOpts() end, - order = 4 - }, - style = { - name = "Histogram Style", - type = "select", - values = WidgetHistogram.styleList, - get = function() return db.style or defaults.style end, - set = function(info, v) db.style = v; createHistograms()StarTip:RebuildOpts() end, - order = 5 - },]] - texture = { - name = "Texture", - desc = "The histogram's texture", - type = "select", - values = LSM:List("statusbar"), - get = function() - return StarTip:GetLSMIndexByName("statusbar", db.texture or "Blizzard") - end, - set = function(info, v) - db.texture = LSM:List("statusbar")[v] - db["textureDirty"] = true - self:ClearHistograms() - end, - order = 6 - }, - 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];self:ClearHistograms(); end, - order = 1 - }, - relativeFrame = { - name = "Relative Frame", - type = "input", - get = function() return db.point[2] end, - set = function(info, v) db.point[2] = v; self:ClearHistograms(); 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]; self:ClearHistograms(); 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); self:ClearHistograms(); 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); self:ClearHistograms(); end, - order = 4 - } - }, - order = 7 - }, - persistent = { - name = "Persistent", - desc = "Whether this histogram is persistent or not, meaning it won't stop when the tooltip hides.", - type = "toggle", - get = function() return db.persistent end, - set = function(info, v) db.persistent = v end, - order = 8 - }, - expression = { - name = "Histogram expression", - desc = "Enter the histogram's first expression", - type = "input", - multiline = true, - width = "full", - get = function() return db.expression end, - set = function(info, v) - db.expression = v; - db["expressionDirty"] = true - self:ClearHistograms() - - end, - order = 9 - }, - min = { - name = "Histogram min expression", - desc = "Enter the histogram's minimum expression", - type = "input", - multiline = true, - width = "full", - get = function() return db.min end, - set = function(info, v) - db.min = v; - db["minDirty"] = true - self:ClearHistograms() - - end, - order = 10 - - }, - max = { - name = "Histogram max expression", - desc = "Enter the histogram's maximum expression", - type = "input", - multiline = true, - width = "full", - get = function() return db.max end, - set = function(info, v) - db.max = v; - db["maxDirty"] = true - self:ClearHistograms() - - end, - order = 11 - }, - color = { - name = "Histogram color script", - desc = "Enter the histogram's color script", - type = "input", - multiline = true, - width = "full", - get = function() return db.color end, - set = function(info, v) - db.color = v; - db["colorDirty"] = true - self:ClearHistograms() - - end, - order = 12 - }, - delete = { - name = "Delete", - desc = "Delete this widget", - type = "execute", - func = function() - local delete = true - for i, v in ipairs(defaultWidgets) do - if db.name == v.name then - db.deleted = true - delete = false - end - end - if delete then - self.db.profile.histograms[i] = nil - end - self:ClearHistograms() - StarTip:RebuildOpts() - end, - order = 13 - } - } + args=WidgetHistogram:GetOptions(db, StarTip.RebuildOpts, StarTip) + } + options[db.name:gsub(" ", "_")].args.delete = { + name = "Delete", + desc = "Delete this widget", + type = "execute", + func = function() + local delete = true + for i, v in ipairs(defaultWidgets) do + if db.name == v.name then + db.deleted = true + delete = false + end + end + if delete then + self.db.profile.histograms[i] = nil + end + self:ClearHistograms() + StarTip:RebuildOpts() + end, + order = 13 + } + options[db.name:gsub(" ", "_")].args.enabled = { + name = "Enable", + desc = "Toggle whether this histogram is enabled or not", + type = "toggle", + get = function() return db.enabled end, + set = function(info, v) + db.enabled = v + db["enabledDirty"] = true + self:ClearHistograms() + end, + order = 1 } end end diff --git a/Modules/Text.lua b/Modules/Text.lua index 2aaf568..d3598ee 100644 --- a/Modules/Text.lua +++ b/Modules/Text.lua @@ -69,8 +69,10 @@ return ClassColor(unit) speed = 100, direction = SCROLL_LEFT, dontRtrim = true, - point = {"BOTTOMLEFT", "GameTooltip", "TOPLEFT", 0, 12}, + points = {{"BOTTOMLEFT", "GameTooltip", "TOPLEFT", 0, 12}}, parent = "GameTooltip", + strata = 1, + level = 1 }, [2] = { name = "Health", @@ -88,8 +90,10 @@ return HPColor(health, max) ]], cols = 20, update = 1000, - point = {"TOPLEFT", "GameTooltip", "BOTTOMLEFT", 0, 1}, - parent = "GameTooltip" + points = {{"TOPLEFT", "GameTooltip", "BOTTOMLEFT", 0, 1}}, + parent = "GameTooltip", + strata = 1, + level = 1 }, [3] = { name = "Power", @@ -108,8 +112,10 @@ return HPColor(mana, max) cols = 20, update = 1000, align = WidgetText.ALIGN_RIGHT, - point = {"TOPRIGHT", "GameTooltip", "BOTTOMRIGHT", 0, 1}, - parent = "GameTooltip" + points = {{"TOPRIGHT", "GameTooltip", "BOTTOMRIGHT", 0, 1}}, + parent = "GameTooltip", + strata = 1, + level = 1 }, [4] = { name = "Memory Percent", @@ -138,8 +144,10 @@ end cols = 20, update = 1000, dontRtrim = true, - point = {"TOPLEFT", "GameTooltip", "BOTTOMLEFT", 0, -62}, - parent = "GameTooltip" + points = {{"TOPLEFT", "GameTooltip", "BOTTOMLEFT", 0, -62}}, + parent = "GameTooltip", + strata = 1, + level = 1 }, [5] = { name = "Memory Total", @@ -158,8 +166,10 @@ return 1, 1, 0 cols = 20, update = 1000, dontRtrim = true, - point = {"TOPLEFT", "GameTooltip", "BOTTOMLEFT", 0, -124}, - parent = "GameTooltip" + points = {{"TOPLEFT", "GameTooltip", "BOTTOMLEFT", 0, -124}}, + parent = "GameTooltip", + strata = 1, + level = 1 }, [6] = { name = "CPU Percent", @@ -184,8 +194,10 @@ end align = WidgetText.ALIGN_RIGHT, update = 1000, dontRtrim = true, - point = {"TOPRIGHT", "GameTooltip", "BOTTOMRIGHT", 0, -62}, - parent = "GameTooltip" + points = {{"TOPRIGHT", "GameTooltip", "BOTTOMRIGHT", 0, -62}}, + parent = "GameTooltip", + strata = 1, + level = 1 }, [7] = { name = "CPU Total", @@ -205,8 +217,10 @@ return 1, 1, 0 align = WidgetText.ALIGN_RIGHT, update = 1000, dontRtrim = true, - point = {"TOPRIGHT", "GameTooltip", "BOTTOMRIGHT", 0, -124}, - parent = "GameTooltip" + points = {{"TOPRIGHT", "GameTooltip", "BOTTOMRIGHT", 0, -124}}, + parent = "GameTooltip", + strata = 1, + level = 1 }, } @@ -229,9 +243,11 @@ local optionsDefaults = { min = "return 0", max = "return 100", height = 6, - point = {"BOTTOMLEFT", "GameTooltip", "TOPLEFT"}, + points = {{"BOTTOMLEFT", "GameTooltip", "TOPLEFT"}}, texture = LSM:GetDefault("statustext"), expression = "", + strata = 1, + level = 1, custom = true } tinsert(mod.db.profile.texts, widget) @@ -253,7 +269,9 @@ local optionsDefaults = { } function updateText(widget) - widget.text:SetText(widget.buffer) + widget.text.fontstring:SetText(widget.buffer) + widget.text:SetHeight(widget.text.fontstring:GetStringHeight()) + widget.text:SetWidth(widget.text.fontstring:GetStringWidth()) local r, g, b = 0, 0, 1 @@ -262,7 +280,7 @@ function updateText(widget) end if type(r) == "number" then - widget.text:SetVertexColor(r, g, b, a) + widget.text.fontstring:SetVertexColor(r, g, b, a) end end @@ -276,14 +294,25 @@ local new, del do local pool = {} local i = 0 - function new(cols) + function new() local text = next(pool) if text then pool[text] = nil else - text = GameTooltip:CreateFontString() - text:SetFontObject(GameTooltipText) + local frame = CreateFrame("Frame") + frame:SetParent(UIParent) + frame:SetBackdrop({ + insets = {left = 0, right = 0, top = 0, bottom = 0}, + }) + frame:ClearAllPoints() + frame:SetAlpha(1) + local fs = frame:CreateFontString() + fs:SetAllPoints(frame) + fs:SetFontObject(GameTooltipText) + fs:Show() + frame.fontstring = fs + text = frame end return text @@ -296,15 +325,18 @@ end local defaultPoint = {"BOTTOMLEFT", "GameTooltip", "TOPLEFT"} local strataNameList = { - "BACKGROUND", "LOW", "MEDIUM", "HIGH", "DIALOG", "FULLSCREEN", "FULLSCREEN_DIALOG", "TOOLTIP" + "TOOLTIP", "FULLSCREEN_DIALOG", "FULLSCREEN", "DIALOG", "HIGH", "MEDIUM", "LOW", "BACKGROUND" } -local strataLocaleList = {"Background", "Low", "Medium", "High", "Dialog", "Fullscreen", "Fullscreen Dialog", "Tooltip"} +local strataLocaleList = { + "Tooltip", "Fullscreen Dialog", "Fullscreen", "Dialog", "High", "Medium", "Low", "Background" +} local function clearText(obj) local widget = mod.texts[obj] if not widget then return end widget:Del() + widget.text:Hide() del(widget.text) end @@ -324,19 +356,26 @@ function createTexts() end]] local appearance = StarTip:GetModule("Appearance") for i, v in ipairs(self.db.profile.texts) do - if v.enabled and not v.deleted then - local text = new(v.cols or WidgetText.defaults.cols) - local widget = mod.texts[v] or WidgetText:New(mod.core, v.name, v, v.row or 0, v.col or 0, v.layer or 0, StarTip.db.profile.errorLevel, updateText) - widget.config.unit = StarTip.unit - text:ClearAllPoints() - text:SetParent(v.parent) - local arg1, arg2, arg3, arg4, arg5 = unpack(v.point) - arg4 = (arg4 or 0) - arg5 = (arg5 or 0) - text:SetPoint(arg1, arg2, arg3, arg4, arg5) - text:Show() - widget.text = text - mod.texts[v] = widget + if v.enabled and not v.deleted then + local widget = mod.texts[v] + if not widget then + local text = new() + widget = WidgetText:New(mod.core, v.name, v, v.row or 0, v.col or 0, v.layer or 0, StarTip.db.profile.errorLevel, updateText) + text:ClearAllPoints() + text:SetParent(v.parent) + for j, point in ipairs(v.points) do + local arg1, arg2, arg3, arg4, arg5 = unpack(point) + arg4 = (arg4 or 0) + arg5 = (arg5 or 0) + text:SetPoint(arg1, arg2, arg3, arg4, arg5) + end + text:SetFrameStrata(strataNameList[v.strata or 1]) + text:SetFrameLevel(v.level or 1) + text:Show() + widget.text = text + mod.texts[v] = widget + end + widget.config.unit = StarTip.unit end end end @@ -442,7 +481,6 @@ end function mod:RebuildOpts() local defaults = WidgetText.defaults self:ClearTexts() - wipe(options) for k, v in pairs(optionsDefaults) do options[k] = v @@ -453,7 +491,7 @@ function mod:RebuildOpts() name = db.name, type="group", order = i, - args=WidgetText:GetOptions(StarTip, db) + args=WidgetText:GetOptions(db, StarTip.RebuildOpts, StarTip) } options[db.name:gsub(" ", "_")].args.delete = { name = "Delete", @@ -467,13 +505,25 @@ function mod:RebuildOpts() end end if delete then - self.db.profile.texts[i] = nil + tremove(self.db.profile.texts, i) end self:ClearTexts() StarTip:RebuildOpts() end, order = 100 } + options[db.name:gsub(" ", "_")].args.enabled = { + name = "Enabled", + desc = "Whether the histogram's enabled or not", + type = "toggle", + get = function() return db.enabled end, + set = function(info, v) + db.enabled = v; + db["enabledDirty"] = true + self:ClearTexts() + end, + order = 1 + } end end