From fd41cd3e5efb8864e2f0c9131dba4b0f099bc12f Mon Sep 17 00:00:00 2001 From: Kurt Date: Wed, 11 Nov 2015 19:16:17 -0800 Subject: [PATCH] Further map visualization improvements now stretching furniture/warps/triggers; warps are no longer using their absolute coordinates (0.5 -> 0.0) for visual appeal. --- pk3DS/Structs.cs | 8 ++-- pk3DS/Subforms/MapPermView.Designer.cs | 3 +- pk3DS/Subforms/MapPermView.cs | 54 +++++++++++++++++++++----- 3 files changed, 50 insertions(+), 15 deletions(-) diff --git a/pk3DS/Structs.cs b/pk3DS/Structs.cs index 9768f83..9e7219b 100644 --- a/pk3DS/Structs.cs +++ b/pk3DS/Structs.cs @@ -1316,8 +1316,8 @@ public class EntityTrigger1 public int X { get { return BitConverter.ToUInt16(Raw, 0x0C); } set { BitConverter.GetBytes((ushort)value).CopyTo(Raw, 0x0C); } } public int Y { get { return BitConverter.ToUInt16(Raw, 0x0E); } set { BitConverter.GetBytes((ushort)value).CopyTo(Raw, 0x0E); } } - public int U10 { get { return BitConverter.ToInt16(Raw, 0x10); } set { BitConverter.GetBytes((short)value).CopyTo(Raw, 0x10); } } - public int U12 { get { return BitConverter.ToInt16(Raw, 0x12); } set { BitConverter.GetBytes((short)value).CopyTo(Raw, 0x12); } } + public int Width { get { return BitConverter.ToInt16(Raw, 0x10); } set { BitConverter.GetBytes((short)value).CopyTo(Raw, 0x10); } } + public int Height { get { return BitConverter.ToInt16(Raw, 0x12); } set { BitConverter.GetBytes((short)value).CopyTo(Raw, 0x12); } } public int U14 { get { return BitConverter.ToInt16(Raw, 0x14); } set { BitConverter.GetBytes((short)value).CopyTo(Raw, 0x14); } } public int U16 { get { return BitConverter.ToInt16(Raw, 0x16); } set { BitConverter.GetBytes((short)value).CopyTo(Raw, 0x16); } } @@ -1349,8 +1349,8 @@ public class EntityTrigger2 public int X { get { return BitConverter.ToUInt16(Raw, 0x0C); } set { BitConverter.GetBytes((ushort)value).CopyTo(Raw, 0x0C); } } public int Y { get { return BitConverter.ToUInt16(Raw, 0x0E); } set { BitConverter.GetBytes((ushort)value).CopyTo(Raw, 0x0E); } } - public int U10 { get { return BitConverter.ToInt16(Raw, 0x10); } set { BitConverter.GetBytes((short)value).CopyTo(Raw, 0x10); } } - public int U12 { get { return BitConverter.ToInt16(Raw, 0x12); } set { BitConverter.GetBytes((short)value).CopyTo(Raw, 0x12); } } + public int Width { get { return BitConverter.ToInt16(Raw, 0x10); } set { BitConverter.GetBytes((short)value).CopyTo(Raw, 0x10); } } + public int Height { get { return BitConverter.ToInt16(Raw, 0x12); } set { BitConverter.GetBytes((short)value).CopyTo(Raw, 0x12); } } public int U14 { get { return BitConverter.ToInt16(Raw, 0x14); } set { BitConverter.GetBytes((short)value).CopyTo(Raw, 0x14); } } public int U16 { get { return BitConverter.ToInt16(Raw, 0x16); } set { BitConverter.GetBytes((short)value).CopyTo(Raw, 0x16); } } diff --git a/pk3DS/Subforms/MapPermView.Designer.cs b/pk3DS/Subforms/MapPermView.Designer.cs index 81573fe..8a24a66 100644 --- a/pk3DS/Subforms/MapPermView.Designer.cs +++ b/pk3DS/Subforms/MapPermView.Designer.cs @@ -162,9 +162,10 @@ private void InitializeComponent() this.Controls.Add(this.NUD_Scale); this.Controls.Add(this.L_Flavor); this.Controls.Add(this.NUD_Flavor); + this.MinimumSize = new System.Drawing.Size(505, 505); this.Name = "MapPermView"; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; - this.Text = "MapPermView"; + this.Text = "Map Viewer"; this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.MapPermView_FormClosing); this.PAN_MAP.ResumeLayout(false); this.PAN_MAP.PerformLayout(); diff --git a/pk3DS/Subforms/MapPermView.cs b/pk3DS/Subforms/MapPermView.cs index 3a2a00e..e3b6b84 100644 --- a/pk3DS/Subforms/MapPermView.cs +++ b/pk3DS/Subforms/MapPermView.cs @@ -40,17 +40,51 @@ public Image getMapImage(bool crop = false, bool entity = true) if (entity && mapScale == 8) { + const float opacity = 0.5f; // Overlay every... overworld entity - foreach (var f in OWSE.CurrentZone.Entities.Furniture) - try { Util.LayerImage(img, Resources.F, f.X * mapScale, f.Y * mapScale, 0.8); } catch {} - foreach (var f in OWSE.CurrentZone.Entities.NPCs) - try { Util.LayerImage(img, Resources.N, f.X * mapScale, f.Y * mapScale, 0.8); } catch {} - foreach (var f in OWSE.CurrentZone.Entities.Warps) - try { Util.LayerImage(img, Resources.W, (int)(f.pX * mapScale), (int)(f.pY * mapScale), 0.8); } catch {} - foreach (var f in OWSE.CurrentZone.Entities.Triggers1) - try { Util.LayerImage(img, Resources.T1, f.X * mapScale, f.Y * mapScale, 0.8); } catch {} - foreach (var f in OWSE.CurrentZone.Entities.Triggers2) - try { Util.LayerImage(img, Resources.T2, f.X * mapScale, f.Y * mapScale, 0.8); } catch { } + foreach (var e in OWSE.CurrentZone.Entities.Furniture) + { + int x = e.X; + int y = e.Y; + for (int sx = 0; sx < e.WX; sx++) // Stretch X + for (int sy = 0; sy < e.WY; sy++) // Stretch Y + try { Util.LayerImage(img, Resources.F, (x+sx)*mapScale, (y+sy)*mapScale, opacity); } + catch { } + } + foreach (var e in OWSE.CurrentZone.Entities.NPCs) + { + int x = e.X; + int y = e.Y; + try { Util.LayerImage(img, Resources.N, x * mapScale, y * mapScale, opacity); } + catch { } + } + foreach (var e in OWSE.CurrentZone.Entities.Warps) + { + int x = (int)e.pX; // shifted warps look weird + int y = (int)e.pY; // shifted warps look weird + for (int sx = 0; sx < e.Width; sx++) // Stretch X + for (int sy = 0; sy < e.Height; sy++) // Stretch Y + try { Util.LayerImage(img, Resources.W, ((x+sx)*mapScale), ((y+sy)*mapScale), opacity); } + catch { } + } + foreach (var e in OWSE.CurrentZone.Entities.Triggers1) + { + int x = e.X; + int y = e.Y; + for (int sx = 0; sx < e.Width; sx++) // Stretch X + for (int sy = 0; sy < e.Height; sy++) // Stretch Y + try { Util.LayerImage(img, Resources.T1, (x + sx) * mapScale, (y + sy) * mapScale, opacity); } + catch { } + } + foreach (var e in OWSE.CurrentZone.Entities.Triggers2) + { + int x = e.X; + int y = e.Y; + for (int sx = 0; sx < e.Width; sx++) // Stretch X + for (int sy = 0; sy < e.Height; sy++) // Stretch Y + try { Util.LayerImage(img, Resources.T2, (x + sx) * mapScale, (y + sy) * mapScale, opacity); } + catch { } + } } if (crop) img = Util.TrimBitmap((Bitmap)img);