diff --git a/core.lua b/core.lua index e5c2b08..3ef5514 100644 --- a/core.lua +++ b/core.lua @@ -30,7 +30,8 @@ XIVBar.defaults = { b = 1, a = 0.25 }, - useCC = true, + useCC = false, + useHoverCC = true, hover = { r = 1, g = 1, @@ -179,19 +180,18 @@ function XIVBar:GetColor(name) end function XIVBar:HoverColors() - local P = self.db.profile local colors = { - P.color.hover.r, - P.color.hover.g, - P.color.hover.b, - P.color.hover.a + self.db.profile.color.hover.r, + self.db.profile.color.hover.g, + self.db.profile.color.hover.b, + self.db.profile.color.hover.a } - if P.color.useCC then + if self.db.profile.color.useHoverCC then colors = { RAID_CLASS_COLORS[self.constants.playerClass].r, RAID_CLASS_COLORS[self.constants.playerClass].g, RAID_CLASS_COLORS[self.constants.playerClass].b, - P.color.hover.a + self.db.profile.color.hover.a } end return colors @@ -227,7 +227,16 @@ function XIVBar:Refresh() self.frames.bar:SetHeight(self:GetHeight()) self.frames.bgTexture:SetAllPoints() - self.frames.bgTexture:SetColorTexture(barColor.r, barColor.g, barColor.b, barColor.a) + if self.db.profile.color.useCC then + self.frames.bgTexture:SetColorTexture( + RAID_CLASS_COLORS[self.constants.playerClass].r, + RAID_CLASS_COLORS[self.constants.playerClass].g, + RAID_CLASS_COLORS[self.constants.playerClass].b, + barColor.a + ) + else + self.frames.bgTexture:SetColorTexture(barColor.r, barColor.g, barColor.b, barColor.a) + end for name, module in self:IterateModules() do if module['Refresh'] == nil then return; end @@ -255,15 +264,23 @@ function XIVBar:GetGeneralOptions() get = function() return self.db.profile.general.barPosition; end, set = function(info, value) self.db.profile.general.barPosition = value; self:Refresh(); end, }, + barCC = { + name = L['Use Class Colors for Bar'], + type = "toggle", + order = 2, + set = function(info, val) self.db.profile.color.useCC = val; self:Refresh(); end, + get = function() return self.db.profile.color.useCC end + }, -- normal barColor = { name = L['Bar Color'], type = "color", - order = 2, + order = 3, hasAlpha = true, set = function(info, r, g, b, a) XIVBar:SetColor('barColor', r, g, b, a) end, - get = function() return XIVBar:GetColor('barColor') end + get = function() return XIVBar:GetColor('barColor') end, + disabled = function() return self.db.profile.color.useCC end }, } } @@ -336,8 +353,8 @@ function XIVBar:GetTextColorOptions() name = L['Use Class Colors for Hover'], type = "toggle", order = 2, - set = function(info, val) self.db.profile.color.useCC = val; self:Refresh(); end, - get = function() return self.db.profile.color.useCC end + set = function(info, val) self.db.profile.color.useHoverCC = val; self:Refresh(); end, + get = function() return self.db.profile.color.useHoverCC end }, -- normal inactive = { name = L['Inactive'], @@ -359,7 +376,7 @@ function XIVBar:GetTextColorOptions() XIVBar:SetColor('hover', r, g, b, a) end, get = function() return XIVBar:GetColor('hover') end, - disabled = function() return self.db.profile.color.useCC end + disabled = function() return self.db.profile.color.useHoverCC end }, -- normal } } diff --git a/locales/enUS.lua b/locales/enUS.lua index ef34d0d..80a95dc 100644 --- a/locales/enUS.lua +++ b/locales/enUS.lua @@ -12,6 +12,7 @@ L['Bar Position'] = true; L['Top'] = true; L['Bottom'] = true; L['Bar Color'] = true; +L['Use Class Colors for Bar'] = true; -- Media L['Font'] = true; diff --git a/modules/micromenu.lua b/modules/micromenu.lua index 9c76dea..c485ee5 100644 --- a/modules/micromenu.lua +++ b/modules/micromenu.lua @@ -20,23 +20,38 @@ function MenuModule:OnInitialize() end function MenuModule:OnEnable() - self.microMenuFrame = CreateFrame("FRAME", nil, xb:GetFrame('bar')) - xb:RegisterFrame('microMenuFrame', self.microMenuFrame) - self:CreateFrames() - self:RegisterFrameEvents() - self:CreateIcons() - self:Refresh() - self:UpdateGuildText() - self:UpdateFriendText() + if self.microMenuFrame == nil then + self.microMenuFrame = CreateFrame("FRAME", nil, xb:GetFrame('bar')) + xb:RegisterFrame('microMenuFrame', self.microMenuFrame) + end + + self.microMenuFrame:Show() + + if xb.db.profile.modules.microMenu.enabled then + self:CreateFrames() + self:RegisterFrameEvents() + self:CreateIcons() + self:Refresh() + self:UpdateGuildText() + self:UpdateFriendText() + end end function MenuModule:OnDisable() + for _, frame in pairs(self.frames) do + frame:Hide() + end + self.microMenuFrame:Hide() + self:Refresh() + self:UnregisterFrameEvents() end function MenuModule:Refresh() if self.frames.menu == nil then return; end + if not xb.db.profile.modules.microMenu.enabled then return; end + self.iconSize = xb:GetHeight(); self.textPosition = "TOP" if xb.db.profile.general.barPosition == 'TOP' then @@ -46,6 +61,7 @@ function MenuModule:Refresh() local colors = xb.db.profile.color local totalWidth = 0; for name, frame in pairs(self.frames) do + frame:Show() self:IconDefaults(name) if name == 'menu' then frame:SetPoint("LEFT", xb.db.profile.modules.microMenu.iconSpacing, 0) @@ -90,18 +106,20 @@ function MenuModule:CreateFrames() self.frames.shop = self.frames.shop or CreateFrame("BUTTON", nil, self.frames.pet) self.frames.help = self.frames.help or CreateFrame("BUTTON", nil, self.frames.shop) - self.text.guild = self.frames.guild:CreateFontString(nil, 'OVERLAY') - self.bgTexture.guild = self.frames.guild:CreateTexture(nil, "OVERLAY") + self.text.guild = self.text.guild or self.frames.guild:CreateFontString(nil, 'OVERLAY') + self.bgTexture.guild = self.bgTexture.guild or self.frames.guild:CreateTexture(nil, "OVERLAY") - self.text.social = self.frames.social:CreateFontString(nil, 'OVERLAY') - self.bgTexture.social = self.frames.social:CreateTexture(nil, "OVERLAY") + self.text.social = self.text.social or self.frames.social:CreateFontString(nil, 'OVERLAY') + self.bgTexture.social = self.bgTexture.social or self.frames.social:CreateTexture(nil, "OVERLAY") end function MenuModule:CreateIcons() for name, frame in pairs(self.frames) do if frame['Click'] ~= nil then --Odd way of checking if it's a button - self.icons[name] = frame:CreateTexture(nil, "OVERLAY") - self.icons[name]:SetTexture(self.mediaFolder..name) + if self.icons[name] == nil then + self.icons[name] = frame:CreateTexture(nil, "OVERLAY") + self.icons[name]:SetTexture(self.mediaFolder..name) + end end end end @@ -141,6 +159,13 @@ function MenuModule:RegisterFrameEvents() self:RegisterEvent('FRIENDLIST_UPDATE', 'UpdateFriendText') end +function MenuModule:UnregisterFrameEvents() + self:UnregisterEvent('GUILD_ROSTER_UPDATE') + self:UnregisterEvent('BN_FRIEND_ACCOUNT_ONLINE') + self:UnregisterEvent('BN_FRIEND_ACCOUNT_OFFLINE') + self:UnregisterEvent('FRIENDLIST_UPDATE') +end + function MenuModule:UpdateGuildText() if IsInGuild() then local _, onlineMembers = GetNumGuildMembers() @@ -313,7 +338,14 @@ function MenuModule:GetConfig() order = 0, type = "toggle", get = function() return xb.db.profile.modules.microMenu.enabled; end, - set = function(_, val) xb.db.profile.modules.microMenu.enabled = val; self:Refresh(); end + set = function(_, val) + xb.db.profile.modules.microMenu.enabled = val + if val then + self:Enable() + else + self:Disable() + end + end }, showTooltips = { name = L['Show Social Tooltips'],