public void FullUpdate() { if (!Active) { return; } if (m_Background != null) { m_Background.Dispose(); } m_Background = new Bitmap(this.Width, this.Height); int xLong = 0, yLat = 0; int xMins = 0, yMins = 0; bool xEast = false, ySouth = false; int w = (this.Width) >> 3; int h = (this.Height) >> 3; int xtrans = this.Width / 2; int ytrans = this.Height / 2; Point3D focus = this.FocusMobile.Position; Point offset = new Point(focus.X & 7, focus.Y & 7); Point mapOrigin = new Point((focus.X >> 3) - (w / 2), (focus.Y >> 3) - (h / 2)); Point pntPlayer = new Point((focus.X) - (mapOrigin.X << 3) - offset.X, (focus.Y) - (mapOrigin.Y << 3) - offset.Y); Graphics gfx = Graphics.FromImage(m_Background); gfx.FillRectangle(Brushes.Black, 0, 0, this.Width, this.Height); gfx.TranslateTransform(-xtrans, -ytrans, MatrixOrder.Append); gfx.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.NearestNeighbor; gfx.PageUnit = GraphicsUnit.Pixel; gfx.ScaleTransform(1.5f, 1.5f, MatrixOrder.Append); gfx.RotateTransform(45, MatrixOrder.Append); gfx.TranslateTransform(xtrans, ytrans, MatrixOrder.Append); Ultima.Map map = Map.GetMap(this.FocusMobile.Map); if (map == null) { map = Ultima.Map.Felucca; } gfx.DrawImage(map.GetImage(mapOrigin.X, mapOrigin.Y, w + offset.X, h + offset.Y, true), -offset.X, -offset.Y); gfx.ScaleTransform(1.0f, 1.0f, MatrixOrder.Append); ArrayList regions = new ArrayList(); ArrayList mButtons = new ArrayList(); if (this.Width > this.Height) { regions = RegionList(focus.X, focus.Y, this.Width); mButtons = ButtonList(focus.X, focus.Y, this.Width); } else { regions = RegionList(focus.X, focus.Y, this.Height); mButtons = ButtonList(focus.X, focus.Y, this.Height); } foreach (Assistant.MapUO.Region region in regions) { gfx.DrawRectangle(Pens.LimeGreen, (region.X) - ((mapOrigin.X << 3) + offset.X), (region.Y) - ((mapOrigin.Y << 3) + offset.Y), region.Width, region.Length); } gfx.DrawLine(Pens.Silver, pntPlayer.X - 2, pntPlayer.Y - 2, pntPlayer.X + 2, pntPlayer.Y + 2); gfx.DrawLine(Pens.Silver, pntPlayer.X - 2, pntPlayer.Y + 2, pntPlayer.X + 2, pntPlayer.Y - 2); gfx.FillRectangle(Brushes.Red, pntPlayer.X, pntPlayer.Y, 1, 1); //gfx.DrawEllipse( Pens.Silver, pntPlayer.X - 2, pntPlayer.Y - 2, 4, 4 ); gfx.DrawString("W", m_BoldFont, Brushes.Red, pntPlayer.X - 35, pntPlayer.Y - 5); gfx.DrawString("E", m_BoldFont, Brushes.Red, pntPlayer.X + 25, pntPlayer.Y - 5); gfx.DrawString("N", m_BoldFont, Brushes.Red, pntPlayer.X - 5, pntPlayer.Y - 35); gfx.DrawString("S", m_BoldFont, Brushes.Red, pntPlayer.X - 5, pntPlayer.Y + 25); gfx.ResetTransform(); if (Format(new Point(focus.X, focus.Y), Ultima.Map.Felucca, ref xLong, ref yLat, ref xMins, ref yMins, ref xEast, ref ySouth)) { string locString = String.Format("{0}°{1}'{2} {3}°{4}'{5} | ({6},{7})", yLat, yMins, ySouth ? "S" : "N", xLong, xMins, xEast ? "E" : "W", World.Player.Position.X, World.Player.Position.Y); SizeF size = gfx.MeasureString(locString, m_RegFont); gfx.FillRectangle(Brushes.Wheat, 0, 0, size.Width + 2, size.Height + 2); gfx.DrawRectangle(Pens.Black, 0, 0, size.Width + 2, size.Height + 2); gfx.DrawString(locString, m_RegFont, Brushes.Black, 1, 1); } gfx.ResetTransform(); gfx.Dispose(); this.Refresh(); }
/// <summary> /// Creates an image of the map. /// </summary> /// <param name="statics">Indicitaes whether statics should be drawn, too</param> /// <returns>An image of map with the same size</returns> public System.Drawing.Image ToImage(bool statics) { return(m_MapObject.GetImage(0, 0, m_MapObject.Width >> 3, m_MapObject.Height >> 3, statics)); // the size is measured in blocks! }
private void onPaint(object sender, PaintEventArgs e) { if (!Loaded) { return; } if (showMap1ToolStripMenuItem.Checked) { map = origmap.GetImage(hScrollBar.Value >> 3, vScrollBar.Value >> 3, (int)((e.ClipRectangle.Width / Zoom) + 8) >> 3, (int)((e.ClipRectangle.Height / Zoom) + 8) >> 3, true); } else { map = currmap.GetImage(hScrollBar.Value >> 3, vScrollBar.Value >> 3, (int)((e.ClipRectangle.Width / Zoom) + 8) >> 3, (int)((e.ClipRectangle.Height / Zoom) + 8) >> 3, true); } if (currmap != null) { if (showDifferencesToolStripMenuItem.Checked) { using (Graphics mapg = Graphics.FromImage(map)) { int maxx = ((int)((e.ClipRectangle.Width / Zoom) + 8) >> 3) + (hScrollBar.Value >> 3); int maxy = ((int)((e.ClipRectangle.Height / Zoom) + 8) >> 3) + (vScrollBar.Value >> 3); if (maxx > (origmap.Width >> 3)) { maxx = (origmap.Width >> 3); } if (maxy > (origmap.Height >> 3)) { maxy = (origmap.Height >> 3); } int gx = 0, gy = 0; for (int x = (hScrollBar.Value >> 3); x < maxx; x++, gx += 8) { gy = 0; for (int y = (vScrollBar.Value >> 3); y < maxy; y++, gy += 8) { for (int xb = 0; xb < 8; xb++) { for (int yb = 0; yb < 8; yb++) { if (diffs[x][y][xb][yb]) { mapg.DrawRectangle(redpen, (gx + xb), (gy + yb), 1, 1); mapg.DrawRectangle(redpen, (gx + xb), 0, 1, 2); mapg.DrawRectangle(redpen, 0, (gy + yb), 2, 1); } } } } } mapg.Save(); } } } if (markDiffToolStripMenuItem.Checked) { Ultima.Map drawmap; if (showMap1ToolStripMenuItem.Checked) { drawmap = origmap; } else { drawmap = currmap; } int count = drawmap.Tiles.Patch.LandBlocksCount + drawmap.Tiles.Patch.StaticBlocksCount; if (count > 0) { using (Graphics mapg = Graphics.FromImage(map)) { int maxx = ((int)((e.ClipRectangle.Width / Zoom) + 8) >> 3) + (hScrollBar.Value >> 3); int maxy = ((int)((e.ClipRectangle.Height / Zoom) + 8) >> 3) + (vScrollBar.Value >> 3); if (maxx > drawmap.Width >> 3) { maxx = drawmap.Width >> 3; } if (maxy > drawmap.Height >> 3) { maxy = drawmap.Height >> 3; } int gx = 0, gy = 0; for (int x = (hScrollBar.Value >> 3); x < maxx; x++, gx += 8) { gy = 0; for (int y = (vScrollBar.Value >> 3); y < maxy; y++, gy += 8) { if (drawmap.Tiles.Patch.IsLandBlockPatched(x, y)) { mapg.FillRectangle(Brushes.Azure, gx, gy, 8, 8); mapg.FillRectangle(Brushes.Azure, gx, 0, 8, 2); mapg.FillRectangle(Brushes.Azure, 0, gy, 2, 8); } if (drawmap.Tiles.Patch.IsStaticBlockPatched(x, y)) { mapg.FillRectangle(Brushes.Azure, gx, gy, 8, 8); mapg.FillRectangle(Brushes.Azure, gx, 0, 8, 2); mapg.FillRectangle(Brushes.Azure, 0, gy, 2, 8); } } } } } } ZoomMap(ref map); e.Graphics.DrawImageUnscaledAndClipped(map, e.ClipRectangle); }
private void onPaint(object sender, PaintEventArgs e) { if (!Loaded) { return; } if (showMap1ToolStripMenuItem.Checked) { map = origmap.GetImage(hScrollBar.Value >> 3, vScrollBar.Value >> 3, (int)((e.ClipRectangle.Width / Zoom) + 8) >> 3, (int)((e.ClipRectangle.Height / Zoom) + 8) >> 3, true); } else { map = currmap.GetImage(hScrollBar.Value >> 3, vScrollBar.Value >> 3, (int)((e.ClipRectangle.Width / Zoom) + 8) >> 3, (int)((e.ClipRectangle.Height / Zoom) + 8) >> 3, true); } if (currmap != null) { if (showDifferencesToolStripMenuItem.Checked) { using (Graphics mapg = Graphics.FromImage(map)) { int maxx = ((int)((e.ClipRectangle.Width / Zoom) + 8) >> 3) + (hScrollBar.Value >> 3); int maxy = ((int)((e.ClipRectangle.Height / Zoom) + 8) >> 3) + (vScrollBar.Value >> 3); if (maxx > (origmap.Width >> 3)) { maxx = (origmap.Width >> 3); } if (maxy > (origmap.Height >> 3)) { maxy = (origmap.Height >> 3); } int gx = 0, gy = 0; for (int x = (hScrollBar.Value >> 3); x < maxx; x++, gx += 8) { gy = 0; for (int y = (vScrollBar.Value >> 3); y < maxy; y++, gy += 8) { for (int xb = 0; xb < 8; xb++) { for (int yb = 0; yb < 8; yb++) { if (diffs[x][y][xb][yb]) { mapg.DrawRectangle(redpen, (gx + xb), (gy + yb), 1, 1); mapg.DrawRectangle(redpen, (gx + xb), 0, 1, 2); mapg.DrawRectangle(redpen, 0, (gy + yb), 2, 1); } } } //Ultima.Tile[] customTiles = currmap.Tiles.GetLandBlock(x, y); //Ultima.Tile[] origTiles = origmap.Tiles.GetLandBlock(x, y); //for (int xb = 0; xb < 8; xb++) //{ // for (int yb = 0; yb < 8; yb++) // { // if ((customTiles[((yb & 0x7) << 3) + (xb & 0x7)].ID != origTiles[((yb & 0x7) << 3) + (xb & 0x7)].ID) // || (customTiles[((yb & 0x7) << 3) + (xb & 0x7)].Z != origTiles[((yb & 0x7) << 3) + (xb & 0x7)].Z)) // { // mapg.DrawRectangle(Pens.Red, (gx + xb), (gy + yb), 1, 1); // mapg.DrawRectangle(Pens.Red, (gx + xb), 0, 1, 2); // mapg.DrawRectangle(Pens.Red, 0, (gy + yb), 2, 1); // } // } //} //Ultima.HuedTile[][][] customStatics = currmap.Tiles.GetStaticBlock(x, y); //Ultima.HuedTile[][][] origStatics = origmap.Tiles.GetStaticBlock(x, y); //for (int xb = 0; xb < 8; xb++) //{ // for (int yb = 0; yb < 8; yb++) // { // if (customStatics[xb][yb].Length != origStatics[xb][yb].Length) // { // mapg.DrawRectangle(Pens.Red, gx + xb, gy + yb, 1, 1); // mapg.DrawRectangle(Pens.Red, (gx + xb), 0, 1, 2); // mapg.DrawRectangle(Pens.Red, 0, (gy + yb), 2, 1); // } // else // { // for (int i = 0; i < customStatics[xb][yb].Length; i++) // { // if ((customStatics[xb][yb][i].ID != origStatics[xb][yb][i].ID) // || (customStatics[xb][yb][i].Z != origStatics[xb][yb][i].Z) // || (customStatics[xb][yb][i].Hue != origStatics[xb][yb][i].Hue)) // { // mapg.DrawRectangle(Pens.Red, gx + xb, gy + yb, 1, 1); // mapg.DrawRectangle(Pens.Red, (gx + xb), 0, 1, 2); // mapg.DrawRectangle(Pens.Red, 0, (gy + yb), 2, 1); // break; // } // } // } // } //} } } mapg.Save(); } } } if (markDiffToolStripMenuItem.Checked) { Ultima.Map drawmap; if (showMap1ToolStripMenuItem.Checked) { drawmap = origmap; } else { drawmap = currmap; } int count = drawmap.Tiles.Patch.LandBlocksCount + drawmap.Tiles.Patch.StaticBlocksCount; if (count > 0) { using (Graphics mapg = Graphics.FromImage(map)) { int maxx = ((int)((e.ClipRectangle.Width / Zoom) + 8) >> 3) + (hScrollBar.Value >> 3); int maxy = ((int)((e.ClipRectangle.Height / Zoom) + 8) >> 3) + (vScrollBar.Value >> 3); if (maxx > drawmap.Width >> 3) { maxx = drawmap.Width >> 3; } if (maxy > drawmap.Height >> 3) { maxy = drawmap.Height >> 3; } int gx = 0, gy = 0; for (int x = (hScrollBar.Value >> 3); x < maxx; x++, gx += 8) { gy = 0; for (int y = (vScrollBar.Value >> 3); y < maxy; y++, gy += 8) { if (drawmap.Tiles.Patch.IsLandBlockPatched(x, y)) { mapg.FillRectangle(Brushes.Azure, gx, gy, 8, 8); mapg.FillRectangle(Brushes.Azure, gx, 0, 8, 2); mapg.FillRectangle(Brushes.Azure, 0, gy, 2, 8); } if (drawmap.Tiles.Patch.IsStaticBlockPatched(x, y)) { mapg.FillRectangle(Brushes.Azure, gx, gy, 8, 8); mapg.FillRectangle(Brushes.Azure, gx, 0, 8, 2); mapg.FillRectangle(Brushes.Azure, 0, gy, 2, 8); } } } } } } ZoomMap(ref map); e.Graphics.DrawImageUnscaledAndClipped(map, e.ClipRectangle); }
protected override void OnPaint(PaintEventArgs e) { if (Current == null) { return; } position = Current.Position; Point point = new Point(position.X % 8, position.Y % 8); Point start = new Point((position.X / 8) - (Width / 16), (position.Y / 8) - (Height / 16)); Point center = new Point((position.X - (start.X * 8)) - point.X, (position.Y - (start.Y * 8)) - point.Y); e.Graphics.TranslateTransform(-Width / 2F, -Height / 2F, MatrixOrder.Append); e.Graphics.InterpolationMode = InterpolationMode.NearestNeighbor; e.Graphics.ScaleTransform(1.5F, 1.5F, MatrixOrder.Append); e.Graphics.RotateTransform(45F, MatrixOrder.Append); e.Graphics.TranslateTransform(Width / 2F, Height / 2F, MatrixOrder.Append); Ultima.Map map = Map.GetMap(Current.Map) ?? Ultima.Map.Trammel; e.Graphics.DrawImage(map.GetImage(start.X, start.Y, Width / 8 + point.X, Height / 8 + point.Y, true), -point.X, -point.Y); e.Graphics.ScaleTransform(1F, 1F, MatrixOrder.Append); e.Graphics.FillRectangle(GetBrush(Current), center.X - 1, center.Y - 1, 2, 2); if (Current != World.Player) { e.Graphics.DrawString(Current.GetName(), Font, Brushes.Silver, center.X, center.Y); } party.Clear(); foreach (Serial serial in Party) { Mobile mobile = World.FindMobile(serial); Point3D pos = mobile != null ? mobile.Position : Point3D.Zero; party.Add(serial, pos); if (pos != Point3D.Zero && mobile != Current) { DrawPoint(e.Graphics, pos, mobile != null ? mobile.GetName() : "(Unknown)", GetBrush(mobile), center); } } if ((PositionCheck.InFire || PositionCheck.InKhaldun) && ConfigEx.GetElement(true, "RadarArcheologyGrid")) { for (int x = center.X - position.X + (position.X - Width) + 40 - (position.X - Width) % 40; x < Width; x += 40) { e.Graphics.DrawLine(Pens.Gray, x, center.Y - Height, x, center.Y + Height); } for (int y = center.Y - position.Y + (position.Y - Height) + 40 - (position.Y - Height) % 40; y < Height; y += 40) { e.Graphics.DrawLine(Pens.Gray, center.X - Width, y, center.X + Width, y); } } foreach (Item sos in World.Player.Backpack.FindItems(0x14ED)) { FishingSOS.SOSInfo info; if (FishingSOS.List.TryGetValue(sos.Serial, out info) && info.Felucca.HasValue) { DrawPoint(e.Graphics, info.Location, null, Brushes.Gold, center); } } e.Graphics.ResetTransform(); e.Graphics.DrawString("W", bigFont, Brushes.DeepPink, 0, 0); e.Graphics.DrawString("S", bigFont, Brushes.DeepPink, 0, Height - bigFont.Height); e.Graphics.DrawString("N", bigFont, Brushes.DeepPink, Width - bigFont.Height, 0); e.Graphics.DrawString("E", bigFont, Brushes.DeepPink, Width - bigFont.Height, Height - bigFont.Height); position = World.Player.Position; }