using System;
using QCRPG.Framework;

namespace QCRPG.TSL.FMHCI.Packets;

public class SsbiPokeRegisterInfo : PacketInfoBase
{
	public override string Name => "Ssbi Poke Register";

	public override string DisplayGroup => "Diagnostic";

	public SsbiPokeRegisterInfo(SsbiPokeRegister packet)
		: base(packet)
	{
		UpdateFieldInfoFromPacket();
	}

	public override void UpdateFieldInfoFromPacket()
	{
		SsbiPokeRegister ssbiPokeRegister = (SsbiPokeRegister)packet;
		fieldInfoList.Clear();
		fieldInfoList.Add(new PacketFieldInfo("Address", "Register address, 10 bit", 16, FormatValue(ssbiPokeRegister.UserFields.Address, 16), "", "", "3FF", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Data", "Register data to write", 8, FormatValue(ssbiPokeRegister.UserFields.Data, 8), "", "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
	}

	public override void UpdatePacketFromFieldInfo(int index, string value)
	{
		SsbiPokeRegister ssbiPokeRegister = (SsbiPokeRegister)packet;
		int num = -1;
		if (index == ++num)
		{
			ssbiPokeRegister.UserFields.Address = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			ssbiPokeRegister.UserFields.Data = Convert.ToUInt32(value, 16);
		}
	}
}
