-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #268 from klingbolt/godot_file_handler
Godot File Handler
- Loading branch information
Showing
5 changed files
with
46 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
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(converter_executable_path, args, true, output, true) | ||
print(output) | ||
if result != OK: | ||
print("Failed to execute the converter. Error code:", result) | ||
else: | ||
print("Command executed successfully.") | ||
|
||
static func create_directory_if_missing(path: String): | ||
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
extends FileDialog | ||
|
||
const FileHandler = preload("res://FileHandler.gd") | ||
var downloaded_markers_dir: String | ||
var unsaved_markers_dir: String | ||
var user_data_dir: String | ||
|
||
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") | ||
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: 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) | ||
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) |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters