using System;
using QCRPG.Framework;

namespace QCRPG.TSL.BT.Packets;

public class Q2qDebugEventInfo : PacketInfoBase
{
	public override string Name => "Q2q Debug Event";

	public override string DisplayGroup => "Vendor Specific";

	public Q2qDebugEventInfo(Q2qDebugEvent packet)
		: base(packet)
	{
		UpdateFieldInfoFromPacket();
	}

	public override void UpdateFieldInfoFromPacket()
	{
		Q2qDebugEvent q2qDebugEvent = (Q2qDebugEvent)packet;
		fieldInfoList.Clear();
		fieldInfoList.Add(new PacketFieldInfo("Sub_Opcode", "", 8, FormatValue(q2qDebugEvent.UserFields.SubOpcode, 8), "", "", "", settable: false, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Q2Q_opcode", Q2qDebugEvent.UserFieldsWrapper.Q2qOpcodeInfo.Q2qOpcodeToDescription(), 8, FormatValue(q2qDebugEvent.UserFields.Q2qOpcode, 8), Q2qDebugEvent.UserFieldsWrapper.Q2qOpcodeInfo.Q2qOpcodeToString(Q2qDebugEvent.UserFieldsWrapper.Q2qOpcodeInfo.ValueToQ2qOpcode(q2qDebugEvent.UserFields.Q2qOpcode)), "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
	}

	public override void UpdatePacketFromFieldInfo(int index, string value)
	{
		Q2qDebugEvent q2qDebugEvent = (Q2qDebugEvent)packet;
		int num = -1;
		if (index == ++num)
		{
			throw new Exception("Tried to set non-settable field SubOpcode");
		}
		if (index == ++num)
		{
			q2qDebugEvent.UserFields.Q2qOpcode = Convert.ToUInt32(value, 16);
		}
	}
}
