using System;
using QCRPG.Framework;

namespace QCRPG.TSL.NFC.Packets;

public class RfDiscoverSelectCmdInfo : PacketInfoBase
{
	public override string Name => "Rf Discover Select Cmd";

	public override string DisplayGroup => "RF Management";

	public RfDiscoverSelectCmdInfo(RfDiscoverSelectCmd packet)
		: base(packet)
	{
		UpdateFieldInfoFromPacket();
	}

	public override void UpdateFieldInfoFromPacket()
	{
		RfDiscoverSelectCmd rfDiscoverSelectCmd = (RfDiscoverSelectCmd)packet;
		fieldInfoList.Clear();
		fieldInfoList.Add(new PacketFieldInfo("RF Discovery ID", RfDiscoveryIdInfo.RfDiscoveryIdToDescription(), 8, FormatValue(rfDiscoverSelectCmd.UserFields.RfDiscoveryId, 8), RfDiscoveryIdInfo.RfDiscoveryIdToString(RfDiscoveryIdInfo.ValueToRfDiscoveryId(rfDiscoverSelectCmd.UserFields.RfDiscoveryId)), "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("RF Protocol", RfProtocolsInfo.RfProtocolsToDescription(), 8, FormatValue(rfDiscoverSelectCmd.UserFields.RfProtocol, 8), RfProtocolsInfo.RfProtocolsToString(RfProtocolsInfo.ValueToRfProtocols(rfDiscoverSelectCmd.UserFields.RfProtocol)), "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("RF Interface", RfInterfacesInfo.RfInterfacesToDescription(), 8, FormatValue(rfDiscoverSelectCmd.UserFields.RfInterface, 8), RfInterfacesInfo.RfInterfacesToString(RfInterfacesInfo.ValueToRfInterfaces(rfDiscoverSelectCmd.UserFields.RfInterface)), "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
	}

	public override void UpdatePacketFromFieldInfo(int index, string value)
	{
		RfDiscoverSelectCmd rfDiscoverSelectCmd = (RfDiscoverSelectCmd)packet;
		int num = -1;
		if (index == ++num)
		{
			rfDiscoverSelectCmd.UserFields.RfDiscoveryId = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			rfDiscoverSelectCmd.UserFields.RfProtocol = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			rfDiscoverSelectCmd.UserFields.RfInterface = Convert.ToUInt32(value, 16);
		}
	}
}
