private void FillTiles(Rectangle rectangle, bool value) { for (int i = (int)rectangle.X; i < (int)rectangle.X + (int)rectangle.Width; i++) { for (int j = (int)rectangle.Y; j < (int)rectangle.Y + (int)rectangle.Height; j++) { Map[i, j] = value; RectangleOutline outline = Outlines[new Point(i, j)]; FormatTile(outline, value); } } }
public override void EventFired(object sender, Event e) { if (e is StartCollisionModeEvent start) { Pivot = start.Pivot; Callback = start.Callback; MultipleAllowed = start.MultipleBoxes; Boxes = start.Boxes.ToList(); Mode = Edit; foreach (CollisionBox box in Boxes) { IOutline outline = new CollisionBoxOutline(Pivot, box, Color.Purple); Outlines.Add(outline); Owner.Events.InvokeEvent(new BeginOverlay(outline)); } IOutline pivotOutline = new RectangleOutline(new Rectangle(Pivot - new Vector2D(1, 1), new Size(2, 2)), Color.White, 4); Outlines.Add(pivotOutline); Owner.Events.InvokeEvent(new BeginOverlay(pivotOutline)); FaceOutline = new RectangleOutline(new Rectangle(0, 0, 0, 0), Color.White, 4); Outlines.Add(FaceOutline); Owner.Events.InvokeEvent(new BeginOverlay(FaceOutline)); } else if (e is ModalChangeEvent changed) { //changed.Valid = false; //Owner.Events.InvokeEvent(new ForceModalChangeEvent("editor_cursor", null)); ModalActive = true; ModalVisible = true; CursorSystem.ModalActive = true; CursorSystem.DraggingEnabled = true; if (changed.From != "collision_face_view") { CursorSystem.SwitchToModal = changed.From; } //CursorSystem.OutlinesEnabled = true; } else if (e is BeginModalChangeEvent bmce) { if (SelectionLocked) { SelectionLocked = false; return; } bmce.SystemName = CursorSystem.SwitchToModal; ModalActive = false; ModalVisible = false; CursorSystem.ModalActive = false; CursorSystem.DraggingEnabled = false; Callback(Boxes); Callback = null; foreach (IOutline outline in Outlines) { Owner.Events.InvokeEvent(new RemoveOverlay(outline)); } Outlines.Clear(); Boxes.Clear(); } }
public override void EventFired(object sender, Event e) { if (e is StartSpriteModeEvent start) { Origin = start.Origin; Callback = start.Callback; MultipleAllowed = start.MultipleSprites; Sprites = start.Sprites; Mode = Edit; foreach (Sprite sprite in Sprites) { IOutline outline = new SpriteOutline(Origin, sprite, Color.Purple); Outlines.Add(outline); Owner.Events.InvokeEvent(new BeginOverlay(outline)); } IOutline pivotOutline = new RectangleOutline(new Rectangle(Origin - new Vector2D(1, 1), new Size(2, 2)), Color.White, 4); Outlines.Add(pivotOutline); Owner.Events.InvokeEvent(new BeginOverlay(pivotOutline)); FaceOutline = new RectangleOutline(new Rectangle(0, 0, 0, 0), Color.White, 4); Outlines.Add(FaceOutline); Owner.Events.InvokeEvent(new BeginOverlay(FaceOutline)); } else if (e is ModalChangeEvent changed) { //changed.Valid = false; //Owner.Events.InvokeEvent(new ForceModalChangeEvent("editor_cursor", null)); ModalActive = true; ModalVisible = true; CursorSystem.ModalActive = true; CursorSystem.DraggingEnabled = true; if (changed.From != "sprite_source_view") { CursorSystem.SwitchToModal = changed.From; } if (Sprites != null) { Renderable.OrderSprites(Sprites); } //CursorSystem.OutlinesEnabled = true; } else if (e is BeginModalChangeEvent bmce) { if (SelectionLocked) { SelectionLocked = false; return; } bmce.SystemName = CursorSystem.SwitchToModal; ModalActive = false; ModalVisible = false; CursorSystem.ModalActive = false; CursorSystem.DraggingEnabled = false; Callback(Sprites); Callback = null; foreach (IOutline outline in Outlines) { Owner.Events.InvokeEvent(new RemoveOverlay(outline)); } Outlines.Clear(); } }
/*private void UpdateSelected() * { * SelectedBox = null; * foreach (bool box in Map) * { * if ((box.ToRectangle() + Pivot).Contains(CursorSystem.CursorPos)) * { * SelectedBox = box; * break; * } * } * foreach (IOutline outline in Outlines) * { * if (outline is CollisionBoxOutline boxOutline) * { * boxOutline.Color = boxOutline.Box == SelectedBox ? Color.Magenta : Color.DarkMagenta; * boxOutline.Thickness = boxOutline.Box == SelectedBox ? 3 : 2; * } * } * }*/ public override void EventFired(object sender, Event e) { if (e is StartRoomBuilderModeEvent start) { Pivot = start.Pivot; Callback = start.Callback; Map = start.Map; Mode = Fill; int width = start.Map.GetLength(0); int height = start.Map.GetLength(1); for (int i = 0; i < width; i++) { for (int j = 0; j < height; j++) { RectangleOutline outline = new RectangleOutline(new Rectangle(i * 16, j * 16, 16, 16) + Pivot, Color.FromArgb(128, 255, 255, 255)) { Thickness = 1 }; Outlines.Add(new Point(i, j), outline); Owner.Events.InvokeEvent(new BeginOverlay(outline)); FormatTile(outline, Map[i, j]); } } IOutline pivotOutline = new RectangleOutline(new Rectangle(Pivot - new Vector2D(1, 1), new Size(2, 2)), Color.White, 4); Overlays.Add(pivotOutline); Owner.Events.InvokeEvent(new BeginOverlay(pivotOutline)); PreviewOutline = new RectangleOutline(new Rectangle(Pivot, new Size(0, 0)), Color.Transparent) { Fill = Color.FromArgb(50, 255, 255, 255) }; Overlays.Add(PreviewOutline); Owner.Events.InvokeEvent(new BeginOverlay(PreviewOutline)); } else if (e is ModalChangeEvent changed) { //changed.Valid = false; //Owner.Events.InvokeEvent(new ForceModalChangeEvent("editor_cursor", null)); ModalActive = true; ModalVisible = true; CursorSystem.ModalActive = true; CursorSystem.DraggingEnabled = true; CursorSystem.SwitchToModal = changed.From; //CursorSystem.OutlinesEnabled = true; } else if (e is BeginModalChangeEvent bmce) { bmce.SystemName = CursorSystem.SwitchToModal; ModalActive = false; ModalVisible = false; CursorSystem.ModalActive = false; CursorSystem.DraggingEnabled = false; Callback(Map); Callback = null; foreach (IOutline outline in Outlines.Values) { Owner.Events.InvokeEvent(new RemoveOverlay(outline)); } foreach (IOverlay overlay in Overlays) { Owner.Events.InvokeEvent(new RemoveOverlay(overlay)); } Outlines.Clear(); Overlays.Clear(); } }
private void FormatTile(RectangleOutline outline, bool value) { //outline.Thickness = value ? 2 : 1; outline.Fill = value ? Color.FromArgb(55, 55, 60) : Color.Transparent; }