using System;
using QCRPG.Framework;

namespace QCRPG.TSL.BT.Packets;

public class LtLeCleTestInfo : PacketInfoBase
{
	public override string Name => "Lt Le Cle Test";

	public override string DisplayGroup => "Vendor Specific";

	public LtLeCleTestInfo(LtLeCleTest packet)
		: base(packet)
	{
		UpdateFieldInfoFromPacket();
	}

	public override void UpdateFieldInfoFromPacket()
	{
		LtLeCleTest ltLeCleTest = (LtLeCleTest)packet;
		fieldInfoList.Clear();
		fieldInfoList.Add(new PacketFieldInfo("Sub OpCode", "Set LE CLE test modes/parameters", 8, FormatValue(ltLeCleTest.UserFields.SubOpcode, 8), "", "", "", settable: false, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("CLE_Test_Mode", LtLeCleTest.UserFieldsWrapper.CleTestModeInfo.CleTestModeToDescription(), 8, FormatValue(ltLeCleTest.UserFields.CleTestMode, 8), LtLeCleTest.UserFieldsWrapper.CleTestModeInfo.CleTestModeToString(LtLeCleTest.UserFieldsWrapper.CleTestModeInfo.ValueToCleTestMode(ltLeCleTest.UserFields.CleTestMode)), "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("CLE_Para1", "", 8, FormatValue(ltLeCleTest.UserFields.ClePara1, 8), "", "00", "FB", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("CLE_Para2", "", 8, FormatValue(ltLeCleTest.UserFields.ClePara2, 8), "", "00", "FB", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
	}

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