using System;
using QCRPG.Framework;

namespace QCRPG.TSL.BT.Packets;

public class SetMptaGrantModeEdgeDelayInfo : PacketInfoBase
{
	public override string Name => "Set Mpta Grant Mode Edge Delay";

	public override string DisplayGroup => "Vendor Specific";

	public SetMptaGrantModeEdgeDelayInfo(SetMptaGrantModeEdgeDelay packet)
		: base(packet)
	{
		UpdateFieldInfoFromPacket();
	}

	public override void UpdateFieldInfoFromPacket()
	{
		SetMptaGrantModeEdgeDelay setMptaGrantModeEdgeDelay = (SetMptaGrantModeEdgeDelay)packet;
		fieldInfoList.Clear();
		fieldInfoList.Add(new PacketFieldInfo("Sub OpCode", SetMptaGrantModeEdgeDelay.UserFieldsWrapper.SubOpcodeInfo.SubOpcodeToDescription(), 8, FormatValue(setMptaGrantModeEdgeDelay.UserFields.SubOpcode, 8), SetMptaGrantModeEdgeDelay.UserFieldsWrapper.SubOpcodeInfo.SubOpcodeToString(SetMptaGrantModeEdgeDelay.UserFieldsWrapper.SubOpcodeInfo.ValueToSubOpcode(setMptaGrantModeEdgeDelay.UserFields.SubOpcode)), "", "", settable: false, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("OP Type", SetMptaGrantModeEdgeDelay.UserFieldsWrapper.OpTypeInfo.OpTypeToDescription(), 8, FormatValue(setMptaGrantModeEdgeDelay.UserFields.OpType, 8), SetMptaGrantModeEdgeDelay.UserFieldsWrapper.OpTypeInfo.OpTypeToString(SetMptaGrantModeEdgeDelay.UserFieldsWrapper.OpTypeInfo.ValueToOpType(setMptaGrantModeEdgeDelay.UserFields.OpType)), "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Delay", "Edge Delay value in usec", 8, FormatValue(setMptaGrantModeEdgeDelay.UserFields.Delay, 8), "", "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
	}

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