Esempio n. 1
0
        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());
            }
        }
Esempio n. 2
0
        private void MouseHexChanged(MapperMap map, Point hex)
        {
            if (map.Objects.Count(x => x.MapX == hex.X && x.MapY == hex.Y) == 0)
            {
                toolStripStatusProto.Text = "";
            }

            foreach (var obj in map.Objects.FindAll(x => x.MapX == hex.X && x.MapY == hex.Y))
            {
                if ((obj.MapObjType == FOCommon.Maps.MapObjectType.Item ||
                     obj.MapObjType == FOCommon.Maps.MapObjectType.Scenery))
                {
                    ItemProto prot;
                    if (!EditorData.itemsPid.TryGetValue(obj.ProtoId, out prot))
                    {
                        continue;
                    }

                    toolStripStatusProto.Text  = "Proto: " + (obj.ProtoId);
                    toolStripStatusProto.Text += string.Format(" ({0} - {1})", prot.Name, prot.PicMap);
                }

                if (obj.MapObjType == FOCommon.Maps.MapObjectType.Critter)
                {
                    toolStripStatusProto.Text = "Critter: " + obj.ProtoId;
                }
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Refresh selection form
        /// </summary>
        /// <param name="map"></param>
        private void refreshSelectionForm(MapperMap map)
        {
            if (frmLayerInfo != null)
            {
                int count = 0;

                frmLayerInfo.copyBuffer = copyBuffer;
                frmLayerInfo.currentMap = EditorData.CurrentMap;

                frmLayerInfo.lstBuffer.Items.Clear();
                frmLayerInfo.lstMainBuffer.Items.Clear();

                foreach (var selection in map.Selection)
                {
                    ListViewItem listItem = new ListViewItem("Selection " + count++);
                    listItem.Tag = selection;
                    frmLayerInfo.lstBuffer.Items.Add(listItem);
                }

                foreach (var selection in copyBuffer)
                {
                    ListViewItem listItem = new ListViewItem("MainSelection " + count++);
                    listItem.Tag = selection;
                    frmLayerInfo.lstMainBuffer.Items.Add(listItem);
                }
            }
        }
Esempio n. 4
0
        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);
        }
Esempio n. 5
0
        private void pnlRenderBitmap_Paint(object sender, PaintEventArgs e)
        {
            MapperMap map = EditorData.CurrentMap;

            if (map == null)
            {
                return;
            }
            DrawGDI(e.Graphics, map);
        }
Esempio n. 6
0
        public static MapperMap Load( string fileName)
        {
            parser = new FOMapParser( fileName );
            if (parser.Parse())
            {
                instance = new MapperMap(parser.Map);
                return instance;
            }

            return (null);
        }
Esempio n. 7
0
        public static MapperMap Load(string fileName)
        {
            parser = new FOMapParser(fileName);
            if (parser.Parse())
            {
                instance = new MapperMap(parser.Map);
                return(instance);
            }

            return(null);
        }
Esempio n. 8
0
        /// <summary>
        /// Show select buffer
        /// </summary>
        /// <param name="map"></param>
        private void showSelectionBuffer(MapperMap map)
        {
            if (frmLayerInfo != null)
            {
                frmLayerInfo.Close();
            }

            frmLayerInfo         = new frmLayerInfo();
            frmLayerInfo.refresh = this.RefreshViewport;
            frmLayerInfo.updateCopyBufferToMap = this.addSelectionsToCurrentMap;

            refreshSelectionForm(map);

            frmLayerInfo.Show();
        }
Esempio n. 9
0
        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);
            }
        }
Esempio n. 10
0
        private void headerToolStripMenuItem_Click(object sender, EventArgs e)
        {
            MapperMap map = EditorData.CurrentMap;

            if (map == null)
            {
                MessageBox.Show("Map not loaded!");
                return;
            }

            frmHeaderEditor formHeaderEditor = new frmHeaderEditor(map.Header);

            if (formHeaderEditor.ShowDialog() == DialogResult.OK)
            {
                // TODO: update map header
            }
        }
Esempio n. 11
0
        /// <summary>
        /// Refresh selection form
        /// </summary>
        /// <param name="map"></param>
        private void refreshSelectionForm(MapperMap map)
        {
            if (frmLayerInfo != null)
            {
                int count = 0;

                frmLayerInfo.copyBuffer = copyBuffer;
                frmLayerInfo.currentMap = EditorData.CurrentMap;

                frmLayerInfo.lstBuffer.Items.Clear();
                frmLayerInfo.lstMainBuffer.Items.Clear();

                foreach (var selection in map.Selection)
                {
                    ListViewItem listItem = new ListViewItem("Selection " + count++);
                    listItem.Tag = selection;
                    frmLayerInfo.lstBuffer.Items.Add(listItem);
                }

                foreach (var selection in copyBuffer)
                {
                    ListViewItem listItem = new ListViewItem("MainSelection " + count++);
                    listItem.Tag = selection;
                    frmLayerInfo.lstMainBuffer.Items.Add(listItem);
                }
            }
        }
Esempio n. 12
0
        private void MouseHexChanged(MapperMap map, Point hex)
        {
            if (map.Objects.Count(x => x.MapX == hex.X && x.MapY == hex.Y) == 0)
                toolStripStatusProto.Text = "";

            foreach (var obj in map.Objects.FindAll(x => x.MapX == hex.X && x.MapY == hex.Y))
            {
                if ((obj.MapObjType == FOCommon.Maps.MapObjectType.Item ||
                      obj.MapObjType == FOCommon.Maps.MapObjectType.Scenery))
                {
                    ItemProto prot;
                    if (!EditorData.itemsPid.TryGetValue(obj.ProtoId, out prot))
                        continue;

                    toolStripStatusProto.Text = "Proto: " + (obj.ProtoId);
                    toolStripStatusProto.Text += string.Format(" ({0} - {1})", prot.Name, prot.PicMap);
                }

                if (obj.MapObjType == FOCommon.Maps.MapObjectType.Critter)
                {
                    toolStripStatusProto.Text = "Critter: " + obj.ProtoId;
                }
            }
        }
