Beispiel #1
0
        public static PPDPlayDecorder FromStream(Stream stream)
        {
            var ret = new PPDPlayDecorder();

            using (GZipStream compStream = new GZipStream(stream, CompressionMode.Decompress))
            {
                int    readSize = 0;
                byte[] bytes2   = new byte[2];
                byte[] bytes4   = new byte[4];
                byte[] bytes8   = new byte[8];
                while (true)
                {
                    UInt16[] pressCount = new UInt16[10];
                    byte[]   pressed    = new byte[2];
                    byte[]   released   = new byte[2];
                    readSize = compStream.Read(bytes4, 0, bytes4.Length);
                    if (readSize == 0)
                    {
                        break;
                    }
                    var time = BitConverter.ToSingle(bytes4, 0);
                    readSize = compStream.Read(bytes8, 0, bytes8.Length);
                    if (readSize == 0)
                    {
                        break;
                    }
                    var currentTime = BitConverter.ToInt64(bytes8, 0);
                    readSize = compStream.Read(bytes2, 0, bytes2.Length);
                    if (readSize == 0)
                    {
                        break;
                    }
                    var bits = new BitArray(bytes2);
                    for (int i = 0; i < pressCount.Length; i++)
                    {
                        if (bits.Get(i))
                        {
                            readSize = compStream.Read(bytes2, 0, bytes2.Length);
                            if (readSize == 0)
                            {
                                break;
                            }
                            pressCount[i] = BitConverter.ToUInt16(bytes2, 0);
                        }
                    }
                    readSize = compStream.Read(pressed, 0, pressed.Length);
                    if (readSize == 0)
                    {
                        break;
                    }
                    readSize = compStream.Read(released, 0, released.Length);
                    if (readSize == 0)
                    {
                        break;
                    }
                    ret.inputs.Add(new PPDPlayInput(time, currentTime, pressCount, pressed, released));
                }
            }
            return(ret);
        }
Beispiel #2
0
        public static PPDPlayDecorder FromBytes(byte[] bytes)
        {
            int             version = 0;
            PPDPlayDecorder ret     = null;

            using (MemoryStream stream = new MemoryStream(bytes))
                using (PackReader reader = new PackReader(stream))
                {
                    foreach (string name in reader.FileList)
                    {
                        var streamReader = reader.Read(name);
                        switch (name)
                        {
                        case "Version":
                            version = streamReader.ReadByte();
                            break;

                        case "Data":
                            ret = FromStream(streamReader);
                            break;
                        }
                    }
                }
            if (version != 2)
            {
                throw new Exception(String.Format("Not Supported Replay Data:{0}", version));
            }
            return(ret);
        }
Beispiel #3
0
        public static PPDPlayDecorder FromInputs(PPDPlayInput[] inputs)
        {
            var ret = new PPDPlayDecorder();

            ret.inputs.AddRange(inputs);
            return(ret);
        }
Beispiel #4
0
        public static PPDPlayDecorder FromRecorder(PPDPlayRecorder recorder)
        {
            var ret = new PPDPlayDecorder();

            ret.inputs.AddRange(recorder.Inputs);
            return(ret);
        }
Beispiel #5
0
 public PPDPlayDecorder Create()
 {
     return(PPDPlayDecorder.FromInputs(new PPDPlayInput[0]));
 }