Newer
Older
DungeonShooting / DungeonShooting_Godot / src / game / ui / mapEditorProject / RoomButtonCell.cs
@小李xl 小李xl on 23 Jul 2023 1 KB 完成搜索房间
  1. using Godot;
  2.  
  3. namespace UI.MapEditorProject;
  4.  
  5. public class RoomButtonCell : UiCell<MapEditorProject.RoomButton, DungeonRoomSplit>
  6. {
  7. private bool _focus = false;
  8.  
  9. public override void OnInit()
  10. {
  11. CellNode.Instance.Pressed += OnClick;
  12. CellNode.Instance.FocusExited += OnFocusExited;
  13. }
  14.  
  15. public override void OnSetData(DungeonRoomSplit data)
  16. {
  17. _focus = false;
  18. CellNode.L_RoomName.Instance.Text = data.RoomInfo.RoomName;
  19. CellNode.L_RoomType.Instance.Text = DungeonManager.DungeonRoomTypeToDescribeString(data.RoomInfo.RoomType);
  20. CellNode.Instance.TooltipText = "路径: " + data.RoomPath;
  21. CellNode.Instance.ReleaseFocus();
  22. }
  23.  
  24. public override void OnDestroy()
  25. {
  26. CellNode.Instance.Pressed -= OnClick;
  27. CellNode.Instance.FocusExited -= OnFocusExited;
  28. }
  29.  
  30. private void OnClick()
  31. {
  32. if (_focus)
  33. {
  34. //打开房间编辑器
  35. ((MapEditorProjectPanel)CellNode.UiPanel).SelectRoom(Data);
  36. CellNode.Instance.ReleaseFocus();
  37. }
  38. else
  39. {
  40. _focus = true;
  41. }
  42. }
  43. private void OnFocusExited()
  44. {
  45. _focus = false;
  46. }
  47. }