Skip to content

Commit 2d58fac

Browse files
committed
Fixed enum table strings and sorting
1 parent afc8e9a commit 2d58fac

File tree

2 files changed

+30
-12
lines changed

2 files changed

+30
-12
lines changed

Annotations/Core/Data/Enum.lua

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9810,6 +9810,10 @@ Constants = {
98109810
DEFAULT_AUCTION_PRICE_MULTIPLIER = 1.5,
98119811
},
98129812
CAAConstants = {
9813+
CAASayCombatEndDefault = true,
9814+
CAATargetNameDefault = true,
9815+
CAASayCombatStartDefault = true,
9816+
CAAEnabledDefault = false,
98139817
CAAFrequencyMin = -10,
98149818
CAAFrequencyDefault = 0,
98159819
CAAInterruptCastDefault = 0,
@@ -9821,12 +9825,10 @@ Constants = {
98219825
CAAPlayerResourcePercentDefault = 0,
98229826
CAATargetCastFormatDefault = 0,
98239827
CAATargetCastModeDefault = 0,
9824-
CAAEnabledDefault = false,
98259828
CAATargetDeathBehaviorDefault = 0,
98269829
CAAThrottleDefault = 0,
98279830
CAAThrottleMin = 0,
98289831
CAAVoiceDefault = 0,
9829-
CAATargetNameDefault = true,
98309832
CAAMinCastTimeStep = 0.5,
98319833
CAAThrottleStep = 0.5,
98329834
CAAPlayerHealthFormatDefault = 1,
@@ -9840,8 +9842,6 @@ Constants = {
98409842
CAAMinCastTimeMax = 5,
98419843
CAAThrottleMax = 5,
98429844
CAAFrequencyMax = 10,
9843-
CAASayCombatEndDefault = true,
9844-
CAASayCombatStartDefault = true,
98459845
},
98469846
CalendarGetEventTypeConstants = {
98479847
DEFAULT_CALENDAR_GET_EVENT_TYPE = 0,
@@ -9850,8 +9850,8 @@ Constants = {
98509850
MaxCallings = 3,
98519851
},
98529852
CatalogShopVirtualCurrencyConstants = {
9853-
HEARTHSTEEL_VC_CURRENCY_CODE = XVV,
9854-
TRADERS_TENDER_VC_CURRENCY_CODE = XWP,
9853+
HEARTHSTEEL_VC_CURRENCY_CODE = "XVV",
9854+
TRADERS_TENDER_VC_CURRENCY_CODE = "XWP",
98559855
},
98569856
CharCustomizationConstants = {
98579857
NUM_CUSTOM_DISPLAY = 4,

luasrc/annotate/literals.lua

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,18 @@ local function SortByValue(tbl)
4242
table.insert(t, {key=key, value=value})
4343
end
4444
table.sort(t, function(a, b)
45-
if a.value ~= b.value then
46-
if type(a.value) == "boolean" or type(b.value) == "boolean" then
47-
return a and not b
45+
if type(a.value) == type(b.value) then
46+
if type(a.value) == "boolean" then
47+
return a.value and not b.value
4848
else
49-
return a.value < b.value
49+
if a.value == b.value then
50+
return a.key < b.key
51+
else
52+
return a.value < b.value
53+
end
5054
end
5155
else
52-
return a.key < b.key
56+
return type(a.value) < type(b.value)
5357
end
5458
end)
5559
return t
@@ -72,6 +76,16 @@ local function IsBitEnum(tbl, name)
7276
return true
7377
end
7478

79+
-- sort a table with numbers, strings and booleans as value
80+
local function SortEnum(a, b)
81+
local typeA, typeB = type(a), type(b)
82+
if typeA == typeB then
83+
return a < b
84+
else
85+
return a < b
86+
end
87+
end
88+
7589
function m:GetEnumTable()
7690
Util:DownloadAndRun(
7791
string.format("https://raw.githubusercontent.com/Ketho/BlizzardInterfaceResources/%s/Resources/LuaEnum.lua", BLIZZRES_BRANCH),
@@ -100,7 +114,11 @@ function m:GetEnumTable()
100114
for _, name in pairs(Util:SortTable(Constants)) do
101115
table.insert(t, string.format("\t%s = {", name))
102116
for _, constTbl in pairs(SortByValue(Constants[name])) do
103-
table.insert(t, string.format("\t\t%s = %s,", constTbl.key, constTbl.value))
117+
if type(constTbl.value) == "string" then
118+
table.insert(t, string.format('\t\t%s = "%s",', constTbl.key, constTbl.value))
119+
else
120+
table.insert(t, string.format("\t\t%s = %s,", constTbl.key, constTbl.value))
121+
end
104122
end
105123
table.insert(t, "\t},")
106124
end

0 commit comments

Comments
 (0)