public override void OnMouseDown(MouseEventArgs e) { base.OnMouseDown(e); Point2I mousePos = new Point2I(e.X, e.Y); // Sample the tile at the mouse position. BaseTileDataInstance baseTile = null; if (editorControl.EventMode) { baseTile = LevelDisplayControl.SampleEventTile(mousePos); } else { baseTile = LevelDisplayControl.SampleTile(mousePos, editorControl.CurrentLayer); } // Select or deselect the tile. if (e.Button == MouseButtons.Left) { /*if (FormsControl.ModifierKeys == Keys.Control) { * if (baseTile != null) { * // Add or remove tiles from selection. * if (!LevelDisplayControl.IsTileInSelection(baseTile)) { * LevelDisplayControl.AddTileToSelection(baseTile); * EditorControl.PropertyGrid.OpenProperties(baseTile); * } * else { * LevelDisplayControl.RemoveTileFromSelection(baseTile); * } * } * } * else */{ // Select a new tile, deselecting others. LevelDisplayControl.DeselectTiles(); if (baseTile != null) { LevelDisplayControl.AddTileToSelection(baseTile); EditorControl.PropertyGrid.OpenProperties(baseTile); } else { EditorControl.PropertyGrid.CloseProperties(); } } } }
public override void OnMouseMove(MouseEventArgs e) { base.OnMouseMove(e); Point2I mousePos = new Point2I(e.X, e.Y); if (!editorControl.EventMode) { // Highlight tiles. TileDataInstance tile = LevelDisplayControl.SampleTile(mousePos, editorControl.CurrentLayer); EditorControl.HighlightMouseTile = (tile != null); } else { // Highlight event tiles. EventTileDataInstance eventTile = LevelDisplayControl.SampleEventTile(mousePos); EditorControl.HighlightMouseTile = (eventTile != null); } }
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(); } } } }