fix: resolve runtime errors and shadowed variable warnings
- use custom_minimum_size instead of minimum_size on Button (Godot 4.6 API) - reduce module_resized signal to 3 args to match _save_layout signature - rename testing_tile refresh param data -> _data (unused) - rename name -> layout_name in save_layout/switch_layout (shadows Node.name)
This commit is contained in:
parent
40ba0f3ee1
commit
12b45b2685
3 changed files with 15 additions and 15 deletions
|
|
@ -65,12 +65,12 @@ func remove_tile(tile_id: String) -> void:
|
||||||
|
|
||||||
|
|
||||||
## Save the current layout to config/layouts/{name}.cfg
|
## Save the current layout to config/layouts/{name}.cfg
|
||||||
func save_layout(name: String = "") -> void:
|
func save_layout(layout_name: String = "") -> void:
|
||||||
if name.is_empty():
|
if layout_name.is_empty():
|
||||||
name = current_layout_name
|
layout_name = current_layout_name
|
||||||
|
|
||||||
var cfg := ConfigFile.new()
|
var cfg := ConfigFile.new()
|
||||||
cfg.set_value("layout", "name", name)
|
cfg.set_value("layout", "name", layout_name)
|
||||||
cfg.set_value("layout", "saved_at", Time.get_datetime_string_from_system())
|
cfg.set_value("layout", "saved_at", Time.get_datetime_string_from_system())
|
||||||
|
|
||||||
var tile_ids: Array = _layout.keys()
|
var tile_ids: Array = _layout.keys()
|
||||||
|
|
@ -85,11 +85,11 @@ func save_layout(name: String = "") -> void:
|
||||||
cfg.set_value(section, "w", entry.get("w", 1))
|
cfg.set_value(section, "w", entry.get("w", 1))
|
||||||
cfg.set_value(section, "h", entry.get("h", 1))
|
cfg.set_value(section, "h", entry.get("h", 1))
|
||||||
|
|
||||||
var path := LAYOUT_DIR.path_join(name + ".cfg")
|
var path := LAYOUT_DIR.path_join(layout_name + ".cfg")
|
||||||
var result := cfg.save(path)
|
var result := cfg.save(path)
|
||||||
if result == OK:
|
if result == OK:
|
||||||
current_layout_name = name
|
current_layout_name = layout_name
|
||||||
layout_saved.emit(name)
|
layout_saved.emit(layout_name)
|
||||||
|
|
||||||
|
|
||||||
## Load a saved layout, replacing the current in-memory layout.
|
## Load a saved layout, replacing the current in-memory layout.
|
||||||
|
|
@ -141,9 +141,9 @@ func get_layout_names() -> PackedStringArray:
|
||||||
|
|
||||||
|
|
||||||
## Switch to a different layout: saves current, loads new, emits signal.
|
## Switch to a different layout: saves current, loads new, emits signal.
|
||||||
func switch_layout(name: String) -> void:
|
func switch_layout(layout_name: String) -> void:
|
||||||
if name == current_layout_name:
|
if layout_name == current_layout_name:
|
||||||
return
|
return
|
||||||
save_layout(current_layout_name)
|
save_layout(current_layout_name)
|
||||||
load_layout(name)
|
load_layout(layout_name)
|
||||||
set_current_layout(name)
|
set_current_layout(layout_name)
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ func initialize() -> void:
|
||||||
_style()
|
_style()
|
||||||
|
|
||||||
|
|
||||||
func refresh(data: Dictionary) -> void:
|
func refresh(_data: Dictionary) -> void:
|
||||||
_cycle = (_cycle + 1) % _levels.size()
|
_cycle = (_cycle + 1) % _levels.size()
|
||||||
var target: float = _levels[_cycle]
|
var target: float = _levels[_cycle]
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ class_name DashboardGrid
|
||||||
|
|
||||||
signal module_placed(module: Control, col: int, row: int)
|
signal module_placed(module: Control, col: int, row: int)
|
||||||
signal module_removed(module: Control)
|
signal module_removed(module: Control)
|
||||||
signal module_resized(module: Control, col: int, row: int, w: int, h: int)
|
signal module_resized(module: Control, col: int, row: int)
|
||||||
|
|
||||||
@export var cell_min_size: Vector2 = Vector2(300, 240)
|
@export var cell_min_size: Vector2 = Vector2(300, 240)
|
||||||
@export var cell_spacing: float = 8.0
|
@export var cell_spacing: float = 8.0
|
||||||
|
|
@ -196,7 +196,7 @@ func _make_menu_button(text: String, tooltip: String) -> Button:
|
||||||
btn.text = text
|
btn.text = text
|
||||||
btn.tooltip_text = tooltip
|
btn.tooltip_text = tooltip
|
||||||
btn.flat = true
|
btn.flat = true
|
||||||
btn.minimum_size = MENU_BUTTON_MIN_SIZE
|
btn.custom_minimum_size = MENU_BUTTON_MIN_SIZE
|
||||||
btn.add_theme_font_size_override("font_size", MENU_BUTTON_FONT_SIZE)
|
btn.add_theme_font_size_override("font_size", MENU_BUTTON_FONT_SIZE)
|
||||||
return btn
|
return btn
|
||||||
|
|
||||||
|
|
@ -614,7 +614,7 @@ func _end_resize(_mouse_pos: Vector2) -> void:
|
||||||
_set_module_grid_data(_resize_module, _resize_origin_col, _resize_origin_row, _resize_origin_w, _resize_origin_h)
|
_set_module_grid_data(_resize_module, _resize_origin_col, _resize_origin_row, _resize_origin_w, _resize_origin_h)
|
||||||
_occupy_cells(_resize_module, _resize_origin_col, _resize_origin_row, _resize_origin_w, _resize_origin_h)
|
_occupy_cells(_resize_module, _resize_origin_col, _resize_origin_row, _resize_origin_w, _resize_origin_h)
|
||||||
_layout_cells()
|
_layout_cells()
|
||||||
module_resized.emit(_resize_module, _resize_origin_col, _resize_origin_row, _resize_origin_w, _resize_origin_h)
|
module_resized.emit(_resize_module, _resize_origin_col, _resize_origin_row)
|
||||||
|
|
||||||
_is_resizing = false
|
_is_resizing = false
|
||||||
_resize_module = null
|
_resize_module = null
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue