Files
GGJ26/addons/resources_spreadsheet_view/main_screen/recent_paths.gd
minimata 158e18f1fe
All checks were successful
Create tag and build when new code gets to main / BumpTag (push) Successful in 8s
Create tag and build when new code gets to main / Export (push) Successful in 1m13s
Added resource table plugin
2026-01-31 10:23:20 +01:00

55 lines
1.1 KiB
GDScript

@tool
extends OptionButton
@onready var editor_view := $"../../../../.."
var recent_paths := []
func _ready():
item_selected.connect(_on_item_selected)
func load_paths(paths):
clear()
for x in paths:
add_path_to_recent(x, true)
selected = recent_paths.size() - 1
func add_path_to_recent(path : String, is_loading : bool = false):
if path in recent_paths: return
var idx_in_array := recent_paths.find(path)
if idx_in_array != -1:
remove_item(idx_in_array)
recent_paths.remove_at(idx_in_array)
recent_paths.append(path)
add_item(path)
select(get_item_count() - 1)
if !is_loading:
editor_view.save_data()
func remove_selected_path_from_recent():
if get_item_count() == 0:
return
var idx_in_array := selected
recent_paths.remove_at(idx_in_array)
remove_item(idx_in_array)
if get_item_count() != 0:
select(0)
editor_view.display_folder(recent_paths[0])
editor_view.save_data()
func _on_item_selected(index : int):
editor_view.current_path = recent_paths[index]
editor_view.node_folder_path.text = recent_paths[index]
editor_view.refresh()