annotate Libs/DF/fw.lua @ 24:7a285d98b95f

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