Tercio@11:
Tercio@58: local dversion = 85
Tercio@25: local major, minor = "DetailsFramework-1.0", dversion
Tercio@11: local DF, oldminor = LibStub:NewLibrary (major, minor)
Tercio@11:
Tercio@18: if (not DF) then
Tercio@20: DetailsFrameworkCanLoad = false
Tercio@11: return
Tercio@11: end
Tercio@11:
Tercio@20: DetailsFrameworkCanLoad = true
Tercio@25: local SharedMedia = LibStub:GetLibrary ("LibSharedMedia-3.0")
Tercio@18:
Tercioo@29: local _
Tercio@11: local _type = type
Tercio@11: local _unpack = unpack
Tercio@11: local upper = string.upper
Tercio@58: local string_match = string.match
Tercio@58:
Tercio@58: SMALL_NUMBER = 0.000001
Tercio@58: ALPHA_BLEND_AMOUNT = 0.8400251
Tercio@11:
Tercioo@29: --> will always give a very random name for our widgets
Tercioo@29: local init_counter = math.random (1, 1000000)
Tercioo@29:
Tercioo@29: DF.LabelNameCounter = DF.LabelNameCounter or init_counter
Tercioo@29: DF.PictureNameCounter = DF.PictureNameCounter or init_counter
Tercioo@29: DF.BarNameCounter = DF.BarNameCounter or init_counter
Tercioo@29: DF.DropDownCounter = DF.DropDownCounter or init_counter
Tercioo@29: DF.PanelCounter = DF.PanelCounter or init_counter
Tercioo@29: DF.SimplePanelCounter = DF.SimplePanelCounter or init_counter
Tercioo@29: DF.ButtonCounter = DF.ButtonCounter or init_counter
Tercioo@29: DF.SliderCounter = DF.SliderCounter or init_counter
Tercioo@29: DF.SwitchCounter = DF.SwitchCounter or init_counter
Tercioo@29: DF.SplitBarCounter = DF.SplitBarCounter or init_counter
Tercio@11:
Tercio@39: DF.FRAMELEVEL_OVERLAY = 750
Tercio@39: DF.FRAMELEVEL_BACKGROUND = 150
Tercio@39:
Tercio@25: DF.FrameWorkVersion = tostring (dversion)
Tercio@25: function DF:PrintVersion()
Tercio@25: print ("Details! Framework Version:", DF.FrameWorkVersion)
Tercio@25: end
Tercio@25:
Tercio@22: LibStub:GetLibrary("AceTimer-3.0"):Embed (DF)
Tercio@22:
Tercioo@29: --> get the working folder
Tercio@11: do
Tercio@11: local path = string.match (debugstack (1, 1, 0), "AddOns\\(.+)fw.lua")
Tercio@11: if (path) then
Tercio@11: DF.folder = "Interface\\AddOns\\" .. path
Tercio@11: else
Tercioo@29: --> if not found, try to use the last valid one
Tercioo@29: DF.folder = DF.folder or ""
Tercio@11: end
Tercio@11: end
Tercio@11:
Tercio@11: DF.debug = false
Tercio@11:
Tercio@11: _G ["DetailsFramework"] = DF
Tercio@11:
Tercio@11: DF.embeds = DF.embeds or {}
Tercio@11: local embed_functions = {
Tercio@20: "RemoveRealName",
Tercio@20: "table",
Tercio@20: "BuildDropDownFontList",
Tercio@11: "SetFontSize",
Tercio@11: "SetFontFace",
Tercio@11: "SetFontColor",
Tercio@11: "GetFontSize",
Tercio@11: "GetFontFace",
Tercio@17: "SetFontOutline",
Tercio@11: "trim",
Tercio@11: "Msg",
Tercio@11: "CreateFlashAnimation",
Tercio@11: "Fade",
Tercio@11: "NewColor",
Tercio@11: "IsHtmlColor",
Tercio@11: "ParseColors",
Tercio@11: "BuildMenu",
Tercio@11: "ShowTutorialAlertFrame",
Tercio@11: "GetNpcIdFromGuid",
Tercio@11: "ShowFeedbackPanel",
Tercio@20: "SetAsOptionsPanel",
Tercio@11:
Tercio@11: "CreateDropDown",
Tercio@11: "CreateButton",
Tercio@11: "CreateColorPickButton",
Tercio@11: "CreateLabel",
Tercio@11: "CreateBar",
Tercio@11: "CreatePanel",
Tercio@11: "CreateFillPanel",
Tercio@11: "ColorPick",
Tercio@11: "IconPick",
Tercio@11: "CreateSimplePanel",
Tercio@11: "CreateChartPanel",
Tercio@11: "CreateImage",
Tercio@11: "CreateScrollBar",
Tercio@11: "CreateSwitch",
Tercio@11: "CreateSlider",
Tercio@11: "CreateSplitBar",
Tercio@11: "CreateTextEntry",
Tercio@11: "Create1PxPanel",
Tercio@11: "CreateFeedbackButton",
Tercio@20: "CreateOptionsFrame",
Tercio@22: "NewSpecialLuaEditorEntry",
Tercio@20: "ShowPromptPanel",
Tercio@22: "ShowTextPromptPanel",
Tercio@11: "www_icons",
Tercio@22: "GetTemplate",
Tercioo@29: "InstallTemplate",
Tercio@22: "GetFrameworkFolder",
Tercioo@29: "ShowPanicWarning",
Tercio@39: "SetFrameworkDebugState",
Tercio@39: "FindHighestParent",
Tercio@39: "OpenInterfaceProfile",
Tercio@40: "CreateInCombatTexture",
Tercio@40: "CreateAnimationHub",
Tercio@40: "CreateAnimation",
Tercio@40: "CreateScrollBox",
Tercio@40: "CreateBorder",
Tercio@42: "FormatNumber",
Tercio@53: "IntegerToTimer",
Tercio@58: "QuickDispatch",
Tercio@58: "CommaValue",
Tercio@58: "RemoveRealmName",
Tercio@58: "Trim",
Tercio@58: "CreateGlowOverlay",
Tercio@58: "CreateFrameShake",
Tercio@11: }
Tercio@11:
Tercio@20: DF.table = {}
Tercio@20:
Tercio@22: function DF:GetFrameworkFolder()
Tercio@22: return DF.folder
Tercio@22: end
Tercio@22:
Tercio@39: function DF:SetFrameworkDebugState (state)
Tercio@39: DF.debug = state
Tercio@39: end
Tercio@39:
Tercio@26: function DF:FadeFrame (frame, t)
Tercio@26: if (t == 0) then
Tercio@26: frame.hidden = false
Tercio@26: frame.faded = false
Tercio@26: frame.fading_out = false
Tercio@26: frame.fading_in = false
Tercio@26: frame:Show()
Tercio@26: frame:SetAlpha (1)
Tercio@26:
Tercio@26: elseif (t == 1) then
Tercio@26: frame.hidden = true
Tercio@26: frame.faded = true
Tercio@26: frame.fading_out = false
Tercio@26: frame.fading_in = false
Tercio@26: frame:SetAlpha (0)
Tercio@26: frame:Hide()
Tercio@26: end
Tercio@26: end
Tercio@26:
Tercio@20: function DF.table.reverse (t)
Tercio@20: local new = {}
Tercio@20: local index = 1
Tercio@20: for i = #t, 1, -1 do
Tercio@20: new [index] = t[i]
Tercio@20: index = index + 1
Tercio@20: end
Tercio@20: return new
Tercio@20: end
Tercio@20:
Tercio@20: --> copy from table2 to table1 overwriting values
Tercio@20: function DF.table.copy (t1, t2)
Tercio@20: for key, value in pairs (t2) do
Tercio@20: if (type (value) == "table") then
Tercio@20: t1 [key] = t1 [key] or {}
Tercio@20: DF.table.copy (t1 [key], t2 [key])
Tercio@20: else
Tercio@20: t1 [key] = value
Tercio@20: end
Tercio@20: end
Tercio@20: return t1
Tercio@20: end
Tercio@20:
Tercio@20: --> copy values that does exist on table2 but not on table1
Tercio@20: function DF.table.deploy (t1, t2)
Tercio@20: for key, value in pairs (t2) do
Tercio@20: if (type (value) == "table") then
Tercio@20: t1 [key] = t1 [key] or {}
Tercio@20: DF.table.deploy (t1 [key], t2 [key])
Tercio@22: elseif (t1 [key] == nil) then
Tercio@20: t1 [key] = value
Tercio@20: end
Tercio@20: end
Tercio@58: return t1
Tercio@20: end
Tercio@20:
Tercio@20: function DF.table.dump (t, s, deep)
Tercio@20: s = s or ""
Tercio@20: deep = deep or 0
Tercio@20: local space = ""
Tercio@20: for i = 1, deep do
Tercio@20: space = space .. " "
Tercio@20: end
Tercio@20: for key, value in pairs (t) do
Tercio@20: local tpe = _type (value)
Tercio@20: if (type (key) ~= "string") then
Tercio@20: key = "unknown?"
Tercio@20: end
Tercio@20: if (tpe == "table") then
Tercio@20: s = s .. space .. "[" .. key .. "] = |cFFa9ffa9table {|r\n"
Tercio@20: s = s .. DF.table.dump (value, nil, deep+1)
Tercio@20: s = s .. space .. "|cFFa9ffa9}|r\n"
Tercio@20: elseif (tpe == "string") then
Tercio@20: s = s .. space .. "[" .. key .. "] = '|cFFfff1c1" .. value .. "|r'\n"
Tercio@20: elseif (tpe == "number") then
Tercio@20: s = s .. space .. "[" .. key .. "] = |cFFffc1f4" .. value .. "|r\n"
Tercio@20: elseif (tpe == "function") then
Tercio@20: s = s .. space .. "[" .. key .. "] = function()\n"
Tercio@20: elseif (tpe == "boolean") then
Tercio@20: s = s .. space .. "[" .. key .. "] = |cFF99d0ff" .. (value and "true" or "false") .. "|r\n"
Tercio@20: end
Tercio@20: end
Tercio@20: return s
Tercio@20: end
Tercio@20:
Tercio@11: DF.www_icons = {
Tercio@11: texture = "feedback_sites",
Tercio@11: wowi = {0, 0.7890625, 0, 37/128},
Tercio@11: curse = {0, 0.7890625, 38/123, 79/128},
Tercio@11: mmoc = {0, 0.7890625, 80/123, 123/128},
Tercio@11: }
Tercio@11:
Tercio@42: local symbol_1K, symbol_10K, symbol_1B
Tercio@42: if (GetLocale() == "koKR") then
Tercio@42: symbol_1K, symbol_10K, symbol_1B = "천", "만", "억"
Tercio@42: elseif (GetLocale() == "zhCN") then
Tercio@42: symbol_1K, symbol_10K, symbol_1B = "千", "万", "亿"
Tercio@42: elseif (GetLocale() == "zhTW") then
Tercio@42: symbol_1K, symbol_10K, symbol_1B = "千", "萬", "億"
Tercio@42: end
Tercio@42:
Tercio@42: if (symbol_1K) then
Tercio@42: function DF.FormatNumber (numero)
Tercio@42: if (numero > 99999999) then
Tercio@42: return format ("%.2f", numero/100000000) .. symbol_1B
Tercio@42: elseif (numero > 999999) then
Tercio@42: return format ("%.2f", numero/10000) .. symbol_10K
Tercio@42: elseif (numero > 99999) then
Tercio@42: return floor (numero/10000) .. symbol_10K
Tercio@42: elseif (numero > 9999) then
Tercio@42: return format ("%.1f", (numero/10000)) .. symbol_10K
Tercio@42: elseif (numero > 999) then
Tercio@42: return format ("%.1f", (numero/1000)) .. symbol_1K
Tercio@42: end
Tercio@42: return format ("%.1f", numero)
Tercio@42: end
Tercio@42: else
Tercio@42: function DF.FormatNumber (numero)
Tercio@47: if (numero > 999999999) then
Tercio@47: return format ("%.2f", numero/1000000000) .. "B"
Tercio@47: elseif (numero > 999999) then
Tercio@42: return format ("%.2f", numero/1000000) .. "M"
Tercio@42: elseif (numero > 99999) then
Tercio@42: return floor (numero/1000) .. "K"
Tercio@42: elseif (numero > 999) then
Tercio@42: return format ("%.1f", (numero/1000)) .. "K"
Tercio@42: end
Tercio@42: return format ("%.1f", numero)
Tercio@42: end
Tercio@42: end
Tercio@42:
Tercio@58: function DF:CommaValue (value)
Tercio@58: if (not value) then
Tercio@58: return "0"
Tercio@58: end
Tercio@58:
Tercio@58: value = floor (value)
Tercio@58:
Tercio@58: if (value == 0) then
Tercio@58: return "0"
Tercio@58: end
Tercio@58:
Tercio@58: --source http://richard.warburton.it
Tercio@58: local left, num, right = string_match (value, '^([^%d]*%d)(%d*)(.-)$')
Tercio@58: return left .. (num:reverse():gsub ('(%d%d%d)','%1,'):reverse()) .. right
Tercio@58: end
Tercio@58:
Tercio@24: function DF:IntegerToTimer (value)
Tercio@24: return "" .. floor (value/60) .. ":" .. format ("%02.f", value%60)
Tercio@24: end
Tercio@24:
Tercio@11: function DF:Embed (target)
Tercio@11: for k, v in pairs (embed_functions) do
Tercio@11: target[v] = self[v]
Tercio@11: end
Tercio@11: self.embeds [target] = true
Tercio@11: return target
Tercio@11: end
Tercio@11:
Tercioo@28: function DF:RemoveRealmName (name)
Tercioo@28: return name:gsub (("%-.*"), "")
Tercioo@28: end
Tercioo@28:
Tercio@20: function DF:RemoveRealName (name)
Tercio@20: return name:gsub (("%-.*"), "")
Tercio@20: end
Tercio@20:
Tercio@11: function DF:SetFontSize (fontString, ...)
Tercio@11: local fonte, _, flags = fontString:GetFont()
Tercio@11: fontString:SetFont (fonte, max (...), flags)
Tercio@11: end
Tercio@11: function DF:SetFontFace (fontString, fontface)
Tercio@25: local font = SharedMedia:Fetch ("font", fontface, true)
Tercio@25: if (font) then
Tercio@25: fontface = font
Tercio@25: end
Tercio@25:
Tercio@11: local _, size, flags = fontString:GetFont()
Tercio@11: fontString:SetFont (fontface, size, flags)
Tercio@11: end
Tercio@11: function DF:SetFontColor (fontString, r, g, b, a)
Tercio@11: r, g, b, a = DF:ParseColors (r, g, b, a)
Tercio@11: fontString:SetTextColor (r, g, b, a)
Tercio@11: end
Tercio@11:
Tercio@11: function DF:GetFontSize (fontString)
Tercio@11: local _, size = fontString:GetFont()
Tercio@11: return size
Tercio@11: end
Tercio@11: function DF:GetFontFace (fontString)
Tercio@11: local fontface = fontString:GetFont()
Tercio@11: return fontface
Tercio@11: end
Tercio@11:
Tercio@49: local ValidOutlines = {
Tercio@49: ["NONE"] = true,
Tercio@49: ["MONOCHROME"] = true,
Tercio@49: ["OUTLINE"] = true,
Tercio@49: ["THICKOUTLINE"] = true,
Tercio@49: }
Tercio@11: function DF:SetFontOutline (fontString, outline)
Tercio@11: local fonte, size = fontString:GetFont()
Tercio@11: if (outline) then
Tercio@49: if (ValidOutlines [outline]) then
Tercio@49: outline = outline
Tercio@49: elseif (_type (outline) == "boolean" and outline) then
Tercio@11: outline = "OUTLINE"
Tercio@11: elseif (outline == 1) then
Tercio@11: outline = "OUTLINE"
Tercio@11: elseif (outline == 2) then
Tercio@11: outline = "THICKOUTLINE"
Tercio@11: end
Tercio@11: end
Tercio@11:
Tercio@11: fontString:SetFont (fonte, size, outline)
Tercio@11: end
Tercio@11:
Tercio@58: function DF:Trim (s) --hello name conventions!
Tercio@58: return DF:trim (s)
Tercio@58: end
Tercio@58:
Tercio@11: function DF:trim (s)
Tercio@11: local from = s:match"^%s*()"
Tercio@11: return from > #s and "" or s:match(".*%S", from)
Tercio@11: end
Tercio@11:
Tercio@11: function DF:Msg (msg)
Tercio@58: print ("|cFFFFFFAA" .. (self.__name or "FW Msg:") .. "|r ", msg)
Tercio@11: end
Tercio@11:
Tercio@11: function DF:GetNpcIdFromGuid (guid)
Tercio@11: local NpcId = select ( 6, strsplit ( "-", guid ) )
Tercio@11: if (NpcId) then
Tercio@11: return tonumber ( NpcId )
Tercio@11: end
Tercio@11: return 0
Tercio@11: end
Tercio@11:
Tercio@58: function DF.SortOrder1 (t1, t2)
Tercio@58: return t1[1] > t2[1]
Tercio@58: end
Tercio@58: function DF.SortOrder2 (t1, t2)
Tercio@58: return t1[2] > t2[2]
Tercio@58: end
Tercio@58: function DF.SortOrder3 (t1, t2)
Tercio@58: return t1[3] > t2[3]
Tercio@58: end
Tercio@58: function DF.SortOrder1R (t1, t2)
Tercio@58: return t1[1] < t2[1]
Tercio@58: end
Tercio@58: function DF.SortOrder2R (t1, t2)
Tercio@58: return t1[2] < t2[2]
Tercio@58: end
Tercio@58: function DF.SortOrder3R (t1, t2)
Tercio@58: return t1[3] < t2[3]
Tercio@58: end
Tercio@58:
Tercio@11: local onFinish = function (self)
Tercio@11: if (self.showWhenDone) then
Tercio@11: self.frame:SetAlpha (1)
Tercio@11: else
Tercio@11: self.frame:SetAlpha (0)
Tercio@11: self.frame:Hide()
Tercio@11: end
Tercio@11:
Tercio@11: if (self.onFinishFunc) then
Tercio@11: self:onFinishFunc (self.frame)
Tercio@11: end
Tercio@11: end
Tercio@11:
Tercio@11: local stop = function (self)
Tercio@11: local FlashAnimation = self.FlashAnimation
Tercio@11: FlashAnimation:Stop()
Tercio@11: end
Tercio@11:
Tercio@11: local flash = function (self, fadeInTime, fadeOutTime, flashDuration, showWhenDone, flashInHoldTime, flashOutHoldTime, loopType)
Tercio@11:
Tercio@11: local FlashAnimation = self.FlashAnimation
Tercio@11:
Tercio@11: local fadeIn = FlashAnimation.fadeIn
Tercio@11: local fadeOut = FlashAnimation.fadeOut
Tercio@11:
Tercio@11: fadeIn:Stop()
Tercio@11: fadeOut:Stop()
Tercio@11:
Tercio@11: fadeIn:SetDuration (fadeInTime or 1)
Tercio@11: fadeIn:SetEndDelay (flashInHoldTime or 0)
Tercio@11:
Tercio@11: fadeOut:SetDuration (fadeOutTime or 1)
Tercio@11: fadeOut:SetEndDelay (flashOutHoldTime or 0)
Tercio@11:
Tercio@11: FlashAnimation.duration = flashDuration
Tercio@11: FlashAnimation.loopTime = FlashAnimation:GetDuration()
Tercio@11: FlashAnimation.finishAt = GetTime() + flashDuration
Tercio@11: FlashAnimation.showWhenDone = showWhenDone
Tercio@11:
Tercio@11: FlashAnimation:SetLooping (loopType or "REPEAT")
Tercio@11:
Tercio@11: self:Show()
Tercio@11: self:SetAlpha (0)
Tercio@11: FlashAnimation:Play()
Tercio@11: end
Tercio@11:
Tercio@11: function DF:CreateFlashAnimation (frame, onFinishFunc, onLoopFunc)
Tercio@11: local FlashAnimation = frame:CreateAnimationGroup()
Tercio@11:
Tercio@11: FlashAnimation.fadeOut = FlashAnimation:CreateAnimation ("Alpha") --> fade out anime
Tercio@11: FlashAnimation.fadeOut:SetOrder (1)
Tercio@39: FlashAnimation.fadeOut:SetFromAlpha (0)
Tercio@39: FlashAnimation.fadeOut:SetToAlpha (1)
Tercio@11:
Tercio@11: FlashAnimation.fadeIn = FlashAnimation:CreateAnimation ("Alpha") --> fade in anime
Tercio@11: FlashAnimation.fadeIn:SetOrder (2)
Tercio@39: FlashAnimation.fadeIn:SetFromAlpha (1)
Tercio@39: FlashAnimation.fadeIn:SetToAlpha (0)
Tercio@11:
Tercio@11: frame.FlashAnimation = FlashAnimation
Tercio@11: FlashAnimation.frame = frame
Tercio@11: FlashAnimation.onFinishFunc = onFinishFunc
Tercio@11:
Tercio@11: FlashAnimation:SetScript ("OnLoop", onLoopFunc)
Tercio@11: FlashAnimation:SetScript ("OnFinished", onFinish)
Tercio@11:
Tercio@11: frame.Flash = flash
Tercio@11: frame.Stop = stop
Tercio@11: end
Tercio@11:
Tercio@11: ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Tercio@11: --> points
Tercio@11:
Tercio@11: function DF:CheckPoints (v1, v2, v3, v4, v5, object)
Tercio@11:
Tercio@11: if (not v1 and not v2) then
Tercio@11: return "topleft", object.widget:GetParent(), "topleft", 0, 0
Tercio@11: end
Tercio@11:
Tercio@11: if (_type (v1) == "string") then
Tercio@11: local frameGlobal = _G [v1]
Tercio@53: if (frameGlobal and type (frameGlobal) == "table" and frameGlobal.GetObjectType) then
Tercio@11: return DF:CheckPoints (frameGlobal, v2, v3, v4, v5, object)
Tercio@11: end
Tercio@11:
Tercio@11: elseif (_type (v2) == "string") then
Tercio@11: local frameGlobal = _G [v2]
Tercio@53: if (frameGlobal and type (frameGlobal) == "table" and frameGlobal.GetObjectType) then
Tercio@11: return DF:CheckPoints (v1, frameGlobal, v3, v4, v5, object)
Tercio@11: end
Tercio@11: end
Tercio@11:
Tercio@11: if (_type (v1) == "string" and _type (v2) == "table") then --> :setpoint ("left", frame, _, _, _)
Tercio@11: if (not v3 or _type (v3) == "number") then --> :setpoint ("left", frame, 10, 10)
Tercio@11: v1, v2, v3, v4, v5 = v1, v2, v1, v3, v4
Tercio@11: end
Tercio@11:
Tercio@11: elseif (_type (v1) == "string" and _type (v2) == "number") then --> :setpoint ("topleft", x, y)
Tercio@11: v1, v2, v3, v4, v5 = v1, object.widget:GetParent(), v1, v2, v3
Tercio@11:
Tercio@11: elseif (_type (v1) == "number") then --> :setpoint (x, y)
Tercio@11: v1, v2, v3, v4, v5 = "topleft", object.widget:GetParent(), "topleft", v1, v2
Tercio@11:
Tercio@11: elseif (_type (v1) == "table") then --> :setpoint (frame, x, y)
Tercio@11: v1, v2, v3, v4, v5 = "topleft", v1, "topleft", v2, v3
Tercio@11:
Tercio@11: end
Tercio@11:
Tercio@11: if (not v2) then
Tercio@11: v2 = object.widget:GetParent()
Tercio@11: elseif (v2.dframework) then
Tercio@11: v2 = v2.widget
Tercio@11: end
Tercio@11:
Tercio@11: return v1 or "topleft", v2, v3 or "topleft", v4 or 0, v5 or 0
Tercio@11: end
Tercio@11:
Tercio@58: local anchoring_functions = {
Tercio@58: function (frame, anchorTo, offSetX, offSetY) --> 1 TOP LEFT
Tercio@58: frame:ClearAllPoints()
Tercio@58: frame:SetPoint ("bottomleft", anchorTo, "topleft", offSetX, offSetY)
Tercio@58: end,
Tercio@58:
Tercio@58: function (frame, anchorTo, offSetX, offSetY) --> 2 LEFT
Tercio@58: frame:ClearAllPoints()
Tercio@58: frame:SetPoint ("right", anchorTo, "left", offSetX, offSetY)
Tercio@58: end,
Tercio@58:
Tercio@58: function (frame, anchorTo, offSetX, offSetY) --> 3 BOTTOM LEFT
Tercio@58: frame:ClearAllPoints()
Tercio@58: frame:SetPoint ("topleft", anchorTo, "bottomleft", offSetX, offSetY)
Tercio@58: end,
Tercio@58:
Tercio@58: function (frame, anchorTo, offSetX, offSetY) --> 4 BOTTOM
Tercio@58: frame:ClearAllPoints()
Tercio@58: frame:SetPoint ("top", anchorTo, "bottom", offSetX, offSetY)
Tercio@58: end,
Tercio@58:
Tercio@58: function (frame, anchorTo, offSetX, offSetY) --> 5 BOTTOM RIGHT
Tercio@58: frame:ClearAllPoints()
Tercio@58: frame:SetPoint ("topright", anchorTo, "bottomright", offSetX, offSetY)
Tercio@58: end,
Tercio@58:
Tercio@58: function (frame, anchorTo, offSetX, offSetY) --> 6 RIGHT
Tercio@58: frame:ClearAllPoints()
Tercio@58: frame:SetPoint ("left", anchorTo, "right", offSetX, offSetY)
Tercio@58: end,
Tercio@58:
Tercio@58: function (frame, anchorTo, offSetX, offSetY) --> 7 TOP RIGHT
Tercio@58: frame:ClearAllPoints()
Tercio@58: frame:SetPoint ("bottomright", anchorTo, "topright", offSetX, offSetY)
Tercio@58: end,
Tercio@58:
Tercio@58: function (frame, anchorTo, offSetX, offSetY) --> 8 TOP
Tercio@58: frame:ClearAllPoints()
Tercio@58: frame:SetPoint ("bottom", anchorTo, "top", offSetX, offSetY)
Tercio@58: end,
Tercio@58:
Tercio@58: function (frame, anchorTo, offSetX, offSetY) --> 9 CENTER
Tercio@58: frame:ClearAllPoints()
Tercio@58: frame:SetPoint ("center", anchorTo, "center", offSetX, offSetY)
Tercio@58: end,
Tercio@58:
Tercio@58: function (frame, anchorTo, offSetX, offSetY) --> 10
Tercio@58: frame:ClearAllPoints()
Tercio@58: frame:SetPoint ("left", anchorTo, "left", offSetX, offSetY)
Tercio@58: end,
Tercio@58:
Tercio@58: function (frame, anchorTo, offSetX, offSetY) --> 11
Tercio@58: frame:ClearAllPoints()
Tercio@58: frame:SetPoint ("right", anchorTo, "right", offSetX, offSetY)
Tercio@58: end,
Tercio@58:
Tercio@58: function (frame, anchorTo, offSetX, offSetY) --> 12
Tercio@58: frame:ClearAllPoints()
Tercio@58: frame:SetPoint ("top", anchorTo, "top", offSetX, offSetY)
Tercio@58: end,
Tercio@58:
Tercio@58: function (frame, anchorTo, offSetX, offSetY) --> 13
Tercio@58: frame:ClearAllPoints()
Tercio@58: frame:SetPoint ("bottom", anchorTo, "bottom", offSetX, offSetY)
Tercio@58: end
Tercio@58: }
Tercio@58:
Tercio@58: function DF:SetAnchor (widget, config, anchorTo)
Tercio@58: anchorTo = anchorTo or widget:GetParent()
Tercio@58: anchoring_functions [config.side] (widget, anchorTo, config.x, config.y)
Tercio@58: end
Tercio@11:
Tercio@11: ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Tercio@11: --> colors
Tercio@11:
Tercio@11: function DF:NewColor (_colorname, _colortable, _green, _blue, _alpha)
Tercio@11: assert (_type (_colorname) == "string", "NewColor: colorname must be a string.")
Tercio@11: assert (not DF.alias_text_colors [_colorname], "NewColor: colorname already exists.")
Tercio@11:
Tercio@11: if (_type (_colortable) == "table") then
Tercio@11: if (_colortable[1] and _colortable[2] and _colortable[3]) then
Tercio@11: _colortable[4] = _colortable[4] or 1
Tercio@11: DF.alias_text_colors [_colorname] = _colortable
Tercio@11: else
Tercio@11: error ("invalid color table.")
Tercio@11: end
Tercio@11: elseif (_colortable and _green and _blue) then
Tercio@11: _alpha = _alpha or 1
Tercio@11: DF.alias_text_colors [_colorname] = {_colortable, _green, _blue, _alpha}
Tercio@11: else
Tercio@11: error ("invalid parameter.")
Tercio@11: end
Tercio@11:
Tercio@11: return true
Tercio@11: end
Tercio@11:
Tercio@11: function DF:IsHtmlColor (color)
Tercio@11: return DF.alias_text_colors [color]
Tercio@11: end
Tercio@11:
Tercio@11: local tn = tonumber
Tercio@11: function DF:ParseColors (_arg1, _arg2, _arg3, _arg4)
Tercio@11: if (_type (_arg1) == "table") then
Tercio@25: if (not _arg1[1] and _arg1.r) then
Tercio@25: _arg1, _arg2, _arg3, _arg4 = _arg1.r, _arg1.g, _arg1.b, _arg1.a
Tercio@25: else
Tercio@25: _arg1, _arg2, _arg3, _arg4 = _unpack (_arg1)
Tercio@25: end
Tercio@11:
Tercio@11: elseif (_type (_arg1) == "string") then
Tercio@11:
Tercio@11: if (string.find (_arg1, "#")) then
Tercio@11: _arg1 = _arg1:gsub ("#","")
Tercio@11: if (string.len (_arg1) == 8) then --alpha
Tercio@11: _arg1, _arg2, _arg3, _arg4 = tn ("0x" .. _arg1:sub (3, 4))/255, tn ("0x" .. _arg1:sub (5, 6))/255, tn ("0x" .. _arg1:sub (7, 8))/255, tn ("0x" .. _arg1:sub (1, 2))/255
Tercio@11: else
Tercio@11: _arg1, _arg2, _arg3, _arg4 = tn ("0x" .. _arg1:sub (1, 2))/255, tn ("0x" .. _arg1:sub (3, 4))/255, tn ("0x" .. _arg1:sub (5, 6))/255, 1
Tercio@11: end
Tercio@11:
Tercio@11: else
Tercio@11: local color = DF.alias_text_colors [_arg1]
Tercio@11: if (color) then
Tercio@11: _arg1, _arg2, _arg3, _arg4 = _unpack (color)
Tercio@11: else
Tercio@11: _arg1, _arg2, _arg3, _arg4 = _unpack (DF.alias_text_colors.none)
Tercio@11: end
Tercio@11: end
Tercio@11: end
Tercio@11:
Tercio@11: if (not _arg1) then
Tercio@11: _arg1 = 1
Tercio@11: end
Tercio@11: if (not _arg2) then
Tercio@11: _arg2 = 1
Tercio@11: end
Tercio@11: if (not _arg3) then
Tercio@11: _arg3 = 1
Tercio@11: end
Tercio@11: if (not _arg4) then
Tercio@11: _arg4 = 1
Tercio@11: end
Tercio@11:
Tercio@11: return _arg1, _arg2, _arg3, _arg4
Tercio@11: end
Tercio@11:
Tercio@11: ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Tercio@11: --> menus
Tercio@11:
Tercio@39: local disable_on_combat = {}
Tercio@39:
Tercio@22: function DF:BuildMenu (parent, menu, x_offset, y_offset, height, use_two_points, text_template, dropdown_template, switch_template, switch_is_box, slider_template, button_template)
Tercio@22:
Tercio@22: if (not parent.widget_list) then
Tercio@22: DF:SetAsOptionsPanel (parent)
Tercio@22: end
Tercio@11:
Tercio@11: local cur_x = x_offset
Tercio@11: local cur_y = y_offset
Tercio@11: local max_x = 0
Tercio@58: local line_widgets_created = 0 --how many widgets has been created on this line loop pass
Tercio@11:
Tercio@11: height = abs ((height or parent:GetHeight()) - abs (y_offset) + 20)
Tercio@11: height = height*-1
Tercio@11:
Tercio@11: for index, widget_table in ipairs (menu) do
Tercio@11:
Tercio@39: local widget_created
Tercio@39:
Tercio@20: if (widget_table.type == "blank" or widget_table.type == "space") then
Tercio@20: -- do nothing
Tercio@20:
Tercio@20: elseif (widget_table.type == "label" or widget_table.type == "text") then
Tercio@22: local label = DF:CreateLabel (parent, widget_table.get() or widget_table.text, widget_table.text_template or text_template or widget_table.size, widget_table.color, widget_table.font, nil, "$parentWidget" .. index, "overlay")
Tercio@20: label._get = widget_table.get
Tercio@20: label.widget_type = "label"
Tercio@20: label:SetPoint (cur_x, cur_y)
Tercio@20: tinsert (parent.widget_list, label)
Tercio@58: line_widgets_created = line_widgets_created + 1
Tercio@20:
Tercio@20: elseif (widget_table.type == "select" or widget_table.type == "dropdown") then
Tercio@22: local dropdown = DF:NewDropDown (parent, nil, "$parentWidget" .. index, nil, 140, 18, widget_table.values, widget_table.get(), dropdown_template)
Tercio@11: dropdown.tooltip = widget_table.desc
Tercio@20: dropdown._get = widget_table.get
Tercio@20: dropdown.widget_type = "select"
Tercio@22: local label = DF:NewLabel (parent, nil, "$parentLabel" .. index, nil, widget_table.name .. (use_two_points and ": " or ""), "GameFontNormal", widget_table.text_template or text_template or 12)
Tercio@11: dropdown:SetPoint ("left", label, "right", 2)
Tercio@11: label:SetPoint (cur_x, cur_y)
Tercio@11:
Tercio@11: local size = label.widget:GetStringWidth() + 140 + 4
Tercio@11: if (size > max_x) then
Tercio@11: max_x = size
Tercio@11: end
Tercio@11:
Tercio@20: tinsert (parent.widget_list, dropdown)
Tercio@39: widget_created = dropdown
Tercio@58: line_widgets_created = line_widgets_created + 1
Tercio@20:
Tercio@11: elseif (widget_table.type == "toggle" or widget_table.type == "switch") then
Tercio@22: local switch = DF:NewSwitch (parent, nil, "$parentWidget" .. index, nil, 60, 20, nil, nil, widget_table.get(), nil, nil, nil, nil, switch_template)
Tercio@11: switch.tooltip = widget_table.desc
Tercio@20: switch._get = widget_table.get
Tercio@20: switch.widget_type = "toggle"
Tercio@11: switch.OnSwitch = widget_table.set
Tercio@11:
Tercio@22: if (switch_is_box) then
Tercio@22: switch:SetAsCheckBox()
Tercio@22: end
Tercio@22:
Tercio@22: local label = DF:NewLabel (parent, nil, "$parentLabel" .. index, nil, widget_table.name .. (use_two_points and ": " or ""), "GameFontNormal", widget_table.text_template or text_template or 12)
Tercio@11: switch:SetPoint ("left", label, "right", 2)
Tercio@11: label:SetPoint (cur_x, cur_y)
Tercio@11:
Tercio@11: local size = label.widget:GetStringWidth() + 60 + 4
Tercio@11: if (size > max_x) then
Tercio@11: max_x = size
Tercio@11: end
Tercio@11:
Tercio@20: tinsert (parent.widget_list, switch)
Tercio@39: widget_created = switch
Tercio@58: line_widgets_created = line_widgets_created + 1
Tercio@20:
Tercio@11: elseif (widget_table.type == "range" or widget_table.type == "slider") then
Tercio@11: local is_decimanls = widget_table.usedecimals
Tercio@22: local slider = DF:NewSlider (parent, nil, "$parentWidget" .. index, nil, 140, 20, widget_table.min, widget_table.max, widget_table.step, widget_table.get(), is_decimanls, nil, nil, slider_template)
Tercio@11: slider.tooltip = widget_table.desc
Tercio@20: slider._get = widget_table.get
Tercio@20: slider.widget_type = "range"
Tercio@11: slider:SetHook ("OnValueChange", widget_table.set)
Tercio@11:
Tercio@40: if (widget_table.thumbscale) then
Tercio@40: slider:SetThumbSize (slider.thumb:GetWidth()*widget_table.thumbscale, nil)
Tercio@40: end
Tercio@40:
Tercio@22: local label = DF:NewLabel (parent, nil, "$parentLabel" .. index, nil, widget_table.name .. (use_two_points and ": " or ""), "GameFontNormal", widget_table.text_template or text_template or 12)
Tercio@11: slider:SetPoint ("left", label, "right", 2)
Tercio@11: label:SetPoint (cur_x, cur_y)
Tercio@11:
Tercio@11: local size = label.widget:GetStringWidth() + 140 + 6
Tercio@11: if (size > max_x) then
Tercio@11: max_x = size
Tercio@11: end
Tercio@11:
Tercio@20: tinsert (parent.widget_list, slider)
Tercio@39: widget_created = slider
Tercio@58: line_widgets_created = line_widgets_created + 1
Tercio@20:
Tercio@11: elseif (widget_table.type == "color" or widget_table.type == "color") then
Tercio@22: local colorpick = DF:NewColorPickButton (parent, "$parentWidget" .. index, nil, widget_table.set, nil, button_template)
Tercio@11: colorpick.tooltip = widget_table.desc
Tercio@20: colorpick._get = widget_table.get
Tercio@20: colorpick.widget_type = "color"
Tercio@11:
Tercio@11: local default_value, g, b, a = widget_table.get()
Tercio@11: if (type (default_value) == "table") then
Tercio@11: colorpick:SetColor (unpack (default_value))
Tercio@11: else
Tercio@11: colorpick:SetColor (default_value, g, b, a)
Tercio@11: end
Tercio@11:
Tercio@22: local label = DF:NewLabel (parent, nil, "$parentLabel" .. index, nil, widget_table.name .. (use_two_points and ": " or ""), "GameFontNormal", widget_table.text_template or text_template or 12)
Tercio@11: colorpick:SetPoint ("left", label, "right", 2)
Tercio@11: label:SetPoint (cur_x, cur_y)
Tercio@11:
Tercio@11: local size = label.widget:GetStringWidth() + 60 + 4
Tercio@11: if (size > max_x) then
Tercio@11: max_x = size
Tercio@11: end
Tercio@11:
Tercio@20: tinsert (parent.widget_list, colorpick)
Tercio@39: widget_created = colorpick
Tercio@58: line_widgets_created = line_widgets_created + 1
Tercio@20:
Tercio@11: elseif (widget_table.type == "execute" or widget_table.type == "button") then
Tercio@11:
Tercio@49: local button = DF:NewButton (parent, nil, "$parentWidget" .. index, nil, 120, 18, widget_table.func, widget_table.param1, widget_table.param2, nil, widget_table.name, nil, button_template, text_template)
Tercio@22: if (not button_template) then
Tercio@22: button:InstallCustomTexture()
Tercio@22: end
Tercio@22:
Tercio@11: button:SetPoint (cur_x, cur_y)
Tercio@11: button.tooltip = widget_table.desc
Tercio@20: button.widget_type = "execute"
Tercio@11:
Tercio@11: local size = button:GetWidth() + 4
Tercio@11: if (size > max_x) then
Tercio@11: max_x = size
Tercio@11: end
Tercio@11:
Tercio@20: tinsert (parent.widget_list, button)
Tercio@39: widget_created = button
Tercio@58: line_widgets_created = line_widgets_created + 1
Tercio@49:
Tercio@49: elseif (widget_table.type == "textentry") then
Tercio@49: local textentry = DF:CreateTextEntry (parent, widget_table.func, 120, 18, nil, "$parentWidget" .. index, nil, button_template)
Tercio@49: textentry.tooltip = widget_table.desc
Tercio@49: textentry.text = widget_table.get()
Tercio@49: textentry._get = widget_table.get
Tercio@49: textentry.widget_type = "textentry"
Tercio@49: textentry:SetHook ("OnEnterPressed", widget_table.set)
Tercio@49: textentry:SetHook ("OnEditFocusLost", widget_table.set)
Tercio@49:
Tercio@49: local label = DF:NewLabel (parent, nil, "$parentLabel" .. index, nil, widget_table.name .. (use_two_points and ": " or ""), "GameFontNormal", widget_table.text_template or text_template or 12)
Tercio@49: textentry:SetPoint ("left", label, "right", 2)
Tercio@49: label:SetPoint (cur_x, cur_y)
Tercio@49:
Tercio@49: local size = label.widget:GetStringWidth() + 60 + 4
Tercio@49: if (size > max_x) then
Tercio@49: max_x = size
Tercio@49: end
Tercio@49:
Tercio@49: tinsert (parent.widget_list, textentry)
Tercio@49: widget_created = textentry
Tercio@58: line_widgets_created = line_widgets_created + 1
Tercio@49:
Tercio@11: end
Tercio@39:
Tercio@39: if (widget_table.nocombat) then
Tercio@39: tinsert (disable_on_combat, widget_created)
Tercio@39: end
Tercio@11:
Tercio@11: if (widget_table.spacement) then
Tercio@11: cur_y = cur_y - 30
Tercio@11: else
Tercio@11: cur_y = cur_y - 20
Tercio@11: end
Tercio@11:
Tercio@39: if (widget_table.type == "breakline" or cur_y < height) then
Tercio@11: cur_y = y_offset
Tercio@11: cur_x = cur_x + max_x + 30
Tercio@58: line_widgets_created = 0
Tercio@11: max_x = 0
Tercio@11: end
Tercio@11:
Tercio@11: end
Tercio@11:
Tercio@39: DF.RefreshUnsafeOptionsWidgets()
Tercio@39:
Tercio@11: end
Tercio@39:
Tercio@39: local lock_notsafe_widgets = function()
Tercio@39: for _, widget in ipairs (disable_on_combat) do
Tercio@39: widget:Disable()
Tercio@39: end
Tercio@39: end
Tercio@39: local unlock_notsafe_widgets = function()
Tercio@39: for _, widget in ipairs (disable_on_combat) do
Tercio@39: widget:Enable()
Tercio@39: end
Tercio@39: end
Tercio@39: function DF.RefreshUnsafeOptionsWidgets()
Tercio@39: if (DF.PlayerHasCombatFlag) then
Tercio@39: lock_notsafe_widgets()
Tercio@39: else
Tercio@39: unlock_notsafe_widgets()
Tercio@39: end
Tercio@39: end
Tercio@39: DF.PlayerHasCombatFlag = false
Tercio@39: local ProtectCombatFrame = CreateFrame ("frame")
Tercio@39: ProtectCombatFrame:RegisterEvent ("PLAYER_REGEN_ENABLED")
Tercio@39: ProtectCombatFrame:RegisterEvent ("PLAYER_REGEN_DISABLED")
Tercio@39: ProtectCombatFrame:RegisterEvent ("PLAYER_ENTERING_WORLD")
Tercio@39: ProtectCombatFrame:SetScript ("OnEvent", function (self, event)
Tercio@39: if (event == "PLAYER_ENTERING_WORLD") then
Tercio@39: if (InCombatLockdown()) then
Tercio@39: DF.PlayerHasCombatFlag = true
Tercio@39: else
Tercio@39: DF.PlayerHasCombatFlag = false
Tercio@39: end
Tercio@39: DF.RefreshUnsafeOptionsWidgets()
Tercio@39:
Tercio@39: elseif (event == "PLAYER_REGEN_ENABLED") then
Tercio@39: DF.PlayerHasCombatFlag = false
Tercio@39: DF.RefreshUnsafeOptionsWidgets()
Tercio@39:
Tercio@39: elseif (event == "PLAYER_REGEN_DISABLED") then
Tercio@39: DF.PlayerHasCombatFlag = true
Tercio@39: DF.RefreshUnsafeOptionsWidgets()
Tercio@39:
Tercio@39: end
Tercio@39: end)
Tercio@40:
Tercio@40: function DF:CreateInCombatTexture (frame)
Tercio@40: if (DF.debug and not frame) then
Tercio@40: error ("Details! Framework: CreateInCombatTexture invalid frame on parameter 1.")
Tercio@40: end
Tercio@40:
Tercio@40: local in_combat_background = DF:CreateImage (frame)
Tercio@40: in_combat_background:SetColorTexture (.6, 0, 0, .1)
Tercio@40: in_combat_background:Hide()
Tercio@40:
Tercio@40: local in_combat_label = Plater:CreateLabel (frame, "you are in combat", 24, "silver")
Tercio@40: in_combat_label:SetPoint ("right", in_combat_background, "right", -10, 0)
Tercio@40: in_combat_label:Hide()
Tercio@40:
Tercio@40: frame:RegisterEvent ("PLAYER_REGEN_DISABLED")
Tercio@40: frame:RegisterEvent ("PLAYER_REGEN_ENABLED")
Tercio@40: frame:SetScript ("OnEvent", function (self, event)
Tercio@40: if (event == "PLAYER_REGEN_DISABLED") then
Tercio@40: in_combat_background:Show()
Tercio@40: in_combat_label:Show()
Tercio@40: elseif (event == "PLAYER_REGEN_ENABLED") then
Tercio@40: in_combat_background:Hide()
Tercio@40: in_combat_label:Hide()
Tercio@40: end
Tercio@40: end)
Tercio@40:
Tercio@40: return in_combat_background
Tercio@40: end
Tercio@11:
Tercio@11: ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Tercio@11: --> tutorials
Tercio@11:
Tercio@11: function DF:ShowTutorialAlertFrame (maintext, desctext, clickfunc)
Tercio@11:
Tercio@11: local TutorialAlertFrame = _G.DetailsFrameworkTutorialAlertFrame
Tercio@11:
Tercio@11: if (not TutorialAlertFrame) then
Tercio@11:
Tercio@11: TutorialAlertFrame = CreateFrame ("ScrollFrame", "DetailsFrameworkTutorialAlertFrame", UIParent, "DetailsFrameworkTutorialAlertFrameTemplate")
Tercio@11: TutorialAlertFrame.isFirst = true
Tercio@11: TutorialAlertFrame:SetPoint ("left", UIParent, "left", -20, 100)
Tercio@11:
Tercio@11: TutorialAlertFrame:SetWidth (290)
Tercio@11: TutorialAlertFrame.ScrollChild:SetWidth (256)
Tercio@11:
Tercio@11: local scrollname = TutorialAlertFrame.ScrollChild:GetName()
Tercio@11: _G [scrollname .. "BorderTopLeft"]:SetVertexColor (1, 0.8, 0, 1)
Tercio@11: _G [scrollname .. "BorderTopRight"]:SetVertexColor (1, 0.8, 0, 1)
Tercio@11: _G [scrollname .. "BorderBotLeft"]:SetVertexColor (1, 0.8, 0, 1)
Tercio@11: _G [scrollname .. "BorderBotRight"]:SetVertexColor (1, 0.8, 0, 1)
Tercio@11: _G [scrollname .. "BorderLeft"]:SetVertexColor (1, 0.8, 0, 1)
Tercio@11: _G [scrollname .. "BorderRight"]:SetVertexColor (1, 0.8, 0, 1)
Tercio@11: _G [scrollname .. "BorderBottom"]:SetVertexColor (1, 0.8, 0, 1)
Tercio@11: _G [scrollname .. "BorderTop"]:SetVertexColor (1, 0.8, 0, 1)
Tercio@11:
Tercio@11: local iconbg = _G [scrollname .. "QuestIconBg"]
Tercio@11: iconbg:SetTexture ([[Interface\MainMenuBar\UI-MainMenuBar-EndCap-Human]])
Tercio@11: iconbg:SetTexCoord (0, 1, 0, 1)
Tercio@11: iconbg:SetSize (100, 100)
Tercio@11: iconbg:ClearAllPoints()
Tercio@11: iconbg:SetPoint ("bottomleft", TutorialAlertFrame.ScrollChild, "bottomleft")
Tercio@11:
Tercio@11: _G [scrollname .. "Exclamation"]:SetVertexColor (1, 0.8, 0, 1)
Tercio@11: _G [scrollname .. "QuestionMark"]:SetVertexColor (1, 0.8, 0, 1)
Tercio@11:
Tercio@11: _G [scrollname .. "TopText"]:SetText ("Details!") --string
Tercio@11: _G [scrollname .. "QuestName"]:SetText ("") --string
Tercio@11: _G [scrollname .. "BottomText"]:SetText ("") --string
Tercio@11:
Tercio@11: TutorialAlertFrame.ScrollChild.IconShine:SetTexture ([[Interface\MainMenuBar\UI-MainMenuBar-EndCap-Human]])
Tercio@11:
Tercio@11: TutorialAlertFrame:SetScript ("OnMouseUp", function (self)
Tercio@11: if (self.clickfunc and type (self.clickfunc) == "function") then
Tercio@11: self.clickfunc()
Tercio@11: end
Tercio@11: self:Hide()
Tercio@11: end)
Tercio@11: TutorialAlertFrame:Hide()
Tercio@11: end
Tercio@11:
Tercio@11: if (type (maintext) == "string") then
Tercio@11: TutorialAlertFrame.ScrollChild.QuestName:SetText (maintext)
Tercio@11: else
Tercio@11: TutorialAlertFrame.ScrollChild.QuestName:SetText ("")
Tercio@11: end
Tercio@11:
Tercio@11: if (type (desctext) == "string") then
Tercio@11: TutorialAlertFrame.ScrollChild.BottomText:SetText (desctext)
Tercio@11: else
Tercio@11: TutorialAlertFrame.ScrollChild.BottomText:SetText ("")
Tercio@11: end
Tercio@11:
Tercio@11: TutorialAlertFrame.clickfunc = clickfunc
Tercio@11: TutorialAlertFrame:Show()
Tercio@11: DetailsTutorialAlertFrame_SlideInFrame (TutorialAlertFrame, "AUTOQUEST")
Tercio@11: end
Tercio@11:
Tercio@20: local refresh_options = function (self)
Tercio@20: for _, widget in ipairs (self.widget_list) do
Tercio@20: if (widget._get) then
Tercio@20: if (widget.widget_type == "label") then
Tercio@20: if (widget._get()) then
Tercio@20: widget:SetText (widget._get())
Tercio@20: end
Tercio@20: elseif (widget.widget_type == "select") then
Tercio@20: widget:Select (widget._get())
Tercio@20: elseif (widget.widget_type == "toggle" or widget.widget_type == "range") then
Tercio@20: widget:SetValue (widget._get())
Tercio@49: elseif (widget.widget_type == "textentry") then
Tercio@49: widget:SetText (widget._get())
Tercio@20: elseif (widget.widget_type == "color") then
Tercio@20: local default_value, g, b, a = widget._get()
Tercio@20: if (type (default_value) == "table") then
Tercio@20: widget:SetColor (unpack (default_value))
Tercio@20: else
Tercio@20: widget:SetColor (default_value, g, b, a)
Tercio@20: end
Tercio@20: end
Tercio@20: end
Tercio@20: end
Tercio@20: end
Tercio@20:
Tercio@20: function DF:SetAsOptionsPanel (frame)
Tercio@20: frame.RefreshOptions = refresh_options
Tercio@20: frame.widget_list = {}
Tercio@20: end
Tercio@20:
Tercio@11: function DF:CreateOptionsFrame (name, title, template)
Tercio@11:
Tercio@11: template = template or 1
Tercio@11:
Tercio@11: if (template == 2) then
Tercio@11: local options_frame = CreateFrame ("frame", name, UIParent, "ButtonFrameTemplate")
Tercio@11: tinsert (UISpecialFrames, name)
Tercio@11: options_frame:SetSize (500, 200)
Tercio@20: options_frame.RefreshOptions = refresh_options
Tercio@20: options_frame.widget_list = {}
Tercio@11:
Tercio@11: options_frame:SetScript ("OnMouseDown", function(self, button)
Tercio@11: if (button == "RightButton") then
Tercio@11: if (self.moving) then
Tercio@11: self.moving = false
Tercio@11: self:StopMovingOrSizing()
Tercio@11: end
Tercio@11: return options_frame:Hide()
Tercio@11: elseif (button == "LeftButton" and not self.moving) then
Tercio@11: self.moving = true
Tercio@11: self:StartMoving()
Tercio@11: end
Tercio@11: end)
Tercio@11: options_frame:SetScript ("OnMouseUp", function(self)
Tercio@11: if (self.moving) then
Tercio@11: self.moving = false
Tercio@11: self:StopMovingOrSizing()
Tercio@11: end
Tercio@11: end)
Tercio@11:
Tercio@11: options_frame:SetMovable (true)
Tercio@11: options_frame:EnableMouse (true)
Tercio@11: options_frame:SetFrameStrata ("DIALOG")
Tercio@11: options_frame:SetToplevel (true)
Tercio@11:
Tercio@11: options_frame:Hide()
Tercio@11:
Tercio@11: options_frame:SetPoint ("center", UIParent, "center")
Tercio@11: options_frame.TitleText:SetText (title)
Tercio@11: options_frame.portrait:SetTexture ([[Interface\CHARACTERFRAME\TEMPORARYPORTRAIT-FEMALE-BLOODELF]])
Tercio@11:
Tercio@11: return options_frame
Tercio@11:
Tercio@11: elseif (template == 1) then
Tercio@11:
Tercio@11: local options_frame = CreateFrame ("frame", name, UIParent)
Tercio@11: tinsert (UISpecialFrames, name)
Tercio@11: options_frame:SetSize (500, 200)
Tercio@20: options_frame.RefreshOptions = refresh_options
Tercio@20: options_frame.widget_list = {}
Tercio@11:
Tercio@11: options_frame:SetScript ("OnMouseDown", function(self, button)
Tercio@11: if (button == "RightButton") then
Tercio@11: if (self.moving) then
Tercio@11: self.moving = false
Tercio@11: self:StopMovingOrSizing()
Tercio@11: end
Tercio@11: return options_frame:Hide()
Tercio@11: elseif (button == "LeftButton" and not self.moving) then
Tercio@11: self.moving = true
Tercio@11: self:StartMoving()
Tercio@11: end
Tercio@11: end)
Tercio@11: options_frame:SetScript ("OnMouseUp", function(self)
Tercio@11: if (self.moving) then
Tercio@11: self.moving = false
Tercio@11: self:StopMovingOrSizing()
Tercio@11: end
Tercio@11: end)
Tercio@11:
Tercio@11: options_frame:SetMovable (true)
Tercio@11: options_frame:EnableMouse (true)
Tercio@11: options_frame:SetFrameStrata ("DIALOG")
Tercio@11: options_frame:SetToplevel (true)
Tercio@11:
Tercio@11: options_frame:Hide()
Tercio@11:
Tercio@11: options_frame:SetPoint ("center", UIParent, "center")
Tercio@11:
Tercio@11: options_frame:SetBackdrop ({bgFile = "Interface\\Tooltips\\UI-Tooltip-Background", tile = true, tileSize = 16,
Tercio@18: edgeFile = DF.folder .. "border_2", edgeSize = 32,
Tercio@11: insets = {left = 1, right = 1, top = 1, bottom = 1}})
Tercio@11: options_frame:SetBackdropColor (0, 0, 0, .7)
Tercio@11:
Tercio@11: local texturetitle = options_frame:CreateTexture (nil, "artwork")
Tercio@11: texturetitle:SetTexture ([[Interface\CURSOR\Interact]])
Tercio@11: texturetitle:SetTexCoord (0, 1, 0, 1)
Tercio@11: texturetitle:SetVertexColor (1, 1, 1, 1)
Tercio@11: texturetitle:SetPoint ("topleft", options_frame, "topleft", 2, -3)
Tercio@11: texturetitle:SetWidth (36)
Tercio@11: texturetitle:SetHeight (36)
Tercio@11:
Tercio@11: local title = DF:NewLabel (options_frame, nil, "$parentTitle", nil, title, nil, 20, "yellow")
Tercio@11: title:SetPoint ("left", texturetitle, "right", 2, -1)
Tercio@11: DF:SetFontOutline (title, true)
Tercio@11:
Tercio@11: local c = CreateFrame ("Button", nil, options_frame, "UIPanelCloseButton")
Tercio@11: c:SetWidth (32)
Tercio@11: c:SetHeight (32)
Tercio@11: c:SetPoint ("TOPRIGHT", options_frame, "TOPRIGHT", -3, -3)
Tercio@11: c:SetFrameLevel (options_frame:GetFrameLevel()+1)
Tercio@11:
Tercio@11: return options_frame
Tercio@11: end
Tercio@22: end
Tercio@22:
Tercio@22: ------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Tercio@22: --> templates
Tercio@22:
Tercio@56: --fonts
Tercio@56:
Tercio@56: DF.font_templates = DF.font_templates or {}
Tercio@22: DF.font_templates ["ORANGE_FONT_TEMPLATE"] = {color = "orange", size = 11, font = "Accidental Presidency"}
Tercio@22: DF.font_templates ["OPTIONS_FONT_TEMPLATE"] = {color = "yellow", size = 12, font = "Accidental Presidency"}
Tercio@22:
Tercio@56: -- dropdowns
Tercio@56:
Tercio@56: DF.dropdown_templates = DF.dropdown_templates or {}
Tercio@22: DF.dropdown_templates ["OPTIONS_DROPDOWN_TEMPLATE"] = {
Tercio@22: backdrop = {edgeFile = [[Interface\Buttons\WHITE8X8]], edgeSize = 1, bgFile = [[Interface\Tooltips\UI-Tooltip-Background]], tileSize = 64, tile = true},
Tercio@22: backdropcolor = {1, 1, 1, .5},
Tercio@22: backdropbordercolor = {0, 0, 0, 1},
Tercio@22: onentercolor = {1, 1, 1, .5},
Tercio@22: onenterbordercolor = {1, 1, 1, 1},
Tercio@22: }
Tercio@22:
Tercio@56: -- switches
Tercio@56:
Tercio@56: DF.switch_templates = DF.switch_templates or {}
Tercio@22: DF.switch_templates ["OPTIONS_CHECKBOX_TEMPLATE"] = {
Tercio@22: backdrop = {edgeFile = [[Interface\Buttons\WHITE8X8]], edgeSize = 1, bgFile = [[Interface\Tooltips\UI-Tooltip-Background]], tileSize = 64, tile = true},
Tercio@22: backdropcolor = {1, 1, 1, .5},
Tercio@22: backdropbordercolor = {0, 0, 0, 1},
Tercio@22: width = 18,
Tercio@22: height = 18,
Tercio@22: enabled_backdropcolor = {1, 1, 1, .5},
Tercio@22: disabled_backdropcolor = {1, 1, 1, .2},
Tercio@22: onenterbordercolor = {1, 1, 1, 1},
Tercio@22: }
Tercio@22: DF.switch_templates ["OPTIONS_CHECKBOX_BRIGHT_TEMPLATE"] = {
Tercio@22: backdrop = {edgeFile = [[Interface\Buttons\WHITE8X8]], edgeSize = 1, bgFile = [[Interface\Tooltips\UI-Tooltip-Background]], tileSize = 64, tile = true},
Tercio@22: backdropcolor = {1, 1, 1, .5},
Tercio@22: backdropbordercolor = {0, 0, 0, 1},
Tercio@22: width = 18,
Tercio@22: height = 18,
Tercio@22: enabled_backdropcolor = {1, 1, 1, .5},
Tercio@22: disabled_backdropcolor = {1, 1, 1, .5},
Tercio@22: onenterbordercolor = {1, 1, 1, 1},
Tercio@22: }
Tercio@22:
Tercio@56: -- buttons
Tercio@56:
Tercio@56: DF.button_templates = DF.button_templates or {}
Tercio@22: DF.button_templates ["OPTIONS_BUTTON_TEMPLATE"] = {
Tercio@22: backdrop = {edgeFile = [[Interface\Buttons\WHITE8X8]], edgeSize = 1, bgFile = [[Interface\Tooltips\UI-Tooltip-Background]], tileSize = 64, tile = true},
Tercio@22: backdropcolor = {1, 1, 1, .5},
Tercio@22: backdropbordercolor = {0, 0, 0, 1},
Tercio@22: }
Tercio@22:
Tercio@56: -- sliders
Tercio@56:
Tercio@56: DF.slider_templates = DF.slider_templates or {}
Tercio@22: DF.slider_templates ["OPTIONS_SLIDER_TEMPLATE"] = {
Tercio@22: backdrop = {edgeFile = [[Interface\Buttons\WHITE8X8]], edgeSize = 1, bgFile = [[Interface\Tooltips\UI-Tooltip-Background]], tileSize = 64, tile = true},
Tercio@22: backdropcolor = {1, 1, 1, .5},
Tercio@22: backdropbordercolor = {0, 0, 0, 1},
Tercio@22: onentercolor = {1, 1, 1, .5},
Tercio@22: onenterbordercolor = {1, 1, 1, 1},
Tercio@22: thumbtexture = [[Interface\Tooltips\UI-Tooltip-Background]],
Tercio@22: thumbwidth = 16,
Tercio@22: thumbheight = 14,
Tercio@22: thumbcolor = {0, 0, 0, 0.5},
Tercio@22: }
Tercio@22:
Tercio@56: function DF:InstallTemplate (widget_type, template_name, template, parent_name)
Tercio@56:
Tercio@56: local newTemplate = {}
Tercio@56:
Tercio@56: --if has a parent, just copy the parent to the new template
Tercio@56: if (parent_name and type (parent_name) == "string") then
Tercio@56: local parentTemplate = DF:GetTemplate (widget_type, parent_name)
Tercio@56: if (parentTemplate) then
Tercio@56: DF.table.copy (newTemplate, parentTemplate)
Tercio@56: end
Tercio@56: end
Tercio@56:
Tercio@56: --copy the template passed into the new template
Tercio@56: DF.table.copy (newTemplate, template)
Tercio@56:
Tercioo@29: widget_type = string.lower (widget_type)
Tercioo@29:
Tercio@22: local template_table
Tercioo@29: if (widget_type == "font") then
Tercio@22: template_table = DF.font_templates
Tercioo@29: elseif (widget_type == "dropdown") then
Tercio@22: template_table = DF.dropdown_templates
Tercioo@29: elseif (widget_type == "button") then
Tercio@22: template_table = DF.button_templates
Tercioo@29: elseif (widget_type == "switch") then
Tercio@22: template_table = DF.switch_templates
Tercioo@29: elseif (widget_type == "slider") then
Tercioo@29: template_table = DF.slider_templates
Tercioo@29: end
Tercioo@29:
Tercio@56: template_table [template_name] = newTemplate
Tercioo@29:
Tercio@56: return newTemplate
Tercioo@29: end
Tercioo@29:
Tercioo@29: function DF:GetTemplate (widget_type, template_name)
Tercioo@29: widget_type = string.lower (widget_type)
Tercioo@29:
Tercioo@29: local template_table
Tercioo@29: if (widget_type == "font") then
Tercioo@29: template_table = DF.font_templates
Tercioo@29: elseif (widget_type == "dropdown") then
Tercioo@29: template_table = DF.dropdown_templates
Tercioo@29: elseif (widget_type == "button") then
Tercioo@29: template_table = DF.button_templates
Tercioo@29: elseif (widget_type == "switch") then
Tercioo@29: template_table = DF.switch_templates
Tercioo@29: elseif (widget_type == "slider") then
Tercio@22: template_table = DF.slider_templates
Tercio@22: end
Tercio@22: return template_table [template_name]
Tercio@22: end
Tercioo@28:
Tercioo@28: function DF.GetParentName (frame)
Tercioo@28: local parentName = frame:GetName()
Tercioo@28: if (not parentName) then
Tercioo@28: error ("Details! FrameWork: called $parent but parent was no name.", 2)
Tercioo@28: end
Tercioo@28: return parentName
Tercioo@28: end
Tercio@39:
Tercio@39: ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Tercio@39: --> widget scripts and hooks
Tercio@39:
Tercio@39: function DF:RunHooksForWidget (event, ...)
Tercio@39: local hooks = self.HookList [event]
Tercio@39:
Tercio@39: if (not hooks) then
Tercio@39: print (self.widget:GetName(), "sem hook para", event)
Tercio@39: return
Tercio@39: end
Tercio@39:
Tercio@39: for i, func in ipairs (hooks) do
Tercio@39: local success, canInterrupt = pcall (func, ...)
Tercio@39: if (not success) then
Tercio@39: error ("Details! Framework: " .. event .. " hook for " .. self:GetName() .. ": " .. canInterrupt)
Tercio@39: elseif (canInterrupt) then
Tercio@39: return true
Tercio@39: end
Tercio@39: end
Tercio@39: end
Tercio@39:
Tercio@39: function DF:SetHook (hookType, func)
Tercio@39: if (self.HookList [hookType]) then
Tercio@39: if (type (func) == "function") then
Tercio@39: local isRemoval = false
Tercio@39: for i = #self.HookList [hookType], 1, -1 do
Tercio@39: if (self.HookList [hookType] [i] == func) then
Tercio@39: tremove (self.HookList [hookType], i)
Tercio@39: isRemoval = true
Tercio@39: break
Tercio@39: end
Tercio@39: end
Tercio@39: if (not isRemoval) then
Tercio@39: tinsert (self.HookList [hookType], func)
Tercio@39: end
Tercio@39: else
Tercio@39: if (DF.debug) then
Tercio@39: error ("Details! Framework: invalid function for widget " .. self.WidgetType .. ".")
Tercio@39: end
Tercio@39: end
Tercio@39: else
Tercio@39: if (DF.debug) then
Tercio@39: error ("Details! Framework: unknown hook type for widget " .. self.WidgetType .. ": '" .. hookType .. "'.")
Tercio@39: end
Tercio@39: end
Tercio@39: end
Tercio@39:
Tercio@39: ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Tercio@39: --> members
Tercio@39:
Tercio@39: DF.GlobalWidgetControlNames = {
Tercio@39: textentry = "DF_TextEntryMetaFunctions",
Tercio@39: button = "DF_ButtonMetaFunctions",
Tercio@39: panel = "DF_PanelMetaFunctions",
Tercio@39: dropdown = "DF_DropdownMetaFunctions",
Tercio@39: label = "DF_LabelMetaFunctions",
Tercio@39: normal_bar = "DF_NormalBarMetaFunctions",
Tercio@39: image = "DF_ImageMetaFunctions",
Tercio@39: slider = "DF_SliderMetaFunctions",
Tercio@39: split_bar = "DF_SplitBarMetaFunctions",
Tercio@40: aura_tracker = "DF_AuraTracker",
Tercio@39: }
Tercio@39:
Tercio@39: function DF:AddMemberForWidget (widgetName, memberType, memberName, func)
Tercio@39: if (DF.GlobalWidgetControlNames [widgetName]) then
Tercio@39: if (type (memberName) == "string" and (memberType == "SET" or memberType == "GET")) then
Tercio@39: if (func) then
Tercio@39: local widgetControlObject = _G [DF.GlobalWidgetControlNames [widgetName]]
Tercio@39:
Tercio@39: if (memberType == "SET") then
Tercio@39: widgetControlObject ["SetMembers"] [memberName] = func
Tercio@39: elseif (memberType == "GET") then
Tercio@39: widgetControlObject ["GetMembers"] [memberName] = func
Tercio@39: end
Tercio@39: else
Tercio@39: if (DF.debug) then
Tercio@39: error ("Details! Framework: AddMemberForWidget invalid function.")
Tercio@39: end
Tercio@39: end
Tercio@39: else
Tercio@39: if (DF.debug) then
Tercio@39: error ("Details! Framework: AddMemberForWidget unknown memberName or memberType.")
Tercio@39: end
Tercio@39: end
Tercio@39: else
Tercio@39: if (DF.debug) then
Tercio@39: error ("Details! Framework: AddMemberForWidget unknown widget type: " .. (widgetName or "") .. ".")
Tercio@39: end
Tercio@39: end
Tercio@39: end
Tercio@39:
Tercio@39: -----------------------------
Tercio@39:
Tercio@39: function DF:OpenInterfaceProfile()
Tercio@39: InterfaceOptionsFrame_OpenToCategory (self.__name)
Tercio@39: InterfaceOptionsFrame_OpenToCategory (self.__name)
Tercio@39: for i = 1, 100 do
Tercio@39: local button = _G ["InterfaceOptionsFrameAddOnsButton" .. i]
Tercio@39: if (button) then
Tercio@39: local text = _G ["InterfaceOptionsFrameAddOnsButton" .. i .. "Text"]
Tercio@39: if (text) then
Tercio@39: text = text:GetText()
Tercio@39: if (text == self.__name) then
Tercio@39: local toggle = _G ["InterfaceOptionsFrameAddOnsButton" .. i .. "Toggle"]
Tercio@39: if (toggle) then
Tercio@39: if (toggle:GetNormalTexture():GetTexture():find ("PlusButton")) then
Tercio@39: --is minimized, need expand
Tercio@39: toggle:Click()
Tercio@39: _G ["InterfaceOptionsFrameAddOnsButton" .. i+1]:Click()
Tercio@39: elseif (toggle:GetNormalTexture():GetTexture():find ("MinusButton")) then
Tercio@39: --isn't minimized
Tercio@39: _G ["InterfaceOptionsFrameAddOnsButton" .. i+1]:Click()
Tercio@39: end
Tercio@39: end
Tercio@39: break
Tercio@39: end
Tercio@39: end
Tercio@39: else
Tercio@39: self:Msg ("Couldn't not find the profile panel.")
Tercio@39: break
Tercio@39: end
Tercio@39: end
Tercio@39: end
Tercio@39:
Tercio@39: -----------------------------
Tercio@39: --safe copy from blizz api
Tercio@39: function DF:Mixin (object, ...)
Tercio@39: for i = 1, select("#", ...) do
Tercio@39: local mixin = select(i, ...);
Tercio@39: for k, v in pairs(mixin) do
Tercio@39: object[k] = v;
Tercio@39: end
Tercio@39: end
Tercio@39:
Tercio@39: return object;
Tercio@39: end
Tercio@40:
Tercio@40: -----------------------------
Tercio@40: --> animations
Tercio@40:
Tercio@40: function DF:CreateAnimationHub (parent, onPlay, onFinished)
Tercio@40: local newAnimation = parent:CreateAnimationGroup()
Tercio@40: newAnimation:SetScript ("OnPlay", onPlay)
Tercio@40: newAnimation:SetScript ("OnFinished", onFinished)
Tercio@40: newAnimation.NextAnimation = 1
Tercio@40: return newAnimation
Tercio@40: end
Tercio@40:
Tercio@40: function DF:CreateAnimation (animation, type, order, duration, arg1, arg2, arg3, arg4, arg5, arg6, arg7)
Tercio@40: local anim = animation:CreateAnimation (type)
Tercio@40:
Tercio@40: anim:SetOrder (order or animation.NextAnimation)
Tercio@40: anim:SetDuration (duration)
Tercio@40:
Tercio@40: type = string.upper (type)
Tercio@40:
Tercio@40: if (type == "ALPHA") then
Tercio@40: anim:SetFromAlpha (arg1)
Tercio@40: anim:SetToAlpha (arg2)
Tercio@40:
Tercio@40: elseif (type == "SCALE") then
Tercio@40: anim:SetFromScale (arg1, arg2)
Tercio@40: anim:SetToScale (arg3, arg4)
Tercio@40: anim:SetOrigin (arg5 or "center", arg6 or 0, arg7 or 0) --point, x, y
Tercio@40:
Tercio@40: elseif (type == "ROTATION") then
Tercio@40: anim:SetDegrees (arg1) --degree
Tercio@40: anim:SetOrigin (arg2 or "center", arg3 or 0, arg4 or 0) --point, x, y
Tercio@40:
Tercio@40: elseif (type == "TRANSLATION") then
Tercio@40: anim:SetOffset (arg1, arg2)
Tercio@40:
Tercio@40: end
Tercio@40:
Tercio@40: animation.NextAnimation = animation.NextAnimation + 1
Tercio@40: return anim
Tercio@40: end
Tercio@40:
Tercio@58: local frameshake_shake_finished = function (parent, shakeObject)
Tercio@58: if (shakeObject.IsPlaying) then
Tercio@58: shakeObject.IsPlaying = false
Tercio@58:
Tercio@58: --> update the amount of shake running on this frame
Tercio@58: parent.__frameshakes.enabled = parent.__frameshakes.enabled - 1
Tercio@58:
Tercio@58: --> restore the default anchors, in case where deltaTime was too small that didn't triggered an update
Tercio@58: for i = 1, #shakeObject.Anchors do
Tercio@58: local anchor = shakeObject.Anchors [i]
Tercio@58:
Tercio@58: if (#anchor == 3) then
Tercio@58: local anchorTo, point1, point2 = unpack (anchor)
Tercio@58: parent:SetPoint (anchorTo, point1, point2)
Tercio@58:
Tercio@58: elseif (#anchor == 5) then
Tercio@58: local anchorName1, anchorTo, anchorName2, point1, point2 = unpack (anchor)
Tercio@58: parent:SetPoint (anchorName1, anchorTo, anchorName2, point1, point2)
Tercio@58: end
Tercio@58: end
Tercio@58: end
Tercio@58: end
Tercio@58:
Tercio@58: local frameshake_do_update = function (parent, shakeObject, deltaTime)
Tercio@58:
Tercio@58: --> check delta time
Tercio@58: deltaTime = deltaTime or 0
Tercio@58:
Tercio@58: --> update time left
Tercio@58: shakeObject.TimeLeft = max (shakeObject.TimeLeft - deltaTime, 0)
Tercio@58:
Tercio@58: if (shakeObject.TimeLeft > 0) then
Tercio@58:
Tercio@58: --> update fade in and out
Tercio@58: if (shakeObject.IsFadingIn) then
Tercio@58: shakeObject.IsFadingInTime = shakeObject.IsFadingInTime + deltaTime
Tercio@58: end
Tercio@58: if (shakeObject.IsFadingOut) then
Tercio@58: shakeObject.IsFadingOutTime = shakeObject.IsFadingOutTime + deltaTime
Tercio@58: end
Tercio@58:
Tercio@58: --> check if can disable fade in
Tercio@58: if (shakeObject.IsFadingIn and shakeObject.IsFadingInTime > shakeObject.FadeInTime) then
Tercio@58: shakeObject.IsFadingIn = false
Tercio@58: end
Tercio@58:
Tercio@58: --> check if can enable fade out
Tercio@58: if (not shakeObject.IsFadingOut and shakeObject.TimeLeft < shakeObject.FadeOutTime) then
Tercio@58: shakeObject.IsFadingOut = true
Tercio@58: shakeObject.IsFadingOutTime = shakeObject.FadeOutTime - shakeObject.TimeLeft
Tercio@58: end
Tercio@58:
Tercio@58: --> update position
Tercio@58: local scaleShake = min (shakeObject.IsFadingIn and (shakeObject.IsFadingInTime / shakeObject.FadeInTime) or 1, shakeObject.IsFadingOut and (1 - shakeObject.IsFadingOutTime / shakeObject.FadeOutTime) or 1)
Tercio@58:
Tercio@58: if (scaleShake > 0) then
Tercio@58:
Tercio@58: --> delate the time by the frequency on both X and Y offsets
Tercio@58: shakeObject.XSineOffset = shakeObject.XSineOffset + (deltaTime * shakeObject.Frequency)
Tercio@58: shakeObject.YSineOffset = shakeObject.YSineOffset + (deltaTime * shakeObject.Frequency)
Tercio@58:
Tercio@58: --> calc the new position
Tercio@58: local newX, newY
Tercio@58: if (shakeObject.AbsoluteSineX) then
Tercio@58: --absoluting only the sine wave, passing a negative scale will reverse the absolute direction
Tercio@58: newX = shakeObject.Amplitude * abs (math.sin (shakeObject.XSineOffset)) * scaleShake * shakeObject.ScaleX
Tercio@58: else
Tercio@58: newX = shakeObject.Amplitude * math.sin (shakeObject.XSineOffset) * scaleShake * shakeObject.ScaleX
Tercio@58: end
Tercio@58:
Tercio@58: if (shakeObject.AbsoluteSineY) then
Tercio@58: newY = shakeObject.Amplitude * abs (math.sin (shakeObject.YSineOffset)) * scaleShake * shakeObject.ScaleY
Tercio@58: else
Tercio@58: newY = shakeObject.Amplitude * math.sin (shakeObject.YSineOffset) * scaleShake * shakeObject.ScaleY
Tercio@58: end
Tercio@58:
Tercio@58: --> apply the offset to the frame anchors
Tercio@58: for i = 1, #shakeObject.Anchors do
Tercio@58: local anchor = shakeObject.Anchors [i]
Tercio@58:
Tercio@58: if (#anchor == 3) then
Tercio@58: local anchorTo, point1, point2 = unpack (anchor)
Tercio@58: parent:SetPoint (anchorTo, point1 + newX, point2 + newY)
Tercio@58:
Tercio@58: elseif (#anchor == 5) then
Tercio@58: local anchorName1, anchorTo, anchorName2, point1, point2 = unpack (anchor)
Tercio@58: parent:SetPoint (anchorName1, anchorTo, anchorName2, point1 + newX, point2 + newY)
Tercio@58: end
Tercio@58: end
Tercio@58:
Tercio@58: end
Tercio@58: else
Tercio@58: frameshake_shake_finished (parent, shakeObject)
Tercio@58: end
Tercio@58: end
Tercio@58:
Tercio@58: local frameshake_update_all = function (parent, deltaTime)
Tercio@58: --> check if there's a shake running
Tercio@58: --print ("Shakes Enabled: ", parent.__frameshakes.enabled)
Tercio@58: if (parent.__frameshakes.enabled > 0) then
Tercio@58: --update all shakes
Tercio@58: for i = 1, #parent.__frameshakes do
Tercio@58: local shakeObject = parent.__frameshakes [i]
Tercio@58: if (shakeObject.IsPlaying) then
Tercio@58: frameshake_do_update (parent, shakeObject, deltaTime)
Tercio@58: end
Tercio@58: end
Tercio@58: end
Tercio@58: end
Tercio@58:
Tercio@58: --> scale direction scales the X and Y coordinates, scale strength scales the amplitude and frequency
Tercio@58: local frameshake_play = function (parent, shakeObject, scaleDirection, scaleAmplitude, scaleFrequency, scaleDuration)
Tercio@58:
Tercio@58: --> check if is already playing
Tercio@58: if (shakeObject.TimeLeft > 0) then
Tercio@58: --> reset the time left
Tercio@58: shakeObject.TimeLeft = shakeObject.Duration
Tercio@58:
Tercio@58: if (shakeObject.IsFadingOut) then
Tercio@58: if (shakeObject.FadeInTime > 0) then
Tercio@58: shakeObject.IsFadingIn = true
Tercio@58: --> scale the current fade out into fade in, so it starts the fade in at the point where it was fading out
Tercio@58: shakeObject.IsFadingInTime = shakeObject.FadeInTime * (1 - shakeObject.IsFadingOutTime / shakeObject.FadeOutTime)
Tercio@58: else
Tercio@58: shakeObject.IsFadingIn = false
Tercio@58: shakeObject.IsFadingInTime = 0
Tercio@58: end
Tercio@58:
Tercio@58: --> disable fade out and enable fade in
Tercio@58: shakeObject.IsFadingOut = false
Tercio@58: shakeObject.IsFadingOutTime = 0
Tercio@58: end
Tercio@58:
Tercio@58: else
Tercio@58: --> create a new random offset
Tercio@58: shakeObject.XSineOffset = math.pi * 2 * math.random()
Tercio@58: shakeObject.YSineOffset = math.pi * 2 * math.random()
Tercio@58:
Tercio@58: --> store the initial position if case it needs a reset
Tercio@58: shakeObject.StartedXSineOffset = shakeObject.XSineOffset
Tercio@58: shakeObject.StartedYSineOffset = shakeObject.YSineOffset
Tercio@58:
Tercio@58: --> check if there's a fade in time
Tercio@58: if (shakeObject.FadeInTime > 0) then
Tercio@58: shakeObject.IsFadingIn = true
Tercio@58: else
Tercio@58: shakeObject.IsFadingIn = false
Tercio@58: end
Tercio@58:
Tercio@58: shakeObject.IsFadingInTime = 0
Tercio@58: shakeObject.IsFadingOut = false
Tercio@58: shakeObject.IsFadingOutTime = 0
Tercio@58:
Tercio@58: --> apply custom scale
Tercio@58: shakeObject.ScaleX = (scaleDirection or 1) * shakeObject.OriginalScaleX
Tercio@58: shakeObject.ScaleY = (scaleDirection or 1) * shakeObject.OriginalScaleY
Tercio@58: shakeObject.Frequency = (scaleFrequency or 1) * shakeObject.OriginalFrequency
Tercio@58: shakeObject.Amplitude = (scaleAmplitude or 1) * shakeObject.OriginalAmplitude
Tercio@58: shakeObject.Duration = (scaleDuration or 1) * shakeObject.OriginalDuration
Tercio@58:
Tercio@58: --> update the time left
Tercio@58: shakeObject.TimeLeft = shakeObject.Duration
Tercio@58:
Tercio@58: --> check if is dynamic points
Tercio@58: if (shakeObject.IsDynamicAnchor) then
Tercio@58: wipe (shakeObject.Anchors)
Tercio@58: for i = 1, parent:GetNumPoints() do
Tercio@58: local p1, p2, p3, p4, p5 = parent:GetPoint (i)
Tercio@58: shakeObject.Anchors [#shakeObject.Anchors+1] = {p1, p2, p3, p4, p5}
Tercio@58: end
Tercio@58: end
Tercio@58:
Tercio@58: --> update the amount of shake running on this frame
Tercio@58: parent.__frameshakes.enabled = parent.__frameshakes.enabled + 1
Tercio@58: end
Tercio@58:
Tercio@58: shakeObject.IsPlaying = true
Tercio@58:
Tercio@58: frameshake_do_update (parent, shakeObject)
Tercio@58: end
Tercio@58:
Tercio@58: function DF:CreateFrameShake (parent, duration, amplitude, frequency, absoluteSineX, absoluteSineY, scaleX, scaleY, fadeInTime, fadeOutTime, anchorPoints)
Tercio@58:
Tercio@58: --> create the shake table
Tercio@58: local frameShake = {
Tercio@58: Amplitude = amplitude or 2,
Tercio@58: Frequency = frequency or 5,
Tercio@58: Duration = duration or 0.3,
Tercio@58: FadeInTime = fadeInTime or 0.01,
Tercio@58: FadeOutTime = fadeOutTime or 0.01,
Tercio@58: ScaleX = scaleX or 0.2,
Tercio@58: ScaleY = scaleY or 1,
Tercio@58: AbsoluteSineX = absoluteSineX,
Tercio@58: AbsoluteSineY = absoluteSineY,
Tercio@58: --
Tercio@58: IsPlaying = false,
Tercio@58: TimeLeft = 0,
Tercio@58: }
Tercio@58:
Tercio@58: frameShake.OriginalScaleX = frameShake.ScaleX
Tercio@58: frameShake.OriginalScaleY = frameShake.ScaleY
Tercio@58: frameShake.OriginalFrequency = frameShake.Frequency
Tercio@58: frameShake.OriginalAmplitude = frameShake.Amplitude
Tercio@58: frameShake.OriginalDuration = frameShake.Duration
Tercio@58:
Tercio@58: if (type (anchorPoints) ~= "table") then
Tercio@58: frameShake.IsDynamicAnchor = true
Tercio@58: frameShake.Anchors = {}
Tercio@58: else
Tercio@58: frameShake.Anchors = anchorPoints
Tercio@58: end
Tercio@58:
Tercio@58: --> inject frame shake table into the frame
Tercio@58: if (not parent.__frameshakes) then
Tercio@58: parent.__frameshakes = {
Tercio@58: enabled = 0,
Tercio@58: }
Tercio@58: parent.PlayFrameShake = frameshake_play
Tercio@58: parent.UpdateFrameShake = frameshake_do_update
Tercio@58: parent.UpdateAllFrameShake = frameshake_update_all
Tercio@58: parent:HookScript ("OnUpdate", frameshake_update_all)
Tercio@58: end
Tercio@58:
Tercio@58: tinsert (parent.__frameshakes, frameShake)
Tercio@58:
Tercio@58: return frameShake
Tercio@58: end
Tercio@58:
Tercio@58:
Tercio@58: -----------------------------
Tercio@58: --> glow overlay
Tercio@58:
Tercio@58: local play_glow_overlay = function (self)
Tercio@58: self:Show()
Tercio@58: if (self.animOut:IsPlaying()) then
Tercio@58: self.animOut:Stop()
Tercio@58: end
Tercio@58: self.animIn:Play()
Tercio@58: end
Tercio@58:
Tercio@58: local stop_glow_overlay = function (self)
Tercio@58: self.animOut:Stop()
Tercio@58: self.animIn:Stop()
Tercio@58: self:Hide()
Tercio@58: end
Tercio@58:
Tercio@58: local defaultColor = {1, 1, 1, 1}
Tercio@58:
Tercio@58: --this is most copied from the wow client code, few changes applied to customize it
Tercio@58: function DF:CreateGlowOverlay (parent, antsColor, glowColor)
Tercio@58: local glowFrame = CreateFrame ("frame", parent:GetName() and "$parentGlow2" or "OverlayActionGlow" .. math.random (1, 10000000), parent, "ActionBarButtonSpellActivationAlert")
Tercio@58:
Tercio@58: glowFrame.Play = play_glow_overlay
Tercio@58: glowFrame.Stop = stop_glow_overlay
Tercio@58:
Tercio@58: parent.overlay = glowFrame
Tercio@58: local frameWidth, frameHeight = parent:GetSize()
Tercio@58:
Tercio@58: local scale = 1.4
Tercio@58:
Tercio@58: --Make the height/width available before the next frame:
Tercio@58: parent.overlay:SetSize(frameWidth * scale, frameHeight * scale)
Tercio@58: parent.overlay:SetPoint("TOPLEFT", parent, "TOPLEFT", -frameWidth * 0.2, frameHeight * 0.2)
Tercio@58: parent.overlay:SetPoint("BOTTOMRIGHT", parent, "BOTTOMRIGHT", frameWidth * 0.2, -frameHeight * 0.2)
Tercio@58:
Tercio@58: local r, g, b, a = DF:ParseColors (antsColor or defaultColor)
Tercio@58: glowFrame.ants:SetVertexColor (r, g, b, a)
Tercio@58:
Tercio@58: local r, g, b, a = DF:ParseColors (glowColor or defaultColor)
Tercio@58: glowFrame.outerGlow:SetVertexColor (r, g, b, a)
Tercio@58:
Tercio@58: glowFrame.outerGlow:SetScale (1.2)
Tercio@58:
Tercio@58: return glowFrame
Tercio@58: end
Tercio@40:
Tercio@40: -----------------------------
Tercio@40: --> borders
Tercio@40:
Tercio@40: local default_border_color1 = .5
Tercio@40: local default_border_color2 = .3
Tercio@40: local default_border_color3 = .1
Tercio@40:
Tercio@40: local SetBorderAlpha = function (self, alpha1, alpha2, alpha3)
Tercio@40: self.Borders.Alpha1 = alpha1 or self.Borders.Alpha1
Tercio@40: self.Borders.Alpha2 = alpha2 or self.Borders.Alpha2
Tercio@40: self.Borders.Alpha3 = alpha3 or self.Borders.Alpha3
Tercio@40:
Tercio@40: for _, texture in ipairs (self.Borders.Layer1) do
Tercio@40: texture:SetAlpha (self.Borders.Alpha1)
Tercio@40: end
Tercio@40: for _, texture in ipairs (self.Borders.Layer2) do
Tercio@40: texture:SetAlpha (self.Borders.Alpha2)
Tercio@40: end
Tercio@40: for _, texture in ipairs (self.Borders.Layer3) do
Tercio@40: texture:SetAlpha (self.Borders.Alpha3)
Tercio@40: end
Tercio@40: end
Tercio@40:
Tercio@58: local SetBorderColor = function (self, r, g, b)
Tercio@58: for _, texture in ipairs (self.Borders.Layer1) do
Tercio@58: texture:SetColorTexture (r, g, b)
Tercio@58: end
Tercio@58: for _, texture in ipairs (self.Borders.Layer2) do
Tercio@58: texture:SetColorTexture (r, g, b)
Tercio@58: end
Tercio@58: for _, texture in ipairs (self.Borders.Layer3) do
Tercio@58: texture:SetColorTexture (r, g, b)
Tercio@58: end
Tercio@58: end
Tercio@58:
Tercio@58: local SetLayerVisibility = function (self, layer1Shown, layer2Shown, layer3Shown)
Tercio@58:
Tercio@58: for _, texture in ipairs (self.Borders.Layer1) do
Tercio@58: texture:SetShown (layer1Shown)
Tercio@58: end
Tercio@58:
Tercio@58: for _, texture in ipairs (self.Borders.Layer2) do
Tercio@58: texture:SetShown (layer2Shown)
Tercio@58: end
Tercio@58:
Tercio@58: for _, texture in ipairs (self.Borders.Layer3) do
Tercio@58: texture:SetShown (layer3Shown)
Tercio@58: end
Tercio@58:
Tercio@58: end
Tercio@58:
Tercio@40: function DF:CreateBorder (parent, alpha1, alpha2, alpha3)
Tercio@40:
Tercio@40: parent.Borders = {
Tercio@40: Layer1 = {},
Tercio@40: Layer2 = {},
Tercio@40: Layer3 = {},
Tercio@40: Alpha1 = alpha1 or default_border_color1,
Tercio@40: Alpha2 = alpha2 or default_border_color2,
Tercio@40: Alpha3 = alpha3 or default_border_color3,
Tercio@40: }
Tercio@40:
Tercio@40: parent.SetBorderAlpha = SetBorderAlpha
Tercio@58: parent.SetBorderColor = SetBorderColor
Tercio@58: parent.SetLayerVisibility = SetLayerVisibility
Tercio@40:
Tercio@40: local border1 = parent:CreateTexture (nil, "background")
Tercio@40: border1:SetPoint ("topleft", parent, "topleft", -1, 1)
Tercio@40: border1:SetPoint ("bottomleft", parent, "bottomleft", -1, -1)
Tercio@40: border1:SetColorTexture (0, 0, 0, alpha1 or default_border_color1)
Tercio@40: local border2 = parent:CreateTexture (nil, "background")
Tercio@40: border2:SetPoint ("topleft", parent, "topleft", -2, 2)
Tercio@40: border2:SetPoint ("bottomleft", parent, "bottomleft", -2, -2)
Tercio@40: border2:SetColorTexture (0, 0, 0, alpha2 or default_border_color2)
Tercio@40: local border3 = parent:CreateTexture (nil, "background")
Tercio@40: border3:SetPoint ("topleft", parent, "topleft", -3, 3)
Tercio@40: border3:SetPoint ("bottomleft", parent, "bottomleft", -3, -3)
Tercio@40: border3:SetColorTexture (0, 0, 0, alpha3 or default_border_color3)
Tercio@40:
Tercio@40: tinsert (parent.Borders.Layer1, border1)
Tercio@40: tinsert (parent.Borders.Layer2, border2)
Tercio@40: tinsert (parent.Borders.Layer3, border3)
Tercio@40:
Tercio@40: local border1 = parent:CreateTexture (nil, "background")
Tercio@40: border1:SetPoint ("topleft", parent, "topleft", 0, 1)
Tercio@40: border1:SetPoint ("topright", parent, "topright", 1, 1)
Tercio@40: border1:SetColorTexture (0, 0, 0, alpha1 or default_border_color1)
Tercio@40: local border2 = parent:CreateTexture (nil, "background")
Tercio@40: border2:SetPoint ("topleft", parent, "topleft", -1, 2)
Tercio@40: border2:SetPoint ("topright", parent, "topright", 2, 2)
Tercio@40: border2:SetColorTexture (0, 0, 0, alpha2 or default_border_color2)
Tercio@40: local border3 = parent:CreateTexture (nil, "background")
Tercio@40: border3:SetPoint ("topleft", parent, "topleft", -2, 3)
Tercio@40: border3:SetPoint ("topright", parent, "topright", 3, 3)
Tercio@40: border3:SetColorTexture (0, 0, 0, alpha3 or default_border_color3)
Tercio@40:
Tercio@40: tinsert (parent.Borders.Layer1, border1)
Tercio@40: tinsert (parent.Borders.Layer2, border2)
Tercio@40: tinsert (parent.Borders.Layer3, border3)
Tercio@40:
Tercio@40: local border1 = parent:CreateTexture (nil, "background")
Tercio@40: border1:SetPoint ("topright", parent, "topright", 1, 0)
Tercio@40: border1:SetPoint ("bottomright", parent, "bottomright", 1, -1)
Tercio@40: border1:SetColorTexture (0, 0, 0, alpha1 or default_border_color1)
Tercio@40: local border2 = parent:CreateTexture (nil, "background")
Tercio@40: border2:SetPoint ("topright", parent, "topright", 2, 1)
Tercio@40: border2:SetPoint ("bottomright", parent, "bottomright", 2, -2)
Tercio@40: border2:SetColorTexture (0, 0, 0, alpha2 or default_border_color2)
Tercio@40: local border3 = parent:CreateTexture (nil, "background")
Tercio@40: border3:SetPoint ("topright", parent, "topright", 3, 2)
Tercio@40: border3:SetPoint ("bottomright", parent, "bottomright", 3, -3)
Tercio@40: border3:SetColorTexture (0, 0, 0, alpha3 or default_border_color3)
Tercio@40:
Tercio@40: tinsert (parent.Borders.Layer1, border1)
Tercio@40: tinsert (parent.Borders.Layer2, border2)
Tercio@40: tinsert (parent.Borders.Layer3, border3)
Tercio@40:
Tercio@40: local border1 = parent:CreateTexture (nil, "background")
Tercio@40: border1:SetPoint ("bottomleft", parent, "bottomleft", 0, -1)
Tercio@40: border1:SetPoint ("bottomright", parent, "bottomright", 0, -1)
Tercio@40: border1:SetColorTexture (0, 0, 0, alpha1 or default_border_color1)
Tercio@40: local border2 = parent:CreateTexture (nil, "background")
Tercio@40: border2:SetPoint ("bottomleft", parent, "bottomleft", -1, -2)
Tercio@40: border2:SetPoint ("bottomright", parent, "bottomright", 1, -2)
Tercio@40: border2:SetColorTexture (0, 0, 0, alpha2 or default_border_color2)
Tercio@40: local border3 = parent:CreateTexture (nil, "background")
Tercio@40: border3:SetPoint ("bottomleft", parent, "bottomleft", -2, -3)
Tercio@40: border3:SetPoint ("bottomright", parent, "bottomright", 2, -3)
Tercio@40: border3:SetColorTexture (0, 0, 0, alpha3 or default_border_color3)
Tercio@40:
Tercio@40: tinsert (parent.Borders.Layer1, border1)
Tercio@40: tinsert (parent.Borders.Layer2, border2)
Tercio@40: tinsert (parent.Borders.Layer3, border3)
Tercio@40:
Tercio@40: end
Tercio@40:
Tercio@58:
Tercio@58: function DF:CreateBorderWithSpread (parent, alpha1, alpha2, alpha3, size, spread)
Tercio@58:
Tercio@58: parent.Borders = {
Tercio@58: Layer1 = {},
Tercio@58: Layer2 = {},
Tercio@58: Layer3 = {},
Tercio@58: Alpha1 = alpha1 or default_border_color1,
Tercio@58: Alpha2 = alpha2 or default_border_color2,
Tercio@58: Alpha3 = alpha3 or default_border_color3,
Tercio@58: }
Tercio@58:
Tercio@58: parent.SetBorderAlpha = SetBorderAlpha
Tercio@58: parent.SetBorderColor = SetBorderColor
Tercio@58: parent.SetLayerVisibility = SetLayerVisibility
Tercio@58:
Tercio@58: --left
Tercio@58: local border1 = parent:CreateTexture (nil, "background")
Tercio@58: border1:SetPoint ("topleft", parent, "topleft", -1 + spread, 1 + (-spread))
Tercio@58: border1:SetPoint ("bottomleft", parent, "bottomleft", -1 + spread, -1 + spread)
Tercio@58: border1:SetColorTexture (0, 0, 0, alpha1 or default_border_color1)
Tercio@58: border1:SetWidth (size)
Tercio@58:
Tercio@58: local border2 = parent:CreateTexture (nil, "background")
Tercio@58: border2:SetPoint ("topleft", parent, "topleft", -2 + spread, 2 + (-spread))
Tercio@58: border2:SetPoint ("bottomleft", parent, "bottomleft", -2 + spread, -2 + spread)
Tercio@58: border2:SetColorTexture (0, 0, 0, alpha2 or default_border_color2)
Tercio@58: border2:SetWidth (size)
Tercio@58:
Tercio@58: local border3 = parent:CreateTexture (nil, "background")
Tercio@58: border3:SetPoint ("topleft", parent, "topleft", -3 + spread, 3 + (-spread))
Tercio@58: border3:SetPoint ("bottomleft", parent, "bottomleft", -3 + spread, -3 + spread)
Tercio@58: border3:SetColorTexture (0, 0, 0, alpha3 or default_border_color3)
Tercio@58: border3:SetWidth (size)
Tercio@58:
Tercio@58: tinsert (parent.Borders.Layer1, border1)
Tercio@58: tinsert (parent.Borders.Layer2, border2)
Tercio@58: tinsert (parent.Borders.Layer3, border3)
Tercio@58:
Tercio@58: --top
Tercio@58: local border1 = parent:CreateTexture (nil, "background")
Tercio@58: border1:SetPoint ("topleft", parent, "topleft", 0 + spread, 1 + (-spread))
Tercio@58: border1:SetPoint ("topright", parent, "topright", 1 + (-spread), 1 + (-spread))
Tercio@58: border1:SetColorTexture (0, 0, 0, alpha1 or default_border_color1)
Tercio@58: border1:SetHeight (size)
Tercio@58:
Tercio@58: local border2 = parent:CreateTexture (nil, "background")
Tercio@58: border2:SetPoint ("topleft", parent, "topleft", -1 + spread, 2 + (-spread))
Tercio@58: border2:SetPoint ("topright", parent, "topright", 2 + (-spread), 2 + (-spread))
Tercio@58: border2:SetColorTexture (0, 0, 0, alpha2 or default_border_color2)
Tercio@58: border2:SetHeight (size)
Tercio@58:
Tercio@58: local border3 = parent:CreateTexture (nil, "background")
Tercio@58: border3:SetPoint ("topleft", parent, "topleft", -2 + spread, 3 + (-spread))
Tercio@58: border3:SetPoint ("topright", parent, "topright", 3 + (-spread), 3 + (-spread))
Tercio@58: border3:SetColorTexture (0, 0, 0, alpha3 or default_border_color3)
Tercio@58: border3:SetHeight (size)
Tercio@58:
Tercio@58: tinsert (parent.Borders.Layer1, border1)
Tercio@58: tinsert (parent.Borders.Layer2, border2)
Tercio@58: tinsert (parent.Borders.Layer3, border3)
Tercio@58:
Tercio@58: --right
Tercio@58: local border1 = parent:CreateTexture (nil, "background")
Tercio@58: border1:SetPoint ("topright", parent, "topright", 1 + (-spread), 0 + (-spread))
Tercio@58: border1:SetPoint ("bottomright", parent, "bottomright", 1 + (-spread), -1 + spread)
Tercio@58: border1:SetColorTexture (0, 0, 0, alpha1 or default_border_color1)
Tercio@58: border1:SetWidth (size)
Tercio@58:
Tercio@58: local border2 = parent:CreateTexture (nil, "background")
Tercio@58: border2:SetPoint ("topright", parent, "topright", 2 + (-spread), 1 + (-spread))
Tercio@58: border2:SetPoint ("bottomright", parent, "bottomright", 2 + (-spread), -2 + spread)
Tercio@58: border2:SetColorTexture (0, 0, 0, alpha2 or default_border_color2)
Tercio@58: border2:SetWidth (size)
Tercio@58:
Tercio@58: local border3 = parent:CreateTexture (nil, "background")
Tercio@58: border3:SetPoint ("topright", parent, "topright", 3 + (-spread), 2 + (-spread))
Tercio@58: border3:SetPoint ("bottomright", parent, "bottomright", 3 + (-spread), -3 + spread)
Tercio@58: border3:SetColorTexture (0, 0, 0, alpha3 or default_border_color3)
Tercio@58: border3:SetWidth (size)
Tercio@58:
Tercio@58: tinsert (parent.Borders.Layer1, border1)
Tercio@58: tinsert (parent.Borders.Layer2, border2)
Tercio@58: tinsert (parent.Borders.Layer3, border3)
Tercio@58:
Tercio@58: local border1 = parent:CreateTexture (nil, "background")
Tercio@58: border1:SetPoint ("bottomleft", parent, "bottomleft", 0 + spread, -1 + spread)
Tercio@58: border1:SetPoint ("bottomright", parent, "bottomright", 0 + (-spread), -1 + spread)
Tercio@58: border1:SetColorTexture (0, 0, 0, alpha1 or default_border_color1)
Tercio@58: border1:SetHeight (size)
Tercio@58:
Tercio@58: local border2 = parent:CreateTexture (nil, "background")
Tercio@58: border2:SetPoint ("bottomleft", parent, "bottomleft", -1 + spread, -2 + spread)
Tercio@58: border2:SetPoint ("bottomright", parent, "bottomright", 1 + (-spread), -2 + spread)
Tercio@58: border2:SetColorTexture (0, 0, 0, alpha2 or default_border_color2)
Tercio@58: border2:SetHeight (size)
Tercio@58:
Tercio@58: local border3 = parent:CreateTexture (nil, "background")
Tercio@58: border3:SetPoint ("bottomleft", parent, "bottomleft", -2 + spread, -3 + spread)
Tercio@58: border3:SetPoint ("bottomright", parent, "bottomright", 2 + (-spread), -3 + spread)
Tercio@58: border3:SetColorTexture (0, 0, 0, alpha3 or default_border_color3)
Tercio@58: border3:SetHeight (size)
Tercio@58:
Tercio@58: tinsert (parent.Borders.Layer1, border1)
Tercio@58: tinsert (parent.Borders.Layer2, border2)
Tercio@58: tinsert (parent.Borders.Layer3, border3)
Tercio@58:
Tercio@58: end
Tercio@58:
Tercio@40: function DF:ReskinSlider (slider, heightOffset)
Tercio@40: if (slider.slider) then
Tercio@40: slider.cima:SetNormalTexture ([[Interface\Buttons\Arrow-Up-Up]])
Tercio@40: slider.cima:SetPushedTexture ([[Interface\Buttons\Arrow-Up-Down]])
Tercio@40: slider.cima:SetDisabledTexture ([[Interface\Buttons\Arrow-Up-Disabled]])
Tercio@40: slider.cima:GetNormalTexture():ClearAllPoints()
Tercio@40: slider.cima:GetPushedTexture():ClearAllPoints()
Tercio@40: slider.cima:GetDisabledTexture():ClearAllPoints()
Tercio@40: slider.cima:GetNormalTexture():SetPoint ("center", slider.cima, "center", 1, 1)
Tercio@40: slider.cima:GetPushedTexture():SetPoint ("center", slider.cima, "center", 1, 1)
Tercio@40: slider.cima:GetDisabledTexture():SetPoint ("center", slider.cima, "center", 1, 1)
Tercio@40: slider.cima:SetSize (16, 16)
Tercio@40: slider.cima:SetBackdrop ({edgeFile = [[Interface\Buttons\WHITE8X8]], edgeSize = 1, bgFile = [[Interface\AddOns\Details\images\background]]})
Tercio@40: slider.cima:SetBackdropColor (0, 0, 0, 0.3)
Tercio@40: slider.cima:SetBackdropBorderColor (0, 0, 0, 1)
Tercio@40:
Tercio@40: slider.baixo:SetNormalTexture ([[Interface\Buttons\Arrow-Down-Up]])
Tercio@40: slider.baixo:SetPushedTexture ([[Interface\Buttons\Arrow-Down-Down]])
Tercio@40: slider.baixo:SetDisabledTexture ([[Interface\Buttons\Arrow-Down-Disabled]])
Tercio@40: slider.baixo:GetNormalTexture():ClearAllPoints()
Tercio@40: slider.baixo:GetPushedTexture():ClearAllPoints()
Tercio@40: slider.baixo:GetDisabledTexture():ClearAllPoints()
Tercio@40: slider.baixo:GetNormalTexture():SetPoint ("center", slider.baixo, "center", 1, -5)
Tercio@40: slider.baixo:GetPushedTexture():SetPoint ("center", slider.baixo, "center", 1, -5)
Tercio@40: slider.baixo:GetDisabledTexture():SetPoint ("center", slider.baixo, "center", 1, -5)
Tercio@40: slider.baixo:SetSize (16, 16)
Tercio@40: slider.baixo:SetBackdrop ({edgeFile = [[Interface\Buttons\WHITE8X8]], edgeSize = 1, bgFile = [[Interface\AddOns\Details\images\background]]})
Tercio@40: slider.baixo:SetBackdropColor (0, 0, 0, 0.35)
Tercio@40: slider.baixo:SetBackdropBorderColor (0, 0, 0, 1)
Tercio@40:
Tercio@40: slider.slider:SetBackdrop ({edgeFile = [[Interface\Buttons\WHITE8X8]], edgeSize = 1, bgFile = [[Interface\AddOns\Details\images\background]]})
Tercio@40: slider.slider:SetBackdropColor (0, 0, 0, 0.35)
Tercio@40: slider.slider:SetBackdropBorderColor (0, 0, 0, 1)
Tercio@40:
Tercio@40: --slider.slider:Altura (164)
Tercio@40: slider.slider:cimaPoint (0, 13)
Tercio@40: slider.slider:baixoPoint (0, -13)
Tercio@40: slider.slider.thumb:SetTexture ([[Interface\AddOns\Details\images\icons2]])
Tercio@40: slider.slider.thumb:SetTexCoord (482/512, 492/512, 104/512, 120/512)
Tercio@40: slider.slider.thumb:SetSize (12, 12)
Tercio@40: slider.slider.thumb:SetVertexColor (0.6, 0.6, 0.6, 0.95)
Tercio@58:
Tercio@40: else
Tercio@58: --up button
Tercio@58: do
Tercio@58: local normalTexture = slider.ScrollBar.ScrollUpButton.Normal
Tercio@58: normalTexture:SetTexture ([[Interface\Buttons\Arrow-Up-Up]])
Tercio@58: normalTexture:SetTexCoord (0, 1, .2, 1)
Tercio@58:
Tercio@58: normalTexture:SetPoint ("topleft", slider.ScrollBar.ScrollUpButton, "topleft", 1, 0)
Tercio@58: normalTexture:SetPoint ("bottomright", slider.ScrollBar.ScrollUpButton, "bottomright", 1, 0)
Tercio@58:
Tercio@58: local pushedTexture = slider.ScrollBar.ScrollUpButton.Pushed
Tercio@58: pushedTexture:SetTexture ([[Interface\Buttons\Arrow-Up-Down]])
Tercio@58: pushedTexture:SetTexCoord (0, 1, .2, 1)
Tercio@58:
Tercio@58: pushedTexture:SetPoint ("topleft", slider.ScrollBar.ScrollUpButton, "topleft", 1, 0)
Tercio@58: pushedTexture:SetPoint ("bottomright", slider.ScrollBar.ScrollUpButton, "bottomright", 1, 0)
Tercio@40:
Tercio@58: local disabledTexture = slider.ScrollBar.ScrollUpButton.Disabled
Tercio@58: disabledTexture:SetTexture ([[Interface\Buttons\Arrow-Up-Disabled]])
Tercio@58: disabledTexture:SetTexCoord (0, 1, .2, 1)
Tercio@58: disabledTexture:SetAlpha (.5)
Tercio@58:
Tercio@58: disabledTexture:SetPoint ("topleft", slider.ScrollBar.ScrollUpButton, "topleft", 1, 0)
Tercio@58: disabledTexture:SetPoint ("bottomright", slider.ScrollBar.ScrollUpButton, "bottomright", 1, 0)
Tercio@58:
Tercio@58: slider.ScrollBar.ScrollUpButton:SetSize (16, 16)
Tercio@58: slider.ScrollBar.ScrollUpButton:SetBackdrop ({edgeFile = [[Interface\Buttons\WHITE8X8]], edgeSize = 1, bgFile = "Interface\\Tooltips\\UI-Tooltip-Background"})
Tercio@58: slider.ScrollBar.ScrollUpButton:SetBackdropColor (0, 0, 0, 0.3)
Tercio@58: slider.ScrollBar.ScrollUpButton:SetBackdropBorderColor (0, 0, 0, 1)
Tercio@58:
Tercio@58: --it was having problems with the texture anchor when calling ClearAllPoints() and setting new points different from the original
Tercio@58: --now it is using the same points from the original with small offsets tp align correctly
Tercio@58: end
Tercio@58:
Tercio@58: --down button
Tercio@58: do
Tercio@58: local normalTexture = slider.ScrollBar.ScrollDownButton.Normal
Tercio@58: normalTexture:SetTexture ([[Interface\Buttons\Arrow-Down-Up]])
Tercio@58: normalTexture:SetTexCoord (0, 1, 0, .8)
Tercio@58:
Tercio@58: normalTexture:SetPoint ("topleft", slider.ScrollBar.ScrollDownButton, "topleft", 1, -4)
Tercio@58: normalTexture:SetPoint ("bottomright", slider.ScrollBar.ScrollDownButton, "bottomright", 1, -4)
Tercio@58:
Tercio@58: local pushedTexture = slider.ScrollBar.ScrollDownButton.Pushed
Tercio@58: pushedTexture:SetTexture ([[Interface\Buttons\Arrow-Down-Down]])
Tercio@58: pushedTexture:SetTexCoord (0, 1, 0, .8)
Tercio@58:
Tercio@58: pushedTexture:SetPoint ("topleft", slider.ScrollBar.ScrollDownButton, "topleft", 1, -4)
Tercio@58: pushedTexture:SetPoint ("bottomright", slider.ScrollBar.ScrollDownButton, "bottomright", 1, -4)
Tercio@58:
Tercio@58: local disabledTexture = slider.ScrollBar.ScrollDownButton.Disabled
Tercio@58: disabledTexture:SetTexture ([[Interface\Buttons\Arrow-Down-Disabled]])
Tercio@58: disabledTexture:SetTexCoord (0, 1, 0, .8)
Tercio@58: disabledTexture:SetAlpha (.5)
Tercio@58:
Tercio@58: disabledTexture:SetPoint ("topleft", slider.ScrollBar.ScrollDownButton, "topleft", 1, -4)
Tercio@58: disabledTexture:SetPoint ("bottomright", slider.ScrollBar.ScrollDownButton, "bottomright", 1, -4)
Tercio@58:
Tercio@58: slider.ScrollBar.ScrollDownButton:SetSize (16, 16)
Tercio@58: slider.ScrollBar.ScrollDownButton:SetBackdrop ({edgeFile = [[Interface\Buttons\WHITE8X8]], edgeSize = 1, bgFile = "Interface\\Tooltips\\UI-Tooltip-Background"})
Tercio@58: slider.ScrollBar.ScrollDownButton:SetBackdropColor (0, 0, 0, 0.3)
Tercio@58: slider.ScrollBar.ScrollDownButton:SetBackdropBorderColor (0, 0, 0, 1)
Tercio@40:
Tercio@58: --
Tercio@58: --slider.ScrollBar.ScrollDownButton:SetPoint ("top", slider.ScrollBar, "bottom", 0, 0)
Tercio@58: end
Tercio@58:
Tercio@40: --
Tercio@40:
Tercio@40: slider.ScrollBar:SetPoint ("TOPLEFT", slider, "TOPRIGHT", 6, -16)
Tercio@40: slider.ScrollBar:SetPoint ("BOTTOMLEFT", slider, "BOTTOMRIGHT", 6, 16 + (heightOffset and heightOffset*-1 or 0))
Tercio@40:
Tercio@40: slider.ScrollBar.ThumbTexture:SetColorTexture (.5, .5, .5, .3)
Tercio@40: slider.ScrollBar.ThumbTexture:SetSize (12, 8)
Tercio@40:
Tercio@40: --
Tercio@40:
Tercio@40: slider.ScrollBar:SetBackdrop ({edgeFile = [[Interface\Buttons\WHITE8X8]], edgeSize = 1, bgFile = "Interface\\Tooltips\\UI-Tooltip-Background"})
Tercio@40: slider.ScrollBar:SetBackdropColor (0, 0, 0, 0.35)
Tercio@40: slider.ScrollBar:SetBackdropBorderColor (0, 0, 0, 1)
Tercio@40: end
Tercio@40: end
Tercio@40:
Tercio@58: function DF:GetCurrentSpec()
Tercio@58: local specIndex = GetSpecialization()
Tercio@58: if (specIndex) then
Tercio@58: local specID = GetSpecializationInfo (specIndex)
Tercio@58: if (specID and specID ~= 0) then
Tercio@58: return specID
Tercio@58: end
Tercio@58: end
Tercio@58: end
Tercio@58:
Tercio@58: local specs_per_class = {
Tercio@58: ["DEMONHUNTER"] = {577, 581},
Tercio@58: ["DEATHKNIGHT"] = {250, 251, 252},
Tercio@58: ["WARRIOR"] = {71, 72, 73},
Tercio@58: ["MAGE"] = {62, 63, 64},
Tercio@58: ["ROGUE"] = {259, 260, 261},
Tercio@58: ["DRUID"] = {102, 103, 104, 105},
Tercio@58: ["HUNTER"] = {253, 254, 255},
Tercio@58: ["SHAMAN"] = {262, 263, 254},
Tercio@58: ["PRIEST"] = {256, 257, 258},
Tercio@58: ["WARLOCK"] = {265, 266, 267},
Tercio@58: ["PALADIN"] = {65, 66, 70},
Tercio@58: ["MONK"] = {268, 269, 270},
Tercio@58: }
Tercio@58:
Tercio@58: function DF:GetClassSpecIDs (class)
Tercio@58: return specs_per_class [class]
Tercio@58: end
Tercio@58:
Tercio@58: local dispatch_error = function (context, errortext)
Tercio@58: DF:Msg ( (context or "") .. " |cFFFF9900error|r: " .. (errortext or ""))
Tercio@58: end
Tercio@58:
Tercio@58: --> safe call an external func with payload and without telling who is calling
Tercio@58: function DF:QuickDispatch (func, ...)
Tercio@58: if (type (func) ~= "function") then
Tercio@58: return
Tercio@58: end
Tercio@58:
Tercio@58: local okay, errortext = pcall (func, ...)
Tercio@58:
Tercio@58: if (not okay) then
Tercio@58: --> trigger an error msg
Tercio@58: dispatch_error (_, errortext)
Tercio@58: return
Tercio@58: end
Tercio@58:
Tercio@58: return true
Tercio@58: end
Tercio@58:
Tercio@58:
Tercio@58:
Tercio@58: --doo elsee
Tercio@58: --was doing double loops due to not enought height