private void DemoCutByTimeThread(object arg) { var info = (CutByTimeInfo)arg; if (info == null) { _app.LogError("Invalid thread argument type"); return; } var protocol = App.GetProtocolFromFilePath(info.FilePath); if (protocol == UDT_DLL.udtProtocol.Invalid) { _app.LogError("Unrecognized protocol for demo '{0}'", Path.GetFileName(info.FilePath)); return; } _app.InitParseArg(); _app.ParseArg.FileOffset = info.FileOffset; _app.ParseArg.GameStateIndex = info.GameStateIndex; try { UDT_DLL.CutDemoByTime(_app.GetMainThreadContext(), ref _app.ParseArg, info.FilePath, info.StartTime, info.EndTime); } catch (Exception exception) { var startTimeDisplay = App.FormatMinutesSeconds(info.StartTime); var endTimeDisplay = App.FormatMinutesSeconds(info.EndTime); _app.LogError("Caught an exception while writing cut {0}-{1}: {2}", startTimeDisplay, endTimeDisplay, exception.Message); } }
public FlagCaptureDisplayInfo(int gameStateIndex, int startTimeMs, int endTimeMs, int durationMs, bool baseToBase, string player, string map) { GameStateIndex = gameStateIndex; GameState = gameStateIndex.ToString(); StartAndEnd = App.FormatMinutesSeconds(startTimeMs / 1000) + " - " + App.FormatMinutesSeconds(endTimeMs / 1000); Duration = (((float)durationMs) / 1000.0f).ToString("F3") + "s"; BaseToBase = baseToBase ? "yes" : "no"; Player = player; Map = map.ToLower(); StartTimeSec = startTimeMs / 1000; EndTimeSec = endTimeMs / 1000; }
public void PopulateViews(DemoInfo demoInfo) { var hideGameStateEditBox = demoInfo.Analyzed && demoInfo.GameStateFileOffsets.Count == 1; _gameStateIndexRow.Visibility = hideGameStateEditBox ? Visibility.Collapsed : Visibility.Visible; if (demoInfo.MatchTimes.Count == 0) { _calcGroupBox.Visibility = Visibility.Collapsed; return; } _calcGroupBox.Visibility = Visibility.Visible; _calcOvertimeRow.Visibility = demoInfo.MatchTimes[0].HadOvertime ? Visibility.Visible : Visibility.Collapsed; var matchCount = demoInfo.MatchTimes.Count; if (matchCount > 1) { _calcMatchSelectionRow.Visibility = Visibility.Visible; _calcMatchSelectionComboBox.Items.Clear(); for (var i = 0; i < matchCount; ++i) { var name = string.Format("Match #{0} (GS {1}, {2} - {3})", (i + 1).ToString(), demoInfo.MatchTimes[i].GameStateIndex, App.FormatMinutesSeconds(demoInfo.MatchTimes[i].StartTimeMs / 1000), App.FormatMinutesSeconds(demoInfo.MatchTimes[i].EndTimeMs / 1000)); _calcMatchSelectionComboBox.Items.Add(name); } _calcMatchSelectionComboBox.SelectedIndex = 0; } else { _calcMatchSelectionRow.Visibility = Visibility.Collapsed; } UpdateCalcServerTime(); }
private FrameworkElement CreateTab() { var minCarryTimeTextBox = new TextBox(); _minCarryTimeTextBox = minCarryTimeTextBox; minCarryTimeTextBox.Width = 50; minCarryTimeTextBox.Text = App.FormatMinutesSeconds(_app.Config.FlagCaptureMinCarryTimeMs / 1000); minCarryTimeTextBox.ToolTip = "seconds OR minutes:seconds"; var maxCarryTimeTextBox = new TextBox(); _maxCarryTimeTextBox = maxCarryTimeTextBox; maxCarryTimeTextBox.Width = 50; maxCarryTimeTextBox.Text = App.FormatMinutesSeconds(_app.Config.FlagCaptureMaxCarryTimeMs / 1000); maxCarryTimeTextBox.ToolTip = "seconds OR minutes:seconds"; var allowBaseToBaseCheckBox = new CheckBox(); _allowBaseToBaseCheckBox = allowBaseToBaseCheckBox; allowBaseToBaseCheckBox.VerticalAlignment = VerticalAlignment.Center; allowBaseToBaseCheckBox.IsChecked = _app.Config.FlagCaptureAllowBaseToBase; allowBaseToBaseCheckBox.Content = " Allow flag pick-ups from the flag's return position?"; var allowMissingToBaseCheckBox = new CheckBox(); _allowMissingToBaseCheckBox = allowMissingToBaseCheckBox; allowMissingToBaseCheckBox.VerticalAlignment = VerticalAlignment.Center; allowMissingToBaseCheckBox.IsChecked = _app.Config.FlagCaptureAllowMissingToBase; allowMissingToBaseCheckBox.Content = " Allow flag pick-ups not from the flag's return position?"; var rulesPanelList = new List <Tuple <FrameworkElement, FrameworkElement> >(); rulesPanelList.Add(App.CreateTuple("Min. Carry Time", minCarryTimeTextBox)); rulesPanelList.Add(App.CreateTuple("Max. Carry Time", maxCarryTimeTextBox)); rulesPanelList.Add(App.CreateTuple("Base Pick-ups?", allowBaseToBaseCheckBox)); rulesPanelList.Add(App.CreateTuple("Non-base Pick-ups?", allowMissingToBaseCheckBox)); var rulesPanel = WpfHelper.CreateDualColumnPanel(rulesPanelList, 120, 5); rulesPanel.HorizontalAlignment = HorizontalAlignment.Center; rulesPanel.VerticalAlignment = VerticalAlignment.Center; var rulesGroupBox = new GroupBox(); rulesGroupBox.Header = "Capture Rules"; rulesGroupBox.HorizontalAlignment = HorizontalAlignment.Left; rulesGroupBox.VerticalAlignment = VerticalAlignment.Top; rulesGroupBox.Margin = new Thickness(5); rulesGroupBox.Content = rulesPanel; var actionsGroupBox = CutByPatternComponent.CreateActionsGroupBox(UDT_DLL.udtPatternType.FlagCaptures); var rootPanel = new WrapPanel(); rootPanel.HorizontalAlignment = HorizontalAlignment.Stretch; rootPanel.VerticalAlignment = VerticalAlignment.Stretch; rootPanel.Margin = new Thickness(5); rootPanel.Orientation = Orientation.Horizontal; rootPanel.Children.Add(rulesGroupBox); rootPanel.Children.Add(actionsGroupBox); var scrollViewer = new ScrollViewer(); scrollViewer.HorizontalAlignment = HorizontalAlignment.Stretch; scrollViewer.VerticalAlignment = VerticalAlignment.Stretch; scrollViewer.Margin = new Thickness(5); scrollViewer.HorizontalScrollBarVisibility = ScrollBarVisibility.Disabled; scrollViewer.VerticalScrollBarVisibility = ScrollBarVisibility.Auto; scrollViewer.Content = rootPanel; return(scrollViewer); }
public void UpdateResults(List <UDT_DLL.udtPatternMatch> results, List <DemoInfo> demos) { _cutResultsListView.Items.Clear(); _fileResultsListView.Items.Clear(); results.Sort((a, b) => a.StartTimeMs.CompareTo(b.StartTimeMs)); results.StableSort((a, b) => a.GameStateIndex.CompareTo(b.GameStateIndex)); results.StableSort((a, b) => a.DemoInputIndex.CompareTo(b.DemoInputIndex)); _results = results; _resultDemos = demos; foreach (var result in results) { var index = result.DemoInputIndex; if (index >= demos.Count) { continue; } var copyMenuItem = new MenuItem(); copyMenuItem.Header = App.CreateContextMenuHeader("Copy to Clipboard", "(Ctrl+C)"); copyMenuItem.Command = _cutCopyCommand.RoutedCommand; var cutMenuItem = new MenuItem(); cutMenuItem.Header = "Apply Cut(s)"; cutMenuItem.Command = _cutCutCommand.RoutedCommand; var revealMenuItem = new MenuItem(); revealMenuItem.Header = "Reveal in File Explorer"; revealMenuItem.Command = _cutRevealCommand.RoutedCommand; var selectMenuItem = new MenuItem(); selectMenuItem.Header = "Select in Demo List"; selectMenuItem.Command = _cutSelectCommand.RoutedCommand; var contextMenu = new ContextMenu(); contextMenu.Items.Add(copyMenuItem); contextMenu.Items.Add(selectMenuItem); contextMenu.Items.Add(cutMenuItem); contextMenu.Items.Add(new Separator()); contextMenu.Items.Add(revealMenuItem); var demo = demos[(int)index]; var fileName = Path.GetFileNameWithoutExtension(demo.FilePath); var gs = result.GameStateIndex.ToString(); var start = App.FormatMinutesSeconds(result.StartTimeMs / 1000); var end = App.FormatMinutesSeconds(result.EndTimeMs / 1000); var patterns = FormatPatterns(result.Patterns); var cutResult = new SearchResultCutDisplayInfo(fileName, gs, start, end, patterns, result, demo); var cutItem = new ListViewItem(); cutItem.Content = cutResult; cutItem.ContextMenu = contextMenu; _cutResultsListView.Items.Add(cutItem); } uint currentFileIndex = uint.MaxValue; var fileResults = new List <UDT_DLL.udtPatternMatch>(); foreach (var result in results) { var index = result.DemoInputIndex; if (index >= demos.Count) { continue; } if (currentFileIndex != index) { if (fileResults.Count > 0) { AddSingleFileResult(fileResults, demos); fileResults.Clear(); } } fileResults.Add(result); currentFileIndex = index; } if (fileResults.Count > 0) { AddSingleFileResult(fileResults, demos); } var cutCount = _cutResultsListView.Items.Count; var fileCount = _fileResultsListView.Items.Count; _resultsTextBlock.Text = string.Format("Found {0} match{1} in {2} demo file{3}.", cutCount, cutCount > 1 ? "es" : "", fileCount, fileCount > 1 ? "s" : ""); var fileMode = _displayFilesRadioButton.IsChecked ?? false; if (fileMode) { OnFileModeChecked(); } else { OnCutModeChecked(); } }
private void SetValidServerTime(int serverTimeMs) { _calcOutputTimeEditBox.Text = App.FormatMinutesSeconds(serverTimeMs / 1000); _calcErrorRow.Visibility = Visibility.Collapsed; _calcErrorTextBlock.Text = "none"; }
public void SetCutInfo(int gsIndex, int startTime, int endTime) { _gameStateIndexEditBox.Text = gsIndex.ToString(); _startTimeEditBox.Text = App.FormatMinutesSeconds(startTime); _endTimeEditBox.Text = App.FormatMinutesSeconds(endTime); }
private FrameworkElement CreateTab() { var startTimeOffsetTextBox = new TextBox(); _startTimeOffsetTextBox = startTimeOffsetTextBox; startTimeOffsetTextBox.Width = 50; startTimeOffsetTextBox.Text = App.FormatMinutesSeconds(_app.Config.MatchCutStartTimeOffsetMs / 1000); startTimeOffsetTextBox.ToolTip = "seconds OR minutes:seconds"; var endTimeOffsetTextBox = new TextBox(); _endTimeOffsetTextBox = endTimeOffsetTextBox; endTimeOffsetTextBox.Width = 50; endTimeOffsetTextBox.Text = App.FormatMinutesSeconds(_app.Config.MatchCutEndTimeOffsetMs / 1000); endTimeOffsetTextBox.ToolTip = "seconds OR minutes:seconds"; var rulesPanelList = new List <Tuple <FrameworkElement, FrameworkElement> >(); rulesPanelList.Add(App.CreateTuple("Start Time Offset", startTimeOffsetTextBox)); rulesPanelList.Add(App.CreateTuple("End Time Offset", endTimeOffsetTextBox)); var rulesPanel = WpfHelper.CreateDualColumnPanel(rulesPanelList, 120, 5); rulesPanel.HorizontalAlignment = HorizontalAlignment.Center; rulesPanel.VerticalAlignment = VerticalAlignment.Center; var rulesGroupBox = new GroupBox(); rulesGroupBox.Header = "Match Cut Rules"; rulesGroupBox.HorizontalAlignment = HorizontalAlignment.Left; rulesGroupBox.VerticalAlignment = VerticalAlignment.Top; rulesGroupBox.Margin = new Thickness(5); rulesGroupBox.Content = rulesPanel; var actionsGroupBox = CutByPatternComponent.CreateActionsGroupBox(UDT_DLL.udtPatternType.Matches); var helpTextBlock = new TextBlock(); helpTextBlock.Margin = new Thickness(5); helpTextBlock.TextWrapping = TextWrapping.WrapWithOverflow; helpTextBlock.Text = "This cut filter is there to help create a new demo for every match in the demo.\n\n" + "The 'Start Time Offset' field is only applied if no pre-match count-down is found.\n" + "The 'End Time Offset' field is only applied if no post-match intermission is found."; var helpGroupBox = new GroupBox(); helpGroupBox.Margin = new Thickness(5); helpGroupBox.Header = "Help"; helpGroupBox.HorizontalAlignment = HorizontalAlignment.Left; helpGroupBox.VerticalAlignment = VerticalAlignment.Top; helpGroupBox.Content = helpTextBlock; var rootPanel = new WrapPanel(); rootPanel.HorizontalAlignment = HorizontalAlignment.Stretch; rootPanel.VerticalAlignment = VerticalAlignment.Stretch; rootPanel.Margin = new Thickness(5); rootPanel.Orientation = Orientation.Horizontal; rootPanel.Children.Add(rulesGroupBox); rootPanel.Children.Add(actionsGroupBox); rootPanel.Children.Add(helpGroupBox); var scrollViewer = new ScrollViewer(); scrollViewer.HorizontalAlignment = HorizontalAlignment.Stretch; scrollViewer.VerticalAlignment = VerticalAlignment.Stretch; scrollViewer.Margin = new Thickness(5); scrollViewer.HorizontalScrollBarVisibility = ScrollBarVisibility.Disabled; scrollViewer.VerticalScrollBarVisibility = ScrollBarVisibility.Auto; scrollViewer.Content = rootPanel; return(scrollViewer); }