Example #1
0
        private void ExtractMapImage(ImageFormat imageFormat)
        {
            Cursor.Current = Cursors.WaitCursor;

            string fileExtension = Utils.GetFileExtensionFor(imageFormat);
            string fileName      = Path.Combine(Options.OutputPath, $"{Options.MapNames[_currMapId]}.{fileExtension}");

            try
            {
                Bitmap extract = _currMap.GetImage(0, 0, _currMap.Width >> 3, _currMap.Height >> 3, showStaticsToolStripMenuItem1.Checked);

                if (showMarkersToolStripMenuItem.Checked)
                {
                    Graphics g = Graphics.FromImage(extract);
                    foreach (TreeNode obj in OverlayObjectTree.Nodes[_currMapId].Nodes)
                    {
                        OverlayObject o = (OverlayObject)obj.Tag;
                        if (o.Visible)
                        {
                            o.Draw(g);
                        }
                    }
                    g.Save();
                }
                extract.Save(fileName, imageFormat);
            }
            finally
            {
                Cursor.Current = Cursors.Default;
            }

            MessageBox.Show($"Map saved to {fileName}", "Saved", MessageBoxButtons.OK, MessageBoxIcon.Information,
                            MessageBoxDefaultButton.Button1);
        }
Example #2
0
        public static void SaveMapOverlays()
        {
            if (!_loaded)
            {
                return;
            }

            string filepath = Options.AppDataPath;

            string fileName = Path.Combine(filepath, "MapOverlays.xml");

            XmlDocument    dom  = new XmlDocument();
            XmlDeclaration decl = dom.CreateXmlDeclaration("1.0", "utf-8", null);

            dom.AppendChild(decl);
            XmlElement sr      = dom.CreateElement("Overlays");
            bool       entries = false;

            for (int i = 0; i < 5; ++i)
            {
                foreach (TreeNode obj in _refMarker.OverlayObjectTree.Nodes[i].Nodes)
                {
                    OverlayObject o    = (OverlayObject)obj.Tag;
                    XmlElement    elem = dom.CreateElement("Marker");
                    o.Save(elem);
                    sr.AppendChild(elem);
                    entries = true;
                }
            }
            dom.AppendChild(sr);
            if (entries)
            {
                dom.Save(fileName);
            }
        }
Example #3
0
        private void ExtractMapJpg(object sender, EventArgs e)
        {
            Cursor.Current = Cursors.WaitCursor;
            string path     = Options.OutputPath;
            string name     = $"{Options.MapNames[_currMapInt]}.jpg";
            string fileName = Path.Combine(path, name);
            Bitmap extract  = _currMap.GetImage(0, 0, _currMap.Width >> 3, _currMap.Height >> 3, showStaticsToolStripMenuItem1.Checked);

            if (showMarkersToolStripMenuItem.Checked)
            {
                Graphics g = Graphics.FromImage(extract);
                foreach (TreeNode obj in OverlayObjectTree.Nodes[_currMapInt].Nodes)
                {
                    OverlayObject o = (OverlayObject)obj.Tag;
                    if (o.Visible)
                    {
                        o.Draw(g);
                    }
                }
                g.Save();
            }
            extract.Save(fileName, ImageFormat.Jpeg);
            Cursor.Current = Cursors.Default;
            MessageBox.Show($"Map saved to {fileName}", "Saved",
                            MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1);
        }
