using System;
using QCRPG.Framework;

namespace QCRPG.TSL.FM.Packets;

public class ReadI2cInfo : PacketInfoBase
{
	public override string Name => "Read I2c";

	public override string DisplayGroup => "Test";

	public ReadI2cInfo(ReadI2c packet)
		: base(packet)
	{
		UpdateFieldInfoFromPacket();
	}

	public override void UpdateFieldInfoFromPacket()
	{
		ReadI2c readI2c = (ReadI2c)packet;
		fieldInfoList.Clear();
		fieldInfoList.Add(new PacketFieldInfo("Length", "Length of the data to read", 8, FormatValue(readI2c.UserFields.Length, 8), "", "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
	}

	public override void UpdatePacketFromFieldInfo(int index, string value)
	{
		ReadI2c readI2c = (ReadI2c)packet;
		int num = -1;
		if (index == ++num)
		{
			readI2c.UserFields.Length = Convert.ToUInt32(value, 16);
		}
	}
}
