Update project configuration files and improve save menu functionality. Added editorconfig settings for various file types, enhanced .gitattributes for text and binary file handling, expanded .gitignore for build and local settings, and modified save_menu.gd to maintain focus on UI elements after refresh.
This commit is contained in:
+27
-5
@@ -72,11 +72,33 @@ func close() -> void:
|
||||
|
||||
# --- Список слотов ----------------------------------------------------------
|
||||
|
||||
func _refresh() -> void:
|
||||
## Перестраивает список. focus_row/focus_delete возвращают фокус на ту же
|
||||
## кнопку, что была нажата, — иначе после перерисовки он теряется.
|
||||
func _refresh(focus_row: int = -1, focus_delete: bool = false) -> void:
|
||||
for child in _slots_box.get_children():
|
||||
_slots_box.remove_child(child)
|
||||
child.queue_free()
|
||||
|
||||
var rows: Array[Node] = []
|
||||
for info: Dictionary in _saves.list_slots():
|
||||
_slots_box.add_child(_make_row(info))
|
||||
var row := _make_row(info)
|
||||
_slots_box.add_child(row)
|
||||
rows.append(row)
|
||||
|
||||
if focus_row >= 0 and focus_row < rows.size():
|
||||
_focus_row_button(rows[focus_row], focus_delete)
|
||||
|
||||
|
||||
func _focus_row_button(row: Node, delete: bool) -> void:
|
||||
var buttons: Array[Button] = []
|
||||
for child: Node in row.get_child(0).get_children():
|
||||
if child is Button:
|
||||
buttons.append(child as Button)
|
||||
if buttons.is_empty():
|
||||
return
|
||||
var target := buttons[1] if delete and buttons.size() > 1 else buttons[0]
|
||||
if not target.disabled:
|
||||
target.grab_focus()
|
||||
|
||||
|
||||
func _make_row(info: Dictionary) -> PanelContainer:
|
||||
@@ -196,7 +218,7 @@ func _on_action_pressed(index: int) -> void:
|
||||
_status.text = "Сохранено в слот %d." % (index + 1)
|
||||
else:
|
||||
_status.text = "Не удалось сохранить в слот %d." % (index + 1)
|
||||
_refresh()
|
||||
_refresh(index)
|
||||
|
||||
|
||||
func _on_delete_pressed(index: int) -> void:
|
||||
@@ -207,13 +229,13 @@ func _on_delete_pressed(index: int) -> void:
|
||||
_pending = {}
|
||||
_saves.delete_slot(index)
|
||||
_status.text = "Слот %d удалён." % (index + 1)
|
||||
_refresh()
|
||||
_refresh(index)
|
||||
|
||||
|
||||
func _set_pending(action: String, index: int, message: String) -> void:
|
||||
_pending = {"action": action, "index": index}
|
||||
_status.text = message
|
||||
_refresh()
|
||||
_refresh(index, action == "delete")
|
||||
|
||||
|
||||
func _is_pending(action: String, index: int) -> bool:
|
||||
|
||||
Reference in New Issue
Block a user