@@ -15,6 +15,8 @@ extends Control
1515@onready var _icon_collapse := EditorInterface .get_editor_theme ().get_icon ("Back" , "EditorIcons" )
1616@onready var _icon_expand := EditorInterface .get_editor_theme ().get_icon ("Forward" , "EditorIcons" )
1717
18+ const Constants = preload ("res://addons/block_code/ui/constants.gd" )
19+
1820var _current_block_code_node : BlockCode
1921var _block_code_nodes : Array
2022var _collapsed : bool = false
@@ -86,6 +88,14 @@ func _on_delete_dialog_confirmed(block_code_node: BlockCode):
8688 undo_redo .commit_action ()
8789
8890
91+ func _try_migration ():
92+ var version : int = _current_block_code_node .block_script .version
93+ if version == Constants .CURRENT_DATA_VERSION :
94+ # No migration needed.
95+ return
96+ push_warning ("Migration not implemented from %d to %d " % [version , Constants .CURRENT_DATA_VERSION ])
97+
98+
8999func switch_scene (scene_root : Node ):
90100 _title_bar .scene_selected (scene_root )
91101
@@ -94,6 +104,8 @@ func switch_block_code_node(block_code_node: BlockCode):
94104 var block_script : BlockScriptData = block_code_node .block_script if block_code_node else null
95105 _current_block_code_node = block_code_node
96106 _delete_node_button .disabled = _current_block_code_node == null
107+ if _current_block_code_node != null :
108+ _try_migration ()
97109 _picker .bsd_selected (block_script )
98110 _title_bar .bsd_selected (block_script )
99111 _block_canvas .bsd_selected (block_script )
@@ -133,6 +145,7 @@ func save_script():
133145 var generated_script = _block_canvas .generate_script_from_current_window (block_script .script_inherits )
134146 block_script .block_trees = block_trees
135147 block_script .generated_script = generated_script
148+ block_script .version = Constants .CURRENT_DATA_VERSION
136149
137150 undo_redo .add_do_property (_current_block_code_node .block_script , "block_trees" , block_trees )
138151 undo_redo .add_do_property (_current_block_code_node .block_script , "generated_script" , generated_script )
0 commit comments