using System;
using QCRPG.Framework;

namespace QCRPG.TSL.BT.Packets;

public class HardwareErrorInfo : PacketInfoBase
{
	public override string Name => "Hardware Error";

	public override string DisplayGroup => "Host Control and Baseband";

	public HardwareErrorInfo(HardwareError packet)
		: base(packet)
	{
		UpdateFieldInfoFromPacket();
	}

	public override void UpdateFieldInfoFromPacket()
	{
		HardwareError hardwareError = (HardwareError)packet;
		fieldInfoList.Clear();
		fieldInfoList.Add(new PacketFieldInfo("Hardware_Code", "Hardware problem code\r\n\r\n" + HardwareError.UserFieldsWrapper.HardwareCodeInfo.HardwareCodeToDescription(), 8, FormatValue(hardwareError.UserFields.HardwareCode, 8), HardwareError.UserFieldsWrapper.HardwareCodeInfo.HardwareCodeToString(HardwareError.UserFieldsWrapper.HardwareCodeInfo.ValueToHardwareCode(hardwareError.UserFields.HardwareCode)), "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
	}

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