stepstead-client/scripts/toast.gd
jts 6a1706051d İlk commit: Stepstead Godot istemci (4.6 Mobile)
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-11 11:31:35 +03:00

45 lines
1.8 KiB
GDScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

extends CanvasLayer
## Ekranın altında geçici bildirim.
@onready var container: VBoxContainer = $Anchor/VBox
func _ready() -> void:
add_to_group("toast")
GameState.harvest_succeeded.connect(_on_harvest)
GameState.level_up.connect(_on_level_up)
GameState.item_used.connect(_on_item_used)
func _on_item_used(p: Dictionary) -> void:
show_toast("🍵 %s kullanıldı +%d adım" % [p.get("item_name", ""), int(p.get("effect_amount", 0))], Color(0.5, 0.85, 1.0))
func _on_harvest(p: Dictionary) -> void:
var skill_tr := {"mining": "Madencilik", "fishing": "Balıılık", "foraging": "Bitki Toplama",
"woodcutting": "Ağaç Kesme", "hunting": "Avcılık"}
var skill: String = str(skill_tr.get(p.get("skill", ""), str(p.get("skill", ""))))
show_toast("+1 %s +%d %s XP" % [p.get("item_name", ""), int(p.get("xp_gained", 0)), skill], Color(0.4, 0.8, 0.4))
func _on_level_up(kind: String, lvl: int) -> void:
if kind == "character":
show_toast("🎉 Karakter Level %d!" % lvl, Color(1.0, 0.85, 0.2))
else:
show_toast("⭐ Skill Level %d!" % lvl, Color(0.5, 0.85, 1.0))
func show_toast(text: String, color: Color = Color.WHITE, dur: float = 2.5) -> void:
var panel := PanelContainer.new()
var sb := StyleBoxFlat.new()
sb.bg_color = Color(0.1, 0.12, 0.15, 0.92)
sb.set_corner_radius_all(8)
sb.set_content_margin_all(12)
panel.add_theme_stylebox_override("panel", sb)
var label := Label.new()
label.text = text
label.add_theme_color_override("font_color", color)
label.add_theme_font_size_override("font_size", 16)
panel.add_child(label)
container.add_child(panel)
panel.modulate.a = 0.0
var tw := create_tween()
tw.tween_property(panel, "modulate:a", 1.0, 0.15)
tw.tween_interval(dur)
tw.tween_property(panel, "modulate:a", 0.0, 0.3)
tw.tween_callback(panel.queue_free)