@@ -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
7377end
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+
7589function 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