Newer
Older
DungeonShooting / DungeonShooting_Godot / src / game / ui / tileSetEditorProject / TileButtonCell.cs
  1.  
  2. using Godot;
  3. using UI.TileSetEditor;
  4.  
  5. namespace UI.TileSetEditorProject;
  6.  
  7. public class TileButtonCell : UiCell<TileSetEditorProject.TileButton, TileSetSplit>
  8. {
  9. public override void OnInit()
  10. {
  11. CellNode.L_SelectTexture.Instance.Visible = false;
  12. }
  13.  
  14. public override void OnSetData(TileSetSplit data)
  15. {
  16. CellNode.L_TileName.Instance.Text = data.TileSetInfo.Name;
  17. //检测是否有错误
  18. var hasError = false;
  19. foreach (var sourceInfo in data.TileSetInfo.Sources)
  20. {
  21. if (string.IsNullOrEmpty(sourceInfo.SourcePath))
  22. {
  23. hasError = true;
  24. break;
  25. }
  26.  
  27. foreach (var terrainInfo in sourceInfo.Terrain)
  28. {
  29. if (!terrainInfo.Ready)
  30. {
  31. hasError = true;
  32. break;
  33. }
  34. }
  35. }
  36.  
  37. if (hasError)
  38. {
  39. CellNode.L_Icon.Instance.Texture = ResourceManager.LoadTexture2D(ResourcePath.resource_sprite_ui_commonIcon_Error_mini_png);
  40. }
  41. else
  42. {
  43. CellNode.L_Icon.Instance.Texture = ResourceManager.LoadTexture2D(ResourcePath.resource_sprite_ui_commonIcon_Success_mini_png);
  44. }
  45. }
  46.  
  47. public override void OnDoubleClick()
  48. {
  49. //打开TileSet编辑器面板
  50. var tileSetEditorPanel = CellNode.UiPanel.ParentUi.OpenNextUi<TileSetEditorPanel>(UiManager.UiNames.TileSetEditor);
  51. tileSetEditorPanel.InitData(Data);
  52. }
  53.  
  54. public override void OnSelect()
  55. {
  56. CellNode.L_SelectTexture.Instance.Visible = true;
  57. var previewGrid = CellNode.UiPanel.PreviewGrid;
  58. previewGrid.SetDataList(Data.TileSetInfo.Sources.ToArray());
  59. }
  60.  
  61. public override void OnUnSelect()
  62. {
  63. CellNode.L_SelectTexture.Instance.Visible = false;
  64. }
  65. }