public override void OnMouseDown(MouseEventArgs e) { base.OnMouseDown(e); Point2I mousePos = new Point2I(e.X, e.Y); Room room = LevelDisplayControl.SampleRoom(mousePos); Point2I tileCoord = LevelDisplayControl.SampleTileCoordinates(mousePos); Point2I target = LevelDisplayControl.SampleLevelTileCoordinates(mousePos); if (!EditorControl.EventMode) { if (e.Button == MouseButtons.Middle) { // Select/sample tiles. TileDataInstance selectedTile = room.GetTile(tileCoord, editorControl.CurrentLayer); if (selectedTile != null) { Point2I levelTileCoord = LevelDisplayControl.ToLevelTileCoordinates(room, tileCoord); EditorControl.PropertyGrid.OpenProperties(selectedTile.Properties, selectedTile); editorControl.SelectedTilesetTile = -Point2I.One; editorControl.SelectedTilesetTileData = selectedTile.TileData; } else { EditorControl.PropertyGrid.CloseProperties(); } } else if (editorControl.CurrentLayer == 0 || GetTileAt(target) != null) { // Fill tiles. TileData fillData = editorControl.SelectedTilesetTileData as TileData; if (fillData != null) { if (e.Button == MouseButtons.Right) { fillData = null; } Fill(target, fillData); } } } else { if (e.Button == MouseButtons.Middle) { // Select events. EventTileDataInstance selectedEventTile = LevelDisplayControl.SampleEventTile(mousePos); if (selectedEventTile != null) { Point2I levelTileCoord = LevelDisplayControl.ToLevelTileCoordinates(room, tileCoord); EditorControl.PropertyGrid.OpenProperties(selectedEventTile.Properties, selectedEventTile); } else { EditorControl.PropertyGrid.CloseProperties(); } } } }
public override void OnMouseDown(MouseEventArgs e) { base.OnMouseDown(e); Point2I mousePos = new Point2I(e.X, e.Y); Room room = LevelDisplayControl.SampleRoom(mousePos); Point2I tileCoord = LevelDisplayControl.SampleTileCoordinates(mousePos); if (editorControl.EventMode) { if (EditorControl.EventMode && e.Button == MouseButtons.Left) { EventTileData eventTile = editorControl.SelectedTilesetTileData as EventTileData; if (room != null && eventTile != null) { Point2I roomPos = LevelDisplayControl.GetRoomDrawPosition(room); Point2I pos = (mousePos - roomPos) / 8; pos *= 8; //Point2I tileCoord = LevelDisplayControl.SampleTileCoordinates(mousePos); room.CreateEventTile(eventTile, pos); } } else if (EditorControl.EventMode && e.Button == MouseButtons.Right) { EventTileDataInstance eventTile = LevelDisplayControl.SampleEventTile(new Point2I(e.X, e.Y)); if (eventTile != null) { eventTile.Room.RemoveEventTile(eventTile); editorControl.OnDeleteObject(eventTile); } } else if (e.Button == MouseButtons.Middle) { // Select events. EventTileDataInstance selectedEventTile = LevelDisplayControl.SampleEventTile(mousePos); if (selectedEventTile != null) { Point2I levelTileCoord = LevelDisplayControl.ToLevelTileCoordinates(room, tileCoord); EditorControl.PropertyGrid.OpenProperties(selectedEventTile.Properties, selectedEventTile); } else { EditorControl.PropertyGrid.CloseProperties(); } } } else { if (e.Button == MouseButtons.Middle) { // Select tiles. TileDataInstance selectedTile = room.GetTile(tileCoord, editorControl.CurrentLayer); if (selectedTile != null) { Point2I levelTileCoord = LevelDisplayControl.ToLevelTileCoordinates(room, tileCoord); EditorControl.PropertyGrid.OpenProperties(selectedTile.Properties, selectedTile); } else { EditorControl.PropertyGrid.CloseProperties(); } } } }