From 5c28b4f61784ad8dc0d98521cf5ddd2e4a885454 Mon Sep 17 00:00:00 2001 From: Hugo Locurcio Date: Mon, 21 Oct 2019 15:54:15 +0200 Subject: [PATCH] Display a disabled item if no recent materials were found in Open Recent --- addons/material_maker/main_window.gd | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/addons/material_maker/main_window.gd b/addons/material_maker/main_window.gd index f5187b1..099cecf 100644 --- a/addons/material_maker/main_window.gd +++ b/addons/material_maker/main_window.gd @@ -123,10 +123,15 @@ func create_menu(menu, menu_name): func create_menu_load_recent(menu): menu.clear() - 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") + + if recent_files.empty(): + menu.add_item("No items found", 0) + 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): do_load_material(recent_files[id])