mirror of
https://github.com/brues-code/ClassicAPI.git
synced 2026-11-16 16:10:36 +00:00
All eight markers live in one 4x4 sheet on this client, and the per-marker files other clients ship are absent here — the art directory holds only UI-RaidTargetingIcons.blp. So naming a single marker requires a sheet plus a sub-rect, which is what an atlas is. A port referencing an individual marker file otherwise gets nothing. Blizzard publishes no atlas names for these. Checked: zero hits for raidtarget / targeting / raidmarker in UiTextureAtlasMember, and current Classic Era still draws them by computing texcoords in SetRaidTargetIconTexture and by per-file |T markup in chat. The names here therefore follow the standalone marker filenames other clients ship, so an addon written against those finds the art under the name it already knows. This lives in the addon rather than AtlasData.h on purpose: the DLL's built-in table means "names Blizzard defined", and adding invented ones there would quietly corrupt that contract. Cell math matches the chat marker tokens, and markers 4 and 8 were confirmed on screen. Also adds CreateAtlasMarkup alongside the existing texture markup helper.
129 lines
5.1 KiB
Lua
129 lines
5.1 KiB
Lua
TextureUtil = {};
|
|
|
|
function SetClampedTextureRotation(texture, rotationDegrees)
|
|
if (rotationDegrees ~= 0 and rotationDegrees ~= 90 and rotationDegrees ~= 180 and rotationDegrees ~= 270) then
|
|
error("SetRotation: rotationDegrees must be 0, 90, 180, or 270");
|
|
return;
|
|
end
|
|
|
|
if not (texture.rotationDegrees) then
|
|
texture.origTexCoords = {texture:GetTexCoord()};
|
|
texture.origWidth = texture:GetWidth();
|
|
texture.origHeight = texture:GetHeight();
|
|
end
|
|
|
|
if (texture.rotationDegrees == rotationDegrees) then
|
|
return;
|
|
end
|
|
|
|
texture.rotationDegrees = rotationDegrees;
|
|
|
|
if (rotationDegrees == 0 or rotationDegrees == 180) then
|
|
texture:SetWidth(texture.origWidth);
|
|
texture:SetHeight(texture.origHeight);
|
|
else
|
|
texture:SetWidth(texture.origHeight);
|
|
texture:SetHeight(texture.origWidth);
|
|
end
|
|
|
|
if (rotationDegrees == 0) then
|
|
texture:SetTexCoord( texture.origTexCoords[1], texture.origTexCoords[2],
|
|
texture.origTexCoords[3], texture.origTexCoords[4],
|
|
texture.origTexCoords[5], texture.origTexCoords[6],
|
|
texture.origTexCoords[7], texture.origTexCoords[8] );
|
|
elseif (rotationDegrees == 90) then
|
|
texture:SetTexCoord( texture.origTexCoords[3], texture.origTexCoords[4],
|
|
texture.origTexCoords[7], texture.origTexCoords[8],
|
|
texture.origTexCoords[1], texture.origTexCoords[2],
|
|
texture.origTexCoords[5], texture.origTexCoords[6] );
|
|
elseif (rotationDegrees == 180) then
|
|
texture:SetTexCoord( texture.origTexCoords[7], texture.origTexCoords[8],
|
|
texture.origTexCoords[5], texture.origTexCoords[6],
|
|
texture.origTexCoords[3], texture.origTexCoords[4],
|
|
texture.origTexCoords[1], texture.origTexCoords[2] );
|
|
elseif (rotationDegrees == 270) then
|
|
texture:SetTexCoord( texture.origTexCoords[5], texture.origTexCoords[6],
|
|
texture.origTexCoords[1], texture.origTexCoords[2],
|
|
texture.origTexCoords[7], texture.origTexCoords[8],
|
|
texture.origTexCoords[3], texture.origTexCoords[4] );
|
|
end
|
|
end
|
|
|
|
function ClearClampedTextureRotation(texture)
|
|
if (texture.rotationDegrees) then
|
|
SetClampedTextureRotation(texture, 0);
|
|
texture.origTexCoords = nil;
|
|
texture.origWidth = nil;
|
|
texture.origHeight = nil;
|
|
texture.rotationDegrees = nil;
|
|
end
|
|
end
|
|
|
|
function GetTexCoordsByGrid(xOffset, yOffset, textureWidth, textureHeight, gridWidth, gridHeight)
|
|
local widthPerGrid = gridWidth / textureWidth;
|
|
local heightPerGrid = gridHeight / textureHeight;
|
|
return (xOffset - 1) * widthPerGrid, (xOffset) * widthPerGrid, (yOffset - 1) * heightPerGrid, (yOffset) * heightPerGrid;
|
|
end
|
|
|
|
-- left/right/top/bottom are normalized [0..1] coords within the file (the
|
|
-- markup's texel fields are produced by multiplying back up by the file size).
|
|
function CreateTextureMarkup(file, fileWidth, fileHeight, width, height, left, right, top, bottom, xOffset, yOffset)
|
|
return string.format("|T%s:%d:%d:%d:%d:%d:%d:%d:%d:%d:%d|t",
|
|
file
|
|
, height
|
|
, width
|
|
, xOffset or 0
|
|
, yOffset or 0
|
|
, fileWidth
|
|
, fileHeight
|
|
, left * fileWidth
|
|
, right * fileWidth
|
|
, top * fileHeight
|
|
, bottom * fileHeight
|
|
);
|
|
end
|
|
|
|
function CreateSimpleTextureMarkup(file, width, height, xOffset, yOffset)
|
|
return string.format("|T%s:%d:%d:%d:%d|t",
|
|
file
|
|
, height or width
|
|
, width
|
|
, xOffset or 0
|
|
, yOffset or 0
|
|
);
|
|
end
|
|
|
|
function CreateAtlasMarkup(atlasName, width, height, offsetX, offsetY)
|
|
return string.format("|A:%s:%d:%d:%d:%d|a",
|
|
atlasName
|
|
, height or 0
|
|
, width or 0
|
|
, offsetX or 0
|
|
, offsetY or 0
|
|
);
|
|
end
|
|
|
|
-- Raid target markers, published as atlas names.
|
|
--
|
|
-- All eight markers live in one 4x4 sheet, so naming a single marker means
|
|
-- naming a cell inside that sheet — exactly what an atlas is for. Blizzard
|
|
-- publishes no atlas names for these, so the names here follow the standalone
|
|
-- marker files that other clients ship. An addon written against those files
|
|
-- finds the art under the name it already knows.
|
|
--
|
|
-- Marker N sits at column (N-1) mod 4 and row floor((N-1) / 4), counting from
|
|
-- the top left. That is the same cell math the chat marker tokens use.
|
|
local RAID_TARGET_SHEET = "Interface\\TargetingFrame\\UI-RaidTargetingIcons";
|
|
local RAID_TARGET_COLUMNS = 4;
|
|
local RAID_TARGET_CELL = 0.25; -- a 64 pixel cell in a 256 pixel sheet
|
|
|
|
for marker = 1, 8 do
|
|
local index = marker - 1;
|
|
local left = math.mod(index, RAID_TARGET_COLUMNS) * RAID_TARGET_CELL;
|
|
local top = math.floor(index / RAID_TARGET_COLUMNS) * RAID_TARGET_CELL;
|
|
C_Texture.RegisterAtlas("UI-RaidTargetingIcon_"..marker, RAID_TARGET_SHEET,
|
|
64, 64,
|
|
left, left + RAID_TARGET_CELL,
|
|
top, top + RAID_TARGET_CELL);
|
|
end
|