using System;
using QCRPG.Framework;

namespace QCRPG.TSL.BT.Packets;

public class PersistAccessOtpGetInfo : PacketInfoBase
{
	public override string Name => "Persist Access Otp Get";

	public override string DisplayGroup => "Vendor Specific";

	public PersistAccessOtpGetInfo(PersistAccessOtpGet packet)
		: base(packet)
	{
		UpdateFieldInfoFromPacket();
	}

	public override void UpdateFieldInfoFromPacket()
	{
		PersistAccessOtpGet persistAccessOtpGet = (PersistAccessOtpGet)packet;
		fieldInfoList.Clear();
		fieldInfoList.Add(new PacketFieldInfo("Sub-Opcode", "", 8, FormatValue(persistAccessOtpGet.UserFields.SubOpcode, 8), "", "", "", settable: false, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("CFG_TYPE", CfgTypeOtpAccessInfo.CfgTypeOtpAccessToDescription(), 8, FormatValue(persistAccessOtpGet.UserFields.CfgType, 8), CfgTypeOtpAccessInfo.CfgTypeOtpAccessToString(CfgTypeOtpAccessInfo.ValueToCfgTypeOtpAccess(persistAccessOtpGet.UserFields.CfgType)), "", "", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
	}

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