diff options
author | Daniel Weipert <git@mail.dweipert.de> | 2025-04-02 17:31:58 +0200 |
---|---|---|
committer | Daniel Weipert <git@mail.dweipert.de> | 2025-04-02 17:31:58 +0200 |
commit | 2ffba3f35af0af2902278d062028a5f83e7fbc53 (patch) | |
tree | f108b7176ba63daa7101de43801a39db5ed3f5a0 /ui/dice_configurator/dice_configuration_face_preview.gd | |
parent | 65bfe9c4c3e09c0d9f5058dd899a82c6a47ec15d (diff) |
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() |