using System;
using QCRPG.Framework;

namespace QCRPG.TSL.NFC.Packets;

public class CoreGetConfigCmdInfo : PacketInfoBase
{
	public override string Name => "Core Get Config Cmd";

	public override string DisplayGroup => "NCI Core";

	public CoreGetConfigCmdInfo(CoreGetConfigCmd packet)
		: base(packet)
	{
		UpdateFieldInfoFromPacket();
	}

	public override void UpdateFieldInfoFromPacket()
	{
		CoreGetConfigCmd coreGetConfigCmd = (CoreGetConfigCmd)packet;
		fieldInfoList.Clear();
		fieldInfoList.Add(new PacketFieldInfo("Number Of Parameters", "The number of Parameter ID fields to follow (n).", 8, FormatValue(coreGetConfigCmd.UserFields.NumberOfParameters, 8), "", "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		for (int i = 0; i < coreGetConfigCmd.UserFields.ParameterIdList.Count; i++)
		{
			fieldInfoList.Add(new PacketFieldInfo("Parameter ID[" + i + "]", ConfigurationParameterTagsInfo.ConfigurationParameterTagsToDescription(), 8, FormatValue(coreGetConfigCmd.UserFields.ParameterIdList[i], 8), ConfigurationParameterTagsInfo.ConfigurationParameterTagsToString(ConfigurationParameterTagsInfo.ValueToConfigurationParameterTags(coreGetConfigCmd.UserFields.ParameterIdList[i])), "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		}
	}

	public override void UpdatePacketFromFieldInfo(int index, string value)
	{
		CoreGetConfigCmd coreGetConfigCmd = (CoreGetConfigCmd)packet;
		int num = -1;
		if (index == ++num)
		{
			coreGetConfigCmd.UserFields.NumberOfParameters = Convert.ToUInt32(value, 16);
			return;
		}
		for (int i = 0; i < coreGetConfigCmd.UserFields.ParameterIdList.Count; i++)
		{
			if (index == ++num)
			{
				coreGetConfigCmd.UserFields.ParameterIdList[i] = Convert.ToUInt32(value, 16);
				break;
			}
		}
	}
}
