From 47bacc293dccd4448c98a08b5da2a39c9670babb Mon Sep 17 00:00:00 2001 From: MilleXIV Date: Sun, 7 Aug 2016 19:27:20 -0400 Subject: [PATCH] Starting up base structures, config, micromenu --- XIV_Databar.toc | 3 +- core.lua | 314 +++++++++++++++++++++++----- locales/enUS.lua | 34 ++- modules/load_modules.xml | 4 + modules/micromenu.lua | 510 ++++++++++++++------------------------------- modules/old/micromenu.lua | 371 +++++++++++++++++++++++++++++++++ modules/test.lua | 48 +++++ 7 files changed, 874 insertions(+), 410 deletions(-) create mode 100644 modules/load_modules.xml create mode 100644 modules/old/micromenu.lua create mode 100644 modules/test.lua diff --git a/XIV_Databar.toc b/XIV_Databar.toc index f6fb8ae..f95de73 100644 --- a/XIV_Databar.toc +++ b/XIV_Databar.toc @@ -9,12 +9,13 @@ embeds.xml locales\locales.xml core.lua +modules\load_modules.xml settings.lua modules\config.lua modules\social.lua -modules\micromenu.lua +modules\old\micromenu.lua modules\armor.lua modules\talent.lua modules\clock.lua diff --git a/core.lua b/core.lua index be214b6..922d18b 100644 --- a/core.lua +++ b/core.lua @@ -1,11 +1,14 @@ local AddOnName, Engine = ...; local _G = _G; local pairs, unpack, select = pairs, unpack, select -local XIVBar = LibStub("AceAddon-3.0"):NewAddon(AddOnName); +local XIVBar = LibStub("AceAddon-3.0"):NewAddon(AddOnName, "AceConsole-3.0", "AceEvent-3.0"); local L = LibStub("AceLocale-3.0"):GetLocale(AddOnName, false); XIVBar.defaults = { profile = { + general = { + barPosition = "BOTTOM", + }, color = { barColor = { r = 0.25, @@ -14,11 +17,37 @@ XIVBar.defaults = { a = 1 }, normal = { + r = 0.8, + g = 0.8, + b = 0.8, + a = 0.75 + }, + inactive = { r = 1, g = 1, b = 1, - a = 0.75 + a = 0.25 + }, + useCC = true, + hover = { + r = 1, + g = 1, + b = 1, + a = 1 } + }, + text = { + fontSize = 12, + smallFontSize = 11, + font = L['Homizio Bold'] + }, + + + + + + modules = { + } } }; @@ -29,8 +58,11 @@ XIVBar.constants = { playerClass = select(2, UnitClass("player")) } +P = {}; + Engine[1] = XIVBar; Engine[2] = L; +Engine[3] = P; _G.XIVBar = Engine; XIVBar.LSM = LibStub('LibSharedMedia-3.0'); @@ -38,59 +70,21 @@ XIVBar.LSM = LibStub('LibSharedMedia-3.0'); _G[AddOnName] = Engine; function XIVBar:OnInitialize() - self.db = LibStub("AceDB-3.0"):New("XIVBarDB", self.defaults, "Default") + + self.LSM:Register(self.LSM.MediaType.FONT, L['Homizio Bold'], self.constants.mediaPath.."homizio_bold.ttf") + local options = { name = "XIV Bar", handler = XIVBar, type = 'group', args = { general = { - name = L['Test'], + name = L['General'], type = "group", args = { - colors = { - name = L['Text Colors'], - type = "group", - inline = true, - args = { - normal = { - name = L['Normal'], - type = "color", - hasAlpha = true, - set = function(info, r, g, b, a) - XIVBar:SetColor('normal', r, g, b, a) - end, - get = function() return XIVBar:GetColor('normal') end - }, -- normal - inactive = { - name = L['Inactive'], - type = "color", - hasAlpha = true, - set = function(info, r, g, b, a) - XIVBar:SetColor('normal', r, g, b, a) - end, - get = function() return XIVBar:GetColor('normal') end - }, -- normal - hoverCC = { - name = L['Hover Class Colors'], - type = "color", - hasAlpha = true, - set = function(info, r, g, b, a) - XIVBar:SetColor('normal', r, g, b, a) - end, - get = function() return XIVBar:GetColor('normal') end - }, -- normal - hover = { - name = L['Normal'], - type = "color", - hasAlpha = true, - set = function(info, r, g, b, a) - XIVBar:SetColor('normal', r, g, b, a) - end, - get = function() return XIVBar:GetColor('normal') end - }, -- normal - } - }, -- colors + general = self:GetGeneralOptions(), + text = self:GetTextOptions(), + textColors = self:GetTextColorOptions(), -- colors } }, -- general modules = { @@ -102,27 +96,239 @@ function XIVBar:OnInitialize() } -- modules } } + for name, module in self:IterateModules() do + if module['GetConfig'] ~= nil then + options.args.modules.args[name] = module:GetConfig() + end + if module['GetDefaultOptions'] ~= nil then + local oName, oTable = module:GetDefaultOptions() + self.defaults.profile.modules[oName] = oTable + end + end + + self.db = LibStub("AceDB-3.0"):New("XIVBarDB", self.defaults, "Default") + P = self.db.profile + LibStub("AceConfig-3.0"):RegisterOptionsTable(AddOnName, options) - LibStub("AceConfigDialog-3.0"):AddToBlizOptions(AddOnName, "XIV Bar", nil, "general") + self.optionsFrame = LibStub("AceConfigDialog-3.0"):AddToBlizOptions(AddOnName, "XIV Bar", nil, "general") + + --options.args.modules = LibStub("AceDBOptions-3.0"):GetOptionsTable(self.db) + self.modulesOptionFrame = LibStub("AceConfigDialog-3.0"):AddToBlizOptions(AddOnName, L['Modules'], "XIV Bar", "modules") --LibStub("AceConfig-3.0"):RegisterOptionsTable(AddOnName.."-Profiles", ) options.args.profiles = LibStub("AceDBOptions-3.0"):GetOptionsTable(self.db) self.profilesOptionFrame = LibStub("AceConfigDialog-3.0"):AddToBlizOptions(AddOnName, L['Profiles'], "XIV Bar", "profiles") + + + + self:RegisterChatCommand('xivbar', 'ToggleConfig') end function XIVBar:OnEnable() self.frames = {} - self.frames.bar = CreateFrame("FRAME") + self:CreateMainBar() +end + +function XIVBar:ToggleConfig() + InterfaceOptionsFrame_OpenToCategory(self.optionsFrame) end function XIVBar:SetColor(name, r, g, b, a) - self.db.profile.color[name].r = r - self.db.profile.color[name].g = g - self.db.profile.color[name].b = b - self.db.profile.color[name].a = a + P.color[name].r = r + P.color[name].g = g + P.color[name].b = b + P.color[name].a = a + + self:Refresh() end function XIVBar:GetColor(name) - d = self.db.profile.color[name] + d = P.color[name] return d.r, d.g, d.b, d.a end + +function XIVBar:HoverColors() + local colors = { + P.color.hover.r, + P.color.hover.g, + P.color.hover.b, + P.color.hover.a + } + if P.color.useCC 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 + } + end + return colors +end + +function XIVBar:RegisterFrame(name, frame) + self.frames[name] = frame +end + +function XIVBar:GetFrame(name) + return self.frames[name] +end + +function XIVBar:CreateMainBar() + self:RegisterFrame('bar', CreateFrame("FRAME", "XIV_Databar", UIParent)) + self:RegisterFrame('bgTexture', self.frames.bar:CreateTexture(nil, "BACKGROUND")) + self:Refresh() +end + +function XIVBar:GetHeight() + return (P.text.fontSize * 2) + 3 +end + +function XIVBar:Refresh() + local mainBar = self.frames.bar + local bgTexture = self.frames.bgTexture + local barColor = P.color.barColor + + mainBar:ClearAllPoints() + mainBar:SetPoint(P.general.barPosition) + mainBar:SetPoint("LEFT") + mainBar:SetPoint("RIGHT") + mainBar:SetHeight(self:GetHeight()) + + bgTexture:SetAllPoints() + bgTexture:SetColorTexture(barColor.r, barColor.g, barColor.b, barColor.a) + + for name, module in self:IterateModules() do + if module['Refresh'] == nil then return; end + module:Refresh() + end +end + + + + + +function XIVBar:GetGeneralOptions() + return { + name = L['General'], + type = "group", + order = 3, + inline = true, + args = { + barPosition = { + name = L['Bar Position'], + type = "select", + order = 1, + values = {TOP = L['Top'], BOTTOM = L['Bottom']}, + style = "dropdown", + get = function() return P.general.barPosition; end, + set = function(info, value) P.general.barPosition = value; self:Refresh(); end, + }, + barColor = { + name = L['Bar Color'], + type = "color", + order = 2, + hasAlpha = true, + set = function(info, r, g, b, a) + XIVBar:SetColor('barColor', r, g, b, a) + end, + get = function() return XIVBar:GetColor('barColor') end + }, + } + } +end + +function XIVBar:GetTextOptions() + local t = self.LSM:List(self.LSM.MediaType.FONT); + local fontList = {}; + for k,v in pairs(t) do + fontList[v] = v; + end + return { + name = L['Text'], + type = "group", + order = 3, + inline = true, + args = { + font = { + name = L['Font'], + type = "select", + order = 1, + values = fontList, + style = "dropdown", + get = function() return P.text.font; end, + set = function(info, val) P.text.font = val; self:Refresh(); end + }, + fontSize = { + name = L['Font Size'], + type = 'range', + order = 2, + min = 10, + max = 20, + step = 1, + get = function() return P.text.fontSize; end, + set = function(info, val) P.text.fontSize = val; self:Refresh(); end + }, + smallFontSize = { + name = L['Small Font Size'], + type = 'range', + order = 2, + min = 10, + max = 20, + step = 1, + get = function() return P.text.smallFontSize; end, + set = function(info, val) P.text.smallFontSize = val; self:Refresh(); end + }, + } + } +end + +function XIVBar:GetTextColorOptions() + return { + name = L['Text Colors'], + type = "group", + order = 3, + inline = true, + args = { + normal = { + name = L['Normal'], + type = "color", + order = 1, + width = "double", + hasAlpha = true, + set = function(info, r, g, b, a) + XIVBar:SetColor('normal', r, g, b, a) + end, + get = function() return XIVBar:GetColor('normal') end + }, -- normal + hoverCC = { + name = L['Use Class Colors for Hover'], + type = "toggle", + order = 2, + set = function(info, val) P.color.useCC = val; self:Refresh(); end, + get = function() return P.color.useCC end + }, -- normal + inactive = { + name = L['Inactive'], + type = "color", + order = 3, + hasAlpha = true, + width = "double", + set = function(info, r, g, b, a) + XIVBar:SetColor('inactive', r, g, b, a) + end, + get = function() return XIVBar:GetColor('inactive') end + }, -- normal + hover = { + name = L['Hover'], + type = "color", + order = 4, + hasAlpha = true, + set = function(info, r, g, b, a) + XIVBar:SetColor('hover', r, g, b, a) + end, + get = function() return XIVBar:GetColor('hover') end, + disabled = function() return P.color.useCC end + }, -- normal + } + } +end diff --git a/locales/enUS.lua b/locales/enUS.lua index ac1b090..ee8810a 100644 --- a/locales/enUS.lua +++ b/locales/enUS.lua @@ -3,6 +3,38 @@ local AceLocale = LibStub:GetLibrary("AceLocale-3.0"); local L = AceLocale:NewLocale(AddOnName, "enUS", true, true); if not L then return; end -L['Test'] = true; +L['General'] = true; +L['Text'] = true; + L['Profiles'] = true; L['Modules'] = true; + +-- General +L['Bar Position'] = true; +L['Top'] = true; +L['Bottom'] = true; +L['Bar Color'] = true; + +-- Media +L['Font'] = true; +L['Font Size'] = true; +L['Small Font Size'] = true; + +-- Text Colors +L['Text Colors'] = true; +L['Normal'] = true; +L['Inactive'] = true; +L['Use Class Colors for Hover'] = true; +L['Hover'] = true; + + + + +-------------------- MODULES --------------------------- +L['Test Module'] = true; + +L['Micromenu'] = true; + + +------------ PROPER NOUNS - DO NOT LOCALIZE ------------ +L['Homizio Bold'] = true; diff --git a/modules/load_modules.xml b/modules/load_modules.xml new file mode 100644 index 0000000..0dfe101 --- /dev/null +++ b/modules/load_modules.xml @@ -0,0 +1,4 @@ + +