package net.northking.cctp.upperComputer.driver.harmony.hyppium.data;

import com.google.gson.annotations.SerializedName;
import net.northking.cctp.upperComputer.driver.protocol.packet.CodecUtils;
import net.northking.cctp.upperComputer.driver.protocol.packet.ICommandData;

import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;
import java.util.ArrayList;

public class UiEventData implements ICommandData {
    @SerializedName("ABILITY")
    private String abilityName;

    @SerializedName("BUNDLE")
    private String bundleName;

    @SerializedName("CENTER_X")
    private double centerX;

    @SerializedName("CENTER_Y")
    private double centerY;

    @SerializedName("EVENT_TYPE")
    private String eventType;

    @SerializedName("LENGTH")
    private int length;

    @SerializedName("OP_TYPE")
    private String operationType;

    @SerializedName("VELO")
    private double velocity;

    @SerializedName("direction.X")
    private double directionX;

    @SerializedName("direction.Y")
    private double directionY;

    private long duration;

    private int fingerNumber;

    private ArrayList<UiEventFinger> fingerList = new ArrayList<>(0);

    public UiEventData() {

    }

    public UiEventData(DataInput dataInput) throws IOException {
        buildFromInput(dataInput);
    }

    @Override
    public void buildFromInput(DataInput dataInput) throws IOException {
        abilityName = CodecUtils.readNullable(dataInput, CodecUtils::readText);
        bundleName = CodecUtils.readNullable(dataInput, CodecUtils::readText);
        centerX = dataInput.readDouble();
        centerY = dataInput.readDouble();
        eventType = CodecUtils.readText(dataInput);
        length = dataInput.readInt();
        operationType = CodecUtils.readText(dataInput);
        velocity = dataInput.readDouble();
        directionX = dataInput.readDouble();
        directionY = dataInput.readDouble();
        duration = dataInput.readLong();
        fingerNumber = dataInput.readInt();
        int listCount = dataInput.readInt();
        for (int i = 0; i < listCount; i++) {
            UiEventFinger finger = new UiEventFinger();
        }
    }

    @Override
    public void encodeToOutput(DataOutput dataOutput) throws IOException {

    }
}