From 35dc2ee1b9a0a609ea5fd02fcc4f03e2031a78bb Mon Sep 17 00:00:00 2001 From: Cold-Mint Date: Wed, 9 Oct 2024 17:36:59 +0800 Subject: [PATCH] =?UTF-8?q?Make=20the=20barrier=20stop=20pickables.=20?= =?UTF-8?q?=E4=BD=BF=E5=B1=8F=E9=9A=9C=E5=8F=AF=E9=98=BB=E6=AD=A2=E5=8F=AF?= =?UTF-8?q?=E6=8B=BE=E6=8D=A1=E7=89=A9=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- prefab/furnitures/SpellEditor.tscn | 7 ++++ .../roomTemplates/tutorials/spellEditor.tscn | 3 -- scripts/furniture/Furniture.cs | 39 ++++++++++++++++++- scripts/furniture/GuiFurniture.cs | 3 +- scripts/pickable/PickAbleTemplate.cs | 1 + 5 files changed, 48 insertions(+), 5 deletions(-) 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