using System;
using QCRPG.Framework;

namespace QCRPG.TSL.BT.Packets;

public class EdlBurnSyscfgRequestInfo : PacketInfoBase
{
	public override string Name => "Edl Burn Syscfg Request";

	public override string DisplayGroup => "Vendor Specific";

	public EdlBurnSyscfgRequestInfo(EdlBurnSyscfgRequest packet)
		: base(packet)
	{
		UpdateFieldInfoFromPacket();
	}

	public override void UpdateFieldInfoFromPacket()
	{
		EdlBurnSyscfgRequest edlBurnSyscfgRequest = (EdlBurnSyscfgRequest)packet;
		fieldInfoList.Clear();
		fieldInfoList.Add(new PacketFieldInfo("Sub OpCode", "EDL_BURN_SYSCFG_REQUEST", 8, FormatValue(edlBurnSyscfgRequest.UserFields.SubOpcode, 8), "", "", "", settable: false, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Address", "Syscfg memory address", 32, FormatValue(edlBurnSyscfgRequest.UserFields.Address, 32), "", "", "", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Length", "Syscfg length", 32, FormatValue(edlBurnSyscfgRequest.UserFields.Length, 32), "", "", "", settable: true, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
	}

	public override void UpdatePacketFromFieldInfo(int index, string value)
	{
		EdlBurnSyscfgRequest edlBurnSyscfgRequest = (EdlBurnSyscfgRequest)packet;
		int num = -1;
		if (index == ++num)
		{
			throw new Exception("Tried to set non-settable field SubOpcode");
		}
		if (index == ++num)
		{
			edlBurnSyscfgRequest.UserFields.Address = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			edlBurnSyscfgRequest.UserFields.Length = Convert.ToUInt32(value, 16);
		}
	}
}
