Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local ADDON_NAME = LibStub("AceAddon-3.0"):NewAddon("BasicUI")
- local L = setmetatable({}, { __index = function(t,k)
- local v = tostring(k)
- rawset(t, k, v)
- return v
- end })
- local db
- local defaults = {
- profile = {
- media = {
- fontNormal = [[Interface\Addons\BasicUI\Media\NORMAL.ttf]],
- fontBold = [[Interface\Addons\BasicUI\Media\BOLD.ttf]],
- fontItalic = [[Interface\Addons\BasicUI\Media\ITALIC.ttf]],
- fontBoldItalic = [[Interface\Addons\BasicUI\Media\BOLDITALIC.ttf]],
- fontNumber = [[Interface\Addons\BasicUI\Media\NUMBER.ttf]],
- fontSize = 15,
- classcolor = true,
- },
- modules = {
- ["*"] = true,
- }
- }
- }
- function ADDON_NAME:OnInitialize()
- self.db = LibStub("AceDB-3.0"):New("BasicDB", defaults, true) -- true is important!
- db = self.db.profile
- self.db.RegisterCallback(self, "OnProfileChanged", "Refresh")
- self.db.RegisterCallback(self, "OnProfileCopied", "Refresh")
- self.db.RegisterCallback(self, "OnProfileReset", "Refresh")
- local Dialog = LibStub("AceConfigDialog-3.0")
- local options = self:GetOptions()
- LibStub("AceConfigRegistry-3.0"):RegisterOptionsTable("BasicUI", options)
- Dialog:AddToBlizOptions("BasicUI", nil, nil, "media")
- for k, v in self:IterateModules() do
- if type(v.GetOptions) == "function" then
- options.args[k] = v:GetOptions()
- Dialog:AddToBlizOptions("BasicUI", options.args[k].name, "BasicUI", k)
- end
- end
- options.args.profile = LibStub("AceDBOptions-3.0"):GetOptionsTable(self.db)
- options.args.profile.order = -1
- Dialog:AddToBlizOptions("BasicUI", options.args.profile.name, "BasicUI", "profile")
- end
- function ADDON_NAME:OnEnable()
- -- set up stuff here
- db = self.db.profile
- SlashCmdList['RELOADUI'] = function()
- ReloadUI()
- end
- SLASH_RELOADUI1 = '/rl'
- local function SetFont(obj, font, size, style, r, g, b, sr, sg, sb, sox, soy)
- obj:SetFont(font, size, style)
- if sr and sg and sb then obj:SetShadowColor(sr, sg, sb) end
- if sox and soy then obj:SetShadowOffset(sox, soy) end
- if r and g and b then obj:SetTextColor(r, g, b)
- elseif r then obj:SetAlpha(r) end
- end
- local NORMAL = db.media.fontNormal
- local BOLD = db.media.fontBold
- local BOLDITALIC = db.media.fontBoldItalic
- local ITALIC = db.media.fontItalic
- local NUMBER = db.media.fontNormal
- UIDROPDOWNMENU_DEFAULT_TEXT_HEIGHT = 15
- CHAT_FONT_HEIGHTS = {7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24}
- UNIT_NAME_FONT = NORMAL
- DAMAGE_TEXT_FONT = NUMBER
- STANDARD_TEXT_FONT = NORMAL
- -- Base fonts
- SetFont(AchievementFont_Small, BOLD, db.media.fontSize)
- SetFont(FriendsFont_Large, NORMAL, db.media.fontSize, nil, nil, nil, nil, 0, 0, 0, 1, -1)
- SetFont(FriendsFont_Normal, NORMAL, db.media.fontSize, nil, nil, nil, nil, 0, 0, 0, 1, -1)
- SetFont(FriendsFont_Small, NORMAL, db.media.fontSize, nil, nil, nil, nil, 0, 0, 0, 1, -1)
- SetFont(FriendsFont_UserText, NUMBER, db.media.fontSize, nil, nil, nil, nil, 0, 0, 0, 1, -1)
- SetFont(GameTooltipHeader, BOLD, db.media.fontSize, "OUTLINE")
- SetFont(GameFont_Gigantic, BOLD, 32, nil, nil, nil, nil, 0, 0, 0, 1, -1)
- SetFont(InvoiceFont_Med, ITALIC, db.media.fontSize, nil, 0.15, 0.09, 0.04)
- SetFont(InvoiceFont_Small, ITALIC, db.media.fontSize, nil, 0.15, 0.09, 0.04)
- SetFont(MailFont_Large, ITALIC, db.media.fontSize, nil, 0.15, 0.09, 0.04, 0.54, 0.4, 0.1, 1, -1)
- SetFont(NumberFont_OutlineThick_Mono_Small, NUMBER, db.media.fontSize, "OUTLINE")
- SetFont(NumberFont_Outline_Huge, NUMBER, 30, "THICKOUTLINE", 30)
- SetFont(NumberFont_Outline_Large, NUMBER, 17, "OUTLINE")
- SetFont(NumberFont_Outline_Med, NUMBER, db.media.fontSize, "OUTLINE")
- SetFont(NumberFont_Shadow_Med, NORMAL, db.media.fontSize)
- SetFont(NumberFont_Shadow_Small, NORMAL, db.media.fontSize)
- SetFont(QuestFont_Shadow_Small, NORMAL, 16)
- SetFont(QuestFont_Large, NORMAL, 16)
- SetFont(QuestFont_Shadow_Huge, BOLD, 19, nil, nil, nil, nil, 0.54, 0.4, 0.1)
- SetFont(QuestFont_Super_Huge, BOLD, 24)
- SetFont(ReputationDetailFont, BOLD, db.media.fontSize, nil, nil, nil, nil, 0, 0, 0, 1, -1)
- SetFont(SpellFont_Small, BOLD, db.media.fontSize)
- SetFont(SystemFont_InverseShadow_Small, BOLD, db.media.fontSize)
- SetFont(SystemFont_Large, NORMAL, 17)
- SetFont(SystemFont_Med1, NORMAL, db.media.fontSize)
- SetFont(SystemFont_Med2, ITALIC, db.media.fontSize, nil, 0.15, 0.09, 0.04)
- SetFont(SystemFont_Med3, NORMAL, db.media.fontSize)
- SetFont(SystemFont_OutlineThick_Huge2, NORMAL, 22, "THICKOUTLINE")
- SetFont(SystemFont_OutlineThick_Huge4, BOLDITALIC, 27, "THICKOUTLINE")
- SetFont(SystemFont_OutlineThick_WTF, BOLDITALIC, 31, "THICKOUTLINE", nil, nil, nil, 0, 0, 0, 1, -1)
- SetFont(SystemFont_Outline_Small, NUMBER, db.media.fontSize, "OUTLINE")
- SetFont(SystemFont_Shadow_Huge1, BOLD, 20)
- SetFont(SystemFont_Shadow_Huge3, BOLD, 25)
- SetFont(SystemFont_Shadow_Large, NORMAL, 17)
- SetFont(SystemFont_Shadow_Med1, NORMAL, db.media.fontSize)
- SetFont(SystemFont_Shadow_Med2, NORMAL, db.media.fontSize)
- SetFont(SystemFont_Shadow_Med3, NORMAL, db.media.fontSize)
- SetFont(SystemFont_Shadow_Outline_Huge2, NORMAL, 22, "OUTLINE")
- SetFont(SystemFont_Shadow_Small, BOLD, db.media.fontSize)
- SetFont(SystemFont_Small, NORMAL, db.media.fontSize)
- SetFont(SystemFont_Tiny, NORMAL, db.media.fontSize)
- SetFont(ChatBubbleFont, NORMAL, db.media.fontSize)
- -- Derived fonts
- SetFont(BossEmoteNormalHuge, BOLDITALIC, 27, "THICKOUTLINE")
- SetFont(CombatTextFont, NORMAL, 26)
- SetFont(ErrorFont, ITALIC, 16, nil, 60)
- SetFont(QuestFontNormalSmall, BOLD, db.media.fontSize, nil, nil, nil, nil, 0.54, 0.4, 0.1)
- SetFont(WorldMapTextFont, BOLDITALIC, 31, "THICKOUTLINE", 40, nil, nil, 0, 0, 0, 1, -1)
- end
- function ADDON_NAME:Refresh()
- db = self.db.profile -- update the upvalue to point to the new profile
- -- change stuff here
- for k, v in self:IterateModules() do
- local isEnabled, shouldEnable = v:IsEnabled(), self:GetModuleEnabled(k)
- if shouldEnable and not isEnabled then
- self:EnableModule(k)
- elseif isEnabled and not shouldEnable then
- self:DisableModule(k)
- end
- if type(v.Refresh) == "function" then
- v:Refresh()
- end
- end
- end
- function ADDON_NAME:GetModuleEnabled(moduleName)
- return db.modules[moduleName]
- end
- function ADDON_NAME:SetModuleEnabled(moduleName, newState)
- local oldState = db.modules[moduleName]
- if oldState == newState then return end
- if newState then
- self:EnableModule(moduleName)
- else
- self:DisableModule(moduleName)
- end
- end
- local options
- function ADDON_NAME:GetOptions()
- options = options or {
- type = "group",
- name = "BasicUI",
- args = {
- media = { -- @PHANX: moved all the "welcome" text into a group, you'll see why later
- type = "group",
- order = 1,
- name = "Media",
- get = function(info) return db.media[ info[#info] ] end,
- set = function(info, value) db.media[ info[#info] ] = value; end,
- args = {
- Text = {
- type = "description",
- order = 0,
- name = L["Welcome to |cff00B4FFBasic|rUI Config Area!"],
- width = "full",
- fontSize = "large",
- },
- Text2 = {
- type = "description",
- order = 1,
- name = L[" "],
- width = "full",
- },
- Text3 = {
- type = "description",
- order = 2,
- name = L["Special Thanks for |cff00B4FFBasic|rUI goes out to: "],
- width = "full",
- fontSize = "medium",
- },
- Text4 = {
- type = "description",
- order = 3,
- name = L["Phanx, Neav, Tuks, Elv, Baine, Treeston, and many more."],
- width = "full",
- fontSize = "large",
- },
- Text5 = {
- type = "description",
- order = 4,
- name = L[" "],
- width = "full",
- fontSize = "medium",
- },
- Text6 = {
- type = "description",
- order = 5,
- name = L["Thank you all for your AddOns, coding help, and support in creating |cff00B4FFBasic|rUI."],
- width = "full",
- fontSize = "medium",
- },
- Text7 = {
- type = "description",
- order = 6,
- name = L[" "],
- width = "full",
- fontSize = "medium",
- },
- reloadUI = {
- type = "execute",
- name = "Reload UI",
- desc = " ",
- order = 7,
- func = function()
- ReloadUI()
- end,
- },
- Text8 = {
- type = "description",
- order = 8,
- name = "When changes are made a reload of the UI is needed.",
- width = "full",
- },
- Text9 = {
- type = "description",
- order = 9,
- name = " ",
- width = "full",
- },
- fontSize = {
- type = "range",
- order = 10,
- name = L["Game Font Size"],
- desc = L["Controls the Size of the Game Font"],
- min = 0,
- max = 30,
- step = 1,
- },
- Text10 = {
- type = "description",
- order = 11,
- name = " ",
- width = "full",
- },
- classcolor = {
- type = "toggle",
- order = 12,
- name = L["Class Color"],
- desc = L["Use your classcolor for border and some text color."],
- },
- },
- },
- }
- }
- return options
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement