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

Save current state to split files #267

Closed

Conversation

klingbolt
Copy link
Contributor

Changes to markers are saved in the split files.

The next PR will save the splits to individual packs.

Spatial.gd Outdated Show resolved Hide resolved
Spatial.gd Outdated Show resolved Hide resolved
Spatial.gd Outdated Show resolved Hide resolved
Icon.gd Outdated Show resolved Hide resolved
Route.gd Outdated Show resolved Hide resolved
Spatial.gd Outdated
return data_out
func save_current_map_data():
var packed_bytes = self.waypoint_data.to_bytes()
if packed_bytes.size() > 0:
Copy link
Owner

Choose a reason for hiding this comment

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

Does this check prevent saving a file which went from having "some markers" to "no markers" ?
IE: prevent deleting the last marker on a map?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was using the check to not make a blank file but you are correct it would prevent that. I'm going to remove the check.

Copy link
Owner

Choose a reason for hiding this comment

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

Make and link issue to track this theoretical case of creating blank files. Because that is possible, maybe the correct logic here will be to delete files that are empty instead of not saving/overwriting them. But something a future pass can deal with.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Spatial.gd Outdated Show resolved Hide resolved
Spatial.gd Outdated Show resolved Hide resolved
Spatial.tscn Outdated
Comment on lines 198 to 201
margin_left = 777.0
margin_top = 89.0
margin_right = 1448.0
margin_bottom = 587.0
Copy link
Owner

Choose a reason for hiding this comment

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

What is the motivation for moving the window?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There are several windows that overlap each other. This moves this window to an unused space. This is something to keep in mind when we do the larger UI update.

Copy link
Owner

Choose a reason for hiding this comment

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

Is overlapping windows a problem?
Keep in mind the default minimum burrito overlay size is 800x600

Spatial.tscn Outdated Show resolved Hide resolved
Spatial.tscn Outdated
Comment on lines 198 to 201
margin_left = 777.0
margin_top = 89.0
margin_right = 1448.0
margin_bottom = 587.0
Copy link
Owner

Choose a reason for hiding this comment

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

Is overlapping windows a problem?
Keep in mind the default minimum burrito overlay size is 800x600

Spatial.gd Outdated
Comment on lines 392 to 393
const user_protobin_by_map_id_dir: String = "user://protobin_by_map_id/"
const user_marker_pack_dir: String = "user://marker_packs/"
Copy link
Owner

Choose a reason for hiding this comment

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

This seems to describe more of what the variable is/contains/its value and not what its purpose is.

Suggested change
const user_protobin_by_map_id_dir: String = "user://protobin_by_map_id/"
const user_marker_pack_dir: String = "user://marker_packs/"
const processed_marker_packs_dir: String = "user://protobin_by_map_id/"
const downloaded_marker_packs_dir: String = "user://marker_packs/"

I dont think my suggustion is quite correct because "processed" is not fully descriptive of the fact that it also stored the autosaves. But the pendulum should probably swing back the other direction slightly.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I like downloaded_marker_packs_dir for the 2nd one.

How about something like active_data_dir. Any changes made with the editor would be saved in this folder and "active_data" conveys that it is mutable.

Spatial.gd Outdated
self.unsaved_data_icon.visible = true
func update_burrito_icon():
if self.unsaved_changes:
$Control/GlobalMenuButton/TextureRect.modulate = Color(.78, 0.3, 0.3, 1.0)
Copy link
Owner

Choose a reason for hiding this comment

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

Lets save this color as a constant up at the top of the file.

Typically a value like this is called a "magic variable". Sometimes referred to by its type, such as "magic string" or "magic number" and it is not always clear why that value is there or what it does. If the line bcame

$Control/GlobalMenuButton/TextureRect.modulate = RED_TINT

or something like that, it becomes much more readable. Not sure "RED_TINT" is the right name.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I chose the color to be different enough to be noticed but I'm not set on it. For now I'm going to use the color constant "red".

Spatial.gd Outdated
$Control/GlobalMenuButton/TextureRect.modulate = Color(.78, 0.3, 0.3, 1.0)
$Control/GlobalMenuButton/main_menu_toggle.hint_tooltip = "Unsaved Data"
else:
$Control/GlobalMenuButton/TextureRect.modulate = Color(1.0, 1.0, 1.0, 1.0)
Copy link
Owner

Choose a reason for hiding this comment

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

You can use the default color constants here instead of 1,1,1,1

https://docs.godotengine.org/en/3.2/classes/class_color.html#constants

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Understood. Using the white color constant. I also found that the alpha should have been lower than one to match the original value.

@@ -49,11 +50,11 @@ func update_point():
self.object_link.set_point_position(self.object_index, self.translation)
self.object_2d_link.points[self.object_index] = Vector2(self.translation.x, self.translation.z)
if point_type == "icon":
self.object_link.translation = self.translation
self.object_link.set_point_position(self.translation)
Copy link
Owner

Choose a reason for hiding this comment

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

Gizmo is technically an external library so lets not modify it internally like this or else updating it for future versions will be harder.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Per our discussion, I have moved the functionality here into the main file. Gizmo should no longer care what type the point is put instead just emit its position when there is a change. This change did require me to make a class that can be used to contain all of the information gizmo was holding.

