using System;
using QCRPG.Framework;

namespace QCRPG.TSL.BT.Packets;

public class QlmpEstServiceReqInfo : PacketInfoBase
{
	public override string Name => "Qlmp Est Service Req";

	public override string DisplayGroup => "Enhanced Logging";

	public QlmpEstServiceReqInfo(QlmpEstServiceReq packet)
		: base(packet)
	{
		UpdateFieldInfoFromPacket();
	}

	public override void UpdateFieldInfoFromPacket()
	{
		QlmpEstServiceReq qlmpEstServiceReq = (QlmpEstServiceReq)packet;
		fieldInfoList.Clear();
		fieldInfoList.Add(new PacketFieldInfo("Seq_Num", "", 8, FormatValue(qlmpEstServiceReq.UserFields.SeqNum, 8), "", "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Logs_Lost_Drop", "", 8, FormatValue(qlmpEstServiceReq.UserFields.LogsLostDrop, 8), "", "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Prod_ID", "", 8, FormatValue(qlmpEstServiceReq.UserFields.ProdId, 8), "", "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Log_Id", QlmpEstServiceReq.UserFieldsWrapper.LogIdInfo.LogIdToDescription(), 16, FormatValue(qlmpEstServiceReq.UserFields.LogId, 16), QlmpEstServiceReq.UserFieldsWrapper.LogIdInfo.LogIdToString(QlmpEstServiceReq.UserFieldsWrapper.LogIdInfo.ValueToLogId(qlmpEstServiceReq.UserFields.LogId)), "", "", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Log_Format_Level", "", 8, FormatValue(qlmpEstServiceReq.UserFields.LogFormatLevel, 8), "", "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Timestamp", "", 32, FormatValue(qlmpEstServiceReq.UserFields.Timestamp, 32), "", "", "", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Handle", "", 8, FormatValue(qlmpEstServiceReq.UserFields.Handle, 8), "", "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Minor_Type", QlmpEstServiceReq.UserFieldsWrapper.MinorTypeInfo.MinorTypeToDescription(), 8, FormatValue(qlmpEstServiceReq.UserFields.MinorType, 8), QlmpEstServiceReq.UserFieldsWrapper.MinorTypeInfo.MinorTypeToString(QlmpEstServiceReq.UserFieldsWrapper.MinorTypeInfo.ValueToMinorType(qlmpEstServiceReq.UserFields.MinorType)), "", "", settable: false, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("PDU_Length", "", 8, FormatValue(qlmpEstServiceReq.UserFields.PduLength, 8), "", "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Supported_Keys", QlmpEstServiceReq.UserFieldsWrapper.SupportedKeysInfo.SupportedKeysToDescription(), 32, FormatValue(qlmpEstServiceReq.UserFields.SupportedKeys, 32), QlmpEstServiceReq.UserFieldsWrapper.SupportedKeysInfo.SupportedKeysToString(QlmpEstServiceReq.UserFieldsWrapper.SupportedKeysInfo.ValueToSupportedKeys(qlmpEstServiceReq.UserFields.SupportedKeys)), "", "", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
	}

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