Пример #1
0
        private void OnCutClicked(bool fileMode)
        {
            var cutLists = fileMode ? GetFileMatches() : GetCutMatches();

            if (cutLists.FileCuts.Count == 0)
            {
                _app.LogError("No cut/file selected or none has a protocol that can be written");
                return;
            }

            _app.SaveBothConfigs();
            _app.DisableUiNonThreadSafe();
            _app.JoinJobThread();

            _app.StartJobThread(DemoCutThread, cutLists);
        }
Пример #2
0
        private void OnGoClicked()
        {
            var demos = _app.SelectedWriteDemos;

            if (demos == null)
            {
                return;
            }

            _app.SaveBothConfigs();
            _app.DisableUiNonThreadSafe();
            _app.JoinJobThread();

            var filePaths = new List <string>();

            foreach (var demo in demos)
            {
                filePaths.Add(demo.FilePath);
            }

            _app.StartJobThread(DemoCutThread, filePaths);
        }
Пример #3
0
        private void OnCutByTimeClicked()
        {
            var demo = _app.SelectedDemo;

            if (demo == null)
            {
                _app.LogError("No demo was selected. Please select one to proceed.");
                return;
            }

            if (!App.IsValidWriteProtocol(demo.ProtocolNumber))
            {
                _app.LogError("Can't write demos of that protocol");
                return;
            }

            int startTime = -1;

            if (!App.GetTimeSeconds(_startTimeEditBox.Text, out startTime))
            {
                _app.LogError("Invalid start time. Format must be (seconds) or (minutes:seconds)");
                return;
            }

            int endTime = -1;

            if (!App.GetTimeSeconds(_endTimeEditBox.Text, out endTime))
            {
                _app.LogError("Invalid end time. Format must be (seconds) or (minutes:seconds)");
                return;
            }

            if (startTime >= endTime)
            {
                _app.LogError("Invalid times. Start time must be strictly inferior to end time.");
                return;
            }

            var gameStateCount = demo.GameStateFileOffsets.Count;
            int gameStateIndex = -1;

            if (!int.TryParse(_gameStateIndexEditBox.Text, out gameStateIndex))
            {
                gameStateIndex = -1;
            }

            uint fileOffset = 0;

            if (!demo.Analyzed || gameStateCount == 0)
            {
                if (gameStateIndex != 0)
                {
                    _app.LogError("You selected a non-0 GameState index but UDT doesn't know the file offset of it, if it even exists. Please analyze the demo first to proceed.");
                    return;
                }
            }
            else if (gameStateCount > 0)
            {
                if (gameStateCount > 1 && gameStateIndex >= gameStateCount)
                {
                    _app.LogError("Invalid GameState index. Valid range for this demo: {0}-{1}", 0, demo.GameStateFileOffsets.Count - 1);
                    return;
                }

                if (gameStateCount == 1 && gameStateIndex != 0)
                {
                    _gameStateIndexEditBox.Text = "0";
                    gameStateIndex = 0;
                    _app.LogWarning("Invalid GameState index. The only valid value for this demo is 0. UDT set it right for you.");
                }

                fileOffset = demo.GameStateFileOffsets[gameStateIndex];
            }

            if (demo.Analyzed && gameStateIndex >= 0 && gameStateIndex < demo.GameStateSnapshotTimesMs.Count)
            {
                var times = demo.GameStateSnapshotTimesMs[gameStateIndex];
                if (startTime > times.Item2 / 1000)
                {
                    _app.LogError("Invalid start time: it comes after the last snapshot of that GameState.");
                    return;
                }
                if (endTime < times.Item1 / 1000)
                {
                    _app.LogError("Invalid end time: it comes before the first snapshot of that GameState.");
                    return;
                }
            }

            _app.DisableUiNonThreadSafe();
            _app.JoinJobThread();
            _app.SaveConfig();

            var info = new CutByTimeInfo();

            info.GameStateIndex = gameStateIndex;
            info.FileOffset     = fileOffset;
            info.FilePath       = demo.FilePath;
            info.StartTime      = startTime;
            info.EndTime        = endTime;

            _app.StartJobThread(DemoCutByTimeThread, info);
        }