using System;
using QCRPG.Framework;

namespace QCRPG.TSL.BT.Packets;

public class A2dpSinkStopInfo : PacketInfoBase
{
	public override string Name => "A2dp Sink Stop";

	public override string DisplayGroup => "Vendor Specific";

	public A2dpSinkStopInfo(A2dpSinkStop packet)
		: base(packet)
	{
		UpdateFieldInfoFromPacket();
	}

	public override void UpdateFieldInfoFromPacket()
	{
		A2dpSinkStop a2dpSinkStop = (A2dpSinkStop)packet;
		fieldInfoList.Clear();
		fieldInfoList.Add(new PacketFieldInfo("Sub OpCode", A2dpSinkStop.UserFieldsWrapper.SubOpcodeInfo.SubOpcodeToDescription(), 8, FormatValue(a2dpSinkStop.UserFields.SubOpcode, 8), A2dpSinkStop.UserFieldsWrapper.SubOpcodeInfo.SubOpcodeToString(A2dpSinkStop.UserFieldsWrapper.SubOpcodeInfo.ValueToSubOpcode(a2dpSinkStop.UserFields.SubOpcode)), "", "", settable: false, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Stream_Handle", "Stream Handle for A2DP sink stream", 8, FormatValue(a2dpSinkStop.UserFields.StreamHandle, 8), "", "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
	}

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