mirror of
https://github.com/Orama-Interactive/Pixelorama.git
synced 2025-01-18 09:09:47 +00:00
Change the layouts array in TopMenuContainer to only contain DockableLayouts instead of being an array of arrays
This commit is contained in:
parent
606ce965f6
commit
ed072de84e
|
@ -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))
|
||||
|
|
Loading…
Reference in a new issue