added brightness slider

This commit is contained in:
KingGurke 2023-10-02 19:26:53 +02:00
parent abd25a59a7
commit 299d5fe09d
9 changed files with 72 additions and 9 deletions

View file

@ -15,6 +15,10 @@ run/main_scene="res://src/gui/menu/main.tscn"
config/features=PackedStringArray("4.1", "Forward Plus") config/features=PackedStringArray("4.1", "Forward Plus")
config/icon="res://icon.svg" config/icon="res://icon.svg"
[autoload]
GlobalWorldEnvironment="*res://src/world_environment.tscn"
[dotnet] [dotnet]
project/assembly_name="LD54" project/assembly_name="LD54"

View file

@ -0,0 +1,7 @@
extends HSlider
func _on_value_changed(value):
print_debug("setting brightness to ", value)
GlobalWorldEnvironment.environment.adjustment_brightness = value

View file

@ -1,5 +1,10 @@
extends Control extends Control
@export var first_selection: Control
func _ready():
first_selection.grab_focus()
func _on_continue_button_pressed(): func _on_continue_button_pressed():
get_tree().current_scene.pause() get_tree().current_scene.pause()
@ -10,4 +15,5 @@ func _on_menu_button_pressed():
func _on_options_button_pressed(): func _on_options_button_pressed():
var options = load("res://src/gui/menu/options.tscn").instantiate() var options = load("res://src/gui/menu/options.tscn").instantiate()
get_parent().add_child((options)) get_parent().add_child((options))
options.last_menu = self
hide() hide()

View file

@ -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="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"] [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 layout_mode = 3
anchors_preset = 15 anchors_preset = 15
anchor_right = 1.0 anchor_right = 1.0
@ -12,6 +12,7 @@ grow_horizontal = 2
grow_vertical = 2 grow_vertical = 2
theme = ExtResource("1_62uke") theme = ExtResource("1_62uke")
script = ExtResource("2_6ldjx") script = ExtResource("2_6ldjx")
first_selection = NodePath("Pause/VBoxContainer/ContinueButton")
[node name="Pause" type="Panel" parent="."] [node name="Pause" type="Panel" parent="."]
layout_mode = 1 layout_mode = 1

View file

@ -2,11 +2,13 @@ extends Control
@export var main_menu: Control @export var main_menu: Control
@export var level_select: 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. # Called when the node enters the scene tree for the first time.
func _ready(): func _ready():
$Main/VBoxContainer/StartButton.grab_focus() first_selection.grab_focus()
# Called every frame. 'delta' is the elapsed time since the previous frame. # 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") # get_tree().change_scene("res://game/main.tscn")
main_menu.hide() main_menu.hide()
level_select.show() level_select.show()
level_first_selection.grab_focus()
func _on_options_button_pressed(): func _on_options_button_pressed():
var options = load("res://src/gui/menu/options.tscn").instantiate() var options = load("res://src/gui/menu/options.tscn").instantiate()
get_parent().add_child((options)) get_parent().add_child((options))
options.last_menu = self
hide() hide()
func _on_quit_button_pressed(): func _on_quit_button_pressed():
@ -31,6 +35,7 @@ func _on_quit_button_pressed():
func _on_back_button_pressed(): func _on_back_button_pressed():
level_select.hide() level_select.hide()
main_menu.show() main_menu.show()
first_selection.grab_focus()
func _on_level_button_pressed(level:int): func _on_level_button_pressed(level:int):
load_level("res://src/game/levels/level_%s.tscn" % level) load_level("res://src/game/levels/level_%s.tscn" % level)

View file

@ -54,7 +54,7 @@ Button/styles/normal = SubResource("StyleBoxFlat_uo2yv")
Button/styles/pressed = SubResource("StyleBoxFlat_sjhib") Button/styles/pressed = SubResource("StyleBoxFlat_sjhib")
Panel/styles/panel = SubResource("StyleBoxFlat_5it3g") 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 layout_mode = 3
anchors_preset = 15 anchors_preset = 15
anchor_right = 1.0 anchor_right = 1.0
@ -67,6 +67,8 @@ theme = SubResource("Theme_67fiq")
script = ExtResource("1_p5r7q") script = ExtResource("1_p5r7q")
main_menu = NodePath("Main") main_menu = NodePath("Main")
level_select = NodePath("LevelSelect") 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="."] [node name="Main" type="Panel" parent="."]
layout_mode = 1 layout_mode = 1
@ -268,6 +270,11 @@ volume_db = -29.953
autoplay = true autoplay = true
bus = &"Music" 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/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/OptionsButton" to="." method="_on_options_button_pressed"]
[connection signal="pressed" from="Main/VBoxContainer/QuitButton" to="." method="_on_quit_button_pressed"] [connection signal="pressed" from="Main/VBoxContainer/QuitButton" to="." method="_on_quit_button_pressed"]

View file

@ -1,5 +1,13 @@
extends Control 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(): func _on_back_button_pressed():
get_parent().get_child(0).show() last_menu.show()
queue_free() queue_free()

View file

@ -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="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="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/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 layout_mode = 3
anchors_preset = 15 anchors_preset = 15
anchor_right = 1.0 anchor_right = 1.0
@ -13,6 +14,7 @@ grow_horizontal = 2
grow_vertical = 2 grow_vertical = 2
theme = ExtResource("1_stpo1") theme = ExtResource("1_stpo1")
script = ExtResource("1_0813x") script = ExtResource("1_0813x")
first_selection = NodePath("Background/BackButton")
[node name="Background" type="Panel" parent="."] [node name="Background" type="Panel" parent="."]
layout_mode = 1 layout_mode = 1
@ -49,9 +51,9 @@ anchor_top = 0.5
anchor_right = 0.5 anchor_right = 0.5
anchor_bottom = 0.5 anchor_bottom = 0.5
offset_left = -102.0 offset_left = -102.0
offset_top = -84.0 offset_top = -102.0
offset_right = 102.0 offset_right = 102.0
offset_bottom = 120.0 offset_bottom = 102.0
grow_horizontal = 2 grow_horizontal = 2
grow_vertical = 2 grow_vertical = 2
@ -120,6 +122,20 @@ step = 0.001
script = ExtResource("3_2vqm2") script = ExtResource("3_2vqm2")
bus_name = "Sfx" 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"] [node name="BackButton" type="Button" parent="Background"]
custom_minimum_size = Vector2(120, 40) custom_minimum_size = Vector2(120, 40)
layout_mode = 1 layout_mode = 1
@ -139,4 +155,5 @@ size_flags_vertical = 8
focus_neighbor_bottom = NodePath("../StartButton") focus_neighbor_bottom = NodePath("../StartButton")
text = "Back" 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"] [connection signal="pressed" from="Background/BackButton" to="." method="_on_back_button_pressed"]

View file

@ -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")