Reworked guidance
This commit is contained in:
@@ -3,27 +3,37 @@ class_name Guidance
|
||||
extends Node2D
|
||||
|
||||
|
||||
const SMALL_SIZE = Vector2(48, 48)
|
||||
const BIG_SIZE = Vector2(96, 48)
|
||||
|
||||
|
||||
enum Size {
|
||||
Small,
|
||||
Big,
|
||||
Custom,
|
||||
}
|
||||
|
||||
|
||||
@export var custom_size := SMALL_SIZE:
|
||||
set(value):
|
||||
custom_size = value
|
||||
if is_node_ready():
|
||||
_update_size()
|
||||
|
||||
@export var size := Size.Small:
|
||||
set(value):
|
||||
size = value
|
||||
if is_node_ready():
|
||||
_update_size()
|
||||
|
||||
@export var text := "":
|
||||
@export_multiline() var text := "":
|
||||
set(value):
|
||||
text = value
|
||||
if is_node_ready():
|
||||
_update_text()
|
||||
|
||||
|
||||
@onready var small_sprite : Sprite2D = $SmallSprite
|
||||
@onready var big_sprite : Sprite2D = $BigSprite
|
||||
@onready var rect : NinePatchRect = $NinePatchRect
|
||||
@onready var label : Label = $Label
|
||||
|
||||
|
||||
@@ -35,11 +45,13 @@ func _ready() -> void:
|
||||
func _update_size() -> void:
|
||||
match size:
|
||||
Size.Small:
|
||||
small_sprite.show()
|
||||
big_sprite.hide()
|
||||
rect.size = SMALL_SIZE
|
||||
Size.Big:
|
||||
small_sprite.hide()
|
||||
big_sprite.show()
|
||||
rect.size = BIG_SIZE
|
||||
Size.Custom:
|
||||
rect.size = custom_size
|
||||
rect.position = -rect.size/2
|
||||
|
||||
|
||||
func _update_text() -> void:
|
||||
label.text = text
|
||||
|
||||
@@ -4,23 +4,24 @@
|
||||
[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"]
|
||||
|
||||
[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]
|
||||
script = ExtResource("1_0gb2d")
|
||||
|
||||
[node name="SmallSprite" type="Sprite2D" parent="." unique_id=1649957299]
|
||||
texture = SubResource("AtlasTexture_0gb2d")
|
||||
|
||||
[node name="BigSprite" type="Sprite2D" parent="." unique_id=835120450]
|
||||
visible = false
|
||||
texture = SubResource("AtlasTexture_37fbl")
|
||||
[node name="NinePatchRect" type="NinePatchRect" parent="." unique_id=422652892]
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
offset_left = -24.0
|
||||
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]
|
||||
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
+44
-12
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user