From 299d5fe09d1cc21b2ea8c27236f1df5670af0dd7 Mon Sep 17 00:00:00 2001 From: KingGurke Date: Mon, 2 Oct 2023 19:26:53 +0200 Subject: [PATCH] added brightness slider --- project.godot | 4 ++++ src/gui/menu/brightness.gd | 7 +++++++ src/gui/menu/level.gd | 6 ++++++ src/gui/menu/level.tscn | 5 +++-- src/gui/menu/main.gd | 7 ++++++- src/gui/menu/main.tscn | 9 ++++++++- src/gui/menu/options.gd | 10 +++++++++- src/gui/menu/options.tscn | 25 +++++++++++++++++++++---- src/world_environment.tscn | 8 ++++++++ 9 files changed, 72 insertions(+), 9 deletions(-) create mode 100644 src/gui/menu/brightness.gd create mode 100644 src/world_environment.tscn diff --git a/project.godot b/project.godot index 316c5fc..8e04b6b 100644 --- a/project.godot +++ b/project.godot @@ -15,6 +15,10 @@ run/main_scene="res://src/gui/menu/main.tscn" config/features=PackedStringArray("4.1", "Forward Plus") config/icon="res://icon.svg" +[autoload] + +GlobalWorldEnvironment="*res://src/world_environment.tscn" + [dotnet] project/assembly_name="LD54" diff --git a/src/gui/menu/brightness.gd b/src/gui/menu/brightness.gd new file mode 100644 index 0000000..4da4354 --- /dev/null +++ b/src/gui/menu/brightness.gd @@ -0,0 +1,7 @@ +extends HSlider + + + +func _on_value_changed(value): + print_debug("setting brightness to ", value) + GlobalWorldEnvironment.environment.adjustment_brightness = value diff --git a/src/gui/menu/level.gd b/src/gui/menu/level.gd index ca3f655..fe56536 100644 --- a/src/gui/menu/level.gd +++ b/src/gui/menu/level.gd @@ -1,5 +1,10 @@ extends Control +@export var first_selection: Control + +func _ready(): + first_selection.grab_focus() + func _on_continue_button_pressed(): get_tree().current_scene.pause() @@ -10,4 +15,5 @@ func _on_menu_button_pressed(): func _on_options_button_pressed(): var options = load("res://src/gui/menu/options.tscn").instantiate() get_parent().add_child((options)) + options.last_menu = self hide() diff --git a/src/gui/menu/level.tscn b/src/gui/menu/level.tscn index b51e6c8..1a55cb9 100644 --- a/src/gui/menu/level.tscn +++ b/src/gui/menu/level.tscn @@ -1,9 +1,9 @@ -[gd_scene load_steps=3 format=3 uid="uid://dyo5dblkfivwn"] +[gd_scene load_steps=3 format=3 uid="uid://c0sexrwxdge73"] [ext_resource type="Theme" uid="uid://dpktnl3r5wul1" path="res://src/gui/menu_theme.tres" id="1_62uke"] [ext_resource type="Script" path="res://src/gui/menu/level.gd" id="2_6ldjx"] -[node name="level" type="Control"] +[node name="level" type="Control" node_paths=PackedStringArray("first_selection")] layout_mode = 3 anchors_preset = 15 anchor_right = 1.0 @@ -12,6 +12,7 @@ grow_horizontal = 2 grow_vertical = 2 theme = ExtResource("1_62uke") script = ExtResource("2_6ldjx") +first_selection = NodePath("Pause/VBoxContainer/ContinueButton") [node name="Pause" type="Panel" parent="."] layout_mode = 1 diff --git a/src/gui/menu/main.gd b/src/gui/menu/main.gd index f5bdd96..e3d3d09 100644 --- a/src/gui/menu/main.gd +++ b/src/gui/menu/main.gd @@ -2,11 +2,13 @@ extends Control @export var main_menu: Control @export var level_select: Control +@export var first_selection: Control +@export var level_first_selection: Control # Called when the node enters the scene tree for the first time. func _ready(): - $Main/VBoxContainer/StartButton.grab_focus() + first_selection.grab_focus() # Called every frame. 'delta' is the elapsed time since the previous frame. @@ -18,11 +20,13 @@ func _on_start_button_pressed(): # get_tree().change_scene("res://game/main.tscn") main_menu.hide() level_select.show() + level_first_selection.grab_focus() func _on_options_button_pressed(): var options = load("res://src/gui/menu/options.tscn").instantiate() get_parent().add_child((options)) + options.last_menu = self hide() func _on_quit_button_pressed(): @@ -31,6 +35,7 @@ func _on_quit_button_pressed(): func _on_back_button_pressed(): level_select.hide() main_menu.show() + first_selection.grab_focus() func _on_level_button_pressed(level:int): load_level("res://src/game/levels/level_%s.tscn" % level) diff --git a/src/gui/menu/main.tscn b/src/gui/menu/main.tscn index 6745e4a..9b08713 100644 --- a/src/gui/menu/main.tscn +++ b/src/gui/menu/main.tscn @@ -54,7 +54,7 @@ Button/styles/normal = SubResource("StyleBoxFlat_uo2yv") Button/styles/pressed = SubResource("StyleBoxFlat_sjhib") Panel/styles/panel = SubResource("StyleBoxFlat_5it3g") -[node name="Menu" type="Control" node_paths=PackedStringArray("main_menu", "level_select")] +[node name="Menu" type="Control" node_paths=PackedStringArray("main_menu", "level_select", "first_selection", "level_first_selection")] layout_mode = 3 anchors_preset = 15 anchor_right = 1.0 @@ -67,6 +67,8 @@ theme = SubResource("Theme_67fiq") script = ExtResource("1_p5r7q") main_menu = NodePath("Main") level_select = NodePath("LevelSelect") +first_selection = NodePath("Main/VBoxContainer/StartButton") +level_first_selection = NodePath("LevelSelect/VBoxContainer/VBoxContainer2/Row1/1") [node name="Main" type="Panel" parent="."] layout_mode = 1 @@ -268,6 +270,11 @@ volume_db = -29.953 autoplay = true bus = &"Music" +[node name="menubox" type="Control" parent="."] +anchors_preset = 0 +offset_right = 40.0 +offset_bottom = 40.0 + [connection signal="pressed" from="Main/VBoxContainer/StartButton" to="." method="_on_start_button_pressed"] [connection signal="pressed" from="Main/VBoxContainer/OptionsButton" to="." method="_on_options_button_pressed"] [connection signal="pressed" from="Main/VBoxContainer/QuitButton" to="." method="_on_quit_button_pressed"] diff --git a/src/gui/menu/options.gd b/src/gui/menu/options.gd index 4aa028d..933688a 100644 --- a/src/gui/menu/options.gd +++ b/src/gui/menu/options.gd @@ -1,5 +1,13 @@ extends Control +@export var first_selection: Control + +var last_menu: Control + +# Called when the node enters the scene tree for the first time. +func _ready(): + first_selection.grab_focus() + func _on_back_button_pressed(): - get_parent().get_child(0).show() + last_menu.show() queue_free() diff --git a/src/gui/menu/options.tscn b/src/gui/menu/options.tscn index 7e16c34..b5ac2ca 100644 --- a/src/gui/menu/options.tscn +++ b/src/gui/menu/options.tscn @@ -1,10 +1,11 @@ -[gd_scene load_steps=4 format=3 uid="uid://fqg6y7xp34u0"] +[gd_scene load_steps=5 format=3 uid="uid://fqg6y7xp34u0"] [ext_resource type="Script" path="res://src/gui/menu/options.gd" id="1_0813x"] [ext_resource type="Theme" uid="uid://dpktnl3r5wul1" path="res://src/gui/menu_theme.tres" id="1_stpo1"] [ext_resource type="Script" path="res://src/gui/menu/volume_slider.gd" id="3_2vqm2"] +[ext_resource type="Script" path="res://src/gui/menu/brightness.gd" id="4_gybdg"] -[node name="options" type="Control"] +[node name="options" type="Control" node_paths=PackedStringArray("first_selection")] layout_mode = 3 anchors_preset = 15 anchor_right = 1.0 @@ -13,6 +14,7 @@ grow_horizontal = 2 grow_vertical = 2 theme = ExtResource("1_stpo1") script = ExtResource("1_0813x") +first_selection = NodePath("Background/BackButton") [node name="Background" type="Panel" parent="."] layout_mode = 1 @@ -49,9 +51,9 @@ anchor_top = 0.5 anchor_right = 0.5 anchor_bottom = 0.5 offset_left = -102.0 -offset_top = -84.0 +offset_top = -102.0 offset_right = 102.0 -offset_bottom = 120.0 +offset_bottom = 102.0 grow_horizontal = 2 grow_vertical = 2 @@ -120,6 +122,20 @@ step = 0.001 script = ExtResource("3_2vqm2") bus_name = "Sfx" +[node name="Label2" type="Label" parent="Background/VBoxContainer"] +layout_mode = 2 +text = "BRIGHTNESS" +horizontal_alignment = 1 + +[node name="Brightness" type="HSlider" parent="Background/VBoxContainer"] +custom_minimum_size = Vector2(125, 0) +layout_mode = 2 +min_value = 0.01 +max_value = 4.0 +step = 0.01 +value = 1.0 +script = ExtResource("4_gybdg") + [node name="BackButton" type="Button" parent="Background"] custom_minimum_size = Vector2(120, 40) layout_mode = 1 @@ -139,4 +155,5 @@ size_flags_vertical = 8 focus_neighbor_bottom = NodePath("../StartButton") text = "Back" +[connection signal="value_changed" from="Background/VBoxContainer/Brightness" to="Background/VBoxContainer/Brightness" method="_on_value_changed"] [connection signal="pressed" from="Background/BackButton" to="." method="_on_back_button_pressed"] diff --git a/src/world_environment.tscn b/src/world_environment.tscn new file mode 100644 index 0000000..918a6ba --- /dev/null +++ b/src/world_environment.tscn @@ -0,0 +1,8 @@ +[gd_scene load_steps=2 format=3 uid="uid://6eet3w6wn1pn"] + +[sub_resource type="Environment" id="Environment_1wedi"] +background_mode = 3 +adjustment_enabled = true + +[node name="WorldEnvironment" type="WorldEnvironment"] +environment = SubResource("Environment_1wedi")