using System;
using QCRPG.Framework;

namespace QCRPG.TSL.FMHCI.Packets;

public class SearchStationListInfo : PacketInfoBase
{
	public override string Name => "Search Station List";

	public override string DisplayGroup => "Receiver Control";

	public SearchStationListInfo(SearchStationList packet)
		: base(packet)
	{
		UpdateFieldInfoFromPacket();
	}

	public override void UpdateFieldInfoFromPacket()
	{
		SearchStationList searchStationList = (SearchStationList)packet;
		fieldInfoList.Clear();
		fieldInfoList.Add(new PacketFieldInfo("Search List Mode", SearchStationList.UserFieldsWrapper.SearchListModeInfo.SearchListModeToDescription(), 8, FormatValue(searchStationList.UserFields.SearchListMode, 8), SearchStationList.UserFieldsWrapper.SearchListModeInfo.SearchListModeToString(SearchStationList.UserFieldsWrapper.SearchListModeInfo.ValueToSearchListMode(searchStationList.UserFields.SearchListMode)), "", "4", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Search List Direction", SearchStationList.UserFieldsWrapper.SearchListDirectionInfo.SearchListDirectionToDescription(), 8, FormatValue(searchStationList.UserFields.SearchListDirection, 8), SearchStationList.UserFieldsWrapper.SearchListDirectionInfo.SearchListDirectionToString(SearchStationList.UserFieldsWrapper.SearchListDirectionInfo.ValueToSearchListDirection(searchStationList.UserFields.SearchListDirection)), "", "1", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Search List Max", "Maximum number of stations to be found.  0x14 = Maximum number of stations.  0x00 = Invalid stations.  Note: In search for strongest/weakest/list PTY, this parameter is ignored and we always return maximum number of stations (0x14).", 32, FormatValue(searchStationList.UserFields.SearchListMax, 32), "", "", "14", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Program Type", "The RDS/RBDS program type", 8, FormatValue(searchStationList.UserFields.ProgramType, 8), "", "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
	}

	public override void UpdatePacketFromFieldInfo(int index, string value)
	{
		SearchStationList searchStationList = (SearchStationList)packet;
		int num = -1;
		if (index == ++num)
		{
			searchStationList.UserFields.SearchListMode = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			searchStationList.UserFields.SearchListDirection = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			searchStationList.UserFields.SearchListMax = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			searchStationList.UserFields.ProgramType = Convert.ToUInt32(value, 16);
		}
	}
}
