using System;
using QCRPG.Framework;

namespace QCRPG.TSL.BT.Packets;

public class EdlStorePsInfo : PacketInfoBase
{
	public override string Name => "Edl Store Ps";

	public override string DisplayGroup => "Vendor Specific";

	public EdlStorePsInfo(EdlStorePs packet)
		: base(packet)
	{
		UpdateFieldInfoFromPacket();
	}

	public override void UpdateFieldInfoFromPacket()
	{
		EdlStorePs edlStorePs = (EdlStorePs)packet;
		fieldInfoList.Clear();
		fieldInfoList.Add(new PacketFieldInfo("Sub OpCode", "EDL_STORE_PS", 8, FormatValue(edlStorePs.UserFields.SubOpcode, 8), "", "", "", settable: false, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("File Type", "File_Type\r\n\r\n" + EdlStorePs.UserFieldsWrapper.FileTypeInfo.FileTypeToDescription(), 8, FormatValue(edlStorePs.UserFields.FileType, 8), EdlStorePs.UserFieldsWrapper.FileTypeInfo.FileTypeToString(EdlStorePs.UserFieldsWrapper.FileTypeInfo.ValueToFileType(edlStorePs.UserFields.FileType)), "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Enable", "Enable\r\n\r\n" + EdlStorePs.UserFieldsWrapper.EnableInfo.EnableToDescription(), 8, FormatValue(edlStorePs.UserFields.Enable, 8), EdlStorePs.UserFieldsWrapper.EnableInfo.EnableToString(EdlStorePs.UserFieldsWrapper.EnableInfo.ValueToEnable(edlStorePs.UserFields.Enable)), "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
	}

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