From 62bb2f3772bbd13ecae0b1c51c413f8b2fbf5743 Mon Sep 17 00:00:00 2001 From: Ryan Reed Date: Sat, 22 Mar 2025 16:04:46 -0400 Subject: [PATCH 1/3] Replaced existing options menu with Pause Menu (missing settings currently) --- autoloads/signal_manager.gd | 6 ++ autoloads/signal_manager.gd.uid | 1 + project.godot | 1 + resources/pause_menu_theme.tres | 6 ++ save_load/autoloads/save_game_manager.gd | 8 +-- scenes/ui/options_menu.tscn | 89 ------------------------ scenes/ui/pause_menu.gd | 37 ++++++++++ scenes/ui/pause_menu.gd.uid | 1 + scenes/ui/pause_menu.tscn | 81 +++++++++++++++++++++ scenes/ui/ui.gd | 41 ++++------- scenes/ui/ui.tscn | 13 +--- 11 files changed, 155 insertions(+), 129 deletions(-) create mode 100644 autoloads/signal_manager.gd create mode 100644 autoloads/signal_manager.gd.uid create mode 100644 resources/pause_menu_theme.tres delete mode 100644 scenes/ui/options_menu.tscn create mode 100644 scenes/ui/pause_menu.gd create mode 100644 scenes/ui/pause_menu.gd.uid create mode 100644 scenes/ui/pause_menu.tscn diff --git a/autoloads/signal_manager.gd b/autoloads/signal_manager.gd new file mode 100644 index 0000000..4d0ce2d --- /dev/null +++ b/autoloads/signal_manager.gd @@ -0,0 +1,6 @@ +## General Purpose signals +extends Node + + +signal options_menu_opened +signal options_menu_closed diff --git a/autoloads/signal_manager.gd.uid b/autoloads/signal_manager.gd.uid new file mode 100644 index 0000000..818e812 --- /dev/null +++ b/autoloads/signal_manager.gd.uid @@ -0,0 +1 @@ +uid://biwce2o15q44g diff --git a/project.godot b/project.godot index d298b9d..398611d 100644 --- a/project.godot +++ b/project.godot @@ -23,6 +23,7 @@ EntityManager="*res://autoloads/entity_manager.gd" InventoryManager="*res://autoloads/inventory_manager.gd" DBItems="*res://autoloads/db_items.gd" SaveGameManager="*res://save_load/autoloads/save_game_manager.gd" +SignalManager="*res://autoloads/signal_manager.gd" [debug] diff --git a/resources/pause_menu_theme.tres b/resources/pause_menu_theme.tres new file mode 100644 index 0000000..af3d5d8 --- /dev/null +++ b/resources/pause_menu_theme.tres @@ -0,0 +1,6 @@ +[gd_resource type="Theme" format=3 uid="uid://b5q8b0l6qp1dt"] + +[resource] +Button/colors/font_color = Color(0.839216, 0.933333, 1, 1) +Button/constants/outline_size = 2 +Button/font_sizes/font_size = 20 diff --git a/save_load/autoloads/save_game_manager.gd b/save_load/autoloads/save_game_manager.gd index 3a2a1e0..dae42bf 100644 --- a/save_load/autoloads/save_game_manager.gd +++ b/save_load/autoloads/save_game_manager.gd @@ -13,12 +13,12 @@ signal game_loaded func _unhandled_input(event: InputEvent) -> void: if event.is_action_pressed("quick_save"): - _save_game() + save_game() if event.is_action_pressed("quick_load"): - _load_game() + load_game() -func _save_game() -> void: +func save_game() -> void: var save_level_data_component: SaveLevelDataComponent = get_tree().get_first_node_in_group("save_level_data_component") if save_level_data_component == null: @@ -28,7 +28,7 @@ func _save_game() -> void: save_level_data_component.save_game() game_saved.emit() -func _load_game() -> void: +func load_game() -> void: EntityManager.reset_world.emit() var save_level_data_component: SaveLevelDataComponent = get_tree().get_first_node_in_group("save_level_data_component") diff --git a/scenes/ui/options_menu.tscn b/scenes/ui/options_menu.tscn deleted file mode 100644 index 9a8fd08..0000000 --- a/scenes/ui/options_menu.tscn +++ /dev/null @@ -1,89 +0,0 @@ -[gd_scene format=3 uid="uid://w6wtjosjn1qu"] - -[node name="OptionsMenu" type="MarginContainer"] -anchors_preset = 15 -anchor_right = 1.0 -anchor_bottom = 1.0 -grow_horizontal = 2 -grow_vertical = 2 - -[node name="PanelContainer" type="PanelContainer" parent="."] -layout_mode = 2 - -[node name="MarginContainer" type="MarginContainer" parent="PanelContainer"] -layout_mode = 2 -theme_override_constants/margin_left = 20 -theme_override_constants/margin_top = 20 -theme_override_constants/margin_right = 20 -theme_override_constants/margin_bottom = 20 - -[node name="LeftContainer" type="HBoxContainer" parent="PanelContainer/MarginContainer"] -layout_mode = 2 - -[node name="VBoxContainer" type="VBoxContainer" parent="PanelContainer/MarginContainer/LeftContainer"] -layout_mode = 2 -size_flags_horizontal = 3 - -[node name="Label" type="Label" parent="PanelContainer/MarginContainer/LeftContainer/VBoxContainer"] -layout_mode = 2 -size_flags_vertical = 0 -theme_type_variation = &"HeaderLarge" -text = "Options Menu" -horizontal_alignment = 1 - -[node name="BlockHighlights" type="HBoxContainer" parent="PanelContainer/MarginContainer/LeftContainer/VBoxContainer"] -layout_mode = 2 - -[node name="CheckButton" type="CheckButton" parent="PanelContainer/MarginContainer/LeftContainer/VBoxContainer/BlockHighlights"] -layout_mode = 2 -button_pressed = true -text = "Enable Block Highlighting" - -[node name="Waila" type="HBoxContainer" parent="PanelContainer/MarginContainer/LeftContainer/VBoxContainer"] -layout_mode = 2 - -[node name="CheckButton" type="CheckButton" parent="PanelContainer/MarginContainer/LeftContainer/VBoxContainer/Waila"] -layout_mode = 2 -button_pressed = true -text = "Enable Waila" - -[node name="BottomRightContainer" type="HBoxContainer" parent="PanelContainer/MarginContainer"] -layout_mode = 2 -size_flags_horizontal = 8 -size_flags_vertical = 8 - -[node name="VBoxContainer" type="VBoxContainer" parent="PanelContainer/MarginContainer/BottomRightContainer"] -layout_mode = 2 -size_flags_horizontal = 8 - -[node name="ControlsLabel" type="Label" parent="PanelContainer/MarginContainer/BottomRightContainer/VBoxContainer"] -layout_mode = 2 -theme_type_variation = &"HeaderSmall" -text = "Controls" -horizontal_alignment = 1 - -[node name="Controls" type="Label" parent="PanelContainer/MarginContainer/BottomRightContainer/VBoxContainer"] -layout_mode = 2 -text = "Left Click - Create Block -Right Click - Delete Block -Scoll Wheel - Change Block -Ctrl - Crouch -Shift - Sprint (until stop or toggled)" - -[node name="CenterContainer" type="CenterContainer" parent="PanelContainer/MarginContainer"] -layout_mode = 2 -size_flags_vertical = 8 - -[node name="HBoxContainer" type="HBoxContainer" parent="PanelContainer/MarginContainer/CenterContainer"] -layout_mode = 2 -theme_override_constants/separation = 10 - -[node name="CloseButton" type="Button" parent="PanelContainer/MarginContainer/CenterContainer/HBoxContainer"] -layout_mode = 2 -theme_override_font_sizes/font_size = 20 -text = "Close Menu" - -[node name="ExitButton" type="Button" parent="PanelContainer/MarginContainer/CenterContainer/HBoxContainer"] -layout_mode = 2 -theme_override_font_sizes/font_size = 20 -text = "Exit Game" diff --git a/scenes/ui/pause_menu.gd b/scenes/ui/pause_menu.gd new file mode 100644 index 0000000..8ba1681 --- /dev/null +++ b/scenes/ui/pause_menu.gd @@ -0,0 +1,37 @@ +class_name PauseMenu +extends Panel + + +func _unhandled_input(event: InputEvent) -> void: + if event.is_action_pressed("ui_cancel") and self.visible: + hide_menu() + elif event.is_action_pressed("ui_cancel") and !self.visible: + show_menu() + + +func show_menu() -> void: + self.visible = true + SignalManager.options_menu_opened.emit() + +func hide_menu() -> void: + self.visible = false + SignalManager.options_menu_closed.emit() + + +# Signals +func _on_exit_game_button_pressed() -> void: + get_tree().quit() + +func _on_resume_button_pressed() -> void: + hide_menu() + +func _on_quick_load_pressed() -> void: + SaveGameManager.load_game() + hide_menu() + +func _on_quick_save_pressed() -> void: + SaveGameManager.save_game() + hide_menu() + +func _on_settings_button_pressed() -> void: + pass # Replace with function body. diff --git a/scenes/ui/pause_menu.gd.uid b/scenes/ui/pause_menu.gd.uid new file mode 100644 index 0000000..9c7340d --- /dev/null +++ b/scenes/ui/pause_menu.gd.uid @@ -0,0 +1 @@ +uid://d3ysjgxxmyqpw diff --git a/scenes/ui/pause_menu.tscn b/scenes/ui/pause_menu.tscn new file mode 100644 index 0000000..c23d0bc --- /dev/null +++ b/scenes/ui/pause_menu.tscn @@ -0,0 +1,81 @@ +[gd_scene load_steps=3 format=3 uid="uid://bopvfwcgnnawg"] + +[ext_resource type="Theme" uid="uid://b5q8b0l6qp1dt" path="res://resources/pause_menu_theme.tres" id="1_6tw0m"] +[ext_resource type="Script" uid="uid://d3ysjgxxmyqpw" path="res://scenes/ui/pause_menu.gd" id="2_0lmf7"] + +[node name="PauseMenu" type="Panel"] +process_mode = 3 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +theme = ExtResource("1_6tw0m") +script = ExtResource("2_0lmf7") + +[node name="Background" type="ColorRect" parent="."] +custom_minimum_size = Vector2(400, 0) +layout_mode = 1 +anchors_preset = 13 +anchor_left = 0.5 +anchor_right = 0.5 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +color = Color(0.192157, 0.239216, 0.352941, 1) + +[node name="MarginContainer" type="MarginContainer" parent="Background"] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +theme_override_constants/margin_left = 10 +theme_override_constants/margin_top = 10 +theme_override_constants/margin_right = 10 +theme_override_constants/margin_bottom = 10 + +[node name="CenterContainer" type="VBoxContainer" parent="Background/MarginContainer"] +layout_mode = 2 +size_flags_horizontal = 4 +theme_override_constants/separation = 20 + +[node name="Title" type="Label" parent="Background/MarginContainer/CenterContainer"] +layout_mode = 2 +theme_override_font_sizes/font_size = 40 +text = "Paused" +horizontal_alignment = 1 +vertical_alignment = 1 + +[node name="ButtonsContainer" type="VBoxContainer" parent="Background/MarginContainer/CenterContainer"] +layout_mode = 2 +size_flags_vertical = 6 +theme_override_constants/separation = 20 + +[node name="ResumeButton" type="Button" parent="Background/MarginContainer/CenterContainer/ButtonsContainer"] +layout_mode = 2 +text = "Resume" + +[node name="QuickSave" type="Button" parent="Background/MarginContainer/CenterContainer/ButtonsContainer"] +layout_mode = 2 +text = "Quick Save" + +[node name="QuickLoad" type="Button" parent="Background/MarginContainer/CenterContainer/ButtonsContainer"] +layout_mode = 2 +text = "Quick Load" + +[node name="SettingsButton" type="Button" parent="Background/MarginContainer/CenterContainer/ButtonsContainer"] +layout_mode = 2 +disabled = true +text = "Settings" + +[node name="ExitGameButton" type="Button" parent="Background/MarginContainer/CenterContainer/ButtonsContainer"] +layout_mode = 2 +text = "Exit Game" + +[connection signal="pressed" from="Background/MarginContainer/CenterContainer/ButtonsContainer/ResumeButton" to="." method="_on_resume_button_pressed"] +[connection signal="pressed" from="Background/MarginContainer/CenterContainer/ButtonsContainer/QuickSave" to="." method="_on_quick_save_pressed"] +[connection signal="pressed" from="Background/MarginContainer/CenterContainer/ButtonsContainer/QuickLoad" to="." method="_on_quick_load_pressed"] +[connection signal="pressed" from="Background/MarginContainer/CenterContainer/ButtonsContainer/SettingsButton" to="." method="_on_settings_button_pressed"] +[connection signal="pressed" from="Background/MarginContainer/CenterContainer/ButtonsContainer/ExitGameButton" to="." method="_on_exit_game_button_pressed"] diff --git a/scenes/ui/ui.gd b/scenes/ui/ui.gd index 5c99e97..571e5e5 100644 --- a/scenes/ui/ui.gd +++ b/scenes/ui/ui.gd @@ -4,40 +4,29 @@ extends CanvasLayer @onready var crosshair: CenterContainer = $Crosshair @onready var inventory: Inventory = $Inventory -@onready var options_menu: MarginContainer = $OptionsMenu @onready var quick_slots: MarginContainer = $QuickSlots @onready var waila: Waila = $Waila -func _process(_delta: float) -> void: - if Input.is_action_just_pressed("ui_cancel"): - toggle_options_menu() +func _ready() -> void: + SignalManager.options_menu_closed.connect(_on_options_menu_closed.bind()) + SignalManager.options_menu_opened.connect(_on_options_menu_opened.bind()) -func toggle_options_menu() -> void: - options_menu.visible = !options_menu.visible - Globals.is_options_menu_active = options_menu.visible - crosshair.visible = !options_menu.visible - quick_slots.visible = !options_menu.visible +func _on_options_menu_closed() -> void: + crosshair.visible = true + quick_slots.visible = true + waila.visible = true - if options_menu.visible: - waila.visible = false - Input.mouse_mode = Input.MOUSE_MODE_VISIBLE - else: - Input.mouse_mode = Input.MOUSE_MODE_CAPTURED + Input.mouse_mode = Input.MOUSE_MODE_CAPTURED + get_tree().paused = false -# Options -func _on_block_highlights_toggled(toggled_on: bool) -> void: - Globals.enable_block_highlight = toggled_on +func _on_options_menu_opened() -> void: + crosshair.visible = false + quick_slots.visible = false + waila.visible = false -func _on_waila_toggled(toggled_on: bool) -> void: - Globals.enable_waila = toggled_on + Input.mouse_mode = Input.MOUSE_MODE_VISIBLE - -# Signals -func _on_close_button_pressed() -> void: - toggle_options_menu() - -func _on_exit_button_pressed() -> void: - get_tree().quit() + get_tree().paused = true diff --git a/scenes/ui/ui.tscn b/scenes/ui/ui.tscn index a1c506d..4138f23 100644 --- a/scenes/ui/ui.tscn +++ b/scenes/ui/ui.tscn @@ -2,9 +2,9 @@ [ext_resource type="Script" uid="uid://bslimr2y4lnvq" path="res://scenes/ui/ui.gd" id="1_aac20"] [ext_resource type="PackedScene" uid="uid://dvogu3djluqsn" path="res://scenes/ui/waila.tscn" id="1_u7n8c"] -[ext_resource type="PackedScene" uid="uid://w6wtjosjn1qu" path="res://scenes/ui/options_menu.tscn" id="2_f5cxw"] [ext_resource type="PackedScene" uid="uid://cbiygbgpfk220" path="res://scenes/ui/quick_slots.tscn" id="4_g5kmx"] [ext_resource type="PackedScene" uid="uid://dcr25y1lw4wjp" path="res://scenes/ui/inventory/inventory.tscn" id="5_0dwhk"] +[ext_resource type="PackedScene" uid="uid://bopvfwcgnnawg" path="res://scenes/ui/pause_menu.tscn" id="6_7vp6q"] [ext_resource type="Resource" uid="uid://blfp6tiir282o" path="res://resources/inventory/player_inventory_testing.tres" id="6_pfayw"] [node name="UI" type="CanvasLayer"] @@ -29,18 +29,11 @@ mouse_filter = 2 [node name="Waila" parent="." instance=ExtResource("1_u7n8c")] -[node name="OptionsMenu" parent="." instance=ExtResource("2_f5cxw")] -visible = false - [node name="QuickSlots" parent="." instance=ExtResource("4_g5kmx")] [node name="Inventory" parent="." instance=ExtResource("5_0dwhk")] visible = false inventory_resource = ExtResource("6_pfayw") -[connection signal="toggled" from="OptionsMenu/PanelContainer/MarginContainer/LeftContainer/VBoxContainer/BlockHighlights/CheckButton" to="." method="_on_block_highlights_toggled"] -[connection signal="toggled" from="OptionsMenu/PanelContainer/MarginContainer/LeftContainer/VBoxContainer/Waila/CheckButton" to="." method="_on_waila_toggled"] -[connection signal="pressed" from="OptionsMenu/PanelContainer/MarginContainer/CenterContainer/HBoxContainer/CloseButton" to="." method="_on_close_button_pressed"] -[connection signal="pressed" from="OptionsMenu/PanelContainer/MarginContainer/CenterContainer/HBoxContainer/ExitButton" to="." method="_on_exit_button_pressed"] - -[editable path="OptionsMenu"] +[node name="PauseMenu" parent="." instance=ExtResource("6_7vp6q")] +visible = false -- 2.30.1 From 25fce83a74fba4d51651c2a95f534d86039206aa Mon Sep 17 00:00:00 2001 From: Ryan Reed Date: Sat, 22 Mar 2025 17:24:35 -0400 Subject: [PATCH 2/3] Adding settings menu --- autoloads/signal_manager.gd | 9 +++- scenes/ui/pause_menu.gd | 12 ++--- scenes/ui/pause_menu.tscn | 31 ++++++----- scenes/ui/settings_menu.gd | 13 +++++ scenes/ui/settings_menu.gd.uid | 1 + scenes/ui/settings_menu.tscn | 98 ++++++++++++++++++++++++++++++++++ scenes/ui/ui.gd | 56 ++++++++++++++----- scenes/ui/ui.tscn | 6 ++- 8 files changed, 188 insertions(+), 38 deletions(-) create mode 100644 scenes/ui/settings_menu.gd create mode 100644 scenes/ui/settings_menu.gd.uid create mode 100644 scenes/ui/settings_menu.tscn diff --git a/autoloads/signal_manager.gd b/autoloads/signal_manager.gd index 4d0ce2d..32e012b 100644 --- a/autoloads/signal_manager.gd +++ b/autoloads/signal_manager.gd @@ -2,5 +2,10 @@ extends Node -signal options_menu_opened -signal options_menu_closed +#signal pause_game +signal resume_game + +signal open_pause_menu +signal close_pause_menu +signal open_settings_menu +signal close_settings_menu diff --git a/scenes/ui/pause_menu.gd b/scenes/ui/pause_menu.gd index 8ba1681..97a1dee 100644 --- a/scenes/ui/pause_menu.gd +++ b/scenes/ui/pause_menu.gd @@ -9,13 +9,11 @@ func _unhandled_input(event: InputEvent) -> void: show_menu() -func show_menu() -> void: - self.visible = true - SignalManager.options_menu_opened.emit() - func hide_menu() -> void: - self.visible = false - SignalManager.options_menu_closed.emit() + SignalManager.close_pause_menu.emit() + +func show_menu() -> void: + SignalManager.open_pause_menu.emit() # Signals @@ -34,4 +32,4 @@ func _on_quick_save_pressed() -> void: hide_menu() func _on_settings_button_pressed() -> void: - pass # Replace with function body. + SignalManager.open_settings_menu.emit() diff --git a/scenes/ui/pause_menu.tscn b/scenes/ui/pause_menu.tscn index c23d0bc..226e21a 100644 --- a/scenes/ui/pause_menu.tscn +++ b/scenes/ui/pause_menu.tscn @@ -13,7 +13,7 @@ grow_vertical = 2 theme = ExtResource("1_6tw0m") script = ExtResource("2_0lmf7") -[node name="Background" type="ColorRect" parent="."] +[node name="MenuBody" type="ColorRect" parent="."] custom_minimum_size = Vector2(400, 0) layout_mode = 1 anchors_preset = 13 @@ -24,7 +24,7 @@ grow_horizontal = 2 grow_vertical = 2 color = Color(0.192157, 0.239216, 0.352941, 1) -[node name="MarginContainer" type="MarginContainer" parent="Background"] +[node name="MarginContainer" type="MarginContainer" parent="MenuBody"] layout_mode = 1 anchors_preset = 15 anchor_right = 1.0 @@ -36,46 +36,45 @@ theme_override_constants/margin_top = 10 theme_override_constants/margin_right = 10 theme_override_constants/margin_bottom = 10 -[node name="CenterContainer" type="VBoxContainer" parent="Background/MarginContainer"] +[node name="CenterContainer" type="VBoxContainer" parent="MenuBody/MarginContainer"] layout_mode = 2 size_flags_horizontal = 4 theme_override_constants/separation = 20 -[node name="Title" type="Label" parent="Background/MarginContainer/CenterContainer"] +[node name="Title" type="Label" parent="MenuBody/MarginContainer/CenterContainer"] layout_mode = 2 theme_override_font_sizes/font_size = 40 text = "Paused" horizontal_alignment = 1 vertical_alignment = 1 -[node name="ButtonsContainer" type="VBoxContainer" parent="Background/MarginContainer/CenterContainer"] +[node name="ButtonsContainer" type="VBoxContainer" parent="MenuBody/MarginContainer/CenterContainer"] layout_mode = 2 size_flags_vertical = 6 theme_override_constants/separation = 20 -[node name="ResumeButton" type="Button" parent="Background/MarginContainer/CenterContainer/ButtonsContainer"] +[node name="ResumeButton" type="Button" parent="MenuBody/MarginContainer/CenterContainer/ButtonsContainer"] layout_mode = 2 text = "Resume" -[node name="QuickSave" type="Button" parent="Background/MarginContainer/CenterContainer/ButtonsContainer"] +[node name="QuickSave" type="Button" parent="MenuBody/MarginContainer/CenterContainer/ButtonsContainer"] layout_mode = 2 text = "Quick Save" -[node name="QuickLoad" type="Button" parent="Background/MarginContainer/CenterContainer/ButtonsContainer"] +[node name="QuickLoad" type="Button" parent="MenuBody/MarginContainer/CenterContainer/ButtonsContainer"] layout_mode = 2 text = "Quick Load" -[node name="SettingsButton" type="Button" parent="Background/MarginContainer/CenterContainer/ButtonsContainer"] +[node name="SettingsButton" type="Button" parent="MenuBody/MarginContainer/CenterContainer/ButtonsContainer"] layout_mode = 2 -disabled = true text = "Settings" -[node name="ExitGameButton" type="Button" parent="Background/MarginContainer/CenterContainer/ButtonsContainer"] +[node name="ExitGameButton" type="Button" parent="MenuBody/MarginContainer/CenterContainer/ButtonsContainer"] layout_mode = 2 text = "Exit Game" -[connection signal="pressed" from="Background/MarginContainer/CenterContainer/ButtonsContainer/ResumeButton" to="." method="_on_resume_button_pressed"] -[connection signal="pressed" from="Background/MarginContainer/CenterContainer/ButtonsContainer/QuickSave" to="." method="_on_quick_save_pressed"] -[connection signal="pressed" from="Background/MarginContainer/CenterContainer/ButtonsContainer/QuickLoad" to="." method="_on_quick_load_pressed"] -[connection signal="pressed" from="Background/MarginContainer/CenterContainer/ButtonsContainer/SettingsButton" to="." method="_on_settings_button_pressed"] -[connection signal="pressed" from="Background/MarginContainer/CenterContainer/ButtonsContainer/ExitGameButton" to="." method="_on_exit_game_button_pressed"] +[connection signal="pressed" from="MenuBody/MarginContainer/CenterContainer/ButtonsContainer/ResumeButton" to="." method="_on_resume_button_pressed"] +[connection signal="pressed" from="MenuBody/MarginContainer/CenterContainer/ButtonsContainer/QuickSave" to="." method="_on_quick_save_pressed"] +[connection signal="pressed" from="MenuBody/MarginContainer/CenterContainer/ButtonsContainer/QuickLoad" to="." method="_on_quick_load_pressed"] +[connection signal="pressed" from="MenuBody/MarginContainer/CenterContainer/ButtonsContainer/SettingsButton" to="." method="_on_settings_button_pressed"] +[connection signal="pressed" from="MenuBody/MarginContainer/CenterContainer/ButtonsContainer/ExitGameButton" to="." method="_on_exit_game_button_pressed"] diff --git a/scenes/ui/settings_menu.gd b/scenes/ui/settings_menu.gd new file mode 100644 index 0000000..697b76e --- /dev/null +++ b/scenes/ui/settings_menu.gd @@ -0,0 +1,13 @@ +class_name SettingsMenu +extends Panel + + +func _on_block_highlighting_toggled(toggled_on: bool) -> void: + Globals.enable_block_highlight = toggled_on + +func _on_enable_waila_toggled(toggled_on: bool) -> void: + Globals.enable_waila = toggled_on + + +func _on_close_button_pressed() -> void: + SignalManager.resume_game.emit() diff --git a/scenes/ui/settings_menu.gd.uid b/scenes/ui/settings_menu.gd.uid new file mode 100644 index 0000000..9866805 --- /dev/null +++ b/scenes/ui/settings_menu.gd.uid @@ -0,0 +1 @@ +uid://37ftrpj14msn diff --git a/scenes/ui/settings_menu.tscn b/scenes/ui/settings_menu.tscn new file mode 100644 index 0000000..7e17aca --- /dev/null +++ b/scenes/ui/settings_menu.tscn @@ -0,0 +1,98 @@ +[gd_scene load_steps=3 format=3 uid="uid://4bdgwwx27m71"] + +[ext_resource type="Script" uid="uid://37ftrpj14msn" path="res://scenes/ui/settings_menu.gd" id="1_qwcqe"] +[ext_resource type="Theme" uid="uid://b5q8b0l6qp1dt" path="res://resources/pause_menu_theme.tres" id="2_mhswj"] + +[node name="SettingsMenu" type="Panel"] +process_mode = 3 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +script = ExtResource("1_qwcqe") + +[node name="MarginContainer" type="MarginContainer" parent="."] +layout_mode = 1 +anchors_preset = 5 +anchor_left = 0.5 +anchor_right = 0.5 +offset_left = -300.0 +offset_right = 300.0 +offset_bottom = 137.0 +grow_horizontal = 2 +theme_override_constants/margin_left = 20 +theme_override_constants/margin_top = 20 +theme_override_constants/margin_right = 20 +theme_override_constants/margin_bottom = 20 + +[node name="VBoxContainer" type="VBoxContainer" parent="MarginContainer"] +layout_mode = 2 +theme_override_constants/separation = 20 + +[node name="Title" type="Label" parent="MarginContainer/VBoxContainer"] +layout_mode = 2 +theme_override_font_sizes/font_size = 40 +text = "Settings" +horizontal_alignment = 1 + +[node name="TabContainer" type="TabContainer" parent="MarginContainer/VBoxContainer"] +layout_mode = 2 +current_tab = 0 + +[node name="Game" type="VBoxContainer" parent="MarginContainer/VBoxContainer/TabContainer"] +layout_mode = 2 +metadata/_tab_index = 0 + +[node name="BlockHighlighting" type="CheckButton" parent="MarginContainer/VBoxContainer/TabContainer/Game"] +layout_mode = 2 +button_pressed = true +text = "Enable Block Highlighting" + +[node name="EnableWaila" type="CheckButton" parent="MarginContainer/VBoxContainer/TabContainer/Game"] +layout_mode = 2 +button_pressed = true +text = "Enable Waila" + +[node name="Graphics (Todo)" type="VBoxContainer" parent="MarginContainer/VBoxContainer/TabContainer"] +visible = false +layout_mode = 2 +metadata/_tab_index = 1 + +[node name="Audio (TODO)" type="VBoxContainer" parent="MarginContainer/VBoxContainer/TabContainer"] +visible = false +layout_mode = 2 +metadata/_tab_index = 2 + +[node name="Inputs (TODO)" type="VBoxContainer" parent="MarginContainer/VBoxContainer/TabContainer"] +visible = false +layout_mode = 2 +metadata/_tab_index = 3 + +[node name="BottomRow" type="MarginContainer" parent="."] +layout_mode = 1 +anchors_preset = 7 +anchor_left = 0.5 +anchor_top = 1.0 +anchor_right = 0.5 +anchor_bottom = 1.0 +offset_left = -82.5 +offset_top = -40.0 +offset_right = 82.5 +grow_horizontal = 2 +grow_vertical = 0 +theme_override_constants/margin_bottom = 10 + +[node name="HBoxContainer" type="HBoxContainer" parent="BottomRow"] +layout_mode = 2 +theme_override_constants/separation = 20 + +[node name="CloseButton" type="Button" parent="BottomRow/HBoxContainer"] +custom_minimum_size = Vector2(141, 36) +layout_mode = 2 +theme = ExtResource("2_mhswj") +text = "Close Settings" + +[connection signal="toggled" from="MarginContainer/VBoxContainer/TabContainer/Game/BlockHighlighting" to="." method="_on_block_highlighting_toggled"] +[connection signal="toggled" from="MarginContainer/VBoxContainer/TabContainer/Game/EnableWaila" to="." method="_on_enable_waila_toggled"] +[connection signal="pressed" from="BottomRow/HBoxContainer/CloseButton" to="." method="_on_close_button_pressed"] diff --git a/scenes/ui/ui.gd b/scenes/ui/ui.gd index 571e5e5..c25e5cb 100644 --- a/scenes/ui/ui.gd +++ b/scenes/ui/ui.gd @@ -5,28 +5,60 @@ extends CanvasLayer @onready var crosshair: CenterContainer = $Crosshair @onready var inventory: Inventory = $Inventory @onready var quick_slots: MarginContainer = $QuickSlots +@onready var pause_menu: PauseMenu = $PauseMenu +@onready var settings_menu: SettingsMenu = $SettingsMenu @onready var waila: Waila = $Waila func _ready() -> void: - SignalManager.options_menu_closed.connect(_on_options_menu_closed.bind()) - SignalManager.options_menu_opened.connect(_on_options_menu_opened.bind()) + SignalManager.close_pause_menu.connect(_on_close_pause_menu) + SignalManager.open_pause_menu.connect(_on_open_pause_menu) + SignalManager.close_settings_menu.connect(_on_close_settings_menu) + SignalManager.open_settings_menu.connect(_on_open_settings_menu) + SignalManager.resume_game.connect(_on_resume_game) -func _on_options_menu_closed() -> void: - crosshair.visible = true - quick_slots.visible = true - waila.visible = true - - Input.mouse_mode = Input.MOUSE_MODE_CAPTURED - - get_tree().paused = false - -func _on_options_menu_opened() -> void: +func hide_ui_elements() -> void: crosshair.visible = false quick_slots.visible = false waila.visible = false +func hide_menus() -> void: + pause_menu.visible = false + settings_menu.visible = false + inventory.visible = false + + +func _on_close_pause_menu() -> void: + SignalManager.resume_game.emit() + +func _on_close_settings_menu() -> void: + SignalManager.resume_game.emit() + +func _on_open_pause_menu() -> void: + Input.mouse_mode = Input.MOUSE_MODE_VISIBLE + + hide_ui_elements() + hide_menus() + pause_menu.visible = true + + get_tree().paused = true + +func _on_open_settings_menu() -> void: Input.mouse_mode = Input.MOUSE_MODE_VISIBLE + hide_ui_elements() + hide_menus() + settings_menu.visible = true + get_tree().paused = true + +func _on_resume_game() -> void: + Input.mouse_mode = Input.MOUSE_MODE_CAPTURED + + hide_menus() + crosshair.visible = true + quick_slots.visible = true + waila.visible = true + + get_tree().paused = false diff --git a/scenes/ui/ui.tscn b/scenes/ui/ui.tscn index 4138f23..69dc0d3 100644 --- a/scenes/ui/ui.tscn +++ b/scenes/ui/ui.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=7 format=3 uid="uid://c7fj7wla8bd70"] +[gd_scene load_steps=8 format=3 uid="uid://c7fj7wla8bd70"] [ext_resource type="Script" uid="uid://bslimr2y4lnvq" path="res://scenes/ui/ui.gd" id="1_aac20"] [ext_resource type="PackedScene" uid="uid://dvogu3djluqsn" path="res://scenes/ui/waila.tscn" id="1_u7n8c"] @@ -6,6 +6,7 @@ [ext_resource type="PackedScene" uid="uid://dcr25y1lw4wjp" path="res://scenes/ui/inventory/inventory.tscn" id="5_0dwhk"] [ext_resource type="PackedScene" uid="uid://bopvfwcgnnawg" path="res://scenes/ui/pause_menu.tscn" id="6_7vp6q"] [ext_resource type="Resource" uid="uid://blfp6tiir282o" path="res://resources/inventory/player_inventory_testing.tres" id="6_pfayw"] +[ext_resource type="PackedScene" uid="uid://4bdgwwx27m71" path="res://scenes/ui/settings_menu.tscn" id="7_7vp6q"] [node name="UI" type="CanvasLayer"] script = ExtResource("1_aac20") @@ -37,3 +38,6 @@ inventory_resource = ExtResource("6_pfayw") [node name="PauseMenu" parent="." instance=ExtResource("6_7vp6q")] visible = false + +[node name="SettingsMenu" parent="." instance=ExtResource("7_7vp6q")] +visible = false -- 2.30.1 From cfeda2818a4ca7780ac838ecd95caf10467e2a0e Mon Sep 17 00:00:00 2001 From: Ryan Reed Date: Sat, 22 Mar 2025 17:30:12 -0400 Subject: [PATCH 3/3] Minor reordering --- scenes/ui/ui.gd | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/scenes/ui/ui.gd b/scenes/ui/ui.gd index c25e5cb..86dbc6d 100644 --- a/scenes/ui/ui.gd +++ b/scenes/ui/ui.gd @@ -18,16 +18,16 @@ func _ready() -> void: SignalManager.resume_game.connect(_on_resume_game) -func hide_ui_elements() -> void: - crosshair.visible = false - quick_slots.visible = false - waila.visible = false - func hide_menus() -> void: pause_menu.visible = false settings_menu.visible = false inventory.visible = false +func hide_ui_elements() -> void: + crosshair.visible = false + quick_slots.visible = false + waila.visible = false + func _on_close_pause_menu() -> void: SignalManager.resume_game.emit() -- 2.30.1