Example #4
0
        private void OnPaint(object sender, PaintEventArgs e)
        {
            _map = _currMap.GetImage(hScrollBar.Value >> 3, vScrollBar.Value >> 3,
                                     (int)(e.ClipRectangle.Width / Zoom + 8) >> 3, (int)(e.ClipRectangle.Height / Zoom + 8) >> 3,
                                     showStaticsToolStripMenuItem1.Checked);
            ZoomMap(ref _map);
            e.Graphics.DrawImageUnscaledAndClipped(_map, e.ClipRectangle);

            if (showCenterCrossToolStripMenuItem1.Checked)
            {
                Brush brush = new SolidBrush(Color.FromArgb(180, Color.White));
                Pen   pen   = new Pen(brush);
                int   x     = Round(pictureBox.Width / 2);
                int   y     = Round(pictureBox.Height / 2);
                e.Graphics.DrawLine(pen, x - 4, y, x + 4, y);
                e.Graphics.DrawLine(pen, x, y - 4, x, y + 4);
                pen.Dispose();
                brush.Dispose();
            }

            if (showClientCrossToolStripMenuItem.Checked)
            {
                if (Client.Running)
                {
                    if (_clientX > hScrollBar.Value &&
                        _clientX < hScrollBar.Value + e.ClipRectangle.Width / Zoom &&
                        _clientY > vScrollBar.Value &&
                        _clientY < vScrollBar.Value + e.ClipRectangle.Height / Zoom &&
                        _clientMap == _currMapInt)
                    {
                        Brush brush = new SolidBrush(Color.FromArgb(180, Color.Yellow));
                        Pen   pen   = new Pen(brush);
                        int   x     = (int)((_clientX - Round(hScrollBar.Value)) * Zoom);
                        int   y     = (int)((_clientY - Round(vScrollBar.Value)) * Zoom);
                        e.Graphics.DrawLine(pen, x - 4, y, x + 4, y);
                        e.Graphics.DrawLine(pen, x, y - 4, x, y + 4);
                        e.Graphics.DrawEllipse(pen, x - 2, y - 2, 2 * 2, 2 * 2);
                        pen.Dispose();
                        brush.Dispose();
                    }
                }
            }

            if (OverlayObjectTree.Nodes.Count <= 0 || !showMarkersToolStripMenuItem.Checked)
            {
                return;
            }

            foreach (TreeNode obj in OverlayObjectTree.Nodes[_currMapInt].Nodes)
            {
                OverlayObject o = (OverlayObject)obj.Tag;
                if (o.IsVisible(e.ClipRectangle, _currMapInt))
                {
                    o.Draw(e.Graphics);
                }
            }
        }
Example #5
0
        private void OnClickGotoMarker(object sender, EventArgs e)
        {
            if (OverlayObjectTree.SelectedNode?.Parent == null)
            {
                return;
            }

            OverlayObject o = (OverlayObject)OverlayObjectTree.SelectedNode.Tag;

            if (_currMapInt != o.DefMap)
            {
                ResetCheckedMap();
                switch (o.DefMap)
                {
                case 0:
                    feluccaToolStripMenuItem.Checked = true;
                    _currMap = Map.Felucca;
                    break;

                case 1:
                    trammelToolStripMenuItem.Checked = true;
                    _currMap = Map.Trammel;
                    break;

                case 2:
                    ilshenarToolStripMenuItem.Checked = true;
                    _currMap = Map.Ilshenar;
                    break;

                case 3:
                    malasToolStripMenuItem.Checked = true;
                    _currMap = Map.Malas;
                    break;

                case 4:
                    tokunoToolStripMenuItem.Checked = true;
                    _currMap = Map.Tokuno;
                    break;

                case 5:
                    terMurToolStripMenuItem.Checked = true;
                    _currMap = Map.TerMur;
                    break;
                }
                _currMapInt = o.DefMap;
            }
            SetScrollBarValues();
            hScrollBar.Value = (int)Math.Max(0, o.Loc.X - (pictureBox.Right / Zoom / 2));
            vScrollBar.Value = (int)Math.Max(0, o.Loc.Y - (pictureBox.Bottom / Zoom / 2));
            pictureBox.Invalidate();
        }
