annotate Libs/DF/fw.lua @ 47:ed3decee0d5d r47-release

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