Advertisement
Guest User

BasicUI.lua

a guest
Apr 27th, 2014
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.62 KB | None | 0 0
  1. local ADDON_NAME = LibStub("AceAddon-3.0"):NewAddon("BasicUI")
  2.  
  3. local L = setmetatable({}, { __index = function(t,k)
  4. local v = tostring(k)
  5. rawset(t, k, v)
  6. return v
  7. end })
  8.  
  9. local db
  10. local defaults = {
  11. profile = {
  12. media = {
  13. fontNormal = [[Interface\Addons\BasicUI\Media\NORMAL.ttf]],
  14. fontBold = [[Interface\Addons\BasicUI\Media\BOLD.ttf]],
  15. fontItalic = [[Interface\Addons\BasicUI\Media\ITALIC.ttf]],
  16. fontBoldItalic = [[Interface\Addons\BasicUI\Media\BOLDITALIC.ttf]],
  17. fontNumber = [[Interface\Addons\BasicUI\Media\NUMBER.ttf]],
  18. fontSize = 15,
  19. classcolor = true,
  20. },
  21. modules = {
  22. ["*"] = true,
  23. }
  24. }
  25. }
  26.  
  27. function ADDON_NAME:OnInitialize()
  28. self.db = LibStub("AceDB-3.0"):New("BasicDB", defaults, true) -- true is important!
  29. db = self.db.profile
  30.  
  31. self.db.RegisterCallback(self, "OnProfileChanged", "Refresh")
  32. self.db.RegisterCallback(self, "OnProfileCopied", "Refresh")
  33. self.db.RegisterCallback(self, "OnProfileReset", "Refresh")
  34.  
  35. local Dialog = LibStub("AceConfigDialog-3.0")
  36.  
  37. local options = self:GetOptions()
  38. LibStub("AceConfigRegistry-3.0"):RegisterOptionsTable("BasicUI", options)
  39. Dialog:AddToBlizOptions("BasicUI", nil, nil, "media")
  40.  
  41. for k, v in self:IterateModules() do
  42. if type(v.GetOptions) == "function" then
  43. options.args[k] = v:GetOptions()
  44. Dialog:AddToBlizOptions("BasicUI", options.args[k].name, "BasicUI", k)
  45. end
  46. end
  47.  
  48. options.args.profile = LibStub("AceDBOptions-3.0"):GetOptionsTable(self.db)
  49. options.args.profile.order = -1
  50. Dialog:AddToBlizOptions("BasicUI", options.args.profile.name, "BasicUI", "profile")
  51. end
  52.  
  53. function ADDON_NAME:OnEnable()
  54. -- set up stuff here
  55.  
  56. db = self.db.profile
  57.  
  58. SlashCmdList['RELOADUI'] = function()
  59. ReloadUI()
  60. end
  61. SLASH_RELOADUI1 = '/rl'
  62.  
  63. local function SetFont(obj, font, size, style, r, g, b, sr, sg, sb, sox, soy)
  64. obj:SetFont(font, size, style)
  65. if sr and sg and sb then obj:SetShadowColor(sr, sg, sb) end
  66. if sox and soy then obj:SetShadowOffset(sox, soy) end
  67. if r and g and b then obj:SetTextColor(r, g, b)
  68. elseif r then obj:SetAlpha(r) end
  69. end
  70.  
  71. local NORMAL = db.media.fontNormal
  72. local BOLD = db.media.fontBold
  73. local BOLDITALIC = db.media.fontBoldItalic
  74. local ITALIC = db.media.fontItalic
  75. local NUMBER = db.media.fontNormal
  76.  
  77. UIDROPDOWNMENU_DEFAULT_TEXT_HEIGHT = 15
  78. CHAT_FONT_HEIGHTS = {7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24}
  79.  
  80. UNIT_NAME_FONT = NORMAL
  81. DAMAGE_TEXT_FONT = NUMBER
  82. STANDARD_TEXT_FONT = NORMAL
  83.  
  84. -- Base fonts
  85. SetFont(AchievementFont_Small, BOLD, db.media.fontSize)
  86. SetFont(FriendsFont_Large, NORMAL, db.media.fontSize, nil, nil, nil, nil, 0, 0, 0, 1, -1)
  87. SetFont(FriendsFont_Normal, NORMAL, db.media.fontSize, nil, nil, nil, nil, 0, 0, 0, 1, -1)
  88. SetFont(FriendsFont_Small, NORMAL, db.media.fontSize, nil, nil, nil, nil, 0, 0, 0, 1, -1)
  89. SetFont(FriendsFont_UserText, NUMBER, db.media.fontSize, nil, nil, nil, nil, 0, 0, 0, 1, -1)
  90. SetFont(GameTooltipHeader, BOLD, db.media.fontSize, "OUTLINE")
  91. SetFont(GameFont_Gigantic, BOLD, 32, nil, nil, nil, nil, 0, 0, 0, 1, -1)
  92. SetFont(InvoiceFont_Med, ITALIC, db.media.fontSize, nil, 0.15, 0.09, 0.04)
  93. SetFont(InvoiceFont_Small, ITALIC, db.media.fontSize, nil, 0.15, 0.09, 0.04)
  94. SetFont(MailFont_Large, ITALIC, db.media.fontSize, nil, 0.15, 0.09, 0.04, 0.54, 0.4, 0.1, 1, -1)
  95. SetFont(NumberFont_OutlineThick_Mono_Small, NUMBER, db.media.fontSize, "OUTLINE")
  96. SetFont(NumberFont_Outline_Huge, NUMBER, 30, "THICKOUTLINE", 30)
  97. SetFont(NumberFont_Outline_Large, NUMBER, 17, "OUTLINE")
  98. SetFont(NumberFont_Outline_Med, NUMBER, db.media.fontSize, "OUTLINE")
  99. SetFont(NumberFont_Shadow_Med, NORMAL, db.media.fontSize)
  100. SetFont(NumberFont_Shadow_Small, NORMAL, db.media.fontSize)
  101. SetFont(QuestFont_Shadow_Small, NORMAL, 16)
  102. SetFont(QuestFont_Large, NORMAL, 16)
  103. SetFont(QuestFont_Shadow_Huge, BOLD, 19, nil, nil, nil, nil, 0.54, 0.4, 0.1)
  104. SetFont(QuestFont_Super_Huge, BOLD, 24)
  105. SetFont(ReputationDetailFont, BOLD, db.media.fontSize, nil, nil, nil, nil, 0, 0, 0, 1, -1)
  106. SetFont(SpellFont_Small, BOLD, db.media.fontSize)
  107. SetFont(SystemFont_InverseShadow_Small, BOLD, db.media.fontSize)
  108. SetFont(SystemFont_Large, NORMAL, 17)
  109. SetFont(SystemFont_Med1, NORMAL, db.media.fontSize)
  110. SetFont(SystemFont_Med2, ITALIC, db.media.fontSize, nil, 0.15, 0.09, 0.04)
  111. SetFont(SystemFont_Med3, NORMAL, db.media.fontSize)
  112. SetFont(SystemFont_OutlineThick_Huge2, NORMAL, 22, "THICKOUTLINE")
  113. SetFont(SystemFont_OutlineThick_Huge4, BOLDITALIC, 27, "THICKOUTLINE")
  114. SetFont(SystemFont_OutlineThick_WTF, BOLDITALIC, 31, "THICKOUTLINE", nil, nil, nil, 0, 0, 0, 1, -1)
  115. SetFont(SystemFont_Outline_Small, NUMBER, db.media.fontSize, "OUTLINE")
  116. SetFont(SystemFont_Shadow_Huge1, BOLD, 20)
  117. SetFont(SystemFont_Shadow_Huge3, BOLD, 25)
  118. SetFont(SystemFont_Shadow_Large, NORMAL, 17)
  119. SetFont(SystemFont_Shadow_Med1, NORMAL, db.media.fontSize)
  120. SetFont(SystemFont_Shadow_Med2, NORMAL, db.media.fontSize)
  121. SetFont(SystemFont_Shadow_Med3, NORMAL, db.media.fontSize)
  122. SetFont(SystemFont_Shadow_Outline_Huge2, NORMAL, 22, "OUTLINE")
  123. SetFont(SystemFont_Shadow_Small, BOLD, db.media.fontSize)
  124. SetFont(SystemFont_Small, NORMAL, db.media.fontSize)
  125. SetFont(SystemFont_Tiny, NORMAL, db.media.fontSize)
  126. SetFont(ChatBubbleFont, NORMAL, db.media.fontSize)
  127.  
  128.  
  129. -- Derived fonts
  130. SetFont(BossEmoteNormalHuge, BOLDITALIC, 27, "THICKOUTLINE")
  131. SetFont(CombatTextFont, NORMAL, 26)
  132. SetFont(ErrorFont, ITALIC, 16, nil, 60)
  133. SetFont(QuestFontNormalSmall, BOLD, db.media.fontSize, nil, nil, nil, nil, 0.54, 0.4, 0.1)
  134. SetFont(WorldMapTextFont, BOLDITALIC, 31, "THICKOUTLINE", 40, nil, nil, 0, 0, 0, 1, -1)
  135. end
  136.  
  137. function ADDON_NAME:Refresh()
  138. db = self.db.profile -- update the upvalue to point to the new profile
  139.  
  140. -- change stuff here
  141.  
  142. for k, v in self:IterateModules() do
  143. local isEnabled, shouldEnable = v:IsEnabled(), self:GetModuleEnabled(k)
  144. if shouldEnable and not isEnabled then
  145. self:EnableModule(k)
  146. elseif isEnabled and not shouldEnable then
  147. self:DisableModule(k)
  148. end
  149. if type(v.Refresh) == "function" then
  150. v:Refresh()
  151. end
  152. end
  153. end
  154.  
  155. function ADDON_NAME:GetModuleEnabled(moduleName)
  156. return db.modules[moduleName]
  157. end
  158.  
  159. function ADDON_NAME:SetModuleEnabled(moduleName, newState)
  160. local oldState = db.modules[moduleName]
  161. if oldState == newState then return end
  162. if newState then
  163. self:EnableModule(moduleName)
  164. else
  165. self:DisableModule(moduleName)
  166. end
  167. end
  168.  
  169. local options
  170. function ADDON_NAME:GetOptions()
  171. options = options or {
  172. type = "group",
  173. name = "BasicUI",
  174. args = {
  175. media = { -- @PHANX: moved all the "welcome" text into a group, you'll see why later
  176. type = "group",
  177. order = 1,
  178. name = "Media",
  179. get = function(info) return db.media[ info[#info] ] end,
  180. set = function(info, value) db.media[ info[#info] ] = value; end,
  181. args = {
  182. Text = {
  183. type = "description",
  184. order = 0,
  185. name = L["Welcome to |cff00B4FFBasic|rUI Config Area!"],
  186. width = "full",
  187. fontSize = "large",
  188. },
  189. Text2 = {
  190. type = "description",
  191. order = 1,
  192. name = L[" "],
  193. width = "full",
  194. },
  195. Text3 = {
  196. type = "description",
  197. order = 2,
  198. name = L["Special Thanks for |cff00B4FFBasic|rUI goes out to: "],
  199. width = "full",
  200. fontSize = "medium",
  201. },
  202. Text4 = {
  203. type = "description",
  204. order = 3,
  205. name = L["Phanx, Neav, Tuks, Elv, Baine, Treeston, and many more."],
  206. width = "full",
  207. fontSize = "large",
  208. },
  209. Text5 = {
  210. type = "description",
  211. order = 4,
  212. name = L[" "],
  213. width = "full",
  214. fontSize = "medium",
  215. },
  216. Text6 = {
  217. type = "description",
  218. order = 5,
  219. name = L["Thank you all for your AddOns, coding help, and support in creating |cff00B4FFBasic|rUI."],
  220. width = "full",
  221. fontSize = "medium",
  222. },
  223. Text7 = {
  224. type = "description",
  225. order = 6,
  226. name = L[" "],
  227. width = "full",
  228. fontSize = "medium",
  229. },
  230. reloadUI = {
  231. type = "execute",
  232. name = "Reload UI",
  233. desc = " ",
  234. order = 7,
  235. func = function()
  236. ReloadUI()
  237. end,
  238. },
  239. Text8 = {
  240. type = "description",
  241. order = 8,
  242. name = "When changes are made a reload of the UI is needed.",
  243. width = "full",
  244. },
  245. Text9 = {
  246. type = "description",
  247. order = 9,
  248. name = " ",
  249. width = "full",
  250. },
  251. fontSize = {
  252. type = "range",
  253. order = 10,
  254. name = L["Game Font Size"],
  255. desc = L["Controls the Size of the Game Font"],
  256. min = 0,
  257. max = 30,
  258. step = 1,
  259. },
  260. Text10 = {
  261. type = "description",
  262. order = 11,
  263. name = " ",
  264. width = "full",
  265. },
  266. classcolor = {
  267. type = "toggle",
  268. order = 12,
  269. name = L["Class Color"],
  270. desc = L["Use your classcolor for border and some text color."],
  271. },
  272. },
  273. },
  274. }
  275. }
  276. return options
  277. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement