Example #1
0
        public override void    HandlePacket(IReplaySettings settings, float time, byte[] data)
        {
            this.RemoveOldData(time - settings.RecordLastSeconds);

            ByteBuffer buffer = Utility.GetBBuffer();

            buffer.Append(data);

            int          touchCount = (int)buffer.ReadByte();
            TouchesState input      = new TouchesState()
            {
                time    = time,
                touches = new TouchesState.Touch[touchCount]
            };

            for (int i = 0; i < touchCount; i++)
            {
                input.touches[i].x        = buffer.ReadSingle();
                input.touches[i].y        = buffer.ReadSingle();
                input.touches[i].fingerID = buffer.ReadInt32();
            }

            this.data.Add(input);
            Utility.RestoreBBuffer(buffer);
        }
Example #2
0
        public override void    HandlePacket(IReplaySettings settings, float time, byte[] data)
        {
            this.RemoveOldData(time - settings.RecordLastSeconds);

            ByteBuffer buffer = Utility.GetBBuffer();

            buffer.Append(data);

            KeyCode keyCode = (KeyCode)buffer.ReadUInt16();
            bool    up      = buffer.ReadBoolean();

            if (up == false)
            {
                this.currentState.Add(keyCode);
            }
            else
            {
                this.currentState.Remove(keyCode);
            }

            this.data.Add(new KeyInput()
            {
                time = time,
                keys = this.currentState.ToArray()
            });

            Utility.RestoreBBuffer(buffer);
        }
Example #3
0
        public override ReplayDataModule        ConvertToReplay(IReplaySettings replay)
        {
            if (this.data.Count == 0)
            {
                return(null);
            }

            return(new KeyboardReplayModule(this));
        }
Example #4
0
        public override void    HandlePacket(IReplaySettings settings, float time, byte[] data)
        {
            if (this.texture == null ||
                this.texture.width != settings.TextureWidth ||
                this.texture.height != settings.TextureHeight)
            {
                this.texture = new Texture2D(settings.TextureWidth, settings.TextureHeight, TextureFormat.ARGB32, false);
            }

            this.RemoveOldData(time - settings.RecordLastSeconds);

            bool usedCompression = false;

            if (this.useCompression == true)
            {
                try
                {
                    using (MemoryStream ms = new MemoryStream(data))
                        using (GZipStream gz = new GZipStream(ms, CompressionMode.Decompress, true))
                        {
                            using (MemoryStream output = new MemoryStream())
                            {
                                if (this.compressionBuffer == null)
                                {
                                    this.compressionBuffer = new byte[4048];
                                }

                                int count = 0;

                                do
                                {
                                    count = gz.Read(this.compressionBuffer, 0, 4048);
                                    if (count > 0)
                                    {
                                        output.Write(this.compressionBuffer, 0, count);
                                    }
                                }while (count > 0);

                                data = output.ToArray();
                            }
                        }

                    usedCompression = true;
                }
                catch (Exception ex)
                {
                    InternalNGDebug.LogFileException("Decompressing texture.", ex);
                }
            }

            this.texture.LoadImage(data);

            this.data.Add(new Screenshot()
            {
                time = time, compressed = usedCompression, data = data
            });
        }
Example #5
0
        public override void    OnGUICamera(IReplaySettings settings, Rect r)
        {
            if (this.texture == null ||
                this.texture.width != settings.TextureWidth ||
                this.texture.height != settings.TextureHeight)
            {
                this.texture = new Texture2D(settings.TextureWidth, settings.TextureHeight, TextureFormat.ARGB32, false);
            }

            EditorGUI.DrawPreviewTexture(r, this.texture, null, this.scaleMode);
        }
Example #6
0
        public override void    HandlePacket(IReplaySettings settings, float time, byte[] data)
        {
            this.RemoveOldData(time - settings.RecordLastSeconds);

            ByteBuffer buffer = Utility.GetBBuffer();

            buffer.Append(data);

            this.data.Add(new MouseInput()
            {
                time    = time,
                x       = buffer.ReadSingle(),
                y       = buffer.ReadSingle(),
                buttons = (MouseButtons)buffer.ReadInt32()
            });

            Utility.RestoreBBuffer(buffer);
        }
Example #7
0
        public Replay(IReplaySettings settings)
        {
            this.name    = DateTime.Now.ToLongTimeString();
            this.canSave = true;
            this.width   = settings.TextureWidth;
            this.height  = settings.TextureHeight;

            // Initialize modules.
            this.modules = new List <ReplayDataModule>();

            for (int i = 0; i < settings.Modules.Count; i++)
            {
                ReplayDataModule module = settings.Modules[i].ConvertToReplay(settings);

                if (module != null && module.data.Count > 0)
                {
                    this.modules.Add(module);
                }
            }

            this.Init();
        }
Example #8
0
 /// <summary>
 /// Generates a Replay version of the current module. Returns null if the module has no data.
 /// </summary>
 /// <param name="settings"></param>
 /// <returns></returns>
 public abstract ReplayDataModule        ConvertToReplay(IReplaySettings settings);
Example #9
0
 /// <summary>
 /// Handle packet data incoming from the server.
 /// </summary>
 /// <param name="settings"></param>
 /// <param name="time"></param>
 /// <param name="data"></param>
 public abstract void    HandlePacket(IReplaySettings settings, float time, byte[] data);
Example #10
0
 /// <summary>
 /// Initializes module. Invoked when the server is initialized.
 /// </summary>
 /// <param name="settings"></param>
 /// <param name="server"></param>
 public virtual void     OnServerInitialized(IReplaySettings settings, Client server)
 {
 }
Example #11
0
 /// <summary>
 /// Displays GUI over the video feed.
 /// </summary>
 /// <param name="settings"></param>
 /// <param name="r"></param>
 public virtual void     OnGUICamera(IReplaySettings settings, Rect r)
 {
 }
Example #12
0
 public override ReplayDataModule        ConvertToReplay(IReplaySettings settings)
 {
     return(new ScreenshotReplayModule(this, settings.TextureWidth, settings.TextureHeight));
 }
Example #13
0
 public override void    OnServerInitialized(IReplaySettings settings, Client server)
 {
     server.AddPacket(new ClientModuleSetUseJPGPacket(this.useJPG));
     server.AddPacket(new ClientModuleSetUseCompressionPacket(this.useCompression));
 }