Resolutions Dropdown and Typo

This commit is contained in:
AXVIII3 2023-04-09 18:34:49 +05:30
parent 9d878116f0
commit ea9cb71f9a
5 changed files with 30 additions and 3 deletions

View file

@ -4,9 +4,8 @@
[ext_resource type="Theme" uid="uid://o3vg845para" path="res://Assets/Theme.tres" id="2_swcn6"]
[ext_resource type="Script" path="res://Scripts/RemapButton.gd" id="3_gktg3"]
[node name="SettingsMenu" type="Node" node_paths=PackedStringArray("button_to_focus_on_start", "display_options_button", "vsync_toggle", "resolutions_options_button", "master_volume_slider", "music_volume_slider", "sfx_volume_slider")]
[node name="SettingsMenu" type="Node" node_paths=PackedStringArray("display_options_button", "vsync_toggle", "resolutions_options_button", "master_volume_slider", "music_volume_slider", "sfx_volume_slider")]
script = ExtResource("1_2rgd2")
button_to_focus_on_start = NodePath("MainVBox/TabsContainer/SettingsTabs/Video/MarginContainer/VideoSettings/DisplayModeOptions")
display_options_button = NodePath("MainVBox/TabsContainer/SettingsTabs/Video/MarginContainer/VideoSettings/DisplayModeOptions")
vsync_toggle = NodePath("MainVBox/TabsContainer/SettingsTabs/Video/MarginContainer/VideoSettings/VsyncButton")
resolutions_options_button = NodePath("MainVBox/TabsContainer/SettingsTabs/Video/MarginContainer/VideoSettings/ResolutionsOptions")
@ -86,7 +85,7 @@ popup/item_2/text = "Maximized"
popup/item_2/id = 2
popup/item_3/text = "Minimized"
popup/item_3/id = 3
popup/item_4/text = "Sxclusive Full-Screen"
popup/item_4/text = "Exclusive Full-Screen"
popup/item_4/id = 4
[node name="VSync Label" type="Label" parent="MainVBox/TabsContainer/SettingsTabs/Video/MarginContainer/VideoSettings"]

View file

@ -13,6 +13,7 @@ func load_data():
game_data = {
"display_mode": 0,
"vsync_on": false,
"current_resolution_index": 0,
"master_volume": 0,
"music_volume": 0,
"sfx_volume": 0,

View file

@ -4,6 +4,18 @@ extends Node
@export var music_bus_index : int = 1
@export var sfx_bus_index : int = 2
const resolutions_dictionary : Dictionary = {
"800x600" : Vector2(800, 600),
"1024x546" : Vector2(1024, 546),
"1152x648" : Vector2(1152, 648),
"1600x900" : Vector2(1600, 900),
"1366x768" : Vector2(1366, 768),
"1920x1080" : Vector2(1920, 1080),
"1920x1200" : Vector2(1920, 1200),
"2560x1440" : Vector2(2560, 1440),
"3840x2160" : Vector2(3840, 2160),
}
# Video Global Settings
func set_display_mode(value: int) -> void:
Save.game_data.display_mode = value
@ -23,6 +35,12 @@ func toggle_vsync(value : bool) -> void:
else: DisplayServer.window_set_vsync_mode(DisplayServer.VSYNC_DISABLED)
pass
func set_resolution(index):
Save.game_data.current_resolution_index = index
Save.save_data()
for i in resolutions_dictionary.keys().size():
if i == index: DisplayServer.window_set_size(resolutions_dictionary.values()[i])
# Audio Global Settings
func update_master_volume(vol : int) -> void:
Save.game_data.master_volume = vol

View file

@ -8,6 +8,7 @@ extends Node
func _ready():
GlobalSettings.set_display_mode(Save.game_data.display_mode)
GlobalSettings.toggle_vsync(Save.game_data.vsync_on)
GlobalSettings.set_resolution(Save.game_data.current_resolution_index)
GlobalSettings.update_master_volume(Save.game_data.master_volume)
GlobalSettings.update_music_volume(Save.game_data.music_volume)
GlobalSettings.update_sfx_volume(Save.game_data.sfx_volume)

View file

@ -12,10 +12,13 @@ extends Node
# Engine Callbacks
func _ready():
add_resolution_items()
display_options_button.select(Save.game_data.display_mode)
GlobalSettings.set_display_mode(Save.game_data.display_mode)
vsync_toggle.set_pressed_no_signal(Save.game_data.vsync_on)
GlobalSettings.toggle_vsync(Save.game_data.vsync_on)
resolutions_options_button.select(Save.game_data.current_resolution_index)
GlobalSettings.set_resolution(Save.game_data.current_resolution_index)
master_volume_slider.value = Save.game_data.master_volume
GlobalSettings.update_master_volume(Save.game_data.master_volume)
music_volume_slider.value = Save.game_data.music_volume
@ -24,6 +27,10 @@ func _ready():
GlobalSettings.update_sfx_volume(Save.game_data.sfx_volume)
pass
func add_resolution_items():
for key in GlobalSettings.resolutions_dictionary.keys():
resolutions_options_button.add_item(key)
# Other Buttons
func _on_back_pressed():
queue_free()
@ -39,6 +46,7 @@ func _on_vsync_button_toggled(button_pressed):
pass
func _on_resolutions_options_item_selected(index):
GlobalSettings.set_resolution(index)
pass
# Audio Settings