From ee998abc9dfaaf242f48abe991b8cc64dced8fe6 Mon Sep 17 00:00:00 2001 From: Jan Heemstra Date: Wed, 1 Dec 2021 00:03:18 +0100 Subject: [PATCH 1/2] Added boilerplate code for graphics menu items --- Game/Assets/UI/GUI.gd | 87 +++++++++++++++++++-- Game/Assets/UI/GraphicsMenu.gd | 64 ++++++++++++++- Game/Assets/UI/GraphicsMenu.tscn | 129 ++++++++++++++++++++++++++++++- 3 files changed, 266 insertions(+), 14 deletions(-) diff --git a/Game/Assets/UI/GUI.gd b/Game/Assets/UI/GUI.gd index 08f4e45..3c9f0f3 100644 --- a/Game/Assets/UI/GUI.gd +++ b/Game/Assets/UI/GUI.gd @@ -43,12 +43,36 @@ func load_settings(): func apply_settings(): for key in settings.keys(): match key: - "Fullscreen": - toggle_fullscreen(settings[key]) "Sensitivity": set_mouse_sensitivity(settings[key]) - "EyeCandyLighting": - toggle_lighting(settings[key]) + "GraphicsEyeCandyLighting": + set_lighting(settings[key]) + "GraphicsFullscreen": + set_fullscreen(settings[key]) + "GraphicsAmbientOcclusion": + set_ambient_occlusion(settings[key]) + "GraphicsShadows": + set_shadows(settings[key]) + "GraphicsGlobalIllumination": + set_global_illumination(settings[key]) + "GraphicsScreenSpaceReflections": + set_screen_space_reflections(settings[key]) + "GraphicsReflectionProbes": + set_reflection_probes(settings[key]) + "GraphicsGlow": + set_glow(settings[key]) + "GraphicsMSAA": + set_MSAA(settings[key]) + "GraphicsFXAA": + set_FXAA(settings[key]) + "GraphicsDebanding": + set_debanding(settings[key]) + "GraphicsDecalsStatic": + set_decals_static(settings[key]) + "GraphicsDecalsDecals": + set_decals_decals(settings[key]) + "GraphicsDynamicLights": + set_dynamic_lights(settings[key]) # These functions are for applying settings changes func quit_game(): @@ -66,19 +90,66 @@ func quit_game(): get_tree().quit() -func toggle_fullscreen(is_fullscreen): +func set_mouse_sensitivity(sensitivity): + pass + +func set_fullscreen(is_fullscreen): if is_fullscreen: get_tree().get_root().mode = Window.MODE_FULLSCREEN else: get_tree().get_root().mode = Window.MODE_WINDOWED -func toggle_lighting(is_enabled): +func set_lighting(is_enabled): var map = get_tree().get_root().get_node("Main").get_node("Map") map.get_node("Lights").visible = is_enabled map.get_node("Decals").visible = is_enabled map.get_node("ReflectionProbes").visible = is_enabled - -func set_mouse_sensitivity(sensitivity): +func set_ambient_occlusion(is_enabled): + # TODO + pass + +func set_shadows(is_enabled): + # TODO + pass + +func set_global_illumination(is_enabled): + # TODO + pass + +func set_screen_space_reflections(is_enabled): + # TODO + pass + +func set_reflection_probes(is_enabled): + # TODO + pass + +func set_glow(is_enabled): + # TODO + pass + +func set_MSAA(is_enabled): + # TODO + pass + +func set_FXAA(is_enabled): + # TODO + pass + +func set_debanding(is_enabled): + # TODO + pass + +func set_decals_static(is_enabled): + # TODO + pass + +func set_decals_decals(is_enabled): + # TODO + pass + +func set_dynamic_lights(is_enabled): + # TODO pass diff --git a/Game/Assets/UI/GraphicsMenu.gd b/Game/Assets/UI/GraphicsMenu.gd index 2e453ab..b701d77 100644 --- a/Game/Assets/UI/GraphicsMenu.gd +++ b/Game/Assets/UI/GraphicsMenu.gd @@ -2,10 +2,70 @@ extends "res://Assets/UI/Menu.gd" func on_fullscreen_toggled(button_pressed): if GUI: - GUI.toggle_fullscreen(button_pressed) + GUI.set_fullscreen(button_pressed) $Fullscreen.save_data() func on_lighting_toggled(button_pressed): if GUI: - GUI.toggle_lighting(button_pressed) + GUI.set_lighting(button_pressed) $Lighting.save_data() + +func on_ambient_occlusion_toggled(button_pressed): + if GUI: + GUI.set_ambient_occlusion(button_pressed) + $AmbientOcclusion.save_data() + +func on_shadows_toggled(button_pressed): + if GUI: + GUI.set_shadows(button_pressed) + $Shadows.save_data() + +func on_global_illumination_toggled(button_pressed): + if GUI: + GUI.set_global_illumination(button_pressed) + $GlobalIllumination.save_data() + +func on_screen_space_reflections_toggled(button_pressed): + if GUI: + GUI.set_screen_space_reflections(button_pressed) + $ScreenSpaceReflections.save_data() + +func on_reflection_probes_toggled(button_pressed): + if GUI: + GUI.set_reflection_probes(button_pressed) + $ReflectionProbes.save_data() + +func on_glow_toggled(button_pressed): + if GUI: + GUI.set_glow(button_pressed) + $Glow.save_data() + +func on_MSAA_toggled(button_pressed): + if GUI: + GUI.set_MSAA(button_pressed) + $MSAA.save_data() + +func on_FXAA_toggled(button_pressed): + if GUI: + GUI.set_FXAA(button_pressed) + $FXAA.save_data() + +func on_debanding_toggled(button_pressed): + if GUI: + GUI.set_debanding(button_pressed) + $Debanding.save_data() + +func on_decals_static_toggled(button_pressed): + if GUI: + GUI.set_decals_static(button_pressed) + $DecalsStatic.save_data() + +func on_decals_decals_toggled(button_pressed): + if GUI: + GUI.set_decals_decals(button_pressed) + $DecalsDecals.save_data() + +func on_dynamic_lights_toggled(button_pressed): + if GUI: + GUI.set_dynamic_lights(button_pressed) + $DynamicLights.save_data() diff --git a/Game/Assets/UI/GraphicsMenu.tscn b/Game/Assets/UI/GraphicsMenu.tscn index 030a8f2..0d6c6c0 100644 --- a/Game/Assets/UI/GraphicsMenu.tscn +++ b/Game/Assets/UI/GraphicsMenu.tscn @@ -12,8 +12,9 @@ anchor_right = 0.0 anchor_bottom = 0.0 offset_right = 250.0 offset_bottom = 40.0 +theme_override_font_sizes/font_size = 16 label = "Fullscreen" -index = "Fullscreen" +index = "GraphicsFullscreen" [node name="Lighting" parent="." index="1" instance=ExtResource( "3" )] anchor_right = 0.0 @@ -22,11 +23,131 @@ offset_top = 44.0 offset_right = 250.0 offset_bottom = 84.0 label = "Eye Candy Lighting" -index = "EyeCandyLighting" +index = "GraphicsEyeCandyLighting" -[node name="Back" parent="." index="2"] +[node name="AmbientOcclusion" parent="." index="2" instance=ExtResource( "3" )] +anchor_right = 0.0 +anchor_bottom = 0.0 offset_top = 88.0 -offset_bottom = 117.0 +offset_right = 250.0 +offset_bottom = 128.0 +label = "Ambient Occlusion" +index = "GraphicsAmbientOcclusion" + +[node name="Shadows" parent="." index="3" instance=ExtResource( "3" )] +anchor_right = 0.0 +anchor_bottom = 0.0 +offset_top = 132.0 +offset_right = 250.0 +offset_bottom = 172.0 +label = "Shadows" +index = "GraphicsShadows" + +[node name="GlobalIllumination" parent="." index="4" instance=ExtResource( "3" )] +anchor_right = 0.0 +anchor_bottom = 0.0 +offset_top = 176.0 +offset_right = 250.0 +offset_bottom = 216.0 +label = "Global Illumination" +index = "GraphicsGlobalIllumination" + +[node name="ScreenSpaceReflections" parent="." index="5" instance=ExtResource( "3" )] +anchor_right = 0.0 +anchor_bottom = 0.0 +offset_top = 220.0 +offset_right = 250.0 +offset_bottom = 260.0 +label = "Screen Space Reflections" +index = "GraphicsScreenSpaceReflections" + +[node name="ReflectionProbes" parent="." index="6" instance=ExtResource( "3" )] +anchor_right = 0.0 +anchor_bottom = 0.0 +offset_top = 264.0 +offset_right = 250.0 +offset_bottom = 304.0 +label = "Reflection Probes" +index = "GraphicsReflectionProbes" + +[node name="Glow" parent="." index="7" instance=ExtResource( "3" )] +anchor_right = 0.0 +anchor_bottom = 0.0 +offset_top = 308.0 +offset_right = 250.0 +offset_bottom = 348.0 +label = "Glow" +index = "GraphicsGlow" + +[node name="MSAA" parent="." index="8" instance=ExtResource( "3" )] +anchor_right = 0.0 +anchor_bottom = 0.0 +offset_top = 352.0 +offset_right = 250.0 +offset_bottom = 392.0 +label = "MSAA" +index = "GraphicsMSAA" + +[node name="FXAA" parent="." index="9" instance=ExtResource( "3" )] +anchor_right = 0.0 +anchor_bottom = 0.0 +offset_top = 396.0 +offset_right = 250.0 +offset_bottom = 436.0 +label = "FXAA" +index = "GraphicsFXAA" + +[node name="Debanding" parent="." index="10" instance=ExtResource( "3" )] +anchor_right = 0.0 +anchor_bottom = 0.0 +offset_top = 440.0 +offset_right = 250.0 +offset_bottom = 480.0 +label = "Debanding" +index = "GraphicsDebanding" + +[node name="DecalsStatic" parent="." index="11" instance=ExtResource( "3" )] +anchor_right = 0.0 +anchor_bottom = 0.0 +offset_top = 484.0 +offset_right = 250.0 +offset_bottom = 524.0 +label = "Decals Static" +index = "GraphicsDecalsStatic" + +[node name="DecalsDecals" parent="." index="12" instance=ExtResource( "3" )] +anchor_right = 0.0 +anchor_bottom = 0.0 +offset_top = 528.0 +offset_right = 250.0 +offset_bottom = 568.0 +label = "Decals Decals" +index = "GraphicsDecalsDecals" + +[node name="DynamicLights" parent="." index="13" instance=ExtResource( "3" )] +anchor_right = 0.0 +anchor_bottom = 0.0 +offset_top = 572.0 +offset_right = 250.0 +offset_bottom = 612.0 +label = "Dynamic Lights" +index = "GraphicsDynamicLights" + +[node name="Back" parent="." index="14"] +offset_top = 616.0 +offset_bottom = 645.0 [connection signal="toggled" from="Fullscreen" to="." method="on_fullscreen_toggled"] [connection signal="toggled" from="Lighting" to="." method="on_lighting_toggled"] +[connection signal="toggled" from="AmbientOcclusion" to="." method="on_ambient_occlusion_toggled"] +[connection signal="toggled" from="Shadows" to="." method="on_shadows_toggled"] +[connection signal="toggled" from="GlobalIllumination" to="." method="on_global_illumination_toggled"] +[connection signal="toggled" from="ScreenSpaceReflections" to="." method="on_screen_space_reflections_toggled"] +[connection signal="toggled" from="ReflectionProbes" to="." method="on_reflection_probes_toggled"] +[connection signal="toggled" from="Glow" to="." method="on_glow_toggled"] +[connection signal="toggled" from="MSAA" to="." method="on_MSAA_toggled"] +[connection signal="toggled" from="FXAA" to="." method="on_FXAA_toggled"] +[connection signal="toggled" from="Debanding" to="." method="on_debanding_toggled"] +[connection signal="toggled" from="DecalsStatic" to="." method="on_decals_static_toggled"] +[connection signal="toggled" from="DecalsDecals" to="." method="on_decals_decals_toggled"] +[connection signal="toggled" from="DynamicLights" to="." method="on_dynamic_lights_toggled"] From cc0aad761be6f387aa848141697eb5d3c6b636fc Mon Sep 17 00:00:00 2001 From: Jan Heemstra Date: Wed, 1 Dec 2021 00:22:47 +0100 Subject: [PATCH 2/2] Added menu scrollcontainer --- Game/Assets/UI/GUI.tscn | 44 ++++++++++++++++++++++++-------------- Game/Assets/UI/Menu.gd | 4 ++-- Game/Assets/UI/Menu.tscn | 5 ++++- Game/Assets/UI/MenuData.gd | 2 +- 4 files changed, 35 insertions(+), 20 deletions(-) diff --git a/Game/Assets/UI/GUI.tscn b/Game/Assets/UI/GUI.tscn index 3bc8248..d65f27b 100644 --- a/Game/Assets/UI/GUI.tscn +++ b/Game/Assets/UI/GUI.tscn @@ -6,9 +6,12 @@ [ext_resource type="Script" path="res://Assets/UI/GUI.gd" id="3"] [ext_resource type="AudioStream" uid="uid://dpjwcruomxgkk" path="res://Assets/SFX/UI_Cancel.wav" id="4_lnh50"] -[node name="GUI" type="CenterContainer"] +[node name="GUI" type="VBoxContainer"] anchor_right = 1.0 anchor_bottom = 1.0 +offset_top = 20.0 +offset_bottom = -20.0 +alignment = 1 script = ExtResource( "3" ) __meta__ = { "_edit_use_anchors_": false @@ -16,24 +19,33 @@ __meta__ = { [node name="Logo" type="TextureRect" parent="."] offset_left = 256.0 -offset_top = 12.0 offset_right = 768.0 -offset_bottom = 587.0 -rect_min_size = Vector2(0, 575) -size_flags_horizontal = 0 +offset_bottom = 197.0 +size_flags_horizontal = 4 size_flags_vertical = 0 texture = ExtResource( "2_oueme" ) __meta__ = { "_edit_use_anchors_": false } -[node name="Menu" parent="." instance=ExtResource( "2" )] +[node name="ScrollContainer" type="ScrollContainer" parent="."] offset_left = 387.0 -offset_top = 236.0 +offset_top = 201.0 offset_right = 637.0 -offset_bottom = 364.0 +offset_bottom = 560.0 +size_flags_horizontal = 6 +size_flags_vertical = 3 +follow_focus = true +scroll_horizontal_enabled = false +scroll_horizontal_visible = false -[node name="Play" parent="Menu" instance=ExtResource( "1" )] +[node name="Menu" parent="ScrollContainer" instance=ExtResource( "2" )] +offset_left = 0.0 +offset_top = 0.0 +offset_right = 250.0 +offset_bottom = 128.0 + +[node name="Play" parent="ScrollContainer/Menu" instance=ExtResource( "1" )] anchor_right = 0.0 anchor_bottom = 0.0 offset_top = 33.0 @@ -43,7 +55,7 @@ text = "play " label = "play" -[node name="Options" parent="Menu" instance=ExtResource( "1" )] +[node name="Options" parent="ScrollContainer/Menu" instance=ExtResource( "1" )] anchor_right = 0.0 anchor_bottom = 0.0 offset_top = 66.0 @@ -53,7 +65,7 @@ theme_override_font_sizes/font_size = 16 text = "options" label = "options" -[node name="Quit" parent="Menu" instance=ExtResource( "1" )] +[node name="Quit" parent="ScrollContainer/Menu" instance=ExtResource( "1" )] anchor_right = 0.0 anchor_bottom = 0.0 offset_top = 99.0 @@ -62,11 +74,11 @@ offset_bottom = 128.0 text = "quit" label = "quit" -[node name="ClickSound" parent="Menu/Quit" index="0"] +[node name="ClickSound" parent="ScrollContainer/Menu/Quit" index="0"] stream = ExtResource( "4_lnh50" ) -[connection signal="pressed" from="Menu/Play" to="Menu" method="open_menu" binds= ["res://Assets/UI/PlayMenu.tscn"]] -[connection signal="pressed" from="Menu/Options" to="Menu" method="open_menu" binds= ["res://Assets/UI/OptionsMenu.tscn"]] -[connection signal="pressed" from="Menu/Quit" to="." method="quit_game"] +[connection signal="pressed" from="ScrollContainer/Menu/Play" to="ScrollContainer/Menu" method="open_menu" binds= ["res://Assets/UI/PlayMenu.tscn"]] +[connection signal="pressed" from="ScrollContainer/Menu/Options" to="ScrollContainer/Menu" method="open_menu" binds= ["res://Assets/UI/OptionsMenu.tscn"]] +[connection signal="pressed" from="ScrollContainer/Menu/Quit" to="." method="quit_game"] -[editable path="Menu/Quit"] +[editable path="ScrollContainer/Menu/Quit"] diff --git a/Game/Assets/UI/Menu.gd b/Game/Assets/UI/Menu.gd index dbbc9af..830b1bd 100644 --- a/Game/Assets/UI/Menu.gd +++ b/Game/Assets/UI/Menu.gd @@ -2,8 +2,8 @@ extends VBoxContainer var previous_menu : Node = null var settings = {} -@onready var GUI = get_parent() -@onready var Main = get_parent().get_parent() +@onready var GUI = get_parent().get_parent() +@onready var Main = get_parent().get_parent().get_parent() # Called when the node enters the scene tree for the first time. func _ready(): diff --git a/Game/Assets/UI/Menu.tscn b/Game/Assets/UI/Menu.tscn index 920f7f7..a30fe84 100644 --- a/Game/Assets/UI/Menu.tscn +++ b/Game/Assets/UI/Menu.tscn @@ -10,14 +10,17 @@ offset_top = 269.0 offset_right = 548.0 offset_bottom = 331.0 rect_min_size = Vector2(250, 0) +size_flags_vertical = 3 +alignment = 1 script = ExtResource( "1" ) __meta__ = { "_edit_use_anchors_": false } [node name="Back" type="Button" parent="."] +offset_top = 16.0 offset_right = 250.0 -offset_bottom = 29.0 +offset_bottom = 45.0 text = "back " diff --git a/Game/Assets/UI/MenuData.gd b/Game/Assets/UI/MenuData.gd index abae6b5..6ac6b44 100644 --- a/Game/Assets/UI/MenuData.gd +++ b/Game/Assets/UI/MenuData.gd @@ -1,7 +1,7 @@ extends "res://Assets/UI/MenuItem.gd" @export var index = "" -@onready var GUI = get_parent().get_parent() +@onready var GUI = get_parent().get_parent().get_parent() signal data_changed(data)