diff --git a/prefab/furnitures/SpellEditor.tscn b/prefab/furnitures/SpellEditor.tscn index f2695c9..4c1d8d0 100644 --- a/prefab/furnitures/SpellEditor.tscn +++ b/prefab/furnitures/SpellEditor.tscn @@ -92,6 +92,7 @@ collision_layer = 256 collision_mask = 160 script = ExtResource("1_t1qdg") Path = "res://prefab/ui/SpellEditorUI.tscn" +_furnitureName = "ui_spell_editor" [node name="CollisionShape2D" type="CollisionShape2D" parent="."] position = Vector2(-0.5, -0.5) @@ -108,3 +109,9 @@ scale = Vector2(0.7, 0.7) sprite_frames = SubResource("SpriteFrames_mppe5") autoplay = "default" frame_progress = 0.717769 + +[node name="TipLabel" type="Label" parent="."] +offset_left = -17.0 +offset_top = 19.0 +offset_right = 23.0 +offset_bottom = 44.0 diff --git a/prefab/roomTemplates/tutorials/spellEditor.tscn b/prefab/roomTemplates/tutorials/spellEditor.tscn index 2a25ba3..3dacf61 100644 --- a/prefab/roomTemplates/tutorials/spellEditor.tscn +++ b/prefab/roomTemplates/tutorials/spellEditor.tscn @@ -103,9 +103,6 @@ position = Vector2(715, 200) [node name="WoodenBox3" parent="." instance=ExtResource("7_jybe6")] position = Vector2(715, 162) -[node name="WoodenBox4" parent="." instance=ExtResource("7_jybe6")] -position = Vector2(714, 122) - [node name="AutoSpawn" type="Node2D" parent="."] [node name="necromancy" type="Marker2D" parent="AutoSpawn"] diff --git a/scripts/furniture/Furniture.cs b/scripts/furniture/Furniture.cs index 8fc7f96..0fe552f 100644 --- a/scripts/furniture/Furniture.cs +++ b/scripts/furniture/Furniture.cs @@ -1,4 +1,5 @@ using ColdMint.scripts.damage; +using ColdMint.scripts.utils; using Godot; namespace ColdMint.scripts.furniture; @@ -11,6 +12,41 @@ public partial class Furniture : RigidBody2D { [Export] private int _initialDurability; [Export] private int _maxDurability; + [Export] + private string? _furnitureName; + + private Label? _tipLabel; + + public override void _MouseEnter() + { + if (_tipLabel == null || string.IsNullOrEmpty(_furnitureName)) + { + return; + } + var translation = TranslationServerUtils.Translate(_furnitureName); + if (string.IsNullOrEmpty(translation)) + { + return; + } + _tipLabel.Visible = true; + _tipLabel.Text = translation; + //Vertical Centering Tip + //垂直居中提示 + var oldPosition = _tipLabel.Position; + oldPosition.X = -_tipLabel.Size.X / 2; + _tipLabel.Rotation = -Rotation; + _tipLabel.Position = oldPosition; + } + + public override void _MouseExit() + { + if (_tipLabel == null) + { + return; + } + + _tipLabel.Visible = false; + } /// /// @@ -29,7 +65,8 @@ public partial class Furniture : RigidBody2D { _initialDurability = _maxDurability; } - + _tipLabel = GetNodeOrNull