Newer
Older
DungeonShooting / DungeonShooting_Godot / src / game / ui / mapEditor / TileView / EditorTileMapBar.cs
@小李xl 小李xl on 16 Jul 2023 1 KB 完整的加载与保存逻辑
  1. using Godot;
  2.  
  3. namespace UI.MapEditor;
  4.  
  5. public class EditorTileMapBar
  6. {
  7. private MapEditorPanel _editorPanel;
  8. private MapEditor.MapEditor_TileMap _editorTileMap;
  9. public EditorTileMapBar(MapEditorPanel editorPanel, MapEditor.MapEditor_TileMap editorTileMap)
  10. {
  11. _editorTileMap = editorTileMap;
  12. _editorPanel = editorPanel;
  13. _editorTileMap.Instance.MapEditorPanel = editorPanel;
  14. //测试加载地牢
  15. _editorTileMap.Instance.LoadTile();
  16. }
  17.  
  18. public void OnShow()
  19. {
  20. _editorTileMap.L_Brush.Instance.Draw += OnDrawGuides;
  21. _editorPanel.ToolsPanel.S_HandTool.Instance.Pressed += _editorTileMap.Instance.OnSelectHandTool;
  22. _editorPanel.ToolsPanel.S_PenTool.Instance.Pressed += _editorTileMap.Instance.OnSelectPenTool;
  23. _editorPanel.ToolsPanel.S_RectTool.Instance.Pressed += _editorTileMap.Instance.OnSelectRectTool;
  24. _editorPanel.ToolsPanel.S_CenterTool.Instance.Pressed += _editorTileMap.Instance.OnClickCenterTool;
  25. }
  26.  
  27. public void OnHide()
  28. {
  29. _editorTileMap.L_Brush.Instance.Draw -= OnDrawGuides;
  30. _editorPanel.ToolsPanel.S_HandTool.Instance.Pressed -= _editorTileMap.Instance.OnSelectHandTool;
  31. _editorPanel.ToolsPanel.S_PenTool.Instance.Pressed -= _editorTileMap.Instance.OnSelectPenTool;
  32. _editorPanel.ToolsPanel.S_RectTool.Instance.Pressed -= _editorTileMap.Instance.OnSelectRectTool;
  33. _editorPanel.ToolsPanel.S_CenterTool.Instance.Pressed -= _editorTileMap.Instance.OnClickCenterTool;
  34. }
  35.  
  36. public void Process(float delta)
  37. {
  38. _editorTileMap.L_Brush.Instance.QueueRedraw();
  39. }
  40.  
  41. private void OnDrawGuides()
  42. {
  43. _editorTileMap.Instance.DrawGuides(_editorTileMap.L_Brush.Instance);
  44. }
  45. }