mirror of
https://github.com/Bluewhale1337/ElvUIModernized.git
synced 2026-07-27 08:24:44 +00:00
load oUF_GPS (in-progress)
This commit is contained in:
@@ -0,0 +1,111 @@
|
||||
local ns = oUF
|
||||
local oUF = ns.oUF
|
||||
assert(oUF, "oUF not loaded")
|
||||
|
||||
local cos, sin, sqrt2, max, atan2 = math.cos, math.sin, math.sqrt(2), math.max, math.atan2
|
||||
local tinsert, tremove = table.insert, table.remove
|
||||
local pi2 = 3.141592653589793 / 2
|
||||
|
||||
local GetPlayerMapPosition = GetPlayerMapPosition
|
||||
local UnitInParty = UnitInParty
|
||||
local UnitInRaid = UnitInRaid
|
||||
local UnitInRange = UnitInRange
|
||||
local UnitIsConnected = UnitIsConnected
|
||||
local UnitIsUnit = UnitIsUnit
|
||||
|
||||
local _FRAMES, OnUpdateFrame = {}
|
||||
|
||||
local function CalculateCorner(r) return .5 + cos(r) / sqrt2, .5 + sin(r) / sqrt2 end
|
||||
local function RotateTexture(texture, angle)
|
||||
local LRx, LRy = CalculateCorner(angle + 0.785398163)
|
||||
local LLx, LLy = CalculateCorner(angle + 2.35619449)
|
||||
local ULx, ULy = CalculateCorner(angle + 3.92699082)
|
||||
local URx, URy = CalculateCorner(angle - 0.785398163)
|
||||
|
||||
texture:SetTexCoord(ULx, ULy, LLx, LLy, URx, URy, LRx, LRy)
|
||||
end
|
||||
|
||||
local GetAngle = function(unit1, unit2)
|
||||
local x1, y1 = GetPlayerMapPosition(unit1)
|
||||
if x1 <= 0 and y1 <= 0 then return nil end
|
||||
local x2, y2 = GetPlayerMapPosition(unit2)
|
||||
if x2 <= 0 and y2 <= 0 then return nil end
|
||||
-- print(pi2, GetPlayerFacing(), y2, y1, x2, x1)
|
||||
return -pi2 - GetPlayerFacing() - atan2(y2 - y1, x2 - x1)
|
||||
end
|
||||
|
||||
local minThrottle = 0.02
|
||||
local numArrows, inRange, unit, GPS
|
||||
local Update = function(self, elapsed)
|
||||
if self.elapsed and self.elapsed > (self.throttle or minThrottle) then
|
||||
numArrows = 0;
|
||||
for _, object in next, _FRAMES do
|
||||
if object:IsShown() then
|
||||
GPS = object.GPS;
|
||||
unit = object.unit;
|
||||
if unit then
|
||||
if unit and GPS.outOfRange then
|
||||
inRange = true;
|
||||
end
|
||||
|
||||
if not unit or not (UnitInParty(unit) or UnitInRaid(unit)) or UnitIsUnit(unit, "player") or not UnitIsConnected(unit) or (GPS.onMouseOver and (GetMouseFocus() ~= object)) or (GPS.outOfRange and inRange) then
|
||||
GPS:Hide()
|
||||
else
|
||||
local angle = GetAngle("player", unit);
|
||||
if angle == nil then
|
||||
GPS:Hide();
|
||||
else
|
||||
GPS:Show();
|
||||
RotateTexture(GPS.Texture, angle);
|
||||
|
||||
numArrows = numArrows + 1;
|
||||
end
|
||||
end
|
||||
else
|
||||
GPS:Hide();
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
self.elapsed = 0;
|
||||
self.throttle = max(minThrottle, 0.005 * numArrows);
|
||||
else
|
||||
self.elapsed = (self.elapsed or 0) + tonumber(elapsed);
|
||||
end
|
||||
end
|
||||
|
||||
local Enable = function(self)
|
||||
local GPS = self.GPS
|
||||
if GPS then
|
||||
tinsert(_FRAMES, self)
|
||||
|
||||
if not OnUpdateFrame then
|
||||
OnUpdateFrame = CreateFrame("Frame")
|
||||
OnUpdateFrame:SetScript("OnUpdate", function()
|
||||
Update(this, arg1)
|
||||
end)
|
||||
end
|
||||
|
||||
OnUpdateFrame:Show()
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
||||
local Disable = function(self)
|
||||
local GPS = self.GPS
|
||||
if GPS then
|
||||
for k, frame in next, _FRAMES do
|
||||
if frame == self then
|
||||
tremove(_FRAMES, k)
|
||||
GPS:Hide()
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
if getn(_FRAMES) == 0 and OnUpdateFrame then
|
||||
OnUpdateFrame:Hide()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
oUF:AddElement("GPS", function() end, Enable, Disable)
|
||||
@@ -0,0 +1,3 @@
|
||||
<Ui xmlns="http://www.blizzard.com/wow/ui/">
|
||||
<Script file="oUF_GPS.lua"/>
|
||||
</Ui>
|
||||
@@ -1,4 +1,5 @@
|
||||
<Ui xmlns="http://www.blizzard.com/wow/ui/">
|
||||
<Include file="oUF_AuraBars\oUF_AuraBars.xml"/>
|
||||
<Include file="oUF_Smooth\oUF_Smooth.xml"/>
|
||||
<Include file="oUF_GPS\oUF_GPS.xml"/>
|
||||
</Ui>
|
||||
@@ -0,0 +1,41 @@
|
||||
local E, L, V, P, G = unpack(ElvUI); --Import: Engine, Locales, PrivateDB, ProfileDB, GlobalDB
|
||||
local UF = E:GetModule("UnitFrames");
|
||||
|
||||
--Cache global variables
|
||||
--Lua functions
|
||||
|
||||
--WoW API / Variables
|
||||
local CreateFrame = CreateFrame
|
||||
|
||||
function UF:Construct_GPS(frame)
|
||||
local gps = CreateFrame("Frame", nil, frame)
|
||||
gps:SetFrameLevel(frame:GetFrameLevel() + 50)
|
||||
-- gps:Hide()
|
||||
|
||||
gps.Texture = gps:CreateTexture("OVERLAY")
|
||||
gps.Texture:SetTexture([[Interface\AddOns\ElvUI\media\textures\arrow.tga]])
|
||||
gps.Texture:SetBlendMode("BLEND")
|
||||
gps.Texture:SetVertexColor(214/255, 41/255, 41/255)
|
||||
gps.Texture:SetAllPoints()
|
||||
|
||||
return gps
|
||||
end
|
||||
|
||||
function UF:Configure_GPS(frame)
|
||||
local GPS = frame.GPS
|
||||
if frame.db.GPSArrow.enable then
|
||||
if not frame:IsElementEnabled("GPS") then
|
||||
frame:EnableElement("GPS")
|
||||
end
|
||||
|
||||
E:Size(GPS, frame.db.GPSArrow.size)
|
||||
GPS.onMouseOver = frame.db.GPSArrow.onMouseOver
|
||||
GPS.outOfRange = frame.db.GPSArrow.outOfRange
|
||||
|
||||
E:Point(GPS, "CENTER", frame, "CENTER", frame.db.GPSArrow.xOffset, frame.db.GPSArrow.yOffset)
|
||||
else
|
||||
if frame:IsElementEnabled("GPS") then
|
||||
frame:DisableElement("GPS")
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -2,6 +2,7 @@
|
||||
<Script file="AuraBars.lua"/>
|
||||
<Script file="Auras.lua"/>
|
||||
<Script file="CombatIndicator.lua"/>
|
||||
<Script file="GPS.lua"/>
|
||||
<Script file="Health.lua"/>
|
||||
<Script file="Name.lua"/>
|
||||
<Script file="Portrait.lua"/>
|
||||
|
||||
@@ -5,9 +5,6 @@ local _G = _G
|
||||
local tinsert = table.insert
|
||||
|
||||
local CreateFrame = CreateFrame
|
||||
local InCombatLockdown = InCombatLockdown
|
||||
local UnregisterStateDriver = UnregisterStateDriver
|
||||
local RegisterStateDriver = RegisterStateDriver
|
||||
local IsInInstance = IsInInstance
|
||||
|
||||
local ns = oUF
|
||||
@@ -33,6 +30,7 @@ function UF:Construct_PartyFrames()
|
||||
self.RaidRoleFramesAnchor = UF:Construct_RaidRoleFrames(self)
|
||||
self.RaidTargetIndicator = UF:Construct_RaidIcon(self)
|
||||
|
||||
self.GPS = UF:Construct_GPS(self)
|
||||
self.unitframeType = "party"
|
||||
|
||||
UF:Update_StatusBars()
|
||||
@@ -114,6 +112,8 @@ function UF:Update_PartyFrames(frame, db)
|
||||
|
||||
UF:Configure_RaidIcon(frame)
|
||||
|
||||
UF:Configure_GPS(frame)
|
||||
|
||||
UF:Configure_RaidRoleIcons(frame)
|
||||
|
||||
frame:UpdateAllElements("ElvUI_UpdateAllElements")
|
||||
|
||||
@@ -23,6 +23,7 @@ function UF:Construct_TargetFrame(frame)
|
||||
frame.Buffs = self:Construct_Buffs(frame)
|
||||
frame.Debuffs = self:Construct_Debuffs(frame)
|
||||
frame.RaidTargetIndicator = UF:Construct_RaidIcon(frame)
|
||||
frame.GPS = self:Construct_GPS(frame)
|
||||
frame.InfoPanel = self:Construct_InfoPanel(frame)
|
||||
frame.AuraBars = self:Construct_AuraBarHeader(frame)
|
||||
|
||||
@@ -88,6 +89,8 @@ function UF:Update_TargetFrame(frame, db)
|
||||
|
||||
UF:Configure_Portrait(frame)
|
||||
|
||||
UF:Configure_GPS(frame)
|
||||
|
||||
UF:Configure_RaidIcon(frame)
|
||||
|
||||
E:SetMoverSnapOffset(frame:GetName().."Mover", -(12 + db.castbar.height))
|
||||
|
||||
Reference in New Issue
Block a user