コード例 #1
0
        public void SaveToConfigObject(UdtConfig config)
        {
            var seconds = 0;

            if (App.GetTimeSeconds(_startTimeOffsetTextBox.Text, out seconds))
            {
                config.MatchCutStartTimeOffsetMs = seconds * 1000;
            }
            if (App.GetTimeSeconds(_endTimeOffsetTextBox.Text, out seconds))
            {
                config.MatchCutEndTimeOffsetMs = seconds * 1000;
            }
        }
コード例 #2
0
        public void SaveToConfigObject(UdtConfig config)
        {
            var seconds = 0;

            if (App.GetTimeSeconds(_minCarryTimeTextBox.Text, out seconds))
            {
                config.FlagCaptureMinCarryTimeMs = seconds * 1000;
            }
            if (App.GetTimeSeconds(_maxCarryTimeTextBox.Text, out seconds))
            {
                config.FlagCaptureMaxCarryTimeMs = seconds * 1000;
            }
            config.FlagCaptureAllowBaseToBase    = _allowBaseToBaseCheckBox.IsChecked ?? false;
            config.FlagCaptureAllowMissingToBase = _allowMissingToBaseCheckBox.IsChecked ?? false;
        }
コード例 #3
0
        private void UpdateCalcServerTime()
        {
            var demo = _app.SelectedDemo;

            if (demo == null)
            {
                SetUnknownServerTime("no demo selected");
                return;
            }

            var matchIndex = _calcMatchSelectionComboBox.SelectedIndex;

            if (matchIndex < 0 || matchIndex >= demo.MatchTimes.Count)
            {
                SetUnknownServerTime("invalid match index");
                return;
            }

            var match = demo.MatchTimes[matchIndex];

            if (match.RoundBasedMode)
            {
                SetUnknownServerTime("match has a round-based game type");
                return;
            }

            int matchTimeMs = 0;

            if (!App.GetTimeSeconds(_calcTimeEditBox.Text, out matchTimeMs))
            {
                SetUnknownServerTime("invalid match time format");
                return;
            }
            matchTimeMs *= 1000;

            var clockGoingUp = _calcClockDirCheckBox.IsChecked ?? false;

            if (_calcOvertimeCheckBox.IsChecked ?? false)
            {
                // @NOTE: We don't have support for overtimes with the clock going down
                // like CPMA does in duels by default.
                // For that we would need the length of a timed overtime and the overtime's index...
                if (match.TimeLimit == 0 || !clockGoingUp)
                {
                    SetUnknownServerTime("found no time limit for this match");
                    return;
                }

                matchTimeMs += match.TimeLimit * 60000;
            }

            var serverTimeMs = 0;

            if (clockGoingUp)
            {
                serverTimeMs = match.StartTimeMs + matchTimeMs;
            }
            else
            {
                if (match.TimeLimit == 0)
                {
                    SetUnknownServerTime("found no time limit for this match");
                    return;
                }

                var durationMs = match.TimeLimit * 60000;
                serverTimeMs = match.StartTimeMs + durationMs - matchTimeMs;
            }

            foreach (var timeOut in match.TimeOuts)
            {
                if (timeOut.StartTimeMs >= serverTimeMs)
                {
                    break;
                }

                serverTimeMs += timeOut.EndTimeMs - timeOut.StartTimeMs;
            }

            // In some cases, a match time exactly at the first or last second
            // would be considered out of range.
            // We extend the allowed range by 1 second on each side
            // to avoid the inconvenience of having to change the value in the GUI.
            if (serverTimeMs < match.StartTimeMs - 1000 ||
                serverTimeMs > match.EndTimeMs + 1000)
            {
                SetUnknownServerTime("match time out of range");
                return;
            }

            SetValidServerTime(serverTimeMs);
        }
コード例 #4
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);
        }