WPF is probably the only decent GUI library in .NET, indeed.
Just some tips on your code:
* Use enums - i.e. object type
Code:
namespace WowPacketParser.Enums
{
public enum ObjectType : uint
{
Object = 0,
Item = 1,
Container = 2,
Unit = 3,
Player = 4,
GameObject = 5,
DynamicObject = 6,
Corpse = 7
}
}
* Use vectors - position X/Y/Z (Vector3) (and O (Vector4))
Code:
using System.Runtime.InteropServices;
namespace WowPacketParser.Misc
{
[StructLayout(LayoutKind.Explicit, Size = 8)]
public struct Vector2
{
public Vector2(float x, float y)
{
X = x;
Y = y;
}
[FieldOffset(0)]
public float X;
[FieldOffset(4)]
public float Y;
public override string ToString()
{
return "X: " + X + " Y: " + Y;
}
}
}
using System.Runtime.InteropServices;
namespace WowPacketParser.Misc
{
[StructLayout(LayoutKind.Explicit, Size = 12)]
public struct Vector3
{
public Vector3(float x, float y, float z)
{
X = x;
Y = y;
Z = z;
}
[FieldOffset(0)]
public float X;
[FieldOffset(4)]
public float Y;
[FieldOffset(8)]
public float Z;
public override string ToString()
{
return "X: " + X + " Y: " + Y + " Z: " + Z;
}
}
}
using System.Runtime.InteropServices;
namespace WowPacketParser.Misc
{
[StructLayout(LayoutKind.Explicit, Size = 16)]
public struct Vector4
{
public Vector4(float x, float y, float z, float o)
{
X = x;
Y = y;
Z = z;
O = o;
}
[FieldOffset(0)]
public float X;
[FieldOffset(4)]
public float Y;
[FieldOffset(8)]
public float Z;
[FieldOffset(12)]
public float O;
public override string ToString()
{
return "X: " + X + " Y: " + Y + " Z: " + Z + " O: " + O;
}
}
}
* You could consider making a wrapper class for GUIDs. Below is one I wrote, based on WCell's EntityId struct, and some searching around on retail.
Code:
using System;
namespace WowPacketParser.Enums
{
public enum HighGuidMask : byte
{
MOTransport = 0x1F,
Item = 0x40,
FlagF1 = 0xF1,
FlagF4 = 0xF4,
FlagF5 = 0xF5,
FlagF7 = 0xF7
}
}
namespace WowPacketParser.Enums
{
public enum HighGuidType : byte
{
NoEntry = 0x00,
GameObject = 0x10,
Transport = 0x20,
Unit = 0x30,
Pet = 0x40,
Vehicle = 0x50,
Item = 0x80,
MOTransport = 0xC0
}
}
namespace WowPacketParser.Enums
{
public enum HighGuid : uint
{
UnitF130 = 0xF130,
UnitF430 = 0xF430,
UnitF730 = 0xF730,
Pet = 0xF140,
MOTransport = 0x1FC0,
Transport = 0xF120,
VehicleF550 = 0xF550,
VehicleF150 = 0xF150,
VehicleF450 = 0xF450,
VehicleF750 = 0xF750,
GameObjectF110 = 0xF110,
GameObjectF410 = 0xF410,
GameObjectF710 = 0xF710,
GameObjectF009 = 0xF009,
Item4000 = 0x4000,
Item4100 = 0x4100,
Item4180 = 0x4180,
Player0100 = 0x0100,
Player0180 = 0x0180,
DynamicObjectF100 = 0xF100,
DynamicObjectF500 = 0xF500,
CorpseF101 = 0xF101,
CorpseF400 = 0xF400,
CorpseF700 = 0xF700,
}
}
using System;
using System.IO;
using System.Runtime.InteropServices;
using WowPacketParser.Enums;
namespace WowPacketParser.Misc
{
[StructLayout(LayoutKind.Explicit, Size = 8)]
public struct Guid
{
public const uint LowMask = 0x00FFFFFF;
public const uint EntryMask = 0x00FFFFFF;
public const uint HighTypeMask = 0x00FF0000;
public const uint HighFlagMask = 0xFF000000;
[FieldOffset(0)]
public ulong Full;
[FieldOffset(0)]
public uint Low;
[FieldOffset(3)]
public uint Entry;
[FieldOffset(4)]
public uint High;
public Guid(ulong id)
: this()
{
Full = id;
}
public bool HasEntry
{
get { return GetHighType() != HighGuidType.NoEntry; }
}
public uint GetLow()
{
return Low & LowMask;
}
public uint GetEntry()
{
if (HasEntry)
return Entry & EntryMask;
return 0;
}
public HighGuid GetHighGuid()
{
return (HighGuid)(High >> 16);
}
public HighGuidType GetHighType()
{
return (HighGuidType)((High & HighTypeMask) >> 16);
}
public HighGuidMask GetHighMask()
{
return (HighGuidMask)((High & HighFlagMask) >> 24);
}
public override bool Equals(object obj)
{
return obj != null && obj is Guid && Equals((Guid)obj);
}
public bool Equals(Guid other)
{
return other.Full == Full;
}
public override int GetHashCode()
{
return Full.GetHashCode();
}
public override string ToString()
{
var highHex = false;
if (Enum.GetName(typeof(HighGuid), GetHighGuid()) == null)
highHex = true;
var highStr = highHex ? "0x" + ((uint)GetHighGuid()).ToString("X4") : GetHighGuid().ToString();
return "Full: " + Full + " High: " + highStr + " (" + GetHighType() + "/" +
GetHighMask() + ") Low: " + GetLow() + " Entry: " + GetEntry();
}
}
}