diff options
Diffstat (limited to 'util')
| -rw-r--r-- | util/extract_panels.rb | 14 | ||||
| -rw-r--r-- | util/generate_gamedata.rb | 37 | 
2 files changed, 51 insertions, 0 deletions
| diff --git a/util/extract_panels.rb b/util/extract_panels.rb new file mode 100644 index 0000000..d524f6e --- /dev/null +++ b/util/extract_panels.rb | |||
| @@ -0,0 +1,14 @@ | |||
| 1 | require 'yaml' | ||
| 2 | |||
| 3 | mappath = ARGV[0] | ||
| 4 | outputpath = ARGV[1] | ||
| 5 | |||
| 6 | panels = [] | ||
| 7 | |||
| 8 | File.readlines(mappath).each do |line| | ||
| 9 | line.match(/node name=\"(.*)\" parent=\"Panels\/(.*)\" instance/) do |m| | ||
| 10 | panels << {"id" => m[2] + "/" + m[1]} | ||
| 11 | end | ||
| 12 | end | ||
| 13 | |||
| 14 | File.write(outputpath, panels.to_yaml) | ||
| diff --git a/util/generate_gamedata.rb b/util/generate_gamedata.rb new file mode 100644 index 0000000..7f4216f --- /dev/null +++ b/util/generate_gamedata.rb | |||
| @@ -0,0 +1,37 @@ | |||
| 1 | require 'yaml' | ||
| 2 | |||
| 3 | configpath = ARGV[0] | ||
| 4 | outputpath = ARGV[1] | ||
| 5 | |||
| 6 | config = YAML.load_file(configpath) | ||
| 7 | output = config.map do |panel| | ||
| 8 | ret = panel | ||
| 9 | if ret["color"].kind_of? String | ||
| 10 | ret["color"] = [ret["color"]] | ||
| 11 | end | ||
| 12 | ret | ||
| 13 | end.map do |panel| | ||
| 14 | ret = {} | ||
| 15 | ret["id"] = "\"#{panel["id"]}\"" | ||
| 16 | ret["color"] = "[\"" + panel["color"].join("\",\"") + "\"]" | ||
| 17 | ret["tag"] = "\"#{panel["tag"]}\"" | ||
| 18 | if panel.include? "subtag" | ||
| 19 | ret["subtag"] = "\"#{panel["subtag"]}\"" | ||
| 20 | end | ||
| 21 | if panel.include? "link" | ||
| 22 | ret["link"] = "\"#{panel["link"]}\"" | ||
| 23 | end | ||
| 24 | if panel.include? "copy_to_sign" | ||
| 25 | ret["copy_to_sign"] = "\"#{panel["copy_to_sign"]}\"" | ||
| 26 | end | ||
| 27 | ret | ||
| 28 | end.map do |panel| | ||
| 29 | "{" + panel.to_a.map do |element| | ||
| 30 | "\"#{element[0]}\":#{element[1]}" | ||
| 31 | end.join(",") + "}" | ||
| 32 | end.join(",") | ||
| 33 | |||
| 34 | header = "extends Node\n\nvar panels = [" | ||
| 35 | footer = "]" | ||
| 36 | |||
| 37 | File.write(outputpath, header + output + footer) \ No newline at end of file | ||
