Mercurial > wow > hansgar_and_franzok_assist
comparison Libs/DF/fw.lua @ 11:2f09fe4be15c
Added an Options Panel.
| author | Tercio |
|---|---|
| date | Mon, 20 Apr 2015 16:34:18 -0300 |
| parents | |
| children | 0c160948ac5e |
comparison
equal
deleted
inserted
replaced
| 10:f1e32be6773e | 11:2f09fe4be15c |
|---|---|
| 1 | |
| 2 local major, minor = "DetailsFramework-1.0", 2 | |
| 3 local DF, oldminor = LibStub:NewLibrary (major, minor) | |
| 4 | |
| 5 | |
| 6 if (not DF) then | |
| 7 return | |
| 8 end | |
| 9 | |
| 10 local _type = type | |
| 11 local _unpack = unpack | |
| 12 local _ | |
| 13 local upper = string.upper | |
| 14 | |
| 15 DF.LabelNameCounter = 1 | |
| 16 DF.PictureNameCounter = 1 | |
| 17 DF.BarNameCounter = 1 | |
| 18 DF.DropDownCounter = 1 | |
| 19 DF.PanelCounter = 1 | |
| 20 DF.ButtonCounter = 1 | |
| 21 DF.SliderCounter = 1 | |
| 22 DF.SplitBarCounter = 1 | |
| 23 | |
| 24 do | |
| 25 local path = string.match (debugstack (1, 1, 0), "AddOns\\(.+)fw.lua") | |
| 26 if (path) then | |
| 27 DF.folder = "Interface\\AddOns\\" .. path | |
| 28 else | |
| 29 DF.folder = "" | |
| 30 end | |
| 31 end | |
| 32 | |
| 33 DF.debug = false | |
| 34 | |
| 35 _G ["DetailsFramework"] = DF | |
| 36 | |
| 37 DF.embeds = DF.embeds or {} | |
| 38 local embed_functions = { | |
| 39 "SetFontSize", | |
| 40 "SetFontFace", | |
| 41 "SetFontColor", | |
| 42 "GetFontSize", | |
| 43 "GetFontFace", | |
| 44 "trim", | |
| 45 "Msg", | |
| 46 "CreateFlashAnimation", | |
| 47 "Fade", | |
| 48 "NewColor", | |
| 49 "IsHtmlColor", | |
| 50 "ParseColors", | |
| 51 "BuildMenu", | |
| 52 "ShowTutorialAlertFrame", | |
| 53 "GetNpcIdFromGuid", | |
| 54 "ShowFeedbackPanel", | |
| 55 | |
| 56 "CreateDropDown", | |
| 57 "CreateButton", | |
| 58 "CreateColorPickButton", | |
| 59 "CreateLabel", | |
| 60 "CreateBar", | |
| 61 "CreatePanel", | |
| 62 "CreateFillPanel", | |
| 63 "ColorPick", | |
| 64 "IconPick", | |
| 65 "CreateSimplePanel", | |
| 66 "CreateChartPanel", | |
| 67 "CreateImage", | |
| 68 "CreateScrollBar", | |
| 69 "CreateSwitch", | |
| 70 "CreateSlider", | |
| 71 "CreateSplitBar", | |
| 72 "CreateTextEntry", | |
| 73 "Create1PxPanel", | |
| 74 "CreateFeedbackButton", | |
| 75 | |
| 76 "www_icons", | |
| 77 } | |
| 78 | |
| 79 DF.www_icons = { | |
| 80 texture = "feedback_sites", | |
| 81 wowi = {0, 0.7890625, 0, 37/128}, | |
| 82 curse = {0, 0.7890625, 38/123, 79/128}, | |
| 83 mmoc = {0, 0.7890625, 80/123, 123/128}, | |
| 84 } | |
| 85 | |
| 86 function DF:Embed (target) | |
| 87 for k, v in pairs (embed_functions) do | |
| 88 target[v] = self[v] | |
| 89 end | |
| 90 self.embeds [target] = true | |
| 91 return target | |
| 92 end | |
| 93 | |
| 94 function DF:SetFontSize (fontString, ...) | |
| 95 local fonte, _, flags = fontString:GetFont() | |
| 96 fontString:SetFont (fonte, max (...), flags) | |
| 97 end | |
| 98 function DF:SetFontFace (fontString, fontface) | |
| 99 local _, size, flags = fontString:GetFont() | |
| 100 fontString:SetFont (fontface, size, flags) | |
| 101 end | |
| 102 function DF:SetFontColor (fontString, r, g, b, a) | |
| 103 r, g, b, a = DF:ParseColors (r, g, b, a) | |
| 104 fontString:SetTextColor (r, g, b, a) | |
| 105 end | |
| 106 | |
| 107 function DF:GetFontSize (fontString) | |
| 108 local _, size = fontString:GetFont() | |
| 109 return size | |
| 110 end | |
| 111 function DF:GetFontFace (fontString) | |
| 112 local fontface = fontString:GetFont() | |
| 113 return fontface | |
| 114 end | |
| 115 | |
| 116 function DF:SetFontOutline (fontString, outline) | |
| 117 local fonte, size = fontString:GetFont() | |
| 118 if (outline) then | |
| 119 if (_type (outline) == "boolean" and outline) then | |
| 120 outline = "OUTLINE" | |
| 121 elseif (outline == 1) then | |
| 122 outline = "OUTLINE" | |
| 123 elseif (outline == 2) then | |
| 124 outline = "THICKOUTLINE" | |
| 125 end | |
| 126 end | |
| 127 | |
| 128 fontString:SetFont (fonte, size, outline) | |
| 129 end | |
| 130 | |
| 131 function DF:trim (s) | |
| 132 local from = s:match"^%s*()" | |
| 133 return from > #s and "" or s:match(".*%S", from) | |
| 134 end | |
| 135 | |
| 136 function DF:Msg (msg) | |
| 137 print ("|cFFFFFFAA" .. self.__name .. "|r " .. msg) | |
| 138 end | |
| 139 | |
| 140 function DF:GetNpcIdFromGuid (guid) | |
| 141 local NpcId = select ( 6, strsplit ( "-", guid ) ) | |
| 142 if (NpcId) then | |
| 143 return tonumber ( NpcId ) | |
| 144 end | |
| 145 return 0 | |
| 146 end | |
| 147 | |
| 148 local onFinish = function (self) | |
| 149 if (self.showWhenDone) then | |
| 150 self.frame:SetAlpha (1) | |
| 151 else | |
| 152 self.frame:SetAlpha (0) | |
| 153 self.frame:Hide() | |
| 154 end | |
| 155 | |
| 156 if (self.onFinishFunc) then | |
| 157 self:onFinishFunc (self.frame) | |
| 158 end | |
| 159 end | |
| 160 | |
| 161 local stop = function (self) | |
| 162 local FlashAnimation = self.FlashAnimation | |
| 163 FlashAnimation:Stop() | |
| 164 end | |
| 165 | |
| 166 local flash = function (self, fadeInTime, fadeOutTime, flashDuration, showWhenDone, flashInHoldTime, flashOutHoldTime, loopType) | |
| 167 | |
| 168 local FlashAnimation = self.FlashAnimation | |
| 169 | |
| 170 local fadeIn = FlashAnimation.fadeIn | |
| 171 local fadeOut = FlashAnimation.fadeOut | |
| 172 | |
| 173 fadeIn:Stop() | |
| 174 fadeOut:Stop() | |
| 175 | |
| 176 fadeIn:SetDuration (fadeInTime or 1) | |
| 177 fadeIn:SetEndDelay (flashInHoldTime or 0) | |
| 178 | |
| 179 fadeOut:SetDuration (fadeOutTime or 1) | |
| 180 fadeOut:SetEndDelay (flashOutHoldTime or 0) | |
| 181 | |
| 182 FlashAnimation.duration = flashDuration | |
| 183 FlashAnimation.loopTime = FlashAnimation:GetDuration() | |
| 184 FlashAnimation.finishAt = GetTime() + flashDuration | |
| 185 FlashAnimation.showWhenDone = showWhenDone | |
| 186 | |
| 187 FlashAnimation:SetLooping (loopType or "REPEAT") | |
| 188 | |
| 189 self:Show() | |
| 190 self:SetAlpha (0) | |
| 191 FlashAnimation:Play() | |
| 192 end | |
| 193 | |
| 194 function DF:CreateFlashAnimation (frame, onFinishFunc, onLoopFunc) | |
| 195 local FlashAnimation = frame:CreateAnimationGroup() | |
| 196 | |
| 197 FlashAnimation.fadeOut = FlashAnimation:CreateAnimation ("Alpha") --> fade out anime | |
| 198 FlashAnimation.fadeOut:SetOrder (1) | |
| 199 FlashAnimation.fadeOut:SetChange (1) | |
| 200 | |
| 201 FlashAnimation.fadeIn = FlashAnimation:CreateAnimation ("Alpha") --> fade in anime | |
| 202 FlashAnimation.fadeIn:SetOrder (2) | |
| 203 FlashAnimation.fadeIn:SetChange (-1) | |
| 204 | |
| 205 frame.FlashAnimation = FlashAnimation | |
| 206 FlashAnimation.frame = frame | |
| 207 FlashAnimation.onFinishFunc = onFinishFunc | |
| 208 | |
| 209 FlashAnimation:SetScript ("OnLoop", onLoopFunc) | |
| 210 FlashAnimation:SetScript ("OnFinished", onFinish) | |
| 211 | |
| 212 frame.Flash = flash | |
| 213 frame.Stop = stop | |
| 214 end | |
| 215 | |
| 216 ----------------------------------------- | |
| 217 | |
| 218 local fade_IN_finished_func = function (frame) | |
| 219 if (frame.fading_in) then | |
| 220 frame.hidden = true | |
| 221 frame.faded = true | |
| 222 frame.fading_in = false | |
| 223 frame:Hide() | |
| 224 end | |
| 225 end | |
| 226 | |
| 227 local fade_OUT_finished_func = function (frame) | |
| 228 if (frame:IsShown() and frame.fading_out) then | |
| 229 frame.hidden = false | |
| 230 frame.faded = false | |
| 231 frame.fading_out = false | |
| 232 else | |
| 233 frame:SetAlpha(0) | |
| 234 end | |
| 235 end | |
| 236 | |
| 237 local just_fade_func = function (frame) | |
| 238 frame.hidden = false | |
| 239 frame.faded = true | |
| 240 frame.fading_in = false | |
| 241 end | |
| 242 | |
| 243 local anim_OUT_alpha_func = function (frame) | |
| 244 frame.fading_out = false | |
| 245 end | |
| 246 | |
| 247 local anim_IN_alpha_func = function (frame) | |
| 248 frame.fading_in = false | |
| 249 end | |
| 250 | |
| 251 function DF:Fade (frame, tipo, velocidade, parametros) | |
| 252 | |
| 253 if (_type (frame) == "table") then | |
| 254 if (frame.dframework) then | |
| 255 frame = frame.widget | |
| 256 end | |
| 257 end | |
| 258 | |
| 259 velocidade = velocidade or 0.3 | |
| 260 | |
| 261 if (upper (tipo) == "IN") then | |
| 262 | |
| 263 if (frame:GetAlpha() == 0 and frame.hidden and not frame.fading_out) then --> ja esta escondida | |
| 264 return | |
| 265 elseif (frame.fading_in) then --> ja esta com uma animação, se for true | |
| 266 return | |
| 267 end | |
| 268 | |
| 269 if (frame.fading_out) then --> se tiver uma animação de aparecer em andamento se for true | |
| 270 frame.fading_out = false | |
| 271 end | |
| 272 | |
| 273 UIFrameFadeIn (frame, velocidade, frame:GetAlpha(), 0) | |
| 274 frame.fading_in = true | |
| 275 | |
| 276 frame.fadeInfo.finishedFunc = fade_IN_finished_func | |
| 277 frame.fadeInfo.finishedArg1 = frame | |
| 278 | |
| 279 elseif (upper (tipo) == "OUT") then --> aparecer | |
| 280 if (frame:GetAlpha() == 1 and not frame.hidden and not frame.fading_in) then --> ja esta na tela | |
| 281 return | |
| 282 elseif (frame.fading_out) then --> já ta com fading out | |
| 283 return | |
| 284 end | |
| 285 | |
| 286 if (frame.fading_in) then --> se tiver uma animação de hidar em andamento se for true | |
| 287 frame.fading_in = false | |
| 288 end | |
| 289 | |
| 290 frame:Show() | |
| 291 UIFrameFadeOut (frame, velocidade, frame:GetAlpha(), 1.0) | |
| 292 frame.fading_out = true | |
| 293 | |
| 294 frame.fadeInfo.finishedFunc = fade_OUT_finished_func | |
| 295 frame.fadeInfo.finishedArg1 = frame | |
| 296 | |
| 297 elseif (tipo == 0) then --> força o frame a ser mostrado | |
| 298 frame.hidden = false | |
| 299 frame.faded = false | |
| 300 frame.fading_out = false | |
| 301 frame.fading_in = false | |
| 302 frame:Show() | |
| 303 frame:SetAlpha (1) | |
| 304 | |
| 305 elseif (tipo == 1) then --> força o frame a ser hidado | |
| 306 frame.hidden = true | |
| 307 frame.faded = true | |
| 308 frame.fading_out = false | |
| 309 frame.fading_in = false | |
| 310 frame:SetAlpha (0) | |
| 311 frame:Hide() | |
| 312 | |
| 313 elseif (tipo == -1) then --> apenas da fade sem hidar | |
| 314 if (frame:GetAlpha() == 0 and frame.hidden and not frame.fading_out) then --> ja esta escondida | |
| 315 return | |
| 316 elseif (frame.fading_in) then --> ja esta com uma animação, se for true | |
| 317 return | |
| 318 end | |
| 319 | |
| 320 if (frame.fading_out) then --> se tiver uma animação de aparecer em andamento se for true | |
| 321 frame.fading_out = false | |
| 322 end | |
| 323 | |
| 324 UIFrameFadeIn (frame, velocidade, frame:GetAlpha(), 0) | |
| 325 frame.fading_in = true | |
| 326 frame.fadeInfo.finishedFunc = just_fade_func | |
| 327 frame.fadeInfo.finishedArg1 = frame | |
| 328 | |
| 329 elseif (upper (tipo) == "ALPHAANIM") then | |
| 330 | |
| 331 local value = velocidade | |
| 332 local currentApha = frame:GetAlpha() | |
| 333 frame:Show() | |
| 334 | |
| 335 if (currentApha < value) then | |
| 336 if (frame.fading_in) then --> se tiver uma animação de hidar em andamento se for true | |
| 337 frame.fading_in = false | |
| 338 frame.fadeInfo.finishedFunc = nil | |
| 339 end | |
| 340 UIFrameFadeOut (frame, 0.3, currentApha, value) | |
| 341 frame.fading_out = true | |
| 342 | |
| 343 frame.fadeInfo.finishedFunc = anim_OUT_alpha_func | |
| 344 frame.fadeInfo.finishedArg1 = frame | |
| 345 | |
| 346 else | |
| 347 if (frame.fading_out) then --> se tiver uma animação de hidar em andamento se for true | |
| 348 frame.fading_out = false | |
| 349 frame.fadeInfo.finishedFunc = nil | |
| 350 end | |
| 351 UIFrameFadeIn (frame, 0.3, currentApha, value) | |
| 352 frame.fading_in = true | |
| 353 | |
| 354 frame.fadeInfo.finishedFunc = anim_IN_alpha_func | |
| 355 frame.fadeInfo.finishedArg1 = frame | |
| 356 end | |
| 357 | |
| 358 elseif (upper (tipo) == "ALPHA") then --> setando um alpha determinado | |
| 359 if (frame.fading_in or frame.fading_out) then | |
| 360 frame.fadeInfo.finishedFunc = nil | |
| 361 UIFrameFadeIn (frame, velocidade, frame:GetAlpha(), frame:GetAlpha()) | |
| 362 end | |
| 363 frame.hidden = false | |
| 364 frame.faded = false | |
| 365 frame.fading_in = false | |
| 366 frame.fading_out = false | |
| 367 frame:Show() | |
| 368 frame:SetAlpha (velocidade) | |
| 369 end | |
| 370 end | |
| 371 | |
| 372 ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | |
| 373 --> points | |
| 374 | |
| 375 function DF:CheckPoints (v1, v2, v3, v4, v5, object) | |
| 376 | |
| 377 if (not v1 and not v2) then | |
| 378 return "topleft", object.widget:GetParent(), "topleft", 0, 0 | |
| 379 end | |
| 380 | |
| 381 if (_type (v1) == "string") then | |
| 382 local frameGlobal = _G [v1] | |
| 383 if (frameGlobal and frameGlobal.GetObjectType) then | |
| 384 return DF:CheckPoints (frameGlobal, v2, v3, v4, v5, object) | |
| 385 end | |
| 386 | |
| 387 elseif (_type (v2) == "string") then | |
| 388 local frameGlobal = _G [v2] | |
| 389 if (frameGlobal and frameGlobal.GetObjectType) then | |
| 390 return DF:CheckPoints (v1, frameGlobal, v3, v4, v5, object) | |
| 391 end | |
| 392 end | |
| 393 | |
| 394 if (_type (v1) == "string" and _type (v2) == "table") then --> :setpoint ("left", frame, _, _, _) | |
| 395 if (not v3 or _type (v3) == "number") then --> :setpoint ("left", frame, 10, 10) | |
| 396 v1, v2, v3, v4, v5 = v1, v2, v1, v3, v4 | |
| 397 end | |
| 398 | |
| 399 elseif (_type (v1) == "string" and _type (v2) == "number") then --> :setpoint ("topleft", x, y) | |
| 400 v1, v2, v3, v4, v5 = v1, object.widget:GetParent(), v1, v2, v3 | |
| 401 | |
| 402 elseif (_type (v1) == "number") then --> :setpoint (x, y) | |
| 403 v1, v2, v3, v4, v5 = "topleft", object.widget:GetParent(), "topleft", v1, v2 | |
| 404 | |
| 405 elseif (_type (v1) == "table") then --> :setpoint (frame, x, y) | |
| 406 v1, v2, v3, v4, v5 = "topleft", v1, "topleft", v2, v3 | |
| 407 | |
| 408 end | |
| 409 | |
| 410 if (not v2) then | |
| 411 v2 = object.widget:GetParent() | |
| 412 elseif (v2.dframework) then | |
| 413 v2 = v2.widget | |
| 414 end | |
| 415 | |
| 416 return v1 or "topleft", v2, v3 or "topleft", v4 or 0, v5 or 0 | |
| 417 end | |
| 418 | |
| 419 | |
| 420 ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | |
| 421 --> colors | |
| 422 | |
| 423 function DF:NewColor (_colorname, _colortable, _green, _blue, _alpha) | |
| 424 assert (_type (_colorname) == "string", "NewColor: colorname must be a string.") | |
| 425 assert (not DF.alias_text_colors [_colorname], "NewColor: colorname already exists.") | |
| 426 | |
| 427 if (_type (_colortable) == "table") then | |
| 428 if (_colortable[1] and _colortable[2] and _colortable[3]) then | |
| 429 _colortable[4] = _colortable[4] or 1 | |
| 430 DF.alias_text_colors [_colorname] = _colortable | |
| 431 else | |
| 432 error ("invalid color table.") | |
| 433 end | |
| 434 elseif (_colortable and _green and _blue) then | |
| 435 _alpha = _alpha or 1 | |
| 436 DF.alias_text_colors [_colorname] = {_colortable, _green, _blue, _alpha} | |
| 437 else | |
| 438 error ("invalid parameter.") | |
| 439 end | |
| 440 | |
| 441 return true | |
| 442 end | |
| 443 | |
| 444 function DF:IsHtmlColor (color) | |
| 445 return DF.alias_text_colors [color] | |
| 446 end | |
| 447 | |
| 448 local tn = tonumber | |
| 449 function DF:ParseColors (_arg1, _arg2, _arg3, _arg4) | |
| 450 if (_type (_arg1) == "table") then | |
| 451 _arg1, _arg2, _arg3, _arg4 = _unpack (_arg1) | |
| 452 | |
| 453 elseif (_type (_arg1) == "string") then | |
| 454 | |
| 455 if (string.find (_arg1, "#")) then | |
| 456 _arg1 = _arg1:gsub ("#","") | |
| 457 if (string.len (_arg1) == 8) then --alpha | |
| 458 _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 | |
| 459 else | |
| 460 _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 | |
| 461 end | |
| 462 | |
| 463 else | |
| 464 local color = DF.alias_text_colors [_arg1] | |
| 465 if (color) then | |
| 466 _arg1, _arg2, _arg3, _arg4 = _unpack (color) | |
| 467 else | |
| 468 _arg1, _arg2, _arg3, _arg4 = _unpack (DF.alias_text_colors.none) | |
| 469 end | |
| 470 end | |
| 471 end | |
| 472 | |
| 473 if (not _arg1) then | |
| 474 _arg1 = 1 | |
| 475 end | |
| 476 if (not _arg2) then | |
| 477 _arg2 = 1 | |
| 478 end | |
| 479 if (not _arg3) then | |
| 480 _arg3 = 1 | |
| 481 end | |
| 482 if (not _arg4) then | |
| 483 _arg4 = 1 | |
| 484 end | |
| 485 | |
| 486 return _arg1, _arg2, _arg3, _arg4 | |
| 487 end | |
| 488 | |
| 489 ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | |
| 490 --> menus | |
| 491 | |
| 492 function DF:BuildMenu (parent, menu, x_offset, y_offset, height) | |
| 493 | |
| 494 local cur_x = x_offset | |
| 495 local cur_y = y_offset | |
| 496 local max_x = 0 | |
| 497 | |
| 498 height = abs ((height or parent:GetHeight()) - abs (y_offset) + 20) | |
| 499 height = height*-1 | |
| 500 | |
| 501 for index, widget_table in ipairs (menu) do | |
| 502 | |
| 503 if (widget_table.type == "select" or widget_table.type == "dropdown") then | |
| 504 local dropdown = self:NewDropDown (parent, nil, "$parentWidget" .. index, nil, 140, 18, widget_table.values, widget_table.get()) | |
| 505 dropdown.tooltip = widget_table.desc | |
| 506 local label = self:NewLabel (parent, nil, "$parentLabel" .. index, nil, widget_table.name, "GameFontNormal", 12) | |
| 507 dropdown:SetPoint ("left", label, "right", 2) | |
| 508 label:SetPoint (cur_x, cur_y) | |
| 509 | |
| 510 local size = label.widget:GetStringWidth() + 140 + 4 | |
| 511 if (size > max_x) then | |
| 512 max_x = size | |
| 513 end | |
| 514 | |
| 515 elseif (widget_table.type == "toggle" or widget_table.type == "switch") then | |
| 516 local switch = self:NewSwitch (parent, nil, "$parentWidget" .. index, nil, 60, 20, nil, nil, widget_table.get()) | |
| 517 switch.tooltip = widget_table.desc | |
| 518 switch.OnSwitch = widget_table.set | |
| 519 | |
| 520 local label = self:NewLabel (parent, nil, "$parentLabel" .. index, nil, widget_table.name, "GameFontNormal", 12) | |
| 521 switch:SetPoint ("left", label, "right", 2) | |
| 522 label:SetPoint (cur_x, cur_y) | |
| 523 | |
| 524 local size = label.widget:GetStringWidth() + 60 + 4 | |
| 525 if (size > max_x) then | |
| 526 max_x = size | |
| 527 end | |
| 528 | |
| 529 elseif (widget_table.type == "range" or widget_table.type == "slider") then | |
| 530 local is_decimanls = widget_table.usedecimals | |
| 531 local slider = self:NewSlider (parent, nil, "$parentWidget" .. index, nil, 140, 20, widget_table.min, widget_table.max, widget_table.step, widget_table.get(), is_decimanls) | |
| 532 slider.tooltip = widget_table.desc | |
| 533 slider:SetHook ("OnValueChange", widget_table.set) | |
| 534 | |
| 535 local label = self:NewLabel (parent, nil, "$parentLabel" .. index, nil, widget_table.name, "GameFontNormal", 12) | |
| 536 slider:SetPoint ("left", label, "right", 2) | |
| 537 label:SetPoint (cur_x, cur_y) | |
| 538 | |
| 539 local size = label.widget:GetStringWidth() + 140 + 6 | |
| 540 if (size > max_x) then | |
| 541 max_x = size | |
| 542 end | |
| 543 | |
| 544 elseif (widget_table.type == "color" or widget_table.type == "color") then | |
| 545 local colorpick = self:NewColorPickButton (parent, "$parentWidget" .. index, nil, widget_table.set) | |
| 546 colorpick.tooltip = widget_table.desc | |
| 547 | |
| 548 local default_value, g, b, a = widget_table.get() | |
| 549 if (type (default_value) == "table") then | |
| 550 colorpick:SetColor (unpack (default_value)) | |
| 551 else | |
| 552 colorpick:SetColor (default_value, g, b, a) | |
| 553 end | |
| 554 | |
| 555 local label = self:NewLabel (parent, nil, "$parentLabel" .. index, nil, widget_table.name, "GameFontNormal", 12) | |
| 556 colorpick:SetPoint ("left", label, "right", 2) | |
| 557 label:SetPoint (cur_x, cur_y) | |
| 558 | |
| 559 local size = label.widget:GetStringWidth() + 60 + 4 | |
| 560 if (size > max_x) then | |
| 561 max_x = size | |
| 562 end | |
| 563 | |
| 564 elseif (widget_table.type == "execute" or widget_table.type == "button") then | |
| 565 | |
| 566 local button = self:NewButton (parent, nil, "$parentWidget", nil, 120, 18, widget_table.func, widget_table.param1, widget_table.param2, nil, widget_table.name) | |
| 567 button:InstallCustomTexture() | |
| 568 button:SetPoint (cur_x, cur_y) | |
| 569 button.tooltip = widget_table.desc | |
| 570 | |
| 571 local size = button:GetWidth() + 4 | |
| 572 if (size > max_x) then | |
| 573 max_x = size | |
| 574 end | |
| 575 | |
| 576 end | |
| 577 | |
| 578 if (widget_table.spacement) then | |
| 579 cur_y = cur_y - 30 | |
| 580 else | |
| 581 cur_y = cur_y - 20 | |
| 582 end | |
| 583 | |
| 584 if (cur_y < height) then | |
| 585 cur_y = y_offset | |
| 586 cur_x = cur_x + max_x + 30 | |
| 587 | |
| 588 max_x = 0 | |
| 589 end | |
| 590 | |
| 591 end | |
| 592 | |
| 593 end | |
| 594 | |
| 595 ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | |
| 596 --> tutorials | |
| 597 | |
| 598 function DF:ShowTutorialAlertFrame (maintext, desctext, clickfunc) | |
| 599 | |
| 600 local TutorialAlertFrame = _G.DetailsFrameworkTutorialAlertFrame | |
| 601 | |
| 602 if (not TutorialAlertFrame) then | |
| 603 | |
| 604 TutorialAlertFrame = CreateFrame ("ScrollFrame", "DetailsFrameworkTutorialAlertFrame", UIParent, "DetailsFrameworkTutorialAlertFrameTemplate") | |
| 605 TutorialAlertFrame.isFirst = true | |
| 606 TutorialAlertFrame:SetPoint ("left", UIParent, "left", -20, 100) | |
| 607 | |
| 608 TutorialAlertFrame:SetWidth (290) | |
| 609 TutorialAlertFrame.ScrollChild:SetWidth (256) | |
| 610 | |
| 611 local scrollname = TutorialAlertFrame.ScrollChild:GetName() | |
| 612 _G [scrollname .. "BorderTopLeft"]:SetVertexColor (1, 0.8, 0, 1) | |
| 613 _G [scrollname .. "BorderTopRight"]:SetVertexColor (1, 0.8, 0, 1) | |
| 614 _G [scrollname .. "BorderBotLeft"]:SetVertexColor (1, 0.8, 0, 1) | |
| 615 _G [scrollname .. "BorderBotRight"]:SetVertexColor (1, 0.8, 0, 1) | |
| 616 _G [scrollname .. "BorderLeft"]:SetVertexColor (1, 0.8, 0, 1) | |
| 617 _G [scrollname .. "BorderRight"]:SetVertexColor (1, 0.8, 0, 1) | |
| 618 _G [scrollname .. "BorderBottom"]:SetVertexColor (1, 0.8, 0, 1) | |
| 619 _G [scrollname .. "BorderTop"]:SetVertexColor (1, 0.8, 0, 1) | |
| 620 | |
| 621 local iconbg = _G [scrollname .. "QuestIconBg"] | |
| 622 iconbg:SetTexture ([[Interface\MainMenuBar\UI-MainMenuBar-EndCap-Human]]) | |
| 623 iconbg:SetTexCoord (0, 1, 0, 1) | |
| 624 iconbg:SetSize (100, 100) | |
| 625 iconbg:ClearAllPoints() | |
| 626 iconbg:SetPoint ("bottomleft", TutorialAlertFrame.ScrollChild, "bottomleft") | |
| 627 | |
| 628 _G [scrollname .. "Exclamation"]:SetVertexColor (1, 0.8, 0, 1) | |
| 629 _G [scrollname .. "QuestionMark"]:SetVertexColor (1, 0.8, 0, 1) | |
| 630 | |
| 631 _G [scrollname .. "TopText"]:SetText ("Details!") --string | |
| 632 _G [scrollname .. "QuestName"]:SetText ("") --string | |
| 633 _G [scrollname .. "BottomText"]:SetText ("") --string | |
| 634 | |
| 635 TutorialAlertFrame.ScrollChild.IconShine:SetTexture ([[Interface\MainMenuBar\UI-MainMenuBar-EndCap-Human]]) | |
| 636 | |
| 637 TutorialAlertFrame:SetScript ("OnMouseUp", function (self) | |
| 638 if (self.clickfunc and type (self.clickfunc) == "function") then | |
| 639 self.clickfunc() | |
| 640 end | |
| 641 self:Hide() | |
| 642 end) | |
| 643 TutorialAlertFrame:Hide() | |
| 644 end | |
| 645 | |
| 646 if (type (maintext) == "string") then | |
| 647 TutorialAlertFrame.ScrollChild.QuestName:SetText (maintext) | |
| 648 else | |
| 649 TutorialAlertFrame.ScrollChild.QuestName:SetText ("") | |
| 650 end | |
| 651 | |
| 652 if (type (desctext) == "string") then | |
| 653 TutorialAlertFrame.ScrollChild.BottomText:SetText (desctext) | |
| 654 else | |
| 655 TutorialAlertFrame.ScrollChild.BottomText:SetText ("") | |
| 656 end | |
| 657 | |
| 658 TutorialAlertFrame.clickfunc = clickfunc | |
| 659 TutorialAlertFrame:Show() | |
| 660 DetailsTutorialAlertFrame_SlideInFrame (TutorialAlertFrame, "AUTOQUEST") | |
| 661 end | |
| 662 | |
| 663 function DF:CreateOptionsFrame (name, title, template) | |
| 664 | |
| 665 template = template or 1 | |
| 666 | |
| 667 if (template == 2) then | |
| 668 local options_frame = CreateFrame ("frame", name, UIParent, "ButtonFrameTemplate") | |
| 669 tinsert (UISpecialFrames, name) | |
| 670 options_frame:SetSize (500, 200) | |
| 671 | |
| 672 options_frame:SetScript ("OnMouseDown", function(self, button) | |
| 673 if (button == "RightButton") then | |
| 674 if (self.moving) then | |
| 675 self.moving = false | |
| 676 self:StopMovingOrSizing() | |
| 677 end | |
| 678 return options_frame:Hide() | |
| 679 elseif (button == "LeftButton" and not self.moving) then | |
| 680 self.moving = true | |
| 681 self:StartMoving() | |
| 682 end | |
| 683 end) | |
| 684 options_frame:SetScript ("OnMouseUp", function(self) | |
| 685 if (self.moving) then | |
| 686 self.moving = false | |
| 687 self:StopMovingOrSizing() | |
| 688 end | |
| 689 end) | |
| 690 | |
| 691 options_frame:SetMovable (true) | |
| 692 options_frame:EnableMouse (true) | |
| 693 options_frame:SetFrameStrata ("DIALOG") | |
| 694 options_frame:SetToplevel (true) | |
| 695 | |
| 696 options_frame:Hide() | |
| 697 | |
| 698 options_frame:SetPoint ("center", UIParent, "center") | |
| 699 options_frame.TitleText:SetText (title) | |
| 700 options_frame.portrait:SetTexture ([[Interface\CHARACTERFRAME\TEMPORARYPORTRAIT-FEMALE-BLOODELF]]) | |
| 701 | |
| 702 return options_frame | |
| 703 | |
| 704 elseif (template == 1) then | |
| 705 | |
| 706 local options_frame = CreateFrame ("frame", name, UIParent) | |
| 707 tinsert (UISpecialFrames, name) | |
| 708 options_frame:SetSize (500, 200) | |
| 709 | |
| 710 options_frame:SetScript ("OnMouseDown", function(self, button) | |
| 711 if (button == "RightButton") then | |
| 712 if (self.moving) then | |
| 713 self.moving = false | |
| 714 self:StopMovingOrSizing() | |
| 715 end | |
| 716 return options_frame:Hide() | |
| 717 elseif (button == "LeftButton" and not self.moving) then | |
| 718 self.moving = true | |
| 719 self:StartMoving() | |
| 720 end | |
| 721 end) | |
| 722 options_frame:SetScript ("OnMouseUp", function(self) | |
| 723 if (self.moving) then | |
| 724 self.moving = false | |
| 725 self:StopMovingOrSizing() | |
| 726 end | |
| 727 end) | |
| 728 | |
| 729 options_frame:SetMovable (true) | |
| 730 options_frame:EnableMouse (true) | |
| 731 options_frame:SetFrameStrata ("DIALOG") | |
| 732 options_frame:SetToplevel (true) | |
| 733 | |
| 734 options_frame:Hide() | |
| 735 | |
| 736 options_frame:SetPoint ("center", UIParent, "center") | |
| 737 | |
| 738 options_frame:SetBackdrop ({bgFile = "Interface\\Tooltips\\UI-Tooltip-Background", tile = true, tileSize = 16, | |
| 739 edgeFile = [[Interface\AddOns\Details\images\border_2]], edgeSize = 32, | |
| 740 insets = {left = 1, right = 1, top = 1, bottom = 1}}) | |
| 741 options_frame:SetBackdropColor (0, 0, 0, .7) | |
| 742 | |
| 743 local texturetitle = options_frame:CreateTexture (nil, "artwork") | |
| 744 texturetitle:SetTexture ([[Interface\CURSOR\Interact]]) | |
| 745 texturetitle:SetTexCoord (0, 1, 0, 1) | |
| 746 texturetitle:SetVertexColor (1, 1, 1, 1) | |
| 747 texturetitle:SetPoint ("topleft", options_frame, "topleft", 2, -3) | |
| 748 texturetitle:SetWidth (36) | |
| 749 texturetitle:SetHeight (36) | |
| 750 | |
| 751 local title = DF:NewLabel (options_frame, nil, "$parentTitle", nil, title, nil, 20, "yellow") | |
| 752 title:SetPoint ("left", texturetitle, "right", 2, -1) | |
| 753 DF:SetFontOutline (title, true) | |
| 754 | |
| 755 local c = CreateFrame ("Button", nil, options_frame, "UIPanelCloseButton") | |
| 756 c:SetWidth (32) | |
| 757 c:SetHeight (32) | |
| 758 c:SetPoint ("TOPRIGHT", options_frame, "TOPRIGHT", -3, -3) | |
| 759 c:SetFrameLevel (options_frame:GetFrameLevel()+1) | |
| 760 | |
| 761 return options_frame | |
| 762 end | |
| 763 end |
