using System;
using QCRPG.Framework;

namespace QCRPG.TSL.BT.Packets;

public class SetMptaContinuousTxGapInfo : PacketInfoBase
{
	public override string Name => "Set Mpta Continuous Tx Gap";

	public override string DisplayGroup => "Vendor Specific";

	public SetMptaContinuousTxGapInfo(SetMptaContinuousTxGap packet)
		: base(packet)
	{
		UpdateFieldInfoFromPacket();
	}

	public override void UpdateFieldInfoFromPacket()
	{
		SetMptaContinuousTxGap setMptaContinuousTxGap = (SetMptaContinuousTxGap)packet;
		fieldInfoList.Clear();
		fieldInfoList.Add(new PacketFieldInfo("Sub OpCode", SetMptaContinuousTxGap.UserFieldsWrapper.SubOpcodeInfo.SubOpcodeToDescription(), 8, FormatValue(setMptaContinuousTxGap.UserFields.SubOpcode, 8), SetMptaContinuousTxGap.UserFieldsWrapper.SubOpcodeInfo.SubOpcodeToString(SetMptaContinuousTxGap.UserFieldsWrapper.SubOpcodeInfo.ValueToSubOpcode(setMptaContinuousTxGap.UserFields.SubOpcode)), "", "", settable: false, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Enable", "Enable the continues Tx gap\r\n\r\n" + SetMptaContinuousTxGap.UserFieldsWrapper.EnableInfo.EnableToDescription(), 8, FormatValue(setMptaContinuousTxGap.UserFields.Enable, 8), SetMptaContinuousTxGap.UserFieldsWrapper.EnableInfo.EnableToString(SetMptaContinuousTxGap.UserFieldsWrapper.EnableInfo.ValueToEnable(setMptaContinuousTxGap.UserFields.Enable)), "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Continues Interval", "Interval for continuous Tx (ms)", 32, FormatValue(setMptaContinuousTxGap.UserFields.ContinuesInterval, 32), "", "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Continues Gap", "Gap for continuous Tx (ms)", 16, FormatValue(setMptaContinuousTxGap.UserFields.ContinuesGap, 16), "", "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
	}

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