using System;
using QCRPG.Framework;

namespace QCRPG.TSL.BT.Packets;

public class ConnectionlessSlaveBroadcastChannelMapChangeInfo : PacketInfoBase
{
	public override string Name => "Connectionless Slave Broadcast Channel Map Change";

	public override string DisplayGroup => "Link Control";

	public ConnectionlessSlaveBroadcastChannelMapChangeInfo(ConnectionlessSlaveBroadcastChannelMapChange packet)
		: base(packet)
	{
		UpdateFieldInfoFromPacket();
	}

	public override void UpdateFieldInfoFromPacket()
	{
		ConnectionlessSlaveBroadcastChannelMapChange connectionlessSlaveBroadcastChannelMapChange = (ConnectionlessSlaveBroadcastChannelMapChange)packet;
		fieldInfoList.Clear();
		fieldInfoList.Add(new PacketFieldInfo("AFH_Channel_Map", "This parameter contains 80 1-bit fields. The nth such field (in the range 0 to 78) contains the value for channel n: 0: channel n is unused, 1: channel n is used. The most significant bit (bit 79) is reserved and shall be set to 0 when transmitted and ignored when received", connectionlessSlaveBroadcastChannelMapChange.UserFields.AfhChannelMapList.Count * 8, FormatValue(connectionlessSlaveBroadcastChannelMapChange.UserFields.AfhChannelMapList, connectionlessSlaveBroadcastChannelMapChange.UserFields.AfhChannelMapList.Count * 8, includeSpaces: false), "", "", "", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
	}

	public override void UpdatePacketFromFieldInfo(int index, string value)
	{
		ConnectionlessSlaveBroadcastChannelMapChange connectionlessSlaveBroadcastChannelMapChange = (ConnectionlessSlaveBroadcastChannelMapChange)packet;
		int num = -1;
		if (index == ++num)
		{
			value = AddLeadingZerosAndCheckValueStringLength(value, connectionlessSlaveBroadcastChannelMapChange.UserFields.AfhChannelMapList.Count);
			int num2 = 0;
			while (value.Length > 0)
			{
				string value2 = value.Substring(0, 2);
				value = value.Remove(0, 2);
				connectionlessSlaveBroadcastChannelMapChange.UserFields.AfhChannelMapList[num2] = Convert.ToUInt32(value2, 16);
				num2++;
			}
		}
	}
}
