/Tukui/core/deprecated.lua

http://github.com/Asphyxia/Tukui · Lua · 150 lines · 124 code · 14 blank · 12 comment · 5 complexity · 15bc15ff526dbfe7c917b917366aac36 MD5 · raw file

  1. --[[
  2. In computer software or authoring programs standards and documentation,
  3. the term deprecation is applied to software features that are superseded
  4. and should be avoided. Although deprecated features remain in the current
  5. version, their use may raise warning messages recommending alternative practices,
  6. and deprecation may indicate that the feature will be removed in the future.
  7. Features are deprecatedrather than being removedin order to provide
  8. backward compatibility and give programmers who have used the feature time to
  9. bring their code into compliance with the new standard.
  10. --]]
  11. local T, C, L = unpack(select(2, ...)) -- Import: T - functions, constants, variables; C - config; L - locales
  12. -- pixel perfect script of custom ui scale.
  13. local mult = 768/string.match(GetCVar("gxResolution"), "%d+x(%d+)")/C["general"].uiscale
  14. local scale = function(x)
  15. return mult*math.floor(x/mult+.5)
  16. end
  17. T.Scale = function(x) return scale(x) end
  18. T.mult = mult
  19. T.CreatePanel = function(f, w, h, a1, p, a2, x, y)
  20. local sh = scale(h)
  21. local sw = scale(w)
  22. f:SetFrameLevel(1)
  23. f:SetHeight(sh)
  24. f:SetWidth(sw)
  25. f:SetFrameStrata("BACKGROUND")
  26. f:SetPoint(a1, p, a2, x, y)
  27. f:SetBackdrop({
  28. bgFile = C["media"].blank,
  29. edgeFile = C["media"].blank,
  30. tile = false, tileSize = 0, edgeSize = mult,
  31. insets = { left = -mult, right = -mult, top = -mult, bottom = -mult}
  32. })
  33. f:SetBackdropColor(unpack(C["media"].backdropcolor))
  34. f:SetBackdropBorderColor(unpack(C["media"].bordercolor))
  35. end
  36. T.CreateTransparentPanel = function(f, w, h, a1, p, a2, x, y)
  37. if t == "Tukui" then
  38. local sh = Scale(h)
  39. local sw = Scale(w)
  40. f:SetFrameLevel(1)
  41. f:SetHeight(sh)
  42. f:SetWidth(sw)
  43. f:SetFrameStrata("BACKGROUND")
  44. f:SetPoint(a1, p, a2, x, y)
  45. f:SetBackdrop({
  46. bgFile = C["media"].blank,
  47. edgeFile = C["media"].blank,
  48. tile = false, tileSize = 0, edgeSize = mult,
  49. insets = { left = T.Scale(2), right = T.Scale(2), top = T.Scale(2), bottom = T.Scale(2)}
  50. })
  51. f:SetBackdropColor(.075,.075,.075,.8) -- (red, green, blue, alpha)
  52. f:SetBackdropBorderColor(unpack(C["media"].bordercolor))
  53. local border = CreateFrame("Frame", nil, f)
  54. border:SetFrameLevel(0)
  55. border:SetPoint("TOPLEFT", f, "TOPLEFT", T.Scale(-1), T.Scale(1))
  56. border:SetFrameStrata("BACKGROUND")
  57. border:SetBackdrop {
  58. edgeFile = C["media"].blank, edgeSize = T.Scale(3),
  59. insets = {left = 0, right = 0, top = 0, bottom = 0}
  60. }
  61. border:SetBackdropColor(unpack(C["media"].backdropcolor))
  62. border:SetBackdropBorderColor(unpack(C["media"].backdropcolor))
  63. border:SetPoint("BOTTOMRIGHT", f, "BOTTOMRIGHT", T.Scale(1), T.Scale(-1))
  64. end
  65. end
  66. T.SetTemplate = function(f)
  67. f:SetBackdrop({
  68. bgFile = C["media"].blank,
  69. edgeFile = C["media"].blank,
  70. tile = false, tileSize = 0, edgeSize = mult,
  71. insets = { left = -mult, right = -mult, top = -mult, bottom = -mult}
  72. })
  73. f:SetBackdropColor(unpack(C["media"].backdropcolor))
  74. f:SetBackdropBorderColor(unpack(C["media"].bordercolor))
  75. end
  76. T.CreateShadow = function(f)
  77. if f.shadow then return end -- we seriously don't want to create shadow 2 times in a row on the same frame.
  78. local shadow = CreateFrame("Frame", nil, f)
  79. shadow:SetFrameLevel(1)
  80. shadow:SetFrameStrata(f:GetFrameStrata())
  81. shadow:SetPoint("TOPLEFT", T.Scale(-4), T.Scale(4))
  82. shadow:SetPoint("BOTTOMLEFT", T.Scale(-4), T.Scale(-4))
  83. shadow:SetPoint("TOPRIGHT", T.Scale(4), T.Scale(4))
  84. shadow:SetPoint("BOTTOMRIGHT", T.Scale(4), T.Scale(-4))
  85. shadow:SetBackdrop( {
  86. edgeFile = C["media"].glowTex, edgeSize = T.Scale(3),
  87. insets = {left = T.Scale(5), right = T.Scale(5), top = T.Scale(5), bottom = T.Scale(5)},
  88. })
  89. shadow:SetBackdropColor(0, 0, 0, 0)
  90. shadow:SetBackdropBorderColor(0, 0, 0, 0.5)
  91. f.shadow = shadow
  92. end
  93. T.Kill = function(object)
  94. if object.UnregisterAllEvents then
  95. object:UnregisterAllEvents()
  96. end
  97. object.Show = T.dummy
  98. object:Hide()
  99. end
  100. -- styleButton function authors are Chiril & Karudon.
  101. T.StyleButton = function(b, checked)
  102. local name = b:GetName()
  103. local button = _G[name]
  104. local icon = _G[name.."Icon"]
  105. local count = _G[name.."Count"]
  106. local border = _G[name.."Border"]
  107. local hotkey = _G[name.."HotKey"]
  108. local cooldown = _G[name.."Cooldown"]
  109. local nametext = _G[name.."Name"]
  110. local flash = _G[name.."Flash"]
  111. local normaltexture = _G[name.."NormalTexture"]
  112. local icontexture = _G[name.."IconTexture"]
  113. local hover = b:CreateTexture("frame", nil, self) -- hover
  114. hover:SetTexture(1,1,1,0.3)
  115. hover:SetHeight(button:GetHeight())
  116. hover:SetWidth(button:GetWidth())
  117. hover:Point("TOPLEFT",button,2,-2)
  118. hover:Point("BOTTOMRIGHT",button,-2,2)
  119. button:SetHighlightTexture(hover)
  120. local pushed = b:CreateTexture("frame", nil, self) -- pushed
  121. pushed:SetTexture(0.9,0.8,0.1,0.3)
  122. pushed:SetHeight(button:GetHeight())
  123. pushed:SetWidth(button:GetWidth())
  124. pushed:Point("TOPLEFT",button,2,-2)
  125. pushed:Point("BOTTOMRIGHT",button,-2,2)
  126. button:SetPushedTexture(pushed)
  127. if checked then
  128. local checked = b:CreateTexture("frame", nil, self) -- checked
  129. checked:SetTexture(0,1,0,0.3)
  130. checked:SetHeight(button:GetHeight())
  131. checked:SetWidth(button:GetWidth())
  132. checked:Point("TOPLEFT",button,2,-2)
  133. checked:Point("BOTTOMRIGHT",button,-2,2)
  134. button:SetCheckedTexture(checked)
  135. end
  136. end