Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion material_maker/main_window.gd
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ const IDLE_FPS_LIMIT_MAX = 100
const RECENT_FILES_COUNT = 15

const MENU_QUICK_EXPORT : int = 1000
const RECENTS_MENU_CLEAR = 10000

const THEMES = ["Default Dark", "Default Light", "Classic"]

Expand Down Expand Up @@ -351,9 +352,15 @@ func create_menu_load_recent(menu) -> void:
for i in recent_files.size():
menu.add_item(recent_files[i], i)
menu.connect_id_pressed(self._on_LoadRecent_id_pressed)
menu.add_separator()
menu.add_item("Clear recent files", RECENTS_MENU_CLEAR)

func _on_LoadRecent_id_pressed(id) -> void:
do_load_project(recent_files[id])
match id:
RECENTS_MENU_CLEAR:
clear_recents()
_:
do_load_project(recent_files[id])

func load_recents() -> void:
var f : FileAccess = FileAccess.open("user://recent_files.bin", FileAccess.READ)
Expand All @@ -362,6 +369,10 @@ func load_recents() -> void:
test_json_conv.parse(f.get_as_text())
recent_files = test_json_conv.get_data()

func clear_recents() -> void:
recent_files.clear()
save_recents()

func save_recents() -> void:
var f : FileAccess = FileAccess.open("user://recent_files.bin", FileAccess.WRITE)
if f != null:
Expand Down