diff options
author | Daniel Weipert <git@mail.dweipert.de> | 2023-12-28 09:07:41 +0100 |
---|---|---|
committer | Daniel Weipert <git@mail.dweipert.de> | 2023-12-28 09:07:41 +0100 |
commit | 96d36cee33d6321834565f0a5d412ef95c5ceffd (patch) | |
tree | 0dec02c5915cc154d48eef6ac9c2cd0be7df7982 /Scenes/UI | |
parent | 46556d864b9685c3b09a0038f5de83966fe7ff94 (diff) |
Diffstat (limited to 'Scenes/UI')
-rw-r--r-- | Scenes/UI/HealthBar.gd | 2 | ||||
-rw-r--r-- | Scenes/UI/Menu.gd | 27 | ||||
-rw-r--r-- | Scenes/UI/Menu.tscn | 84 |
3 files changed, 91 insertions, 22 deletions
diff --git a/Scenes/UI/HealthBar.gd b/Scenes/UI/HealthBar.gd index 8c4c90d..ba51007 100644 --- a/Scenes/UI/HealthBar.gd +++ b/Scenes/UI/HealthBar.gd @@ -9,7 +9,7 @@ func connect_to_player(player_to_connect: Player): self.player = player_to_connect self.draw_health() - self.player.connect("damaged", func (_health): self.draw_health()) + self.player.connect("health_changed", func (_health): self.draw_health()) func draw_health(): diff --git a/Scenes/UI/Menu.gd b/Scenes/UI/Menu.gd index b482342..ec6ca49 100644 --- a/Scenes/UI/Menu.gd +++ b/Scenes/UI/Menu.gd @@ -1,8 +1,14 @@ extends TabContainer +@onready var audio_bus = AudioServer.get_bus_index("Master") + + func _ready(): hide() + + self._ready_bombs() + self._ready_system() func _input(_event: InputEvent): @@ -37,6 +43,12 @@ func get_player(): ### Bombs ### +func _ready_bombs(): + for component in Bomb.COMPONENT_TYPE: + var idx = Bomb.COMPONENT_TYPE[component] + $Bombs/Panel/HBoxContainer/VBoxContainer3/BombComponents.set_item_text(idx, component.capitalize()) + + func _on_button_bomb_normal_pressed(): self.get_player().Bomb = preload("res://Scenes/Entities/Bombs/Bomb__Normal.tscn") @@ -50,9 +62,24 @@ func _on_bomb_power_item_selected(index): self.get_player().bomb_power = power +func _on_bomb_components_multi_selected(_index, _selected): + Global.player.bomb_components = [] + for idx in $Bombs/Panel/HBoxContainer/VBoxContainer3/BombComponents.get_selected_items(): + Global.player.bomb_components.append(idx) # same as enum idx + + ### System ### +func _ready_system(): + AudioServer.set_bus_volume_db(self.audio_bus, linear_to_db(0)) + $System/Panel/VBoxContainer2/SliderVolume.value = db_to_linear(AudioServer.get_bus_volume_db(self.audio_bus)) + + +func _on_slider_volume_value_changed(value): + AudioServer.set_bus_volume_db(self.audio_bus, linear_to_db(value)) + + func quit_game(): get_tree().quit() diff --git a/Scenes/UI/Menu.tscn b/Scenes/UI/Menu.tscn index 4a8f26e..38c3ee4 100644 --- a/Scenes/UI/Menu.tscn +++ b/Scenes/UI/Menu.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=8 format=3 uid="uid://d3xrwsv32hs6k"] +[gd_scene load_steps=9 format=3 uid="uid://d3xrwsv32hs6k"] [ext_resource type="Script" path="res://Scenes/UI/Menu.gd" id="1_vwah3"] @@ -11,10 +11,13 @@ bg_color = Color(0, 0, 0, 0.784314) [sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_p483f"] [sub_resource type="LabelSettings" id="LabelSettings_3ht7i"] -font_size = 10 +font_size = 5 [sub_resource type="LabelSettings" id="LabelSettings_s4847"] -font_size = 10 +font_size = 5 + +[sub_resource type="LabelSettings" id="LabelSettings_qokw0"] +font_size = 5 [sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_7at3v"] @@ -25,7 +28,7 @@ anchor_right = 1.0 anchor_bottom = 1.0 grow_horizontal = 2 grow_vertical = 2 -theme_override_font_sizes/font_size = 10 +theme_override_font_sizes/font_size = 5 theme_override_styles/panel = SubResource("StyleBoxFlat_flq5r") theme_override_styles/tabbar_background = SubResource("StyleBoxFlat_u0ugs") clip_tabs = false @@ -33,10 +36,10 @@ script = ExtResource("1_vwah3") [node name="Bombs" type="MarginContainer" parent="."] layout_mode = 2 -theme_override_constants/margin_left = 8 -theme_override_constants/margin_top = 8 -theme_override_constants/margin_right = 8 -theme_override_constants/margin_bottom = 8 +theme_override_constants/margin_left = 4 +theme_override_constants/margin_top = 4 +theme_override_constants/margin_right = 4 +theme_override_constants/margin_bottom = 4 [node name="Panel" type="Panel" parent="Bombs"] layout_mode = 2 @@ -44,8 +47,8 @@ theme_override_styles/panel = SubResource("StyleBoxEmpty_p483f") [node name="HBoxContainer" type="HBoxContainer" parent="Bombs/Panel"] layout_mode = 1 -offset_right = 177.0 -offset_bottom = 101.0 +offset_right = 89.0 +offset_bottom = 78.0 [node name="VBoxContainer" type="VBoxContainer" parent="Bombs/Panel/HBoxContainer"] layout_mode = 2 @@ -58,12 +61,12 @@ horizontal_alignment = 1 [node name="ButtonBombNormal" type="Button" parent="Bombs/Panel/HBoxContainer/VBoxContainer"] layout_mode = 2 -theme_override_font_sizes/font_size = 10 +theme_override_font_sizes/font_size = 4 text = "Normal" [node name="ButtonBombBreakables" type="Button" parent="Bombs/Panel/HBoxContainer/VBoxContainer"] layout_mode = 2 -theme_override_font_sizes/font_size = 10 +theme_override_font_sizes/font_size = 4 text = "Breakables" [node name="Space" type="Control" parent="Bombs/Panel/HBoxContainer"] @@ -81,7 +84,7 @@ horizontal_alignment = 1 [node name="BombPower" type="ItemList" parent="Bombs/Panel/HBoxContainer/VBoxContainer2"] layout_mode = 2 -theme_override_font_sizes/font_size = 10 +theme_override_font_sizes/font_size = 4 auto_height = true item_count = 4 item_0/text = "2" @@ -89,13 +92,35 @@ item_1/text = "3" item_2/text = "4" item_3/text = "5" +[node name="VBoxContainer3" type="VBoxContainer" parent="Bombs/Panel/HBoxContainer"] +layout_mode = 2 + +[node name="Label" type="Label" parent="Bombs/Panel/HBoxContainer/VBoxContainer3"] +layout_mode = 2 +text = "Components" +label_settings = SubResource("LabelSettings_qokw0") + +[node name="BombComponents" type="ItemList" parent="Bombs/Panel/HBoxContainer/VBoxContainer3"] +layout_mode = 2 +theme_override_font_sizes/font_size = 4 +select_mode = 1 +auto_height = true +text_overrun_behavior = 0 +item_count = 5 +fixed_column_width = 500 +item_0/text = "Breakable" +item_1/text = "RemoteControl" +item_2/text = "RemoteDetonate" +item_3/text = "Water" +item_4/text = "Salt" + [node name="System" type="MarginContainer" parent="."] visible = false layout_mode = 2 -theme_override_constants/margin_left = 16 -theme_override_constants/margin_top = 16 -theme_override_constants/margin_right = 16 -theme_override_constants/margin_bottom = 16 +theme_override_constants/margin_left = 4 +theme_override_constants/margin_top = 4 +theme_override_constants/margin_right = 4 +theme_override_constants/margin_bottom = 4 [node name="Panel" type="Panel" parent="System"] layout_mode = 2 @@ -108,23 +133,40 @@ anchor_left = 1.0 anchor_top = 1.0 anchor_right = 1.0 anchor_bottom = 1.0 -offset_left = -92.0 -offset_top = -48.0 +offset_left = -36.0 +offset_top = -34.0 grow_horizontal = 0 grow_vertical = 0 [node name="ButtonResume" type="Button" parent="System/Panel/VBoxContainer"] layout_mode = 2 -theme_override_font_sizes/font_size = 10 +theme_override_font_sizes/font_size = 4 text = "Resume Game" [node name="ButtonQuit" type="Button" parent="System/Panel/VBoxContainer"] layout_mode = 2 -theme_override_font_sizes/font_size = 10 +theme_override_font_sizes/font_size = 4 text = "Quit Game" +[node name="VBoxContainer2" type="VBoxContainer" parent="System/Panel"] +layout_mode = 0 +offset_right = 80.0 +offset_bottom = 40.0 + +[node name="Label" type="Label" parent="System/Panel/VBoxContainer2"] +layout_mode = 2 +theme_override_font_sizes/font_size = 6 +text = "Audio" + +[node name="SliderVolume" type="HSlider" parent="System/Panel/VBoxContainer2"] +layout_mode = 2 +max_value = 1.0 +step = 0.05 + [connection signal="pressed" from="Bombs/Panel/HBoxContainer/VBoxContainer/ButtonBombNormal" to="." method="_on_button_bomb_normal_pressed"] [connection signal="pressed" from="Bombs/Panel/HBoxContainer/VBoxContainer/ButtonBombBreakables" to="." method="_on_button_bomb_breakables_pressed"] [connection signal="item_selected" from="Bombs/Panel/HBoxContainer/VBoxContainer2/BombPower" to="." method="_on_bomb_power_item_selected"] +[connection signal="multi_selected" from="Bombs/Panel/HBoxContainer/VBoxContainer3/BombComponents" to="." method="_on_bomb_components_multi_selected"] [connection signal="pressed" from="System/Panel/VBoxContainer/ButtonResume" to="." method="_on_button_resume_pressed"] [connection signal="pressed" from="System/Panel/VBoxContainer/ButtonQuit" to="." method="_on_button_quit_pressed"] +[connection signal="value_changed" from="System/Panel/VBoxContainer2/SliderVolume" to="." method="_on_slider_volume_value_changed"] |