2020-11-03 16:39:55 +01:00
|
|
|
class_name FileBrowserItem
|
2020-10-23 13:07:16 +02:00
|
|
|
extends Control
|
|
|
|
|
|
|
|
signal clicked(what)
|
|
|
|
|
2020-11-03 16:39:55 +01:00
|
|
|
enum IconStatus {NONE, NEW, REMOVED, CONFLICT, EDIT, UNTRACKED}
|
|
|
|
export(IconStatus) var status setget _set_status
|
2020-10-23 13:07:16 +02:00
|
|
|
export var label: String setget _set_label
|
2020-11-07 13:59:47 +01:00
|
|
|
var type = "file"
|
2020-10-23 13:07:16 +02:00
|
|
|
|
|
|
|
onready var label_node = $VBoxContainer/Label
|
2020-11-03 16:39:55 +01:00
|
|
|
onready var status_icon = $VBoxContainer/Control/TextureRect/StatusIcon
|
2020-10-23 13:07:16 +02:00
|
|
|
|
|
|
|
func _ready():
|
|
|
|
_set_label(label)
|
2020-11-03 16:39:55 +01:00
|
|
|
_set_status(status)
|
2020-10-23 13:07:16 +02:00
|
|
|
|
|
|
|
func _set_label(new_label):
|
|
|
|
label = new_label
|
|
|
|
if label_node:
|
|
|
|
label_node.text = helpers.abbreviate(new_label, 30)
|
|
|
|
|
|
|
|
func _gui_input(event):
|
|
|
|
if event is InputEventMouseButton and event.is_pressed() and event.button_index == BUTTON_LEFT:
|
|
|
|
emit_signal("clicked", self)
|
2020-11-03 16:39:55 +01:00
|
|
|
|
|
|
|
func _set_status(new_status):
|
|
|
|
if status_icon:
|
|
|
|
match new_status:
|
|
|
|
IconStatus.NEW:
|
|
|
|
status_icon.texture = preload("res://images/new.svg")
|
|
|
|
status_icon.modulate = Color("33BB33")
|
|
|
|
IconStatus.REMOVED:
|
|
|
|
status_icon.texture = preload("res://images/removed.svg")
|
|
|
|
status_icon.modulate = Color("D10F0F")
|
|
|
|
IconStatus.CONFLICT:
|
|
|
|
status_icon.texture = preload("res://images/conflict.svg")
|
|
|
|
status_icon.modulate = Color("DE5E09")
|
|
|
|
IconStatus.EDIT:
|
|
|
|
status_icon.texture = preload("res://images/modified.svg")
|
|
|
|
status_icon.modulate = Color("344DED")
|
|
|
|
IconStatus.UNTRACKED:
|
|
|
|
status_icon.texture = preload("res://images/untracked.svg")
|
|
|
|
status_icon.modulate = Color("9209B8")
|
|
|
|
IconStatus.NONE:
|
|
|
|
status_icon.texture = null
|
|
|
|
|
|
|
|
status = new_status
|
|
|
|
|