using System;
using QCRPG.Framework;

namespace QCRPG.TSL.BT.Packets;

public class CommandCompleteForReadLocalSupportedCodecsInfo : PacketInfoBase
{
	public override string Name => "Command Complete For Read Local Supported Codecs";

	public override string DisplayGroup => "Information Parameters";

	public CommandCompleteForReadLocalSupportedCodecsInfo(CommandCompleteForReadLocalSupportedCodecs packet)
		: base(packet)
	{
		UpdateFieldInfoFromPacket();
	}

	public override void UpdateFieldInfoFromPacket()
	{
		CommandCompleteForReadLocalSupportedCodecs commandCompleteForReadLocalSupportedCodecs = (CommandCompleteForReadLocalSupportedCodecs)packet;
		fieldInfoList.Clear();
		fieldInfoList.Add(new PacketFieldInfo("Num HCI Command Packets", "", 8, FormatValue(commandCompleteForReadLocalSupportedCodecs.UserFields.NumHciCommandPackets, 8), "", "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Command OpCode", CommandOpcodeInfo.CommandOpcodeToDescription(), 16, FormatValue(commandCompleteForReadLocalSupportedCodecs.UserFields.CommandOpcode, 16), CommandOpcodeInfo.CommandOpcodeToString(CommandOpcodeInfo.ValueToCommandOpcode(commandCompleteForReadLocalSupportedCodecs.UserFields.CommandOpcode)), "", "", settable: false, littleEndianTransport: true, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Status", ErrorCodeInfo.ErrorCodeToDescription(), 8, FormatValue(commandCompleteForReadLocalSupportedCodecs.UserFields.Status, 8), ErrorCodeInfo.ErrorCodeToString(ErrorCodeInfo.ValueToErrorCode(commandCompleteForReadLocalSupportedCodecs.UserFields.Status)), "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Number_of_Supported_Codecs", "Total number of codecs supported.", 8, FormatValue(commandCompleteForReadLocalSupportedCodecs.UserFields.NumberOfSupportedCodecs, 8), "", "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		for (int i = 0; i < commandCompleteForReadLocalSupportedCodecs.UserFields.NumSupportedCodecsList.Count; i++)
		{
			fieldInfoList.Add(new PacketFieldInfo("Supported_Codecs[" + i + "]", "", 8, FormatValue(commandCompleteForReadLocalSupportedCodecs.UserFields.NumSupportedCodecsList[i].SupportedCodecs, 8), "", "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		}
		fieldInfoList.Add(new PacketFieldInfo("Number_of_Supported_Vendor_Specific_Codecs", "Total number of vendor specific codecs supported.", 8, FormatValue(commandCompleteForReadLocalSupportedCodecs.UserFields.NumberOfSupportedVendorSpecificCodecs, 8), "", "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		for (int j = 0; j < commandCompleteForReadLocalSupportedCodecs.UserFields.NumVendorSpecificCodecsList.Count; j++)
		{
			fieldInfoList.Add(new PacketFieldInfo("Vendor_Specific_Codecs[" + j + "]", "", 32, FormatValue(commandCompleteForReadLocalSupportedCodecs.UserFields.NumVendorSpecificCodecsList[j].VendorSpecificCodecs, 32), "", "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		}
	}

	public override void UpdatePacketFromFieldInfo(int index, string value)
	{
		CommandCompleteForReadLocalSupportedCodecs commandCompleteForReadLocalSupportedCodecs = (CommandCompleteForReadLocalSupportedCodecs)packet;
		int num = -1;
		if (index == ++num)
		{
			commandCompleteForReadLocalSupportedCodecs.UserFields.NumHciCommandPackets = Convert.ToUInt32(value, 16);
			return;
		}
		if (index == ++num)
		{
			throw new Exception("Tried to set non-settable field CommandOpcode");
		}
		if (index == ++num)
		{
			commandCompleteForReadLocalSupportedCodecs.UserFields.Status = Convert.ToUInt32(value, 16);
			return;
		}
		if (index == ++num)
		{
			commandCompleteForReadLocalSupportedCodecs.UserFields.NumberOfSupportedCodecs = Convert.ToUInt32(value, 16);
			return;
		}
		for (int i = 0; i < commandCompleteForReadLocalSupportedCodecs.UserFields.NumSupportedCodecsList.Count; i++)
		{
			if (index == ++num)
			{
				commandCompleteForReadLocalSupportedCodecs.UserFields.NumSupportedCodecsList[i].SupportedCodecs = Convert.ToUInt32(value, 16);
				return;
			}
		}
		if (index == ++num)
		{
			commandCompleteForReadLocalSupportedCodecs.UserFields.NumberOfSupportedVendorSpecificCodecs = Convert.ToUInt32(value, 16);
			return;
		}
		for (int j = 0; j < commandCompleteForReadLocalSupportedCodecs.UserFields.NumVendorSpecificCodecsList.Count; j++)
		{
			if (index == ++num)
			{
				commandCompleteForReadLocalSupportedCodecs.UserFields.NumVendorSpecificCodecsList[j].VendorSpecificCodecs = Convert.ToUInt32(value, 16);
				break;
			}
		}
	}
}
