Newer
Older
DungeonShooting / DungeonShooting_Godot / src / game / ui / mapEditor / TileView / EditorTileMapBar.cs
@小李xl 小李xl on 29 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.TileMap _editorTileMap;
  9. public EditorTileMapBar(MapEditorPanel editorPanel, MapEditor.TileMap editorTileMap)
  10. {
  11. _editorTileMap = editorTileMap;
  12. _editorPanel = editorPanel;
  13. _editorTileMap.Instance.MapEditorPanel = editorPanel;
  14. _editorTileMap.Instance.MapEditorToolsPanel = editorPanel.S_MapEditorTools.Instance;
  15. _editorTileMap.Instance.MapEditorToolsPanel.EditorMap = _editorTileMap;
  16. }
  17.  
  18. public void OnShow()
  19. {
  20. _editorTileMap.L_Brush.Instance.Draw += OnDrawGuides;
  21. var mapEditorToolsPanel = _editorPanel.S_MapEditorTools.Instance;
  22. mapEditorToolsPanel.S_HandTool.Instance.Pressed += _editorTileMap.Instance.OnSelectHandTool;
  23. mapEditorToolsPanel.S_PenTool.Instance.Pressed += _editorTileMap.Instance.OnSelectPenTool;
  24. mapEditorToolsPanel.S_RectTool.Instance.Pressed += _editorTileMap.Instance.OnSelectRectTool;
  25. mapEditorToolsPanel.S_CenterTool.Instance.Pressed += _editorTileMap.Instance.OnClickCenterTool;
  26. }
  27.  
  28. public void OnHide()
  29. {
  30. _editorTileMap.L_Brush.Instance.Draw -= OnDrawGuides;
  31. var mapEditorToolsPanel = _editorPanel.S_MapEditorTools.Instance;
  32. mapEditorToolsPanel.S_HandTool.Instance.Pressed -= _editorTileMap.Instance.OnSelectHandTool;
  33. mapEditorToolsPanel.S_PenTool.Instance.Pressed -= _editorTileMap.Instance.OnSelectPenTool;
  34. mapEditorToolsPanel.S_RectTool.Instance.Pressed -= _editorTileMap.Instance.OnSelectRectTool;
  35. mapEditorToolsPanel.S_CenterTool.Instance.Pressed -= _editorTileMap.Instance.OnClickCenterTool;
  36. }
  37.  
  38. public void Process(float delta)
  39. {
  40. _editorTileMap.L_Brush.Instance.QueueRedraw();
  41. }
  42.  
  43. private void OnDrawGuides()
  44. {
  45. _editorTileMap.Instance.DrawGuides(_editorTileMap.L_Brush.Instance);
  46. }
  47. }