Added graphics & display settings to settings menu

This commit is contained in:
Rob Kelly 2024-12-09 11:49:40 -07:00
parent 6bd59706ab
commit 4575fb1d08
7 changed files with 216 additions and 6 deletions

View File

@ -27,6 +27,55 @@ SETTINGS_ACCELERATION_Y,"Acceleration, Vertical"
SETTINGS_INVERT_PITCH,"Invert Pitch"
SETTINGS_GRAPHICS,Graphics
SETTINGS_GRAPHICS_HEADING,"Graphics & Display"
SETTINGS_GRAPHICS_DISPLAY_HEADING,Display
SETTINGS_GRAPHICS_FULLSCREEN,Fullscreen
SETTINGS_GRAPHICS_VSYNC,V-Sync
SETTINGS_GRAPHICS_AA_HEADING,Antialiasing
SETTINGS_GRAPHICS_MSAA,MSAA
SETTINGS_GRAPHICS_MSAA_0,"Disabled (Fastest)"
SETTINGS_GRAPHICS_MSAA_2,"2× (Average)"
SETTINGS_GRAPHICS_MSAA_4,"4× (Slow)"
SETTINGS_GRAPHICS_MSAA_8,"8× (Slowest)"
SETTINGS_GRAPHICS_FXAA,"Enable FXAA"
SETTINGS_GRAPHICS_TAA,"Enable TAA"
SETTINGS_GRAPHICS_DEBANDING,"Use Debanding"
SETTINGS_GRAPHICS_TEXTURES_HEADING,Textures
SETTINGS_GRAPHICS_ANISOTROPIC,"Anisotropic Filtering Level (requires restart)"
SETTINGS_GRAPHICS_ANISOTROPIC_0,"Disabled (Fastest)"
SETTINGS_GRAPHICS_ANISOTROPIC_1,"2× (Faster)"
SETTINGS_GRAPHICS_ANISOTROPIC_2,"4× (Fast)"
SETTINGS_GRAPHICS_ANISOTROPIC_3,"8× (Average)"
SETTINGS_GRAPHICS_ANISOTROPIC_4,"16× (Slow)"
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
SETTINGS_AUDIO,Audio
SETTINGS_AUDIO_HEADING,"Audio Settings"
SETTINGS_CONTROLS,Controls

1 keys en
27 SETTINGS_INVERT_PITCH Invert Pitch
28 SETTINGS_GRAPHICS Graphics
29 SETTINGS_GRAPHICS_HEADING Graphics & Display
30 SETTINGS_GRAPHICS_DISPLAY_HEADING Display
31 SETTINGS_GRAPHICS_FULLSCREEN Fullscreen
32 SETTINGS_GRAPHICS_VSYNC V-Sync
33 SETTINGS_GRAPHICS_AA_HEADING Antialiasing
34 SETTINGS_GRAPHICS_MSAA MSAA
35 SETTINGS_GRAPHICS_MSAA_0 Disabled (Fastest)
36 SETTINGS_GRAPHICS_MSAA_2 2× (Average)
37 SETTINGS_GRAPHICS_MSAA_4 4× (Slow)
38 SETTINGS_GRAPHICS_MSAA_8 8× (Slowest)
39 SETTINGS_GRAPHICS_FXAA Enable FXAA
40 SETTINGS_GRAPHICS_TAA Enable TAA
41 SETTINGS_GRAPHICS_DEBANDING Use Debanding
42 SETTINGS_GRAPHICS_TEXTURES_HEADING Textures
43 SETTINGS_GRAPHICS_ANISOTROPIC Anisotropic Filtering Level (requires restart)
44 SETTINGS_GRAPHICS_ANISOTROPIC_0 Disabled (Fastest)
45 SETTINGS_GRAPHICS_ANISOTROPIC_1 2× (Faster)
46 SETTINGS_GRAPHICS_ANISOTROPIC_2 4× (Fast)
47 SETTINGS_GRAPHICS_ANISOTROPIC_3 8× (Average)
48 SETTINGS_GRAPHICS_ANISOTROPIC_4 16× (Slow)
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79 SETTINGS_AUDIO Audio
80 SETTINGS_AUDIO_HEADING Audio Settings
81 SETTINGS_CONTROLS Controls

