1
0
Fork 0
mirror of https://github.com/Orama-Interactive/Pixelorama.git synced 2025-01-18 17:19:50 +00:00

Change the layouts array in TopMenuContainer to only contain DockableLayouts instead of being an array of arrays

This commit is contained in:
Emmanouil Papadeas 2024-02-01 22:10:18 +02:00
parent 606ce965f6
commit ed072de84e
3 changed files with 9 additions and 7 deletions

View file

@ -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") const HEART_ICON := preload("res://assets/graphics/misc/heart.svg")
var recent_projects := [] var recent_projects := []
var layouts := [ var layouts: Array[DockableLayout] = [
["Default", preload("res://assets/layouts/default.tres")], preload("res://assets/layouts/Default.tres"),
["Tallscreen", preload("res://assets/layouts/tallscreen.tres")], preload("res://assets/layouts/Tallscreen.tres"),
] ]
var default_layout_size := layouts.size() var default_layout_size := layouts.size()
var selected_layout := 0 var selected_layout := 0
@ -255,8 +255,9 @@ func _setup_layouts_submenu(item: String) -> void:
var file_name = dir.get_next() var file_name = dir.get_next()
while file_name != "": while file_name != "":
if !dir.current_is_dir(): if !dir.current_is_dir():
var file_name_no_tres: String = file_name.get_basename() var layout := ResourceLoader.load(path.path_join(file_name))
layouts.append([file_name_no_tres, ResourceLoader.load(path.path_join(file_name))]) if layout is DockableLayout:
layouts.append(layout)
file_name = dir.get_next() file_name = dir.get_next()
dir.list_dir_end() 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.clear() # Does not do anything if it's called for the first time
layouts_submenu.add_item("Manage Layouts", 0) layouts_submenu.add_item("Manage Layouts", 0)
for layout in layouts: 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: func _setup_image_menu() -> void:
@ -571,7 +573,7 @@ func set_layout(id: int) -> void:
if id >= layouts.size(): if id >= layouts.size():
id = 0 id = 0
selected_layout = id 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(): for i in layouts.size():
var offset := i + 1 var offset := i + 1
layouts_submenu.set_item_checked(offset, offset == (id + 1)) layouts_submenu.set_item_checked(offset, offset == (id + 1))