using System;
using QCRPG.Framework;

namespace QCRPG.TSL.BT.Packets;

public class AddScoConnectionInfo : PacketInfoBase
{
	public override string Name => "Add Sco Connection";

	public override string DisplayGroup => "Link Control";

	public AddScoConnectionInfo(AddScoConnection packet)
		: base(packet)
	{
		UpdateFieldInfoFromPacket();
	}

	public override void UpdateFieldInfoFromPacket()
	{
		AddScoConnection addScoConnection = (AddScoConnection)packet;
		fieldInfoList.Clear();
		fieldInfoList.Add(new PacketFieldInfo("Connection Handle", "Connection Handle for the ACL connection being used to create an SCO connection.Range: 0x0000-0x0EFF (0x0F00 - 0x0FFF Reserved for future use)", 16, FormatValue(addScoConnection.UserFields.ConnectionHandle, 16), "", "", "", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Packet Type", SynchronousPacketTypeInfo.SynchronousPacketTypeToDescription(), 16, FormatValue(addScoConnection.UserFields.PacketType, 16), SynchronousPacketTypeInfo.SynchronousPacketTypeToString(SynchronousPacketTypeInfo.ValueToSynchronousPacketType(addScoConnection.UserFields.PacketType)), "", "", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
	}

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