Example #6
0
        private void OnClickSwitchVisible(object sender, EventArgs e)
        {
            if (OverlayObjectTree.SelectedNode?.Parent == null)
            {
                return;
            }

            OverlayObject o = (OverlayObject)OverlayObjectTree.SelectedNode.Tag;

            o.Visible = !o.Visible;
            OverlayObjectTree.SelectedNode.ForeColor = !o.Visible ? Color.Red : Color.Black;

            OverlayObjectTree.Invalidate();
            pictureBox.Invalidate();
        }
Example #7
0
        private void OnClickGotoMarker(object sender, EventArgs e)
        {
            if (OverlayObjectTree.SelectedNode?.Parent == null)
            {
                return;
            }

            OverlayObject o = (OverlayObject)OverlayObjectTree.SelectedNode.Tag;

            if (_currMapId != o.DefMap)
            {
                ResetCheckedMap();
                SwitchMap(o.DefMap);
                _currMapId = o.DefMap;
            }
            SetScrollBarValues();
            hScrollBar.Value = (int)Math.Max(0, o.Loc.X - (pictureBox.Right / Zoom / 2));
            vScrollBar.Value = (int)Math.Max(0, o.Loc.Y - (pictureBox.Bottom / Zoom / 2));
            pictureBox.Invalidate();
        }
Example #8
0
        private void OnPaint(object sender, PaintEventArgs e)
        {
            if (FormsDesignerHelper.IsInDesignMode())
            {
                return;
            }

            if (PreloadWorker.IsBusy)
            {
                e.Graphics.DrawString("Preloading map. Please wait...", SystemFonts.DefaultFont, Brushes.Black, 60, 60);
                return;
            }

            _map = _currMap.GetImage(hScrollBar.Value >> 3, vScrollBar.Value >> 3,
                                     (int)((e.ClipRectangle.Width / Zoom) + 8) >> 3, (int)((e.ClipRectangle.Height / Zoom) + 8) >> 3,
                                     showStaticsToolStripMenuItem1.Checked);
            ZoomMap(ref _map);
            e.Graphics.DrawImageUnscaledAndClipped(_map, e.ClipRectangle);

            if (showCenterCrossToolStripMenuItem1.Checked)
            {
                using (Brush brush = new SolidBrush(Color.FromArgb(180, Color.White)))
                    using (Pen pen = new Pen(brush))
                    {
                        int x = Round(pictureBox.Width / 2);
                        int y = Round(pictureBox.Height / 2);

                        e.Graphics.DrawLine(pen, x - 4, y, x + 4, y);
                        e.Graphics.DrawLine(pen, x, y - 4, x, y + 4);
                    }
            }

            if (showClientCrossToolStripMenuItem.Checked && Client.Running)
            {
                if (_clientX > hScrollBar.Value &&
                    _clientX < hScrollBar.Value + (e.ClipRectangle.Width / Zoom) &&
                    _clientY > vScrollBar.Value &&
                    _clientY < vScrollBar.Value + (e.ClipRectangle.Height / Zoom) &&
                    _clientMap == _currMapId)
                {
                    using (Brush brush = new SolidBrush(Color.FromArgb(180, Color.Yellow)))
                        using (Pen pen = new Pen(brush))
                        {
                            int x = (int)((_clientX - Round(hScrollBar.Value)) * Zoom);
                            int y = (int)((_clientY - Round(vScrollBar.Value)) * Zoom);

                            e.Graphics.DrawLine(pen, x - 4, y, x + 4, y);
                            e.Graphics.DrawLine(pen, x, y - 4, x, y + 4);

                            e.Graphics.DrawEllipse(pen, x - 2, y - 2, 2 * 2, 2 * 2);
                        }
                }
            }

            if (OverlayObjectTree.Nodes.Count <= 0 || !showMarkersToolStripMenuItem.Checked)
            {
                return;
            }

            foreach (TreeNode obj in OverlayObjectTree.Nodes[_currMapId].Nodes)
            {
                OverlayObject o = (OverlayObject)obj.Tag;
                if (o.IsVisible(e.ClipRectangle, _currMapId))
                {
                    o.Draw(e.Graphics);
                }
            }
        }