annotate Libs/DF/fw.lua @ 25:6bb668a41455

- framework update.
author Tercio
date Thu, 08 Oct 2015 11:52:43 -0300
parents 7a285d98b95f
children e16b1fc13935
rev   line source
Tercio@11 1
Tercio@25 2 local dversion = 10
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
Tercio@11 14 local _type = type
Tercio@11 15 local _unpack = unpack
Tercio@11 16 local _
Tercio@11 17 local upper = string.upper
Tercio@11 18
Tercio@11 19 DF.LabelNameCounter = 1
Tercio@11 20 DF.PictureNameCounter = 1
Tercio@11 21 DF.BarNameCounter = 1
Tercio@11 22 DF.DropDownCounter = 1
Tercio@11 23 DF.PanelCounter = 1
Tercio@11 24 DF.ButtonCounter = 1
Tercio@11 25 DF.SliderCounter = 1
Tercio@11 26 DF.SplitBarCounter = 1
Tercio@11 27
Tercio@25 28 DF.FrameWorkVersion = tostring (dversion)
Tercio@25 29 function DF:PrintVersion()
Tercio@25 30 print ("Details! Framework Version:", DF.FrameWorkVersion)
Tercio@25 31 end
Tercio@25 32
Tercio@22 33 LibStub:GetLibrary("AceTimer-3.0"):Embed (DF)
Tercio@22 34
Tercio@11 35 do
Tercio@11 36 local path = string.match (debugstack (1, 1, 0), "AddOns\\(.+)fw.lua")
Tercio@11 37 if (path) then
Tercio@11 38 DF.folder = "Interface\\AddOns\\" .. path
Tercio@11 39 else
Tercio@11 40 DF.folder = ""
Tercio@11 41 end
Tercio@11 42 end
Tercio@11 43
Tercio@11 44 DF.debug = false
Tercio@11 45
Tercio@11 46 _G ["DetailsFramework"] = DF
Tercio@11 47
Tercio@11 48 DF.embeds = DF.embeds or {}
Tercio@11 49 local embed_functions = {
Tercio@20 50 "RemoveRealName",
Tercio@20 51 "table",
Tercio@20 52 "BuildDropDownFontList",
Tercio@11 53 "SetFontSize",
Tercio@11 54 "SetFontFace",
Tercio@11 55 "SetFontColor",
Tercio@11 56 "GetFontSize",
Tercio@11 57 "GetFontFace",
Tercio@17 58 "SetFontOutline",
Tercio@11 59 "trim",
Tercio@11 60 "Msg",
Tercio@11 61 "CreateFlashAnimation",
Tercio@11 62 "Fade",
Tercio@11 63 "NewColor",
Tercio@11 64 "IsHtmlColor",
Tercio@11 65 "ParseColors",
Tercio@11 66 "BuildMenu",
Tercio@11 67 "ShowTutorialAlertFrame",
Tercio@11 68 "GetNpcIdFromGuid",
Tercio@11 69 "ShowFeedbackPanel",
Tercio@20 70 "SetAsOptionsPanel",
Tercio@11 71
Tercio@11 72 "CreateDropDown",
Tercio@11 73 "CreateButton",
Tercio@11 74 "CreateColorPickButton",
Tercio@11 75 "CreateLabel",
Tercio@11 76 "CreateBar",
Tercio@11 77 "CreatePanel",
Tercio@11 78 "CreateFillPanel",
Tercio@11 79 "ColorPick",
Tercio@11 80 "IconPick",
Tercio@11 81 "CreateSimplePanel",
Tercio@11 82 "CreateChartPanel",
Tercio@11 83 "CreateImage",
Tercio@11 84 "CreateScrollBar",
Tercio@11 85 "CreateSwitch",
Tercio@11 86 "CreateSlider",
Tercio@11 87 "CreateSplitBar",
Tercio@11 88 "CreateTextEntry",
Tercio@11 89 "Create1PxPanel",
Tercio@11 90 "CreateFeedbackButton",
Tercio@20 91 "CreateOptionsFrame",
Tercio@22 92 "NewSpecialLuaEditorEntry",
Tercio@20 93 "ShowPromptPanel",
Tercio@22 94 "ShowTextPromptPanel",
Tercio@11 95 "www_icons",
Tercio@22 96 "GetTemplate",
Tercio@22 97 "GetFrameworkFolder",
Tercio@11 98 }
Tercio@11 99
Tercio@20 100 DF.table = {}
Tercio@20 101
Tercio@22 102 function DF:GetFrameworkFolder()
Tercio@22 103 return DF.folder
Tercio@22 104 end
Tercio@22 105
Tercio@20 106 function DF.table.reverse (t)
Tercio@20 107 local new = {}
Tercio@20 108 local index = 1
Tercio@20 109 for i = #t, 1, -1 do
Tercio@20 110 new [index] = t[i]
Tercio@20 111 index = index + 1
Tercio@20 112 end
Tercio@20 113 return new
Tercio@20 114 end
Tercio@20 115
Tercio@20 116 --> copy from table2 to table1 overwriting values
Tercio@20 117 function DF.table.copy (t1, t2)
Tercio@20 118 for key, value in pairs (t2) do
Tercio@20 119 if (type (value) == "table") then
Tercio@20 120 t1 [key] = t1 [key] or {}
Tercio@20 121 DF.table.copy (t1 [key], t2 [key])
Tercio@20 122 else
Tercio@20 123 t1 [key] = value
Tercio@20 124 end
Tercio@20 125 end
Tercio@20 126 return t1
Tercio@20 127 end
Tercio@20 128
Tercio@20 129 --> copy values that does exist on table2 but not on table1
Tercio@20 130 function DF.table.deploy (t1, t2)
Tercio@20 131 for key, value in pairs (t2) do
Tercio@20 132 if (type (value) == "table") then
Tercio@20 133 t1 [key] = t1 [key] or {}
Tercio@20 134 DF.table.deploy (t1 [key], t2 [key])
Tercio@22 135 elseif (t1 [key] == nil) then
Tercio@20 136 t1 [key] = value
Tercio@20 137 end
Tercio@20 138 end
Tercio@20 139 end
Tercio@20 140
Tercio@20 141 function DF.table.dump (t, s, deep)
Tercio@20 142 s = s or ""
Tercio@20 143 deep = deep or 0
Tercio@20 144 local space = ""
Tercio@20 145 for i = 1, deep do
Tercio@20 146 space = space .. " "
Tercio@20 147 end
Tercio@20 148 for key, value in pairs (t) do
Tercio@20 149 local tpe = _type (value)
Tercio@20 150 if (type (key) ~= "string") then
Tercio@20 151 key = "unknown?"
Tercio@20 152 end
Tercio@20 153 if (tpe == "table") then
Tercio@20 154 s = s .. space .. "[" .. key .. "] = |cFFa9ffa9table {|r\n"
Tercio@20 155 s = s .. DF.table.dump (value, nil, deep+1)
Tercio@20 156 s = s .. space .. "|cFFa9ffa9}|r\n"
Tercio@20 157 elseif (tpe == "string") then
Tercio@20 158 s = s .. space .. "[" .. key .. "] = '|cFFfff1c1" .. value .. "|r'\n"
Tercio@20 159 elseif (tpe == "number") then
Tercio@20 160 s = s .. space .. "[" .. key .. "] = |cFFffc1f4" .. value .. "|r\n"
Tercio@20 161 elseif (tpe == "function") then
Tercio@20 162 s = s .. space .. "[" .. key .. "] = function()\n"
Tercio@20 163 elseif (tpe == "boolean") then
Tercio@20 164 s = s .. space .. "[" .. key .. "] = |cFF99d0ff" .. (value and "true" or "false") .. "|r\n"
Tercio@20 165 end
Tercio@20 166 end
Tercio@20 167 return s
Tercio@20 168 end
Tercio@20 169
Tercio@11 170 DF.www_icons = {
Tercio@11 171 texture = "feedback_sites",
Tercio@11 172 wowi = {0, 0.7890625, 0, 37/128},
Tercio@11 173 curse = {0, 0.7890625, 38/123, 79/128},
Tercio@11 174 mmoc = {0, 0.7890625, 80/123, 123/128},
Tercio@11 175 }
Tercio@11 176
Tercio@24 177 function DF:IntegerToTimer (value)
Tercio@24 178 return "" .. floor (value/60) .. ":" .. format ("%02.f", value%60)
Tercio@24 179 end
Tercio@24 180
Tercio@11 181 function DF:Embed (target)
Tercio@11 182 for k, v in pairs (embed_functions) do
Tercio@11 183 target[v] = self[v]
Tercio@11 184 end
Tercio@11 185 self.embeds [target] = true
Tercio@11 186 return target
Tercio@11 187 end
Tercio@11 188
Tercio@20 189 function DF:RemoveRealName (name)
Tercio@20 190 return name:gsub (("%-.*"), "")
Tercio@20 191 end
Tercio@20 192
Tercio@11 193 function DF:SetFontSize (fontString, ...)
Tercio@11 194 local fonte, _, flags = fontString:GetFont()
Tercio@11 195 fontString:SetFont (fonte, max (...), flags)
Tercio@11 196 end
Tercio@11 197 function DF:SetFontFace (fontString, fontface)
Tercio@25 198 local font = SharedMedia:Fetch ("font", fontface, true)
Tercio@25 199 if (font) then
Tercio@25 200 fontface = font
Tercio@25 201 end
Tercio@25 202
Tercio@11 203 local _, size, flags = fontString:GetFont()
Tercio@11 204 fontString:SetFont (fontface, size, flags)
Tercio@11 205 end
Tercio@11 206 function DF:SetFontColor (fontString, r, g, b, a)
Tercio@11 207 r, g, b, a = DF:ParseColors (r, g, b, a)
Tercio@11 208 fontString:SetTextColor (r, g, b, a)
Tercio@11 209 end
Tercio@11 210
Tercio@11 211 function DF:GetFontSize (fontString)
Tercio@11 212 local _, size = fontString:GetFont()
Tercio@11 213 return size
Tercio@11 214 end
Tercio@11 215 function DF:GetFontFace (fontString)
Tercio@11 216 local fontface = fontString:GetFont()
Tercio@11 217 return fontface
Tercio@11 218 end
Tercio@11 219
Tercio@11 220 function DF:SetFontOutline (fontString, outline)
Tercio@11 221 local fonte, size = fontString:GetFont()
Tercio@11 222 if (outline) then
Tercio@11 223 if (_type (outline) == "boolean" and outline) then
Tercio@11 224 outline = "OUTLINE"
Tercio@11 225 elseif (outline == 1) then
Tercio@11 226 outline = "OUTLINE"
Tercio@11 227 elseif (outline == 2) then
Tercio@11 228 outline = "THICKOUTLINE"
Tercio@11 229 end
Tercio@11 230 end
Tercio@11 231
Tercio@11 232 fontString:SetFont (fonte, size, outline)
Tercio@11 233 end
Tercio@11 234
Tercio@11 235 function DF:trim (s)
Tercio@11 236 local from = s:match"^%s*()"
Tercio@11 237 return from > #s and "" or s:match(".*%S", from)
Tercio@11 238 end
Tercio@11 239
Tercio@11 240 function DF:Msg (msg)
Tercio@11 241 print ("|cFFFFFFAA" .. self.__name .. "|r " .. msg)
Tercio@11 242 end
Tercio@11 243
Tercio@11 244 function DF:GetNpcIdFromGuid (guid)
Tercio@11 245 local NpcId = select ( 6, strsplit ( "-", guid ) )
Tercio@11 246 if (NpcId) then
Tercio@11 247 return tonumber ( NpcId )
Tercio@11 248 end
Tercio@11 249 return 0
Tercio@11 250 end
Tercio@11 251
Tercio@11 252 local onFinish = function (self)
Tercio@11 253 if (self.showWhenDone) then
Tercio@11 254 self.frame:SetAlpha (1)
Tercio@11 255 else
Tercio@11 256 self.frame:SetAlpha (0)
Tercio@11 257 self.frame:Hide()
Tercio@11 258 end
Tercio@11 259
Tercio@11 260 if (self.onFinishFunc) then
Tercio@11 261 self:onFinishFunc (self.frame)
Tercio@11 262 end
Tercio@11 263 end
Tercio@11 264
Tercio@11 265 local stop = function (self)
Tercio@11 266 local FlashAnimation = self.FlashAnimation
Tercio@11 267 FlashAnimation:Stop()
Tercio@11 268 end
Tercio@11 269
Tercio@11 270 local flash = function (self, fadeInTime, fadeOutTime, flashDuration, showWhenDone, flashInHoldTime, flashOutHoldTime, loopType)
Tercio@11 271
Tercio@11 272 local FlashAnimation = self.FlashAnimation
Tercio@11 273
Tercio@11 274 local fadeIn = FlashAnimation.fadeIn
Tercio@11 275 local fadeOut = FlashAnimation.fadeOut
Tercio@11 276
Tercio@11 277 fadeIn:Stop()
Tercio@11 278 fadeOut:Stop()
Tercio@11 279
Tercio@11 280 fadeIn:SetDuration (fadeInTime or 1)
Tercio@11 281 fadeIn:SetEndDelay (flashInHoldTime or 0)
Tercio@11 282
Tercio@11 283 fadeOut:SetDuration (fadeOutTime or 1)
Tercio@11 284 fadeOut:SetEndDelay (flashOutHoldTime or 0)
Tercio@11 285
Tercio@11 286 FlashAnimation.duration = flashDuration
Tercio@11 287 FlashAnimation.loopTime = FlashAnimation:GetDuration()
Tercio@11 288 FlashAnimation.finishAt = GetTime() + flashDuration
Tercio@11 289 FlashAnimation.showWhenDone = showWhenDone
Tercio@11 290
Tercio@11 291 FlashAnimation:SetLooping (loopType or "REPEAT")
Tercio@11 292
Tercio@11 293 self:Show()
Tercio@11 294 self:SetAlpha (0)
Tercio@11 295 FlashAnimation:Play()
Tercio@11 296 end
Tercio@11 297
Tercio@11 298 function DF:CreateFlashAnimation (frame, onFinishFunc, onLoopFunc)
Tercio@11 299 local FlashAnimation = frame:CreateAnimationGroup()
Tercio@11 300
Tercio@11 301 FlashAnimation.fadeOut = FlashAnimation:CreateAnimation ("Alpha") --> fade out anime
Tercio@11 302 FlashAnimation.fadeOut:SetOrder (1)
Tercio@11 303 FlashAnimation.fadeOut:SetChange (1)
Tercio@11 304
Tercio@11 305 FlashAnimation.fadeIn = FlashAnimation:CreateAnimation ("Alpha") --> fade in anime
Tercio@11 306 FlashAnimation.fadeIn:SetOrder (2)
Tercio@11 307 FlashAnimation.fadeIn:SetChange (-1)
Tercio@11 308
Tercio@11 309 frame.FlashAnimation = FlashAnimation
Tercio@11 310 FlashAnimation.frame = frame
Tercio@11 311 FlashAnimation.onFinishFunc = onFinishFunc
Tercio@11 312
Tercio@11 313 FlashAnimation:SetScript ("OnLoop", onLoopFunc)
Tercio@11 314 FlashAnimation:SetScript ("OnFinished", onFinish)
Tercio@11 315
Tercio@11 316 frame.Flash = flash
Tercio@11 317 frame.Stop = stop
Tercio@11 318 end
Tercio@11 319
Tercio@11 320 -----------------------------------------
Tercio@11 321
Tercio@11 322 local fade_IN_finished_func = function (frame)
Tercio@11 323 if (frame.fading_in) then
Tercio@11 324 frame.hidden = true
Tercio@11 325 frame.faded = true
Tercio@11 326 frame.fading_in = false
Tercio@11 327 frame:Hide()
Tercio@11 328 end
Tercio@11 329 end
Tercio@11 330
Tercio@11 331 local fade_OUT_finished_func = function (frame)
Tercio@11 332 if (frame:IsShown() and frame.fading_out) then
Tercio@11 333 frame.hidden = false
Tercio@11 334 frame.faded = false
Tercio@11 335 frame.fading_out = false
Tercio@11 336 else
Tercio@11 337 frame:SetAlpha(0)
Tercio@11 338 end
Tercio@11 339 end
Tercio@11 340
Tercio@11 341 local just_fade_func = function (frame)
Tercio@11 342 frame.hidden = false
Tercio@11 343 frame.faded = true
Tercio@11 344 frame.fading_in = false
Tercio@11 345 end
Tercio@11 346
Tercio@11 347 local anim_OUT_alpha_func = function (frame)
Tercio@11 348 frame.fading_out = false
Tercio@11 349 end
Tercio@11 350
Tercio@11 351 local anim_IN_alpha_func = function (frame)
Tercio@11 352 frame.fading_in = false
Tercio@11 353 end
Tercio@11 354
Tercio@11 355 function DF:Fade (frame, tipo, velocidade, parametros)
Tercio@11 356
Tercio@11 357 if (_type (frame) == "table") then
Tercio@11 358 if (frame.dframework) then
Tercio@11 359 frame = frame.widget
Tercio@11 360 end
Tercio@11 361 end
Tercio@11 362
Tercio@11 363 velocidade = velocidade or 0.3
Tercio@11 364
Tercio@11 365 if (upper (tipo) == "IN") then
Tercio@11 366
Tercio@11 367 if (frame:GetAlpha() == 0 and frame.hidden and not frame.fading_out) then --> ja esta escondida
Tercio@11 368 return
Tercio@11 369 elseif (frame.fading_in) then --> ja esta com uma animação, se for true
Tercio@11 370 return
Tercio@11 371 end
Tercio@11 372
Tercio@11 373 if (frame.fading_out) then --> se tiver uma animação de aparecer em andamento se for true
Tercio@11 374 frame.fading_out = false
Tercio@11 375 end
Tercio@11 376
Tercio@11 377 UIFrameFadeIn (frame, velocidade, frame:GetAlpha(), 0)
Tercio@11 378 frame.fading_in = true
Tercio@11 379
Tercio@11 380 frame.fadeInfo.finishedFunc = fade_IN_finished_func
Tercio@11 381 frame.fadeInfo.finishedArg1 = frame
Tercio@11 382
Tercio@11 383 elseif (upper (tipo) == "OUT") then --> aparecer
Tercio@11 384 if (frame:GetAlpha() == 1 and not frame.hidden and not frame.fading_in) then --> ja esta na tela
Tercio@11 385 return
Tercio@11 386 elseif (frame.fading_out) then --> já ta com fading out
Tercio@11 387 return
Tercio@11 388 end
Tercio@11 389
Tercio@11 390 if (frame.fading_in) then --> se tiver uma animação de hidar em andamento se for true
Tercio@11 391 frame.fading_in = false
Tercio@11 392 end
Tercio@11 393
Tercio@11 394 frame:Show()
Tercio@11 395 UIFrameFadeOut (frame, velocidade, frame:GetAlpha(), 1.0)
Tercio@11 396 frame.fading_out = true
Tercio@11 397
Tercio@11 398 frame.fadeInfo.finishedFunc = fade_OUT_finished_func
Tercio@11 399 frame.fadeInfo.finishedArg1 = frame
Tercio@11 400
Tercio@11 401 elseif (tipo == 0) then --> força o frame a ser mostrado
Tercio@11 402 frame.hidden = false
Tercio@11 403 frame.faded = false
Tercio@11 404 frame.fading_out = false
Tercio@11 405 frame.fading_in = false
Tercio@11 406 frame:Show()
Tercio@11 407 frame:SetAlpha (1)
Tercio@11 408
Tercio@11 409 elseif (tipo == 1) then --> força o frame a ser hidado
Tercio@11 410 frame.hidden = true
Tercio@11 411 frame.faded = true
Tercio@11 412 frame.fading_out = false
Tercio@11 413 frame.fading_in = false
Tercio@11 414 frame:SetAlpha (0)
Tercio@11 415 frame:Hide()
Tercio@11 416
Tercio@11 417 elseif (tipo == -1) then --> apenas da fade sem hidar
Tercio@11 418 if (frame:GetAlpha() == 0 and frame.hidden and not frame.fading_out) then --> ja esta escondida
Tercio@11 419 return
Tercio@11 420 elseif (frame.fading_in) then --> ja esta com uma animação, se for true
Tercio@11 421 return
Tercio@11 422 end
Tercio@11 423
Tercio@11 424 if (frame.fading_out) then --> se tiver uma animação de aparecer em andamento se for true
Tercio@11 425 frame.fading_out = false
Tercio@11 426 end
Tercio@11 427
Tercio@11 428 UIFrameFadeIn (frame, velocidade, frame:GetAlpha(), 0)
Tercio@11 429 frame.fading_in = true
Tercio@11 430 frame.fadeInfo.finishedFunc = just_fade_func
Tercio@11 431 frame.fadeInfo.finishedArg1 = frame
Tercio@11 432
Tercio@11 433 elseif (upper (tipo) == "ALPHAANIM") then
Tercio@11 434
Tercio@11 435 local value = velocidade
Tercio@11 436 local currentApha = frame:GetAlpha()
Tercio@11 437 frame:Show()
Tercio@11 438
Tercio@11 439 if (currentApha < value) then
Tercio@11 440 if (frame.fading_in) then --> se tiver uma animação de hidar em andamento se for true
Tercio@11 441 frame.fading_in = false
Tercio@11 442 frame.fadeInfo.finishedFunc = nil
Tercio@11 443 end
Tercio@11 444 UIFrameFadeOut (frame, 0.3, currentApha, value)
Tercio@11 445 frame.fading_out = true
Tercio@11 446
Tercio@11 447 frame.fadeInfo.finishedFunc = anim_OUT_alpha_func
Tercio@11 448 frame.fadeInfo.finishedArg1 = frame
Tercio@11 449
Tercio@11 450 else
Tercio@11 451 if (frame.fading_out) then --> se tiver uma animação de hidar em andamento se for true
Tercio@11 452 frame.fading_out = false
Tercio@11 453 frame.fadeInfo.finishedFunc = nil
Tercio@11 454 end
Tercio@11 455 UIFrameFadeIn (frame, 0.3, currentApha, value)
Tercio@11 456 frame.fading_in = true
Tercio@11 457
Tercio@11 458 frame.fadeInfo.finishedFunc = anim_IN_alpha_func
Tercio@11 459 frame.fadeInfo.finishedArg1 = frame
Tercio@11 460 end
Tercio@11 461
Tercio@11 462 elseif (upper (tipo) == "ALPHA") then --> setando um alpha determinado
Tercio@11 463 if (frame.fading_in or frame.fading_out) then
Tercio@11 464 frame.fadeInfo.finishedFunc = nil
Tercio@11 465 UIFrameFadeIn (frame, velocidade, frame:GetAlpha(), frame:GetAlpha())
Tercio@11 466 end
Tercio@11 467 frame.hidden = false
Tercio@11 468 frame.faded = false
Tercio@11 469 frame.fading_in = false
Tercio@11 470 frame.fading_out = false
Tercio@11 471 frame:Show()
Tercio@11 472 frame:SetAlpha (velocidade)
Tercio@11 473 end
Tercio@11 474 end
Tercio@11 475
Tercio@11 476 ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Tercio@11 477 --> points
Tercio@11 478
Tercio@11 479 function DF:CheckPoints (v1, v2, v3, v4, v5, object)
Tercio@11 480
Tercio@11 481 if (not v1 and not v2) then
Tercio@11 482 return "topleft", object.widget:GetParent(), "topleft", 0, 0
Tercio@11 483 end
Tercio@11 484
Tercio@11 485 if (_type (v1) == "string") then
Tercio@11 486 local frameGlobal = _G [v1]
Tercio@11 487 if (frameGlobal and frameGlobal.GetObjectType) then
Tercio@11 488 return DF:CheckPoints (frameGlobal, v2, v3, v4, v5, object)
Tercio@11 489 end
Tercio@11 490
Tercio@11 491 elseif (_type (v2) == "string") then
Tercio@11 492 local frameGlobal = _G [v2]
Tercio@11 493 if (frameGlobal and frameGlobal.GetObjectType) then
Tercio@11 494 return DF:CheckPoints (v1, frameGlobal, v3, v4, v5, object)
Tercio@11 495 end
Tercio@11 496 end
Tercio@11 497
Tercio@11 498 if (_type (v1) == "string" and _type (v2) == "table") then --> :setpoint ("left", frame, _, _, _)
Tercio@11 499 if (not v3 or _type (v3) == "number") then --> :setpoint ("left", frame, 10, 10)
Tercio@11 500 v1, v2, v3, v4, v5 = v1, v2, v1, v3, v4
Tercio@11 501 end
Tercio@11 502
Tercio@11 503 elseif (_type (v1) == "string" and _type (v2) == "number") then --> :setpoint ("topleft", x, y)
Tercio@11 504 v1, v2, v3, v4, v5 = v1, object.widget:GetParent(), v1, v2, v3
Tercio@11 505
Tercio@11 506 elseif (_type (v1) == "number") then --> :setpoint (x, y)
Tercio@11 507 v1, v2, v3, v4, v5 = "topleft", object.widget:GetParent(), "topleft", v1, v2
Tercio@11 508
Tercio@11 509 elseif (_type (v1) == "table") then --> :setpoint (frame, x, y)
Tercio@11 510 v1, v2, v3, v4, v5 = "topleft", v1, "topleft", v2, v3
Tercio@11 511
Tercio@11 512 end
Tercio@11 513
Tercio@11 514 if (not v2) then
Tercio@11 515 v2 = object.widget:GetParent()
Tercio@11 516 elseif (v2.dframework) then
Tercio@11 517 v2 = v2.widget
Tercio@11 518 end
Tercio@11 519
Tercio@11 520 return v1 or "topleft", v2, v3 or "topleft", v4 or 0, v5 or 0
Tercio@11 521 end
Tercio@11 522
Tercio@11 523
Tercio@11 524 ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Tercio@11 525 --> colors
Tercio@11 526
Tercio@11 527 function DF:NewColor (_colorname, _colortable, _green, _blue, _alpha)
Tercio@11 528 assert (_type (_colorname) == "string", "NewColor: colorname must be a string.")
Tercio@11 529 assert (not DF.alias_text_colors [_colorname], "NewColor: colorname already exists.")
Tercio@11 530
Tercio@11 531 if (_type (_colortable) == "table") then
Tercio@11 532 if (_colortable[1] and _colortable[2] and _colortable[3]) then
Tercio@11 533 _colortable[4] = _colortable[4] or 1
Tercio@11 534 DF.alias_text_colors [_colorname] = _colortable
Tercio@11 535 else
Tercio@11 536 error ("invalid color table.")
Tercio@11 537 end
Tercio@11 538 elseif (_colortable and _green and _blue) then
Tercio@11 539 _alpha = _alpha or 1
Tercio@11 540 DF.alias_text_colors [_colorname] = {_colortable, _green, _blue, _alpha}
Tercio@11 541 else
Tercio@11 542 error ("invalid parameter.")
Tercio@11 543 end
Tercio@11 544
Tercio@11 545 return true
Tercio@11 546 end
Tercio@11 547
Tercio@11 548 function DF:IsHtmlColor (color)
Tercio@11 549 return DF.alias_text_colors [color]
Tercio@11 550 end
Tercio@11 551
Tercio@11 552 local tn = tonumber
Tercio@11 553 function DF:ParseColors (_arg1, _arg2, _arg3, _arg4)
Tercio@11 554 if (_type (_arg1) == "table") then
Tercio@25 555 if (not _arg1[1] and _arg1.r) then
Tercio@25 556 _arg1, _arg2, _arg3, _arg4 = _arg1.r, _arg1.g, _arg1.b, _arg1.a
Tercio@25 557 else
Tercio@25 558 _arg1, _arg2, _arg3, _arg4 = _unpack (_arg1)
Tercio@25 559 end
Tercio@11 560
Tercio@11 561 elseif (_type (_arg1) == "string") then
Tercio@11 562
Tercio@11 563 if (string.find (_arg1, "#")) then
Tercio@11 564 _arg1 = _arg1:gsub ("#","")
Tercio@11 565 if (string.len (_arg1) == 8) then --alpha
Tercio@11 566 _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 567 else
Tercio@11 568 _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 569 end
Tercio@11 570
Tercio@11 571 else
Tercio@11 572 local color = DF.alias_text_colors [_arg1]
Tercio@11 573 if (color) then
Tercio@11 574 _arg1, _arg2, _arg3, _arg4 = _unpack (color)
Tercio@11 575 else
Tercio@11 576 _arg1, _arg2, _arg3, _arg4 = _unpack (DF.alias_text_colors.none)
Tercio@11 577 end
Tercio@11 578 end
Tercio@11 579 end
Tercio@11 580
Tercio@11 581 if (not _arg1) then
Tercio@11 582 _arg1 = 1
Tercio@11 583 end
Tercio@11 584 if (not _arg2) then
Tercio@11 585 _arg2 = 1
Tercio@11 586 end
Tercio@11 587 if (not _arg3) then
Tercio@11 588 _arg3 = 1
Tercio@11 589 end
Tercio@11 590 if (not _arg4) then
Tercio@11 591 _arg4 = 1
Tercio@11 592 end
Tercio@11 593
Tercio@11 594 return _arg1, _arg2, _arg3, _arg4
Tercio@11 595 end
Tercio@11 596
Tercio@11 597 ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Tercio@11 598 --> menus
Tercio@11 599
Tercio@22 600 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 601
Tercio@22 602 if (not parent.widget_list) then
Tercio@22 603 DF:SetAsOptionsPanel (parent)
Tercio@22 604 end
Tercio@11 605
Tercio@11 606 local cur_x = x_offset
Tercio@11 607 local cur_y = y_offset
Tercio@11 608 local max_x = 0
Tercio@11 609
Tercio@11 610 height = abs ((height or parent:GetHeight()) - abs (y_offset) + 20)
Tercio@11 611 height = height*-1
Tercio@11 612
Tercio@11 613 for index, widget_table in ipairs (menu) do
Tercio@11 614
Tercio@20 615 if (widget_table.type == "blank" or widget_table.type == "space") then
Tercio@20 616 -- do nothing
Tercio@20 617
Tercio@20 618 elseif (widget_table.type == "label" or widget_table.type == "text") then
Tercio@22 619 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 620 label._get = widget_table.get
Tercio@20 621 label.widget_type = "label"
Tercio@20 622 label:SetPoint (cur_x, cur_y)
Tercio@20 623 tinsert (parent.widget_list, label)
Tercio@20 624
Tercio@20 625 elseif (widget_table.type == "select" or widget_table.type == "dropdown") then
Tercio@22 626 local dropdown = DF:NewDropDown (parent, nil, "$parentWidget" .. index, nil, 140, 18, widget_table.values, widget_table.get(), dropdown_template)
Tercio@11 627 dropdown.tooltip = widget_table.desc
Tercio@20 628 dropdown._get = widget_table.get
Tercio@20 629 dropdown.widget_type = "select"
Tercio@22 630 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 631 dropdown:SetPoint ("left", label, "right", 2)
Tercio@11 632 label:SetPoint (cur_x, cur_y)
Tercio@11 633
Tercio@11 634 local size = label.widget:GetStringWidth() + 140 + 4
Tercio@11 635 if (size > max_x) then
Tercio@11 636 max_x = size
Tercio@11 637 end
Tercio@11 638
Tercio@20 639 tinsert (parent.widget_list, dropdown)
Tercio@20 640
Tercio@11 641 elseif (widget_table.type == "toggle" or widget_table.type == "switch") then
Tercio@22 642 local switch = DF:NewSwitch (parent, nil, "$parentWidget" .. index, nil, 60, 20, nil, nil, widget_table.get(), nil, nil, nil, nil, switch_template)
Tercio@11 643 switch.tooltip = widget_table.desc
Tercio@20 644 switch._get = widget_table.get
Tercio@20 645 switch.widget_type = "toggle"
Tercio@11 646 switch.OnSwitch = widget_table.set
Tercio@11 647
Tercio@22 648 if (switch_is_box) then
Tercio@22 649 switch:SetAsCheckBox()
Tercio@22 650 end
Tercio@22 651
Tercio@22 652 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 653 switch:SetPoint ("left", label, "right", 2)
Tercio@11 654 label:SetPoint (cur_x, cur_y)
Tercio@11 655
Tercio@11 656 local size = label.widget:GetStringWidth() + 60 + 4
Tercio@11 657 if (size > max_x) then
Tercio@11 658 max_x = size
Tercio@11 659 end
Tercio@11 660
Tercio@20 661 tinsert (parent.widget_list, switch)
Tercio@20 662
Tercio@11 663 elseif (widget_table.type == "range" or widget_table.type == "slider") then
Tercio@11 664 local is_decimanls = widget_table.usedecimals
Tercio@22 665 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 666 slider.tooltip = widget_table.desc
Tercio@20 667 slider._get = widget_table.get
Tercio@20 668 slider.widget_type = "range"
Tercio@11 669 slider:SetHook ("OnValueChange", widget_table.set)
Tercio@11 670
Tercio@22 671 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 672 slider:SetPoint ("left", label, "right", 2)
Tercio@11 673 label:SetPoint (cur_x, cur_y)
Tercio@11 674
Tercio@11 675 local size = label.widget:GetStringWidth() + 140 + 6
Tercio@11 676 if (size > max_x) then
Tercio@11 677 max_x = size
Tercio@11 678 end
Tercio@11 679
Tercio@20 680 tinsert (parent.widget_list, slider)
Tercio@20 681
Tercio@11 682 elseif (widget_table.type == "color" or widget_table.type == "color") then
Tercio@22 683 local colorpick = DF:NewColorPickButton (parent, "$parentWidget" .. index, nil, widget_table.set, nil, button_template)
Tercio@11 684 colorpick.tooltip = widget_table.desc
Tercio@20 685 colorpick._get = widget_table.get
Tercio@20 686 colorpick.widget_type = "color"
Tercio@11 687
Tercio@11 688 local default_value, g, b, a = widget_table.get()
Tercio@11 689 if (type (default_value) == "table") then
Tercio@11 690 colorpick:SetColor (unpack (default_value))
Tercio@11 691 else
Tercio@11 692 colorpick:SetColor (default_value, g, b, a)
Tercio@11 693 end
Tercio@11 694
Tercio@22 695 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 696 colorpick:SetPoint ("left", label, "right", 2)
Tercio@11 697 label:SetPoint (cur_x, cur_y)
Tercio@11 698
Tercio@11 699 local size = label.widget:GetStringWidth() + 60 + 4
Tercio@11 700 if (size > max_x) then
Tercio@11 701 max_x = size
Tercio@11 702 end
Tercio@11 703
Tercio@20 704 tinsert (parent.widget_list, colorpick)
Tercio@20 705
Tercio@11 706 elseif (widget_table.type == "execute" or widget_table.type == "button") then
Tercio@11 707
Tercio@22 708 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 709 if (not button_template) then
Tercio@22 710 button:InstallCustomTexture()
Tercio@22 711 end
Tercio@22 712
Tercio@11 713 button:SetPoint (cur_x, cur_y)
Tercio@11 714 button.tooltip = widget_table.desc
Tercio@20 715 button.widget_type = "execute"
Tercio@11 716
Tercio@11 717 local size = button:GetWidth() + 4
Tercio@11 718 if (size > max_x) then
Tercio@11 719 max_x = size
Tercio@11 720 end
Tercio@11 721
Tercio@20 722 tinsert (parent.widget_list, button)
Tercio@20 723
Tercio@11 724 end
Tercio@11 725
Tercio@11 726 if (widget_table.spacement) then
Tercio@11 727 cur_y = cur_y - 30
Tercio@11 728 else
Tercio@11 729 cur_y = cur_y - 20
Tercio@11 730 end
Tercio@11 731
Tercio@11 732 if (cur_y < height) then
Tercio@11 733 cur_y = y_offset
Tercio@11 734 cur_x = cur_x + max_x + 30
Tercio@11 735
Tercio@11 736 max_x = 0
Tercio@11 737 end
Tercio@11 738
Tercio@11 739 end
Tercio@11 740
Tercio@11 741 end
Tercio@11 742
Tercio@11 743 ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Tercio@11 744 --> tutorials
Tercio@11 745
Tercio@11 746 function DF:ShowTutorialAlertFrame (maintext, desctext, clickfunc)
Tercio@11 747
Tercio@11 748 local TutorialAlertFrame = _G.DetailsFrameworkTutorialAlertFrame
Tercio@11 749
Tercio@11 750 if (not TutorialAlertFrame) then
Tercio@11 751
Tercio@11 752 TutorialAlertFrame = CreateFrame ("ScrollFrame", "DetailsFrameworkTutorialAlertFrame", UIParent, "DetailsFrameworkTutorialAlertFrameTemplate")
Tercio@11 753 TutorialAlertFrame.isFirst = true
Tercio@11 754 TutorialAlertFrame:SetPoint ("left", UIParent, "left", -20, 100)
Tercio@11 755
Tercio@11 756 TutorialAlertFrame:SetWidth (290)
Tercio@11 757 TutorialAlertFrame.ScrollChild:SetWidth (256)
Tercio@11 758
Tercio@11 759 local scrollname = TutorialAlertFrame.ScrollChild:GetName()
Tercio@11 760 _G [scrollname .. "BorderTopLeft"]:SetVertexColor (1, 0.8, 0, 1)
Tercio@11 761 _G [scrollname .. "BorderTopRight"]:SetVertexColor (1, 0.8, 0, 1)
Tercio@11 762 _G [scrollname .. "BorderBotLeft"]:SetVertexColor (1, 0.8, 0, 1)
Tercio@11 763 _G [scrollname .. "BorderBotRight"]:SetVertexColor (1, 0.8, 0, 1)
Tercio@11 764 _G [scrollname .. "BorderLeft"]:SetVertexColor (1, 0.8, 0, 1)
Tercio@11 765 _G [scrollname .. "BorderRight"]:SetVertexColor (1, 0.8, 0, 1)
Tercio@11 766 _G [scrollname .. "BorderBottom"]:SetVertexColor (1, 0.8, 0, 1)
Tercio@11 767 _G [scrollname .. "BorderTop"]:SetVertexColor (1, 0.8, 0, 1)
Tercio@11 768
Tercio@11 769 local iconbg = _G [scrollname .. "QuestIconBg"]
Tercio@11 770 iconbg:SetTexture ([[Interface\MainMenuBar\UI-MainMenuBar-EndCap-Human]])
Tercio@11 771 iconbg:SetTexCoord (0, 1, 0, 1)
Tercio@11 772 iconbg:SetSize (100, 100)
Tercio@11 773 iconbg:ClearAllPoints()
Tercio@11 774 iconbg:SetPoint ("bottomleft", TutorialAlertFrame.ScrollChild, "bottomleft")
Tercio@11 775
Tercio@11 776 _G [scrollname .. "Exclamation"]:SetVertexColor (1, 0.8, 0, 1)
Tercio@11 777 _G [scrollname .. "QuestionMark"]:SetVertexColor (1, 0.8, 0, 1)
Tercio@11 778
Tercio@11 779 _G [scrollname .. "TopText"]:SetText ("Details!") --string
Tercio@11 780 _G [scrollname .. "QuestName"]:SetText ("") --string
Tercio@11 781 _G [scrollname .. "BottomText"]:SetText ("") --string
Tercio@11 782
Tercio@11 783 TutorialAlertFrame.ScrollChild.IconShine:SetTexture ([[Interface\MainMenuBar\UI-MainMenuBar-EndCap-Human]])
Tercio@11 784
Tercio@11 785 TutorialAlertFrame:SetScript ("OnMouseUp", function (self)
Tercio@11 786 if (self.clickfunc and type (self.clickfunc) == "function") then
Tercio@11 787 self.clickfunc()
Tercio@11 788 end
Tercio@11 789 self:Hide()
Tercio@11 790 end)
Tercio@11 791 TutorialAlertFrame:Hide()
Tercio@11 792 end
Tercio@11 793
Tercio@11 794 if (type (maintext) == "string") then
Tercio@11 795 TutorialAlertFrame.ScrollChild.QuestName:SetText (maintext)
Tercio@11 796 else
Tercio@11 797 TutorialAlertFrame.ScrollChild.QuestName:SetText ("")
Tercio@11 798 end
Tercio@11 799
Tercio@11 800 if (type (desctext) == "string") then
Tercio@11 801 TutorialAlertFrame.ScrollChild.BottomText:SetText (desctext)
Tercio@11 802 else
Tercio@11 803 TutorialAlertFrame.ScrollChild.BottomText:SetText ("")
Tercio@11 804 end
Tercio@11 805
Tercio@11 806 TutorialAlertFrame.clickfunc = clickfunc
Tercio@11 807 TutorialAlertFrame:Show()
Tercio@11 808 DetailsTutorialAlertFrame_SlideInFrame (TutorialAlertFrame, "AUTOQUEST")
Tercio@11 809 end
Tercio@11 810
Tercio@20 811 local refresh_options = function (self)
Tercio@20 812 for _, widget in ipairs (self.widget_list) do
Tercio@20 813 if (widget._get) then
Tercio@20 814 if (widget.widget_type == "label") then
Tercio@20 815 if (widget._get()) then
Tercio@20 816 widget:SetText (widget._get())
Tercio@20 817 end
Tercio@20 818 elseif (widget.widget_type == "select") then
Tercio@20 819 widget:Select (widget._get())
Tercio@20 820 elseif (widget.widget_type == "toggle" or widget.widget_type == "range") then
Tercio@20 821 widget:SetValue (widget._get())
Tercio@20 822 elseif (widget.widget_type == "color") then
Tercio@20 823 local default_value, g, b, a = widget._get()
Tercio@20 824 if (type (default_value) == "table") then
Tercio@20 825 widget:SetColor (unpack (default_value))
Tercio@20 826 else
Tercio@20 827 widget:SetColor (default_value, g, b, a)
Tercio@20 828 end
Tercio@20 829 end
Tercio@20 830 end
Tercio@20 831 end
Tercio@20 832 end
Tercio@20 833
Tercio@20 834 function DF:SetAsOptionsPanel (frame)
Tercio@20 835 frame.RefreshOptions = refresh_options
Tercio@20 836 frame.widget_list = {}
Tercio@20 837 end
Tercio@20 838
Tercio@11 839 function DF:CreateOptionsFrame (name, title, template)
Tercio@11 840
Tercio@11 841 template = template or 1
Tercio@11 842
Tercio@11 843 if (template == 2) then
Tercio@11 844 local options_frame = CreateFrame ("frame", name, UIParent, "ButtonFrameTemplate")
Tercio@11 845 tinsert (UISpecialFrames, name)
Tercio@11 846 options_frame:SetSize (500, 200)
Tercio@20 847 options_frame.RefreshOptions = refresh_options
Tercio@20 848 options_frame.widget_list = {}
Tercio@11 849
Tercio@11 850 options_frame:SetScript ("OnMouseDown", function(self, button)
Tercio@11 851 if (button == "RightButton") then
Tercio@11 852 if (self.moving) then
Tercio@11 853 self.moving = false
Tercio@11 854 self:StopMovingOrSizing()
Tercio@11 855 end
Tercio@11 856 return options_frame:Hide()
Tercio@11 857 elseif (button == "LeftButton" and not self.moving) then
Tercio@11 858 self.moving = true
Tercio@11 859 self:StartMoving()
Tercio@11 860 end
Tercio@11 861 end)
Tercio@11 862 options_frame:SetScript ("OnMouseUp", function(self)
Tercio@11 863 if (self.moving) then
Tercio@11 864 self.moving = false
Tercio@11 865 self:StopMovingOrSizing()
Tercio@11 866 end
Tercio@11 867 end)
Tercio@11 868
Tercio@11 869 options_frame:SetMovable (true)
Tercio@11 870 options_frame:EnableMouse (true)
Tercio@11 871 options_frame:SetFrameStrata ("DIALOG")
Tercio@11 872 options_frame:SetToplevel (true)
Tercio@11 873
Tercio@11 874 options_frame:Hide()
Tercio@11 875
Tercio@11 876 options_frame:SetPoint ("center", UIParent, "center")
Tercio@11 877 options_frame.TitleText:SetText (title)
Tercio@11 878 options_frame.portrait:SetTexture ([[Interface\CHARACTERFRAME\TEMPORARYPORTRAIT-FEMALE-BLOODELF]])
Tercio@11 879
Tercio@11 880 return options_frame
Tercio@11 881
Tercio@11 882 elseif (template == 1) then
Tercio@11 883
Tercio@11 884 local options_frame = CreateFrame ("frame", name, UIParent)
Tercio@11 885 tinsert (UISpecialFrames, name)
Tercio@11 886 options_frame:SetSize (500, 200)
Tercio@20 887 options_frame.RefreshOptions = refresh_options
Tercio@20 888 options_frame.widget_list = {}
Tercio@11 889
Tercio@11 890 options_frame:SetScript ("OnMouseDown", function(self, button)
Tercio@11 891 if (button == "RightButton") then
Tercio@11 892 if (self.moving) then
Tercio@11 893 self.moving = false
Tercio@11 894 self:StopMovingOrSizing()
Tercio@11 895 end
Tercio@11 896 return options_frame:Hide()
Tercio@11 897 elseif (button == "LeftButton" and not self.moving) then
Tercio@11 898 self.moving = true
Tercio@11 899 self:StartMoving()
Tercio@11 900 end
Tercio@11 901 end)
Tercio@11 902 options_frame:SetScript ("OnMouseUp", function(self)
Tercio@11 903 if (self.moving) then
Tercio@11 904 self.moving = false
Tercio@11 905 self:StopMovingOrSizing()
Tercio@11 906 end
Tercio@11 907 end)
Tercio@11 908
Tercio@11 909 options_frame:SetMovable (true)
Tercio@11 910 options_frame:EnableMouse (true)
Tercio@11 911 options_frame:SetFrameStrata ("DIALOG")
Tercio@11 912 options_frame:SetToplevel (true)
Tercio@11 913
Tercio@11 914 options_frame:Hide()
Tercio@11 915
Tercio@11 916 options_frame:SetPoint ("center", UIParent, "center")
Tercio@11 917
Tercio@11 918 options_frame:SetBackdrop ({bgFile = "Interface\\Tooltips\\UI-Tooltip-Background", tile = true, tileSize = 16,
Tercio@18 919 edgeFile = DF.folder .. "border_2", edgeSize = 32,
Tercio@11 920 insets = {left = 1, right = 1, top = 1, bottom = 1}})
Tercio@11 921 options_frame:SetBackdropColor (0, 0, 0, .7)
Tercio@11 922
Tercio@11 923 local texturetitle = options_frame:CreateTexture (nil, "artwork")
Tercio@11 924 texturetitle:SetTexture ([[Interface\CURSOR\Interact]])
Tercio@11 925 texturetitle:SetTexCoord (0, 1, 0, 1)
Tercio@11 926 texturetitle:SetVertexColor (1, 1, 1, 1)
Tercio@11 927 texturetitle:SetPoint ("topleft", options_frame, "topleft", 2, -3)
Tercio@11 928 texturetitle:SetWidth (36)
Tercio@11 929 texturetitle:SetHeight (36)
Tercio@11 930
Tercio@11 931 local title = DF:NewLabel (options_frame, nil, "$parentTitle", nil, title, nil, 20, "yellow")
Tercio@11 932 title:SetPoint ("left", texturetitle, "right", 2, -1)
Tercio@11 933 DF:SetFontOutline (title, true)
Tercio@11 934
Tercio@11 935 local c = CreateFrame ("Button", nil, options_frame, "UIPanelCloseButton")
Tercio@11 936 c:SetWidth (32)
Tercio@11 937 c:SetHeight (32)
Tercio@11 938 c:SetPoint ("TOPRIGHT", options_frame, "TOPRIGHT", -3, -3)
Tercio@11 939 c:SetFrameLevel (options_frame:GetFrameLevel()+1)
Tercio@11 940
Tercio@11 941 return options_frame
Tercio@11 942 end
Tercio@22 943 end
Tercio@22 944
Tercio@22 945 ------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Tercio@22 946 --> templates
Tercio@22 947
Tercio@22 948 DF.font_templates = {}
Tercio@22 949 DF.font_templates ["ORANGE_FONT_TEMPLATE"] = {color = "orange", size = 11, font = "Accidental Presidency"}
Tercio@22 950 DF.font_templates ["OPTIONS_FONT_TEMPLATE"] = {color = "yellow", size = 12, font = "Accidental Presidency"}
Tercio@22 951
Tercio@22 952 DF.dropdown_templates = {}
Tercio@22 953 DF.dropdown_templates ["OPTIONS_DROPDOWN_TEMPLATE"] = {
Tercio@22 954 backdrop = {edgeFile = [[Interface\Buttons\WHITE8X8]], edgeSize = 1, bgFile = [[Interface\Tooltips\UI-Tooltip-Background]], tileSize = 64, tile = true},
Tercio@22 955 backdropcolor = {1, 1, 1, .5},
Tercio@22 956 backdropbordercolor = {0, 0, 0, 1},
Tercio@22 957 onentercolor = {1, 1, 1, .5},
Tercio@22 958 onenterbordercolor = {1, 1, 1, 1},
Tercio@22 959 }
Tercio@22 960
Tercio@22 961 DF.switch_templates = {}
Tercio@22 962 DF.switch_templates ["OPTIONS_CHECKBOX_TEMPLATE"] = {
Tercio@22 963 backdrop = {edgeFile = [[Interface\Buttons\WHITE8X8]], edgeSize = 1, bgFile = [[Interface\Tooltips\UI-Tooltip-Background]], tileSize = 64, tile = true},
Tercio@22 964 backdropcolor = {1, 1, 1, .5},
Tercio@22 965 backdropbordercolor = {0, 0, 0, 1},
Tercio@22 966 width = 18,
Tercio@22 967 height = 18,
Tercio@22 968 enabled_backdropcolor = {1, 1, 1, .5},
Tercio@22 969 disabled_backdropcolor = {1, 1, 1, .2},
Tercio@22 970 onenterbordercolor = {1, 1, 1, 1},
Tercio@22 971 }
Tercio@22 972 DF.switch_templates ["OPTIONS_CHECKBOX_BRIGHT_TEMPLATE"] = {
Tercio@22 973 backdrop = {edgeFile = [[Interface\Buttons\WHITE8X8]], edgeSize = 1, bgFile = [[Interface\Tooltips\UI-Tooltip-Background]], tileSize = 64, tile = true},
Tercio@22 974 backdropcolor = {1, 1, 1, .5},
Tercio@22 975 backdropbordercolor = {0, 0, 0, 1},
Tercio@22 976 width = 18,
Tercio@22 977 height = 18,
Tercio@22 978 enabled_backdropcolor = {1, 1, 1, .5},
Tercio@22 979 disabled_backdropcolor = {1, 1, 1, .5},
Tercio@22 980 onenterbordercolor = {1, 1, 1, 1},
Tercio@22 981 }
Tercio@22 982
Tercio@22 983 DF.button_templates = {}
Tercio@22 984 DF.button_templates ["OPTIONS_BUTTON_TEMPLATE"] = {
Tercio@22 985 backdrop = {edgeFile = [[Interface\Buttons\WHITE8X8]], edgeSize = 1, bgFile = [[Interface\Tooltips\UI-Tooltip-Background]], tileSize = 64, tile = true},
Tercio@22 986 backdropcolor = {1, 1, 1, .5},
Tercio@22 987 backdropbordercolor = {0, 0, 0, 1},
Tercio@22 988 }
Tercio@22 989
Tercio@22 990 DF.slider_templates = {}
Tercio@22 991 DF.slider_templates ["OPTIONS_SLIDER_TEMPLATE"] = {
Tercio@22 992 backdrop = {edgeFile = [[Interface\Buttons\WHITE8X8]], edgeSize = 1, bgFile = [[Interface\Tooltips\UI-Tooltip-Background]], tileSize = 64, tile = true},
Tercio@22 993 backdropcolor = {1, 1, 1, .5},
Tercio@22 994 backdropbordercolor = {0, 0, 0, 1},
Tercio@22 995 onentercolor = {1, 1, 1, .5},
Tercio@22 996 onenterbordercolor = {1, 1, 1, 1},
Tercio@22 997 thumbtexture = [[Interface\Tooltips\UI-Tooltip-Background]],
Tercio@22 998 thumbwidth = 16,
Tercio@22 999 thumbheight = 14,
Tercio@22 1000 thumbcolor = {0, 0, 0, 0.5},
Tercio@22 1001 }
Tercio@22 1002
Tercio@22 1003 function DF:GetTemplate (type, template_name)
Tercio@22 1004 local template_table
Tercio@22 1005 if (type == "font") then
Tercio@22 1006 template_table = DF.font_templates
Tercio@22 1007 elseif (type == "dropdown") then
Tercio@22 1008 template_table = DF.dropdown_templates
Tercio@22 1009 elseif (type == "button") then
Tercio@22 1010 template_table = DF.button_templates
Tercio@22 1011 elseif (type == "switch") then
Tercio@22 1012 template_table = DF.switch_templates
Tercio@22 1013 elseif (type == "slider") then
Tercio@22 1014 template_table = DF.slider_templates
Tercio@22 1015 end
Tercio@22 1016 return template_table [template_name]
Tercio@22 1017 end
Tercio@22 1018