Skip to content
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

Open
wants to merge 2 commits into
base: xml_converter
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 3 additions & 11 deletions ImportPackDialog.gd
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
Comment on lines 5 to +6
Copy link
Owner

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


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)
30 changes: 28 additions & 2 deletions Settings.gd
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 = {}
Expand All @@ -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
Copy link
Owner

Choose a reason for hiding this comment

The 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 = {}
Expand All @@ -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
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens if self.downloaded_markers_dir or self.unsaved_markers_dir changes during runtime?


func save():
_config_data = {
Expand All @@ -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
Copy link
Owner

Choose a reason for hiding this comment

The 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 "user_data_dir", "download_markers_dir", and "unsaved_markers_dir" from the settings every time the data is saved?

Additionally, do you want to save this data to the dynamic default values of OS.get_user_data_dir() if the user has not explicitly configured a custom path?

"unsaved_changes": unsaved_changes
}

var file = File.new()
Expand Down
14 changes: 7 additions & 7 deletions Spatial.gd
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,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
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You probably dont need a local shadow of Settings.unsaved_changes here. Otherwise you have to keep them in sync, which it does not look like you are doing in this pr.


server.listen(4242)

Expand Down Expand Up @@ -395,14 +397,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://protobin_by_map_id/"
# 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()
Expand Down Expand Up @@ -546,7 +545,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)


Expand All @@ -555,7 +554,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():
Expand Down Expand Up @@ -877,6 +876,7 @@ func refresh_trail2d_points(trail2d: Line2D):
trail2d.refresh_points()



################################################################################
# Signal Functions
################################################################################
Expand Down
Loading