using System;
using QCRPG.Framework;

namespace QCRPG.TSL.BT.Packets;

public class NvmAccessGetInfo : PacketInfoBase
{
	public override string Name => "Nvm Access Get";

	public override string DisplayGroup => "Vendor Specific";

	public NvmAccessGetInfo(NvmAccessGet packet)
		: base(packet)
	{
		UpdateFieldInfoFromPacket();
	}

	public override void UpdateFieldInfoFromPacket()
	{
		NvmAccessGet nvmAccessGet = (NvmAccessGet)packet;
		fieldInfoList.Clear();
		fieldInfoList.Add(new PacketFieldInfo("NVM Command", "", 8, FormatValue(nvmAccessGet.UserFields.NvmCommand, 8), "", "", "", settable: false, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Tag Number", "", 8, FormatValue(nvmAccessGet.UserFields.TagNumber, 8), "", "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
	}

	public override void UpdatePacketFromFieldInfo(int index, string value)
	{
		NvmAccessGet nvmAccessGet = (NvmAccessGet)packet;
		int num = -1;
		if (index == ++num)
		{
			throw new Exception("Tried to set non-settable field NvmCommand");
		}
		if (index == ++num)
		{
			nvmAccessGet.UserFields.TagNumber = Convert.ToUInt32(value, 16);
		}
	}
}
