Newer
Older
DungeonShooting / DungeonShooting_Godot / src / game / ui / tileSetEditorCombination / right / TileCell.cs
  1. using Godot;
  2.  
  3. namespace UI.TileSetEditorCombination;
  4.  
  5. public class TileCell : UiCell<TileSetEditorCombination.CellButton, ImportCombinationData>
  6. {
  7. public override void OnInit()
  8. {
  9. CellNode.L_SelectTexture.Instance.Visible = false;
  10. }
  11. public override void OnSetData(ImportCombinationData data)
  12. {
  13. CellNode.L_CellName.Instance.Text = data.CombinationInfo.Name;
  14. CellNode.L_PreviewImage.Instance.Texture = data.PreviewTexture;
  15. }
  16.  
  17. public override void OnDisable()
  18. {
  19. if (Data.PreviewTexture != null)
  20. {
  21. Data.PreviewTexture.Dispose();
  22. Data.PreviewTexture = null;
  23. }
  24. }
  25.  
  26. public override void OnDestroy()
  27. {
  28. if (Data.PreviewTexture != null)
  29. {
  30. Data.PreviewTexture.Dispose();
  31. Data.PreviewTexture = null;
  32. }
  33. }
  34.  
  35. public override void OnDoubleClick()
  36. {
  37. //双击移除Cell数据
  38. EditorWindowManager.ShowEditCombination(
  39. Data.CombinationInfo.Name,
  40. CellNode.UiPanel.EditorPanel.BgColor,
  41. Data.PreviewTexture,
  42. (newName) => //修改
  43. {
  44. Data.CombinationInfo.Name = newName;
  45. EventManager.EmitEvent(EventEnum.OnUpdateCombination, Data);
  46. },
  47. () => //删除
  48. {
  49. EventManager.EmitEvent(EventEnum.OnRemoveCombination, Data);
  50. }
  51. );
  52. }
  53.  
  54. public override void OnSelect()
  55. {
  56. CellNode.L_SelectTexture.Instance.Visible = true;
  57. }
  58.  
  59. public override void OnUnSelect()
  60. {
  61. CellNode.L_SelectTexture.Instance.Visible = false;
  62. }
  63. }