using System;
using QCRPG.Framework;

namespace QCRPG.TSL.BT.Packets;

public class MasterLinkKeyInfo : PacketInfoBase
{
	public override string Name => "Master Link Key";

	public override string DisplayGroup => "Link Control";

	public MasterLinkKeyInfo(MasterLinkKey packet)
		: base(packet)
	{
		UpdateFieldInfoFromPacket();
	}

	public override void UpdateFieldInfoFromPacket()
	{
		MasterLinkKey masterLinkKey = (MasterLinkKey)packet;
		fieldInfoList.Clear();
		fieldInfoList.Add(new PacketFieldInfo("Key Flag", MasterLinkKey.UserFieldsWrapper.KeyFlagInfo.KeyFlagToDescription(), 8, FormatValue(masterLinkKey.UserFields.KeyFlag, 8), MasterLinkKey.UserFieldsWrapper.KeyFlagInfo.KeyFlagToString(MasterLinkKey.UserFieldsWrapper.KeyFlagInfo.ValueToKeyFlag(masterLinkKey.UserFields.KeyFlag)), "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
	}

	public override void UpdatePacketFromFieldInfo(int index, string value)
	{
		MasterLinkKey masterLinkKey = (MasterLinkKey)packet;
		int num = -1;
		if (index == ++num)
		{
			masterLinkKey.UserFields.KeyFlag = Convert.ToUInt32(value, 16);
		}
	}
}
