using System;
using QCRPG.Framework;

namespace QCRPG.TSL.BT.Packets;

public class LeSetDefaultPhyInfo : PacketInfoBase
{
	public override string Name => "Le Set Default Phy";

	public override string DisplayGroup => "LE Controller";

	public LeSetDefaultPhyInfo(LeSetDefaultPhy packet)
		: base(packet)
	{
		UpdateFieldInfoFromPacket();
	}

	public override void UpdateFieldInfoFromPacket()
	{
		LeSetDefaultPhy leSetDefaultPhy = (LeSetDefaultPhy)packet;
		fieldInfoList.Clear();
		fieldInfoList.Add(new PacketFieldInfo("ALL_PHYS", PhyPreferenceUseInfo.PhyPreferenceUseToDescription(), 8, FormatValue(leSetDefaultPhy.UserFields.AllPhys, 8), PhyPreferenceUseInfo.PhyPreferenceUseToString(PhyPreferenceUseInfo.ValueToPhyPreferenceUse(leSetDefaultPhy.UserFields.AllPhys)), "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("TX_PHYS", TransmitterPhyPreferenceInfo.TransmitterPhyPreferenceToDescription(), 8, FormatValue(leSetDefaultPhy.UserFields.TxPhys, 8), TransmitterPhyPreferenceInfo.TransmitterPhyPreferenceToString(TransmitterPhyPreferenceInfo.ValueToTransmitterPhyPreference(leSetDefaultPhy.UserFields.TxPhys)), "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("RX_PHYS", ReceiverPhyPreferenceInfo.ReceiverPhyPreferenceToDescription(), 8, FormatValue(leSetDefaultPhy.UserFields.RxPhys, 8), ReceiverPhyPreferenceInfo.ReceiverPhyPreferenceToString(ReceiverPhyPreferenceInfo.ValueToReceiverPhyPreference(leSetDefaultPhy.UserFields.RxPhys)), "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
	}

	public override void UpdatePacketFromFieldInfo(int index, string value)
	{
		LeSetDefaultPhy leSetDefaultPhy = (LeSetDefaultPhy)packet;
		int num = -1;
		if (index == ++num)
		{
			leSetDefaultPhy.UserFields.AllPhys = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			leSetDefaultPhy.UserFields.TxPhys = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			leSetDefaultPhy.UserFields.RxPhys = Convert.ToUInt32(value, 16);
		}
	}
}
