annotate Libs/DF/fw.lua @ 53:36b4d9559b69 v7.3.0.053

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