using System;
using QCRPG.Framework;

namespace QCRPG.TSL.BT.Packets;

public class EdlBoardIdResponseInfo : PacketInfoBase
{
	public override string Name => "Edl Board Id Response";

	public override string DisplayGroup => "Vendor Specific";

	public EdlBoardIdResponseInfo(EdlBoardIdResponse packet)
		: base(packet)
	{
		UpdateFieldInfoFromPacket();
	}

	public override void UpdateFieldInfoFromPacket()
	{
		EdlBoardIdResponse edlBoardIdResponse = (EdlBoardIdResponse)packet;
		fieldInfoList.Clear();
		fieldInfoList.Add(new PacketFieldInfo("Vendor Event Class", EdlBoardIdResponse.UserFieldsWrapper.VendorEventClassInfo.VendorEventClassToDescription(), 8, FormatValue(edlBoardIdResponse.UserFields.VendorEventClass, 8), EdlBoardIdResponse.UserFieldsWrapper.VendorEventClassInfo.VendorEventClassToString(EdlBoardIdResponse.UserFieldsWrapper.VendorEventClassInfo.ValueToVendorEventClass(edlBoardIdResponse.UserFields.VendorEventClass)), "", "", settable: false, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Sub OpCode", EdlBoardIdResponse.UserFieldsWrapper.SubOpcodeInfo.SubOpcodeToDescription(), 8, FormatValue(edlBoardIdResponse.UserFields.SubOpcode, 8), EdlBoardIdResponse.UserFieldsWrapper.SubOpcodeInfo.SubOpcodeToString(EdlBoardIdResponse.UserFieldsWrapper.SubOpcodeInfo.ValueToSubOpcode(edlBoardIdResponse.UserFields.SubOpcode)), "", "", settable: false, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("String Length", EdlBoardIdResponse.UserFieldsWrapper.StringLengthInfo.StringLengthToDescription(), 8, FormatValue(edlBoardIdResponse.UserFields.StringLength, 8), EdlBoardIdResponse.UserFieldsWrapper.StringLengthInfo.StringLengthToString(EdlBoardIdResponse.UserFieldsWrapper.StringLengthInfo.ValueToStringLength(edlBoardIdResponse.UserFields.StringLength)), "", "", settable: false, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Board ID", "", 16, FormatValue(edlBoardIdResponse.UserFields.BoardId, 16), "", "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
	}

	public override void UpdatePacketFromFieldInfo(int index, string value)
	{
		EdlBoardIdResponse edlBoardIdResponse = (EdlBoardIdResponse)packet;
		int num = -1;
		if (index == ++num)
		{
			throw new Exception("Tried to set non-settable field VendorEventClass");
		}
		if (index == ++num)
		{
			throw new Exception("Tried to set non-settable field SubOpcode");
		}
		if (index == ++num)
		{
			throw new Exception("Tried to set non-settable field StringLength");
		}
		if (index == ++num)
		{
			edlBoardIdResponse.UserFields.BoardId = Convert.ToUInt32(value, 16);
		}
	}
}
