diff --git a/Localization/enUS.lua b/Localization/enUS.lua index f790dca..2d47ea9 100644 --- a/Localization/enUS.lua +++ b/Localization/enUS.lua @@ -333,8 +333,20 @@ L["Add a text widget"] = true L["Restore Defaults"] = true L["Restore Defaults"] = true - - +-- PVP icon +L["PvP Icon"] = true +L["Add Point"] = true +L["Add a new point"] = true +L["Icon Point"] = true +L["Which point of the PvP icon is attached at the relative point."] = true +L["Relative Point"] = true +L["Which point of StarTip's tooltip should the PvP icon be attached."] = true +L["X Offset"] = true +L["X axis offset from attached point."] = true +L["Y Offset"] = true +L["Y axis offset from attached point."] = true +L["Delete"] = true +L["Delete this point"] = true diff --git a/Modules/PvP/PvP.lua b/Modules/PvP/PvP.lua index 42ca144..48cb0e7 100644 --- a/Modules/PvP/PvP.lua +++ b/Modules/PvP/PvP.lua @@ -5,30 +5,50 @@ local _G = _G local GameTooltip = _G.GameTooltip local UnitFactionGroup = _G.UnitFactionGroup local self = mod +local L = StarTip.L +local LibWidget = LibStub("LibScriptableWidget-1.0") + +local defaults = { + profile = { + width = 30, + height = 30, + points = {{"TOP", "StarTipQTipMain", "TOPRIGHT", 0, 0}} + } +} function mod:OnInitialize() self.db = StarTip.db:RegisterNamespace(self:GetName(), defaults) - local frame = _G.CreateFrame("Frame", nil, GameTooltip) - local pvp = frame:CreateTexture(nil, "OVERLAY") - pvp:SetHeight(30) - pvp:SetWidth(30) - pvp:SetPoint("TOPRIGHT", GameTooltip, 20, 10) - pvp:Hide() + + local frame = _G.CreateFrame("Frame", nil, StarTip.tooltipMain) + local pvp = frame:CreateTexture(nil, "TOOLTIP") + + pvp:SetHeight(self.db.profile.height or 30) + pvp:SetWidth(self.db.profile.width or 30) + + for i, v in pairs(self.db.profile.points) do + pvp:SetPoint(unpack(v)) + end + self.PvP = pvp end function mod:OnEnable() - self:RegisterEvent("UNIT_FACTION") + + --self:RegisterEvent("UNIT_FACTION") end function mod:OnDisable() - self:UnregisterEvent("UNIT_FACTION") + --self:UnregisterEvent("UNIT_FACTION") end function mod:UNIT_FACTION(event, unit) - if unit ~= "mouseover" then return end + + unit = unit or "mouseover" + + if not UnitExists(unit) then return end local factionGroup = UnitFactionGroup(unit) + if(UnitIsPVPFreeForAll(unit)) then self.PvP:SetTexture[[Interface\TargetingFrame\UI-PVP-FFA]] self.PvP:Show() @@ -41,9 +61,103 @@ function mod:UNIT_FACTION(event, unit) end function mod:SetUnit() - self:UNIT_FACTION(nil, "mouseover") + self:UNIT_FACTION(nil, StarTip.unit or "mouseover") end function mod:OnHide() self.PvP:Hide() end + +function mod:GetOptions() + local options = { + pvp = { + name = L["PvP 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", "TOPRIGHT", 0, 0}) + 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] + 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] + 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) 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) 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 diff --git a/StarTip.lua b/StarTip.lua index 2af6e0e..d06a9df 100644 --- a/StarTip.lua +++ b/StarTip.lua @@ -495,6 +495,11 @@ function StarTip.cellPrototype:ReleaseCell() self.r, self.g, self.b = 1, 1, 1 end +StarTip.tooltipMain = LQT:Acquire("StarTipQTipMain", 2) +--StarTip.tooltipMain:SetDefaultProvider(StarTip.cellProvider) +StarTip.tooltipMain:SetParent(UIParent) +_G["StarTipQTipMain"] = StarTip.tooltipMain + function StarTip:OnEnable() if self.db.profile.minimap.hide then LibDBIcon:Hide("StarTipLDB") @@ -502,12 +507,6 @@ function StarTip:OnEnable() LibDBIcon:Show("StarTipLDB") end - - StarTip.tooltipMain = LQT:Acquire("StarTipQTipMain", 2) - --StarTip.tooltipMain:SetDefaultProvider(StarTip.cellProvider) - StarTip.tooltipMain:SetParent(UIParent) - _G["StarTipQTipMain"] = StarTip.tooltipMain - GameTooltip:HookScript("OnTooltipSetUnit", self.OnTooltipSetUnit) GameTooltip:HookScript("OnTooltipSetItem", self.OnTooltipSetItem) GameTooltip:HookScript("OnTooltipSetSpell", self.OnTooltipSetSpell) diff --git a/modules.xml b/modules.xml index b98c931..d322be8 100644 --- a/modules.xml +++ b/modules.xml @@ -6,14 +6,14 @@ <Script file = "Modules\Border\Border.lua"/> <Script file = "Modules\Fade\Fade.lua"/> <Script file = "Modules\Position\Position.lua"/> -<Script file = "Modules\PvP\PvP.lua"/> -<Script file = "Modules\RaidIcon\RaidIcon.lua"/> -<Script file = "Modules\Targeting\Targeting.lua"/> <Script file = "Modules\Texts\Texts.lua"/> <Script file = "Modules\Bars\Bars.lua"/> <Script file = "Modules\Histograms\Histograms.lua"/> <Script file = "Modules\UnitTooltip\UnitTooltip.lua"/> +<Script file = "Modules\Targeting\Targeting.lua"/> +<Script file = "Modules\RaidIcon\RaidIcon.lua"/> +<Script file = "Modules\PvP\PvP.lua"/> <Script file = "Modules\Portrait\Portrait.lua"/> <Script file = "Modules\Icons\Icons.lua"/> <Script file = "Modules\Gestures\Gestures.lua"/>