diff --git a/Localization/enUS.lua b/Localization/enUS.lua index 2d47ea9..b32f318 100644 --- a/Localization/enUS.lua +++ b/Localization/enUS.lua @@ -348,7 +348,13 @@ L["Y axis offset from attached point."] = true L["Delete"] = true L["Delete this point"] = true - +-- Raid Icon +L["Raid Icon"] = true +L["Icon Width"] = true +L["How wide to make the raid icon."] = true +L["Icon Height"] = true +L["How tall to make the raid icon."] = true +L["Icon Height"] = true diff --git a/Modules/RaidIcon/RaidIcon.lua b/Modules/RaidIcon/RaidIcon.lua index 8df484f..6ecba7b 100644 --- a/Modules/RaidIcon/RaidIcon.lua +++ b/Modules/RaidIcon/RaidIcon.lua @@ -7,16 +7,24 @@ local GetRaidTargetIndex = _G.GetRaidTargetIndex local SetRaidTargetIconTexture = _G.SetRaidTargetIconTexture local self = mod +local defaults = { + profile = { + width = 16, + height = 16, + points = {{"TOP", "StarTipQTipMain", "TOP", 0, 4}} + } +} + function mod:OnInitialize() self.db = StarTip.db:RegisterNamespace(self:GetName(), defaults) - local frame = CreateFrame("Frame", nil, GameTooltip) + local frame = CreateFrame("Frame", nil, StarTip.tooltipMain) local icon = frame:CreateTexture(nil, "OVERLAY") - icon:SetHeight(16) - icon:SetWidth(16) - icon:SetPoint("TOP", GameTooltip, 0, 4) - icon:SetTexture"Interface\\TargetingFrame\\UI-RaidTargetingIcons" + icon:SetHeight(self.db.profile.height) + icon:SetWidth(self.db.profile.width) + icon:SetTexture("Interface\\TargetingFrame\\UI-RaidTargetingIcons") icon:Hide() self.icon = icon + self:ReAnchor() end function mod:OnEnable() @@ -35,6 +43,13 @@ function mod:OnHide() if self.icon:IsShown() then self.icon:Hide() end end +function mod:ReAnchor() + self.icon:ClearAllPoints() + for i, v in ipairs(self.db.profile.points) do + self.icon:SetPoint(unpack(v)) + end +end + function mod:RAID_TARGET_UPDATE(event) local index = _G.GetRaidTargetIndex("mouseover") @@ -46,3 +61,128 @@ function mod:RAID_TARGET_UPDATE(event) end end +function mod:GetOptions() + local options = { + pvp = { + name = L["Raid Icon"], + type = "group", + args = { + + add = { + name = L["Add Point"], + desc = L["Add a new point"], + type = "input", + set = function(info, v) + tinsert(db.points, {"TOP", "StarTipQTip", "TOP", 0, 0}) + end, + order = 1 + } + } + }, + width = { + name = L["Icon Width"], + desc = L["How wide to make the raid icon."], + type = "input", + pattern = "%d", + get = function() return tostring(self.db.profile.width or 16) end, + set = function(info, v) + self.db.profile.width = tonumber(v) + self.icon:SetWidth(self.db.profile.width) + end, + order = 1 + }, + height = { + name = L["Icon Height"], + desc = L["How tall to make the raid icon."], + type = "input", + pattern = "%d", + get = function() return tostring(self.db.profile.height or 16) end, + set = function(info, v) + self.db.profile.height = tonumber(v) + self.icon:SetHeight(self.db.profile.height) + end, + order = 1 + } + } + + for i, point in ipairs(self.db.profile.points) do + options.pvp.args["point" .. i] = { + name = "Point #" .. i, + type = "group", + order = i + 1, + args = { + point = { + name = L["Icon Point"], + desc = L["Which point of the PvP icon is attached at the relative point."], + type = "select", + values = LibWidget.anchors, + get = function() return LibWidget.anchorsDict[point[1] or 1] end, + set = function(info, v) + point[1] = LibWidget.anchors[v] + self:ReAnchor() + end, + order = 1 + }, +--[[ + relativeFrame = { + name = L["Relative Frame"], + type = "input", + get = function() return point[2] end, + set = function(info, v) + points[2] = v + end, + order = 2 + }, +]] + relativePoint = { + name = L["Relative Point"], + desc = L["Which point of StarTip's tooltip should the PvP icon be attached."], + type = "select", + values = LibWidget.anchors, + get = function() return LibWidget.anchorsDict[point[3] or 1] end, + set = function(info, v) + point[3] = LibWidget.anchors[v] + self:ReAnchor() + end, + order = 3 + }, + xOfs = { + name = L["X Offset"], + desc = L["X axis offset from attached point."], + type = "input", + pattern = "%d", + get = function() return tostring(point[4] or 0) end, + set = function(info, v) + point[4] = tonumber(v) + self:ReAnchor() + end, + order = 5 + }, + yOfs = { + name = L["Y Offset"], + desc = L["Y axis offset from attached point."], + type = "input", + pattern = "%d", + get = function() return tostring(point[5] or 0) end, + set = function(info, v) + point[5] = tonumber(v) + self:ReAnchor() + end, + order = 5 + }, + delete = { + name = L["Delete"], + desc = L["Delete this point"], + type = "execute", + func = function() + tremove(self.db.profile.points, i) + end, + order = 6 + } + } + } + end + + return options + +end