using System;
using QCRPG.Framework;

namespace QCRPG.TSL.BT.Packets;

public class MaxSlotsChangeEventInfo : PacketInfoBase
{
	public override string Name => "Max Slots Change Event";

	public override string DisplayGroup => "Link Control";

	public MaxSlotsChangeEventInfo(MaxSlotsChangeEvent packet)
		: base(packet)
	{
		UpdateFieldInfoFromPacket();
	}

	public override void UpdateFieldInfoFromPacket()
	{
		MaxSlotsChangeEvent maxSlotsChangeEvent = (MaxSlotsChangeEvent)packet;
		fieldInfoList.Clear();
		fieldInfoList.Add(new PacketFieldInfo("Connection Handle", "Connection handle", 16, FormatValue(maxSlotsChangeEvent.UserFields.ConnectionHandle, 16), "", "", "0EFF", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("LMP_MAX_SLOTS", "LMP_MAX_SLOTS", 8, FormatValue(maxSlotsChangeEvent.UserFields.LmpMaxSlots, 8), "", "", "05", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
	}

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