Esempio n. 13
0
        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());
        }
Esempio n. 14
0
        /// <summary>
        /// Show select buffer
        /// </summary>
        /// <param name="map"></param>
        private void showSelectionBuffer(MapperMap map)
        {
            if (frmLayerInfo != null)
                frmLayerInfo.Close();

            frmLayerInfo = new frmLayerInfo();
            frmLayerInfo.refresh = this.RefreshViewport;
            frmLayerInfo.updateCopyBufferToMap = this.addSelectionsToCurrentMap;

            refreshSelectionForm(map);

            frmLayerInfo.Show();
        }
Esempio n. 15
0
        public frmMapTree(MapperMap map)
        {
            InitializeComponent();
            var header = treeView1.Nodes.Add("Map Header Data");
            this.Text = map.Name;

            Type type = typeof(FOCommon.Maps.MapHeader);
            foreach(var field in type.GetProperties())
            {
                 header.Nodes.Add(field.Name + " = " + field.GetValue(map.Header, null));
            }

            var tilesNode = treeView1.Nodes.Add("Tiles");
            List<string> addedTiles = new List<string>();
            foreach (var tile in map.Tiles)
            {
                if (addedTiles.Contains(tile.Path)) continue;
                addedTiles.Add(tile.Path);
                var tilePathNode = tilesNode.Nodes.Add(tile.Path);
                tilePathNode.Nodes.Add(map.Tiles.Count(x => x.Path == tile.Path).ToString() + " occurances");
            }

            var objectsNode = treeView1.Nodes.Add("Objects");
            var crNode = objectsNode.Nodes.Add("Critters");
            var scNode = objectsNode.Nodes.Add("Scenery");
            var itNode = objectsNode.Nodes.Add("Items");

            foreach (var obj in map.Objects)
            {
                //string objType = "Unknown";
                TreeNode parent = objectsNode;

                if (obj.MapObjType == FOCommon.Maps.MapObjectType.Critter)
                {
                    //objType = "Critter";
                    parent = crNode;
                }
                if (obj.MapObjType == FOCommon.Maps.MapObjectType.Item)
                {
                    //objType = "Item";
                    parent = itNode;
                }
                if (obj.MapObjType == FOCommon.Maps.MapObjectType.Scenery)
                {
                    //objType = "Scenery";
                    parent = scNode;
                }

                var node = parent.Nodes.Add("ProtoId " + obj.ProtoId + " [" + obj.MapX + "," + obj.MapY + "]");

                foreach (var kvp in obj.Properties)
                {
                    node.Nodes.Add(kvp.Key + " = " + kvp.Value);
                }
                if (obj.MapObjType == FOCommon.Maps.MapObjectType.Critter)
                {
                    foreach (var kvp in obj.CritterParams)
                    {
                        node.Nodes.Add(kvp.Key + " = " + kvp.Value);
                    }
                }
            }
        }
Esempio n. 16
0
        public frmMapTree(MapperMap map)
        {
            InitializeComponent();
            var header = treeView1.Nodes.Add("Map Header Data");

            this.Text = map.Name;

            Type type = typeof(FOCommon.Maps.MapHeader);

            foreach (var field in type.GetProperties())
            {
                header.Nodes.Add(field.Name + " = " + field.GetValue(map.Header, null));
            }

            var           tilesNode  = treeView1.Nodes.Add("Tiles");
            List <string> addedTiles = new List <string>();

            foreach (var tile in map.Tiles)
            {
                if (addedTiles.Contains(tile.Path))
                {
                    continue;
                }
                addedTiles.Add(tile.Path);
                var tilePathNode = tilesNode.Nodes.Add(tile.Path);
                tilePathNode.Nodes.Add(map.Tiles.Count(x => x.Path == tile.Path).ToString() + " occurances");
            }

            var objectsNode = treeView1.Nodes.Add("Objects");
            var crNode      = objectsNode.Nodes.Add("Critters");
            var scNode      = objectsNode.Nodes.Add("Scenery");
            var itNode      = objectsNode.Nodes.Add("Items");

            foreach (var obj in map.Objects)
            {
                //string objType = "Unknown";
                TreeNode parent = objectsNode;

                if (obj.MapObjType == FOCommon.Maps.MapObjectType.Critter)
                {
                    //objType = "Critter";
                    parent = crNode;
                }
                if (obj.MapObjType == FOCommon.Maps.MapObjectType.Item)
                {
                    //objType = "Item";
                    parent = itNode;
                }
                if (obj.MapObjType == FOCommon.Maps.MapObjectType.Scenery)
                {
                    //objType = "Scenery";
                    parent = scNode;
                }

                var node = parent.Nodes.Add("ProtoId " + obj.ProtoId + " [" + obj.MapX + "," + obj.MapY + "]");

                foreach (var kvp in obj.Properties)
                {
                    node.Nodes.Add(kvp.Key + " = " + kvp.Value);
                }
                if (obj.MapObjType == FOCommon.Maps.MapObjectType.Critter)
                {
                    foreach (var kvp in obj.CritterParams)
                    {
                        node.Nodes.Add(kvp.Key + " = " + kvp.Value);
                    }
                }
            }
        }
Esempio n. 17
0
 public void AddMap(MapperMap Map)
 {
     Maps.Add(Map);
 }
Esempio n. 18
0
 public void AddMap(MapperMap Map)
 {
     Maps.Add(Map);
 }
Esempio n. 19
0
        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);
        }