diff --git a/game/ui/about/About.tscn b/game/ui/about/About.tscn index 41e6fe74..35ac75e4 100644 --- a/game/ui/about/About.tscn +++ b/game/ui/about/About.tscn @@ -96,48 +96,49 @@ SOFTWARE." visible = false anchor_right = 1.0 anchor_bottom = 1.0 -margin_left = 8.0 -margin_top = 62.0 -margin_bottom = 27.0 +margin_left = 4.0 +margin_top = 31.0 +margin_right = -4.0 +margin_bottom = -4.0 size_flags_horizontal = 3 script = ExtResource( 7 ) tree_path = NodePath("HBoxContainer/Tree") rtl_path = NodePath("HBoxContainer/PanelContainer/RichTextLabel") [node name="Label" type="Label" parent="PanelContainer/VBoxContainer/TabContainer/Third-Party Licenses"] -margin_right = 712.0 +margin_right = 720.0 margin_bottom = 51.0 text = "This project relies on a number of third-party free and open source assets/components, all compatible with the terms of its MIT license. The following is an exhaustive list of all such third-party components with their respective copyright statements and license terms." autowrap = true [node name="HBoxContainer" type="HSplitContainer" parent="PanelContainer/VBoxContainer/TabContainer/Third-Party Licenses"] margin_top = 59.0 -margin_right = 712.0 -margin_bottom = 361.0 +margin_right = 720.0 +margin_bottom = 396.0 size_flags_horizontal = 3 size_flags_vertical = 3 split_offset = -88 [node name="Tree" type="Tree" parent="PanelContainer/VBoxContainer/TabContainer/Third-Party Licenses/HBoxContainer"] -margin_right = 262.0 -margin_bottom = 302.0 +margin_right = 266.0 +margin_bottom = 337.0 size_flags_horizontal = 3 size_flags_vertical = 3 hide_folding = true hide_root = true [node name="PanelContainer" type="PanelContainer" parent="PanelContainer/VBoxContainer/TabContainer/Third-Party Licenses/HBoxContainer"] -margin_left = 274.0 -margin_right = 712.0 -margin_bottom = 302.0 +margin_left = 278.0 +margin_right = 720.0 +margin_bottom = 337.0 size_flags_horizontal = 3 size_flags_vertical = 3 [node name="RichTextLabel" type="RichTextLabel" parent="PanelContainer/VBoxContainer/TabContainer/Third-Party Licenses/HBoxContainer/PanelContainer"] margin_left = 4.0 margin_top = 4.0 -margin_right = 434.0 -margin_bottom = 298.0 +margin_right = 438.0 +margin_bottom = 333.0 size_flags_horizontal = 3 size_flags_vertical = 3 diff --git a/game/ui/about/Third-Party Licenses.gd b/game/ui/about/Third-Party Licenses.gd index 1bd95a0c..1d86700a 100644 --- a/game/ui/about/Third-Party Licenses.gd +++ b/game/ui/about/Third-Party Licenses.gd @@ -8,6 +8,15 @@ var rtl : RichTextLabel var populated : bool = false +var _data : Array = Array() + +enum AttibutionIndex { + ATTRIBUTION_INDEX_NAME = 0, + ATTRIBUTION_INDEX_URL = 1, + ATTRIBUTION_INDEX_DESCRIPTION = 2, + ATTRIBUTION_INDEX_LICENSES = 3, +} + func _enter_tree(): tree = get_node(tree_path) as Tree rtl = get_node(rtl_path) as RichTextLabel @@ -28,6 +37,25 @@ func populate(): populated = true + #root + tree.create_item() + + _data.clear() + load_all_xmls("res://") + + for entry in _data: + var main : TreeItem = tree.create_item() + + main.set_text(0, entry[0][0]) + main.set_metadata(0, data_arr_to_string(entry[0])) + + for i in range(1, entry.size()): + var curr : TreeItem = tree.create_item(main) + + curr.set_text(0, entry[i][0]) + curr.set_metadata(0, data_arr_to_string(entry[i])) + + # tree.create_item() # # for info in Engine.get_copyright_info(): @@ -49,3 +77,86 @@ func populate(): # # ti.set_metadata(0, st) # ti.set_text(0, info["name"]) + +func load_all_xmls(path : String) -> void: + var dir = Directory.new() + if dir.open(path) == OK: + dir.list_dir_begin() + var file_name = dir.get_next() + while file_name != "": + if file_name == "." or file_name == "..": + file_name = dir.get_next() + continue + + if dir.current_is_dir(): + if path == "res://": + load_all_xmls(path + file_name) + else: + load_all_xmls(path + "/" + file_name) + else: + if file_name == "Attributions.xml": + if path == "res://": + load_xml(path + file_name) + else: + load_xml(path + "/" + file_name) + + file_name = dir.get_next() + else: + print("An error occurred when trying to access the path: " + path) + +func load_xml(path : String) -> void: + var parser : XMLParser = XMLParser.new() + var err = parser.open(path) + + if err != OK: + print("Couldn't open file: " + path + " Err: " + err) + return + + var attributions : Array = Array() + attributions.resize(1) + var attrib : PoolStringArray = PoolStringArray() + attrib.resize(4) + var curr_element : String = "" + while parser.read() == OK: + if parser.get_node_type() == XMLParser.NODE_ELEMENT: + curr_element = parser.get_node_name() + + elif parser.get_node_type() == XMLParser.NODE_TEXT: + if curr_element == "Name": + attrib[AttibutionIndex.ATTRIBUTION_INDEX_NAME] = parser.get_node_data() + elif curr_element == "Description": + attrib[AttibutionIndex.ATTRIBUTION_INDEX_DESCRIPTION] = parser.get_node_data() + elif curr_element == "Licenses": + attrib[AttibutionIndex.ATTRIBUTION_INDEX_LICENSES] = parser.get_node_data() + elif curr_element == "URL": + attrib[AttibutionIndex.ATTRIBUTION_INDEX_URL] = parser.get_node_data() + + elif parser.get_node_type() == XMLParser.NODE_ELEMENT_END: + if parser.get_node_name() == "Attribution": + attributions.push_back(attrib) + attrib = PoolStringArray() + attrib.resize(4) + elif parser.get_node_name() == "Module": + attributions[0] = attrib + attrib = PoolStringArray() + attrib.resize(4) + + if attributions[0] == null: + print("Attributions file does not have a Module tag! Path: " + path) + + _data.push_back(attributions) + +func data_arr_to_string(arr : Array) -> String: + var s : String = "" + + s += arr[AttibutionIndex.ATTRIBUTION_INDEX_NAME] + "\n\n" + + if arr[AttibutionIndex.ATTRIBUTION_INDEX_URL] != "": + s += "url: " + arr[AttibutionIndex.ATTRIBUTION_INDEX_URL] + "\n\n" + + s += arr[AttibutionIndex.ATTRIBUTION_INDEX_DESCRIPTION] + "\n\n" + + s += "License(s):\n\n" + s += arr[AttibutionIndex.ATTRIBUTION_INDEX_LICENSES] + + return s