diff options
author | Daniel Weipert <code@drogueronin.de> | 2023-08-10 11:48:05 +0200 |
---|---|---|
committer | Daniel Weipert <code@drogueronin.de> | 2023-08-10 11:48:05 +0200 |
commit | 46556d864b9685c3b09a0038f5de83966fe7ff94 (patch) | |
tree | c68082eacd35559e14565d1598dd694972fb8e0e /Scenes/UI/Menu.gd |
Initial commit
Diffstat (limited to 'Scenes/UI/Menu.gd')
-rw-r--r-- | Scenes/UI/Menu.gd | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/Scenes/UI/Menu.gd b/Scenes/UI/Menu.gd new file mode 100644 index 0000000..b482342 --- /dev/null +++ b/Scenes/UI/Menu.gd @@ -0,0 +1,65 @@ +extends TabContainer + + +func _ready(): + hide() + + +func _input(_event: InputEvent): + if Input.is_action_just_pressed("ui_menu"): + if get_tree().paused: # game is paused + self.close_menu() + else: # game is running + self.open_menu() + + if Input.is_action_pressed("ui_menu_left"): + if get_current_tab() > 0: + set_current_tab(get_current_tab() - 1) + if Input.is_action_pressed("ui_menu_right"): + if get_current_tab() < get_tab_count() - 1: + set_current_tab(get_current_tab() + 1) + + +func open_menu(): + get_tree().paused = true + show() + + +func close_menu(): + hide() + get_tree().paused = false + + +func get_player(): + return get_tree().get_current_scene().get_node("Player") + + +### Bombs ### + + +func _on_button_bomb_normal_pressed(): + self.get_player().Bomb = preload("res://Scenes/Entities/Bombs/Bomb__Normal.tscn") + + +func _on_button_bomb_breakables_pressed(): + self.get_player().Bomb = preload("res://Scenes/Entities/Bombs/Bomb__Breakables.tscn") + + +func _on_bomb_power_item_selected(index): + var power = int($Bombs/Panel/HBoxContainer/VBoxContainer2/BombPower.get_item_text(index)) + self.get_player().bomb_power = power + + +### System ### + + +func quit_game(): + get_tree().quit() + + +func _on_button_resume_pressed(): + self.close_menu() + + +func _on_button_quit_pressed(): + self.quit_game() |