using System;
using QCRPG.Framework;

namespace QCRPG.TSL.BT.Packets;

public class SetMptaDeviceStatusInfo : PacketInfoBase
{
	public override string Name => "Set Mpta Device Status";

	public override string DisplayGroup => "Vendor Specific";

	public SetMptaDeviceStatusInfo(SetMptaDeviceStatus packet)
		: base(packet)
	{
		UpdateFieldInfoFromPacket();
	}

	public override void UpdateFieldInfoFromPacket()
	{
		SetMptaDeviceStatus setMptaDeviceStatus = (SetMptaDeviceStatus)packet;
		fieldInfoList.Clear();
		fieldInfoList.Add(new PacketFieldInfo("Sub OpCode", SetMptaDeviceStatus.UserFieldsWrapper.SubOpcodeInfo.SubOpcodeToDescription(), 8, FormatValue(setMptaDeviceStatus.UserFields.SubOpcode, 8), SetMptaDeviceStatus.UserFieldsWrapper.SubOpcodeInfo.SubOpcodeToString(SetMptaDeviceStatus.UserFieldsWrapper.SubOpcodeInfo.ValueToSubOpcode(setMptaDeviceStatus.UserFields.SubOpcode)), "", "", settable: false, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Status", "The external device status\r\n\r\n" + SetMptaDeviceStatus.UserFieldsWrapper.StatusInfo.StatusToDescription(), 8, FormatValue(setMptaDeviceStatus.UserFields.Status, 8), SetMptaDeviceStatus.UserFieldsWrapper.StatusInfo.StatusToString(SetMptaDeviceStatus.UserFieldsWrapper.StatusInfo.ValueToStatus(setMptaDeviceStatus.UserFields.Status)), "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
	}

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