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