using System;
using QCRPG.Framework;

namespace QCRPG.TSL.BT.Packets;

public class DbfwScoPacketInfoInfo : PacketInfoBase
{
	public override string Name => "Dbfw Sco Packet Info";

	public override string DisplayGroup => "Vendor Specific";

	public DbfwScoPacketInfoInfo(DbfwScoPacketInfo packet)
		: base(packet)
	{
		UpdateFieldInfoFromPacket();
	}

	public override void UpdateFieldInfoFromPacket()
	{
		DbfwScoPacketInfo dbfwScoPacketInfo = (DbfwScoPacketInfo)packet;
		fieldInfoList.Clear();
		fieldInfoList.Add(new PacketFieldInfo("DBFW_Event_Code", "DBFW debug event", 8, FormatValue(dbfwScoPacketInfo.UserFields.DbfwEventCode, 8), "", "", "", settable: false, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Sub_Event_Code", "DBFW SCO packet info", 8, FormatValue(dbfwScoPacketInfo.UserFields.SubEventCode, 8), "", "", "", settable: false, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Packet_Type_M2S", DbfwScoPacketInfo.UserFieldsWrapper.PacketTypeM2sInfo.PacketTypeM2sToDescription(), 8, FormatValue(dbfwScoPacketInfo.UserFields.PacketTypeM2s, 8), DbfwScoPacketInfo.UserFieldsWrapper.PacketTypeM2sInfo.PacketTypeM2sToString(DbfwScoPacketInfo.UserFieldsWrapper.PacketTypeM2sInfo.ValueToPacketTypeM2s(dbfwScoPacketInfo.UserFields.PacketTypeM2s)), "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Packet_Type_S2M", DbfwScoPacketInfo.UserFieldsWrapper.PacketTypeS2mInfo.PacketTypeS2mToDescription(), 8, FormatValue(dbfwScoPacketInfo.UserFields.PacketTypeS2m, 8), DbfwScoPacketInfo.UserFieldsWrapper.PacketTypeS2mInfo.PacketTypeS2mToString(DbfwScoPacketInfo.UserFieldsWrapper.PacketTypeS2mInfo.ValueToPacketTypeS2m(dbfwScoPacketInfo.UserFields.PacketTypeS2m)), "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
	}

	public override void UpdatePacketFromFieldInfo(int index, string value)
	{
		DbfwScoPacketInfo dbfwScoPacketInfo = (DbfwScoPacketInfo)packet;
		int num = -1;
		if (index == ++num)
		{
			throw new Exception("Tried to set non-settable field DbfwEventCode");
		}
		if (index == ++num)
		{
			throw new Exception("Tried to set non-settable field SubEventCode");
		}
		if (index == ++num)
		{
			dbfwScoPacketInfo.UserFields.PacketTypeM2s = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			dbfwScoPacketInfo.UserFields.PacketTypeS2m = Convert.ToUInt32(value, 16);
		}
	}
}
