using System;
using QCRPG.Framework;

namespace QCRPG.TSL.BT.Packets;

public class ReadMptaLevelConfigInfo : PacketInfoBase
{
	public override string Name => "Read Mpta Level Config";

	public override string DisplayGroup => "Vendor Specific";

	public ReadMptaLevelConfigInfo(ReadMptaLevelConfig packet)
		: base(packet)
	{
		UpdateFieldInfoFromPacket();
	}

	public override void UpdateFieldInfoFromPacket()
	{
		ReadMptaLevelConfig readMptaLevelConfig = (ReadMptaLevelConfig)packet;
		fieldInfoList.Clear();
		fieldInfoList.Add(new PacketFieldInfo("Sub OpCode", ReadMptaLevelConfig.UserFieldsWrapper.SubOpcodeInfo.SubOpcodeToDescription(), 8, FormatValue(readMptaLevelConfig.UserFields.SubOpcode, 8), ReadMptaLevelConfig.UserFieldsWrapper.SubOpcodeInfo.SubOpcodeToString(ReadMptaLevelConfig.UserFieldsWrapper.SubOpcodeInfo.ValueToSubOpcode(readMptaLevelConfig.UserFields.SubOpcode)), "", "", settable: false, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("OP Type", ReadMptaLevelConfig.UserFieldsWrapper.OpTypeInfo.OpTypeToDescription(), 8, FormatValue(readMptaLevelConfig.UserFields.OpType, 8), ReadMptaLevelConfig.UserFieldsWrapper.OpTypeInfo.OpTypeToString(ReadMptaLevelConfig.UserFieldsWrapper.OpTypeInfo.ValueToOpType(readMptaLevelConfig.UserFields.OpType)), "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
	}

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