-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: spawn&kill scene and parenting transform (#2)
* feat: spawn and kill scene * split to components * rust: add parenting with cyclic checker godot: add grid and improve ui to test * fix fmt
- Loading branch information
1 parent
471b91d
commit 7b49c80
Showing
21 changed files
with
14,989 additions
and
388 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,35 @@ | ||
extends Node | ||
|
||
var scene_runner: SceneRunner | ||
@onready var scene_list = $UI/Panel_Scenes/ItemList_Scenes | ||
|
||
# Called when the node enters the scene tree for the first time. | ||
func _process(delta): | ||
%Label_FPS.set_text(str(Engine.get_frames_per_second()) + " FPS") | ||
|
||
func _ready(): | ||
pass | ||
|
||
var main_class: MainTestClass = MainTestClass.new() | ||
print('main class created') | ||
scene_runner = SceneRunner.new() | ||
self.add_child(scene_runner) | ||
print('scene_runner created') | ||
|
||
$UI/Panel_SpawnScene/OptionButton_SceneToSpawn.clear() | ||
for path in DirAccess.get_directories_at("res://assets/scenes"): | ||
$UI/Panel_SpawnScene/OptionButton_SceneToSpawn.add_item(path) | ||
$UI/Panel_SpawnScene/OptionButton_SceneToSpawn.select(0) | ||
func _on_add_button_pressed(): | ||
var path = $UI/Panel_SpawnScene/OptionButton_SceneToSpawn.text | ||
var scene_id = scene_runner.start_scene(path, Vector3(float($UI/Panel_SpawnScene/X.value) * 16, 0, float($UI/Panel_SpawnScene/Z.value) * 16)) | ||
var item = scene_list.add_item(path) | ||
scene_list.set_item_metadata(item, scene_id) | ||
|
||
main_class.start_scene() | ||
self.add_child(main_class) | ||
|
||
# Called every frame. 'delta' is the elapsed time since the previous frame. | ||
func _process(delta): | ||
$Label.set_text("FPS " + str(Engine.get_frames_per_second())) | ||
func _on_button_delete_scene_pressed(): | ||
var selected = scene_list.get_selected_items() | ||
if selected.size() > 0: | ||
var scene_id: int = scene_list.get_item_metadata(selected[0]) | ||
if scene_runner.kill_scene(scene_id): | ||
print(scene_id, " scene deleted") | ||
scene_list.remove_item(selected[0]) | ||
if scene_list.item_count > 0: | ||
scene_list.select(0) | ||
else: | ||
print(scene_id, " couldn't delete scene") | ||
|
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
Oops, something went wrong.