2019-12-12 16:32:49 +00:00
|
|
|
extends Node
|
|
|
|
|
|
|
|
# Declare member variables here. Examples:
|
|
|
|
# var a = 2
|
|
|
|
# var b = "text"
|
|
|
|
|
|
|
|
var _msg_xml = XMLParser.new()
|
|
|
|
var _msg_md5sum
|
2020-01-05 15:16:07 +00:00
|
|
|
var _msg_data = {}
|
2019-12-12 16:32:49 +00:00
|
|
|
|
|
|
|
func open_message_xml():
|
|
|
|
var file = File.new()
|
|
|
|
file.open("res://assets/Definition/msg.xml", File.READ)
|
|
|
|
var content = file.get_as_text()
|
|
|
|
_msg_md5sum = content.md5_text()
|
|
|
|
file.close()
|
|
|
|
_msg_xml.open("res://assets/Definition/msg.xml")
|
|
|
|
print("[msg:open_message_xml] " + _msg_md5sum)
|
|
|
|
|
|
|
|
func is_correct_md5(value):
|
|
|
|
return (_msg_md5sum == value)
|
|
|
|
|
|
|
|
func read_all_node():
|
|
|
|
var i
|
|
|
|
_msg_xml.seek(0)
|
|
|
|
var ret = _msg_xml.read()
|
|
|
|
var branch = ""
|
|
|
|
var leaf = ""
|
|
|
|
while ret == OK:
|
|
|
|
#print("Node: Name:" + _msg_xml.get_node_name() + ", Type:" + str(_msg_xml.get_node_type()) + ", Data:" + str(_msg_xml.get_node_data()) + ", attribut count:" + str(_msg_xml.get_attribute_count()) )
|
|
|
|
#i = 0
|
|
|
|
#while i < _msg_xml.get_attribute_count():
|
|
|
|
# print(" -- Attribut Name:" + _msg_xml.get_attribute_name(i) + " Value:" + _msg_xml.get_attribute_value(i))
|
|
|
|
# i += 1
|
2020-01-05 15:16:07 +00:00
|
|
|
if _msg_xml.get_node_type() != XMLParser.NODE_ELEMENT:
|
|
|
|
ret = _msg_xml.read()
|
|
|
|
continue
|
|
|
|
|
2019-12-12 16:32:49 +00:00
|
|
|
match _msg_xml.get_node_name():
|
|
|
|
"branch":
|
|
|
|
i = 0
|
|
|
|
while i < _msg_xml.get_attribute_count() and _msg_xml.get_attribute_name(i) != "name":
|
|
|
|
i += 1
|
|
|
|
if i < _msg_xml.get_attribute_count():
|
|
|
|
branch = _msg_xml.get_attribute_value(i)
|
2020-01-05 15:16:07 +00:00
|
|
|
#print(branch + " " + str(_msg_xml.get_node_type()))
|
|
|
|
_msg_data[branch] = []
|
2019-12-12 16:32:49 +00:00
|
|
|
"leaf":
|
|
|
|
i = 0
|
|
|
|
while i < _msg_xml.get_attribute_count() and _msg_xml.get_attribute_name(i) != "name":
|
|
|
|
i += 1
|
|
|
|
if i < _msg_xml.get_attribute_count():
|
2020-01-05 15:16:07 +00:00
|
|
|
leaf = _msg_xml.get_attribute_value(i)
|
|
|
|
#print(branch + ":" + leaf + str(_msg_xml.get_node_type()))
|
|
|
|
_msg_data[branch].append(leaf)
|
2019-12-12 16:32:49 +00:00
|
|
|
ret = _msg_xml.read()
|
2020-01-05 15:16:07 +00:00
|
|
|
print("Branch:" + str(_msg_data.size()))
|
|
|
|
for key in _msg_data:
|
|
|
|
print(" " + key + ":" + str(_msg_data[key].size()))
|
|
|
|
for leaf in _msg_data[key]:
|
|
|
|
print(" " + key + ":" + leaf)
|
|
|
|
|
2019-12-12 16:32:49 +00:00
|
|
|
|
|
|
|
# Called when the node enters the scene tree for the first time.
|
|
|
|
func _ready():
|
|
|
|
open_message_xml()
|
|
|
|
read_all_node()
|
2020-01-05 15:16:07 +00:00
|
|
|
print("[msg] ready")
|
2019-12-12 16:32:49 +00:00
|
|
|
|
|
|
|
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
|
|
|
#func _process(delta):
|
|
|
|
# pass
|