mirror of
https://github.com/brues-code/pfUI.git
synced 2026-09-30 19:19:59 +00:00
mapcolors: rewrite module implementation
This commit is contained in:
@@ -178,6 +178,7 @@ function pfUI:LoadConfig()
|
||||
pfUI:UpdateConfig("appearance", "worldmap", "mapreveal_color", ".4,.4,.4,1")
|
||||
pfUI:UpdateConfig("appearance", "worldmap", "mapexploration", "0")
|
||||
pfUI:UpdateConfig("appearance", "worldmap", "groupcircles", "3")
|
||||
pfUI:UpdateConfig("appearance", "worldmap", "colornames", "1")
|
||||
|
||||
pfUI:UpdateConfig("loot", nil, "autoresize", "1")
|
||||
pfUI:UpdateConfig("loot", nil, "autopickup", "1")
|
||||
|
||||
Vendored
+1
@@ -119,6 +119,7 @@ pfUI_translation["deDE"] = {
|
||||
["Close"] = nil,
|
||||
["Color Buff Stacks"] = nil,
|
||||
["Color Debuff Stacks"] = nil,
|
||||
["Colorize player name on WorldMap and BattlefieldMinimap"] = nil,
|
||||
["Colorize Unknown Classes"] = nil,
|
||||
["Colors"] = nil,
|
||||
["Combat"] = nil,
|
||||
|
||||
Vendored
+1
@@ -119,6 +119,7 @@ pfUI_translation["enUS"] = {
|
||||
["Close"] = nil,
|
||||
["Color Buff Stacks"] = nil,
|
||||
["Color Debuff Stacks"] = nil,
|
||||
["Colorize player name on WorldMap and BattlefieldMinimap"] = nil,
|
||||
["Colorize Unknown Classes"] = nil,
|
||||
["Colors"] = nil,
|
||||
["Combat"] = nil,
|
||||
|
||||
Vendored
+1
@@ -119,6 +119,7 @@ pfUI_translation["esES"] = {
|
||||
["Close"] = "Cerrar",
|
||||
["Color Buff Stacks"] = "Colorear pilas de beneficios",
|
||||
["Color Debuff Stacks"] = "Colorear pilas de perjuicios",
|
||||
["Colorize player name on WorldMap and BattlefieldMinimap"] = nil,
|
||||
["Colorize Unknown Classes"] = "Colorear clases desconocidas",
|
||||
["Colors"] = "Colores",
|
||||
["Combat"] = "Combate",
|
||||
|
||||
Vendored
+1
@@ -119,6 +119,7 @@ pfUI_translation["frFR"] = {
|
||||
["Close"] = "Fermer",
|
||||
["Color Buff Stacks"] = "Couleur des l'empilements des Améliorations",
|
||||
["Color Debuff Stacks"] = "Couleur de l'empilements de Affaiblissements",
|
||||
["Colorize player name on WorldMap and BattlefieldMinimap"] = nil,
|
||||
["Colorize Unknown Classes"] = "Colorie les classes inconnues",
|
||||
["Colors"] = "Couleurs",
|
||||
["Combat"] = "Combat",
|
||||
|
||||
Vendored
+1
@@ -119,6 +119,7 @@ pfUI_translation["koKR"] = {
|
||||
["Close"] = "닫기",
|
||||
["Color Buff Stacks"] = nil,
|
||||
["Color Debuff Stacks"] = nil,
|
||||
["Colorize player name on WorldMap and BattlefieldMinimap"] = nil,
|
||||
["Colorize Unknown Classes"] = nil,
|
||||
["Colors"] = nil,
|
||||
["Combat"] = "전투",
|
||||
|
||||
Vendored
+1
@@ -119,6 +119,7 @@ pfUI_translation["ruRU"] = {
|
||||
["Close"] = "Закрыть",
|
||||
["Color Buff Stacks"] = "Цвет стаков баффа",
|
||||
["Color Debuff Stacks"] = "Цвет стаков дебаффа",
|
||||
["Colorize player name on WorldMap and BattlefieldMinimap"] = "Раскрасить имена игроков на карте мира и миникарте поля боя",
|
||||
["Colorize Unknown Classes"] = "Раскрасить неизвестные классы",
|
||||
["Colors"] = "Цвета по умолчанию",
|
||||
["Combat"] = "Бой",
|
||||
|
||||
Vendored
+1
@@ -119,6 +119,7 @@ pfUI_translation["zhCN"] = {
|
||||
["Close"] = "关闭",
|
||||
["Color Buff Stacks"] = "Buff堆叠颜色",
|
||||
["Color Debuff Stacks"] = "Debuff堆叠颜色",
|
||||
["Colorize player name on WorldMap and BattlefieldMinimap"] = nil,
|
||||
["Colorize Unknown Classes"] = "有色未知职业",
|
||||
["Colors"] = "颜色",
|
||||
["Combat"] = "战斗报警",
|
||||
|
||||
Vendored
+1
@@ -119,6 +119,7 @@ pfUI_translation["zhTW"] = {
|
||||
["Close"] = "關閉",
|
||||
["Color Buff Stacks"] = nil,
|
||||
["Color Debuff Stacks"] = nil,
|
||||
["Colorize player name on WorldMap and BattlefieldMinimap"] = nil,
|
||||
["Colorize Unknown Classes"] = "未知職業色彩",
|
||||
["Colors"] = nil,
|
||||
["Combat"] = "戰鬥報警",
|
||||
|
||||
@@ -1518,6 +1518,7 @@ pfUI:RegisterModule("gui", "vanilla:tbc", function ()
|
||||
CreateConfig(U["mapreveal"], T["Map Reveal Color"], C.appearance.worldmap, "mapreveal_color", "color")
|
||||
CreateConfig(U["mapreveal"], T["Map Exploration Points"], C.appearance.worldmap, "mapexploration", "checkbox")
|
||||
CreateConfig(U["mapcolors"], T["Map Group/Raid Circle Size"], C.appearance.worldmap, "groupcircles", "dropdown", pfUI.gui.dropdowns.mapcircle)
|
||||
CreateConfig(U["mapcolors"], T["Colorize player name on WorldMap and BattlefieldMinimap"], C.appearance.worldmap, "colornames", "checkbox")
|
||||
CreateConfig(U["map"], T["Map Tooltip Scale"], C.appearance.worldmap, "tooltipsize", "dropdown", pfUI.gui.dropdowns.maptooltip)
|
||||
CreateConfig(nil) -- spacer
|
||||
CreateConfig(nil, T["Enable Frame Shadow"], C.appearance.border, "shadow", "checkbox")
|
||||
|
||||
+141
-82
@@ -1,93 +1,152 @@
|
||||
-- adds class colored circles on world and battlefield map
|
||||
pfUI:RegisterModule("mapcolors", function ()
|
||||
pfUI.mapcolors = CreateFrame("Frame", nil, UIParent)
|
||||
pfUI.mapcolors:SetScript("OnUpdate", function()
|
||||
-- throttle to to one item per .1 second
|
||||
if ( this.tick or 1) > GetTime() then return else this.tick = GetTime() + .1 end
|
||||
|
||||
local frame, icon
|
||||
|
||||
-- initialize all button names
|
||||
if not this.buttons then
|
||||
this.buttons = {}
|
||||
|
||||
for i = 1, 4 do
|
||||
icon = string.format("WorldMapParty%d", i)
|
||||
this.buttons[icon] = string.format("party%d", i)
|
||||
end
|
||||
|
||||
for i = 1, 4 do
|
||||
icon = string.format("BattlefieldMinimapParty%d", i)
|
||||
this.buttons[icon] = string.format("party%d", i)
|
||||
end
|
||||
|
||||
for i = 1, 40 do
|
||||
icon = string.format("BattlefieldMinimapRaid%d", i)
|
||||
this.buttons[icon] = string.format("raid%d", i)
|
||||
end
|
||||
|
||||
for i = 1, 40 do
|
||||
icon = string.format("WorldMapRaid%d", i)
|
||||
this.buttons[icon] = string.format("raid%d", i)
|
||||
end
|
||||
local button_cache = {}
|
||||
local function Initialize(unit_button_name)
|
||||
local texture_size = tonumber(C.appearance.worldmap.groupcircles)
|
||||
for i=1, MAX_PARTY_MEMBERS do
|
||||
local frame_name = unit_button_name.."Party"..i
|
||||
local frame = _G[frame_name]
|
||||
frame.icon = _G[frame_name.."Icon"]
|
||||
frame.icon:SetTexture(pfUI.media["img:circleparty"])
|
||||
frame.icon:SetVertexColor(.5, 1, .5)
|
||||
SetAllPointsOffset(frame.icon, frame, texture_size, -texture_size)
|
||||
-- populate cache to default values
|
||||
button_cache[frame_name] = {
|
||||
r = .5, g = 1, b = .5
|
||||
}
|
||||
end
|
||||
|
||||
-- update all available buttons
|
||||
local ingroup
|
||||
for name, unitstr in pairs(this.buttons) do
|
||||
frame = _G[name]
|
||||
|
||||
if frame and UnitExists(unitstr) then
|
||||
icon = _G[name.."Icon"]
|
||||
icon:SetTexture()
|
||||
|
||||
-- create icon if not yet existing
|
||||
if not frame.pfIcon then
|
||||
frame.pfIcon = frame:CreateTexture(nil, "OVERLAY")
|
||||
SetAllPointsOffset(frame.pfIcon, frame, this.size, -this.size)
|
||||
end
|
||||
|
||||
-- check if unit is in same group
|
||||
ingroup = nil
|
||||
for i=1,5 do -- check if unit is in group
|
||||
if UnitName(string.format("party%d", i)) == UnitName(unitstr) then
|
||||
ingroup = true
|
||||
for i=1, MAX_RAID_MEMBERS do
|
||||
local frame_name = unit_button_name.."Raid"..i
|
||||
local frame = _G[frame_name]
|
||||
frame.icon = _G[frame_name.."Icon"]
|
||||
frame.icon:SetTexture(pfUI.media["img:circleraid"])
|
||||
frame.icon:SetVertexColor(.5, 1, .5)
|
||||
SetAllPointsOffset(frame.icon, frame, texture_size, -texture_size)
|
||||
-- populate cache to default values
|
||||
button_cache[frame_name] = {
|
||||
inParty = false,
|
||||
r = .5, g = 1, b = .5
|
||||
}
|
||||
end
|
||||
end
|
||||
local function GetTextureColor(frame)
|
||||
if UnitExists(frame.unit) then
|
||||
local _, class = UnitClass(frame.unit)
|
||||
local color = RAID_CLASS_COLORS[class]
|
||||
return color.r, color.g, color.b
|
||||
else
|
||||
return .5, 1, .5
|
||||
end
|
||||
end
|
||||
local function UpdateTexture(frame, inParty)
|
||||
print('UpdateTexture', frame:GetName(), frame.unit, UnitName(frame.unit), UnitClass(frame.unit), inParty)
|
||||
if inParty then
|
||||
frame.icon:SetTexture(pfUI.media["img:circleparty"])
|
||||
else
|
||||
frame.icon:SetTexture(pfUI.media["img:circleraid"])
|
||||
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)
|
||||
if GetNumRaidMembers() > 0 then
|
||||
for i=1, MAX_RAID_MEMBERS do
|
||||
local frame_name = unit_button_name.."Raid"..i
|
||||
local frame = _G[frame_name]
|
||||
local cache = button_cache[frame_name]
|
||||
if frame.unit then
|
||||
local inParty = UnitInParty(frame.unit)
|
||||
if inParty ~= cache.inParty then
|
||||
cache.inParty = inParty
|
||||
UpdateTexture(frame, cache.inParty)
|
||||
end
|
||||
local r, g, b = GetTextureColor(frame)
|
||||
if r ~= cache.r or g ~= cache.g or b ~= cache.b then
|
||||
cache.r, cache.g, cache.b = r, g, b
|
||||
UpdateTextureColor(frame, cache.r, cache.g, cache.b)
|
||||
end
|
||||
end
|
||||
|
||||
-- update texture according to raid/group state
|
||||
if ingroup and frame.pfIcon.ingroup ~= "PARTY" then
|
||||
frame.pfIcon:SetTexture(pfUI.media["img:circleparty"])
|
||||
frame.pfIcon.ingroup = "PARTY"
|
||||
elseif not ingroup and frame.pfIcon.ingroup ~= "RAID" then
|
||||
frame.pfIcon:SetTexture(pfUI.media["img:circleraid"])
|
||||
frame.pfIcon.ingroup = "RAID"
|
||||
end
|
||||
|
||||
-- detect unit class and set color
|
||||
local _, class = UnitClass(unitstr)
|
||||
local color = RAID_CLASS_COLORS[class]
|
||||
if color then
|
||||
frame.pfIcon:SetVertexColor(color.r, color.g, color.b)
|
||||
else
|
||||
frame.pfIcon:SetVertexColor(.5,1,.5)
|
||||
end
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
pfUI.mapcolors.UpdateConfig = function()
|
||||
pfUI.mapcolors.size = tonumber(C.appearance.worldmap.groupcircles)
|
||||
|
||||
if not pfUI.mapcolors.buttons then return end
|
||||
for name, unitstr in pairs(pfUI.mapcolors.buttons) do
|
||||
frame = _G[name]
|
||||
|
||||
if frame and frame.pfIcon then
|
||||
SetAllPointsOffset(frame.pfIcon, frame, pfUI.mapcolors.size, -pfUI.mapcolors.size)
|
||||
elseif GetNumPartyMembers() > 0 then
|
||||
for i=1, MAX_PARTY_MEMBERS do
|
||||
local frame_name = unit_button_name.."Party"..i
|
||||
local frame = _G[frame_name]
|
||||
local cache = button_cache[frame_name]
|
||||
if frame.unit then
|
||||
local r, g, b = GetTextureColor(frame)
|
||||
if r ~= cache.r or g ~= cache.g or b ~= cache.b then
|
||||
cache.r, cache.g, cache.b = r, g, b
|
||||
UpdateTextureColor(frame, cache.r, cache.g, cache.b)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
local function ColorizeName(frame)
|
||||
local _, class = UnitClass(frame.unit)
|
||||
local color = RAID_CLASS_COLORS[class]
|
||||
frame.name = frame.name or UnitName(frame.unit)
|
||||
frame.name = '|c'..color.colorStr..frame.name..'|r'
|
||||
end
|
||||
local function UpdateUnitColors(unit_button_name, tooltip)
|
||||
local tooltipText = ""
|
||||
if unit_button_name == 'WorldMap' then
|
||||
-- Check player
|
||||
if MouseIsOver(WorldMapPlayer) then
|
||||
ColorizeName(WorldMapPlayer)
|
||||
tooltipText = WorldMapPlayer.name
|
||||
end
|
||||
end
|
||||
-- Check party
|
||||
for i=1, MAX_PARTY_MEMBERS do
|
||||
local frame = _G[unit_button_name.."Party"..i]
|
||||
if frame:IsVisible() and MouseIsOver(frame) then
|
||||
ColorizeName(frame)
|
||||
tooltipText = tooltipText.."\n"..frame.name
|
||||
end
|
||||
end
|
||||
--Check Raid
|
||||
for i=1, MAX_RAID_MEMBERS do
|
||||
local frame = _G[unit_button_name.."Raid"..i]
|
||||
if frame:IsVisible() and MouseIsOver(frame) then
|
||||
ColorizeName(frame)
|
||||
tooltipText = tooltipText.."\n"..frame.name
|
||||
end
|
||||
end
|
||||
tooltip:SetText(tooltipText)
|
||||
tooltip:Show()
|
||||
end
|
||||
|
||||
pfUI.mapcolors:UpdateConfig()
|
||||
-- WorldMap
|
||||
Initialize('WorldMap')
|
||||
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
|
||||
UpdateUnitFrames('WorldMap')
|
||||
end)
|
||||
if C.appearance.worldmap.colornames == "1" then
|
||||
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
|
||||
UpdateUnitColors('WorldMap', WorldMapTooltip)
|
||||
end)
|
||||
end
|
||||
-- BattlefieldMinimap
|
||||
HookAddonOrVariable("Blizzard_BattlefieldMinimap", function()
|
||||
Initialize('BattlefieldMinimap')
|
||||
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
|
||||
UpdateUnitFrames('BattlefieldMinimap')
|
||||
end)
|
||||
if C.appearance.worldmap.colornames == "1" then
|
||||
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
|
||||
UpdateUnitColors('BattlefieldMinimap', GameTooltip)
|
||||
end)
|
||||
end
|
||||
end)
|
||||
end)
|
||||
|
||||
Reference in New Issue
Block a user