53 lines
1.3 KiB
GDScript
53 lines
1.3 KiB
GDScript
extends HBoxContainer
|
|
onready var le_directory := $le_directory
|
|
onready var btn_browse := $btn_browse
|
|
onready var btn_remove := $btn_remove
|
|
|
|
signal path_updated
|
|
|
|
export var directory: String = "" setget set_directory, get_directory
|
|
func set_directory(value: String):
|
|
directory = value
|
|
if le_directory:
|
|
le_directory.text = directory
|
|
emit_signal('path_updated', value)
|
|
|
|
func get_directory():
|
|
return le_directory.text
|
|
|
|
export var removable: bool = true setget set_removable
|
|
func set_removable(value: bool):
|
|
removable = value
|
|
if btn_remove:
|
|
btn_remove.disabled = not removable
|
|
|
|
export var readonly: bool = false setget set_readonly
|
|
func set_readonly(value: bool):
|
|
readonly = value
|
|
if le_directory:
|
|
le_directory.editable = not readonly
|
|
if btn_browse:
|
|
btn_browse.disabled = readonly
|
|
|
|
func _ready():
|
|
le_directory.text = directory
|
|
le_directory.editable = not readonly
|
|
btn_browse.disabled = readonly
|
|
btn_remove.disabled = not removable
|
|
|
|
#func _process(delta):
|
|
# pass
|
|
|
|
|
|
func _on_btn_browse_pressed():
|
|
var dialog = FileDialog.new()
|
|
dialog.access = FileDialog.ACCESS_FILESYSTEM
|
|
dialog.mode = FileDialog.MODE_OPEN_DIR
|
|
dialog.connect("dir_selected", self, "set_directory")
|
|
add_child(dialog)
|
|
dialog.popup(Rect2(0, 0, 800, 600))
|
|
|
|
|
|
func _on_btn_remove_pressed():
|
|
set_directory("")
|