using System;
using QCRPG.Framework;

namespace QCRPG.TSL.BT.Packets;

public class SlcLogIdPollmgrResultInfo : PacketInfoBase
{
	public override string Name => "Slc Log Id Pollmgr Result";

	public override string DisplayGroup => "Enhanced Logging";

	public SlcLogIdPollmgrResultInfo(SlcLogIdPollmgrResult packet)
		: base(packet)
	{
		UpdateFieldInfoFromPacket();
	}

	public override void UpdateFieldInfoFromPacket()
	{
		SlcLogIdPollmgrResult slcLogIdPollmgrResult = (SlcLogIdPollmgrResult)packet;
		fieldInfoList.Clear();
		fieldInfoList.Add(new PacketFieldInfo("Seq_Num", "", 8, FormatValue(slcLogIdPollmgrResult.UserFields.SeqNum, 8), "", "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Logs_Lost_Drop", "", 8, FormatValue(slcLogIdPollmgrResult.UserFields.LogsLostDrop, 8), "", "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Prod_ID", "", 8, FormatValue(slcLogIdPollmgrResult.UserFields.ProdId, 8), "", "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Log_Id", SlcLogIdPollmgrResult.UserFieldsWrapper.LogIdInfo.LogIdToDescription(), 16, FormatValue(slcLogIdPollmgrResult.UserFields.LogId, 16), SlcLogIdPollmgrResult.UserFieldsWrapper.LogIdInfo.LogIdToString(SlcLogIdPollmgrResult.UserFieldsWrapper.LogIdInfo.ValueToLogId(slcLogIdPollmgrResult.UserFields.LogId)), "", "", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Log_Format_Level", "", 8, FormatValue(slcLogIdPollmgrResult.UserFields.LogFormatLevel, 8), "", "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Timestamp", "", 32, FormatValue(slcLogIdPollmgrResult.UserFields.Timestamp, 32), "", "", "", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("SLC_Fmt_Specifier", "", 2, FormatValue(slcLogIdPollmgrResult.UserFields.SlcFmtSpecifier, 2), "", "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("SLC_Log_ID", "", 6, FormatValue(slcLogIdPollmgrResult.UserFields.SlcLogId, 6), "", "", "", settable: false, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("HCI_Handle", "", 8, FormatValue(slcLogIdPollmgrResult.UserFields.HciHandle, 8), "", "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Poll_Mgr_Priority", "", 8, FormatValue(slcLogIdPollmgrResult.UserFields.PollMgrPriority, 8), "", "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
	}

	public override void UpdatePacketFromFieldInfo(int index, string value)
	{
		SlcLogIdPollmgrResult slcLogIdPollmgrResult = (SlcLogIdPollmgrResult)packet;
		int num = -1;
		if (index == ++num)
		{
			slcLogIdPollmgrResult.UserFields.SeqNum = Convert.ToUInt32(value, 16);
			return;
		}
		if (index == ++num)
		{
			slcLogIdPollmgrResult.UserFields.LogsLostDrop = Convert.ToUInt32(value, 16);
			return;
		}
		if (index == ++num)
		{
			slcLogIdPollmgrResult.UserFields.ProdId = Convert.ToUInt32(value, 16);
			return;
		}
		if (index == ++num)
		{
			slcLogIdPollmgrResult.UserFields.LogId = Convert.ToUInt32(value, 16);
			return;
		}
		if (index == ++num)
		{
			slcLogIdPollmgrResult.UserFields.LogFormatLevel = Convert.ToUInt32(value, 16);
			return;
		}
		if (index == ++num)
		{
			slcLogIdPollmgrResult.UserFields.Timestamp = Convert.ToUInt32(value, 16);
			return;
		}
		if (index == ++num)
		{
			slcLogIdPollmgrResult.UserFields.SlcFmtSpecifier = Convert.ToUInt32(value, 16);
			return;
		}
		if (index == ++num)
		{
			throw new Exception("Tried to set non-settable field SlcLogId");
		}
		if (index == ++num)
		{
			slcLogIdPollmgrResult.UserFields.HciHandle = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			slcLogIdPollmgrResult.UserFields.PollMgrPriority = Convert.ToUInt32(value, 16);
		}
	}
}
