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