Example #1
0
    public virtual void OnGUI()
    {
        ShowOptions = GUI.Toggle(new Rect(0, 0, StandardWidth, StandardHeight), ShowOptions, (ShowOptions ? "Hide" : "Show") + KeyToText(HideKey));
        if (ShowOptions)
        {
            UseXml = GUI.Toggle(new Rect(0, StandardHeight, StandardWidth, StandardHeight), UseXml, "Use XML");
            GUI.skin.label.fontSize = GUI.skin.button.fontSize = GUI.skin.textField.fontSize = GUI.skin.toggle.fontSize = _fontSize;

            if (!Player.Recording)
            {
                if (GUI.Button(new Rect(StandardWidth * 2, 0, StandardWidth, StandardHeight),
                               (Player.Replaying ? "Stop" : "Replay") + (KeyInput != null ? KeyToText(KeyInput.ReplayKey) : "")))
                {
                    Player.Replay();
                }
                //Compression options
                Player.UseZip = GUI.Toggle(new Rect(0, StandardHeight * 3, StandardWidth, StandardHeight), Player.UseZip,
                                           "Zip");

                if (Player.UseZip)
                {
                    Player.UseCompoundArchive = GUI.Toggle(new Rect(0, StandardHeight * 4, StandardWidth, StandardHeight),
                                                           Player.UseCompoundArchive, "Archive");

                    if (Player.UseCompoundArchive)
                    {
                        Player.CompoundZipName = GUI.TextField(
                            new Rect(0, StandardHeight * 5, StandardWidth, StandardHeight), Player.CompoundZipName, 25);
                    }
                }

                if (Player.Replaying)
                {
                    {
                        //Pause/Unpause button
                        if (GUI.Button(new Rect(StandardWidth * 2, StandardHeight, StandardWidth, StandardHeight), (Player.Playing ? "Pause" : "Unpause") + (KeyInput != null ? KeyToText(KeyInput.PauseKey) : "")))
                        {
                            Player.Pause();
                        }
                        //Index
                        float index = GUI.HorizontalSlider(new Rect(StandardWidth * 2, StandardHeight * 2, StandardWidth, StandardHeight), Player.Index, 0, Player.FrameCount);
                        if (index != Player.Index)
                        {
                            Player.SetIndex(index, false);
                        }

                        //Speed
                        Player.Speed = GUI.HorizontalSlider(new Rect(StandardWidth * 2, StandardHeight * 3, StandardWidth, StandardHeight), Player.Speed, 0.1f, 2);
                        Player.Speed = Mathf.Clamp(Single.Parse(GUI.TextField(new Rect(StandardWidth * 2, StandardHeight * 4, StandardWidth, StandardHeight), Player.Speed.ToString(), 25)), 0.1f, 2);
                    }
                }

                //Multi-replay handling
                if (XmlData != null && XmlData.Files.Length > 1)
                {
                    // Progress bar
                    GUI.DrawTexture(new Rect(Screen.width - StandardWidth, Screen.height - StandardHeight, StandardWidth, StandardHeight), _noProgressBar);
                    GUI.DrawTexture(new Rect(Screen.width - StandardWidth, Screen.height - StandardHeight, StandardWidth * ((XmlDataIndex + 1.0f) / XmlData.Files.Length), StandardHeight), _progressBar);

                    //Previous replay
                    if (XmlDataIndex > 0)
                    {
                        if (GUI.Button(new Rect(0, Screen.height / 2f, Screen.width / 10f, Screen.height / 5f), "Previous"))
                        {
                            XmlDataIndex--;
                            FileInfo data = XmlData.Files[XmlDataIndex];
                            Player.Load(data.Zip, data.FileName, data.EntryName);
                            Player.SetIndex(0, false);
                            Player.Speed = 1;
                            Player.Replay();
                            Player.Replay();
                        }
                    }
                    //Next replay
                    if (XmlDataIndex < XmlData.Files.Length - 1)
                    {
                        if (GUI.Button(
                                new Rect(Screen.width * 0.9f, Screen.height / 2f, Screen.width / 10f, Screen.height / 5f),
                                "Next"))
                        {
                            XmlDataIndex++;
                            FileInfo data = XmlData.Files[XmlDataIndex];
                            Player.Load(data.Zip, data.FileName, data.EntryName);
                            Player.SetIndex(0, false);
                            Player.Speed = 1;
                            Player.Replay();
                            Player.Replay();
                        }
                    }
                }
            }
        }
    }
Example #2
0
    public override bool Load(bool useZip, string fileName, string entryName)
    {
        if (!base.Load(useZip, fileName, entryName))
        {
            return(false);
        }
        int localMaxFrames = 0;

        //Single save file
        if (FrameList.Count > 0 && FrameList[0].MyName == "SingleSave" && (bool)FrameList[0].MyObject)
        {
            for (int i = WekitPlayers.Count - 1; i >= 0; i--)
            {
                WekitPlayer_Base player = WekitPlayers[i];
                player.ClearFrameList();

                for (int j = FrameList.Count - 1; j >= 1; j--)
                {
                    if (FrameList[j].MyName == player.PlayerName)
                    {
                        player.MakeDataContainerFromObject(FrameList[j].MyObject);

                        if (player.FrameCount > localMaxFrames)
                        {
                            localMaxFrames = player.FrameCount;
                            ReplayFps      = player.ReplayFps;
                        }
                        break;
                    }
                }
                if (player.FrameCount == 0)
                {
                    player.Enabled(false);
                    ActiveWekitPlayers.Remove(player);
                }
                else
                {
                    player.Enabled(true);
                    if (!ActiveWekitPlayers.Contains(player))
                    {
                        ActiveWekitPlayers.Add(player);
                    }
                    if (OverWriteWekitPlayers.Contains(player))
                    {
                        OverWriteWekitPlayers.Remove(player);
                    }
                }
            }
        }
        //Multiple files
        else
        {
            for (int i = WekitPlayers.Count - 1; i >= 0; i--)
            {
                WekitPlayer_Base player = WekitPlayers[i];
                player.ClearFrameList();
                if (!player.Load(useZip, fileName, entryName))
                {
                    player.Enabled(false);
                    ActiveWekitPlayers.Remove(player);
                }
                else
                {
                    player.Enabled(true);
                    if (!ActiveWekitPlayers.Contains(player))
                    {
                        ActiveWekitPlayers.Add(player);
                    }
                    if (OverWriteWekitPlayers.Contains(player))
                    {
                        OverWriteWekitPlayers.Remove(player);
                    }

                    if (player.FrameCount > localMaxFrames)
                    {
                        localMaxFrames = player.FrameCount;
                        ReplayFps      = player.ReplayFps;
                    }
                }
            }
        }
        if (localMaxFrames == 0)
        {
            return(false);
        }
        FrameList = new List <ObjectWithName>(new ObjectWithName[localMaxFrames + 1]);
        return(true);
    }