add ant info popup animations
This commit is contained in:
parent
b684fe56f3
commit
941eeb941d
@ -62,6 +62,7 @@ offset_top = 13.0
|
||||
offset_right = 321.0
|
||||
offset_bottom = 63.0
|
||||
pivot_offset = Vector2(40, 23)
|
||||
mouse_filter = 1
|
||||
texture_normal = ExtResource("4_b8264")
|
||||
texture_pressed = ExtResource("4_b8264")
|
||||
texture_hover = ExtResource("5_f3si0")
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
[gd_scene load_steps=14 format=3 uid="uid://c70rhvk2okkcu"]
|
||||
[gd_scene load_steps=15 format=3 uid="uid://c70rhvk2okkcu"]
|
||||
|
||||
[ext_resource type="StyleBox" uid="uid://do5c5v5kvgv0s" path="res://resources/styles/panel_small_style.tres" id="1_wcf51"]
|
||||
[ext_resource type="Script" path="res://scripts/ui/buy_ants.gd" id="2_sf7hb"]
|
||||
@ -7,6 +7,7 @@
|
||||
[ext_resource type="Texture2D" uid="uid://slraulfmk8c0" path="res://assets/textures/gui/pictograms.png" id="4_s7jbe"]
|
||||
[ext_resource type="Script" path="res://scripts/ui/components/honeydew_counter.gd" id="6_k6iup"]
|
||||
[ext_resource type="Script" path="res://scripts/ui/components/animated_texture_button.gd" id="6_msnw2"]
|
||||
[ext_resource type="Script" path="res://scripts/ui/components/show_on_hover.gd" id="8_p2yo4"]
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_t7i0n"]
|
||||
atlas = ExtResource("4_s7jbe")
|
||||
@ -44,9 +45,9 @@ script = ExtResource("2_sf7hb")
|
||||
[node name="Equals1" type="TextureRect" parent="."]
|
||||
layout_mode = 1
|
||||
offset_left = 110.0
|
||||
offset_top = 95.0
|
||||
offset_top = 105.0
|
||||
offset_right = 137.0
|
||||
offset_bottom = 120.0
|
||||
offset_bottom = 130.0
|
||||
texture = SubResource("AtlasTexture_t7i0n")
|
||||
|
||||
[node name="Equals2" type="TextureRect" parent="."]
|
||||
@ -65,6 +66,7 @@ offset_top = 16.0
|
||||
offset_right = 112.0
|
||||
offset_bottom = 72.0
|
||||
pivot_offset = Vector2(49, 27)
|
||||
mouse_filter = 1
|
||||
texture_normal = ExtResource("2_shpjn")
|
||||
texture_pressed = ExtResource("2_shpjn")
|
||||
texture_hover = ExtResource("3_bwnfl")
|
||||
@ -100,10 +102,11 @@ script = ExtResource("6_k6iup")
|
||||
self_modulate = Color(0.827451, 0.717647, 0.564706, 1)
|
||||
layout_mode = 0
|
||||
offset_left = 15.0
|
||||
offset_top = 77.0
|
||||
offset_top = 87.0
|
||||
offset_right = 114.0
|
||||
offset_bottom = 133.0
|
||||
pivot_offset = Vector2(47, 26)
|
||||
offset_bottom = 143.0
|
||||
pivot_offset = Vector2(47, 28)
|
||||
mouse_filter = 1
|
||||
texture_normal = ExtResource("2_shpjn")
|
||||
texture_pressed = ExtResource("2_shpjn")
|
||||
texture_hover = ExtResource("3_bwnfl")
|
||||
@ -129,9 +132,9 @@ texture = SubResource("AtlasTexture_eg31t")
|
||||
[node name="GathererPriceCounter" type="ReferenceRect" parent="."]
|
||||
layout_mode = 0
|
||||
offset_left = 135.0
|
||||
offset_top = 87.0
|
||||
offset_top = 97.0
|
||||
offset_right = 219.0
|
||||
offset_bottom = 131.0
|
||||
offset_bottom = 141.0
|
||||
mouse_filter = 2
|
||||
script = ExtResource("6_k6iup")
|
||||
|
||||
@ -144,13 +147,16 @@ offset_bottom = 183.0
|
||||
mouse_filter = 2
|
||||
script = ExtResource("6_k6iup")
|
||||
|
||||
[node name="NitwitPanel" type="Panel" parent="."]
|
||||
[node name="NitwitPanel" type="Panel" parent="." node_paths=PackedStringArray("hovered_control")]
|
||||
layout_mode = 0
|
||||
offset_left = 249.0
|
||||
offset_top = -11.0
|
||||
offset_right = 506.0
|
||||
offset_bottom = 124.0
|
||||
pivot_offset = Vector2(-13, 61)
|
||||
theme_override_styles/panel = ExtResource("1_wcf51")
|
||||
script = ExtResource("8_p2yo4")
|
||||
hovered_control = NodePath("../BuyNitwitButton")
|
||||
|
||||
[node name="InfoTexture" type="TextureRect" parent="NitwitPanel"]
|
||||
layout_mode = 1
|
||||
@ -182,13 +188,16 @@ grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
texture = SubResource("AtlasTexture_gdhp3")
|
||||
|
||||
[node name="GathererPanel" type="Panel" parent="."]
|
||||
[node name="GathererPanel" type="Panel" parent="." node_paths=PackedStringArray("hovered_control")]
|
||||
layout_mode = 0
|
||||
offset_left = 262.0
|
||||
offset_top = 43.0
|
||||
offset_right = 458.0
|
||||
offset_bottom = 174.0
|
||||
pivot_offset = Vector2(-23, 70)
|
||||
theme_override_styles/panel = ExtResource("1_wcf51")
|
||||
script = ExtResource("8_p2yo4")
|
||||
hovered_control = NodePath("../BuyGathererButton")
|
||||
|
||||
[node name="InfoTexture" type="TextureRect" parent="GathererPanel"]
|
||||
layout_mode = 1
|
||||
|
||||
@ -61,6 +61,7 @@ offset_top = 24.0
|
||||
offset_right = 117.0
|
||||
offset_bottom = 97.0
|
||||
pivot_offset = Vector2(39, 37.5)
|
||||
mouse_filter = 1
|
||||
texture_normal = ExtResource("2_e7opb")
|
||||
texture_pressed = ExtResource("2_e7opb")
|
||||
texture_hover = ExtResource("3_fx7y7")
|
||||
@ -91,6 +92,7 @@ offset_top = -25.0
|
||||
offset_right = 182.0
|
||||
offset_bottom = 35.0
|
||||
pivot_offset = Vector2(33, 30.5)
|
||||
mouse_filter = 1
|
||||
texture_normal = ExtResource("2_e7opb")
|
||||
texture_pressed = ExtResource("2_e7opb")
|
||||
texture_hover = ExtResource("3_fx7y7")
|
||||
|
||||
@ -41,7 +41,7 @@ func open(at: Anthill) -> void:
|
||||
_anthill = at
|
||||
set_target(_anthill.ui_origin)
|
||||
counter.initialize(_anthill.honeydew, _anthill.max_honeydew)
|
||||
_open_animation()
|
||||
_open_animation(self)
|
||||
|
||||
|
||||
func close() -> void:
|
||||
|
||||
@ -1,17 +1,15 @@
|
||||
extends FollowingUI
|
||||
class_name BuyAnts
|
||||
|
||||
const COUNTER_SIZE:float = 32
|
||||
const COUNTER_SIZE: float = 32
|
||||
|
||||
var _anthill: Anthill
|
||||
|
||||
@onready var buy_nitwit_button: BaseButton = $BuyNitwitButton
|
||||
@onready var nitwit_price_counter: HoneydewCounter = $NitwitPriceCounter
|
||||
@onready var nitwit_info: Control = $NitwitPanel
|
||||
|
||||
@onready var buy_gatherer_button: BaseButton = $BuyGathererButton
|
||||
@onready var gatherer_price_counter: HoneydewCounter = $GathererPriceCounter
|
||||
@onready var gatherer_info: Control = $GathererPanel
|
||||
|
||||
@onready var counter: HoneydewCounter = $HoneydewCounter
|
||||
|
||||
@ -19,16 +17,12 @@ var _anthill: Anthill
|
||||
func _ready() -> void:
|
||||
assert(buy_nitwit_button != null, "buy_nitwit_button missing!")
|
||||
assert(nitwit_price_counter != null, "nitwit_price_counter missing!")
|
||||
assert(nitwit_info != null, "nitwit_info missing!")
|
||||
assert(buy_gatherer_button != null, "buy_gatherer_button missing!")
|
||||
assert(gatherer_price_counter != null, "gatherer_price_counter missing!")
|
||||
assert(gatherer_info != null, "gatherer_info missing!")
|
||||
assert(counter != null, "counter missing!")
|
||||
super._ready()
|
||||
buy_nitwit_button.pressed.connect(_on_buy_nitwit_button_pressed)
|
||||
nitwit_info.visible = false
|
||||
buy_gatherer_button.pressed.connect(_on_buy_gatherer_button_pressed)
|
||||
gatherer_info.visible = false
|
||||
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
@ -36,16 +30,14 @@ func _process(delta: float) -> void:
|
||||
if _anthill == null or not visible:
|
||||
return
|
||||
counter.update_counter(_anthill.honeydew)
|
||||
nitwit_info.visible = buy_nitwit_button.is_hovered()
|
||||
gatherer_info.visible = buy_gatherer_button.is_hovered()
|
||||
|
||||
|
||||
func open(at: Anthill) -> void:
|
||||
visible = true
|
||||
_anthill = at
|
||||
nitwit_price_counter.initialize(
|
||||
AntNitwit.get_cost(),
|
||||
AntNitwit.get_cost(),
|
||||
AntNitwit.get_cost(),
|
||||
AntNitwit.get_cost(),
|
||||
COUNTER_SIZE,
|
||||
)
|
||||
gatherer_price_counter.initialize(
|
||||
@ -55,15 +47,17 @@ func open(at: Anthill) -> void:
|
||||
)
|
||||
set_target(_anthill.ui_origin)
|
||||
counter.initialize(_anthill.honeydew, _anthill.max_honeydew)
|
||||
_open_animation()
|
||||
_open_animation(self)
|
||||
|
||||
|
||||
func close() -> void:
|
||||
super.close()
|
||||
_anthill = null
|
||||
|
||||
|
||||
func _on_buy_nitwit_button_pressed() -> void:
|
||||
_anthill.spawn_nitwit()
|
||||
|
||||
|
||||
func _on_buy_gatherer_button_pressed() -> void:
|
||||
_anthill.spawn_gatherer()
|
||||
|
||||
@ -32,39 +32,47 @@ func _input(event: InputEvent) -> void:
|
||||
|
||||
|
||||
func close() -> void:
|
||||
await _close_animation()
|
||||
await _close_animation(self)
|
||||
visible = false
|
||||
|
||||
|
||||
func _open_animation() -> void:
|
||||
func _open_animation(control: Control) -> void:
|
||||
await _animate(
|
||||
control,
|
||||
Vector2.ZERO,
|
||||
Vector2.ONE,
|
||||
OPEN_TWEEN_DURATION,
|
||||
Tween.EASE_OUT,
|
||||
Tween.TRANS_ELASTIC,
|
||||
)
|
||||
|
||||
func _close_animation() -> void:
|
||||
|
||||
func _close_animation(control: Control) -> void:
|
||||
await _animate(
|
||||
control,
|
||||
Vector2.ONE,
|
||||
Vector2.ZERO,
|
||||
CLOSE_TWEEN_DURATION,
|
||||
Tween.EASE_IN,
|
||||
Tween.TRANS_BACK,
|
||||
)
|
||||
|
||||
|
||||
func _animate(
|
||||
control: Control,
|
||||
from_scale: Vector2,
|
||||
to_scale: Vector2,
|
||||
duration: float,
|
||||
ease_type: Tween.EaseType,
|
||||
trans_type: Tween.TransitionType,
|
||||
) -> void:
|
||||
if _tween:
|
||||
_tween.stop()
|
||||
scale = Vector2.ONE
|
||||
_tween.kill()
|
||||
control.scale = from_scale
|
||||
_tween = create_tween()
|
||||
await (
|
||||
_tween
|
||||
.tween_property(self, "scale", to_scale, duration)
|
||||
.tween_property(control, "scale", to_scale, duration)
|
||||
.set_ease(ease_type)
|
||||
.set_trans(trans_type)
|
||||
.finished
|
||||
|
||||
@ -35,7 +35,7 @@ func _hover_off_animation() -> void:
|
||||
|
||||
func _animate(to_scale: Vector2) -> void:
|
||||
if _tween:
|
||||
_tween.stop()
|
||||
_tween.kill()
|
||||
_tween = create_tween()
|
||||
await (
|
||||
_tween
|
||||
|
||||
63
scripts/ui/components/show_on_hover.gd
Normal file
63
scripts/ui/components/show_on_hover.gd
Normal file
@ -0,0 +1,63 @@
|
||||
extends Control
|
||||
class_name ShowOnHover
|
||||
|
||||
const OPEN_TWEEN_DURATION: float = 0.5
|
||||
const CLOSE_TWEEN_DURATION: float = 0.25
|
||||
|
||||
@export var hovered_control: Control
|
||||
|
||||
var _tween: Tween
|
||||
|
||||
func _ready() -> void:
|
||||
assert(hovered_control != null, "hovered_control missing!")
|
||||
scale = Vector2.ZERO
|
||||
hovered_control.mouse_entered.connect(_on_mouse_entered)
|
||||
hovered_control.mouse_exited.connect(_on_mouse_exited)
|
||||
|
||||
|
||||
func _open_animation() -> void:
|
||||
await _animate(
|
||||
Vector2.ZERO,
|
||||
Vector2.ONE,
|
||||
OPEN_TWEEN_DURATION,
|
||||
Tween.EASE_OUT,
|
||||
Tween.TRANS_ELASTIC,
|
||||
)
|
||||
|
||||
|
||||
func _close_animation() -> void:
|
||||
await _animate(
|
||||
Vector2.ONE,
|
||||
Vector2.ZERO,
|
||||
CLOSE_TWEEN_DURATION,
|
||||
Tween.EASE_IN,
|
||||
Tween.TRANS_BACK,
|
||||
)
|
||||
|
||||
|
||||
func _animate(
|
||||
from_scale: Vector2,
|
||||
to_scale: Vector2,
|
||||
duration: float,
|
||||
ease_type: Tween.EaseType,
|
||||
trans_type: Tween.TransitionType,
|
||||
) -> void:
|
||||
if _tween:
|
||||
_tween.kill()
|
||||
scale = from_scale
|
||||
_tween = create_tween()
|
||||
await (
|
||||
_tween
|
||||
.tween_property(self, "scale", to_scale, duration)
|
||||
.set_ease(ease_type)
|
||||
.set_trans(trans_type)
|
||||
.finished
|
||||
)
|
||||
|
||||
|
||||
func _on_mouse_entered() -> void:
|
||||
_open_animation()
|
||||
|
||||
|
||||
func _on_mouse_exited() -> void:
|
||||
_close_animation()
|
||||
@ -80,7 +80,7 @@ func _animate(
|
||||
trans_type: Tween.TransitionType,
|
||||
) -> void:
|
||||
if _tween:
|
||||
_tween.stop()
|
||||
_tween.kill()
|
||||
panel.scale = panel_scale_init
|
||||
controls_info.position = controls_info_pos_init
|
||||
_tween = create_tween()
|
||||
|
||||
@ -45,7 +45,7 @@ func open(who: Unit) -> void:
|
||||
visible = true
|
||||
unit = who
|
||||
set_target(unit.ui_origin)
|
||||
_open_animation()
|
||||
_open_animation(self)
|
||||
|
||||
|
||||
func close() -> void:
|
||||
|
||||
Loading…
Reference in New Issue
Block a user