private void RefreshViewport() { if (Frms.Count == 0) { return; } MapperMap map = EditorData.CurrentMap; if (map == null) { return; } DrawMap.InvalidateCache(); pnlRenderBitmap.Refresh(); if (frmDebugInfo != null && !frmDebugInfo.IsDisposed) { frmDebugInfo.setText("Objects rendered: " + DrawMap.GetNumCachedObjects()); frmDebugInfo.setText("Objects selected: " + (DrawMap.GetSelectedObjects().Count + DrawMap.GetSelectedTiles().Count)); } refreshSelectionForm(map); }
private void DrawGDI(Graphics g, MapperMap map) { if (mapperSettings.Performance.FastRendering) { g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.NearestNeighbor; g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.None; g.PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.None; g.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighSpeed; } else { g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.High; g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality; g.PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.HighQuality; g.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality; } int border = 128; var screenArea = new RectangleF(pnlViewPort.HorizontalScroll.Value - border, pnlViewPort.VerticalScroll.Value - border, pnlViewPort.Width + border, pnlViewPort.Height + border); DrawMap.OnGraphics(g, map, map.HexMap, EditorData.itemsPid, critterData, Frms, EditorData, new SizeF(scaleFactor, scaleFactor), screenArea, mouseSelection); if (mouseSelection.isDown) { g.DrawRectangle(mouseSelection.rectPen, mouseSelection.GetRect()); } }
private void pnlRenderBitmap_MouseUp(object sender, MouseEventArgs e) { if (e.Button == System.Windows.Forms.MouseButtons.Left) { mouseSelection.MouseUp(); EditorData.CurrentMap.MapSelect(DrawMap.GetSelectedTiles(), DrawMap.GetSelectedObjects()); RefreshViewport(); } else if (e.Button == System.Windows.Forms.MouseButtons.Right) { mouseSelection.isRightClickDown = false; } }
private void LoadMap(string fileName) { MapperMap map = MapperMap.Load(fileName); if (map != null) { EditorData.AddMap(map); // Preserve selection reference if (EditorData.CurrentMap != null) { //map.Selection.AddRange(EditorData.CurrentMap.Selection.Clone()); if (frmLayerInfo != null && frmLayerInfo.Visible) { showSelectionBuffer(map); } } EditorData.CurrentMap = map; this.Text = title + fileName; headerToolStripMenuItem.Enabled = menuFileExport.Enabled = viewMapTreeToolStripMenuItem.Enabled = true; viewPortSize.X = ((map.GetEdgeCoords(FOHexMap.Direction.Right).X) - (map.GetEdgeCoords(FOHexMap.Direction.Left).X)) + 100.0f; viewPortSize.Y = ((map.GetEdgeCoords(FOHexMap.Direction.Down).Y) - (map.GetEdgeCoords(FOHexMap.Direction.Up).Y)) + 100.0f; resizeViewport(); centerViewport(); RefreshViewport(); // TODO: Check critter/proto names and PID in the map itself instead of just graphics. var errors = DrawMap.GetErrors(); errors.Sort(); frmErrors frmErrors = new frmErrors(fileName, string.Join(Environment.NewLine, errors.Distinct().ToArray())); if (errors.Count != 0) { frmErrors.ShowDialog(); } } else { MessageBox.Show("Error loading map " + fileName); } }
private DrawMap.Flags UpdateFlag(bool enable, DrawMap.Flags flag, DrawMap.Flags newFlag ) { if (enable) flag = flag | newFlag; else flag = flag & ~newFlag; return flag; }
public void UpdateSelectFlags(bool enable, DrawMap.Flags flag) { selectFlags = UpdateFlag(enable, selectFlags, flag); }
public void UpdateOverlayFlags(bool enable, DrawMap.Flags flag) { overlayFlags = UpdateFlag(enable, overlayFlags, flag); }
public void UpdateDrawFlags(bool enable, DrawMap.Flags flag) { drawFlags = UpdateFlag(enable, drawFlags, flag); }
private void UpdateSelectFlags(object sender, DrawMap.Flags flag) { EditorData.UpdateSelectFlags(((ToolStripMenuItem)sender).Checked, flag); }
private void UpdateOverlayFlags(object sender, DrawMap.Flags flag) { EditorData.UpdateOverlayFlags(((ToolStripMenuItem)sender).Checked, flag); RefreshViewport(); }
private void frmMain_KeyUp(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Delete) { foreach (var obj in DrawMap.GetSelectedObjects()) { EditorData.CurrentMap.Objects.Remove(obj); } foreach (var tile in DrawMap.GetSelectedTiles()) { EditorData.CurrentMap.Tiles.Remove(tile); } RefreshViewport(); } else if (e.Control && e.KeyCode == Keys.C) { Selection selected = new Selection(); selected.Objects.AddRange(DrawMap.GetSelectedObjects().Clone().Select(a => { a.colorOverlay = 40; return(a); })); selected.Tiles.AddRange(DrawMap.GetSelectedTiles().Clone().Select(a => { a.colorOverlay = 40; return(a); })); EditorData.CurrentMap.Selection.Add(selected); RefreshViewport(); } else if (e.Control && e.KeyCode == Keys.B) // Clear last selection buffer { if (EditorData.CurrentMap.Selection.Count > 0) { EditorData.CurrentMap.Selection.Remove(EditorData.CurrentMap.Selection.Last()); } RefreshViewport(); } else if (e.Control && e.KeyCode == Keys.V) // Paste buffer { addSelectionsToCurrentMap(); } else if (e.Control && e.KeyCode == Keys.S) { EditorData.CurrentMap.Save(); } else if (e.KeyCode == Keys.Down) { EditorData.CurrentMap.MapSelection.MoveObject(0, 1); RefreshViewport(); } else if (e.KeyCode == Keys.Up) { EditorData.CurrentMap.MapSelection.MoveObject(0, -1); RefreshViewport(); } else if (e.KeyCode == Keys.Right) { EditorData.CurrentMap.MapSelection.MoveObject(-1, 0); RefreshViewport(); } else if (e.KeyCode == Keys.Left) { EditorData.CurrentMap.MapSelection.MoveObject(1, 0); RefreshViewport(); } }
private void pnlRenderBitmap_MouseMove(object sender, MouseEventArgs e) { MapperMap map = EditorData.CurrentMap; if (map == null) { return; } if (mouseSelection.isDown) { mouseSelection.mouseRectPos.X = (int)((float)e.X / scaleFactor); mouseSelection.mouseRectPos.Y = (int)((float)e.Y / scaleFactor); mouseSelection.CalculateSelectionArea(); int padding = 70; mouseSelection.UpdateMaxRect(); int x1 = mouseSelection.clickedPos.X - padding; int y1 = mouseSelection.clickedPos.Y - padding; int x2 = mouseSelection.maxMouseRectPos.X + padding; int y2 = mouseSelection.maxMouseRectPos.Y + padding; DrawMap.InvalidateCache(); pnlRenderBitmap.Invalidate(new Rectangle(x1, y1, x2 - x1, y2 - y1)); } if (mouseSelection.isRightClickDown) { if (EditorData.CurrentMap.Selection.Count > 0) { dynamic offset = EditorData.CurrentMap.Selection.First().GetOffset(currentMouseHex.X, currentMouseHex.Y); var X = offset.X; var Y = offset.Y; foreach (var obj in EditorData.CurrentMap.Selection) { obj.MoveObject(X, Y); } } else if (EditorData.CurrentMap.MapSelection.hasAny()) { dynamic offset = EditorData.CurrentMap.MapSelection.GetOffset(currentMouseHex.X, currentMouseHex.Y); int X = offset.X; int Y = offset.Y; EditorData.CurrentMap.MapSelection.MoveObject(X, Y); } RefreshViewport(); } var hex = map.HexMap.GetHex(new PointF(e.X / scaleFactor, e.Y / scaleFactor + 6.0f)); if (currentMouseHex != null && (currentMouseHex.X != hex.X && currentMouseHex.Y != hex.Y)) { MouseHexChanged(map, hex); } currentMouseHex = hex; toolStripStatusHex.Text = string.Format("Mouse Coords: {0},{1} - Hex: {2},{3}", e.X, e.Y, hex.X, hex.Y); }