Tercio@11: Tercio@11: local major, minor = "DetailsFramework-1.0", 2 Tercio@11: local DF, oldminor = LibStub:NewLibrary (major, minor) Tercio@11: Tercio@11: Tercio@11: if (not DF) then Tercio@11: return Tercio@11: end Tercio@11: Tercio@11: local _type = type Tercio@11: local _unpack = unpack Tercio@11: local _ Tercio@11: local upper = string.upper Tercio@11: Tercio@11: DF.LabelNameCounter = 1 Tercio@11: DF.PictureNameCounter = 1 Tercio@11: DF.BarNameCounter = 1 Tercio@11: DF.DropDownCounter = 1 Tercio@11: DF.PanelCounter = 1 Tercio@11: DF.ButtonCounter = 1 Tercio@11: DF.SliderCounter = 1 Tercio@11: DF.SplitBarCounter = 1 Tercio@11: 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 Tercio@11: DF.folder = "" 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@11: "SetFontSize", Tercio@11: "SetFontFace", Tercio@11: "SetFontColor", Tercio@11: "GetFontSize", Tercio@11: "GetFontFace", 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@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@11: Tercio@11: "www_icons", Tercio@11: } Tercio@11: 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@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: 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@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@11: function DF:SetFontOutline (fontString, outline) Tercio@11: local fonte, size = fontString:GetFont() Tercio@11: if (outline) then Tercio@11: if (_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@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@11: print ("|cFFFFFFAA" .. self.__name .. "|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@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@11: FlashAnimation.fadeOut:SetChange (1) Tercio@11: Tercio@11: FlashAnimation.fadeIn = FlashAnimation:CreateAnimation ("Alpha") --> fade in anime Tercio@11: FlashAnimation.fadeIn:SetOrder (2) Tercio@11: FlashAnimation.fadeIn:SetChange (-1) 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: Tercio@11: local fade_IN_finished_func = function (frame) Tercio@11: if (frame.fading_in) then Tercio@11: frame.hidden = true Tercio@11: frame.faded = true Tercio@11: frame.fading_in = false Tercio@11: frame:Hide() Tercio@11: end Tercio@11: end Tercio@11: Tercio@11: local fade_OUT_finished_func = function (frame) Tercio@11: if (frame:IsShown() and frame.fading_out) then Tercio@11: frame.hidden = false Tercio@11: frame.faded = false Tercio@11: frame.fading_out = false Tercio@11: else Tercio@11: frame:SetAlpha(0) Tercio@11: end Tercio@11: end Tercio@11: Tercio@11: local just_fade_func = function (frame) Tercio@11: frame.hidden = false Tercio@11: frame.faded = true Tercio@11: frame.fading_in = false Tercio@11: end Tercio@11: Tercio@11: local anim_OUT_alpha_func = function (frame) Tercio@11: frame.fading_out = false Tercio@11: end Tercio@11: Tercio@11: local anim_IN_alpha_func = function (frame) Tercio@11: frame.fading_in = false Tercio@11: end Tercio@11: Tercio@11: function DF:Fade (frame, tipo, velocidade, parametros) Tercio@11: Tercio@11: if (_type (frame) == "table") then Tercio@11: if (frame.dframework) then Tercio@11: frame = frame.widget Tercio@11: end Tercio@11: end Tercio@11: Tercio@11: velocidade = velocidade or 0.3 Tercio@11: Tercio@11: if (upper (tipo) == "IN") then Tercio@11: Tercio@11: if (frame:GetAlpha() == 0 and frame.hidden and not frame.fading_out) then --> ja esta escondida Tercio@11: return Tercio@11: elseif (frame.fading_in) then --> ja esta com uma animação, se for true Tercio@11: return Tercio@11: end Tercio@11: Tercio@11: if (frame.fading_out) then --> se tiver uma animação de aparecer em andamento se for true Tercio@11: frame.fading_out = false Tercio@11: end Tercio@11: Tercio@11: UIFrameFadeIn (frame, velocidade, frame:GetAlpha(), 0) Tercio@11: frame.fading_in = true Tercio@11: Tercio@11: frame.fadeInfo.finishedFunc = fade_IN_finished_func Tercio@11: frame.fadeInfo.finishedArg1 = frame Tercio@11: Tercio@11: elseif (upper (tipo) == "OUT") then --> aparecer Tercio@11: if (frame:GetAlpha() == 1 and not frame.hidden and not frame.fading_in) then --> ja esta na tela Tercio@11: return Tercio@11: elseif (frame.fading_out) then --> já ta com fading out Tercio@11: return Tercio@11: end Tercio@11: Tercio@11: if (frame.fading_in) then --> se tiver uma animação de hidar em andamento se for true Tercio@11: frame.fading_in = false Tercio@11: end Tercio@11: Tercio@11: frame:Show() Tercio@11: UIFrameFadeOut (frame, velocidade, frame:GetAlpha(), 1.0) Tercio@11: frame.fading_out = true Tercio@11: Tercio@11: frame.fadeInfo.finishedFunc = fade_OUT_finished_func Tercio@11: frame.fadeInfo.finishedArg1 = frame Tercio@11: Tercio@11: elseif (tipo == 0) then --> força o frame a ser mostrado Tercio@11: frame.hidden = false Tercio@11: frame.faded = false Tercio@11: frame.fading_out = false Tercio@11: frame.fading_in = false Tercio@11: frame:Show() Tercio@11: frame:SetAlpha (1) Tercio@11: Tercio@11: elseif (tipo == 1) then --> força o frame a ser hidado Tercio@11: frame.hidden = true Tercio@11: frame.faded = true Tercio@11: frame.fading_out = false Tercio@11: frame.fading_in = false Tercio@11: frame:SetAlpha (0) Tercio@11: frame:Hide() Tercio@11: Tercio@11: elseif (tipo == -1) then --> apenas da fade sem hidar Tercio@11: if (frame:GetAlpha() == 0 and frame.hidden and not frame.fading_out) then --> ja esta escondida Tercio@11: return Tercio@11: elseif (frame.fading_in) then --> ja esta com uma animação, se for true Tercio@11: return Tercio@11: end Tercio@11: Tercio@11: if (frame.fading_out) then --> se tiver uma animação de aparecer em andamento se for true Tercio@11: frame.fading_out = false Tercio@11: end Tercio@11: Tercio@11: UIFrameFadeIn (frame, velocidade, frame:GetAlpha(), 0) Tercio@11: frame.fading_in = true Tercio@11: frame.fadeInfo.finishedFunc = just_fade_func Tercio@11: frame.fadeInfo.finishedArg1 = frame Tercio@11: Tercio@11: elseif (upper (tipo) == "ALPHAANIM") then Tercio@11: Tercio@11: local value = velocidade Tercio@11: local currentApha = frame:GetAlpha() Tercio@11: frame:Show() Tercio@11: Tercio@11: if (currentApha < value) then Tercio@11: if (frame.fading_in) then --> se tiver uma animação de hidar em andamento se for true Tercio@11: frame.fading_in = false Tercio@11: frame.fadeInfo.finishedFunc = nil Tercio@11: end Tercio@11: UIFrameFadeOut (frame, 0.3, currentApha, value) Tercio@11: frame.fading_out = true Tercio@11: Tercio@11: frame.fadeInfo.finishedFunc = anim_OUT_alpha_func Tercio@11: frame.fadeInfo.finishedArg1 = frame Tercio@11: Tercio@11: else Tercio@11: if (frame.fading_out) then --> se tiver uma animação de hidar em andamento se for true Tercio@11: frame.fading_out = false Tercio@11: frame.fadeInfo.finishedFunc = nil Tercio@11: end Tercio@11: UIFrameFadeIn (frame, 0.3, currentApha, value) Tercio@11: frame.fading_in = true Tercio@11: Tercio@11: frame.fadeInfo.finishedFunc = anim_IN_alpha_func Tercio@11: frame.fadeInfo.finishedArg1 = frame Tercio@11: end Tercio@11: Tercio@11: elseif (upper (tipo) == "ALPHA") then --> setando um alpha determinado Tercio@11: if (frame.fading_in or frame.fading_out) then Tercio@11: frame.fadeInfo.finishedFunc = nil Tercio@11: UIFrameFadeIn (frame, velocidade, frame:GetAlpha(), frame:GetAlpha()) Tercio@11: end Tercio@11: frame.hidden = false Tercio@11: frame.faded = false Tercio@11: frame.fading_in = false Tercio@11: frame.fading_out = false Tercio@11: frame:Show() Tercio@11: frame:SetAlpha (velocidade) Tercio@11: end 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@11: if (frameGlobal 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@11: if (frameGlobal 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@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@11: _arg1, _arg2, _arg3, _arg4 = _unpack (_arg1) 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@11: function DF:BuildMenu (parent, menu, x_offset, y_offset, height) Tercio@11: Tercio@11: local cur_x = x_offset Tercio@11: local cur_y = y_offset Tercio@11: local max_x = 0 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@11: if (widget_table.type == "select" or widget_table.type == "dropdown") then Tercio@11: local dropdown = self:NewDropDown (parent, nil, "$parentWidget" .. index, nil, 140, 18, widget_table.values, widget_table.get()) Tercio@11: dropdown.tooltip = widget_table.desc Tercio@11: local label = self:NewLabel (parent, nil, "$parentLabel" .. index, nil, widget_table.name, "GameFontNormal", 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@11: elseif (widget_table.type == "toggle" or widget_table.type == "switch") then Tercio@11: local switch = self:NewSwitch (parent, nil, "$parentWidget" .. index, nil, 60, 20, nil, nil, widget_table.get()) Tercio@11: switch.tooltip = widget_table.desc Tercio@11: switch.OnSwitch = widget_table.set Tercio@11: Tercio@11: local label = self:NewLabel (parent, nil, "$parentLabel" .. index, nil, widget_table.name, "GameFontNormal", 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@11: elseif (widget_table.type == "range" or widget_table.type == "slider") then Tercio@11: local is_decimanls = widget_table.usedecimals Tercio@11: local slider = self:NewSlider (parent, nil, "$parentWidget" .. index, nil, 140, 20, widget_table.min, widget_table.max, widget_table.step, widget_table.get(), is_decimanls) Tercio@11: slider.tooltip = widget_table.desc Tercio@11: slider:SetHook ("OnValueChange", widget_table.set) Tercio@11: Tercio@11: local label = self:NewLabel (parent, nil, "$parentLabel" .. index, nil, widget_table.name, "GameFontNormal", 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@11: elseif (widget_table.type == "color" or widget_table.type == "color") then Tercio@11: local colorpick = self:NewColorPickButton (parent, "$parentWidget" .. index, nil, widget_table.set) Tercio@11: colorpick.tooltip = widget_table.desc 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@11: local label = self:NewLabel (parent, nil, "$parentLabel" .. index, nil, widget_table.name, "GameFontNormal", 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@11: elseif (widget_table.type == "execute" or widget_table.type == "button") then Tercio@11: Tercio@11: local button = self:NewButton (parent, nil, "$parentWidget", nil, 120, 18, widget_table.func, widget_table.param1, widget_table.param2, nil, widget_table.name) Tercio@11: button:InstallCustomTexture() Tercio@11: button:SetPoint (cur_x, cur_y) Tercio@11: button.tooltip = widget_table.desc 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@11: 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@11: if (cur_y < height) then Tercio@11: cur_y = y_offset Tercio@11: cur_x = cur_x + max_x + 30 Tercio@11: Tercio@11: max_x = 0 Tercio@11: end Tercio@11: Tercio@11: end Tercio@11: Tercio@11: 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@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@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@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@11: edgeFile = [[Interface\AddOns\Details\images\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@11: end