Skip to content

Commit

Permalink
refactor: new way of generating class icons (#52)
Browse files Browse the repository at this point in the history
- Allows us to get rid of the big hard coded tables.
- passing size 18 is the same is the seperate table for "big" icons that used to exist.
  • Loading branch information
juemrami authored May 22, 2024
1 parent 728fffc commit 77baaa6
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 43 deletions.
7 changes: 4 additions & 3 deletions LFGBulletinBoard/GroupBulletinBoard.lua
Original file line number Diff line number Diff line change
Expand Up @@ -731,9 +731,10 @@ local function Event_CHAT_MSG_SYSTEM(arg1)
local txt

if class and class~="" then
txt="|Hplayer:"..name.."|h"..GBB.Tool.IconClass[class]..
"|c"..GBB.Tool.ClassColor[class].colorStr ..
name.."|r"..symbol.."|h"
txt="|Hplayer:"..name.."|h"
..(GBB.Tool.GetClassIcon(req.class) or "")
.."|c"..GBB.Tool.ClassColor[class].colorStr .. name.."|r"
..symbol.."|h";
else
txt="|Hplayer:"..name.."|h"..name..symbol.."|h"
end
Expand Down
8 changes: 5 additions & 3 deletions LFGBulletinBoard/GroupList.lua
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ function GBB.AddGroupList(entry)
end
GroupBulletinBoardFrame_GroupFrame:AddMessage(
"|Hplayer:".. entry.name .."|h"..
GBB.Tool.IconClass[entry.class]..
(GBB.Tool.GetClassIcon(entry.class) or "")..
"|c"..GBB.Tool.ClassColor[entry.class].colorStr ..
entry.name..

Expand Down Expand Up @@ -139,9 +139,11 @@ local function EnterHyperlink(self,link,text)
GameTooltip_SetDefaultAnchor(GameTooltip,UIParent)
GameTooltip:SetOwner(GroupBulletinBoardFrame, "ANCHOR_BOTTOM", 0,-25)
GameTooltip:ClearLines()
GameTooltip:AddLine(GBB.Tool.IconClass[entry.class]..
GameTooltip:AddLine(
(GBB.Tool.GetClassIcon(entry.class) or "")..
"|c"..GBB.Tool.ClassColor[entry.class].colorStr ..
entry.name)
entry.name
);
if entry.dungeon then
GameTooltip:AddLine(entry.dungeon)
end
Expand Down
9 changes: 5 additions & 4 deletions LFGBulletinBoard/LfgToolList.lua
Original file line number Diff line number Diff line change
Expand Up @@ -361,11 +361,12 @@ local function CreateItem(yy,i,doCompact,req,forceHight)
prefix="|r"
end
local ClassIcon=""
if GBB.DB.ShowClassIcon and req.class and GBB.Tool.IconClass[req.class] then
if GBB.DB.ShowClassIcon and req.class then
if doCompact<1 or GBB.DB.ChatStyle then
ClassIcon=GBB.Tool.IconClass[req.class]
ClassIcon = GBB.Tool.GetClassIcon(req.class) or ""

else
ClassIcon=GBB.Tool.IconClassBig[req.class]
ClassIcon = GBB.Tool.GetClassIcon(req.class, 18) or ""
end
end

Expand Down Expand Up @@ -705,7 +706,7 @@ function GBB.LfgRequestShowTooltip(self)
if GBB.DB.EnableGroup and GBB.GroupTrans and GBB.GroupTrans[req.name] then
local entry=GBB.GroupTrans[req.name]

GameTooltip:AddLine(GBB.Tool.IconClass[entry.class]..
GameTooltip:AddLine((GBB.Tool.GetClassIcon(entry.class) or "")..
"|c"..GBB.Tool.ClassColor[entry.class].colorStr ..
entry.name)
if entry.dungeon then
Expand Down
43 changes: 18 additions & 25 deletions LFGBulletinBoard/LibGPIToolBox.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,31 +4,24 @@ local Tool=Addon.Tool

Tool.IconClassTexture="Interface\\GLUES\\CHARACTERCREATE\\UI-CHARACTERCREATE-CLASSES"
Tool.IconClassTextureWithoutBorder="Interface\\WorldStateFrame\\ICONS-CLASSES"
Tool.IconClassTextureCoord=CLASS_ICON_TCOORDS
Tool.IconClass={
["WARRIOR"]= "|TInterface\\WorldStateFrame\\ICONS-CLASSES:0:0:0:0:256:256:0:64:0:64|t",
["MAGE"]= "|TInterface\\WorldStateFrame\\ICONS-CLASSES:0:0:0:0:256:256:64:128:0:64|t",
["ROGUE"]= "|TInterface\\WorldStateFrame\\ICONS-CLASSES:0:0:0:0:256:256:128:192:0:64|t",
["DRUID"]= "|TInterface\\WorldStateFrame\\ICONS-CLASSES:0:0:0:0:256:256:192:256:0:64|t",
["HUNTER"]= "|TInterface\\WorldStateFrame\\ICONS-CLASSES:0:0:0:0:256:256:0:64:64:128|t",
["SHAMAN"]= "|TInterface\\WorldStateFrame\\ICONS-CLASSES:0:0:0:0:256:256:64:128:64:128|t",
["PRIEST"]= "|TInterface\\WorldStateFrame\\ICONS-CLASSES:0:0:0:0:256:256:128:192:64:128|t",
["WARLOCK"]= "|TInterface\\WorldStateFrame\\ICONS-CLASSES:0:0:0:0:256:256:192:256:64:128|t",
["PALADIN"]= "|TInterface\\WorldStateFrame\\ICONS-CLASSES:0:0:0:0:256:256:0:64:128:192|t",
["DEATHKNIGHT"]= "|TInterface\\WorldStateFrame\\ICONS-CLASSES:0:0:0:0:256:256:64:128:128:192|t",
}
Tool.IconClassBig={
["WARRIOR"]= "|TInterface\\WorldStateFrame\\ICONS-CLASSES:18:18:-4:4:256:256:0:64:0:64|t",
["MAGE"]= "|TInterface\\WorldStateFrame\\ICONS-CLASSES:18:18:-4:4:256:256:64:128:0:64|t",
["ROGUE"]= "|TInterface\\WorldStateFrame\\ICONS-CLASSES:18:18:-4:4:256:256:128:192:0:64|t",
["DRUID"]= "|TInterface\\WorldStateFrame\\ICONS-CLASSES:18:18:-4:4:256:256:192:256:0:64|t",
["HUNTER"]= "|TInterface\\WorldStateFrame\\ICONS-CLASSES:18:18:-4:4:256:256:0:64:64:128|t",
["SHAMAN"]= "|TInterface\\WorldStateFrame\\ICONS-CLASSES:18:18:-4:4:256:256:64:128:64:128|t",
["PRIEST"]= "|TInterface\\WorldStateFrame\\ICONS-CLASSES:18:18:-4:4:256:256:128:192:64:128|t",
["WARLOCK"]= "|TInterface\\WorldStateFrame\\ICONS-CLASSES:18:18:-4:4:256:256:192:256:64:128|t",
["PALADIN"]= "|TInterface\\WorldStateFrame\\ICONS-CLASSES:18:18:-4:4:256:256:0:64:128:192|t",
["DEATHKNIGHT"]= "|TInterface\\WorldStateFrame\\ICONS-CLASSES:18:18:-4:4:256:256:64:128:128:192|t",
}

---@param classFile string
---@param size number?
function Tool.GetClassIcon(classFile, size)
assert(type(classFile) == "string", "Usage: Tool.GetClassIcon(class: string, size: number?)", classFile)
local coords = CLASS_ICON_TCOORDS[classFile:upper()];
local size = size or 14;
if coords then
local icon = CreateTextureMarkup(
"Interface\\WorldStateFrame\\ICONS-CLASSES",
256, 256, -- og size
size, size, -- new size
coords[1], coords[2], coords[3], coords[4], -- texCoords
0, 1 -- x, y offsets
);
return icon;
end
end

Tool.RaidIconNames=ICON_TAG_LIST
Tool.RaidIcon={
Expand Down
12 changes: 4 additions & 8 deletions LFGBulletinBoard/RequestList.lua
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ local function CreateItem(scrollPos,i,scale,req,forceHight)
hoverTex:SetPoint("BOTTOMRIGHT", pad, -pad)
hoverTex:SetAtlas("search-highlight")
hoverTex:SetDesaturated(true) -- its comes blue by default
hoverTex:SetVertexColor(0.5, 0.5, 0.5, 0.7)
hoverTex:SetVertexColor(0.7, 0.7, 0.7, 0.4)
hoverTex:SetBlendMode("ADD")

GBB.Tool.EnableHyperlink(entry)
Expand Down Expand Up @@ -255,12 +255,8 @@ local function CreateItem(scrollPos,i,scale,req,forceHight)
end

local ClassIcon=""
if GBB.DB.ShowClassIcon and req.class and GBB.Tool.IconClass[req.class] then
if scale < 1 or GBB.DB.ChatStyle then
ClassIcon=GBB.Tool.IconClass[req.class]
else
ClassIcon=GBB.Tool.IconClassBig[req.class]
end
if GBB.DB.ShowClassIcon and req.class then
ClassIcon = GBB.Tool.GetClassIcon(req.class, GBB.DB.ChatStyle and 12 or 18) or ""
end

local FriendIcon = (
Expand Down Expand Up @@ -1074,7 +1070,7 @@ function GBB.RequestShowTooltip(self)
if GBB.DB.EnableGroup and GBB.GroupTrans and GBB.GroupTrans[req.name] then
local entry=GBB.GroupTrans[req.name]

GameTooltip:AddLine(GBB.Tool.IconClass[entry.class]..
GameTooltip:AddLine((GBB.Tool.GetClassIcon(entry.class) or "")..
"|c"..GBB.Tool.ClassColor[entry.class].colorStr ..
entry.name)
if entry.dungeon then
Expand Down

0 comments on commit 77baaa6

Please sign in to comment.