diff --git a/Scenes/GUI/MainMenu.tscn b/Scenes/GUI/MainMenu.tscn index 4676d63..03bc163 100644 --- a/Scenes/GUI/MainMenu.tscn +++ b/Scenes/GUI/MainMenu.tscn @@ -823,6 +823,20 @@ text = "Shadows:" horizontal_alignment = 2 vertical_alignment = 1 +[node name="VSyncLabel" type="Label" parent="SettingsScreen/DialogPanel/GraphicsPanel"] +layout_mode = 1 +anchors_preset = -1 +anchor_right = 0.5 +offset_left = 4.0 +offset_top = 164.0 +offset_right = -4.0 +offset_bottom = 196.0 +grow_horizontal = 2 +grow_vertical = 2 +text = "VSync:" +horizontal_alignment = 2 +vertical_alignment = 1 + [node name="AAOption" type="OptionButton" parent="SettingsScreen/DialogPanel/GraphicsPanel"] layout_mode = 1 anchors_preset = -1 @@ -931,6 +945,23 @@ popup/item_0/id = 0 popup/item_1/text = "Enabled" popup/item_1/id = 1 +[node name="VSyncOption" type="OptionButton" parent="SettingsScreen/DialogPanel/GraphicsPanel"] +layout_mode = 1 +anchors_preset = -1 +anchor_left = 0.5 +anchor_right = 1.0 +offset_left = 4.0 +offset_top = 164.0 +offset_right = -4.0 +offset_bottom = 196.0 +alignment = 1 +selected = 1 +item_count = 2 +popup/item_0/text = "Disabled" +popup/item_0/id = 0 +popup/item_1/text = "Enabled" +popup/item_1/id = 1 + [node name="InterfacePanel" type="Panel" parent="SettingsScreen/DialogPanel"] visible = false layout_mode = 1 @@ -1190,6 +1221,7 @@ parameters/looping = true [connection signal="item_selected" from="SettingsScreen/DialogPanel/GraphicsPanel/SSAAOption" to="SettingsScreen/DialogPanel/GraphicsPanel" method="_on_option_aa_ss_item_selected"] [connection signal="value_changed" from="SettingsScreen/DialogPanel/GraphicsPanel/FOVSlider" to="SettingsScreen/DialogPanel/GraphicsPanel" method="_on_fov_slider_value_changed"] [connection signal="item_selected" from="SettingsScreen/DialogPanel/GraphicsPanel/ShadowsOption" to="SettingsScreen/DialogPanel/GraphicsPanel" method="_on_shadows_option_item_selected"] +[connection signal="item_selected" from="SettingsScreen/DialogPanel/GraphicsPanel/VSyncOption" to="SettingsScreen/DialogPanel/GraphicsPanel" method="_on_v_sync_option_item_selected"] [connection signal="item_selected" from="SettingsScreen/DialogPanel/InterfacePanel/ScalingOption" to="SettingsScreen/DialogPanel/InterfacePanel" method="_on_scaling_option_item_selected"] [connection signal="item_selected" from="SettingsScreen/DialogPanel/InterfacePanel/ThemeOption" to="SettingsScreen/DialogPanel/InterfacePanel" method="_on_theme_option_item_selected"] [connection signal="item_selected" from="SettingsScreen/DialogPanel/InterfacePanel/MusicOption" to="SettingsScreen/DialogPanel/InterfacePanel" method="_on_music_option_item_selected"] diff --git a/Scripts/Configs/GlobalVariables.gd b/Scripts/Configs/GlobalVariables.gd index 48d1023..9c6f5cf 100644 --- a/Scripts/Configs/GlobalVariables.gd +++ b/Scripts/Configs/GlobalVariables.gd @@ -11,6 +11,7 @@ var shadows : int = 1 var title_music : int = 1 var title_dynamic : int = 1 var mouse_sens : float = 1.0 +var vsync: int = 1 var theme_index = [ "res://UI/Themes/Dark.tres", @@ -42,6 +43,7 @@ func updateConfig(): config.set_value("GRAPHICS", "msaa", msaa) config.set_value("GRAPHICS", "ssaa", ssaa) config.set_value("GRAPHICS", "shadows", shadows) + config.set_value("GRAPHICS", "vsync", vsync) config.set_value("INTERFACE", "scaling", scaling) config.set_value("INTERFACE", "theme", theme) config.set_value("INTERFACE", "title_music", title_music) @@ -56,15 +58,16 @@ func loadConfig(): print("Couldn't load config!") return - FOV = config.get_value("GRAPHICS", "fov") - msaa = config.get_value("GRAPHICS", "msaa") - ssaa = config.get_value("GRAPHICS", "ssaa") - shadows = config.get_value("GRAPHICS", "shadows") - scaling = config.get_value("INTERFACE", "scaling") - theme = config.get_value("INTERFACE", "theme") - title_music = config.get_value("INTERFACE", "title_music") - title_dynamic = config.get_value("INTERFACE", "title_dynamic") - mouse_sens = config.get_value("INPUT", "mouse_sens") + FOV = config.get_value("GRAPHICS", "fov", 80.0) + msaa = config.get_value("GRAPHICS", "msaa", 1) + ssaa = config.get_value("GRAPHICS", "ssaa", 1) + shadows = config.get_value("GRAPHICS", "shadows", 1) + vsync = config.get_value("GRAPHICS", "vsync", 1) + scaling = config.get_value("INTERFACE", "scaling", 0) + theme = config.get_value("INTERFACE", "theme", 0) + title_music = config.get_value("INTERFACE", "title_music", 1) + title_dynamic = config.get_value("INTERFACE", "title_dynamic", 1) + mouse_sens = config.get_value("INPUT", "mouse_sens", 1.0) print("config loaded.") diff --git a/Scripts/GraphicsOptions.gd b/Scripts/GraphicsOptions.gd index c78839d..7f8157c 100644 --- a/Scripts/GraphicsOptions.gd +++ b/Scripts/GraphicsOptions.gd @@ -8,6 +8,7 @@ func _ready() -> void: $ShadowsOption.select(GlobalVariables.shadows) $FOVSlider.value = GlobalVariables.FOV $FOVSlider/CurrentLabel.text = str(int(GlobalVariables.FOV)) + $VSyncOption.select(GlobalVariables.vsync) func _on_tab_bar_tab_changed(tab: int) -> void: if (thisTab == tab): @@ -39,3 +40,9 @@ func _on_shadows_option_item_selected(index: int) -> void: GlobalVariables.shadows = index get_tree().set_group("lights", "shadow_enabled", index == 1) GlobalVariables.updateConfig() + + +func _on_v_sync_option_item_selected(index: int) -> void: + GlobalVariables.vsync = index + DisplayServer.window_set_vsync_mode(index as DisplayServer.VSyncMode) + GlobalVariables.updateConfig() diff --git a/Scripts/MainMenu.gd b/Scripts/MainMenu.gd index ee3034f..2f80ca4 100644 --- a/Scripts/MainMenu.gd +++ b/Scripts/MainMenu.gd @@ -9,9 +9,6 @@ func _ready(): $Buttons/FreeRoamButton.grab_focus() GlobalVariables.loadConfig() - $SettingsScreen/DialogPanel/GraphicsPanel/FOVSlider.value = GlobalVariables.FOV - $SettingsScreen/DialogPanel/GraphicsPanel/AAOption.selected = GlobalVariables.msaa - $SettingsScreen/DialogPanel/GraphicsPanel/SSAAOption.selected = GlobalVariables.ssaa get_window().set_theme(load(GlobalVariables.theme_index[GlobalVariables.theme])) if (GlobalVariables.title_music == 1): $Music.play() @@ -19,6 +16,8 @@ func _ready(): $BackgroundImage.visible = false $DynamicBackground.visible = true + DisplayServer.window_set_vsync_mode(GlobalVariables.vsync as DisplayServer.VSyncMode) + get_tree().set_group("lights", "shadow_enabled", GlobalVariables.shadows == 1) var moddir = DirAccess.open("user://Mods")