Newer
Older
DungeonShooting / DungeonShooting_Godot / src / game / ui / mapEditorProject / RoomButtonCell.cs
  1. using Godot;
  2.  
  3. namespace UI.MapEditorProject;
  4.  
  5. public class RoomButtonCell : UiCell<MapEditorProject.RoomButton, DungeonRoomSplit>
  6. {
  7. public override void OnInit()
  8. {
  9. CellNode.L_SelectTexture.Instance.Visible = false;
  10. }
  11. public override void OnSetData(DungeonRoomSplit data)
  12. {
  13. CellNode.L_RoomName.Instance.Text = data.RoomInfo.RoomName;
  14. CellNode.L_RoomType.Instance.Text = DungeonManager.DungeonRoomTypeToDescribeString(data.RoomInfo.RoomType);
  15. //预览图
  16. CellNode.L_PreviewImage.Instance.Texture = data.PreviewImage;
  17. //提示
  18. var tipText = "权重: " + data.RoomInfo.Weight;
  19. //错误消息
  20. if (data.ErrorType == RoomErrorType.None)
  21. {
  22. CellNode.L_ErrorTexture.Instance.Visible = false;
  23. }
  24. else
  25. {
  26. CellNode.L_ErrorTexture.Instance.Visible = true;
  27. tipText += "\n错误: " + EditorManager.GetRoomErrorTypeMessage(data.ErrorType);
  28. }
  29. if (!string.IsNullOrEmpty(data.RoomInfo.Remark))
  30. {
  31. tipText += "\n备注: " + data.RoomInfo.Remark;
  32. }
  33. CellNode.Instance.TooltipText = tipText;
  34. }
  35.  
  36. public override void OnDisable()
  37. {
  38. CellNode.L_PreviewImage.Instance.Texture = null;
  39. }
  40.  
  41. public override void OnDoubleClick()
  42. {
  43. //打开房间编辑器
  44. CellNode.UiPanel.OpenSelectRoom(Data);
  45. }
  46. public override void OnSelect()
  47. {
  48. EditorManager.SetSelectRoom(Data);
  49. CellNode.L_SelectTexture.Instance.Visible = true;
  50. }
  51.  
  52. public override void OnUnSelect()
  53. {
  54. CellNode.L_SelectTexture.Instance.Visible = false;
  55. }
  56. }