Minor updates

dump zd, remove uneeded controls, add parsing for matrix 2nd file (still
no idea the purpose)
This commit is contained in:
Kurt
2015-11-14 08:29:59 -08:00
parent faa7afc881
commit c28053cfd0
4 changed files with 115 additions and 65 deletions

View File

@@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Linq;
@@ -910,9 +911,12 @@ public class MapMatrix
private int Area;
public ushort[] EntryList;
public Entry[] Entries;
public MapMatrix(byte[] data)
public Unknown[] Unknowns;
public byte[] UnkData;
public MapMatrix(byte[][] data)
{
using (BinaryReader br = new BinaryReader(new MemoryStream(data)))
using (BinaryReader br = new BinaryReader(new MemoryStream(data[0])))
{
u0 = br.ReadUInt32();
Width = br.ReadUInt16();
@@ -926,6 +930,8 @@ public MapMatrix(byte[] data)
if (br.BaseStream.Position != br.BaseStream.Length)
uL = br.ReadUInt16();
}
if (data.Length > 1)
parseUnk(UnkData = data[1]);
}
public byte[] Write()
{
@@ -1019,6 +1025,42 @@ public Bitmap Preview(int s, int ColorShift)
return img;
}
}
public string Unk2String()
{
return Unknowns.Aggregate("", (current, l) => current + String.Format("{0}: {1,3} {2,3} {3,3} {4,3}{5,3}", l.Direction, l.p1, l.p2, l.p3, l.p4, Environment.NewLine));
}
private void parseUnk(byte[] data)
{
List<Unknown> unk = new List<Unknown>();
using (var br = new BinaryReader(new MemoryStream(data)))
do
{
unk.Add(new Unknown {
Direction = br.ReadUInt32(),
_1 = br.ReadSingle(),
_2 = br.ReadSingle(),
_3 = br.ReadSingle(),
_4 = br.ReadSingle(),
});
} while (unk.Last().Direction != 0);
unk.RemoveAt(unk.Count()-1);
Unknowns = unk.ToArray();
}
public class Unknown
{
public uint Direction;
public float _1;
public float _2;
public float _3;
public float _4;
public int p1 { get { return (int)_1 / 18; } }
public int p2 { get { return (int)_2 / 18; } }
public int p3 { get { return (int)_3 / 18; } }
public int p4 { get { return (int)_4 / 18; } }
}
}
public class ZoneData
{

View File

@@ -13,7 +13,6 @@ public MapPermView()
InitializeComponent();
}
private ToolTip mapCoord = new ToolTip();
public int mapScale = -1;
public int DrawMap = -1;
public void drawMap(int Map)
@@ -25,7 +24,11 @@ public Bitmap getMapImage(bool crop = false, bool entity = true, bool sliceArea
{
// Load MM
byte[][] MM = CTR.mini.unpackMini(File.ReadAllBytes(OWSE.MapMatrixes[DrawMap]), "MM");
var mm = new MapMatrix(MM[0]);
var mm = OWSE.mm = new MapMatrix(MM);
// Unknown
if (ModifierKeys == Keys.Control)
Clipboard.SetText(mm.Unk2String());
// Load GR TileMaps
for (int i = 0; i < mm.EntryList.Length; i++)
@@ -40,7 +43,6 @@ public Bitmap getMapImage(bool crop = false, bool entity = true, bool sliceArea
baseImage = (Bitmap)img.Clone();
if (sliceArea && mapScale > 3)
{
int area = (40*mapScale);
@@ -55,7 +57,7 @@ public Bitmap getMapImage(bool crop = false, bool entity = true, bool sliceArea
if (crop)
img = Util.TrimBitmap(img);
OWSE.mm = mm;
return img;
}
@@ -109,16 +111,23 @@ private Bitmap overlayEntities(Bitmap img)
catch { }
}
// Overlay map
// Overlay Map Data
// Flyto
{
int x = (int)OWSE.CurrentZone.ZD.pX2;
int y = (int)OWSE.CurrentZone.ZD.pY2;
for (int sx = 0; sx < 1; sx++) // Stretch X
for (int sy = 0; sy < 1; sy++) // Stretch Y
try { Util.LayerImage(img, Resources.FLY, (x + sx) * mapScale, (y + sy) * mapScale, opacity); }
try { Util.LayerImage(img, Resources.FLY, (x + sx) * mapScale, (y + sy) * mapScale, opacity/2); }
catch { }
}
// Unknown
//{
// using(var g = Graphics.FromImage(img))
// foreach (var l in OWSE.mm.LoadLines)
// try { g.DrawLine(new Pen(Color.Red, 4), l.p2 * mapScale, l.p1 * mapScale, l.p4 * mapScale, l.p3 * mapScale); }
// catch {}
//}
return img;
}

View File

@@ -601,6 +601,27 @@ private void B_DumpMaps_Click(object sender, EventArgs e)
CB_LocationID.SelectedIndex = 0;
Util.Alert("All Map images have been dumped to " + folder + ".");
}
private void B_DumpZD_Click(object sender, EventArgs e)
{
if (Util.Prompt(MessageBoxButtons.YesNoCancel, "Export all ZD?") != DialogResult.Yes)
return;
List<string> result = new List<string>();
List<byte[]> data = new List<byte[]>();
for (int i = 0; i < CB_LocationID.Items.Count; i++)
{
CB_LocationID.SelectedIndex = i;
result.Add(Util.getHexString(CurrentZone.ZD.Data));
data.Add(CurrentZone.ZD.Data);
}
if (Util.Prompt(MessageBoxButtons.YesNoCancel, "Write ZDs to file?") == DialogResult.Yes)
File.WriteAllBytes("ZDs.bin", data.SelectMany(z => z).ToArray());
if (Util.Prompt(MessageBoxButtons.YesNoCancel, "Copy ZDs to Clipboard?") == DialogResult.Yes)
Clipboard.SetText(string.Join(Environment.NewLine, result));
CB_LocationID.SelectedIndex = 0;
}
private void pasteScript(object sender, EventArgs e)
{
@@ -621,14 +642,6 @@ private void pasteScript(object sender, EventArgs e)
}
// Coordinate Simplifiers
private void changeNPC_X(object sender, EventArgs e)
{
L_NpX.Text = (NUD_NX.Value / 18).ToString("F");
}
private void changeNPC_Y(object sender, EventArgs e)
{
L_NpY.Text = (NUD_NY.Value / 18).ToString("F");
}
private void changeWarp_X(object sender, EventArgs e)
{
L_WpX.Text = (NUD_WX.Value / 18).ToString();
@@ -650,5 +663,6 @@ private void closingForm(object sender, FormClosingEventArgs e)
mapView.Close();
mapView.Dispose();
}
}
}

