using System;
using QCRPG.Framework;

namespace QCRPG.TSL.NFC.Packets;

public class RfNfceeActionNtfInfo : PacketInfoBase
{
	public override string Name => "Rf Nfcee Action Ntf";

	public override string DisplayGroup => "RF Management";

	public RfNfceeActionNtfInfo(RfNfceeActionNtf packet)
		: base(packet)
	{
		UpdateFieldInfoFromPacket();
	}

	public override void UpdateFieldInfoFromPacket()
	{
		RfNfceeActionNtf rfNfceeActionNtf = (RfNfceeActionNtf)packet;
		fieldInfoList.Clear();
		fieldInfoList.Add(new PacketFieldInfo("NFCEE ID", NfceeIdsInfo.NfceeIdsToDescription(), 8, FormatValue(rfNfceeActionNtf.UserFields.NfceeId, 8), NfceeIdsInfo.NfceeIdsToString(NfceeIdsInfo.ValueToNfceeIds(rfNfceeActionNtf.UserFields.NfceeId)), "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Trigger", RfNfceeActionNtf.UserFieldsWrapper.TriggerInfo.TriggerToDescription(), 8, FormatValue(rfNfceeActionNtf.UserFields.Trigger, 8), RfNfceeActionNtf.UserFieldsWrapper.TriggerInfo.TriggerToString(RfNfceeActionNtf.UserFieldsWrapper.TriggerInfo.ValueToTrigger(rfNfceeActionNtf.UserFields.Trigger)), "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Supporting Data Length", "The length of Supporting Data field to follow (n).", 8, FormatValue(rfNfceeActionNtf.UserFields.SupportingDataLength, 8), "", "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Supporting Data", "Depends on Trigger.", rfNfceeActionNtf.UserFields.SupportingDataList.Count * 8, FormatValue(rfNfceeActionNtf.UserFields.SupportingDataList, rfNfceeActionNtf.UserFields.SupportingDataList.Count * 8, includeSpaces: false), "", "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
	}

	public override void UpdatePacketFromFieldInfo(int index, string value)
	{
		RfNfceeActionNtf rfNfceeActionNtf = (RfNfceeActionNtf)packet;
		int num = -1;
		if (index == ++num)
		{
			rfNfceeActionNtf.UserFields.NfceeId = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			rfNfceeActionNtf.UserFields.Trigger = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			rfNfceeActionNtf.UserFields.SupportingDataLength = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			value = AddLeadingZerosAndCheckValueStringLength(value, rfNfceeActionNtf.UserFields.SupportingDataList.Count);
			int num2 = 0;
			while (value.Length > 0)
			{
				string value2 = value.Substring(0, 2);
				value = value.Remove(0, 2);
				rfNfceeActionNtf.UserFields.SupportingDataList[num2] = Convert.ToUInt32(value2, 16);
				num2++;
			}
		}
	}
}
