diff options
Diffstat (limited to 'ui/dice_configurator/dice_configuration_face_preview.gd')
-rw-r--r-- | ui/dice_configurator/dice_configuration_face_preview.gd | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/ui/dice_configurator/dice_configuration_face_preview.gd b/ui/dice_configurator/dice_configuration_face_preview.gd new file mode 100644 index 0000000..525134c --- /dev/null +++ b/ui/dice_configurator/dice_configuration_face_preview.gd @@ -0,0 +1,55 @@ +@tool +extends Control + + +@export var face: Game.Face: set = set_face +@export var type: Game.FaceType: set = set_type +@export var value: int: set = set_value +@export var active: bool = false: set = set_active + + +func _ready() -> void: + set_face(face) + set_type(type) + set_value(value) + set_active(active) + + +func set_face(v: Game.Face) -> void: + face = v + + if face == Game.Face.FRONT: + %Face.texture = load("res://ui/assets/dice_configuration_face_preview_front.png") + elif face == Game.Face.BACK: + %Face.texture = load("res://ui/assets/dice_configuration_face_preview_back.png") + elif face == Game.Face.LEFT: + %Face.texture = load("res://ui/assets/dice_configuration_face_preview_left.png") + elif face == Game.Face.RIGHT: + %Face.texture = load("res://ui/assets/dice_configuration_face_preview_right.png") + elif face == Game.Face.TOP: + %Face.texture = load("res://ui/assets/dice_configuration_face_preview_top.png") + elif face == Game.Face.BOTTOM: + %Face.texture = load("res://ui/assets/dice_configuration_face_preview_bottom.png") + + +func set_type(v: Game.FaceType) -> void: + type = v + %Type.texture_normal = DiceFace.get_face_type_icon(type) + + +func set_value(v: int) -> void: + value = v + if has_node("%Value"): + %Value.text = str(value) + + +func set_active(v: bool) -> void: + active = v + if active: + %Face.self_modulate = Color.hex(0xafff00ff) + else: + %Face.self_modulate = Color.hex(0x00fec164) + + +func _on_child_focus_entered() -> void: + focus_entered.emit() |