View File

@@ -60,8 +60,6 @@ private void InitializeComponent()
this.L_FE = new System.Windows.Forms.Label();
this.tb_Overworld = new System.Windows.Forms.TabPage();
this.GB_N = new System.Windows.Forms.GroupBox();
this.L_NpY = new System.Windows.Forms.Label();
this.L_NpX = new System.Windows.Forms.Label();
this.NUD_NMove2 = new System.Windows.Forms.NumericUpDown();
this.L_Move2 = new System.Windows.Forms.Label();
this.NUD_NMove1 = new System.Windows.Forms.NumericUpDown();
@@ -141,6 +139,7 @@ private void InitializeComponent()
this.tb_File5 = new System.Windows.Forms.TabPage();
this.L_File5TabData = new System.Windows.Forms.Label();
this.tb_RAW = new System.Windows.Forms.TabPage();
this.L_ZD = new System.Windows.Forms.Label();
this.L_File3 = new System.Windows.Forms.Label();
this.L_ZDMaster = new System.Windows.Forms.Label();
this.L_File5 = new System.Windows.Forms.Label();
@@ -152,7 +151,6 @@ private void InitializeComponent()
this.RTB_OWSC = new System.Windows.Forms.RichTextBox();
this.RTB_Encounter = new System.Windows.Forms.RichTextBox();
this.RTB_MapSC = new System.Windows.Forms.RichTextBox();
this.B_Map = new System.Windows.Forms.Button();
this.tb_Dev = new System.Windows.Forms.TabPage();
this.L_DeComp = new System.Windows.Forms.Label();
this.RTB_CompressedScript = new System.Windows.Forms.RichTextBox();
@@ -164,9 +162,10 @@ private void InitializeComponent()
this.B_DumpWarp = new System.Windows.Forms.Button();
this.B_DumpNPC = new System.Windows.Forms.Button();
this.B_DumpFurniture = new System.Windows.Forms.Button();
this.B_Map = new System.Windows.Forms.Button();
this.L_ZDPreview = new System.Windows.Forms.Label();
this.B_HLCMD = new System.Windows.Forms.Button();
this.L_ZD = new System.Windows.Forms.Label();
this.B_DumpZD = new System.Windows.Forms.Button();
this.tabControl1.SuspendLayout();
this.tb_ZoneData.SuspendLayout();
this.tb_OWSC.SuspendLayout();
@@ -598,8 +597,6 @@ private void InitializeComponent()
//
// GB_N
//
this.GB_N.Controls.Add(this.L_NpY);
this.GB_N.Controls.Add(this.L_NpX);
this.GB_N.Controls.Add(this.NUD_NMove2);
this.GB_N.Controls.Add(this.L_Move2);
this.GB_N.Controls.Add(this.NUD_NMove1);
@@ -633,26 +630,6 @@ private void InitializeComponent()
this.GB_N.TabStop = false;
this.GB_N.Text = "Info:";
//
// L_NpY
//
this.L_NpY.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.L_NpY.AutoSize = true;
this.L_NpY.Location = new System.Drawing.Point(152, 200);
this.L_NpY.Name = "L_NpY";
this.L_NpY.Size = new System.Drawing.Size(29, 13);
this.L_NpY.TabIndex = 459;
this.L_NpY.Text = "HEX";
//
// L_NpX
//
this.L_NpX.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.L_NpX.AutoSize = true;
this.L_NpX.Location = new System.Drawing.Point(152, 174);
this.L_NpX.Name = "L_NpX";
this.L_NpX.Size = new System.Drawing.Size(29, 13);
this.L_NpX.TabIndex = 458;
this.L_NpX.Text = "HEX";
//
// NUD_NMove2
//
this.NUD_NMove2.Location = new System.Drawing.Point(234, 146);
@@ -834,7 +811,6 @@ private void InitializeComponent()
this.NUD_NY.Name = "NUD_NY";
this.NUD_NY.Size = new System.Drawing.Size(53, 20);
this.NUD_NY.TabIndex = 441;
this.NUD_NY.ValueChanged += new System.EventHandler(this.changeNPC_Y);
//
// L_NY
//
@@ -856,7 +832,6 @@ private void InitializeComponent()
this.NUD_NX.Name = "NUD_NX";
this.NUD_NX.Size = new System.Drawing.Size(53, 20);
this.NUD_NX.TabIndex = 439;
this.NUD_NX.ValueChanged += new System.EventHandler(this.changeNPC_X);
//
// L_NX
//
@@ -1523,6 +1498,16 @@ private void InitializeComponent()
this.tb_RAW.Text = "RAW";
this.tb_RAW.UseVisualStyleBackColor = true;
//
// L_ZD
//
this.L_ZD.AutoSize = true;
this.L_ZD.Font = new System.Drawing.Font("Courier New", 8.25F);
this.L_ZD.Location = new System.Drawing.Point(140, 346);
this.L_ZD.Name = "L_ZD";
this.L_ZD.Size = new System.Drawing.Size(35, 28);
this.L_ZD.TabIndex = 430;
this.L_ZD.Text = "X: ~\r\nY: ~";
//
// L_File3
//
this.L_File3.Location = new System.Drawing.Point(70, 83);
@@ -1629,18 +1614,9 @@ private void InitializeComponent()
this.RTB_MapSC.TabIndex = 419;
this.RTB_MapSC.Text = "00 11 22 33 44 55 66 77 88 99 AA BB CC DD EE FF";
//
// B_Map
//
this.B_Map.Location = new System.Drawing.Point(318, 5);
this.B_Map.Name = "B_Map";
this.B_Map.Size = new System.Drawing.Size(89, 23);
this.B_Map.TabIndex = 420;
this.B_Map.Text = "Show Map";
this.B_Map.UseVisualStyleBackColor = true;
this.B_Map.Click += new System.EventHandler(this.B_Map_Click);
//
// tb_Dev
//
this.tb_Dev.Controls.Add(this.B_DumpZD);
this.tb_Dev.Controls.Add(this.L_DeComp);
this.tb_Dev.Controls.Add(this.RTB_CompressedScript);
this.tb_Dev.Controls.Add(this.RTB_DecompressedScript);
@@ -1757,6 +1733,16 @@ private void InitializeComponent()
this.B_DumpFurniture.UseVisualStyleBackColor = true;
this.B_DumpFurniture.Click += new System.EventHandler(this.B_DumpFurniture_Click);
//
// B_Map
//
this.B_Map.Location = new System.Drawing.Point(318, 5);
this.B_Map.Name = "B_Map";
this.B_Map.Size = new System.Drawing.Size(89, 23);
this.B_Map.TabIndex = 420;
this.B_Map.Text = "Show Map";
this.B_Map.UseVisualStyleBackColor = true;
this.B_Map.Click += new System.EventHandler(this.B_Map_Click);
//
// L_ZDPreview
//
this.L_ZDPreview.AutoSize = true;
@@ -1776,15 +1762,15 @@ private void InitializeComponent()
this.B_HLCMD.UseVisualStyleBackColor = true;
this.B_HLCMD.Click += new System.EventHandler(this.B_HLCMD_Click);
//
// L_ZD
// B_DumpZD
//
this.L_ZD.AutoSize = true;
this.L_ZD.Font = new System.Drawing.Font("Courier New", 8.25F);
this.L_ZD.Location = new System.Drawing.Point(140, 346);
this.L_ZD.Name = "L_ZD";
this.L_ZD.Size = new System.Drawing.Size(35, 28);
this.L_ZD.TabIndex = 430;
this.L_ZD.Text = "X: ~\r\nY: ~";
this.B_DumpZD.Location = new System.Drawing.Point(149, 51);
this.B_DumpZD.Name = "B_DumpZD";
this.B_DumpZD.Size = new System.Drawing.Size(89, 39);
this.B_DumpZD.TabIndex = 431;
this.B_DumpZD.Text = "Dump all ZD";
this.B_DumpZD.UseVisualStyleBackColor = true;
this.B_DumpZD.Click += new System.EventHandler(this.B_DumpZD_Click);
//
// OWSE
//
@@ -1991,8 +1977,6 @@ private void InitializeComponent()
private System.Windows.Forms.Label L_WY;
private System.Windows.Forms.NumericUpDown NUD_WX;
private System.Windows.Forms.Label L_WX;
private System.Windows.Forms.Label L_NpY;
private System.Windows.Forms.Label L_NpX;
private System.Windows.Forms.NumericUpDown NUD_FWY;
private System.Windows.Forms.Label L_FWY;
private System.Windows.Forms.NumericUpDown NUD_FWX;
@@ -2011,6 +1995,7 @@ private void InitializeComponent()
private System.Windows.Forms.Label L_T2X;
private System.Windows.Forms.Button B_Map;
private System.Windows.Forms.Label L_ZD;
private System.Windows.Forms.Button B_DumpZD;
}
}