Merge pull request #44 from Calinou/open-recent-display-no-items-found

Display a disabled item if no recent materials were found in Open Recent
This commit is contained in:
Rodz Labs 2019-10-21 20:55:47 +02:00 committed by GitHub
commit 2d236a1735
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -123,10 +123,15 @@ func create_menu(menu, menu_name):
func create_menu_load_recent(menu): func create_menu_load_recent(menu):
menu.clear() menu.clear()
for i in recent_files.size():
menu.add_item(recent_files[i], i) if recent_files.empty():
if !menu.is_connected("id_pressed", self, "_on_LoadRecent_id_pressed"): menu.add_item("No items found", 0)
menu.connect("id_pressed", self, "_on_LoadRecent_id_pressed") menu.set_item_disabled(0, true)
else:
for i in recent_files.size():
menu.add_item(recent_files[i], i)
if !menu.is_connected("id_pressed", self, "_on_LoadRecent_id_pressed"):
menu.connect("id_pressed", self, "_on_LoadRecent_id_pressed")
func _on_LoadRecent_id_pressed(id): func _on_LoadRecent_id_pressed(id):
do_load_material(recent_files[id]) do_load_material(recent_files[id])