Reworked guidance

This commit is contained in:
2026-07-03 15:36:13 +03:00
parent c86437353e
commit 599710c345
7 changed files with 81 additions and 45 deletions
+19 -7
View File
@@ -3,27 +3,37 @@ class_name Guidance
extends Node2D extends Node2D
const SMALL_SIZE = Vector2(48, 48)
const BIG_SIZE = Vector2(96, 48)
enum Size { enum Size {
Small, Small,
Big, Big,
Custom,
} }
@export var custom_size := SMALL_SIZE:
set(value):
custom_size = value
if is_node_ready():
_update_size()
@export var size := Size.Small: @export var size := Size.Small:
set(value): set(value):
size = value size = value
if is_node_ready(): if is_node_ready():
_update_size() _update_size()
@export var text := "": @export_multiline() var text := "":
set(value): set(value):
text = value text = value
if is_node_ready(): if is_node_ready():
_update_text() _update_text()
@onready var small_sprite : Sprite2D = $SmallSprite @onready var rect : NinePatchRect = $NinePatchRect
@onready var big_sprite : Sprite2D = $BigSprite
@onready var label : Label = $Label @onready var label : Label = $Label
@@ -35,11 +45,13 @@ func _ready() -> void:
func _update_size() -> void: func _update_size() -> void:
match size: match size:
Size.Small: Size.Small:
small_sprite.show() rect.size = SMALL_SIZE
big_sprite.hide()
Size.Big: Size.Big:
small_sprite.hide() rect.size = BIG_SIZE
big_sprite.show() Size.Custom:
rect.size = custom_size
rect.position = -rect.size/2
func _update_text() -> void: func _update_text() -> void:
label.text = text label.text = text
+15 -14
View File
@@ -4,23 +4,24 @@
[ext_resource type="Texture2D" uid="uid://dc3j8hs0ld4cg" path="res://images/entities/guidance.png" id="2_37fbl"] [ext_resource type="Texture2D" uid="uid://dc3j8hs0ld4cg" path="res://images/entities/guidance.png" id="2_37fbl"]
[ext_resource type="Theme" uid="uid://bqj884yfvhhft" path="res://game/themes/main_menu.tres" id="3_1vdxa"] [ext_resource type="Theme" uid="uid://bqj884yfvhhft" path="res://game/themes/main_menu.tres" id="3_1vdxa"]
[sub_resource type="AtlasTexture" id="AtlasTexture_0gb2d"]
atlas = ExtResource("2_37fbl")
region = Rect2(0, 0, 48, 48)
[sub_resource type="AtlasTexture" id="AtlasTexture_37fbl"]
atlas = ExtResource("2_37fbl")
region = Rect2(48, 0, 96, 48)
[node name="Guidance" type="Node2D" unique_id=1797017316] [node name="Guidance" type="Node2D" unique_id=1797017316]
script = ExtResource("1_0gb2d") script = ExtResource("1_0gb2d")
[node name="SmallSprite" type="Sprite2D" parent="." unique_id=1649957299] [node name="NinePatchRect" type="NinePatchRect" parent="." unique_id=422652892]
texture = SubResource("AtlasTexture_0gb2d") anchors_preset = 15
anchor_right = 1.0
[node name="BigSprite" type="Sprite2D" parent="." unique_id=835120450] anchor_bottom = 1.0
visible = false offset_left = -24.0
texture = SubResource("AtlasTexture_37fbl") offset_top = -24.0
offset_right = 24.0
offset_bottom = 24.0
grow_horizontal = 2
grow_vertical = 2
texture = ExtResource("2_37fbl")
patch_margin_left = 9
patch_margin_top = 9
patch_margin_right = 9
patch_margin_bottom = 9
[node name="Label" type="Label" parent="." unique_id=1747099762] [node name="Label" type="Label" parent="." unique_id=1747099762]
anchors_preset = 15 anchors_preset = 15
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Binary file not shown.