Skip to content

Commit 3900abb

Browse files
authored
Merge pull request #723 from Xian55/backport/4.3.4
Addon: [1.8.0] - Add support Legacy Cataclysm 4.3.4 client
2 parents 87fdf73 + 93731b8 commit 3900abb

File tree

156 files changed

+50426
-1024
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

156 files changed

+50426
-1024
lines changed
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
param(
2+
[Parameter(Mandatory = $true)]
3+
[string]$InputCsvPath = "community-listfile.csv", # https://github.com/wowdev/wow-listfile/releases/latest/download/community-listfile.csv
4+
[string]$OutputLuaPath = "LegacyTextureToFileID.lua",
5+
[switch]$OnlyIcons = $true # keep only interface/icons/*
6+
)
7+
8+
Write-Host "Reading $InputCsvPath ..."
9+
$rows = Get-Content -Raw -Path $InputCsvPath -ErrorAction Stop |
10+
ConvertFrom-Csv -Delimiter ';' -Header 'FileID','Path'
11+
12+
# Filter: remove .meta and optionally only icons
13+
$filtered = $rows | Where-Object {
14+
$_.Path -and
15+
$_.Path -notmatch '\.meta$' -and
16+
(-not $OnlyIcons -or $_.Path -match '^interface/icons/')
17+
}
18+
19+
Write-Host "Found $($filtered.Count) candidate rows."
20+
21+
# Start Lua file
22+
@(
23+
"-- Auto-generated from wowdev community-listfile.csv",
24+
"-- Generated: $(Get-Date -Format 'yyyy-MM-dd HH:mm:ss')",
25+
"",
26+
"DataToColor = DataToColor or {}",
27+
"DataToColor.LegacyTextureToFileID = {"
28+
) | Set-Content -Path $OutputLuaPath -Encoding UTF8
29+
30+
$seen = [System.Collections.Generic.HashSet[string]]::new()
31+
32+
foreach ($row in $filtered) {
33+
$fileID = [int]$row.FileID
34+
if ($fileID -le 0) { continue }
35+
36+
# normalize
37+
$p = $row.Path.Trim().ToLower()
38+
$p = $p -replace '\.blp$', ''
39+
$p = $p -replace '/', '\\'
40+
41+
# only keep ones starting with interface\
42+
if ($p -notmatch '^interface\\') { continue }
43+
44+
# ensure consistent key
45+
$key = $p
46+
47+
# avoid duplicates
48+
if ($seen.Add($key)) {
49+
$line = ' ["{0}"] = {1},' -f $key, $fileID
50+
Add-Content -Path $OutputLuaPath -Value $line -Encoding UTF8
51+
}
52+
}
53+
54+
Add-Content -Path $OutputLuaPath -Value "}" -Encoding UTF8
55+
Write-Host "✅ Done! Wrote $OutputLuaPath"

.bat/Generate-WorldMapMapping.ps1

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
$luaFile = "UIMapIDToWorldMapAreaID.lua" # https://www.townlong-yak.com/framexml/8.1.5/Blizzard_Deprecated/UIMapIDToWorldMapAreaID.lua
2+
$csvFile = "UiMap.8.1.0.27826.csv" # https://wago.tools/db2/UiMap?build=8.1.0.27826&page=1
3+
$outFile = "WorldMapAreaIDToUiMapID.lua"
4+
5+
# Build UiMapID → Name lookup (if CSV available)
6+
$names = @{}
7+
if (Test-Path $csvFile) {
8+
Import-Csv $csvFile | ForEach-Object {
9+
if ($_.Name_lang -and $_.ID) {
10+
$names[[int]$_.ID] = $_.Name_lang
11+
}
12+
}
13+
}
14+
15+
# Parse UiMapID → WorldMapAreaID
16+
$mapping = @{}
17+
Select-String -Path $luaFile -Pattern '^\d+,' | ForEach-Object {
18+
$cols = $_.Line -split ','
19+
if ($cols.Count -ge 2) {
20+
$uiMap = [int]$cols[0]
21+
$worldMap = [int]$cols[1]
22+
if ($uiMap -gt 0 -and $worldMap -gt 0) {
23+
if (-not $mapping.ContainsKey($worldMap) -or $uiMap -lt $mapping[$worldMap]) {
24+
$mapping[$worldMap] = $uiMap
25+
}
26+
}
27+
}
28+
}
29+
30+
# Write output
31+
@(
32+
"-- Auto-generated mapping WorldMapAreaID → UiMapID"
33+
"DataToColor = DataToColor or {}"
34+
"DataToColor.WorldMapAreaIDToUiMapID = {"
35+
) + ($mapping.GetEnumerator() | Sort-Object Name | ForEach-Object {
36+
$comment = ""
37+
if ($names.ContainsKey($_.Value)) {
38+
$comment = " -- $($names[$_.Value])"
39+
}
40+
" [$($_.Name)] = $($_.Value),$comment"
41+
}) + "}" | Set-Content $outFile -Encoding UTF8
42+
43+
Write-Host "✅ Generated $outFile with $($mapping.Count) entries"

