annotate Libs/DF/fw.lua @ 22:dbd417f413a8

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