using System;
using QCRPG.Framework;

namespace QCRPG.TSL.BT.Packets;

public class CleDebugEventInfo : PacketInfoBase
{
	public override string Name => "Cle Debug Event";

	public override string DisplayGroup => "Vendor Specific";

	public CleDebugEventInfo(CleDebugEvent packet)
		: base(packet)
	{
		UpdateFieldInfoFromPacket();
	}

	public override void UpdateFieldInfoFromPacket()
	{
		CleDebugEvent cleDebugEvent = (CleDebugEvent)packet;
		fieldInfoList.Clear();
		fieldInfoList.Add(new PacketFieldInfo("Sub_Opcode", "", 8, FormatValue(cleDebugEvent.UserFields.SubOpcode, 8), "", "", "", settable: false, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("CLE_opcode", "", 8, FormatValue(cleDebugEvent.UserFields.CleOpcode, 8), "", "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("CLE_paylen", "", 8, FormatValue(cleDebugEvent.UserFields.ClePaylen, 8), "", "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
	}

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