using System;
using QCRPG.Framework;

namespace QCRPG.TSL.BT.Packets;

public class ReadRemoteExtendedFeaturesInfo : PacketInfoBase
{
	public override string Name => "Read Remote Extended Features";

	public override string DisplayGroup => "Link Control";

	public ReadRemoteExtendedFeaturesInfo(ReadRemoteExtendedFeatures packet)
		: base(packet)
	{
		UpdateFieldInfoFromPacket();
	}

	public override void UpdateFieldInfoFromPacket()
	{
		ReadRemoteExtendedFeatures readRemoteExtendedFeatures = (ReadRemoteExtendedFeatures)packet;
		fieldInfoList.Clear();
		fieldInfoList.Add(new PacketFieldInfo("Connection_Handle", "The Connection_Handle identifying the remote device for which extended feature information is required.", 16, FormatValue(readRemoteExtendedFeatures.UserFields.ConnectionHandle, 16), "", "0000", "0EFF", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Page Number", ReadRemoteExtendedFeatures.UserFieldsWrapper.PageNumberInfo.PageNumberToDescription(), 8, FormatValue(readRemoteExtendedFeatures.UserFields.PageNumber, 8), ReadRemoteExtendedFeatures.UserFieldsWrapper.PageNumberInfo.PageNumberToString(ReadRemoteExtendedFeatures.UserFieldsWrapper.PageNumberInfo.ValueToPageNumber(readRemoteExtendedFeatures.UserFields.PageNumber)), "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
	}

	public override void UpdatePacketFromFieldInfo(int index, string value)
	{
		ReadRemoteExtendedFeatures readRemoteExtendedFeatures = (ReadRemoteExtendedFeatures)packet;
		int num = -1;
		if (index == ++num)
		{
			readRemoteExtendedFeatures.UserFields.ConnectionHandle = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			readRemoteExtendedFeatures.UserFields.PageNumber = Convert.ToUInt32(value, 16);
		}
	}
}
