diff options
author | Tiger Wang <ziwei.tiger@outlook.com> | 2020-08-19 21:48:15 +0200 |
---|---|---|
committer | Tiger Wang <ziwei.tiger@outlook.com> | 2020-08-19 21:48:15 +0200 |
commit | 77ee79d35c86f0911c47ddfade9261f98b964d9a (patch) | |
tree | e836f09d622b81c3b802528ea463c7b3cbe4946a /Tools | |
parent | Lua generator (diff) | |
download | cuberite-1.14.tar cuberite-1.14.tar.gz cuberite-1.14.tar.bz2 cuberite-1.14.tar.lz cuberite-1.14.tar.xz cuberite-1.14.tar.zst cuberite-1.14.zip |
Diffstat (limited to 'Tools')
-rw-r--r-- | Tools/BlockTypePaletteGenerator/ItemGenerator.lua | 33 |
1 files changed, 23 insertions, 10 deletions
diff --git a/Tools/BlockTypePaletteGenerator/ItemGenerator.lua b/Tools/BlockTypePaletteGenerator/ItemGenerator.lua index 5eff87603..8150b6837 100644 --- a/Tools/BlockTypePaletteGenerator/ItemGenerator.lua +++ b/Tools/BlockTypePaletteGenerator/ItemGenerator.lua @@ -197,26 +197,39 @@ local function writeItems(registry) io.write("\nenum class Statistic\n{\n", table.concat(names, ",\n"), "\n};")
end
-local function writeGlobalPalette(registry)
- io.write("UInt32 FromItem(Statistic ID)\n{\nswitch (ID)\n{")
+local function writeGlobalPalette(registry) + io.write("UInt32 From(const Statistic ID)\n{\nswitch (ID)\n{")
for itemName, id in spairs(registry) do
io.write("\ncase Statistic::", makeTitleCase(itemName), ": return ", id, ";")
end
- io.write("\ndefault: return 0;\n}\n}")
+ io.write("\ndefault: return -1;\n}\n}")
end
local function writeReverseGlobalPalette(registry)
- io.write("Item ToStatistic(UInt32 ID)\n{\nswitch (ID)\n{")
+ io.write("Item ToStatistic(const UInt32 ID)\n{\nswitch (ID)\n{") for itemName, id in spairs(registry) do
io.write("\ncase ", id, ": return Item::", makeTitleCase(itemName), ";")
end
io.write("\ndefault: return Statistic::Air;\n}\n}")
end
+ +local function writeReverseSerializer(registry)
+ for itemName in spairs(registry) do
+ io.write("{ \"", itemName, "\", Statistic::", makeTitleCase(itemName), " },\n")
+ end
+end
-if true then
- writeItems(registry)
-else
- writeGlobalPalette(registry)
- io.write("\n\n")
- writeReverseGlobalPalette(registry)
+local function writeSerializer(registry)
+ io.write("const char * From(const Statistic ID)\n{\nswitch (ID)\n{")
+ for itemName in spairs(registry) do
+ io.write("\ncase Statistic::", makeTitleCase(itemName), ": return \"", itemName, "\";")
+ end
end
+
+-- writeSerializer(registry)
+
+-- writeItems(registry)
+
+writeGlobalPalette(registry)
+-- io.write("\n\n")
+-- writeReverseGlobalPalette(registry) |