using System;
using QCRPG.Framework;

namespace QCRPG.TSL.BT.Packets;

public class QllLlFeatureReqInfo : PacketInfoBase
{
	public override string Name => "Qll Ll Feature Req";

	public override string DisplayGroup => "Enhanced Logging";

	public QllLlFeatureReqInfo(QllLlFeatureReq packet)
		: base(packet)
	{
		UpdateFieldInfoFromPacket();
	}

	public override void UpdateFieldInfoFromPacket()
	{
		QllLlFeatureReq qllLlFeatureReq = (QllLlFeatureReq)packet;
		fieldInfoList.Clear();
		fieldInfoList.Add(new PacketFieldInfo("Seq_Num", "", 8, FormatValue(qllLlFeatureReq.UserFields.SeqNum, 8), "", "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Logs_Lost_Drop", "", 8, FormatValue(qllLlFeatureReq.UserFields.LogsLostDrop, 8), "", "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Prod_ID", "", 8, FormatValue(qllLlFeatureReq.UserFields.ProdId, 8), "", "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Log_Id", QllLlFeatureReq.UserFieldsWrapper.LogIdInfo.LogIdToDescription(), 16, FormatValue(qllLlFeatureReq.UserFields.LogId, 16), QllLlFeatureReq.UserFieldsWrapper.LogIdInfo.LogIdToString(QllLlFeatureReq.UserFieldsWrapper.LogIdInfo.ValueToLogId(qllLlFeatureReq.UserFields.LogId)), "", "", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Log_Format_Level", "", 8, FormatValue(qllLlFeatureReq.UserFields.LogFormatLevel, 8), "", "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Timestamp", "", 32, FormatValue(qllLlFeatureReq.UserFields.Timestamp, 32), "", "", "", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Handle", "", 8, FormatValue(qllLlFeatureReq.UserFields.Handle, 8), "", "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("PDU_Length", "", 8, FormatValue(qllLlFeatureReq.UserFields.PduLength, 8), "", "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Channel", QllLlFeatureReq.UserFieldsWrapper.ChannelInfo.ChannelToDescription(), 8, FormatValue(qllLlFeatureReq.UserFields.Channel, 8), QllLlFeatureReq.UserFieldsWrapper.ChannelInfo.ChannelToString(QllLlFeatureReq.UserFieldsWrapper.ChannelInfo.ValueToChannel(qllLlFeatureReq.UserFields.Channel)), "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Opcode", QllLlFeatureReq.UserFieldsWrapper.OpcodeInfo.OpcodeToDescription(), 8, FormatValue(qllLlFeatureReq.UserFields.Opcode, 8), QllLlFeatureReq.UserFieldsWrapper.OpcodeInfo.OpcodeToString(QllLlFeatureReq.UserFieldsWrapper.OpcodeInfo.ValueToOpcode(qllLlFeatureReq.UserFields.Opcode)), "", "", settable: false, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Feature_Set", QllLlFeatureReq.UserFieldsWrapper.FeatureSetInfo.FeatureSetToDescription(), 64, FormatValue(qllLlFeatureReq.UserFields.FeatureSet, 64), QllLlFeatureReq.UserFieldsWrapper.FeatureSetInfo.FeatureSetToString(QllLlFeatureReq.UserFieldsWrapper.FeatureSetInfo.ValueToFeatureSet(qllLlFeatureReq.UserFields.FeatureSet)), "", "", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Event_counter", "", 16, FormatValue(qllLlFeatureReq.UserFields.EventCounter, 16), "", "", "", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
	}

	public override void UpdatePacketFromFieldInfo(int index, string value)
	{
		QllLlFeatureReq qllLlFeatureReq = (QllLlFeatureReq)packet;
		int num = -1;
		if (index == ++num)
		{
			qllLlFeatureReq.UserFields.SeqNum = Convert.ToUInt32(value, 16);
			return;
		}
		if (index == ++num)
		{
			qllLlFeatureReq.UserFields.LogsLostDrop = Convert.ToUInt32(value, 16);
			return;
		}
		if (index == ++num)
		{
			qllLlFeatureReq.UserFields.ProdId = Convert.ToUInt32(value, 16);
			return;
		}
		if (index == ++num)
		{
			qllLlFeatureReq.UserFields.LogId = Convert.ToUInt32(value, 16);
			return;
		}
		if (index == ++num)
		{
			qllLlFeatureReq.UserFields.LogFormatLevel = Convert.ToUInt32(value, 16);
			return;
		}
		if (index == ++num)
		{
			qllLlFeatureReq.UserFields.Timestamp = Convert.ToUInt32(value, 16);
			return;
		}
		if (index == ++num)
		{
			qllLlFeatureReq.UserFields.Handle = Convert.ToUInt32(value, 16);
			return;
		}
		if (index == ++num)
		{
			qllLlFeatureReq.UserFields.PduLength = Convert.ToUInt32(value, 16);
			return;
		}
		if (index == ++num)
		{
			qllLlFeatureReq.UserFields.Channel = Convert.ToUInt32(value, 16);
			return;
		}
		if (index == ++num)
		{
			throw new Exception("Tried to set non-settable field Opcode");
		}
		if (index == ++num)
		{
			qllLlFeatureReq.UserFields.FeatureSet = Convert.ToUInt64(value, 16);
		}
		else if (index == ++num)
		{
			qllLlFeatureReq.UserFields.EventCounter = Convert.ToUInt32(value, 16);
		}
	}
}
