using System;
using QCRPG.Framework;

namespace QCRPG.TSL.FMHCI.Packets;

public class TxRdsRawGroupsInfo : PacketInfoBase
{
	public override string Name => "Tx Rds Raw Groups";

	public override string DisplayGroup => "Transmitter Control";

	public TxRdsRawGroupsInfo(TxRdsRawGroups packet)
		: base(packet)
	{
		UpdateFieldInfoFromPacket();
	}

	public override void UpdateFieldInfoFromPacket()
	{
		TxRdsRawGroups txRdsRawGroups = (TxRdsRawGroups)packet;
		fieldInfoList.Clear();
		fieldInfoList.Add(new PacketFieldInfo("Number Of RDS Groups", "", 8, FormatValue(txRdsRawGroups.UserFields.NumberOfRdsGroups, 8), "", "", "1F", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		for (int i = 0; i < txRdsRawGroups.UserFields.RdsGroupListList.Count; i++)
		{
			fieldInfoList.Add(new PacketFieldInfo("RDS Group Block Info 1[" + i + "]", "", 16, FormatValue(txRdsRawGroups.UserFields.RdsGroupListList[i].RdsGroupBlockInfo1, 16), "", "", "", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
			fieldInfoList.Add(new PacketFieldInfo("RDS Group Block Info 2[" + i + "]", "", 16, FormatValue(txRdsRawGroups.UserFields.RdsGroupListList[i].RdsGroupBlockInfo2, 16), "", "", "", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
			fieldInfoList.Add(new PacketFieldInfo("RDS Group Block Info 3[" + i + "]", "", 16, FormatValue(txRdsRawGroups.UserFields.RdsGroupListList[i].RdsGroupBlockInfo3, 16), "", "", "", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
			fieldInfoList.Add(new PacketFieldInfo("RDS Group Block Info 4[" + i + "]", "", 16, FormatValue(txRdsRawGroups.UserFields.RdsGroupListList[i].RdsGroupBlockInfo4, 16), "", "", "", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		}
	}

	public override void UpdatePacketFromFieldInfo(int index, string value)
	{
		TxRdsRawGroups txRdsRawGroups = (TxRdsRawGroups)packet;
		int num = -1;
		if (index == ++num)
		{
			txRdsRawGroups.UserFields.NumberOfRdsGroups = Convert.ToUInt32(value, 16);
			return;
		}
		for (int i = 0; i < txRdsRawGroups.UserFields.RdsGroupListList.Count; i++)
		{
			if (index == ++num)
			{
				txRdsRawGroups.UserFields.RdsGroupListList[i].RdsGroupBlockInfo1 = Convert.ToUInt32(value, 16);
				break;
			}
			if (index == ++num)
			{
				txRdsRawGroups.UserFields.RdsGroupListList[i].RdsGroupBlockInfo2 = Convert.ToUInt32(value, 16);
				break;
			}
			if (index == ++num)
			{
				txRdsRawGroups.UserFields.RdsGroupListList[i].RdsGroupBlockInfo3 = Convert.ToUInt32(value, 16);
				break;
			}
			if (index == ++num)
			{
				txRdsRawGroups.UserFields.RdsGroupListList[i].RdsGroupBlockInfo4 = Convert.ToUInt32(value, 16);
				break;
			}
		}
	}
}