Addons/DataToColor/Collections.lua

Lines changed: 48 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,59 @@
1+
--[[
2+
Collections.lua
3+
4+
This file provides data structures for managing collections of data over time.
5+
It is designed for the DataToColor addon.
6+
]]
7+
18
local Load = select(2, ...)
29
local DataToColor = unpack(Load)
310

411
local GetTime = GetTime
512

13+
--------------------------------------------------------------------------------
14+
-- TimedQueue
15+
-- A queue that releases one item at a time, after a specified tick lifetime.
16+
-- This is used to iterate over a collection of items across multiple frames.
17+
--------------------------------------------------------------------------------
618
local TimedQueue = {}
719
DataToColor.TimedQueue = TimedQueue
820

21+
-- Constructor for a new TimedQueue
922
function TimedQueue:new(tickLifetime, defaultValue)
1023
local o = {
11-
head = {}, tail = {}, index = 1, headLength = 0,
12-
tickLifetime = tickLifetime,
13-
lastValue = defaultValue,
14-
lastChangedTick = 0, defaultValue = defaultValue }
24+
head = {}, -- The current batch of items to process
25+
tail = {}, -- The next batch of items
26+
index = 1, -- The current position in the head
27+
headLength = 0, -- The number of items in the head
28+
tickLifetime = tickLifetime, -- How many ticks an item stays as the current value
29+
lastValue = defaultValue, -- The last value shifted from the queue
30+
lastChangedTick = 0, -- The tick when the last value was changed
31+
defaultValue = defaultValue -- The value to return when the queue is empty
32+
}
1533
setmetatable(o, self)
1634
self.__index = self
1735
return o
1836
end
1937

38+
-- Shifts an item from the queue if the lifetime has expired.
39+
-- Otherwise, returns the last shifted item.
2040
function TimedQueue:shift(globalTick)
41+
-- Check if it's time to get a new item
2142
if math.abs(globalTick - self.lastChangedTick) >= self.tickLifetime or self.lastValue == self.defaultValue then
43+
-- If we've processed all items in the head, swap with the tail
2244
if self.index > self.headLength then
2345
self.head, self.tail = self.tail, self.head
2446
self.index = 1
2547
self.headLength = #self.head
48+
-- If the new head is empty, we're done for now
2649
if self.headLength == 0 then
2750
self.lastValue = self.defaultValue
2851
return
2952
end
3053
end
54+
3155
local value = self.head[self.index]
32-
self.head[self.index] = nil
56+
self.head[self.index] = nil -- Clear the value from the old table
3357
self.index = self.index + 1
3458

3559
self.lastValue = value
@@ -41,10 +65,12 @@ function TimedQueue:shift(globalTick)
4165
return self.lastValue
4266
end
4367

68+
-- Adds an item to the tail of the queue.
4469
function TimedQueue:push(item)
4570
return table.insert(self.tail, item)
4671
end
4772

73+
-- Peeks at the next item to be shifted without actually shifting it.
4874
function TimedQueue:peek()
4975
if self.index <= self.headLength then
5076
return self.head[self.index]
@@ -55,48 +81,58 @@ function TimedQueue:peek()
5581
return nil
5682
end
5783

84+
--------------------------------------------------------------------------------
85+
-- TimedMap
86+
-- A map-like structure where entries can be marked as "dirty" and have a
87+
-- time-based component for retrieval.
88+
--------------------------------------------------------------------------------
5889
local struct = {}
59-
DataToColor.struct = struct
90+
DataToColor.struct = struct -- Assign to old name for backward compatibility
6091

92+
-- Constructor for a new TimedMap
6193
function struct:new(tickLifetime)
6294
local o = {
63-
table = {},
95+
entries = {}, -- The storage for key-value pairs
6496
tickLifetime = tickLifetime,
6597
lastChangedTick = 0,
6698
lastKey = -1
6799
}
100+
-- For backward compatibility, also provide .table as alias to .entries
101+
o.table = o.entries
68102
setmetatable(o, self)
69103
self.__index = self
70104
return o
71105
end
72106

