Guest User

Untitled

a guest
Jul 15th, 2026
686
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.73 KB | None | 0 0
  1. --[[
  2. Copyright (C) 2006-2007 Nymbia
  3. Copyright (C) 2010-2017 Hendrik "Nevcairiel" Leppkes < [email protected] >
  4.  
  5. This program is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation; either version 2 of the License, or
  8. (at your option) any later version.
  9.  
  10. This program is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. GNU General Public License for more details.
  14.  
  15. You should have received a copy of the GNU General Public License along
  16. with this program; if not, write to the Free Software Foundation, Inc.,
  17. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  18. ]]
  19. local Quartz3 = LibStub("AceAddon-3.0"):GetAddon("Quartz3")
  20. local L = LibStub("AceLocale-3.0"):GetLocale("Quartz3")
  21. local media = LibStub("LibSharedMedia-3.0")
  22. local LibDualSpec = LibStub("LibDualSpec-1.0", true)
  23.  
  24. ----------------------------
  25. -- Upvalues
  26. -- GLOBALS: LibStub, InterfaceOptionsFrame_OpenToCategory
  27. local pairs, unpack, type = pairs, unpack, type
  28.  
  29. local getOpt, setOpt, getColor, setColor
  30. do
  31. function getOpt(info)
  32. local key = info[#info]
  33. return Quartz3.db.profile[key]
  34. end
  35.  
  36. function setOpt(info, value)
  37. local key = info[#info]
  38. Quartz3.db.profile[key] = value
  39. Quartz3:ApplySettings()
  40. end
  41.  
  42. function getColor(info)
  43. return unpack(getOpt(info))
  44. end
  45.  
  46. function setColor(info, r, g, b, a)
  47. setOpt(info, {r, g, b, a})
  48. end
  49. end
  50.  
  51. local options, moduleOptions = nil, {}
  52. local function getOptions()
  53. if not options then
  54. options = {
  55. type = "group",
  56. args = {
  57. general = {
  58. type = "group",
  59. inline = true,
  60. name = "",
  61. args = {
  62. unlock = {
  63. type = "execute",
  64. name = L["Toggle Bar Lock"],
  65. desc = L["Unlock the Bars to be able to move them around."],
  66. func = function()
  67. Quartz3:ToggleLock(true)
  68. end,
  69. order = 50,
  70. },
  71. nllock = {
  72. type = "description",
  73. name = "",
  74. order = 51,
  75. },
  76. hidesamwise = {
  77. type = "toggle",
  78. name = L["Hide Samwise Icon"],
  79. desc = L["Hide the icon for spells with no icon"],
  80. order = 101,
  81. get = getOpt,
  82. set = setOpt,
  83. },
  84. casttimeprecision = {
  85. type = "range",
  86. name = L["Cast Time Precision"],
  87. desc = L["Number of decimals to show for the Cast Time"],
  88. min = 0, max = 3, step = 1,
  89. get = getOpt,
  90. set = setOpt,
  91. order = 102,
  92. },
  93. colors = {
  94. type = "group",
  95. name = L["Colors"],
  96. desc = L["Colors"],
  97. guiInline = true,
  98. order = 450,
  99. get = getColor,
  100. set = setColor,
  101. args = {
  102. spelltextcolor = {
  103. type = "color",
  104. name = L["Spell Text"],
  105. desc = L["Set the color of the %s"]:format(L["Spell Text"]),
  106. order = 98,
  107. },
  108. timetextcolor = {
  109. type = "color",
  110. name = L["Time Text"],
  111. desc = L["Set the color of the %s"]:format(L["Time Text"]),
  112. order = 98,
  113. },
  114. header = {
  115. type = "header",
  116. name = "",
  117. order = 99,
  118. },
  119. castingcolor = {
  120. type = "color",
  121. name = L["Casting"],
  122. desc = L["Set the color of the cast bar when %s"]:format(L["Casting"]),
  123. },
  124. channelingcolor = {
  125. type = "color",
  126. name = L["Channeling"],
  127. desc = L["Set the color of the cast bar when %s"]:format(L["Channeling"]),
  128. },
  129. completecolor = {
  130. type = "color",
  131. name = L["Complete"],
  132. desc = L["Set the color of the cast bar when %s"]:format(L["Complete"]),
  133. },
  134. failcolor = {
  135. type = "color",
  136. name = L["Failed"],
  137. desc = L["Set the color of the cast bar when %s"]:format(L["Failed"]),
  138. },
  139. sparkcolor = {
  140. type = "color",
  141. name = L["Spark Color"],
  142. desc = L["Set the color of the casting bar spark"],
  143. hasAlpha = true,
  144. },
  145. nl1 = {
  146. type = "description",
  147. name = "",
  148. order = 101,
  149. },
  150. backgroundcolor = {
  151. type = "color",
  152. name = L["Background"],
  153. desc = L["Set the color of the casting bar background"],
  154. order = 102,
  155. },
  156. backgroundalpha = {
  157. type = "range",
  158. name = L["Background Alpha"],
  159. desc = L["Set the alpha of the casting bar background"],
  160. isPercent = true,
  161. min = 0, max = 1, bigStep = 0.025,
  162. get = getOpt,
  163. set = setOpt,
  164. order = 103,
  165. },
  166. bordercolor = {
  167. type = "color",
  168. name = L["Border"],
  169. desc = L["Set the color of the casting bar border"],
  170. order = 104,
  171. },
  172. borderalpha = {
  173. type = "range",
  174. name = L["Border Alpha"],
  175. desc = L["Set the alpha of the casting bar border"],
  176. isPercent = true,
  177. min = 0, max = 1, bigStep = 0.025,
  178. get = getOpt,
  179. set = setOpt,
  180. order = 105,
  181. },
  182. },
  183. },
  184. },
  185. },
  186. },
  187. }
  188. for k,v in pairs(moduleOptions) do
  189. options.args[k] = (type(v) == "function") and v() or v
  190. end
  191. end
  192. return options
  193. end
  194.  
  195. function Quartz3:ChatCommand(input)
  196. if not input or input:trim() == "" then
  197. if InterfaceOptionsFrame_OpenToCategory then
  198. InterfaceOptionsFrame_OpenToCategory(Quartz3.optFrames.Profiles)
  199. InterfaceOptionsFrame_OpenToCategory(Quartz3.optFrames.Quartz3)
  200. else
  201. Settings.OpenToCategory(self.optionsCategoryID)
  202. end
  203. else
  204. LibStub("AceConfigCmd-3.0").HandleCommand(Quartz3, "quartz", "Quartz3", input)
  205. end
  206. end
  207.  
  208. function Quartz3:SetupOptions()
  209. self.optFrames = {}
  210. LibStub("AceConfigRegistry-3.0"):RegisterOptionsTable("Quartz3", getOptions)
  211. self.optFrames.Quartz3, self.optionsCategoryID = LibStub("AceConfigDialog-3.0"):AddToBlizOptions("Quartz3", "Quartz 3", nil, "general")
  212. self:RegisterChatCommand("quartz", "ChatCommand")
  213. self:RegisterChatCommand("q3", "ChatCommand")
  214.  
  215. local profileOptions = LibStub("AceDBOptions-3.0"):GetOptionsTable(self.db)
  216. if LibDualSpec then
  217. LibDualSpec:EnhanceDatabase(self.db, "Quartz3")
  218. LibDualSpec:EnhanceOptions(profileOptions, self.db)
  219. end
  220.  
  221. self:RegisterModuleOptions("Profiles", profileOptions, "Profiles")
  222. end
  223.  
  224. function Quartz3:RegisterModuleOptions(name, optTable, displayName)
  225. moduleOptions[name] = optTable
  226. self.optFrames[name] = LibStub("AceConfigDialog-3.0"):AddToBlizOptions("Quartz3", displayName or name, "Quartz 3", name)
  227. end
  228.  
Advertisement
Add Comment
Please, Sign In to add comment