Skip to content

Commit

Permalink
Added method to call xml_converter
Browse files Browse the repository at this point in the history
  • Loading branch information
klingbolt committed Jan 1, 2024
1 parent 4df5c1b commit ece36df
Show file tree
Hide file tree
Showing 5 changed files with 82 additions and 8 deletions.
6 changes: 6 additions & 0 deletions Category2D.gd
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,9 @@ func add_path2d(path):
func add_subcategory(subcategory):
self.add_child(subcategory, true)
subcategories.push_back(subcategory)

func clear_all():
self.paths2d = []
self.subcategories = []
for child in self.get_children():
child.queue_free()
7 changes: 7 additions & 0 deletions Category3D.gd
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,10 @@ func add_icon(icon):
func add_subcategory(subcategory):
self.add_child(subcategory, true)
subcategories.push_back(subcategory)

func clear_all():
self.paths = []
self.icons = []
self.subcategories = []
for child in self.get_children():
child.queue_free()
65 changes: 65 additions & 0 deletions PackDialog.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
extends Control

const executable_path: String = "./xml_converter/build/xml_converter"
var protobin_data_folder: String
var split_protobin_data_folder: String
var user_data_dir: String
onready var output_dialog = $WindowDialog
onready var output_label = $WindowDialog/ScrollContainer/Label

func _ready():
var dir = Directory.new()
self.user_data_dir = str(OS.get_user_data_dir())
self.protobin_data_folder = self.user_data_dir.plus_file("packs")
self.split_protobin_data_folder = self.user_data_dir.plus_file("protobins")
if not dir.dir_exists(self.protobin_data_folder):
var success = dir.make_dir(self.protobin_data_folder)
if success != OK:
print("Error: Could not create data folder:", self.protobin_data_folder)


func clear_directory_contents(dir_path: String) -> void:
var dir = Directory.new()
if dir.open(dir_path) == OK:
while dir.get_next():
var entry_path: String = dir_path + "/" + dir.get_file()
# Remove subdirectories and files, but not "." and ".."
if dir.current_is_dir() and dir.get_file() != "." and dir.get_file() != "..":
clear_directory_contents(entry_path)
# Remove the subdirectory after its contents are cleared
dir.remove(entry_path)
elif dir.current_is_file():
dir.remove(entry_path)
else:
print("Failed to open directory:", dir_path)

func _on_FileDialog_dir_selected(dir_path):
var output: Array = []
print("Selected folder:", dir_path)
var dir = Directory.new()
var new_path: String = self.protobin_data_folder.plus_file(dir_path.get_file())
if not dir.dir_exists(new_path):
var success = dir.make_dir(new_path)
if success != OK:
print("Error: Could not create data folder:", self.protobin_data_folder)
#else:
# #Pop up here to confirm overwrite?
# clear_directory_contents(dir_path)
var args: PoolStringArray = [
"--input-taco-path", dir_path,
"--output-waypoint-path", new_path,
"--output-split-waypoint-path", self.split_protobin_data_folder]
custom_print(args)
var result: int = OS.execute(self.executable_path, args, true, output)
custom_print(output)
if result != OK:
print("Failed to execute the command. Error code:", result)
else:
print("Command executed successfully.")

func custom_print(message: Array):
output_dialog.show()
for line in message:
output_label.text += line + "\n"


7 changes: 2 additions & 5 deletions Spatial.gd
Original file line number Diff line number Diff line change
Expand Up @@ -482,11 +482,8 @@ func _unhandled_input(event):
################################################################################
func clear_map_markers():
# Clear all the rendered assets to make way for the new ones
for child in self.markers_3d.get_children():
child.queue_free()

for child in self.markers_2d.get_children():
child.queue_free()
self.markers_3d.clear_all()
self.markers_2d.clear_all()

func init_category_tree():
self.markers_ui.clear()
Expand Down
5 changes: 2 additions & 3 deletions Spatial.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -936,7 +936,6 @@ __meta__ = {
[connection signal="pressed" from="Control/GlobalMenuButton/EditorQuckPanel/HBoxContainer/NewIcon" to="." method="_on_NewIcon_pressed"]
[connection signal="pressed" from="Control/GlobalMenuButton/EditorQuckPanel/HBoxContainer/AdjustPoints" to="." method="_on_AdjustNodesButton_pressed"]
[connection signal="dir_selected" from="Control/Dialogs/FileDialog" to="Control/Dialogs/FileDialog" method="_on_FileDialog_dir_selected"]
[connection signal="file_selected" from="Control/Dialogs/FileDialog" to="Control/Dialogs/FileDialog" method="_on_FileDialog_file_selected"]
[connection signal="hide" from="Control/Dialogs/FileDialog" to="." method="_on_Dialog_hide"]
[connection signal="hide" from="Control/Dialogs/MainMenu" to="." method="_on_Dialog_hide"]
[connection signal="pressed" from="Control/Dialogs/MainMenu/ScrollContainer/VBoxContainer/LoadPath" to="." method="_on_LoadPath_pressed"]
Expand Down Expand Up @@ -983,9 +982,9 @@ __meta__ = {
[connection signal="text_changed" from="Control/Dialogs/SettingsDialog/ScrollContainer/GridContainer/WinePath" to="Control/Dialogs/SettingsDialog" method="save_settings"]
[connection signal="text_changed" from="Control/Dialogs/SettingsDialog/ScrollContainer/GridContainer/EnvironmentVars" to="Control/Dialogs/SettingsDialog" method="save_settings"]
[connection signal="hide" from="Control/Dialogs/CategoriesDialog" to="." method="_on_Dialog_hide"]
[connection signal="cell_selected" from="Control/Dialogs/CategoriesDialog/MarkersUI" to="." method="_on_MarkerPacks_cell_selected"]
[connection signal="cell_selected" from="Control/Dialogs/CategoriesDialog/MarkersUI" to="." method="_on_MarkersUI_cell_selected"]
[connection signal="item_edited" from="Control/Dialogs/CategoriesDialog/MarkersUI" to="." method="_on_MarkerPacks_item_edited"]
[connection signal="cell_selected" from="Control/Dialogs/CategoriesDialog/MarkersUI" to="." method="_on_MarkerPacks_cell_selected"]
[connection signal="item_edited" from="Control/Dialogs/CategoriesDialog/MarkersUI" to="." method="_on_MarkersUI_item_edited"]
[connection signal="item_edited" from="Control/Dialogs/CategoriesDialog/MarkersUI" to="." method="_on_MarkerPacks_item_edited"]
[connection signal="multi_selected" from="Control/Dialogs/CategoriesDialog/MarkersUI" to="." method="_on_Tree_multi_selected"]
[connection signal="tree_entered" from="Control/Dialogs/CategoriesDialog/MarkersUI" to="." method="_on_Tree_tree_entered"]

0 comments on commit ece36df

Please sign in to comment.