107+
-- Sets a value for a key.
73108
function struct:set(key, value)
74-
local entry = self.table[key]
109+
local entry = self.entries[key]
75110
if not entry then
76-
self.table[key] = { value = value or key, dirty = 0 }
111+
self.entries[key] = { value = value or key, dirty = 0 }
77112
return
78113
end
79114

80115
entry.value = value or key
81116
entry.dirty = 0
82117
end
83118

119+
-- Gets a key-value pair that is not dirty or has expired.
84120
function struct:getTimed(globalTick)
85121
local time = GetTime()
86-
for k, v in pairs(self.table) do
122+
for k, v in pairs(self.entries) do
87123
if v.dirty == 0 or (v.dirty == 1 and v.value - time <= 0) then
88124
if self.lastKey ~= k then
89125
self.lastKey = k
90126
self.lastChangedTick = globalTick
91-
--print("changed: ", globalTick, " key:", k, " val: ", v.value)
92127
end
93128
return k, v.value
94129
end
95130
end
96131
end
97132

133+
-- Gets a key-value pair, ignoring dirty status.
98134
function struct:getForced(globalTick)
99-
for k, v in pairs(self.table) do
135+
for k, v in pairs(self.entries) do
100136
if self.lastKey ~= v.value then
101137
self.lastKey = v.value
102138
self.lastChangedTick = globalTick

Addons/DataToColor/Constants.lua

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,51 @@ DataToColor.C.unitSoftInteract = "softinteract"
3737

3838
DataToColor.C.SpellQueueWindow = "SpellQueueWindow"
3939

40+
DataToColor.C.CHARACTER_CLASS_MAP = {
41+
["None"] = 0,
42+
["Warrior"] = 1,
43+
["Paladin"] = 2,
44+
["Hunter"] = 3,
45+
["Rogue"] = 4,
46+
["Priest"] = 5,
47+
["DeathKnight"] = 6,
48+
["Shaman"] = 7,
49+
["Mage"] = 8,
50+
["Warlock"] = 9,
51+
["Monk"] = 10,
52+
["Druid"] = 11,
53+
["DemonHunter"] = 12
54+
}
55+
56+
DataToColor.C.CHARACTER_RACE_MAP = {
57+
["None"] = 0,
58+
["Human"] = 1,
59+
["Orc"] = 2,
60+
["Dwarf"] = 3,
61+
["NightElf"] = 4,
62+
["Undead"] = 5,
63+
["Tauren"] = 6,
64+
["Gnome"] = 7,
65+
["Troll"] = 8,
66+
["Goblin"] = 9,
67+
["BloodElf"] = 10,
68+
["Draenei"] = 11,
69+
["Worgen"] = 22
70+
}
71+
4072
-- Character's name
4173
DataToColor.C.CHARACTER_NAME = UnitName(DataToColor.C.unitPlayer)
4274
DataToColor.C.CHARACTER_GUID = UnitGUID(DataToColor.C.unitPlayer)
43-
_, DataToColor.C.CHARACTER_CLASS, DataToColor.C.CHARACTER_CLASS_ID = UnitClass(DataToColor.C.unitPlayer)
44-
_, _, DataToColor.C.CHARACTER_RACE_ID = UnitRace(DataToColor.C.unitPlayer)
75+
DataToColor.C.CHARACTER_CLASS_LOWER, DataToColor.C.CHARACTER_CLASS, DataToColor.C.CHARACTER_CLASS_ID = UnitClass(DataToColor.C.unitPlayer)
76+
DataToColor.C.CHARACTER_RACE, _, DataToColor.C.CHARACTER_RACE_ID = UnitRace(DataToColor.C.unitPlayer)
77+
78+
if DataToColor.C.CHARACTER_RACE_ID == nil then
79+
DataToColor.C.CHARACTER_RACE_ID = DataToColor.C.CHARACTER_RACE_MAP[DataToColor.C.CHARACTER_RACE]
80+
end
81+
82+
if DataToColor.C.CHARACTER_CLASS_ID == nil then
83+
DataToColor.C.CHARACTER_CLASS_ID = DataToColor.C.CHARACTER_CLASS_MAP[DataToColor.C.CHARACTER_CLASS_LOWER]
84+
end
4585

4686
-- Spells
4787
DataToColor.C.Spell.AutoShotId = 75

0 commit comments

Comments
 (0)