PackDialog.gd Outdated
Comment on lines 4 to 5
var user_marker_pack_dir: String
var user_protobin_by_map_id_dir: String
Copy link
Owner

Choose a reason for hiding this comment

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

Same thing about naming these variables as the other comment about the variables that are named similarly.

Spatial.gd Outdated
return data_out
func save_current_map_data():
var packed_bytes = self.waypoint_data.to_bytes()
if packed_bytes.size() > 0:
Copy link
Owner

Choose a reason for hiding this comment

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

Make and link issue to track this theoretical case of creating blank files. Because that is possible, maybe the correct logic here will be to delete files that are empty instead of not saving/overwriting them. But something a future pass can deal with.

Spatial.gd Outdated
file.open(self.marker_file_path, file.WRITE)
file.store_buffer(packed_bytes)
self.unsaved_changes = false
update_burrito_icon()
Copy link
Owner

Choose a reason for hiding this comment

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

How easy/likely is it for a programming mistake to lead to a desynced status and saved notification? EG: updating the variable without calling update_burrito_icon()

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Very likely if the two lines are unknowingly coupled. I have written a setter function that can be called that would handle updating the icon.

@@ -85,7 +85,7 @@ __meta__ = {
}

[node name="TextureRect" type="TextureRect" parent="Control/GlobalMenuButton"]
modulate = Color( 1, 1, 1, 0.439216 )
modulate = Color( 1, 1, 1, 0.44 )
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Rounded this to make it simpler to reset.

@@ -185,7 +185,7 @@ __meta__ = {

[node name="ImportPackDialog" type="FileDialog" parent="Control/Dialogs"]
margin_left = 289.0
margin_top = 36.0
margin_top = 60.0
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Moved this back but shrunk it down a bit so it didn't overlap the editor bar and burrito icon

Copy link
Owner

@AsherGlick AsherGlick left a comment

Choose a reason for hiding this comment

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

As we discussed offline, this might actually be 3 PRs

  1. Removing the tight coupling of 3d and 2d routes in gizmo
  2. Changing the source of truth of the node positions from 3d nodes to waypoint datums
  3. Saving the waypoint data to file

Lets do a technical write up on number 2 too before continuing.

@@ -389,12 +390,16 @@ func reset_3D_minimap_masks(category: Spatial):


var waypoint_data: Waypoint.Waypoint = Waypoint.Waypoint.new()
const user_protobin_by_map_id_dir: String = "user://protobin_by_map_id/"
const user_marker_pack_dir: String = "user://marker_packs/"
# We save the marker data in this directory where the files are have been split
Copy link
Owner

Choose a reason for hiding this comment

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

are split or have been split

const user_protobin_by_map_id_dir: String = "user://protobin_by_map_id/"
const user_marker_pack_dir: String = "user://marker_packs/"
# We save the marker data in this directory where the files are have been split
# by Map ID. All changes made by the editor are saved in these files.
Copy link
Owner

Choose a reason for hiding this comment

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

Suggested change
# by Map ID. All changes made by the editor are saved in these files.
# by Map ID. All changes made by the editor are automatically saved in these files prior to export.

@@ -690,30 +700,35 @@ func gen_adjustment_nodes():
continue
var new_gizmo = gizmo_scene.instance()
new_gizmo.translation = gizmo_position
new_gizmo.link_point("path", route, path2d, i)
new_gizmo.connect("selected", self, "on_gizmo_selected")
new_gizmo.connect("selected", self, "on_gizmo_selected", ["path", [route, path2d], i])
Copy link
Owner

Choose a reason for hiding this comment

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

I think something is too clever here passing in an array of [route, path2d] or [icon] depending on the first argument being "path" or "icon".

$Control/Dialogs/NodeEditorDialog/ScrollContainer/VBoxContainer/DeleteNode.disabled = false
# Only enable these buttons if the object selected is a point on the path not an icon
if object.point_type == "path":
if point_type == "path":
Copy link
Owner

Choose a reason for hiding this comment

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

Can we have logic that does not rely on point_type branching in multiple places?

update_burrito_icon()
func on_point_updated(position: Vector3):
set_unsaved_changes(true)
if self.currently_selected_node.point_type == "icon":
Copy link
Owner

Choose a reason for hiding this comment

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

Can we have logic that does not rely on point_type branching in multiple places?

@@ -833,28 +854,28 @@ func _on_NodeEditorDialog_hide():

func _on_DeleteNode_pressed():
if self.currently_selected_node.point_type == "icon":
Copy link
Owner

Choose a reason for hiding this comment

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

Can we have logic that does not rely on point_type branching in multiple places?


path.remove_point(index)
path2d.remove_point(index)
clear_adjustment_nodes()
gen_adjustment_nodes()
on_gizmo_deselected(self.currently_selected_node)
on_gizmo_deselected(self.currently_selected_node.gizmo)


func _on_NewNodeAfter_pressed():
if self.currently_selected_node.point_type == "icon":
Copy link
Owner

Choose a reason for hiding this comment

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

Can we have logic that does not rely on point_type branching in multiple places?

@klingbolt
Copy link
Contributor Author

This PR is now obsolete.

@klingbolt klingbolt closed this Sep 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants