using System;
using QCRPG.Framework;

namespace QCRPG.TSL.BT.Packets;

public class HciSetQlmEventMaskInfo : PacketInfoBase
{
	public override string Name => "Hci Set Qlm Event Mask";

	public override string DisplayGroup => "Vendor Specific";

	public HciSetQlmEventMaskInfo(HciSetQlmEventMask packet)
		: base(packet)
	{
		UpdateFieldInfoFromPacket();
	}

	public override void UpdateFieldInfoFromPacket()
	{
		HciSetQlmEventMask hciSetQlmEventMask = (HciSetQlmEventMask)packet;
		fieldInfoList.Clear();
		fieldInfoList.Add(new PacketFieldInfo("SubOpcode", "HCI_VS_QBCE_HCI_Set_QLM_Event_Mask", 8, FormatValue(hciSetQlmEventMask.UserFields.Subopcode, 8), "", "", "", settable: false, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Event_Mask", HciSetQlmEventMask.UserFieldsWrapper.EventMaskInfo.EventMaskToDescription(), 64, FormatValue(hciSetQlmEventMask.UserFields.EventMask, 64), HciSetQlmEventMask.UserFieldsWrapper.EventMaskInfo.EventMaskToString(HciSetQlmEventMask.UserFieldsWrapper.EventMaskInfo.ValueToEventMask(hciSetQlmEventMask.UserFields.EventMask)), "", "", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Status", ErrorCodeInfo.ErrorCodeToDescription(), 8, FormatValue(hciSetQlmEventMask.UserFields.Status, 8), ErrorCodeInfo.ErrorCodeToString(ErrorCodeInfo.ValueToErrorCode(hciSetQlmEventMask.UserFields.Status)), "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
	}

	public override void UpdatePacketFromFieldInfo(int index, string value)
	{
		HciSetQlmEventMask hciSetQlmEventMask = (HciSetQlmEventMask)packet;
		int num = -1;
		if (index == ++num)
		{
			throw new Exception("Tried to set non-settable field Subopcode");
		}
		if (index == ++num)
		{
			hciSetQlmEventMask.UserFields.EventMask = Convert.ToUInt64(value, 16);
		}
		else if (index == ++num)
		{
			hciSetQlmEventMask.UserFields.Status = Convert.ToUInt32(value, 16);
		}
	}
}
