using System;
using QCRPG.Framework;

namespace QCRPG.TSL.BT.Packets;

public class ReadClockInfo : PacketInfoBase
{
	public override string Name => "Read Clock";

	public override string DisplayGroup => "Status Parameters";

	public ReadClockInfo(ReadClock packet)
		: base(packet)
	{
		UpdateFieldInfoFromPacket();
	}

	public override void UpdateFieldInfoFromPacket()
	{
		ReadClock readClock = (ReadClock)packet;
		fieldInfoList.Clear();
		fieldInfoList.Add(new PacketFieldInfo("Connection Handle", "", 16, FormatValue(readClock.UserFields.ConnectionHandle, 16), "", "0000", "0EFF", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Which Clock", ReadClock.UserFieldsWrapper.WhichClockInfo.WhichClockToDescription(), 8, FormatValue(readClock.UserFields.WhichClock, 8), ReadClock.UserFieldsWrapper.WhichClockInfo.WhichClockToString(ReadClock.UserFieldsWrapper.WhichClockInfo.ValueToWhichClock(readClock.UserFields.WhichClock)), "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
	}

	public override void UpdatePacketFromFieldInfo(int index, string value)
	{
		ReadClock readClock = (ReadClock)packet;
		int num = -1;
		if (index == ++num)
		{
			readClock.UserFields.ConnectionHandle = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			readClock.UserFields.WhichClock = Convert.ToUInt32(value, 16);
		}
	}
}
