using System;
using QCRPG.Framework;

namespace QCRPG.TSL.BT.Packets;

public class HciVsDebugWsimGpmInfo : PacketInfoBase
{
	public override string Name => "Hci Vs Debug Wsim Gpm";

	public override string DisplayGroup => "Vendor Specific";

	public HciVsDebugWsimGpmInfo(HciVsDebugWsimGpm packet)
		: base(packet)
	{
		UpdateFieldInfoFromPacket();
	}

	public override void UpdateFieldInfoFromPacket()
	{
		HciVsDebugWsimGpm hciVsDebugWsimGpm = (HciVsDebugWsimGpm)packet;
		fieldInfoList.Clear();
		fieldInfoList.Add(new PacketFieldInfo("SubOpCode", "", 8, FormatValue(hciVsDebugWsimGpm.UserFields.Subopcode, 8), "", "", "", settable: false, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("GPM_data", "Fake WSI GPM data", hciVsDebugWsimGpm.UserFields.GpmDataList.Count * 8, FormatValue(hciVsDebugWsimGpm.UserFields.GpmDataList, hciVsDebugWsimGpm.UserFields.GpmDataList.Count * 8, includeSpaces: false), "", "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
	}

	public override void UpdatePacketFromFieldInfo(int index, string value)
	{
		HciVsDebugWsimGpm hciVsDebugWsimGpm = (HciVsDebugWsimGpm)packet;
		int num = -1;
		if (index == ++num)
		{
			throw new Exception("Tried to set non-settable field Subopcode");
		}
		if (index == ++num)
		{
			value = AddLeadingZerosAndCheckValueStringLength(value, hciVsDebugWsimGpm.UserFields.GpmDataList.Count);
			int num2 = 0;
			while (value.Length > 0)
			{
				string value2 = value.Substring(0, 2);
				value = value.Remove(0, 2);
				hciVsDebugWsimGpm.UserFields.GpmDataList[num2] = Convert.ToUInt32(value2, 16);
				num2++;
			}
		}
	}
}
