mirror of
https://github.com/brues-code/pfUI.git
synced 2026-10-19 11:00:50 +00:00
mapcolors: remove unnecessary function call
- add line breaks between function definitions - remove debug output and misleading comments
This commit is contained in:
+19
-14
@@ -1,6 +1,7 @@
|
|||||||
-- adds class colored circles on world and battlefield map
|
-- adds class colored circles on world and battlefield map
|
||||||
pfUI:RegisterModule("mapcolors", function ()
|
pfUI:RegisterModule("mapcolors", function ()
|
||||||
local button_cache = {}
|
local button_cache = {}
|
||||||
|
|
||||||
local function Initialize(unit_button_name)
|
local function Initialize(unit_button_name)
|
||||||
local texture_size = tonumber(C.appearance.worldmap.groupcircles)
|
local texture_size = tonumber(C.appearance.worldmap.groupcircles)
|
||||||
for i=1, MAX_PARTY_MEMBERS do
|
for i=1, MAX_PARTY_MEMBERS do
|
||||||
@@ -15,6 +16,7 @@ pfUI:RegisterModule("mapcolors", function ()
|
|||||||
r = .5, g = 1, b = .5
|
r = .5, g = 1, b = .5
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
for i=1, MAX_RAID_MEMBERS do
|
for i=1, MAX_RAID_MEMBERS do
|
||||||
local frame_name = unit_button_name.."Raid"..i
|
local frame_name = unit_button_name.."Raid"..i
|
||||||
local frame = _G[frame_name]
|
local frame = _G[frame_name]
|
||||||
@@ -29,6 +31,7 @@ pfUI:RegisterModule("mapcolors", function ()
|
|||||||
}
|
}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function GetTextureColor(frame)
|
local function GetTextureColor(frame)
|
||||||
if UnitExists(frame.unit) then
|
if UnitExists(frame.unit) then
|
||||||
local _, class = UnitClass(frame.unit)
|
local _, class = UnitClass(frame.unit)
|
||||||
@@ -38,18 +41,15 @@ pfUI:RegisterModule("mapcolors", function ()
|
|||||||
return .5, 1, .5
|
return .5, 1, .5
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function UpdateTexture(frame, inParty)
|
local function UpdateTexture(frame, inParty)
|
||||||
print('UpdateTexture', frame:GetName(), frame.unit, UnitName(frame.unit), UnitClass(frame.unit), inParty)
|
|
||||||
if inParty then
|
if inParty then
|
||||||
frame.icon:SetTexture(pfUI.media["img:circleparty"])
|
frame.icon:SetTexture(pfUI.media["img:circleparty"])
|
||||||
else
|
else
|
||||||
frame.icon:SetTexture(pfUI.media["img:circleraid"])
|
frame.icon:SetTexture(pfUI.media["img:circleraid"])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
local function UpdateTextureColor(frame, r, g, b)
|
|
||||||
print('UpdateTextureColor', frame:GetName(), frame.unit, UnitName(frame.unit), UnitClass(frame.unit), r, g, b)
|
|
||||||
frame.icon:SetVertexColor(r, g, b)
|
|
||||||
end
|
|
||||||
local function UpdateUnitFrames(unit_button_name)
|
local function UpdateUnitFrames(unit_button_name)
|
||||||
if GetNumRaidMembers() > 0 then
|
if GetNumRaidMembers() > 0 then
|
||||||
for i=1, MAX_RAID_MEMBERS do
|
for i=1, MAX_RAID_MEMBERS do
|
||||||
@@ -65,7 +65,7 @@ pfUI:RegisterModule("mapcolors", function ()
|
|||||||
local r, g, b = GetTextureColor(frame)
|
local r, g, b = GetTextureColor(frame)
|
||||||
if r ~= cache.r or g ~= cache.g or b ~= cache.b then
|
if r ~= cache.r or g ~= cache.g or b ~= cache.b then
|
||||||
cache.r, cache.g, cache.b = r, g, b
|
cache.r, cache.g, cache.b = r, g, b
|
||||||
UpdateTextureColor(frame, cache.r, cache.g, cache.b)
|
frame.icon:SetVertexColor(cache.r, cache.g, cache.b)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -78,28 +78,31 @@ pfUI:RegisterModule("mapcolors", function ()
|
|||||||
local r, g, b = GetTextureColor(frame)
|
local r, g, b = GetTextureColor(frame)
|
||||||
if r ~= cache.r or g ~= cache.g or b ~= cache.b then
|
if r ~= cache.r or g ~= cache.g or b ~= cache.b then
|
||||||
cache.r, cache.g, cache.b = r, g, b
|
cache.r, cache.g, cache.b = r, g, b
|
||||||
UpdateTextureColor(frame, cache.r, cache.g, cache.b)
|
frame.icon:SetVertexColor(cache.r, cache.g, cache.b)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function ColorizeName(frame)
|
local function ColorizeName(frame)
|
||||||
local _, class = UnitClass(frame.unit)
|
local _, class = UnitClass(frame.unit)
|
||||||
local color = RAID_CLASS_COLORS[class]
|
local color = RAID_CLASS_COLORS[class]
|
||||||
frame.name = frame.name or UnitName(frame.unit)
|
frame.name = frame.name or UnitName(frame.unit)
|
||||||
frame.name = '|c'..color.colorStr..frame.name..'|r'
|
frame.name = '|c'..color.colorStr..frame.name..'|r'
|
||||||
end
|
end
|
||||||
|
|
||||||
local function UpdateUnitColors(unit_button_name, tooltip)
|
local function UpdateUnitColors(unit_button_name, tooltip)
|
||||||
local tooltipText = ""
|
local tooltipText = ""
|
||||||
if unit_button_name == 'WorldMap' then
|
if unit_button_name == 'WorldMap' then
|
||||||
-- Check player
|
-- check player
|
||||||
if MouseIsOver(WorldMapPlayer) then
|
if MouseIsOver(WorldMapPlayer) then
|
||||||
ColorizeName(WorldMapPlayer)
|
ColorizeName(WorldMapPlayer)
|
||||||
tooltipText = WorldMapPlayer.name
|
tooltipText = WorldMapPlayer.name
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
-- Check party
|
|
||||||
|
-- check party
|
||||||
for i=1, MAX_PARTY_MEMBERS do
|
for i=1, MAX_PARTY_MEMBERS do
|
||||||
local frame = _G[unit_button_name.."Party"..i]
|
local frame = _G[unit_button_name.."Party"..i]
|
||||||
if frame:IsVisible() and MouseIsOver(frame) then
|
if frame:IsVisible() and MouseIsOver(frame) then
|
||||||
@@ -107,7 +110,8 @@ pfUI:RegisterModule("mapcolors", function ()
|
|||||||
tooltipText = tooltipText.."\n"..frame.name
|
tooltipText = tooltipText.."\n"..frame.name
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
--Check Raid
|
|
||||||
|
--check Raid
|
||||||
for i=1, MAX_RAID_MEMBERS do
|
for i=1, MAX_RAID_MEMBERS do
|
||||||
local frame = _G[unit_button_name.."Raid"..i]
|
local frame = _G[unit_button_name.."Raid"..i]
|
||||||
if frame:IsVisible() and MouseIsOver(frame) then
|
if frame:IsVisible() and MouseIsOver(frame) then
|
||||||
@@ -115,6 +119,7 @@ pfUI:RegisterModule("mapcolors", function ()
|
|||||||
tooltipText = tooltipText.."\n"..frame.name
|
tooltipText = tooltipText.."\n"..frame.name
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
tooltip:SetText(tooltipText)
|
tooltip:SetText(tooltipText)
|
||||||
tooltip:Show()
|
tooltip:Show()
|
||||||
end
|
end
|
||||||
@@ -122,28 +127,28 @@ pfUI:RegisterModule("mapcolors", function ()
|
|||||||
-- WorldMap
|
-- WorldMap
|
||||||
Initialize('WorldMap')
|
Initialize('WorldMap')
|
||||||
hooksecurefunc('WorldMapButton_OnUpdate', function()
|
hooksecurefunc('WorldMapButton_OnUpdate', function()
|
||||||
-- throttle to to one item per 1 second
|
|
||||||
if ( this.tick or .5) > GetTime() then return else this.tick = GetTime() + .5 end
|
if ( this.tick or .5) > GetTime() then return else this.tick = GetTime() + .5 end
|
||||||
UpdateUnitFrames('WorldMap')
|
UpdateUnitFrames('WorldMap')
|
||||||
end)
|
end)
|
||||||
|
|
||||||
if C.appearance.worldmap.colornames == "1" then
|
if C.appearance.worldmap.colornames == "1" then
|
||||||
hooksecurefunc('WorldMapUnit_OnEnter', function()
|
hooksecurefunc('WorldMapUnit_OnEnter', function()
|
||||||
-- throttle to to one item per 1 second
|
|
||||||
if ( this.tick or .5) > GetTime() then return else this.tick = GetTime() + .5 end
|
if ( this.tick or .5) > GetTime() then return else this.tick = GetTime() + .5 end
|
||||||
UpdateUnitColors('WorldMap', WorldMapTooltip)
|
UpdateUnitColors('WorldMap', WorldMapTooltip)
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- BattlefieldMinimap
|
-- BattlefieldMinimap
|
||||||
HookAddonOrVariable("Blizzard_BattlefieldMinimap", function()
|
HookAddonOrVariable("Blizzard_BattlefieldMinimap", function()
|
||||||
Initialize('BattlefieldMinimap')
|
Initialize('BattlefieldMinimap')
|
||||||
|
|
||||||
hooksecurefunc('BattlefieldMinimap_OnUpdate', function()
|
hooksecurefunc('BattlefieldMinimap_OnUpdate', function()
|
||||||
-- throttle to to one item per 1 second
|
|
||||||
if ( this.tick or .5) > GetTime() then return else this.tick = GetTime() + .5 end
|
if ( this.tick or .5) > GetTime() then return else this.tick = GetTime() + .5 end
|
||||||
UpdateUnitFrames('BattlefieldMinimap')
|
UpdateUnitFrames('BattlefieldMinimap')
|
||||||
end)
|
end)
|
||||||
|
|
||||||
if C.appearance.worldmap.colornames == "1" then
|
if C.appearance.worldmap.colornames == "1" then
|
||||||
hooksecurefunc('BattlefieldMinimapUnit_OnEnter', function()
|
hooksecurefunc('BattlefieldMinimapUnit_OnEnter', function()
|
||||||
-- throttle to to one item per 1 second
|
|
||||||
if ( this.tick or .5) > GetTime() then return else this.tick = GetTime() + .5 end
|
if ( this.tick or .5) > GetTime() then return else this.tick = GetTime() + .5 end
|
||||||
UpdateUnitColors('BattlefieldMinimap', GameTooltip)
|
UpdateUnitColors('BattlefieldMinimap', GameTooltip)
|
||||||
end)
|
end)
|
||||||
|
|||||||
Reference in New Issue
Block a user