-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Folder names to settings #324
base: xml_converter
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,17 @@ | ||
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) | ||
pass | ||
|
||
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()) | ||
var new_path: String = Settings.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 | ||
"--output-split-waypoint-path", Settings.unsaved_markers_dir | ||
] | ||
FileHandler.call_xml_converter(args) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
extends Node | ||
|
||
const CONFIG_PATH = "user://settings.json" | ||
const FileHandler = preload("res://FileHandler.gd") | ||
|
||
var _config_data = {} | ||
var local_category_data = {} | ||
|
@@ -17,12 +18,24 @@ var burrito_link_wine_path: String = "" | |
var burrito_link_env_args: String = "" | ||
|
||
|
||
var user_data_dir: String | ||
var downloaded_markers_dir: String | ||
#We save the marker data in this directory when the files are have been split | ||
#by Map ID. All changes made by the editor are automatically saved in these | ||
#files prior to export. | ||
Comment on lines
+23
to
+25
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: same as in #323 where this comment is from I think. Add a space after each |
||
var unsaved_markers_dir: String | ||
|
||
var unsaved_changes: bool = false | ||
|
||
func _ready(): | ||
var file = File.new() | ||
file.open(CONFIG_PATH, file.READ) | ||
var text = file.get_as_text() | ||
var datum = JSON.parse(text) | ||
self._config_data = JSON.parse(text).result | ||
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("protobin_by_map_id") | ||
|
||
if self._config_data == null: | ||
self._config_data = {} | ||
|
@@ -45,7 +58,16 @@ func _ready(): | |
self.burrito_link_wine_path = self._config_data["burrito_link_wine_path"] | ||
if "burrito_link_env_args" in self._config_data: | ||
self.burrito_link_env_args = self._config_data["burrito_link_env_args"] | ||
|
||
if "user_data_dir" in self._config_data: | ||
self.user_data_dir = self._config_data["user_data_dir"] | ||
if "downloaded_markers_dir" in self._config_data: | ||
self.downloaded_markers_dir = self._config_data["downloaded_markers_dir"] | ||
if "unsaved_markers_dir" in self._config_data: | ||
self.unsaved_markers_dir = self._config_data["unsaved_markers_dir"] | ||
if "unsaved_changes" in self._config_data: | ||
self.unsaved_changes = self._config_data["unsaved_changes"] | ||
FileHandler.create_directory_if_missing(self.downloaded_markers_dir) | ||
FileHandler.create_directory_if_missing(self.unsaved_markers_dir) | ||
Comment on lines
+69
to
+70
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What happens if |
||
|
||
func save(): | ||
_config_data = { | ||
|
@@ -57,7 +79,11 @@ func save(): | |
"burrito_link_auto_launch_enabled": burrito_link_auto_launch_enabled, | ||
"burrito_link_wine_path": burrito_link_wine_path, | ||
"burrito_link_env_args": burrito_link_env_args, | ||
"local_category_data": local_category_data | ||
"local_category_data": local_category_data, | ||
#"user_data_dir" : user_data_dir, | ||
#"downloaded_markers_dir": downloaded_markers_dir, | ||
#"unsaved_markers_dir": unsaved_markers_dir, | ||
Comment on lines
+83
to
+85
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why are we loading this data but not saving it? Won't this effectively delete Additionally, do you want to save this data to the dynamic default values of |
||
"unsaved_changes": unsaved_changes | ||
} | ||
|
||
var file = File.new() | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -82,6 +82,8 @@ func _ready(): | |
# Postion at top left corner | ||
OS.set_window_position(Vector2(0,0)) | ||
set_minimal_mouse_block() | ||
if Settings.unsaved_changes: | ||
set_unsaved_changes(Settings.unsaved_changes) | ||
Comment on lines
+88
to
+89
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You probably dont need a local shadow of |
||
|
||
server.listen(4242) | ||
|
||
|
@@ -390,14 +392,11 @@ func reset_3D_minimap_masks(category: Spatial): | |
|
||
|
||
var waypoint_data = Waypoint.Waypoint.new() | ||
#We save the marker data in this directory when the files are have been split | ||
#by Map ID. All changes made by the editor are automatically saved in these | ||
#files prior to export. | ||
var unsaved_markers_dir = "user://protobins/" | ||
# Filepath for the current map | ||
var marker_file_path = "" | ||
|
||
func load_waypoint_markers(map_id_to_load: int): | ||
self.marker_file_path = self.unsaved_markers_dir + String(map_id_to_load) + ".bin" | ||
self.marker_file_path = Settings.unsaved_markers_dir.plus_file(String(map_id_to_load) + ".bin") | ||
self.waypoint_data = Waypoint.Waypoint.new() | ||
clear_map_markers() | ||
init_category_tree() | ||
|
@@ -541,7 +540,7 @@ func _waypoint_categories_to_godot_nodes(item: TreeItem, waypoint_category: Wayp | |
if texture_id == null: | ||
print("Warning: No texture found in " , category_name) | ||
continue | ||
var full_texture_path = self.unsaved_markers_dir + self.waypoint_data.get_textures()[texture_id].get_filepath() | ||
var full_texture_path = Settings.unsaved_markers_dir + self.waypoint_data.get_textures()[texture_id].get_filepath() | ||
gen_new_trail(full_texture_path, trail, category_item) | ||
|
||
|
||
|
@@ -550,7 +549,7 @@ func _waypoint_categories_to_godot_nodes(item: TreeItem, waypoint_category: Wayp | |
if texture_id == null: | ||
print("Warning: No texture found in " , category_name) | ||
continue | ||
var full_texture_path = self.unsaved_markers_dir + self.waypoint_data.get_textures()[texture_id].get_filepath() | ||
var full_texture_path = Settings.unsaved_markers_dir + self.waypoint_data.get_textures()[texture_id].get_filepath() | ||
gen_new_icon(full_texture_path, icon, category_item) | ||
|
||
for category_child in waypoint_category.get_children(): | ||
|
@@ -631,6 +630,8 @@ func gen_new_icon(texture_path: String, waypoint_icon: Waypoint.Icon, category_i | |
func set_unsaved_changes(value): | ||
if self.unsaved_changes != value: | ||
unsaved_changes = value | ||
Settings.unsaved_changes = self.unsaved_changes | ||
Settings.save() | ||
update_burrito_icon() | ||
|
||
func update_burrito_icon(): | ||
|
@@ -647,7 +648,7 @@ func save_current_map_data(): | |
var file = File.new() | ||
file.open(self.marker_file_path, file.WRITE) | ||
file.store_buffer(packed_bytes) | ||
set_unsaved_changes(false) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why are you removing "marking that there are no longer unsaved changes" from the function that saves changes and therefore removes unsaved changes? |
||
|
||
|
||
|
||
################################################################################ | ||
|
@@ -767,7 +768,7 @@ func set_icon_position(new_position: Vector3, waypoint_icon: Waypoint.Icon, icon | |
position.set_y(new_position.y) | ||
position.set_z(new_position.z) | ||
icon.set_position(new_position) | ||
set_unsaved_changes(true) | ||
Settings.set_unsaved_changes(true) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does this function exist? Did you test this code? |
||
|
||
func remove_icon(waypoint_icon: Waypoint.Icon, icon: Sprite3D): | ||
if icon.waypoint != waypoint_icon: | ||
|
@@ -853,18 +854,19 @@ func new_trail_point_after(waypoint_trail: Waypoint.Trail, trail3d: Spatial, tra | |
|
||
func refresh_trail3d_points(trail3d: Spatial): | ||
trail3d.refresh_mesh() | ||
set_unsaved_changes(true) | ||
Settings.set_unsaved_changes(true) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does this function exist? |
||
|
||
func refresh_trail2d_points(trail2d: Line2D): | ||
trail2d.refresh_points() | ||
set_unsaved_changes(true) | ||
Settings.set_unsaved_changes(true) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does this function exist? |
||
|
||
|
||
################################################################################ | ||
# Signal Functions | ||
################################################################################ | ||
func _on_SaveTrail_pressed(): | ||
save_current_map_data() | ||
Settings.set_unsaved_changes(false) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does this function exist? |
||
|
||
func _on_main_menu_toggle_pressed(): | ||
$Control/Dialogs/MainMenu.show() | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function can be deleted if it only contained the no-op
pass