View File

@ -1,9 +1,10 @@
[gd_scene load_steps=9 format=3 uid="uid://cefit4bc8akbb"]
[gd_scene load_steps=10 format=3 uid="uid://cefit4bc8akbb"]
[ext_resource type="Script" path="res://src/game/game.gd" id="1_4qa87"]
[ext_resource type="FontFile" uid="uid://dsa0oh7c0h4pu" path="res://assets/fonts/Racing_Sans_One/RacingSansOne-Regular.ttf" id="2_y3adf"]
[ext_resource type="Script" path="res://src/ui/decorations/rumbler.gd" id="3_3vfdb"]
[ext_resource type="Script" path="res://src/ui/game_viewport_container.gd" id="3_rmm5i"]
[ext_resource type="Script" path="res://src/game/game_viewport.gd" id="5_v2qv5"]
[sub_resource type="Animation" id="Animation_c3dlb"]
length = 0.001
@ -192,6 +193,7 @@ use_taa = true
audio_listener_enable_3d = true
size = Vector2i(1920, 1080)
render_target_update_mode = 4
script = ExtResource("5_v2qv5")
[node name="Content" type="Node" parent="RootControl/Rumbler/ViewportContainer/Viewport"]
unique_name_in_owner = true

16
src/game/game_viewport.gd Normal file
View File

@ -0,0 +1,16 @@
extends SubViewport
## Logic for dynamically resetting viewport graphics settings
func _ready() -> void:
ProjectSettings.settings_changed.connect(apply_rendering_settings)
func apply_rendering_settings() -> void:
print_debug("Applying rendering settings to viewport")
msaa_2d = ProjectSettings.get_setting("rendering/anti_aliasing/quality/msaa_2d")
msaa_3d = ProjectSettings.get_setting("rendering/anti_aliasing/quality/msaa_3d")
screen_space_aa = ProjectSettings.get_setting("rendering/anti_aliasing/quality/screen_space_aa")
use_taa = ProjectSettings.get_setting("rendering/anti_aliasing/quality/use_taa")
use_debanding = ProjectSettings.get_setting("rendering/anti_aliasing/quality/use_debanding")

View File

@ -0,0 +1,10 @@
extends "res://src/ui/menus/settings_menu/settings/checkbox_setting/checkbox_setting.gd"
## Special case setting for fullscreen mode
func initialize_value(value: Variant) -> void:
checkbox.button_pressed = (value as Window.Mode) == Window.MODE_FULLSCREEN
func get_value() -> Variant:
return Window.MODE_FULLSCREEN if checkbox.button_pressed else Window.MODE_WINDOWED

View File

@ -0,0 +1,12 @@
extends Setting
## Setting with a dropdown menu representing an enum value
@onready var dropdown: OptionButton = %Dropdown
func initialize_value(value: Variant) -> void:
dropdown.selected = dropdown.get_item_index(value as int)
func get_value() -> Variant:
return dropdown.get_item_id(dropdown.selected)

View File

@ -1,9 +1,13 @@
[gd_scene load_steps=2 format=3 uid="uid://dpry41u0ctikn"]
[gd_scene load_steps=3 format=3 uid="uid://dpry41u0ctikn"]
[ext_resource type="PackedScene" uid="uid://dcah6r3ku60g6" path="res://src/ui/menus/settings_menu/settings/setting/setting.tscn" id="1_km84n"]
[ext_resource type="Script" path="res://src/ui/menus/settings_menu/settings/dropdown_setting/dropdown_setting.gd" id="2_ubo13"]
[node name="DropdownSetting" instance=ExtResource("1_km84n")]
script = ExtResource("2_ubo13")
[node name="OptionButton" type="OptionButton" parent="PanelContainer/MarginContainer" index="0"]
[node name="Dropdown" type="OptionButton" parent="PanelContainer/MarginContainer" index="0"]
unique_name_in_owner = true
layout_mode = 2
selected = 0
item_count = 1

