using System;
using QCRPG.Framework;

namespace QCRPG.TSL.FMHCI.Packets;

public class RdsGroupsInfo : PacketInfoBase
{
	public override string Name => "Rds Groups";

	public override string DisplayGroup => "Receiver Control";

	public RdsGroupsInfo(RdsGroups packet)
		: base(packet)
	{
		UpdateFieldInfoFromPacket();
	}

	public override void UpdateFieldInfoFromPacket()
	{
		RdsGroups rdsGroups = (RdsGroups)packet;
		fieldInfoList.Clear();
		fieldInfoList.Add(new PacketFieldInfo("RDS Group Enable Mask", "A bitmask of RDS/RBDS groups to enable.  Each bit set will allow that RDS/RBDS group to be buffered and sent to the client. If a bit is set then that particular RDS group type will be buffered and passed to the client/application layer.  By default, no RDS groups will be passed to the client.  Bits 0, 2, 4, etc., enable groups 0A, 1A, 2A, etc.  Bits 1, 3, 5, etc., enable groups 0B, 1B, 2B, etc.", 32, FormatValue(rdsGroups.UserFields.RdsGroupEnableMask, 32), "", "", "", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("RDS Buffer Size", "The number of RDS/RBDS groups the FM driver should buffer before sending to the client", 32, FormatValue(rdsGroups.UserFields.RdsBufferSize, 32), "", "", "", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Enable RDS Change Filter", RdsGroups.UserFieldsWrapper.EnableRdsChangeFilterInfo.EnableRdsChangeFilterToDescription(), 8, FormatValue(rdsGroups.UserFields.EnableRdsChangeFilter, 8), RdsGroups.UserFieldsWrapper.EnableRdsChangeFilterInfo.EnableRdsChangeFilterToString(RdsGroups.UserFieldsWrapper.EnableRdsChangeFilterInfo.ValueToEnableRdsChangeFilter(rdsGroups.UserFields.EnableRdsChangeFilter)), "", "1", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
	}

	public override void UpdatePacketFromFieldInfo(int index, string value)
	{
		RdsGroups rdsGroups = (RdsGroups)packet;
		int num = -1;
		if (index == ++num)
		{
			rdsGroups.UserFields.RdsGroupEnableMask = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			rdsGroups.UserFields.RdsBufferSize = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			rdsGroups.UserFields.EnableRdsChangeFilter = Convert.ToUInt32(value, 16);
		}
	}
}
