-
-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refs #373: Progress on migration script to update the SimpleClick GUI.
The script is executed only if the project is using the SimpleClick template, and it removes the InventoryBar, SettingsBar, TextSettingsPopup and SoundSettingsPopup components.
- Loading branch information
Showing
3 changed files
with
79 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
addons/popochiu/migration/migrations/popochiu_migration_4.gd
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
@tool | ||
class_name PopochiuMigration4 | ||
extends PopochiuMigration | ||
|
||
# Update constant values to be correct for your migration | ||
const VERSION = 4 | ||
const DESCRIPTION = "short description of migration goes here" | ||
const STEPS = [ | ||
"Remove InventoryBar, SettingsBar, TextSettingsPopup and SoundSettingsPopup.", | ||
"Add SimpleClickBar and SimpleClickSettingsPopup.", | ||
"Update SaveAndLoadPopup.", | ||
] | ||
|
||
|
||
|
||
#region Virtual #################################################################################### | ||
func _is_migration_needed() -> bool: | ||
return PopochiuResources.get_data_value("ui", "template", "") == "SimpleClick" | ||
|
||
|
||
func _do_migration() -> bool: | ||
return await PopochiuMigrationHelper.execute_migration_steps( | ||
self, | ||
[ | ||
# Include the function names for each step here | ||
_remove_non_used_components, | ||
_step2, | ||
_step3, | ||
] | ||
) | ||
|
||
|
||
func _is_reload_required() -> bool: | ||
return false | ||
|
||
|
||
#endregion | ||
|
||
#region Private #################################################################################### | ||
func _remove_non_used_components() -> Completion: | ||
var gui_scene := (ResourceLoader.load( | ||
PopochiuResources.GUI_GAME_SCENE, "", ResourceLoader.CACHE_MODE_IGNORE | ||
) as PackedScene).instantiate() | ||
var nodes_to_remove: Array[Control] = [] | ||
for node_name: String in [ | ||
"InventoryBar", "SettingsBar", "TextSettingsPopup", "SoundSettingsPopup" | ||
]: | ||
var node: Node = gui_scene.find_child(node_name) | ||
if is_instance_valid(node) and node is Control: | ||
nodes_to_remove.append(node) | ||
for node: Control in nodes_to_remove: | ||
node.owner = null | ||
node.queue_free() | ||
await PopochiuEditorHelper.frame_processed() | ||
|
||
var gui_packed_scene := PackedScene.new() | ||
gui_packed_scene.pack(gui_scene) | ||
ResourceSaver.save(gui_packed_scene, PopochiuResources.GUI_GAME_SCENE) | ||
|
||
return Completion.DONE | ||
|
||
|
||
func _step2() -> Completion: | ||
return Completion.DONE | ||
|
||
|
||
func _step3() -> Completion: | ||
return Completion.DONE | ||
|
||
|
||
#endregion |