using System;
using QCRPG.Framework;

namespace QCRPG.TSL.BT.Packets;

public class TruncatedPageCompleteInfo : PacketInfoBase
{
	public override string Name => "Truncated Page Complete";

	public override string DisplayGroup => "Link Control";

	public TruncatedPageCompleteInfo(TruncatedPageComplete packet)
		: base(packet)
	{
		UpdateFieldInfoFromPacket();
	}

	public override void UpdateFieldInfoFromPacket()
	{
		TruncatedPageComplete truncatedPageComplete = (TruncatedPageComplete)packet;
		fieldInfoList.Clear();
		fieldInfoList.Add(new PacketFieldInfo("Status", ErrorCodeInfo.ErrorCodeToDescription(), 8, FormatValue(truncatedPageComplete.UserFields.Status, 8), ErrorCodeInfo.ErrorCodeToString(ErrorCodeInfo.ValueToErrorCode(truncatedPageComplete.UserFields.Status)), "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("BD Address", "BD_ADDR of the paged (slave) device.", 48, FormatValue(truncatedPageComplete.UserFields.BdAddress, 48), "", "", "", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
	}

	public override void UpdatePacketFromFieldInfo(int index, string value)
	{
		TruncatedPageComplete truncatedPageComplete = (TruncatedPageComplete)packet;
		int num = -1;
		if (index == ++num)
		{
			truncatedPageComplete.UserFields.Status = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			truncatedPageComplete.UserFields.BdAddress = Convert.ToUInt64(value, 16);
		}
	}
}
