Skip to content

Commit

Permalink
Merge pull request #344 from klingbolt/single_marker_save_file
Browse files Browse the repository at this point in the history
Single File for saving imported packs
  • Loading branch information
AsherGlick authored Sep 2, 2024
2 parents 543d09f + 2723a49 commit 8e826f8
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 9 deletions.
15 changes: 12 additions & 3 deletions Spatial.gd
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,7 @@ var waypoint_data = Waypoint.Waypoint.new()
# by Map ID. All changes made by the editor are automatically saved in these
# files prior to export.
var unsaved_markers_dir = "user://protobin_by_map_id/"
var saved_markers_dir = "user://protobin/"
var marker_file_path = ""

func load_waypoint_markers(map_id_to_load: int):
Expand Down Expand Up @@ -1109,11 +1110,19 @@ func _on_ImportPackDialog_dir_selected(dir):
var user_data_dir = str(OS.get_user_data_dir())
var args: PoolStringArray = [
"--input-taco-path", dir,
# TODO: This line is not working as intended and needs to be investigated
# "--input-waypoint-path", user_data_dir.plus_file("protobin"),
"--output-waypoint-path", user_data_dir.plus_file("protobin"),
"--input-waypoint-path", ProjectSettings.globalize_path(self.saved_markers_dir),
"--output-waypoint-path", ProjectSettings.globalize_path(self.saved_markers_dir),
"--output-split-waypoint-path", ProjectSettings.globalize_path(self.unsaved_markers_dir)
]
FileHandler.call_xml_converter(args)
save_hashes()
load_waypoint_markers(self.map_id)


func _on_SaveData_pressed():
var user_data_dir = str(OS.get_user_data_dir())
var args: PoolStringArray = [
"--input-waypoint-path", ProjectSettings.globalize_path(self.unsaved_markers_dir),
"--output-waypoint-path", ProjectSettings.globalize_path(self.saved_markers_dir),
]
FileHandler.call_xml_converter(args)
4 changes: 2 additions & 2 deletions Spatial.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ margin_bottom = 92.0
rect_min_size = Vector2( 0, 40 )
text = "Import Marker Pack"

[node name="SaveTrail" type="Button" parent="Control/Dialogs/MainMenu/ScrollContainer/VBoxContainer"]
[node name="SaveData" type="Button" parent="Control/Dialogs/MainMenu/ScrollContainer/VBoxContainer"]
margin_top = 96.0
margin_right = 220.0
margin_bottom = 136.0
Expand Down Expand Up @@ -889,7 +889,7 @@ material/0 = SubResource( 4 )
[connection signal="hide" from="Control/Dialogs/MainMenu" to="." method="_on_Dialog_hide"]
[connection signal="pressed" from="Control/Dialogs/MainMenu/ScrollContainer/VBoxContainer/LoadTrail" to="." method="_on_LoadTrail_pressed"]
[connection signal="pressed" from="Control/Dialogs/MainMenu/ScrollContainer/VBoxContainer/ImportPath" to="." method="_on_ImportPath_pressed"]
[connection signal="pressed" from="Control/Dialogs/MainMenu/ScrollContainer/VBoxContainer/SaveTrail" to="." method="_on_SaveTrail_pressed"]
[connection signal="pressed" from="Control/Dialogs/MainMenu/ScrollContainer/VBoxContainer/SaveData" to="." method="_on_SaveData_pressed"]
[connection signal="pressed" from="Control/Dialogs/MainMenu/ScrollContainer/VBoxContainer/OpenEditorQuickPanel" to="." method="_on_OpenEditorQuickPanel_pressed"]
[connection signal="pressed" from="Control/Dialogs/MainMenu/ScrollContainer/VBoxContainer/Ranges" to="." method="_on_RangesButton_pressed"]
[connection signal="pressed" from="Control/Dialogs/MainMenu/ScrollContainer/VBoxContainer/Settings" to="." method="_on_Settings_pressed"]
Expand Down
12 changes: 8 additions & 4 deletions xml_converter/src/attribute/image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,10 @@ string image_to_xml_attribute(
const Image* value) {
if (filesystem::exists(filesystem::path(value->original_filepath))) {
filesystem::path output_path = filesystem::path(state->marker_pack_root_directory) / value->filename;
filesystem::create_directories(output_path.parent_path());
filesystem::copy_file(filesystem::path(value->original_filepath), output_path, filesystem::copy_options::overwrite_existing);
if (value->original_filepath != output_path) {
filesystem::create_directories(output_path.parent_path());
filesystem::copy_file(filesystem::path(value->original_filepath), output_path, filesystem::copy_options::overwrite_existing);
}
}
else {
cout << "Warning: File path " << value->original_filepath << " not found." << endl;
Expand Down Expand Up @@ -87,8 +89,10 @@ void image_to_proto(
state->textures.push_back(&value);
if (filesystem::exists(filesystem::path(value.original_filepath))) {
filesystem::path output_path = filesystem::path(state->marker_pack_root_directory) / value.filename;
filesystem::create_directories(output_path.parent_path());
filesystem::copy_file(filesystem::path(value.original_filepath), output_path, filesystem::copy_options::overwrite_existing);
if (value.original_filepath != output_path) {
filesystem::create_directories(output_path.parent_path());
filesystem::copy_file(filesystem::path(value.original_filepath), output_path, filesystem::copy_options::overwrite_existing);
}
}
else {
cout << "Warning: File path " << value.original_filepath << " not found." << endl;
Expand Down

0 comments on commit 8e826f8

Please sign in to comment.