using System;
using QCRPG.Framework;

namespace QCRPG.TSL.BT.Packets;

public class DebugCxmLogInfo : PacketInfoBase
{
	public override string Name => "Debug Cxm Log";

	public override string DisplayGroup => "Vendor Specific";

	public DebugCxmLogInfo(DebugCxmLog packet)
		: base(packet)
	{
		UpdateFieldInfoFromPacket();
	}

	public override void UpdateFieldInfoFromPacket()
	{
		DebugCxmLog debugCxmLog = (DebugCxmLog)packet;
		fieldInfoList.Clear();
		fieldInfoList.Add(new PacketFieldInfo("VS Event Type", "Debug VS Event", 8, FormatValue(debugCxmLog.UserFields.VsEventType, 8), "", "", "", settable: false, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Sub OpCode", "HCI_VS_DEBUG_CXM_LOG_EVT", 8, FormatValue(debugCxmLog.UserFields.SubOpcode, 8), "", "", "", settable: false, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Mci_Mws Msg Payload Length", "MCI/MWS Message Payload Length - Byte 4", 8, FormatValue(debugCxmLog.UserFields.MciMwsMsgPayloadLength, 8), "", "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Mci_Mws Msg Header", "MCI/MWS Message Header - Byte 5", 8, FormatValue(debugCxmLog.UserFields.MciMwsMsgHeader, 8), "", "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Padding and Timestamp", "Word aligned padding and timestamp.", 24, FormatValue(debugCxmLog.UserFields.PaddingAndTimestamp, 24), "", "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Byte 9", "Byte 9", 8, FormatValue(debugCxmLog.UserFields.Byte9, 8), "", "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Byte 10", "Byte 10", 8, FormatValue(debugCxmLog.UserFields.Byte10, 8), "", "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Byte 11", "Byte 11", 8, FormatValue(debugCxmLog.UserFields.Byte11, 8), "", "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Byte 12", "Byte 12", 8, FormatValue(debugCxmLog.UserFields.Byte12, 8), "", "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Mci_Mws GPM Type", "MCI/MWS GPM Type - Byte 13", 8, FormatValue(debugCxmLog.UserFields.MciMwsGpmType, 8), "", "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Mci_Mws Agent Type", "MCI/MWS COEX Agent Type - Byte 14", 8, FormatValue(debugCxmLog.UserFields.MciMwsAgentType, 8), "", "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		for (int i = 0; i < debugCxmLog.UserFields.RemainingPayloadList.Count; i++)
		{
			fieldInfoList.Add(new PacketFieldInfo("Payload_Byte[" + i + "]", "", 8, FormatValue(debugCxmLog.UserFields.RemainingPayloadList[i].PayloadByte, 8), "", "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		}
	}

	public override void UpdatePacketFromFieldInfo(int index, string value)
	{
		DebugCxmLog debugCxmLog = (DebugCxmLog)packet;
		int num = -1;
		if (index == ++num)
		{
			throw new Exception("Tried to set non-settable field VsEventType");
		}
		if (index == ++num)
		{
			throw new Exception("Tried to set non-settable field SubOpcode");
		}
		if (index == ++num)
		{
			debugCxmLog.UserFields.MciMwsMsgPayloadLength = Convert.ToUInt32(value, 16);
			return;
		}
		if (index == ++num)
		{
			debugCxmLog.UserFields.MciMwsMsgHeader = Convert.ToUInt32(value, 16);
			return;
		}
		if (index == ++num)
		{
			debugCxmLog.UserFields.PaddingAndTimestamp = Convert.ToUInt32(value, 16);
			return;
		}
		if (index == ++num)
		{
			debugCxmLog.UserFields.Byte9 = Convert.ToUInt32(value, 16);
			return;
		}
		if (index == ++num)
		{
			debugCxmLog.UserFields.Byte10 = Convert.ToUInt32(value, 16);
			return;
		}
		if (index == ++num)
		{
			debugCxmLog.UserFields.Byte11 = Convert.ToUInt32(value, 16);
			return;
		}
		if (index == ++num)
		{
			debugCxmLog.UserFields.Byte12 = Convert.ToUInt32(value, 16);
			return;
		}
		if (index == ++num)
		{
			debugCxmLog.UserFields.MciMwsGpmType = Convert.ToUInt32(value, 16);
			return;
		}
		if (index == ++num)
		{
			debugCxmLog.UserFields.MciMwsAgentType = Convert.ToUInt32(value, 16);
			return;
		}
		for (int i = 0; i < debugCxmLog.UserFields.RemainingPayloadList.Count; i++)
		{
			if (index == ++num)
			{
				debugCxmLog.UserFields.RemainingPayloadList[i].PayloadByte = Convert.ToUInt32(value, 16);
				break;
			}
		}
	}
}
