diff --git a/assets/layouts/default.tres b/assets/layouts/Default.tres similarity index 100% rename from assets/layouts/default.tres rename to assets/layouts/Default.tres diff --git a/assets/layouts/tallscreen.tres b/assets/layouts/Tallscreen.tres similarity index 100% rename from assets/layouts/tallscreen.tres rename to assets/layouts/Tallscreen.tres diff --git a/src/UI/TopMenuContainer/TopMenuContainer.gd b/src/UI/TopMenuContainer/TopMenuContainer.gd index 7f2a4aff2..9856da33b 100644 --- a/src/UI/TopMenuContainer/TopMenuContainer.gd +++ b/src/UI/TopMenuContainer/TopMenuContainer.gd @@ -10,9 +10,9 @@ const PIXELORAMA_ICON := preload("res://assets/graphics/icons/icon_16x16.png") const HEART_ICON := preload("res://assets/graphics/misc/heart.svg") var recent_projects := [] -var layouts := [ - ["Default", preload("res://assets/layouts/default.tres")], - ["Tallscreen", preload("res://assets/layouts/tallscreen.tres")], +var layouts: Array[DockableLayout] = [ + preload("res://assets/layouts/Default.tres"), + preload("res://assets/layouts/Tallscreen.tres"), ] var default_layout_size := layouts.size() var selected_layout := 0 @@ -255,8 +255,9 @@ func _setup_layouts_submenu(item: String) -> void: var file_name = dir.get_next() while file_name != "": if !dir.current_is_dir(): - var file_name_no_tres: String = file_name.get_basename() - layouts.append([file_name_no_tres, ResourceLoader.load(path.path_join(file_name))]) + var layout := ResourceLoader.load(path.path_join(file_name)) + if layout is DockableLayout: + layouts.append(layout) file_name = dir.get_next() dir.list_dir_end() @@ -276,7 +277,8 @@ func populate_layouts_submenu() -> void: layouts_submenu.clear() # Does not do anything if it's called for the first time layouts_submenu.add_item("Manage Layouts", 0) for layout in layouts: - layouts_submenu.add_radio_check_item(layout[0]) + var layout_name := layout.resource_path.get_basename().get_file() + layouts_submenu.add_radio_check_item(layout_name) func _setup_image_menu() -> void: @@ -571,7 +573,7 @@ func set_layout(id: int) -> void: if id >= layouts.size(): id = 0 selected_layout = id - main_ui.layout = layouts[id][1].clone() # Clone is needed to avoid modifying premade layouts + main_ui.layout = layouts[id].clone() # Clone is needed to avoid modifying premade layouts for i in layouts.size(): var offset := i + 1 layouts_submenu.set_item_checked(offset, offset == (id + 1))