View File

@ -1,8 +1,10 @@
[gd_scene load_steps=4 format=3 uid="uid://d3eaqw2rdurct"]
[gd_scene load_steps=6 format=3 uid="uid://d3eaqw2rdurct"]
[ext_resource type="Script" path="res://src/ui/menus/settings_menu/settings_menu.gd" id="1_lbcn7"]
[ext_resource type="PackedScene" uid="uid://bpmpj4n6xp17l" path="res://src/ui/menus/settings_menu/settings/checkbox_setting/checkbox_setting.tscn" id="2_f274v"]
[ext_resource type="PackedScene" uid="uid://dut1lj8ju37sq" path="res://src/ui/menus/settings_menu/settings/numeric_setting/numeric_setting.tscn" id="3_jox8e"]
[ext_resource type="PackedScene" uid="uid://dpry41u0ctikn" path="res://src/ui/menus/settings_menu/settings/dropdown_setting/dropdown_setting.tscn" id="4_g7eck"]
[ext_resource type="Script" path="res://src/ui/menus/settings_menu/settings/checkbox_setting/fullscreen_setting.gd" id="4_ug1id"]
[node name="SettingsMenu" type="MarginContainer"]
anchors_preset = 15
@ -14,9 +16,10 @@ script = ExtResource("1_lbcn7")
[node name="TabContainer" type="TabContainer" parent="."]
layout_mode = 2
current_tab = 0
current_tab = 1
[node name="SETTINGS_GAME" type="MarginContainer" parent="TabContainer"]
visible = false
layout_mode = 2
theme_type_variation = &"SettingsPageContainer"
metadata/_tab_index = 0
@ -157,7 +160,6 @@ key = &"game/config/controls/camera/invert_pitch"
text = "SETTINGS_INVERT_PITCH"
[node name="SETTINGS_GRAPHICS" type="MarginContainer" parent="TabContainer"]
visible = false
layout_mode = 2
theme_type_variation = &"SettingsPageContainer"
metadata/_tab_index = 1
@ -194,6 +196,114 @@ theme_type_variation = &"SettingsListMargin"
[node name="SettingsList" type="VBoxContainer" parent="TabContainer/SETTINGS_GRAPHICS/VBoxContainer/ScrollContainer/MarginContainer"]
layout_mode = 2
[node name="DisplayHeading" type="HBoxContainer" parent="TabContainer/SETTINGS_GRAPHICS/VBoxContainer/ScrollContainer/MarginContainer/SettingsList"]
layout_mode = 2
[node name="Label" type="Label" parent="TabContainer/SETTINGS_GRAPHICS/VBoxContainer/ScrollContainer/MarginContainer/SettingsList/DisplayHeading"]
layout_mode = 2
theme_type_variation = &"HeaderMedium"
text = "SETTINGS_GRAPHICS_DISPLAY_HEADING"
[node name="HSeparator" type="HSeparator" parent="TabContainer/SETTINGS_GRAPHICS/VBoxContainer/ScrollContainer/MarginContainer/SettingsList/DisplayHeading"]
layout_mode = 2
size_flags_horizontal = 3
[node name="Fullscreen" parent="TabContainer/SETTINGS_GRAPHICS/VBoxContainer/ScrollContainer/MarginContainer/SettingsList" groups=["Settings"] instance=ExtResource("2_f274v")]
layout_mode = 2
script = ExtResource("4_ug1id")
key = &"display/window/size/mode"
[node name="SettingLabel" parent="TabContainer/SETTINGS_GRAPHICS/VBoxContainer/ScrollContainer/MarginContainer/SettingsList/Fullscreen" index="1"]
text = "SETTINGS_GRAPHICS_FULLSCREEN"
[node name="VSync" parent="TabContainer/SETTINGS_GRAPHICS/VBoxContainer/ScrollContainer/MarginContainer/SettingsList" groups=["Settings"] instance=ExtResource("2_f274v")]
layout_mode = 2
key = &"display/window/vsync/vsync_mode"
[node name="SettingLabel" parent="TabContainer/SETTINGS_GRAPHICS/VBoxContainer/ScrollContainer/MarginContainer/SettingsList/VSync" index="1"]
text = "SETTINGS_GRAPHICS_VSYNC"
[node name="AntialiasingHeading" type="HBoxContainer" parent="TabContainer/SETTINGS_GRAPHICS/VBoxContainer/ScrollContainer/MarginContainer/SettingsList"]
layout_mode = 2
[node name="Label" type="Label" parent="TabContainer/SETTINGS_GRAPHICS/VBoxContainer/ScrollContainer/MarginContainer/SettingsList/AntialiasingHeading"]
layout_mode = 2
theme_type_variation = &"HeaderMedium"
text = "SETTINGS_GRAPHICS_AA_HEADING"
[node name="HSeparator" type="HSeparator" parent="TabContainer/SETTINGS_GRAPHICS/VBoxContainer/ScrollContainer/MarginContainer/SettingsList/AntialiasingHeading"]
layout_mode = 2
size_flags_horizontal = 3
[node name="MSAA" parent="TabContainer/SETTINGS_GRAPHICS/VBoxContainer/ScrollContainer/MarginContainer/SettingsList" groups=["Settings"] instance=ExtResource("4_g7eck")]
layout_mode = 2
key = &"rendering/anti_aliasing/quality/msaa_3d"
[node name="SettingLabel" parent="TabContainer/SETTINGS_GRAPHICS/VBoxContainer/ScrollContainer/MarginContainer/SettingsList/MSAA" index="1"]
text = "SETTINGS_GRAPHICS_MSAA"
[node name="Dropdown" parent="TabContainer/SETTINGS_GRAPHICS/VBoxContainer/ScrollContainer/MarginContainer/SettingsList/MSAA/PanelContainer/MarginContainer" index="0"]
item_count = 4
popup/item_0/text = "SETTINGS_GRAPHICS_MSAA_0"
popup/item_1/text = "SETTINGS_GRAPHICS_MSAA_2"
popup/item_1/id = 1
popup/item_2/text = "SETTINGS_GRAPHICS_MSAA_4"
popup/item_2/id = 2
popup/item_3/text = "SETTINGS_GRAPHICS_MSAA_8"
popup/item_3/id = 3
[node name="FXAA" parent="TabContainer/SETTINGS_GRAPHICS/VBoxContainer/ScrollContainer/MarginContainer/SettingsList" groups=["Settings"] instance=ExtResource("2_f274v")]
layout_mode = 2
key = &"rendering/anti_aliasing/quality/screen_space_aa"
[node name="SettingLabel" parent="TabContainer/SETTINGS_GRAPHICS/VBoxContainer/ScrollContainer/MarginContainer/SettingsList/FXAA" index="1"]
text = "SETTINGS_GRAPHICS_FXAA"
[node name="TAA" parent="TabContainer/SETTINGS_GRAPHICS/VBoxContainer/ScrollContainer/MarginContainer/SettingsList" groups=["Settings"] instance=ExtResource("2_f274v")]
layout_mode = 2
key = &"rendering/anti_aliasing/quality/use_taa"
[node name="SettingLabel" parent="TabContainer/SETTINGS_GRAPHICS/VBoxContainer/ScrollContainer/MarginContainer/SettingsList/TAA" index="1"]
text = "SETTINGS_GRAPHICS_TAA"
[node name="Debanding" parent="TabContainer/SETTINGS_GRAPHICS/VBoxContainer/ScrollContainer/MarginContainer/SettingsList" groups=["Settings"] instance=ExtResource("2_f274v")]
layout_mode = 2
key = &"rendering/anti_aliasing/quality/use_debanding"
[node name="SettingLabel" parent="TabContainer/SETTINGS_GRAPHICS/VBoxContainer/ScrollContainer/MarginContainer/SettingsList/Debanding" index="1"]
text = "SETTINGS_GRAPHICS_DEBANDING"
[node name="TextureHeading" type="HBoxContainer" parent="TabContainer/SETTINGS_GRAPHICS/VBoxContainer/ScrollContainer/MarginContainer/SettingsList"]
layout_mode = 2
[node name="Label" type="Label" parent="TabContainer/SETTINGS_GRAPHICS/VBoxContainer/ScrollContainer/MarginContainer/SettingsList/TextureHeading"]
layout_mode = 2
theme_type_variation = &"HeaderMedium"
text = "SETTINGS_GRAPHICS_TEXTURES_HEADING"
[node name="HSeparator" type="HSeparator" parent="TabContainer/SETTINGS_GRAPHICS/VBoxContainer/ScrollContainer/MarginContainer/SettingsList/TextureHeading"]
layout_mode = 2
size_flags_horizontal = 3
[node name="AnisotropicLevel" parent="TabContainer/SETTINGS_GRAPHICS/VBoxContainer/ScrollContainer/MarginContainer/SettingsList" groups=["Settings"] instance=ExtResource("4_g7eck")]
layout_mode = 2
key = &"rendering/textures/default_filters/anisotropic_filtering_level"
[node name="SettingLabel" parent="TabContainer/SETTINGS_GRAPHICS/VBoxContainer/ScrollContainer/MarginContainer/SettingsList/AnisotropicLevel" index="1"]
text = "SETTINGS_GRAPHICS_ANISOTROPIC"
[node name="Dropdown" parent="TabContainer/SETTINGS_GRAPHICS/VBoxContainer/ScrollContainer/MarginContainer/SettingsList/AnisotropicLevel/PanelContainer/MarginContainer" index="0"]
item_count = 5
popup/item_0/text = "SETTINGS_GRAPHICS_ANISOTROPIC_0"
popup/item_1/text = "SETTINGS_GRAPHICS_ANISOTROPIC_1"
popup/item_1/id = 1
popup/item_2/text = "SETTINGS_GRAPHICS_ANISOTROPIC_2"
popup/item_2/id = 2
popup/item_3/text = "SETTINGS_GRAPHICS_ANISOTROPIC_3"
popup/item_3/id = 3
popup/item_4/text = "SETTINGS_GRAPHICS_ANISOTROPIC_4"
popup/item_4/id = 4
[node name="SETTINGS_AUDIO" type="MarginContainer" parent="TabContainer"]
visible = false
layout_mode = 2
@ -306,3 +416,10 @@ text = "UI_ACCEPT"
[editable path="TabContainer/SETTINGS_GAME/VBoxContainer/ScrollContainer/MarginContainer/SettingsList/AccelerationX"]
[editable path="TabContainer/SETTINGS_GAME/VBoxContainer/ScrollContainer/MarginContainer/SettingsList/AccelerationY"]
[editable path="TabContainer/SETTINGS_GAME/VBoxContainer/ScrollContainer/MarginContainer/SettingsList/InvertPitch"]
[editable path="TabContainer/SETTINGS_GRAPHICS/VBoxContainer/ScrollContainer/MarginContainer/SettingsList/Fullscreen"]
[editable path="TabContainer/SETTINGS_GRAPHICS/VBoxContainer/ScrollContainer/MarginContainer/SettingsList/VSync"]
[editable path="TabContainer/SETTINGS_GRAPHICS/VBoxContainer/ScrollContainer/MarginContainer/SettingsList/MSAA"]
[editable path="TabContainer/SETTINGS_GRAPHICS/VBoxContainer/ScrollContainer/MarginContainer/SettingsList/FXAA"]
[editable path="TabContainer/SETTINGS_GRAPHICS/VBoxContainer/ScrollContainer/MarginContainer/SettingsList/TAA"]
[editable path="TabContainer/SETTINGS_GRAPHICS/VBoxContainer/ScrollContainer/MarginContainer/SettingsList/Debanding"]
[editable path="TabContainer/SETTINGS_GRAPHICS/VBoxContainer/ScrollContainer/MarginContainer/SettingsList/AnisotropicLevel"]