using System; using System.Collections.Generic; using System.ComponentModel; using System.Drawing; using System.Text; using System.Windows.Forms; using File=System.IO.File; using StreamReader=System.IO.StreamReader; using MemoryStream=System.IO.MemoryStream; using BinaryReader=System.IO.BinaryReader; using BinaryWriter=System.IO.BinaryWriter; namespace FalloutClient { public partial class DebugEditor : Form { [System.Runtime.InteropServices.StructLayout(System.Runtime.InteropServices.LayoutKind.Explicit)] private struct ByteConverter { [System.Runtime.InteropServices.FieldOffset(0)] private int i; [System.Runtime.InteropServices.FieldOffset(0)] private float f; public int GetAsInt(float f) { this.f=f; return i; } public float GetAsFloat(int i) { this.i=i; return f; } public byte[] GetAsBytes(ulong ul) { byte[] b=new byte[8]; for(int i=0;i<8;i++) b[i]=(byte)((ul&((ulong)0xff<<(i*8)))>>(i*8)); return b; } } private static ByteConverter converter=new ByteConverter(); private enum Mode { Globals, MapVars, SGlobals, Arrays, Critters } private readonly EditorConnection connection; private Mode mode; private readonly Dictionary GlobNames=new Dictionary(); private readonly Dictionary CritNames=new Dictionary(); private void Redraw() { dataGridView1.SuspendLayout(); dataGridView1.Rows.Clear(); switch(mode) { case Mode.Globals: Column2.ReadOnly=false; Column3.ReadOnly=false; Column2.HeaderText="Value (Int)"; Column3.HeaderText="Value (Float)"; bEdit.Enabled=false; for(int i=0;i0xffffffff?new string(System.Text.ASCIIEncoding.ASCII.GetChars(converter.GetAsBytes(connection.SGlobalKeys[i]))):("0x"+connection.SGlobalKeys[i].ToString("x")); dataGridView1.Rows.Add(s, "", connection.sGlobals[i], converter.GetAsFloat(connection.sGlobals[i])); } break; case Mode.Arrays: Column2.ReadOnly=true; Column3.ReadOnly=true; Column2.HeaderText="Array length"; Column3.HeaderText="Element size"; bEdit.Enabled=true; for(int i=0;i(bytes, 0)); break; } } br.Close(); strings=EditorWindow.ShowEditor(null, types, strings); if(strings!=null) { connection.WriteDataType(DataTypeSend.SetArray); connection.WriteInt(i); ms=new MemoryStream(connection.ArrayLengths[i]*connection.ArrayDataSizes[i]); BinaryWriter bw=new BinaryWriter(ms); for(int j=0;j