using System;
using QCRPG.Framework;

namespace QCRPG.TSL.BT.Packets;

public class SetMptaPriorityWeightInfo : PacketInfoBase
{
	public override string Name => "Set Mpta Priority Weight";

	public override string DisplayGroup => "Vendor Specific";

	public SetMptaPriorityWeightInfo(SetMptaPriorityWeight packet)
		: base(packet)
	{
		UpdateFieldInfoFromPacket();
	}

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

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