using System;
using QCRPG.Framework;

namespace QCRPG.TSL.BT.Packets;

public class SetFeatureBitInfo : PacketInfoBase
{
	public override string Name => "Set Feature Bit";

	public override string DisplayGroup => "Vendor Specific";

	public SetFeatureBitInfo(SetFeatureBit packet)
		: base(packet)
	{
		UpdateFieldInfoFromPacket();
	}

	public override void UpdateFieldInfoFromPacket()
	{
		SetFeatureBit setFeatureBit = (SetFeatureBit)packet;
		fieldInfoList.Clear();
		fieldInfoList.Add(new PacketFieldInfo("Bit_Number", "Feature bit number to be set or cleared, (0~255)", 8, FormatValue(setFeatureBit.UserFields.BitNumber, 8), "", "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Feature_Set_or_Clear", SetFeatureBit.UserFieldsWrapper.FeatureSetOrClearInfo.FeatureSetOrClearToDescription(), 8, FormatValue(setFeatureBit.UserFields.FeatureSetOrClear, 8), SetFeatureBit.UserFieldsWrapper.FeatureSetOrClearInfo.FeatureSetOrClearToString(SetFeatureBit.UserFieldsWrapper.FeatureSetOrClearInfo.ValueToFeatureSetOrClear(setFeatureBit.UserFields.FeatureSetOrClear)), "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
	}

	public override void UpdatePacketFromFieldInfo(int index, string value)
	{
		SetFeatureBit setFeatureBit = (SetFeatureBit)packet;
		int num = -1;
		if (index == ++num)
		{
			setFeatureBit.UserFields.BitNumber = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			setFeatureBit.UserFields.FeatureSetOrClear = Convert.ToUInt32(value, 16);
		}
	}
}
