From cdb4e5a99c85c2519206c47254f2ef11d04b708a Mon Sep 17 00:00:00 2001 From: klingbolt Date: Sat, 20 Jan 2024 12:14:15 -0500 Subject: [PATCH 01/10] Changed name of file that will hold all functions for loading and saving files. Deleted obsolete JSON code --- PackDialog.gd => FileHandler.gd | 2 ++ Spatial.gd | 43 +++++++++------------------------ Spatial.tscn | 4 +-- 3 files changed, 15 insertions(+), 34 deletions(-) rename PackDialog.gd => FileHandler.gd (97%) diff --git a/PackDialog.gd b/FileHandler.gd similarity index 97% rename from PackDialog.gd rename to FileHandler.gd index 10b86f2e..947445bc 100644 --- a/PackDialog.gd +++ b/FileHandler.gd @@ -1,5 +1,7 @@ extends Control +const Waypoint = preload("res://waypoint.gd") + const executable_path: String = "./xml_converter/build/xml_converter" var protobin_data_folder: String var split_protobin_data_folder: String diff --git a/Spatial.gd b/Spatial.gd index 63d186b3..88c00485 100644 --- a/Spatial.gd +++ b/Spatial.gd @@ -51,9 +51,14 @@ const category3d_scene = preload("res://Category3D.tscn") const category2d_scene = preload("res://Category2D.tscn") const path2d_scene = preload("res://Route2D.tscn") const gizmo_scene = preload("res://Gizmo/PointEdit.tscn") + +# Scripts containing code used by this scene const CategoryData = preload("res://CategoryData.gd") const Waypoint = preload("res://waypoint.gd") -const PackDialog = preload("res://PackDialog.gd") +const FileHandler = preload("res://FileHandler.gd") + +# Instancing scripts +var file_handler: FileHandler = FileHandler.new() ##########Node Connections########### onready var markers_ui := $Control/Dialogs/CategoriesDialog/MarkersUI as Tree @@ -80,6 +85,9 @@ func _ready(): OS.set_window_position(Vector2(0,0)) set_minimal_mouse_block() + # Call ready for additional scripts + self.file_handler._ready() + server.listen(4242) if (Settings.burrito_link_auto_launch_enabled): @@ -632,32 +640,6 @@ func gen_new_icon(position: Vector3, texture_path: String, waypoint_icon, catego var category_data = category_item.get_metadata(0) category_data.category3d.add_icon(new_icon) -# This function take all of the currently rendered objects and converts it into -# the data format that is saved/loaded from. -func data_from_renderview(): - var icons_data = [] - var paths_data = [] - - for icon in $Icons.get_children(): - icons_data.append({ - "position": [icon.translation.x, icon.translation.y, -icon.translation.z], - "texture": icon.texture_path - }) - - for path in $Paths.get_children(): - #print(path) - var points = [] - for point in range(path.get_point_count()): - var point_position:Vector3 = path.get_point_position(point) - points.append([point_position.x, point_position.y, -point_position.z]) - paths_data.append({ - "points": points, - "texture": path.texture_path - }) - - var data_out = {"icons": icons_data, "paths": paths_data} - return data_out - ################################################################################ # Adjustment and gizmo functions ################################################################################ @@ -822,16 +804,13 @@ func _on_NewPathPoint_pressed(): # ################################################################################ func _on_SavePath_pressed(): - $Control/Dialogs/SaveDialog.show() + pass ################################################################################ # TODO: This function will be used when exporting packs ################################################################################ func _on_SaveDialog_file_selected(path): - self.markerdata[str(self.map_id)] = data_from_renderview() - var save_game = File.new() - save_game.open(path, File.WRITE) - save_game.store_string(JSON.print(self.markerdata)) + pass func _on_NodeEditorDialog_hide(): self.currently_selected_node = null diff --git a/Spatial.tscn b/Spatial.tscn index a220578a..96ff7495 100644 --- a/Spatial.tscn +++ b/Spatial.tscn @@ -3,6 +3,7 @@ [ext_resource path="res://Spatial.gd" type="Script" id=1] [ext_resource path="res://shaders/range_indicators.shader" type="Shader" id=2] [ext_resource path="res://burrito.png" type="Texture" id=3] +[ext_resource path="res://FileHandler.gd" type="Script" id=4] [ext_resource path="res://icon_close.png" type="Texture" id=5] [ext_resource path="res://RangeDialog.gd" type="Script" id=6] [ext_resource path="res://icon_new_icon.png" type="Texture" id=7] @@ -12,7 +13,6 @@ [ext_resource path="res://icon_new_point.png" type="Texture" id=11] [ext_resource path="res://SettingsDialog.gd" type="Script" id=12] [ext_resource path="res://Category3D.gd" type="Script" id=13] -[ext_resource path="res://PackDialog.gd" type="Script" id=14] [ext_resource path="res://Category2D.gd" type="Script" id=15] [sub_resource type="Shader" id=1] @@ -193,7 +193,7 @@ mode = 2 access = 2 current_dir = "" current_path = "" -script = ExtResource( 14 ) +script = ExtResource( 4 ) __meta__ = { "_edit_use_anchors_": false } From 629d3eedffc4d90b75ae3d19572ab712267ecdde Mon Sep 17 00:00:00 2001 From: klingbolt Date: Sat, 20 Jan 2024 12:16:00 -0500 Subject: [PATCH 02/10] Removed extra lines --- FileHandler.gd | 2 -- 1 file changed, 2 deletions(-) diff --git a/FileHandler.gd b/FileHandler.gd index 947445bc..10b86f2e 100644 --- a/FileHandler.gd +++ b/FileHandler.gd @@ -1,7 +1,5 @@ extends Control -const Waypoint = preload("res://waypoint.gd") - const executable_path: String = "./xml_converter/build/xml_converter" var protobin_data_folder: String var split_protobin_data_folder: String From fecd28d02a8abbc26da5e36ab59470b7d6d9291f Mon Sep 17 00:00:00 2001 From: klingbolt Date: Sat, 2 Mar 2024 20:44:24 -0500 Subject: [PATCH 03/10] Spliting xml converter functions into seperate file from dialogs --- FileHandler.gd | 34 ++++++++++----------------------- ImportPackDialog.gd | 20 ++++++++++++++++++++ Spatial.gd | 46 +++++++++++++++++++++++++-------------------- Spatial.tscn | 13 +++++++++++-- 4 files changed, 67 insertions(+), 46 deletions(-) create mode 100644 ImportPackDialog.gd diff --git a/FileHandler.gd b/FileHandler.gd index 10b86f2e..d6174a9d 100644 --- a/FileHandler.gd +++ b/FileHandler.gd @@ -6,35 +6,14 @@ var split_protobin_data_folder: String var user_data_dir: String 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) - if not dir.dir_exists(self.split_protobin_data_folder): - var success = dir.make_dir(self.split_protobin_data_folder) - if success != OK: - print("Error: Could not create data folder:", self.split_protobin_data_folder) + ensure_folder_existance(self.protobin_data_folder) + ensure_folder_existance(self.split_protobin_data_folder) -func _on_FileDialog_dir_selected(dir_path): +func call_xml_converter(args): 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? - var args: PoolStringArray = [ - "--input-taco-path", dir_path, - "--output-waypoint-path", new_path, - "--output-split-waypoint-path", self.split_protobin_data_folder - ] print(args) var result: int = OS.execute(self.executable_path, args, true, output, true) print(output) @@ -42,3 +21,10 @@ func _on_FileDialog_dir_selected(dir_path): print("Failed to execute the command. Error code:", result) else: print("Command executed successfully.") + +func ensure_folder_existance(path): + var dir = Directory.new() + if not dir.dir_exists(path): + var success = dir.make_dir(path) + if success != OK: + print("Error: Could not create data folder:", path) diff --git a/ImportPackDialog.gd b/ImportPackDialog.gd new file mode 100644 index 00000000..27eaed01 --- /dev/null +++ b/ImportPackDialog.gd @@ -0,0 +1,20 @@ +extends FileDialog +const FileHandler = preload("res://FileHandler.gd") +var file_handler: FileHandler + +func _ready(): + self.file_handler = FileHandler.new() + pass + +func _on_FileDialog_dir_selected(dir_path): + print("Selected folder:", dir_path) + var new_path: String = file_handler.protobin_data_folder.plus_file(dir_path.get_file()) + file_handler.ensure_folder_existance(new_path) + #else: + # #Pop up here to confirm overwrite? + var args: PoolStringArray = [ + "--input-taco-path", dir_path, + "--output-waypoint-path", new_path, + "--output-split-waypoint-path", file_handler.split_protobin_data_folder + ] + file_handler.call_xml_converter(args) diff --git a/Spatial.gd b/Spatial.gd index 88c00485..861efbe4 100644 --- a/Spatial.gd +++ b/Spatial.gd @@ -55,10 +55,6 @@ const gizmo_scene = preload("res://Gizmo/PointEdit.tscn") # Scripts containing code used by this scene const CategoryData = preload("res://CategoryData.gd") const Waypoint = preload("res://waypoint.gd") -const FileHandler = preload("res://FileHandler.gd") - -# Instancing scripts -var file_handler: FileHandler = FileHandler.new() ##########Node Connections########### onready var markers_ui := $Control/Dialogs/CategoriesDialog/MarkersUI as Tree @@ -85,9 +81,6 @@ func _ready(): OS.set_window_position(Vector2(0,0)) set_minimal_mouse_block() - # Call ready for additional scripts - self.file_handler._ready() - server.listen(4242) if (Settings.burrito_link_auto_launch_enabled): @@ -640,6 +633,32 @@ func gen_new_icon(position: Vector3, texture_path: String, waypoint_icon, catego var category_data = category_item.get_metadata(0) category_data.category3d.add_icon(new_icon) +# This function take all of the currently rendered objects and converts it into +# the data format that is saved/loaded from. +func data_from_renderview(): + var icons_data = [] + var paths_data = [] + + for icon in $Icons.get_children(): + icons_data.append({ + "position": [icon.translation.x, icon.translation.y, -icon.translation.z], + "texture": icon.texture_path + }) + + for path in $Paths.get_children(): + #print(path) + var points = [] + for point in range(path.get_point_count()): + var point_position:Vector3 = path.get_point_position(point) + points.append([point_position.x, point_position.y, -point_position.z]) + paths_data.append({ + "points": points, + "texture": path.texture_path + }) + + var data_out = {"icons": icons_data, "paths": paths_data} + return data_out + ################################################################################ # Adjustment and gizmo functions ################################################################################ @@ -799,19 +818,6 @@ func _on_NewPathPoint_pressed(): self.currently_active_path.add_point(z_accurate_player_position) self.currently_active_path_2d.add_point(Vector2(self.player_position.x, -self.player_position.z)) - -################################################################################ -# -################################################################################ -func _on_SavePath_pressed(): - pass - -################################################################################ -# TODO: This function will be used when exporting packs -################################################################################ -func _on_SaveDialog_file_selected(path): - pass - func _on_NodeEditorDialog_hide(): self.currently_selected_node = null clear_adjustment_nodes() diff --git a/Spatial.tscn b/Spatial.tscn index 96ff7495..164877af 100644 --- a/Spatial.tscn +++ b/Spatial.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=19 format=2] +[gd_scene load_steps=20 format=2] [ext_resource path="res://Spatial.gd" type="Script" id=1] [ext_resource path="res://shaders/range_indicators.shader" type="Shader" id=2] @@ -13,6 +13,7 @@ [ext_resource path="res://icon_new_point.png" type="Texture" id=11] [ext_resource path="res://SettingsDialog.gd" type="Script" id=12] [ext_resource path="res://Category3D.gd" type="Script" id=13] +[ext_resource path="res://ImportPackDialog.gd" type="Script" id=14] [ext_resource path="res://Category2D.gd" type="Script" id=15] [sub_resource type="Shader" id=1] @@ -71,6 +72,14 @@ __meta__ = { "_edit_use_anchors_": false } +[node name="FileHandler" type="Control" parent="Control"] +margin_right = 40.0 +margin_bottom = 40.0 +script = ExtResource( 4 ) +__meta__ = { +"_edit_use_anchors_": false +} + [node name="Markers2D" type="Node2D" parent="Control"] material = SubResource( 2 ) scale = Vector2( 2, 2 ) @@ -193,7 +202,7 @@ mode = 2 access = 2 current_dir = "" current_path = "" -script = ExtResource( 4 ) +script = ExtResource( 14 ) __meta__ = { "_edit_use_anchors_": false } From 10f7c71d66bc6e0f359746d240d2dac64ac20578 Mon Sep 17 00:00:00 2001 From: klingbolt Date: Sat, 2 Mar 2024 20:46:38 -0500 Subject: [PATCH 04/10] removed extra space --- Spatial.gd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Spatial.gd b/Spatial.gd index 861efbe4..ab0352f3 100644 --- a/Spatial.gd +++ b/Spatial.gd @@ -658,7 +658,7 @@ func data_from_renderview(): var data_out = {"icons": icons_data, "paths": paths_data} return data_out - + ################################################################################ # Adjustment and gizmo functions ################################################################################ From 61b44e71b408b96253a4de1b18737bc5ebb07fb3 Mon Sep 17 00:00:00 2001 From: klingbolt Date: Tue, 2 Apr 2024 20:14:22 -0400 Subject: [PATCH 05/10] changed to static functions and updated naming --- FileHandler.gd | 24 +++++++++++------------- ImportPackDialog.gd | 13 ++++--------- Spatial.tscn | 11 +---------- 3 files changed, 16 insertions(+), 32 deletions(-) diff --git a/FileHandler.gd b/FileHandler.gd index d6174a9d..51587914 100644 --- a/FileHandler.gd +++ b/FileHandler.gd @@ -1,28 +1,26 @@ -extends Control - -const executable_path: String = "./xml_converter/build/xml_converter" -var protobin_data_folder: String -var split_protobin_data_folder: String +var downloaded_markers_dir: String +var unsaved_markers_dir: String var user_data_dir: String -func _ready(): +func _init(): 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") - ensure_folder_existance(self.protobin_data_folder) - ensure_folder_existance(self.split_protobin_data_folder) + self.downloaded_markers_dir = self.user_data_dir.plus_file("packs") + self.unsaved_markers_dir = self.user_data_dir.plus_file("protobins") + create_directory_if_missing(self.downloaded_markers_dir) + create_directory_if_missing(self.unsaved_markers_dir) -func call_xml_converter(args): +static func call_xml_converter(args): + var executable_path: String = "./xml_converter/build/xml_converter" var output: Array = [] print(args) - var result: int = OS.execute(self.executable_path, args, true, output, true) + var result: int = OS.execute(executable_path, args, true, output, true) print(output) if result != OK: print("Failed to execute the command. Error code:", result) else: print("Command executed successfully.") -func ensure_folder_existance(path): +static func create_directory_if_missing(path): var dir = Directory.new() if not dir.dir_exists(path): var success = dir.make_dir(path) diff --git a/ImportPackDialog.gd b/ImportPackDialog.gd index 27eaed01..c10193a3 100644 --- a/ImportPackDialog.gd +++ b/ImportPackDialog.gd @@ -1,20 +1,15 @@ extends FileDialog const FileHandler = preload("res://FileHandler.gd") -var file_handler: FileHandler - -func _ready(): - self.file_handler = FileHandler.new() - pass func _on_FileDialog_dir_selected(dir_path): print("Selected folder:", dir_path) - var new_path: String = file_handler.protobin_data_folder.plus_file(dir_path.get_file()) - file_handler.ensure_folder_existance(new_path) + var new_path: String = FileHandler.downloaded_markers_dir.plus_file(dir_path.get_file()) + FileHandler.create_directory_if_missing(new_path) #else: # #Pop up here to confirm overwrite? var args: PoolStringArray = [ "--input-taco-path", dir_path, "--output-waypoint-path", new_path, - "--output-split-waypoint-path", file_handler.split_protobin_data_folder + "--output-split-waypoint-path", FileHandler.unsaved_markers_dir ] - file_handler.call_xml_converter(args) + FileHandler.call_xml_converter(args) diff --git a/Spatial.tscn b/Spatial.tscn index 164877af..05650e14 100644 --- a/Spatial.tscn +++ b/Spatial.tscn @@ -1,9 +1,8 @@ -[gd_scene load_steps=20 format=2] +[gd_scene load_steps=19 format=2] [ext_resource path="res://Spatial.gd" type="Script" id=1] [ext_resource path="res://shaders/range_indicators.shader" type="Shader" id=2] [ext_resource path="res://burrito.png" type="Texture" id=3] -[ext_resource path="res://FileHandler.gd" type="Script" id=4] [ext_resource path="res://icon_close.png" type="Texture" id=5] [ext_resource path="res://RangeDialog.gd" type="Script" id=6] [ext_resource path="res://icon_new_icon.png" type="Texture" id=7] @@ -72,14 +71,6 @@ __meta__ = { "_edit_use_anchors_": false } -[node name="FileHandler" type="Control" parent="Control"] -margin_right = 40.0 -margin_bottom = 40.0 -script = ExtResource( 4 ) -__meta__ = { -"_edit_use_anchors_": false -} - [node name="Markers2D" type="Node2D" parent="Control"] material = SubResource( 2 ) scale = Vector2( 2, 2 ) From b022773e02cc63a6b79170851ada72cc93189980 Mon Sep 17 00:00:00 2001 From: klingbolt Date: Sat, 27 Apr 2024 11:18:11 -0400 Subject: [PATCH 06/10] Moved variables back to pack dialog --- ImportPackDialog.gd | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/ImportPackDialog.gd b/ImportPackDialog.gd index c10193a3..b28aaa16 100644 --- a/ImportPackDialog.gd +++ b/ImportPackDialog.gd @@ -1,15 +1,23 @@ extends FileDialog const FileHandler = preload("res://FileHandler.gd") +var downloaded_markers_dir: String +var unsaved_markers_dir: String +var user_data_dir: String func _on_FileDialog_dir_selected(dir_path): print("Selected folder:", dir_path) - var new_path: String = FileHandler.downloaded_markers_dir.plus_file(dir_path.get_file()) + self.user_data_dir = str(OS.get_user_data_dir()) + self.downloaded_markers_dir = self.user_data_dir.plus_file("packs") + self.unsaved_markers_dir = self.user_data_dir.plus_file("protobins") + FileHandler.create_directory_if_missing(self.downloaded_markers_dir) + FileHandler.create_directory_if_missing(self.unsaved_markers_dir) + var new_path: String = self.downloaded_markers_dir.plus_file(dir_path.get_file()) FileHandler.create_directory_if_missing(new_path) #else: # #Pop up here to confirm overwrite? var args: PoolStringArray = [ "--input-taco-path", dir_path, "--output-waypoint-path", new_path, - "--output-split-waypoint-path", FileHandler.unsaved_markers_dir + "--output-split-waypoint-path", self.unsaved_markers_dir ] FileHandler.call_xml_converter(args) From 7757841adc792e923375617613f75d450c406017 Mon Sep 17 00:00:00 2001 From: klingbolt Date: Sat, 27 Apr 2024 15:35:15 -0400 Subject: [PATCH 07/10] Move variable creation to ready function --- ImportPackDialog.gd | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/ImportPackDialog.gd b/ImportPackDialog.gd index b28aaa16..d146d77e 100644 --- a/ImportPackDialog.gd +++ b/ImportPackDialog.gd @@ -1,20 +1,21 @@ extends FileDialog + const FileHandler = preload("res://FileHandler.gd") var downloaded_markers_dir: String var unsaved_markers_dir: String var user_data_dir: String -func _on_FileDialog_dir_selected(dir_path): - print("Selected folder:", dir_path) +func _ready(): self.user_data_dir = str(OS.get_user_data_dir()) self.downloaded_markers_dir = self.user_data_dir.plus_file("packs") self.unsaved_markers_dir = self.user_data_dir.plus_file("protobins") FileHandler.create_directory_if_missing(self.downloaded_markers_dir) FileHandler.create_directory_if_missing(self.unsaved_markers_dir) + +func _on_FileDialog_dir_selected(dir_path): + print("Selected folder:", dir_path) var new_path: String = self.downloaded_markers_dir.plus_file(dir_path.get_file()) FileHandler.create_directory_if_missing(new_path) - #else: - # #Pop up here to confirm overwrite? var args: PoolStringArray = [ "--input-taco-path", dir_path, "--output-waypoint-path", new_path, From bccee54f7a0118c84891ec6aae07b5bb59a76a49 Mon Sep 17 00:00:00 2001 From: klingbolt Date: Sat, 27 Apr 2024 15:55:42 -0400 Subject: [PATCH 08/10] Removed lines from File Handler --- FileHandler.gd | 16 ++-------------- ImportPackDialog.gd | 7 +++++-- 2 files changed, 7 insertions(+), 16 deletions(-) diff --git a/FileHandler.gd b/FileHandler.gd index 51587914..a1f6bcc5 100644 --- a/FileHandler.gd +++ b/FileHandler.gd @@ -1,16 +1,4 @@ -var downloaded_markers_dir: String -var unsaved_markers_dir: String -var user_data_dir: String - -func _init(): - self.user_data_dir = str(OS.get_user_data_dir()) - self.downloaded_markers_dir = self.user_data_dir.plus_file("packs") - self.unsaved_markers_dir = self.user_data_dir.plus_file("protobins") - create_directory_if_missing(self.downloaded_markers_dir) - create_directory_if_missing(self.unsaved_markers_dir) - -static func call_xml_converter(args): - var executable_path: String = "./xml_converter/build/xml_converter" +static func call_xml_converter(executable_path: String, args: PoolStringArray): var output: Array = [] print(args) var result: int = OS.execute(executable_path, args, true, output, true) @@ -20,7 +8,7 @@ static func call_xml_converter(args): else: print("Command executed successfully.") -static func create_directory_if_missing(path): +static func create_directory_if_missing(path: String): var dir = Directory.new() if not dir.dir_exists(path): var success = dir.make_dir(path) diff --git a/ImportPackDialog.gd b/ImportPackDialog.gd index d146d77e..5e26a9f0 100644 --- a/ImportPackDialog.gd +++ b/ImportPackDialog.gd @@ -4,6 +4,7 @@ const FileHandler = preload("res://FileHandler.gd") var downloaded_markers_dir: String var unsaved_markers_dir: String var user_data_dir: String +var executable_path: String = "./xml_converter/build/xml_converter" func _ready(): self.user_data_dir = str(OS.get_user_data_dir()) @@ -12,13 +13,15 @@ func _ready(): FileHandler.create_directory_if_missing(self.downloaded_markers_dir) FileHandler.create_directory_if_missing(self.unsaved_markers_dir) -func _on_FileDialog_dir_selected(dir_path): +func _on_FileDialog_dir_selected(dir_path: String): print("Selected folder:", dir_path) var new_path: String = self.downloaded_markers_dir.plus_file(dir_path.get_file()) FileHandler.create_directory_if_missing(new_path) + #else: + # #Pop up here to confirm overwrite? var args: PoolStringArray = [ "--input-taco-path", dir_path, "--output-waypoint-path", new_path, "--output-split-waypoint-path", self.unsaved_markers_dir ] - FileHandler.call_xml_converter(args) + FileHandler.call_xml_converter(self.executable_path, args) From e333616874b86752a2acbcea480295f150a09d27 Mon Sep 17 00:00:00 2001 From: klingbolt Date: Fri, 17 May 2024 19:01:45 -0400 Subject: [PATCH 09/10] fixed function that calls only one program to only call that program. Edited comments --- FileHandler.gd | 6 +++--- ImportPackDialog.gd | 6 ++---- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/FileHandler.gd b/FileHandler.gd index a1f6bcc5..3f018386 100644 --- a/FileHandler.gd +++ b/FileHandler.gd @@ -1,10 +1,10 @@ -static func call_xml_converter(executable_path: String, args: PoolStringArray): +static func call_xml_converter(args: PoolStringArray): var output: Array = [] print(args) - var result: int = OS.execute(executable_path, args, true, output, true) + var result: int = OS.execute("./xml_converter/build/xml_converter", args, true, output, true) print(output) if result != OK: - print("Failed to execute the command. Error code:", result) + print("Failed to execute the converter. Error code:", result) else: print("Command executed successfully.") diff --git a/ImportPackDialog.gd b/ImportPackDialog.gd index 5e26a9f0..3db05f00 100644 --- a/ImportPackDialog.gd +++ b/ImportPackDialog.gd @@ -4,9 +4,9 @@ const FileHandler = preload("res://FileHandler.gd") var downloaded_markers_dir: String var unsaved_markers_dir: String var user_data_dir: String -var executable_path: String = "./xml_converter/build/xml_converter" func _ready(): + #TODO: Move these to global file Settings so they can be customized self.user_data_dir = str(OS.get_user_data_dir()) self.downloaded_markers_dir = self.user_data_dir.plus_file("packs") self.unsaved_markers_dir = self.user_data_dir.plus_file("protobins") @@ -17,11 +17,9 @@ func _on_FileDialog_dir_selected(dir_path: String): print("Selected folder:", dir_path) var new_path: String = self.downloaded_markers_dir.plus_file(dir_path.get_file()) FileHandler.create_directory_if_missing(new_path) - #else: - # #Pop up here to confirm overwrite? var args: PoolStringArray = [ "--input-taco-path", dir_path, "--output-waypoint-path", new_path, "--output-split-waypoint-path", self.unsaved_markers_dir ] - FileHandler.call_xml_converter(self.executable_path, args) + FileHandler.call_xml_converter(args) From 6f0ee47f67a647619bffa950413143d273475d36 Mon Sep 17 00:00:00 2001 From: klingbolt Date: Fri, 17 May 2024 20:29:53 -0400 Subject: [PATCH 10/10] changed to constant variable --- FileHandler.gd | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/FileHandler.gd b/FileHandler.gd index 3f018386..eb0207f5 100644 --- a/FileHandler.gd +++ b/FileHandler.gd @@ -1,7 +1,9 @@ +const converter_executable_path = "./xml_converter/build/xml_converter" + static func call_xml_converter(args: PoolStringArray): var output: Array = [] print(args) - var result: int = OS.execute("./xml_converter/build/xml_converter", args, true, output, true) + var result: int = OS.execute(converter_executable_path, args, true, output, true) print(output) if result != OK: print("Failed to execute the converter. Error code:", result)