using System;
using QCRPG.Framework;

namespace QCRPG.TSL.BT.Packets;

public class HostBufferSizeInfo : PacketInfoBase
{
	public override string Name => "Host Buffer Size";

	public override string DisplayGroup => "Host Control and Baseband";

	public HostBufferSizeInfo(HostBufferSize packet)
		: base(packet)
	{
		UpdateFieldInfoFromPacket();
	}

	public override void UpdateFieldInfoFromPacket()
	{
		HostBufferSize hostBufferSize = (HostBufferSize)packet;
		fieldInfoList.Clear();
		fieldInfoList.Add(new PacketFieldInfo("ACL Data Packet Length", "Maximum length (in octets) of the data portion of each HCI ACL Data Packet that the Host is able to accept", 16, FormatValue(hostBufferSize.UserFields.AclDataPacketLength, 16), "", "", "", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Synchronous Data Packet Length", "Maximum length (in octets) of the data portion of each HCI synchronous Data Packet that the Host is able to accept", 8, FormatValue(hostBufferSize.UserFields.SynchronousDataPacketLength, 8), "", "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Total Num ACL Data Packets", "Total number of HCI ACL Data Packets that can be stored in the data buffers of the Host", 16, FormatValue(hostBufferSize.UserFields.TotalNumAclDataPackets, 16), "", "", "", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Total Num Synchronous Data Packets", "Total number of HCI synchronous Data Packets that can be stored in the data buffers of the Host", 16, FormatValue(hostBufferSize.UserFields.TotalNumSynchronousDataPackets, 16), "", "", "", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
	}

	public override void UpdatePacketFromFieldInfo(int index, string value)
	{
		HostBufferSize hostBufferSize = (HostBufferSize)packet;
		int num = -1;
		if (index == ++num)
		{
			hostBufferSize.UserFields.AclDataPacketLength = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			hostBufferSize.UserFields.SynchronousDataPacketLength = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			hostBufferSize.UserFields.TotalNumAclDataPackets = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			hostBufferSize.UserFields.TotalNumSynchronousDataPackets = Convert.ToUInt32(value, 16);
		}
	}
}
