annotate Libs/DF/fw.lua @ 51:dbf04157d63e v7.3.0.051

- ToC Update.
author Tercio
date Sat, 02 Sep 2017 12:42:52 -0300
parents 7d5934415ad0
children 36b4d9559b69
rev   line source
Tercio@11 1
Tercio@49 2 local dversion = 54
Tercio@25 3 local major, minor = "DetailsFramework-1.0", dversion
Tercio@11 4 local DF, oldminor = LibStub:NewLibrary (major, minor)
Tercio@11 5
Tercio@18 6 if (not DF) then
Tercio@20 7 DetailsFrameworkCanLoad = false
Tercio@11 8 return
Tercio@11 9 end
Tercio@11 10
Tercio@20 11 DetailsFrameworkCanLoad = true
Tercio@25 12 local SharedMedia = LibStub:GetLibrary ("LibSharedMedia-3.0")
Tercio@18 13
Tercioo@29 14 local _
Tercio@11 15 local _type = type
Tercio@11 16 local _unpack = unpack
Tercio@11 17 local upper = string.upper
Tercio@11 18
Tercioo@29 19 --> will always give a very random name for our widgets
Tercioo@29 20 local init_counter = math.random (1, 1000000)
Tercioo@29 21
Tercioo@29 22 DF.LabelNameCounter = DF.LabelNameCounter or init_counter
Tercioo@29 23 DF.PictureNameCounter = DF.PictureNameCounter or init_counter
Tercioo@29 24 DF.BarNameCounter = DF.BarNameCounter or init_counter
Tercioo@29 25 DF.DropDownCounter = DF.DropDownCounter or init_counter
Tercioo@29 26 DF.PanelCounter = DF.PanelCounter or init_counter
Tercioo@29 27 DF.SimplePanelCounter = DF.SimplePanelCounter or init_counter
Tercioo@29 28 DF.ButtonCounter = DF.ButtonCounter or init_counter
Tercioo@29 29 DF.SliderCounter = DF.SliderCounter or init_counter
Tercioo@29 30 DF.SwitchCounter = DF.SwitchCounter or init_counter
Tercioo@29 31 DF.SplitBarCounter = DF.SplitBarCounter or init_counter
Tercio@11 32
Tercio@39 33 DF.FRAMELEVEL_OVERLAY = 750
Tercio@39 34 DF.FRAMELEVEL_BACKGROUND = 150
Tercio@39 35
Tercio@25 36 DF.FrameWorkVersion = tostring (dversion)
Tercio@25 37 function DF:PrintVersion()
Tercio@25 38 print ("Details! Framework Version:", DF.FrameWorkVersion)
Tercio@25 39 end
Tercio@25 40
Tercio@22 41 LibStub:GetLibrary("AceTimer-3.0"):Embed (DF)
Tercio@22 42
Tercioo@29 43 --> get the working folder
Tercio@11 44 do
Tercio@11 45 local path = string.match (debugstack (1, 1, 0), "AddOns\\(.+)fw.lua")
Tercio@11 46 if (path) then
Tercio@11 47 DF.folder = "Interface\\AddOns\\" .. path
Tercio@11 48 else
Tercioo@29 49 --> if not found, try to use the last valid one
Tercioo@29 50 DF.folder = DF.folder or ""
Tercio@11 51 end
Tercio@11 52 end
Tercio@11 53
Tercio@11 54 DF.debug = false
Tercio@11 55
Tercio@11 56 _G ["DetailsFramework"] = DF
Tercio@11 57
Tercio@11 58 DF.embeds = DF.embeds or {}
Tercio@11 59 local embed_functions = {
Tercio@20 60 "RemoveRealName",
Tercio@20 61 "table",
Tercio@20 62 "BuildDropDownFontList",
Tercio@11 63 "SetFontSize",
Tercio@11 64 "SetFontFace",
Tercio@11 65 "SetFontColor",
Tercio@11 66 "GetFontSize",
Tercio@11 67 "GetFontFace",
Tercio@17 68 "SetFontOutline",
Tercio@11 69 "trim",
Tercio@11 70 "Msg",
Tercio@11 71 "CreateFlashAnimation",
Tercio@11 72 "Fade",
Tercio@11 73 "NewColor",
Tercio@11 74 "IsHtmlColor",
Tercio@11 75 "ParseColors",
Tercio@11 76 "BuildMenu",
Tercio@11 77 "ShowTutorialAlertFrame",
Tercio@11 78 "GetNpcIdFromGuid",
Tercio@11 79 "ShowFeedbackPanel",
Tercio@20 80 "SetAsOptionsPanel",
Tercio@11 81
Tercio@11 82 "CreateDropDown",
Tercio@11 83 "CreateButton",
Tercio@11 84 "CreateColorPickButton",
Tercio@11 85 "CreateLabel",
Tercio@11 86 "CreateBar",
Tercio@11 87 "CreatePanel",
Tercio@11 88 "CreateFillPanel",
Tercio@11 89 "ColorPick",
Tercio@11 90 "IconPick",
Tercio@11 91 "CreateSimplePanel",
Tercio@11 92 "CreateChartPanel",
Tercio@11 93 "CreateImage",
Tercio@11 94 "CreateScrollBar",
Tercio@11 95 "CreateSwitch",
Tercio@11 96 "CreateSlider",
Tercio@11 97 "CreateSplitBar",
Tercio@11 98 "CreateTextEntry",
Tercio@11 99 "Create1PxPanel",
Tercio@11 100 "CreateFeedbackButton",
Tercio@20 101 "CreateOptionsFrame",
Tercio@22 102 "NewSpecialLuaEditorEntry",
Tercio@20 103 "ShowPromptPanel",
Tercio@22 104 "ShowTextPromptPanel",
Tercio@11 105 "www_icons",
Tercio@22 106 "GetTemplate",
Tercioo@29 107 "InstallTemplate",
Tercio@22 108 "GetFrameworkFolder",
Tercioo@29 109 "ShowPanicWarning",
Tercio@39 110 "SetFrameworkDebugState",
Tercio@39 111 "FindHighestParent",
Tercio@39 112 "OpenInterfaceProfile",
Tercio@40 113 "CreateInCombatTexture",
Tercio@40 114 "CreateAnimationHub",
Tercio@40 115 "CreateAnimation",
Tercio@40 116 "CreateScrollBox",
Tercio@40 117 "CreateBorder",
Tercio@42 118 "FormatNumber",
Tercio@11 119 }
Tercio@11 120
Tercio@20 121 DF.table = {}
Tercio@20 122
Tercio@22 123 function DF:GetFrameworkFolder()
Tercio@22 124 return DF.folder
Tercio@22 125 end
Tercio@22 126
Tercio@39 127 function DF:SetFrameworkDebugState (state)
Tercio@39 128 DF.debug = state
Tercio@39 129 end
Tercio@39 130
Tercio@26 131 function DF:FadeFrame (frame, t)
Tercio@26 132 if (t == 0) then
Tercio@26 133 frame.hidden = false
Tercio@26 134 frame.faded = false
Tercio@26 135 frame.fading_out = false
Tercio@26 136 frame.fading_in = false
Tercio@26 137 frame:Show()
Tercio@26 138 frame:SetAlpha (1)
Tercio@26 139
Tercio@26 140 elseif (t == 1) then
Tercio@26 141 frame.hidden = true
Tercio@26 142 frame.faded = true
Tercio@26 143 frame.fading_out = false
Tercio@26 144 frame.fading_in = false
Tercio@26 145 frame:SetAlpha (0)
Tercio@26 146 frame:Hide()
Tercio@26 147 end
Tercio@26 148 end
Tercio@26 149
Tercio@20 150 function DF.table.reverse (t)
Tercio@20 151 local new = {}
Tercio@20 152 local index = 1
Tercio@20 153 for i = #t, 1, -1 do
Tercio@20 154 new [index] = t[i]
Tercio@20 155 index = index + 1
Tercio@20 156 end
Tercio@20 157 return new
Tercio@20 158 end
Tercio@20 159
Tercio@20 160 --> copy from table2 to table1 overwriting values
Tercio@20 161 function DF.table.copy (t1, t2)
Tercio@20 162 for key, value in pairs (t2) do
Tercio@20 163 if (type (value) == "table") then
Tercio@20 164 t1 [key] = t1 [key] or {}
Tercio@20 165 DF.table.copy (t1 [key], t2 [key])
Tercio@20 166 else
Tercio@20 167 t1 [key] = value
Tercio@20 168 end
Tercio@20 169 end
Tercio@20 170 return t1
Tercio@20 171 end
Tercio@20 172
Tercio@20 173 --> copy values that does exist on table2 but not on table1
Tercio@20 174 function DF.table.deploy (t1, t2)
Tercio@20 175 for key, value in pairs (t2) do
Tercio@20 176 if (type (value) == "table") then
Tercio@20 177 t1 [key] = t1 [key] or {}
Tercio@20 178 DF.table.deploy (t1 [key], t2 [key])
Tercio@22 179 elseif (t1 [key] == nil) then
Tercio@20 180 t1 [key] = value
Tercio@20 181 end
Tercio@20 182 end
Tercio@20 183 end
Tercio@20 184
Tercio@20 185 function DF.table.dump (t, s, deep)
Tercio@20 186 s = s or ""
Tercio@20 187 deep = deep or 0
Tercio@20 188 local space = ""
Tercio@20 189 for i = 1, deep do
Tercio@20 190 space = space .. " "
Tercio@20 191 end
Tercio@20 192 for key, value in pairs (t) do
Tercio@20 193 local tpe = _type (value)
Tercio@20 194 if (type (key) ~= "string") then
Tercio@20 195 key = "unknown?"
Tercio@20 196 end
Tercio@20 197 if (tpe == "table") then
Tercio@20 198 s = s .. space .. "[" .. key .. "] = |cFFa9ffa9table {|r\n"
Tercio@20 199 s = s .. DF.table.dump (value, nil, deep+1)
Tercio@20 200 s = s .. space .. "|cFFa9ffa9}|r\n"
Tercio@20 201 elseif (tpe == "string") then
Tercio@20 202 s = s .. space .. "[" .. key .. "] = '|cFFfff1c1" .. value .. "|r'\n"
Tercio@20 203 elseif (tpe == "number") then
Tercio@20 204 s = s .. space .. "[" .. key .. "] = |cFFffc1f4" .. value .. "|r\n"
Tercio@20 205 elseif (tpe == "function") then
Tercio@20 206 s = s .. space .. "[" .. key .. "] = function()\n"
Tercio@20 207 elseif (tpe == "boolean") then
Tercio@20 208 s = s .. space .. "[" .. key .. "] = |cFF99d0ff" .. (value and "true" or "false") .. "|r\n"
Tercio@20 209 end
Tercio@20 210 end
Tercio@20 211 return s
Tercio@20 212 end
Tercio@20 213
Tercio@11 214 DF.www_icons = {
Tercio@11 215 texture = "feedback_sites",
Tercio@11 216 wowi = {0, 0.7890625, 0, 37/128},
Tercio@11 217 curse = {0, 0.7890625, 38/123, 79/128},
Tercio@11 218 mmoc = {0, 0.7890625, 80/123, 123/128},
Tercio@11 219 }
Tercio@11 220
Tercio@42 221 local symbol_1K, symbol_10K, symbol_1B
Tercio@42 222 if (GetLocale() == "koKR") then
Tercio@42 223 symbol_1K, symbol_10K, symbol_1B = "천", "만", "억"
Tercio@42 224 elseif (GetLocale() == "zhCN") then
Tercio@42 225 symbol_1K, symbol_10K, symbol_1B = "千", "万", "亿"
Tercio@42 226 elseif (GetLocale() == "zhTW") then
Tercio@42 227 symbol_1K, symbol_10K, symbol_1B = "千", "萬", "億"
Tercio@42 228 end
Tercio@42 229
Tercio@42 230 if (symbol_1K) then
Tercio@42 231 function DF.FormatNumber (numero)
Tercio@42 232 if (numero > 99999999) then
Tercio@42 233 return format ("%.2f", numero/100000000) .. symbol_1B
Tercio@42 234 elseif (numero > 999999) then
Tercio@42 235 return format ("%.2f", numero/10000) .. symbol_10K
Tercio@42 236 elseif (numero > 99999) then
Tercio@42 237 return floor (numero/10000) .. symbol_10K
Tercio@42 238 elseif (numero > 9999) then
Tercio@42 239 return format ("%.1f", (numero/10000)) .. symbol_10K
Tercio@42 240 elseif (numero > 999) then
Tercio@42 241 return format ("%.1f", (numero/1000)) .. symbol_1K
Tercio@42 242 end
Tercio@42 243 return format ("%.1f", numero)
Tercio@42 244 end
Tercio@42 245 else
Tercio@42 246 function DF.FormatNumber (numero)
Tercio@47 247 if (numero > 999999999) then
Tercio@47 248 return format ("%.2f", numero/1000000000) .. "B"
Tercio@47 249 elseif (numero > 999999) then
Tercio@42 250 return format ("%.2f", numero/1000000) .. "M"
Tercio@42 251 elseif (numero > 99999) then
Tercio@42 252 return floor (numero/1000) .. "K"
Tercio@42 253 elseif (numero > 999) then
Tercio@42 254 return format ("%.1f", (numero/1000)) .. "K"
Tercio@42 255 end
Tercio@42 256 return format ("%.1f", numero)
Tercio@42 257 end
Tercio@42 258 end
Tercio@42 259
Tercio@24 260 function DF:IntegerToTimer (value)
Tercio@24 261 return "" .. floor (value/60) .. ":" .. format ("%02.f", value%60)
Tercio@24 262 end
Tercio@24 263
Tercio@11 264 function DF:Embed (target)
Tercio@11 265 for k, v in pairs (embed_functions) do
Tercio@11 266 target[v] = self[v]
Tercio@11 267 end
Tercio@11 268 self.embeds [target] = true
Tercio@11 269 return target
Tercio@11 270 end
Tercio@11 271
Tercioo@28 272 function DF:RemoveRealmName (name)
Tercioo@28 273 return name:gsub (("%-.*"), "")
Tercioo@28 274 end
Tercioo@28 275
Tercio@20 276 function DF:RemoveRealName (name)
Tercio@20 277 return name:gsub (("%-.*"), "")
Tercio@20 278 end
Tercio@20 279
Tercio@11 280 function DF:SetFontSize (fontString, ...)
Tercio@11 281 local fonte, _, flags = fontString:GetFont()
Tercio@11 282 fontString:SetFont (fonte, max (...), flags)
Tercio@11 283 end
Tercio@11 284 function DF:SetFontFace (fontString, fontface)
Tercio@25 285 local font = SharedMedia:Fetch ("font", fontface, true)
Tercio@25 286 if (font) then
Tercio@25 287 fontface = font
Tercio@25 288 end
Tercio@25 289
Tercio@11 290 local _, size, flags = fontString:GetFont()
Tercio@11 291 fontString:SetFont (fontface, size, flags)
Tercio@11 292 end
Tercio@11 293 function DF:SetFontColor (fontString, r, g, b, a)
Tercio@11 294 r, g, b, a = DF:ParseColors (r, g, b, a)
Tercio@11 295 fontString:SetTextColor (r, g, b, a)
Tercio@11 296 end
Tercio@11 297
Tercio@11 298 function DF:GetFontSize (fontString)
Tercio@11 299 local _, size = fontString:GetFont()
Tercio@11 300 return size
Tercio@11 301 end
Tercio@11 302 function DF:GetFontFace (fontString)
Tercio@11 303 local fontface = fontString:GetFont()
Tercio@11 304 return fontface
Tercio@11 305 end
Tercio@11 306
Tercio@49 307 local ValidOutlines = {
Tercio@49 308 ["NONE"] = true,
Tercio@49 309 ["MONOCHROME"] = true,
Tercio@49 310 ["OUTLINE"] = true,
Tercio@49 311 ["THICKOUTLINE"] = true,
Tercio@49 312 }
Tercio@11 313 function DF:SetFontOutline (fontString, outline)
Tercio@11 314 local fonte, size = fontString:GetFont()
Tercio@11 315 if (outline) then
Tercio@49 316 if (ValidOutlines [outline]) then
Tercio@49 317 outline = outline
Tercio@49 318 elseif (_type (outline) == "boolean" and outline) then
Tercio@11 319 outline = "OUTLINE"
Tercio@11 320 elseif (outline == 1) then
Tercio@11 321 outline = "OUTLINE"
Tercio@11 322 elseif (outline == 2) then
Tercio@11 323 outline = "THICKOUTLINE"
Tercio@11 324 end
Tercio@11 325 end
Tercio@11 326
Tercio@11 327 fontString:SetFont (fonte, size, outline)
Tercio@11 328 end
Tercio@11 329
Tercio@11 330 function DF:trim (s)
Tercio@11 331 local from = s:match"^%s*()"
Tercio@11 332 return from > #s and "" or s:match(".*%S", from)
Tercio@11 333 end
Tercio@11 334
Tercio@11 335 function DF:Msg (msg)
Tercio@11 336 print ("|cFFFFFFAA" .. self.__name .. "|r " .. msg)
Tercio@11 337 end
Tercio@11 338
Tercio@11 339 function DF:GetNpcIdFromGuid (guid)
Tercio@11 340 local NpcId = select ( 6, strsplit ( "-", guid ) )
Tercio@11 341 if (NpcId) then
Tercio@11 342 return tonumber ( NpcId )
Tercio@11 343 end
Tercio@11 344 return 0
Tercio@11 345 end
Tercio@11 346
Tercio@11 347 local onFinish = function (self)
Tercio@11 348 if (self.showWhenDone) then
Tercio@11 349 self.frame:SetAlpha (1)
Tercio@11 350 else
Tercio@11 351 self.frame:SetAlpha (0)
Tercio@11 352 self.frame:Hide()
Tercio@11 353 end
Tercio@11 354
Tercio@11 355 if (self.onFinishFunc) then
Tercio@11 356 self:onFinishFunc (self.frame)
Tercio@11 357 end
Tercio@11 358 end
Tercio@11 359
Tercio@11 360 local stop = function (self)
Tercio@11 361 local FlashAnimation = self.FlashAnimation
Tercio@11 362 FlashAnimation:Stop()
Tercio@11 363 end
Tercio@11 364
Tercio@11 365 local flash = function (self, fadeInTime, fadeOutTime, flashDuration, showWhenDone, flashInHoldTime, flashOutHoldTime, loopType)
Tercio@11 366
Tercio@11 367 local FlashAnimation = self.FlashAnimation
Tercio@11 368
Tercio@11 369 local fadeIn = FlashAnimation.fadeIn
Tercio@11 370 local fadeOut = FlashAnimation.fadeOut
Tercio@11 371
Tercio@11 372 fadeIn:Stop()
Tercio@11 373 fadeOut:Stop()
Tercio@11 374
Tercio@11 375 fadeIn:SetDuration (fadeInTime or 1)
Tercio@11 376 fadeIn:SetEndDelay (flashInHoldTime or 0)
Tercio@11 377
Tercio@11 378 fadeOut:SetDuration (fadeOutTime or 1)
Tercio@11 379 fadeOut:SetEndDelay (flashOutHoldTime or 0)
Tercio@11 380
Tercio@11 381 FlashAnimation.duration = flashDuration
Tercio@11 382 FlashAnimation.loopTime = FlashAnimation:GetDuration()
Tercio@11 383 FlashAnimation.finishAt = GetTime() + flashDuration
Tercio@11 384 FlashAnimation.showWhenDone = showWhenDone
Tercio@11 385
Tercio@11 386 FlashAnimation:SetLooping (loopType or "REPEAT")
Tercio@11 387
Tercio@11 388 self:Show()
Tercio@11 389 self:SetAlpha (0)
Tercio@11 390 FlashAnimation:Play()
Tercio@11 391 end
Tercio@11 392
Tercio@11 393 function DF:CreateFlashAnimation (frame, onFinishFunc, onLoopFunc)
Tercio@11 394 local FlashAnimation = frame:CreateAnimationGroup()
Tercio@11 395
Tercio@11 396 FlashAnimation.fadeOut = FlashAnimation:CreateAnimation ("Alpha") --> fade out anime
Tercio@11 397 FlashAnimation.fadeOut:SetOrder (1)
Tercio@39 398 FlashAnimation.fadeOut:SetFromAlpha (0)
Tercio@39 399 FlashAnimation.fadeOut:SetToAlpha (1)
Tercio@11 400
Tercio@11 401 FlashAnimation.fadeIn = FlashAnimation:CreateAnimation ("Alpha") --> fade in anime
Tercio@11 402 FlashAnimation.fadeIn:SetOrder (2)
Tercio@39 403 FlashAnimation.fadeIn:SetFromAlpha (1)
Tercio@39 404 FlashAnimation.fadeIn:SetToAlpha (0)
Tercio@11 405
Tercio@11 406 frame.FlashAnimation = FlashAnimation
Tercio@11 407 FlashAnimation.frame = frame
Tercio@11 408 FlashAnimation.onFinishFunc = onFinishFunc
Tercio@11 409
Tercio@11 410 FlashAnimation:SetScript ("OnLoop", onLoopFunc)
Tercio@11 411 FlashAnimation:SetScript ("OnFinished", onFinish)
Tercio@11 412
Tercio@11 413 frame.Flash = flash
Tercio@11 414 frame.Stop = stop
Tercio@11 415 end
Tercio@11 416
Tercio@11 417 ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Tercio@11 418 --> points
Tercio@11 419
Tercio@11 420 function DF:CheckPoints (v1, v2, v3, v4, v5, object)
Tercio@11 421
Tercio@11 422 if (not v1 and not v2) then
Tercio@11 423 return "topleft", object.widget:GetParent(), "topleft", 0, 0
Tercio@11 424 end
Tercio@11 425
Tercio@11 426 if (_type (v1) == "string") then
Tercio@11 427 local frameGlobal = _G [v1]
Tercio@11 428 if (frameGlobal and frameGlobal.GetObjectType) then
Tercio@11 429 return DF:CheckPoints (frameGlobal, v2, v3, v4, v5, object)
Tercio@11 430 end
Tercio@11 431
Tercio@11 432 elseif (_type (v2) == "string") then
Tercio@11 433 local frameGlobal = _G [v2]
Tercio@11 434 if (frameGlobal and frameGlobal.GetObjectType) then
Tercio@11 435 return DF:CheckPoints (v1, frameGlobal, v3, v4, v5, object)
Tercio@11 436 end
Tercio@11 437 end
Tercio@11 438
Tercio@11 439 if (_type (v1) == "string" and _type (v2) == "table") then --> :setpoint ("left", frame, _, _, _)
Tercio@11 440 if (not v3 or _type (v3) == "number") then --> :setpoint ("left", frame, 10, 10)
Tercio@11 441 v1, v2, v3, v4, v5 = v1, v2, v1, v3, v4
Tercio@11 442 end
Tercio@11 443
Tercio@11 444 elseif (_type (v1) == "string" and _type (v2) == "number") then --> :setpoint ("topleft", x, y)
Tercio@11 445 v1, v2, v3, v4, v5 = v1, object.widget:GetParent(), v1, v2, v3
Tercio@11 446
Tercio@11 447 elseif (_type (v1) == "number") then --> :setpoint (x, y)
Tercio@11 448 v1, v2, v3, v4, v5 = "topleft", object.widget:GetParent(), "topleft", v1, v2
Tercio@11 449
Tercio@11 450 elseif (_type (v1) == "table") then --> :setpoint (frame, x, y)
Tercio@11 451 v1, v2, v3, v4, v5 = "topleft", v1, "topleft", v2, v3
Tercio@11 452
Tercio@11 453 end
Tercio@11 454
Tercio@11 455 if (not v2) then
Tercio@11 456 v2 = object.widget:GetParent()
Tercio@11 457 elseif (v2.dframework) then
Tercio@11 458 v2 = v2.widget
Tercio@11 459 end
Tercio@11 460
Tercio@11 461 return v1 or "topleft", v2, v3 or "topleft", v4 or 0, v5 or 0
Tercio@11 462 end
Tercio@11 463
Tercio@11 464
Tercio@11 465 ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Tercio@11 466 --> colors
Tercio@11 467
Tercio@11 468 function DF:NewColor (_colorname, _colortable, _green, _blue, _alpha)
Tercio@11 469 assert (_type (_colorname) == "string", "NewColor: colorname must be a string.")
Tercio@11 470 assert (not DF.alias_text_colors [_colorname], "NewColor: colorname already exists.")
Tercio@11 471
Tercio@11 472 if (_type (_colortable) == "table") then
Tercio@11 473 if (_colortable[1] and _colortable[2] and _colortable[3]) then
Tercio@11 474 _colortable[4] = _colortable[4] or 1
Tercio@11 475 DF.alias_text_colors [_colorname] = _colortable
Tercio@11 476 else
Tercio@11 477 error ("invalid color table.")
Tercio@11 478 end
Tercio@11 479 elseif (_colortable and _green and _blue) then
Tercio@11 480 _alpha = _alpha or 1
Tercio@11 481 DF.alias_text_colors [_colorname] = {_colortable, _green, _blue, _alpha}
Tercio@11 482 else
Tercio@11 483 error ("invalid parameter.")
Tercio@11 484 end
Tercio@11 485
Tercio@11 486 return true
Tercio@11 487 end
Tercio@11 488
Tercio@11 489 function DF:IsHtmlColor (color)
Tercio@11 490 return DF.alias_text_colors [color]
Tercio@11 491 end
Tercio@11 492
Tercio@11 493 local tn = tonumber
Tercio@11 494 function DF:ParseColors (_arg1, _arg2, _arg3, _arg4)
Tercio@11 495 if (_type (_arg1) == "table") then
Tercio@25 496 if (not _arg1[1] and _arg1.r) then
Tercio@25 497 _arg1, _arg2, _arg3, _arg4 = _arg1.r, _arg1.g, _arg1.b, _arg1.a
Tercio@25 498 else
Tercio@25 499 _arg1, _arg2, _arg3, _arg4 = _unpack (_arg1)
Tercio@25 500 end
Tercio@11 501
Tercio@11 502 elseif (_type (_arg1) == "string") then
Tercio@11 503
Tercio@11 504 if (string.find (_arg1, "#")) then
Tercio@11 505 _arg1 = _arg1:gsub ("#","")
Tercio@11 506 if (string.len (_arg1) == 8) then --alpha
Tercio@11 507 _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 508 else
Tercio@11 509 _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 510 end
Tercio@11 511
Tercio@11 512 else
Tercio@11 513 local color = DF.alias_text_colors [_arg1]
Tercio@11 514 if (color) then
Tercio@11 515 _arg1, _arg2, _arg3, _arg4 = _unpack (color)
Tercio@11 516 else
Tercio@11 517 _arg1, _arg2, _arg3, _arg4 = _unpack (DF.alias_text_colors.none)
Tercio@11 518 end
Tercio@11 519 end
Tercio@11 520 end
Tercio@11 521
Tercio@11 522 if (not _arg1) then
Tercio@11 523 _arg1 = 1
Tercio@11 524 end
Tercio@11 525 if (not _arg2) then
Tercio@11 526 _arg2 = 1
Tercio@11 527 end
Tercio@11 528 if (not _arg3) then
Tercio@11 529 _arg3 = 1
Tercio@11 530 end
Tercio@11 531 if (not _arg4) then
Tercio@11 532 _arg4 = 1
Tercio@11 533 end
Tercio@11 534
Tercio@11 535 return _arg1, _arg2, _arg3, _arg4
Tercio@11 536 end
Tercio@11 537
Tercio@11 538 ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Tercio@11 539 --> menus
Tercio@11 540
Tercio@39 541 local disable_on_combat = {}
Tercio@39 542
Tercio@22 543 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 544
Tercio@22 545 if (not parent.widget_list) then
Tercio@22 546 DF:SetAsOptionsPanel (parent)
Tercio@22 547 end
Tercio@11 548
Tercio@11 549 local cur_x = x_offset
Tercio@11 550 local cur_y = y_offset
Tercio@11 551 local max_x = 0
Tercio@11 552
Tercio@11 553 height = abs ((height or parent:GetHeight()) - abs (y_offset) + 20)
Tercio@11 554 height = height*-1
Tercio@11 555
Tercio@11 556 for index, widget_table in ipairs (menu) do
Tercio@11 557
Tercio@39 558 local widget_created
Tercio@39 559
Tercio@20 560 if (widget_table.type == "blank" or widget_table.type == "space") then
Tercio@20 561 -- do nothing
Tercio@20 562
Tercio@20 563 elseif (widget_table.type == "label" or widget_table.type == "text") then
Tercio@22 564 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 565 label._get = widget_table.get
Tercio@20 566 label.widget_type = "label"
Tercio@20 567 label:SetPoint (cur_x, cur_y)
Tercio@20 568 tinsert (parent.widget_list, label)
Tercio@20 569
Tercio@20 570 elseif (widget_table.type == "select" or widget_table.type == "dropdown") then
Tercio@22 571 local dropdown = DF:NewDropDown (parent, nil, "$parentWidget" .. index, nil, 140, 18, widget_table.values, widget_table.get(), dropdown_template)
Tercio@11 572 dropdown.tooltip = widget_table.desc
Tercio@20 573 dropdown._get = widget_table.get
Tercio@20 574 dropdown.widget_type = "select"
Tercio@22 575 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 576 dropdown:SetPoint ("left", label, "right", 2)
Tercio@11 577 label:SetPoint (cur_x, cur_y)
Tercio@11 578
Tercio@11 579 local size = label.widget:GetStringWidth() + 140 + 4
Tercio@11 580 if (size > max_x) then
Tercio@11 581 max_x = size
Tercio@11 582 end
Tercio@11 583
Tercio@20 584 tinsert (parent.widget_list, dropdown)
Tercio@39 585 widget_created = dropdown
Tercio@20 586
Tercio@11 587 elseif (widget_table.type == "toggle" or widget_table.type == "switch") then
Tercio@22 588 local switch = DF:NewSwitch (parent, nil, "$parentWidget" .. index, nil, 60, 20, nil, nil, widget_table.get(), nil, nil, nil, nil, switch_template)
Tercio@11 589 switch.tooltip = widget_table.desc
Tercio@20 590 switch._get = widget_table.get
Tercio@20 591 switch.widget_type = "toggle"
Tercio@11 592 switch.OnSwitch = widget_table.set
Tercio@11 593
Tercio@22 594 if (switch_is_box) then
Tercio@22 595 switch:SetAsCheckBox()
Tercio@22 596 end
Tercio@22 597
Tercio@22 598 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 599 switch:SetPoint ("left", label, "right", 2)
Tercio@11 600 label:SetPoint (cur_x, cur_y)
Tercio@11 601
Tercio@11 602 local size = label.widget:GetStringWidth() + 60 + 4
Tercio@11 603 if (size > max_x) then
Tercio@11 604 max_x = size
Tercio@11 605 end
Tercio@11 606
Tercio@20 607 tinsert (parent.widget_list, switch)
Tercio@39 608 widget_created = switch
Tercio@20 609
Tercio@11 610 elseif (widget_table.type == "range" or widget_table.type == "slider") then
Tercio@11 611 local is_decimanls = widget_table.usedecimals
Tercio@22 612 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 613 slider.tooltip = widget_table.desc
Tercio@20 614 slider._get = widget_table.get
Tercio@20 615 slider.widget_type = "range"
Tercio@11 616 slider:SetHook ("OnValueChange", widget_table.set)
Tercio@11 617
Tercio@40 618 if (widget_table.thumbscale) then
Tercio@40 619 slider:SetThumbSize (slider.thumb:GetWidth()*widget_table.thumbscale, nil)
Tercio@40 620 end
Tercio@40 621
Tercio@22 622 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 623 slider:SetPoint ("left", label, "right", 2)
Tercio@11 624 label:SetPoint (cur_x, cur_y)
Tercio@11 625
Tercio@11 626 local size = label.widget:GetStringWidth() + 140 + 6
Tercio@11 627 if (size > max_x) then
Tercio@11 628 max_x = size
Tercio@11 629 end
Tercio@11 630
Tercio@20 631 tinsert (parent.widget_list, slider)
Tercio@39 632 widget_created = slider
Tercio@20 633
Tercio@11 634 elseif (widget_table.type == "color" or widget_table.type == "color") then
Tercio@22 635 local colorpick = DF:NewColorPickButton (parent, "$parentWidget" .. index, nil, widget_table.set, nil, button_template)
Tercio@11 636 colorpick.tooltip = widget_table.desc
Tercio@20 637 colorpick._get = widget_table.get
Tercio@20 638 colorpick.widget_type = "color"
Tercio@11 639
Tercio@11 640 local default_value, g, b, a = widget_table.get()
Tercio@11 641 if (type (default_value) == "table") then
Tercio@11 642 colorpick:SetColor (unpack (default_value))
Tercio@11 643 else
Tercio@11 644 colorpick:SetColor (default_value, g, b, a)
Tercio@11 645 end
Tercio@11 646
Tercio@22 647 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 648 colorpick:SetPoint ("left", label, "right", 2)
Tercio@11 649 label:SetPoint (cur_x, cur_y)
Tercio@11 650
Tercio@11 651 local size = label.widget:GetStringWidth() + 60 + 4
Tercio@11 652 if (size > max_x) then
Tercio@11 653 max_x = size
Tercio@11 654 end
Tercio@11 655
Tercio@20 656 tinsert (parent.widget_list, colorpick)
Tercio@39 657 widget_created = colorpick
Tercio@20 658
Tercio@11 659 elseif (widget_table.type == "execute" or widget_table.type == "button") then
Tercio@11 660
Tercio@49 661 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 662 if (not button_template) then
Tercio@22 663 button:InstallCustomTexture()
Tercio@22 664 end
Tercio@22 665
Tercio@11 666 button:SetPoint (cur_x, cur_y)
Tercio@11 667 button.tooltip = widget_table.desc
Tercio@20 668 button.widget_type = "execute"
Tercio@11 669
Tercio@11 670 local size = button:GetWidth() + 4
Tercio@11 671 if (size > max_x) then
Tercio@11 672 max_x = size
Tercio@11 673 end
Tercio@11 674
Tercio@20 675 tinsert (parent.widget_list, button)
Tercio@39 676 widget_created = button
Tercio@20 677
Tercio@49 678
Tercio@49 679 elseif (widget_table.type == "textentry") then
Tercio@49 680 local textentry = DF:CreateTextEntry (parent, widget_table.func, 120, 18, nil, "$parentWidget" .. index, nil, button_template)
Tercio@49 681 textentry.tooltip = widget_table.desc
Tercio@49 682 textentry.text = widget_table.get()
Tercio@49 683 textentry._get = widget_table.get
Tercio@49 684 textentry.widget_type = "textentry"
Tercio@49 685 textentry:SetHook ("OnEnterPressed", widget_table.set)
Tercio@49 686 textentry:SetHook ("OnEditFocusLost", widget_table.set)
Tercio@49 687
Tercio@49 688 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 689 textentry:SetPoint ("left", label, "right", 2)
Tercio@49 690 label:SetPoint (cur_x, cur_y)
Tercio@49 691
Tercio@49 692 local size = label.widget:GetStringWidth() + 60 + 4
Tercio@49 693 if (size > max_x) then
Tercio@49 694 max_x = size
Tercio@49 695 end
Tercio@49 696
Tercio@49 697 tinsert (parent.widget_list, textentry)
Tercio@49 698 widget_created = textentry
Tercio@49 699
Tercio@11 700 end
Tercio@39 701
Tercio@39 702 if (widget_table.nocombat) then
Tercio@39 703 tinsert (disable_on_combat, widget_created)
Tercio@39 704 end
Tercio@11 705
Tercio@11 706 if (widget_table.spacement) then
Tercio@11 707 cur_y = cur_y - 30
Tercio@11 708 else
Tercio@11 709 cur_y = cur_y - 20
Tercio@11 710 end
Tercio@11 711
Tercio@39 712 if (widget_table.type == "breakline" or cur_y < height) then
Tercio@11 713 cur_y = y_offset
Tercio@11 714 cur_x = cur_x + max_x + 30
Tercio@11 715 max_x = 0
Tercio@11 716 end
Tercio@11 717
Tercio@11 718 end
Tercio@11 719
Tercio@39 720 DF.RefreshUnsafeOptionsWidgets()
Tercio@39 721
Tercio@11 722 end
Tercio@39 723
Tercio@39 724 local lock_notsafe_widgets = function()
Tercio@39 725 for _, widget in ipairs (disable_on_combat) do
Tercio@39 726 widget:Disable()
Tercio@39 727 end
Tercio@39 728 end
Tercio@39 729 local unlock_notsafe_widgets = function()
Tercio@39 730 for _, widget in ipairs (disable_on_combat) do
Tercio@39 731 widget:Enable()
Tercio@39 732 end
Tercio@39 733 end
Tercio@39 734 function DF.RefreshUnsafeOptionsWidgets()
Tercio@39 735 if (DF.PlayerHasCombatFlag) then
Tercio@39 736 lock_notsafe_widgets()
Tercio@39 737 else
Tercio@39 738 unlock_notsafe_widgets()
Tercio@39 739 end
Tercio@39 740 end
Tercio@39 741 DF.PlayerHasCombatFlag = false
Tercio@39 742 local ProtectCombatFrame = CreateFrame ("frame")
Tercio@39 743 ProtectCombatFrame:RegisterEvent ("PLAYER_REGEN_ENABLED")
Tercio@39 744 ProtectCombatFrame:RegisterEvent ("PLAYER_REGEN_DISABLED")
Tercio@39 745 ProtectCombatFrame:RegisterEvent ("PLAYER_ENTERING_WORLD")
Tercio@39 746 ProtectCombatFrame:SetScript ("OnEvent", function (self, event)
Tercio@39 747 if (event == "PLAYER_ENTERING_WORLD") then
Tercio@39 748 if (InCombatLockdown()) then
Tercio@39 749 DF.PlayerHasCombatFlag = true
Tercio@39 750 else
Tercio@39 751 DF.PlayerHasCombatFlag = false
Tercio@39 752 end
Tercio@39 753 DF.RefreshUnsafeOptionsWidgets()
Tercio@39 754
Tercio@39 755 elseif (event == "PLAYER_REGEN_ENABLED") then
Tercio@39 756 DF.PlayerHasCombatFlag = false
Tercio@39 757 DF.RefreshUnsafeOptionsWidgets()
Tercio@39 758
Tercio@39 759 elseif (event == "PLAYER_REGEN_DISABLED") then
Tercio@39 760 DF.PlayerHasCombatFlag = true
Tercio@39 761 DF.RefreshUnsafeOptionsWidgets()
Tercio@39 762
Tercio@39 763 end
Tercio@39 764 end)
Tercio@40 765
Tercio@40 766 function DF:CreateInCombatTexture (frame)
Tercio@40 767 if (DF.debug and not frame) then
Tercio@40 768 error ("Details! Framework: CreateInCombatTexture invalid frame on parameter 1.")
Tercio@40 769 end
Tercio@40 770
Tercio@40 771 local in_combat_background = DF:CreateImage (frame)
Tercio@40 772 in_combat_background:SetColorTexture (.6, 0, 0, .1)
Tercio@40 773 in_combat_background:Hide()
Tercio@40 774
Tercio@40 775 local in_combat_label = Plater:CreateLabel (frame, "you are in combat", 24, "silver")
Tercio@40 776 in_combat_label:SetPoint ("right", in_combat_background, "right", -10, 0)
Tercio@40 777 in_combat_label:Hide()
Tercio@40 778
Tercio@40 779 frame:RegisterEvent ("PLAYER_REGEN_DISABLED")
Tercio@40 780 frame:RegisterEvent ("PLAYER_REGEN_ENABLED")
Tercio@40 781 frame:SetScript ("OnEvent", function (self, event)
Tercio@40 782 if (event == "PLAYER_REGEN_DISABLED") then
Tercio@40 783 in_combat_background:Show()
Tercio@40 784 in_combat_label:Show()
Tercio@40 785 elseif (event == "PLAYER_REGEN_ENABLED") then
Tercio@40 786 in_combat_background:Hide()
Tercio@40 787 in_combat_label:Hide()
Tercio@40 788 end
Tercio@40 789 end)
Tercio@40 790
Tercio@40 791 return in_combat_background
Tercio@40 792 end
Tercio@11 793
Tercio@11 794 ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Tercio@11 795 --> tutorials
Tercio@11 796
Tercio@11 797 function DF:ShowTutorialAlertFrame (maintext, desctext, clickfunc)
Tercio@11 798
Tercio@11 799 local TutorialAlertFrame = _G.DetailsFrameworkTutorialAlertFrame
Tercio@11 800
Tercio@11 801 if (not TutorialAlertFrame) then
Tercio@11 802
Tercio@11 803 TutorialAlertFrame = CreateFrame ("ScrollFrame", "DetailsFrameworkTutorialAlertFrame", UIParent, "DetailsFrameworkTutorialAlertFrameTemplate")
Tercio@11 804 TutorialAlertFrame.isFirst = true
Tercio@11 805 TutorialAlertFrame:SetPoint ("left", UIParent, "left", -20, 100)
Tercio@11 806
Tercio@11 807 TutorialAlertFrame:SetWidth (290)
Tercio@11 808 TutorialAlertFrame.ScrollChild:SetWidth (256)
Tercio@11 809
Tercio@11 810 local scrollname = TutorialAlertFrame.ScrollChild:GetName()
Tercio@11 811 _G [scrollname .. "BorderTopLeft"]:SetVertexColor (1, 0.8, 0, 1)
Tercio@11 812 _G [scrollname .. "BorderTopRight"]:SetVertexColor (1, 0.8, 0, 1)
Tercio@11 813 _G [scrollname .. "BorderBotLeft"]:SetVertexColor (1, 0.8, 0, 1)
Tercio@11 814 _G [scrollname .. "BorderBotRight"]:SetVertexColor (1, 0.8, 0, 1)
Tercio@11 815 _G [scrollname .. "BorderLeft"]:SetVertexColor (1, 0.8, 0, 1)
Tercio@11 816 _G [scrollname .. "BorderRight"]:SetVertexColor (1, 0.8, 0, 1)
Tercio@11 817 _G [scrollname .. "BorderBottom"]:SetVertexColor (1, 0.8, 0, 1)
Tercio@11 818 _G [scrollname .. "BorderTop"]:SetVertexColor (1, 0.8, 0, 1)
Tercio@11 819
Tercio@11 820 local iconbg = _G [scrollname .. "QuestIconBg"]
Tercio@11 821 iconbg:SetTexture ([[Interface\MainMenuBar\UI-MainMenuBar-EndCap-Human]])
Tercio@11 822 iconbg:SetTexCoord (0, 1, 0, 1)
Tercio@11 823 iconbg:SetSize (100, 100)
Tercio@11 824 iconbg:ClearAllPoints()
Tercio@11 825 iconbg:SetPoint ("bottomleft", TutorialAlertFrame.ScrollChild, "bottomleft")
Tercio@11 826
Tercio@11 827 _G [scrollname .. "Exclamation"]:SetVertexColor (1, 0.8, 0, 1)
Tercio@11 828 _G [scrollname .. "QuestionMark"]:SetVertexColor (1, 0.8, 0, 1)
Tercio@11 829
Tercio@11 830 _G [scrollname .. "TopText"]:SetText ("Details!") --string
Tercio@11 831 _G [scrollname .. "QuestName"]:SetText ("") --string
Tercio@11 832 _G [scrollname .. "BottomText"]:SetText ("") --string
Tercio@11 833
Tercio@11 834 TutorialAlertFrame.ScrollChild.IconShine:SetTexture ([[Interface\MainMenuBar\UI-MainMenuBar-EndCap-Human]])
Tercio@11 835
Tercio@11 836 TutorialAlertFrame:SetScript ("OnMouseUp", function (self)
Tercio@11 837 if (self.clickfunc and type (self.clickfunc) == "function") then
Tercio@11 838 self.clickfunc()
Tercio@11 839 end
Tercio@11 840 self:Hide()
Tercio@11 841 end)
Tercio@11 842 TutorialAlertFrame:Hide()
Tercio@11 843 end
Tercio@11 844
Tercio@11 845 if (type (maintext) == "string") then
Tercio@11 846 TutorialAlertFrame.ScrollChild.QuestName:SetText (maintext)
Tercio@11 847 else
Tercio@11 848 TutorialAlertFrame.ScrollChild.QuestName:SetText ("")
Tercio@11 849 end
Tercio@11 850
Tercio@11 851 if (type (desctext) == "string") then
Tercio@11 852 TutorialAlertFrame.ScrollChild.BottomText:SetText (desctext)
Tercio@11 853 else
Tercio@11 854 TutorialAlertFrame.ScrollChild.BottomText:SetText ("")
Tercio@11 855 end
Tercio@11 856
Tercio@11 857 TutorialAlertFrame.clickfunc = clickfunc
Tercio@11 858 TutorialAlertFrame:Show()
Tercio@11 859 DetailsTutorialAlertFrame_SlideInFrame (TutorialAlertFrame, "AUTOQUEST")
Tercio@11 860 end
Tercio@11 861
Tercio@20 862 local refresh_options = function (self)
Tercio@20 863 for _, widget in ipairs (self.widget_list) do
Tercio@20 864 if (widget._get) then
Tercio@20 865 if (widget.widget_type == "label") then
Tercio@20 866 if (widget._get()) then
Tercio@20 867 widget:SetText (widget._get())
Tercio@20 868 end
Tercio@20 869 elseif (widget.widget_type == "select") then
Tercio@20 870 widget:Select (widget._get())
Tercio@20 871 elseif (widget.widget_type == "toggle" or widget.widget_type == "range") then
Tercio@20 872 widget:SetValue (widget._get())
Tercio@49 873 elseif (widget.widget_type == "textentry") then
Tercio@49 874 widget:SetText (widget._get())
Tercio@20 875 elseif (widget.widget_type == "color") then
Tercio@20 876 local default_value, g, b, a = widget._get()
Tercio@20 877 if (type (default_value) == "table") then
Tercio@20 878 widget:SetColor (unpack (default_value))
Tercio@20 879 else
Tercio@20 880 widget:SetColor (default_value, g, b, a)
Tercio@20 881 end
Tercio@20 882 end
Tercio@20 883 end
Tercio@20 884 end
Tercio@20 885 end
Tercio@20 886
Tercio@20 887 function DF:SetAsOptionsPanel (frame)
Tercio@20 888 frame.RefreshOptions = refresh_options
Tercio@20 889 frame.widget_list = {}
Tercio@20 890 end
Tercio@20 891
Tercio@11 892 function DF:CreateOptionsFrame (name, title, template)
Tercio@11 893
Tercio@11 894 template = template or 1
Tercio@11 895
Tercio@11 896 if (template == 2) then
Tercio@11 897 local options_frame = CreateFrame ("frame", name, UIParent, "ButtonFrameTemplate")
Tercio@11 898 tinsert (UISpecialFrames, name)
Tercio@11 899 options_frame:SetSize (500, 200)
Tercio@20 900 options_frame.RefreshOptions = refresh_options
Tercio@20 901 options_frame.widget_list = {}
Tercio@11 902
Tercio@11 903 options_frame:SetScript ("OnMouseDown", function(self, button)
Tercio@11 904 if (button == "RightButton") then
Tercio@11 905 if (self.moving) then
Tercio@11 906 self.moving = false
Tercio@11 907 self:StopMovingOrSizing()
Tercio@11 908 end
Tercio@11 909 return options_frame:Hide()
Tercio@11 910 elseif (button == "LeftButton" and not self.moving) then
Tercio@11 911 self.moving = true
Tercio@11 912 self:StartMoving()
Tercio@11 913 end
Tercio@11 914 end)
Tercio@11 915 options_frame:SetScript ("OnMouseUp", function(self)
Tercio@11 916 if (self.moving) then
Tercio@11 917 self.moving = false
Tercio@11 918 self:StopMovingOrSizing()
Tercio@11 919 end
Tercio@11 920 end)
Tercio@11 921
Tercio@11 922 options_frame:SetMovable (true)
Tercio@11 923 options_frame:EnableMouse (true)
Tercio@11 924 options_frame:SetFrameStrata ("DIALOG")
Tercio@11 925 options_frame:SetToplevel (true)
Tercio@11 926
Tercio@11 927 options_frame:Hide()
Tercio@11 928
Tercio@11 929 options_frame:SetPoint ("center", UIParent, "center")
Tercio@11 930 options_frame.TitleText:SetText (title)
Tercio@11 931 options_frame.portrait:SetTexture ([[Interface\CHARACTERFRAME\TEMPORARYPORTRAIT-FEMALE-BLOODELF]])
Tercio@11 932
Tercio@11 933 return options_frame
Tercio@11 934
Tercio@11 935 elseif (template == 1) then
Tercio@11 936
Tercio@11 937 local options_frame = CreateFrame ("frame", name, UIParent)
Tercio@11 938 tinsert (UISpecialFrames, name)
Tercio@11 939 options_frame:SetSize (500, 200)
Tercio@20 940 options_frame.RefreshOptions = refresh_options
Tercio@20 941 options_frame.widget_list = {}
Tercio@11 942
Tercio@11 943 options_frame:SetScript ("OnMouseDown", function(self, button)
Tercio@11 944 if (button == "RightButton") then
Tercio@11 945 if (self.moving) then
Tercio@11 946 self.moving = false
Tercio@11 947 self:StopMovingOrSizing()
Tercio@11 948 end
Tercio@11 949 return options_frame:Hide()
Tercio@11 950 elseif (button == "LeftButton" and not self.moving) then
Tercio@11 951 self.moving = true
Tercio@11 952 self:StartMoving()
Tercio@11 953 end
Tercio@11 954 end)
Tercio@11 955 options_frame:SetScript ("OnMouseUp", function(self)
Tercio@11 956 if (self.moving) then
Tercio@11 957 self.moving = false
Tercio@11 958 self:StopMovingOrSizing()
Tercio@11 959 end
Tercio@11 960 end)
Tercio@11 961
Tercio@11 962 options_frame:SetMovable (true)
Tercio@11 963 options_frame:EnableMouse (true)
Tercio@11 964 options_frame:SetFrameStrata ("DIALOG")
Tercio@11 965 options_frame:SetToplevel (true)
Tercio@11 966
Tercio@11 967 options_frame:Hide()
Tercio@11 968
Tercio@11 969 options_frame:SetPoint ("center", UIParent, "center")
Tercio@11 970
Tercio@11 971 options_frame:SetBackdrop ({bgFile = "Interface\\Tooltips\\UI-Tooltip-Background", tile = true, tileSize = 16,
Tercio@18 972 edgeFile = DF.folder .. "border_2", edgeSize = 32,
Tercio@11 973 insets = {left = 1, right = 1, top = 1, bottom = 1}})
Tercio@11 974 options_frame:SetBackdropColor (0, 0, 0, .7)
Tercio@11 975
Tercio@11 976 local texturetitle = options_frame:CreateTexture (nil, "artwork")
Tercio@11 977 texturetitle:SetTexture ([[Interface\CURSOR\Interact]])
Tercio@11 978 texturetitle:SetTexCoord (0, 1, 0, 1)
Tercio@11 979 texturetitle:SetVertexColor (1, 1, 1, 1)
Tercio@11 980 texturetitle:SetPoint ("topleft", options_frame, "topleft", 2, -3)
Tercio@11 981 texturetitle:SetWidth (36)
Tercio@11 982 texturetitle:SetHeight (36)
Tercio@11 983
Tercio@11 984 local title = DF:NewLabel (options_frame, nil, "$parentTitle", nil, title, nil, 20, "yellow")
Tercio@11 985 title:SetPoint ("left", texturetitle, "right", 2, -1)
Tercio@11 986 DF:SetFontOutline (title, true)
Tercio@11 987
Tercio@11 988 local c = CreateFrame ("Button", nil, options_frame, "UIPanelCloseButton")
Tercio@11 989 c:SetWidth (32)
Tercio@11 990 c:SetHeight (32)
Tercio@11 991 c:SetPoint ("TOPRIGHT", options_frame, "TOPRIGHT", -3, -3)
Tercio@11 992 c:SetFrameLevel (options_frame:GetFrameLevel()+1)
Tercio@11 993
Tercio@11 994 return options_frame
Tercio@11 995 end
Tercio@22 996 end
Tercio@22 997
Tercio@22 998 ------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Tercio@22 999 --> templates
Tercio@22 1000
Tercio@22 1001 DF.font_templates = {}
Tercio@22 1002 DF.font_templates ["ORANGE_FONT_TEMPLATE"] = {color = "orange", size = 11, font = "Accidental Presidency"}
Tercio@22 1003 DF.font_templates ["OPTIONS_FONT_TEMPLATE"] = {color = "yellow", size = 12, font = "Accidental Presidency"}
Tercio@22 1004
Tercio@22 1005 DF.dropdown_templates = {}
Tercio@22 1006 DF.dropdown_templates ["OPTIONS_DROPDOWN_TEMPLATE"] = {
Tercio@22 1007 backdrop = {edgeFile = [[Interface\Buttons\WHITE8X8]], edgeSize = 1, bgFile = [[Interface\Tooltips\UI-Tooltip-Background]], tileSize = 64, tile = true},
Tercio@22 1008 backdropcolor = {1, 1, 1, .5},
Tercio@22 1009 backdropbordercolor = {0, 0, 0, 1},
Tercio@22 1010 onentercolor = {1, 1, 1, .5},
Tercio@22 1011 onenterbordercolor = {1, 1, 1, 1},
Tercio@22 1012 }
Tercio@22 1013
Tercio@22 1014 DF.switch_templates = {}
Tercio@22 1015 DF.switch_templates ["OPTIONS_CHECKBOX_TEMPLATE"] = {
Tercio@22 1016 backdrop = {edgeFile = [[Interface\Buttons\WHITE8X8]], edgeSize = 1, bgFile = [[Interface\Tooltips\UI-Tooltip-Background]], tileSize = 64, tile = true},
Tercio@22 1017 backdropcolor = {1, 1, 1, .5},
Tercio@22 1018 backdropbordercolor = {0, 0, 0, 1},
Tercio@22 1019 width = 18,
Tercio@22 1020 height = 18,
Tercio@22 1021 enabled_backdropcolor = {1, 1, 1, .5},
Tercio@22 1022 disabled_backdropcolor = {1, 1, 1, .2},
Tercio@22 1023 onenterbordercolor = {1, 1, 1, 1},
Tercio@22 1024 }
Tercio@22 1025 DF.switch_templates ["OPTIONS_CHECKBOX_BRIGHT_TEMPLATE"] = {
Tercio@22 1026 backdrop = {edgeFile = [[Interface\Buttons\WHITE8X8]], edgeSize = 1, bgFile = [[Interface\Tooltips\UI-Tooltip-Background]], tileSize = 64, tile = true},
Tercio@22 1027 backdropcolor = {1, 1, 1, .5},
Tercio@22 1028 backdropbordercolor = {0, 0, 0, 1},
Tercio@22 1029 width = 18,
Tercio@22 1030 height = 18,
Tercio@22 1031 enabled_backdropcolor = {1, 1, 1, .5},
Tercio@22 1032 disabled_backdropcolor = {1, 1, 1, .5},
Tercio@22 1033 onenterbordercolor = {1, 1, 1, 1},
Tercio@22 1034 }
Tercio@22 1035
Tercio@22 1036 DF.button_templates = {}
Tercio@22 1037 DF.button_templates ["OPTIONS_BUTTON_TEMPLATE"] = {
Tercio@22 1038 backdrop = {edgeFile = [[Interface\Buttons\WHITE8X8]], edgeSize = 1, bgFile = [[Interface\Tooltips\UI-Tooltip-Background]], tileSize = 64, tile = true},
Tercio@22 1039 backdropcolor = {1, 1, 1, .5},
Tercio@22 1040 backdropbordercolor = {0, 0, 0, 1},
Tercio@22 1041 }
Tercio@22 1042
Tercio@22 1043 DF.slider_templates = {}
Tercio@22 1044 DF.slider_templates ["OPTIONS_SLIDER_TEMPLATE"] = {
Tercio@22 1045 backdrop = {edgeFile = [[Interface\Buttons\WHITE8X8]], edgeSize = 1, bgFile = [[Interface\Tooltips\UI-Tooltip-Background]], tileSize = 64, tile = true},
Tercio@22 1046 backdropcolor = {1, 1, 1, .5},
Tercio@22 1047 backdropbordercolor = {0, 0, 0, 1},
Tercio@22 1048 onentercolor = {1, 1, 1, .5},
Tercio@22 1049 onenterbordercolor = {1, 1, 1, 1},
Tercio@22 1050 thumbtexture = [[Interface\Tooltips\UI-Tooltip-Background]],
Tercio@22 1051 thumbwidth = 16,
Tercio@22 1052 thumbheight = 14,
Tercio@22 1053 thumbcolor = {0, 0, 0, 0.5},
Tercio@22 1054 }
Tercio@22 1055
Tercioo@29 1056 function DF:InstallTemplate (widget_type, template_name, template)
Tercioo@29 1057 widget_type = string.lower (widget_type)
Tercioo@29 1058
Tercio@22 1059 local template_table
Tercioo@29 1060 if (widget_type == "font") then
Tercio@22 1061 template_table = DF.font_templates
Tercioo@29 1062 elseif (widget_type == "dropdown") then
Tercio@22 1063 template_table = DF.dropdown_templates
Tercioo@29 1064 elseif (widget_type == "button") then
Tercio@22 1065 template_table = DF.button_templates
Tercioo@29 1066 elseif (widget_type == "switch") then
Tercio@22 1067 template_table = DF.switch_templates
Tercioo@29 1068 elseif (widget_type == "slider") then
Tercioo@29 1069 template_table = DF.slider_templates
Tercioo@29 1070 end
Tercioo@29 1071
Tercioo@29 1072 template_table [template_name] = template
Tercioo@29 1073
Tercioo@29 1074 return template
Tercioo@29 1075 end
Tercioo@29 1076
Tercioo@29 1077 function DF:GetTemplate (widget_type, template_name)
Tercioo@29 1078 widget_type = string.lower (widget_type)
Tercioo@29 1079
Tercioo@29 1080 local template_table
Tercioo@29 1081 if (widget_type == "font") then
Tercioo@29 1082 template_table = DF.font_templates
Tercioo@29 1083 elseif (widget_type == "dropdown") then
Tercioo@29 1084 template_table = DF.dropdown_templates
Tercioo@29 1085 elseif (widget_type == "button") then
Tercioo@29 1086 template_table = DF.button_templates
Tercioo@29 1087 elseif (widget_type == "switch") then
Tercioo@29 1088 template_table = DF.switch_templates
Tercioo@29 1089 elseif (widget_type == "slider") then
Tercio@22 1090 template_table = DF.slider_templates
Tercio@22 1091 end
Tercio@22 1092 return template_table [template_name]
Tercio@22 1093 end
Tercioo@28 1094
Tercioo@28 1095 function DF.GetParentName (frame)
Tercioo@28 1096 local parentName = frame:GetName()
Tercioo@28 1097 if (not parentName) then
Tercioo@28 1098 error ("Details! FrameWork: called $parent but parent was no name.", 2)
Tercioo@28 1099 end
Tercioo@28 1100 return parentName
Tercioo@28 1101 end
Tercio@39 1102
Tercio@39 1103 ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Tercio@39 1104 --> widget scripts and hooks
Tercio@39 1105
Tercio@39 1106 function DF:RunHooksForWidget (event, ...)
Tercio@39 1107 local hooks = self.HookList [event]
Tercio@39 1108
Tercio@39 1109 if (not hooks) then
Tercio@39 1110 print (self.widget:GetName(), "sem hook para", event)
Tercio@39 1111 return
Tercio@39 1112 end
Tercio@39 1113
Tercio@39 1114 for i, func in ipairs (hooks) do
Tercio@39 1115 local success, canInterrupt = pcall (func, ...)
Tercio@39 1116 if (not success) then
Tercio@39 1117 error ("Details! Framework: " .. event .. " hook for " .. self:GetName() .. ": " .. canInterrupt)
Tercio@39 1118 elseif (canInterrupt) then
Tercio@39 1119 return true
Tercio@39 1120 end
Tercio@39 1121 end
Tercio@39 1122 end
Tercio@39 1123
Tercio@39 1124 function DF:SetHook (hookType, func)
Tercio@39 1125 if (self.HookList [hookType]) then
Tercio@39 1126 if (type (func) == "function") then
Tercio@39 1127 local isRemoval = false
Tercio@39 1128 for i = #self.HookList [hookType], 1, -1 do
Tercio@39 1129 if (self.HookList [hookType] [i] == func) then
Tercio@39 1130 tremove (self.HookList [hookType], i)
Tercio@39 1131 isRemoval = true
Tercio@39 1132 break
Tercio@39 1133 end
Tercio@39 1134 end
Tercio@39 1135 if (not isRemoval) then
Tercio@39 1136 tinsert (self.HookList [hookType], func)
Tercio@39 1137 end
Tercio@39 1138 else
Tercio@39 1139 if (DF.debug) then
Tercio@39 1140 error ("Details! Framework: invalid function for widget " .. self.WidgetType .. ".")
Tercio@39 1141 end
Tercio@39 1142 end
Tercio@39 1143 else
Tercio@39 1144 if (DF.debug) then
Tercio@39 1145 error ("Details! Framework: unknown hook type for widget " .. self.WidgetType .. ": '" .. hookType .. "'.")
Tercio@39 1146 end
Tercio@39 1147 end
Tercio@39 1148 end
Tercio@39 1149
Tercio@39 1150 ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Tercio@39 1151 --> members
Tercio@39 1152
Tercio@39 1153 DF.GlobalWidgetControlNames = {
Tercio@39 1154 textentry = "DF_TextEntryMetaFunctions",
Tercio@39 1155 button = "DF_ButtonMetaFunctions",
Tercio@39 1156 panel = "DF_PanelMetaFunctions",
Tercio@39 1157 dropdown = "DF_DropdownMetaFunctions",
Tercio@39 1158 label = "DF_LabelMetaFunctions",
Tercio@39 1159 normal_bar = "DF_NormalBarMetaFunctions",
Tercio@39 1160 image = "DF_ImageMetaFunctions",
Tercio@39 1161 slider = "DF_SliderMetaFunctions",
Tercio@39 1162 split_bar = "DF_SplitBarMetaFunctions",
Tercio@40 1163 aura_tracker = "DF_AuraTracker",
Tercio@39 1164 }
Tercio@39 1165
Tercio@39 1166 function DF:AddMemberForWidget (widgetName, memberType, memberName, func)
Tercio@39 1167 if (DF.GlobalWidgetControlNames [widgetName]) then
Tercio@39 1168 if (type (memberName) == "string" and (memberType == "SET" or memberType == "GET")) then
Tercio@39 1169 if (func) then
Tercio@39 1170 local widgetControlObject = _G [DF.GlobalWidgetControlNames [widgetName]]
Tercio@39 1171
Tercio@39 1172 if (memberType == "SET") then
Tercio@39 1173 widgetControlObject ["SetMembers"] [memberName] = func
Tercio@39 1174 elseif (memberType == "GET") then
Tercio@39 1175 widgetControlObject ["GetMembers"] [memberName] = func
Tercio@39 1176 end
Tercio@39 1177 else
Tercio@39 1178 if (DF.debug) then
Tercio@39 1179 error ("Details! Framework: AddMemberForWidget invalid function.")
Tercio@39 1180 end
Tercio@39 1181 end
Tercio@39 1182 else
Tercio@39 1183 if (DF.debug) then
Tercio@39 1184 error ("Details! Framework: AddMemberForWidget unknown memberName or memberType.")
Tercio@39 1185 end
Tercio@39 1186 end
Tercio@39 1187 else
Tercio@39 1188 if (DF.debug) then
Tercio@39 1189 error ("Details! Framework: AddMemberForWidget unknown widget type: " .. (widgetName or "") .. ".")
Tercio@39 1190 end
Tercio@39 1191 end
Tercio@39 1192 end
Tercio@39 1193
Tercio@39 1194 -----------------------------
Tercio@39 1195
Tercio@39 1196 function DF:OpenInterfaceProfile()
Tercio@39 1197 InterfaceOptionsFrame_OpenToCategory (self.__name)
Tercio@39 1198 InterfaceOptionsFrame_OpenToCategory (self.__name)
Tercio@39 1199 for i = 1, 100 do
Tercio@39 1200 local button = _G ["InterfaceOptionsFrameAddOnsButton" .. i]
Tercio@39 1201 if (button) then
Tercio@39 1202 local text = _G ["InterfaceOptionsFrameAddOnsButton" .. i .. "Text"]
Tercio@39 1203 if (text) then
Tercio@39 1204 text = text:GetText()
Tercio@39 1205 if (text == self.__name) then
Tercio@39 1206 local toggle = _G ["InterfaceOptionsFrameAddOnsButton" .. i .. "Toggle"]
Tercio@39 1207 if (toggle) then
Tercio@39 1208 if (toggle:GetNormalTexture():GetTexture():find ("PlusButton")) then
Tercio@39 1209 --is minimized, need expand
Tercio@39 1210 toggle:Click()
Tercio@39 1211 _G ["InterfaceOptionsFrameAddOnsButton" .. i+1]:Click()
Tercio@39 1212 elseif (toggle:GetNormalTexture():GetTexture():find ("MinusButton")) then
Tercio@39 1213 --isn't minimized
Tercio@39 1214 _G ["InterfaceOptionsFrameAddOnsButton" .. i+1]:Click()
Tercio@39 1215 end
Tercio@39 1216 end
Tercio@39 1217 break
Tercio@39 1218 end
Tercio@39 1219 end
Tercio@39 1220 else
Tercio@39 1221 self:Msg ("Couldn't not find the profile panel.")
Tercio@39 1222 break
Tercio@39 1223 end
Tercio@39 1224 end
Tercio@39 1225 end
Tercio@39 1226
Tercio@39 1227 -----------------------------
Tercio@39 1228 --safe copy from blizz api
Tercio@39 1229 function DF:Mixin (object, ...)
Tercio@39 1230 for i = 1, select("#", ...) do
Tercio@39 1231 local mixin = select(i, ...);
Tercio@39 1232 for k, v in pairs(mixin) do
Tercio@39 1233 object[k] = v;
Tercio@39 1234 end
Tercio@39 1235 end
Tercio@39 1236
Tercio@39 1237 return object;
Tercio@39 1238 end
Tercio@40 1239
Tercio@40 1240 -----------------------------
Tercio@40 1241 --> animations
Tercio@40 1242
Tercio@40 1243 function DF:CreateAnimationHub (parent, onPlay, onFinished)
Tercio@40 1244 local newAnimation = parent:CreateAnimationGroup()
Tercio@40 1245 newAnimation:SetScript ("OnPlay", onPlay)
Tercio@40 1246 newAnimation:SetScript ("OnFinished", onFinished)
Tercio@40 1247 newAnimation.NextAnimation = 1
Tercio@40 1248 return newAnimation
Tercio@40 1249 end
Tercio@40 1250
Tercio@40 1251 function DF:CreateAnimation (animation, type, order, duration, arg1, arg2, arg3, arg4, arg5, arg6, arg7)
Tercio@40 1252 local anim = animation:CreateAnimation (type)
Tercio@40 1253
Tercio@40 1254 anim:SetOrder (order or animation.NextAnimation)
Tercio@40 1255 anim:SetDuration (duration)
Tercio@40 1256
Tercio@40 1257 type = string.upper (type)
Tercio@40 1258
Tercio@40 1259 if (type == "ALPHA") then
Tercio@40 1260 anim:SetFromAlpha (arg1)
Tercio@40 1261 anim:SetToAlpha (arg2)
Tercio@40 1262
Tercio@40 1263 elseif (type == "SCALE") then
Tercio@40 1264 anim:SetFromScale (arg1, arg2)
Tercio@40 1265 anim:SetToScale (arg3, arg4)
Tercio@40 1266 anim:SetOrigin (arg5 or "center", arg6 or 0, arg7 or 0) --point, x, y
Tercio@40 1267
Tercio@40 1268 elseif (type == "ROTATION") then
Tercio@40 1269 anim:SetDegrees (arg1) --degree
Tercio@40 1270 anim:SetOrigin (arg2 or "center", arg3 or 0, arg4 or 0) --point, x, y
Tercio@40 1271
Tercio@40 1272 elseif (type == "TRANSLATION") then
Tercio@40 1273 anim:SetOffset (arg1, arg2)
Tercio@40 1274
Tercio@40 1275 end
Tercio@40 1276
Tercio@40 1277 animation.NextAnimation = animation.NextAnimation + 1
Tercio@40 1278 return anim
Tercio@40 1279 end
Tercio@40 1280
Tercio@40 1281
Tercio@40 1282 -----------------------------
Tercio@40 1283 --> borders
Tercio@40 1284
Tercio@40 1285 local default_border_color1 = .5
Tercio@40 1286 local default_border_color2 = .3
Tercio@40 1287 local default_border_color3 = .1
Tercio@40 1288
Tercio@40 1289 local SetBorderAlpha = function (self, alpha1, alpha2, alpha3)
Tercio@40 1290 self.Borders.Alpha1 = alpha1 or self.Borders.Alpha1
Tercio@40 1291 self.Borders.Alpha2 = alpha2 or self.Borders.Alpha2
Tercio@40 1292 self.Borders.Alpha3 = alpha3 or self.Borders.Alpha3
Tercio@40 1293
Tercio@40 1294 for _, texture in ipairs (self.Borders.Layer1) do
Tercio@40 1295 texture:SetAlpha (self.Borders.Alpha1)
Tercio@40 1296 end
Tercio@40 1297 for _, texture in ipairs (self.Borders.Layer2) do
Tercio@40 1298 texture:SetAlpha (self.Borders.Alpha2)
Tercio@40 1299 end
Tercio@40 1300 for _, texture in ipairs (self.Borders.Layer3) do
Tercio@40 1301 texture:SetAlpha (self.Borders.Alpha3)
Tercio@40 1302 end
Tercio@40 1303 end
Tercio@40 1304
Tercio@40 1305 function DF:CreateBorder (parent, alpha1, alpha2, alpha3)
Tercio@40 1306
Tercio@40 1307 parent.Borders = {
Tercio@40 1308 Layer1 = {},
Tercio@40 1309 Layer2 = {},
Tercio@40 1310 Layer3 = {},
Tercio@40 1311 Alpha1 = alpha1 or default_border_color1,
Tercio@40 1312 Alpha2 = alpha2 or default_border_color2,
Tercio@40 1313 Alpha3 = alpha3 or default_border_color3,
Tercio@40 1314 }
Tercio@40 1315
Tercio@40 1316 parent.SetBorderAlpha = SetBorderAlpha
Tercio@40 1317
Tercio@40 1318 local border1 = parent:CreateTexture (nil, "background")
Tercio@40 1319 border1:SetPoint ("topleft", parent, "topleft", -1, 1)
Tercio@40 1320 border1:SetPoint ("bottomleft", parent, "bottomleft", -1, -1)
Tercio@40 1321 border1:SetColorTexture (0, 0, 0, alpha1 or default_border_color1)
Tercio@40 1322 local border2 = parent:CreateTexture (nil, "background")
Tercio@40 1323 border2:SetPoint ("topleft", parent, "topleft", -2, 2)
Tercio@40 1324 border2:SetPoint ("bottomleft", parent, "bottomleft", -2, -2)
Tercio@40 1325 border2:SetColorTexture (0, 0, 0, alpha2 or default_border_color2)
Tercio@40 1326 local border3 = parent:CreateTexture (nil, "background")
Tercio@40 1327 border3:SetPoint ("topleft", parent, "topleft", -3, 3)
Tercio@40 1328 border3:SetPoint ("bottomleft", parent, "bottomleft", -3, -3)
Tercio@40 1329 border3:SetColorTexture (0, 0, 0, alpha3 or default_border_color3)
Tercio@40 1330
Tercio@40 1331 tinsert (parent.Borders.Layer1, border1)
Tercio@40 1332 tinsert (parent.Borders.Layer2, border2)
Tercio@40 1333 tinsert (parent.Borders.Layer3, border3)
Tercio@40 1334
Tercio@40 1335 local border1 = parent:CreateTexture (nil, "background")
Tercio@40 1336 border1:SetPoint ("topleft", parent, "topleft", 0, 1)
Tercio@40 1337 border1:SetPoint ("topright", parent, "topright", 1, 1)
Tercio@40 1338 border1:SetColorTexture (0, 0, 0, alpha1 or default_border_color1)
Tercio@40 1339 local border2 = parent:CreateTexture (nil, "background")
Tercio@40 1340 border2:SetPoint ("topleft", parent, "topleft", -1, 2)
Tercio@40 1341 border2:SetPoint ("topright", parent, "topright", 2, 2)
Tercio@40 1342 border2:SetColorTexture (0, 0, 0, alpha2 or default_border_color2)
Tercio@40 1343 local border3 = parent:CreateTexture (nil, "background")
Tercio@40 1344 border3:SetPoint ("topleft", parent, "topleft", -2, 3)
Tercio@40 1345 border3:SetPoint ("topright", parent, "topright", 3, 3)
Tercio@40 1346 border3:SetColorTexture (0, 0, 0, alpha3 or default_border_color3)
Tercio@40 1347
Tercio@40 1348 tinsert (parent.Borders.Layer1, border1)
Tercio@40 1349 tinsert (parent.Borders.Layer2, border2)
Tercio@40 1350 tinsert (parent.Borders.Layer3, border3)
Tercio@40 1351
Tercio@40 1352 local border1 = parent:CreateTexture (nil, "background")
Tercio@40 1353 border1:SetPoint ("topright", parent, "topright", 1, 0)
Tercio@40 1354 border1:SetPoint ("bottomright", parent, "bottomright", 1, -1)
Tercio@40 1355 border1:SetColorTexture (0, 0, 0, alpha1 or default_border_color1)
Tercio@40 1356 local border2 = parent:CreateTexture (nil, "background")
Tercio@40 1357 border2:SetPoint ("topright", parent, "topright", 2, 1)
Tercio@40 1358 border2:SetPoint ("bottomright", parent, "bottomright", 2, -2)
Tercio@40 1359 border2:SetColorTexture (0, 0, 0, alpha2 or default_border_color2)
Tercio@40 1360 local border3 = parent:CreateTexture (nil, "background")
Tercio@40 1361 border3:SetPoint ("topright", parent, "topright", 3, 2)
Tercio@40 1362 border3:SetPoint ("bottomright", parent, "bottomright", 3, -3)
Tercio@40 1363 border3:SetColorTexture (0, 0, 0, alpha3 or default_border_color3)
Tercio@40 1364
Tercio@40 1365 tinsert (parent.Borders.Layer1, border1)
Tercio@40 1366 tinsert (parent.Borders.Layer2, border2)
Tercio@40 1367 tinsert (parent.Borders.Layer3, border3)
Tercio@40 1368
Tercio@40 1369 local border1 = parent:CreateTexture (nil, "background")
Tercio@40 1370 border1:SetPoint ("bottomleft", parent, "bottomleft", 0, -1)
Tercio@40 1371 border1:SetPoint ("bottomright", parent, "bottomright", 0, -1)
Tercio@40 1372 border1:SetColorTexture (0, 0, 0, alpha1 or default_border_color1)
Tercio@40 1373 local border2 = parent:CreateTexture (nil, "background")
Tercio@40 1374 border2:SetPoint ("bottomleft", parent, "bottomleft", -1, -2)
Tercio@40 1375 border2:SetPoint ("bottomright", parent, "bottomright", 1, -2)
Tercio@40 1376 border2:SetColorTexture (0, 0, 0, alpha2 or default_border_color2)
Tercio@40 1377 local border3 = parent:CreateTexture (nil, "background")
Tercio@40 1378 border3:SetPoint ("bottomleft", parent, "bottomleft", -2, -3)
Tercio@40 1379 border3:SetPoint ("bottomright", parent, "bottomright", 2, -3)
Tercio@40 1380 border3:SetColorTexture (0, 0, 0, alpha3 or default_border_color3)
Tercio@40 1381
Tercio@40 1382 tinsert (parent.Borders.Layer1, border1)
Tercio@40 1383 tinsert (parent.Borders.Layer2, border2)
Tercio@40 1384 tinsert (parent.Borders.Layer3, border3)
Tercio@40 1385
Tercio@40 1386 end
Tercio@40 1387
Tercio@40 1388 function DF:ReskinSlider (slider, heightOffset)
Tercio@40 1389 if (slider.slider) then
Tercio@40 1390 slider.cima:SetNormalTexture ([[Interface\Buttons\Arrow-Up-Up]])
Tercio@40 1391 slider.cima:SetPushedTexture ([[Interface\Buttons\Arrow-Up-Down]])
Tercio@40 1392 slider.cima:SetDisabledTexture ([[Interface\Buttons\Arrow-Up-Disabled]])
Tercio@40 1393 slider.cima:GetNormalTexture():ClearAllPoints()
Tercio@40 1394 slider.cima:GetPushedTexture():ClearAllPoints()
Tercio@40 1395 slider.cima:GetDisabledTexture():ClearAllPoints()
Tercio@40 1396 slider.cima:GetNormalTexture():SetPoint ("center", slider.cima, "center", 1, 1)
Tercio@40 1397 slider.cima:GetPushedTexture():SetPoint ("center", slider.cima, "center", 1, 1)
Tercio@40 1398 slider.cima:GetDisabledTexture():SetPoint ("center", slider.cima, "center", 1, 1)
Tercio@40 1399 slider.cima:SetSize (16, 16)
Tercio@40 1400 slider.cima:SetBackdrop ({edgeFile = [[Interface\Buttons\WHITE8X8]], edgeSize = 1, bgFile = [[Interface\AddOns\Details\images\background]]})
Tercio@40 1401 slider.cima:SetBackdropColor (0, 0, 0, 0.3)
Tercio@40 1402 slider.cima:SetBackdropBorderColor (0, 0, 0, 1)
Tercio@40 1403
Tercio@40 1404 slider.baixo:SetNormalTexture ([[Interface\Buttons\Arrow-Down-Up]])
Tercio@40 1405 slider.baixo:SetPushedTexture ([[Interface\Buttons\Arrow-Down-Down]])
Tercio@40 1406 slider.baixo:SetDisabledTexture ([[Interface\Buttons\Arrow-Down-Disabled]])
Tercio@40 1407 slider.baixo:GetNormalTexture():ClearAllPoints()
Tercio@40 1408 slider.baixo:GetPushedTexture():ClearAllPoints()
Tercio@40 1409 slider.baixo:GetDisabledTexture():ClearAllPoints()
Tercio@40 1410 slider.baixo:GetNormalTexture():SetPoint ("center", slider.baixo, "center", 1, -5)
Tercio@40 1411 slider.baixo:GetPushedTexture():SetPoint ("center", slider.baixo, "center", 1, -5)
Tercio@40 1412 slider.baixo:GetDisabledTexture():SetPoint ("center", slider.baixo, "center", 1, -5)
Tercio@40 1413 slider.baixo:SetSize (16, 16)
Tercio@40 1414 slider.baixo:SetBackdrop ({edgeFile = [[Interface\Buttons\WHITE8X8]], edgeSize = 1, bgFile = [[Interface\AddOns\Details\images\background]]})
Tercio@40 1415 slider.baixo:SetBackdropColor (0, 0, 0, 0.35)
Tercio@40 1416 slider.baixo:SetBackdropBorderColor (0, 0, 0, 1)
Tercio@40 1417
Tercio@40 1418 slider.slider:SetBackdrop ({edgeFile = [[Interface\Buttons\WHITE8X8]], edgeSize = 1, bgFile = [[Interface\AddOns\Details\images\background]]})
Tercio@40 1419 slider.slider:SetBackdropColor (0, 0, 0, 0.35)
Tercio@40 1420 slider.slider:SetBackdropBorderColor (0, 0, 0, 1)
Tercio@40 1421
Tercio@40 1422 --slider.slider:Altura (164)
Tercio@40 1423 slider.slider:cimaPoint (0, 13)
Tercio@40 1424 slider.slider:baixoPoint (0, -13)
Tercio@40 1425 slider.slider.thumb:SetTexture ([[Interface\AddOns\Details\images\icons2]])
Tercio@40 1426 slider.slider.thumb:SetTexCoord (482/512, 492/512, 104/512, 120/512)
Tercio@40 1427 slider.slider.thumb:SetSize (12, 12)
Tercio@40 1428 slider.slider.thumb:SetVertexColor (0.6, 0.6, 0.6, 0.95)
Tercio@40 1429 else
Tercio@40 1430
Tercio@40 1431 slider.ScrollBar.ScrollUpButton:SetNormalTexture ([[Interface\Buttons\Arrow-Up-Up]])
Tercio@40 1432 slider.ScrollBar.ScrollUpButton:GetNormalTexture():SetTexCoord (0, 1, 0, 1)
Tercio@40 1433 slider.ScrollBar.ScrollUpButton:SetPushedTexture ([[Interface\Buttons\Arrow-Up-Down]])
Tercio@40 1434 slider.ScrollBar.ScrollUpButton:GetPushedTexture():SetTexCoord (0, 1, 0, 1)
Tercio@40 1435 slider.ScrollBar.ScrollUpButton:SetDisabledTexture ([[Interface\Buttons\Arrow-Up-Disabled]])
Tercio@40 1436 slider.ScrollBar.ScrollUpButton:GetDisabledTexture():SetTexCoord (0, 1, 0, 1)
Tercio@40 1437
Tercio@40 1438 slider.ScrollBar.ScrollUpButton:SetSize (16, 16)
Tercio@40 1439 slider.ScrollBar.ScrollUpButton:SetBackdrop ({edgeFile = [[Interface\Buttons\WHITE8X8]], edgeSize = 1, bgFile = "Interface\\Tooltips\\UI-Tooltip-Background"})
Tercio@40 1440 slider.ScrollBar.ScrollUpButton:SetBackdropColor (0, 0, 0, 0.3)
Tercio@40 1441 slider.ScrollBar.ScrollUpButton:SetBackdropBorderColor (0, 0, 0, 1)
Tercio@40 1442
Tercio@40 1443 slider.ScrollBar.ScrollUpButton:GetNormalTexture():ClearAllPoints()
Tercio@40 1444 slider.ScrollBar.ScrollUpButton:GetPushedTexture():ClearAllPoints()
Tercio@40 1445 slider.ScrollBar.ScrollUpButton:GetDisabledTexture():ClearAllPoints()
Tercio@40 1446 slider.ScrollBar.ScrollUpButton:GetNormalTexture():SetPoint ("center", slider.ScrollBar.ScrollUpButton, "center", 1, 1)
Tercio@40 1447 slider.ScrollBar.ScrollUpButton:GetPushedTexture():SetPoint ("center", slider.ScrollBar.ScrollUpButton, "center", 1, 1)
Tercio@40 1448 slider.ScrollBar.ScrollUpButton:GetDisabledTexture():SetPoint ("center", slider.ScrollBar.ScrollUpButton, "center", 1, 1)
Tercio@40 1449
Tercio@40 1450 --
Tercio@40 1451
Tercio@40 1452 slider.ScrollBar.ScrollDownButton:SetNormalTexture ([[Interface\Buttons\Arrow-Down-Up]])
Tercio@40 1453 slider.ScrollBar.ScrollDownButton:GetNormalTexture():SetTexCoord (0, 1, 0, 1)
Tercio@40 1454 slider.ScrollBar.ScrollDownButton:SetPushedTexture ([[Interface\Buttons\Arrow-Down-Down]])
Tercio@40 1455 slider.ScrollBar.ScrollDownButton:GetPushedTexture():SetTexCoord (0, 1, 0, 1)
Tercio@40 1456 slider.ScrollBar.ScrollDownButton:SetDisabledTexture ([[Interface\Buttons\Arrow-Down-Disabled]])
Tercio@40 1457 slider.ScrollBar.ScrollDownButton:GetDisabledTexture():SetTexCoord (0, 1, 0, 1)
Tercio@40 1458
Tercio@40 1459 slider.ScrollBar.ScrollDownButton:SetSize (16, 16)
Tercio@40 1460 slider.ScrollBar.ScrollDownButton:SetBackdrop ({edgeFile = [[Interface\Buttons\WHITE8X8]], edgeSize = 1, bgFile = "Interface\\Tooltips\\UI-Tooltip-Background"})
Tercio@40 1461 slider.ScrollBar.ScrollDownButton:SetBackdropColor (0, 0, 0, 0.3)
Tercio@40 1462 slider.ScrollBar.ScrollDownButton:SetBackdropBorderColor (0, 0, 0, 1)
Tercio@40 1463
Tercio@40 1464 slider.ScrollBar.ScrollDownButton:GetNormalTexture():ClearAllPoints()
Tercio@40 1465 slider.ScrollBar.ScrollDownButton:GetPushedTexture():ClearAllPoints()
Tercio@40 1466 slider.ScrollBar.ScrollDownButton:GetDisabledTexture():ClearAllPoints()
Tercio@40 1467 slider.ScrollBar.ScrollDownButton:GetNormalTexture():SetPoint ("center", slider.ScrollBar.ScrollDownButton, "center", 1, -5)
Tercio@40 1468 slider.ScrollBar.ScrollDownButton:GetPushedTexture():SetPoint ("center", slider.ScrollBar.ScrollDownButton, "center", 1, -5)
Tercio@40 1469 slider.ScrollBar.ScrollDownButton:GetDisabledTexture():SetPoint ("center", slider.ScrollBar.ScrollDownButton, "center", 1, -5)
Tercio@40 1470
Tercio@40 1471 --
Tercio@40 1472 slider.ScrollBar:SetPoint ("TOPLEFT", slider, "TOPRIGHT", 6, -16)
Tercio@40 1473 slider.ScrollBar:SetPoint ("BOTTOMLEFT", slider, "BOTTOMRIGHT", 6, 16 + (heightOffset and heightOffset*-1 or 0))
Tercio@40 1474
Tercio@40 1475 slider.ScrollBar.ThumbTexture:SetColorTexture (.5, .5, .5, .3)
Tercio@40 1476 slider.ScrollBar.ThumbTexture:SetSize (12, 8)
Tercio@40 1477
Tercio@40 1478 --
Tercio@40 1479
Tercio@40 1480 slider.ScrollBar:SetBackdrop ({edgeFile = [[Interface\Buttons\WHITE8X8]], edgeSize = 1, bgFile = "Interface\\Tooltips\\UI-Tooltip-Background"})
Tercio@40 1481 slider.ScrollBar:SetBackdropColor (0, 0, 0, 0.35)
Tercio@40 1482 slider.ScrollBar:SetBackdropBorderColor (0, 0, 0, 1)
Tercio@40 1483 end
Tercio@40 1484 end
Tercio@40 1485
Tercio@40 1486 --doo elsee