Newer
Older
DungeonShooting / DungeonShooting_Godot / src / game / ui / mapEditorProject / RoomButtonCell.cs
  1. using System.Linq;
  2. using Godot;
  3. using UI.TileSetEditor;
  4.  
  5. namespace UI.MapEditorProject;
  6.  
  7. public class RoomButtonCell : UiCell<MapEditorProject.RoomButton, DungeonRoomSplit>
  8. {
  9. public override void OnInit()
  10. {
  11. CellNode.L_SelectTexture.Instance.Visible = false;
  12. }
  13. public override void OnSetData(DungeonRoomSplit data)
  14. {
  15. CellNode.L_RoomName.Instance.Text = data.RoomInfo.RoomName;
  16. CellNode.L_RoomType.Instance.Text = DungeonManager.DungeonRoomTypeToDescribeString(data.RoomInfo.RoomType);
  17. //预览图
  18. CellNode.L_PreviewImage.Instance.Texture = data.PreviewImage;
  19. //提示
  20. var tipText = "权重: " + data.RoomInfo.Weight;
  21. //错误消息
  22. if (data.ErrorType == RoomErrorType.None)
  23. {
  24. CellNode.L_ErrorTexture.Instance.Visible = false;
  25. }
  26. else
  27. {
  28. CellNode.L_ErrorTexture.Instance.Visible = true;
  29. tipText += "\n错误: " + EditorTileMapManager.GetRoomErrorTypeMessage(data.ErrorType);
  30. }
  31. if (!string.IsNullOrEmpty(data.RoomInfo.Remark))
  32. {
  33. tipText += "\n备注: " + data.RoomInfo.Remark;
  34. }
  35. CellNode.Instance.TooltipText = tipText;
  36. }
  37.  
  38. public override void OnDisable()
  39. {
  40. CellNode.L_PreviewImage.Instance.Texture = null;
  41. }
  42.  
  43. public override void OnDoubleClick()
  44. {
  45. //加载TileSet
  46. var tileSetSplit = GameApplication.Instance.TileSetConfig[CellNode.UiPanel.GroupGrid.SelectData.TileSet];
  47. //判断tileSet是否可以使用
  48. if (string.IsNullOrEmpty(tileSetSplit.TileSetInfo.Sources[0].SourcePath))
  49. {
  50. EditorWindowManager.ShowConfirm("错误", "当前房间绑定的 TileSet 中 Main Source 未被赋予纹理数据!\n是否前往编辑 TileSet?", (v) =>
  51. {
  52. if (v)
  53. {
  54. //跳转编辑TileSet页面
  55. var tileSetEditorPanel = CellNode.UiPanel.ParentUi.OpenNextUi<TileSetEditorPanel>(UiManager.UiNames.TileSetEditor);
  56. tileSetEditorPanel.InitData(tileSetSplit);
  57. }
  58. });
  59. return;
  60. }
  61. CellNode.UiPanel.OpenSelectRoom(Data, tileSetSplit);
  62. }
  63. public override void OnSelect()
  64. {
  65. EditorTileMapManager.SetSelectRoom(Data);
  66. CellNode.L_SelectTexture.Instance.Visible = true;
  67. }
  68.  
  69. public override void OnUnSelect()
  70. {
  71. CellNode.L_SelectTexture.Instance.Visible = false;
  72. }
  73. }