add graphics settings save

This commit is contained in:
2026-06-14 19:01:40 +02:00
parent 74e69cbe81
commit 1d8346d294
4 changed files with 89 additions and 9 deletions

View File

@@ -6,6 +6,7 @@ signal resolution_changed(resolution: Vector2i)
@export var window_option_menu_button_scene: PackedScene
var current_mode_index: int = 0
var current_resolution: Vector2i = Vector2i.ZERO
var available_resolutions: Array[Vector2i] = [
Vector2i(1280, 720),
@@ -37,6 +38,11 @@ func _ready() -> void:
_populate_resolutions()
_update_ui()
func initialize(mode_index: int, res: Vector2i) -> void:
current_mode_index = mode_index
current_resolution = res
_update_ui()
func _populate_resolutions() -> void:
var screen_size = DisplayServer.screen_get_size()
@@ -63,6 +69,7 @@ func _on_resolution_selected(res: Vector2i, btn) -> void:
button.deselect()
btn.select()
current_resolution = res
resolution_changed.emit(res)
func _on_left_arrow_pressed() -> void:
@@ -95,7 +102,16 @@ func _update_ui() -> void:
else:
button.disable()
var btn = res_buttons[0]
btn.select()
if show_res:
resolution_changed.emit(available_resolutions[0])
if res_buttons.size() > 0:
var target_index = 0
for idx in range(_valid_resolutions.size()):
if _valid_resolutions[idx] == current_resolution:
target_index = idx
break
var btn = res_buttons[target_index]
btn.select()
current_resolution = _valid_resolutions[target_index]
if show_res:
resolution_changed.emit(current_resolution)