using System;
using QCRPG.Framework;

namespace QCRPG.TSL.BT.Packets;

public class LogicalLinkCancelInfo : PacketInfoBase
{
	public override string Name => "Logical Link Cancel";

	public override string DisplayGroup => "Link Control";

	public LogicalLinkCancelInfo(LogicalLinkCancel packet)
		: base(packet)
	{
		UpdateFieldInfoFromPacket();
	}

	public override void UpdateFieldInfoFromPacket()
	{
		LogicalLinkCancel logicalLinkCancel = (LogicalLinkCancel)packet;
		fieldInfoList.Clear();
		fieldInfoList.Add(new PacketFieldInfo("Physical_Link_Handle", "Physical Link Handle over which the logical link is to be established.", 8, FormatValue(logicalLinkCancel.UserFields.PhysicalLinkHandle, 8), "", "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Tx_Flow_Spec_ID", "Flow Spec ID identifying the logical link whose creation is being cancelled. This matches the ID field of the Tx_Flow_Spec in the matching Create or Accept Logical Link command", 8, FormatValue(logicalLinkCancel.UserFields.TxFlowSpecId, 8), "", "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
	}

	public override void UpdatePacketFromFieldInfo(int index, string value)
	{
		LogicalLinkCancel logicalLinkCancel = (LogicalLinkCancel)packet;
		int num = -1;
		if (index == ++num)
		{
			logicalLinkCancel.UserFields.PhysicalLinkHandle = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			logicalLinkCancel.UserFields.TxFlowSpecId = Convert.ToUInt32(value, 16);
		}
	}
}
