Example #1
0
        private void DemoCutThread(object arg)
        {
            var cuts = arg as CutLists;

            if (cuts == null)
            {
                _app.LogError("Invalid thread argument");
                return;
            }

            _app.InitParseArg();
            _app.ParseArg.ProgressCb = (progress, context) => {};

            try
            {
                var progress  = 0.0;
                var fileCount = cuts.FileCuts.Count;
                foreach (var fileCuts in cuts.FileCuts)
                {
                    UDT_DLL.CutDemoByTimes(_app.GetMainThreadContext(), ref _app.ParseArg, fileCuts.FilePath, fileCuts.Cuts);
                    progress += 1.0 / (double)fileCount;
                    _app.SetProgressThreadSafe(100.0 * progress);
                }
            }
            catch (Exception exception)
            {
                _app.LogError("Caught an exception while cutting demos: {0}", exception.Message);
            }
        }
Example #2
0
        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);
            }
        }
Example #3
0
        static private void DemoSearchThread(object arg)
        {
            var app       = App.Instance;
            var threadArg = arg as ThreadArg;

            if (threadArg == null)
            {
                app.LogError("Invalid thread argument type");
                return;
            }

            if (threadArg.Demos == null || threadArg.FilePaths == null || threadArg.Patterns == null || threadArg.Resources == null)
            {
                app.LogError("Invalid thread argument data");
                return;
            }

            app.InitParseArg();

            try
            {
                var resources = threadArg.Resources;
                var options   = UDT_DLL.CreateCutByPatternOptions(app.Config, app.PrivateConfig);
                var results   = UDT_DLL.FindPatternsInDemos(resources, ref app.ParseArg, threadArg.FilePaths, threadArg.Patterns, options);
                app.UpdateSearchResults(results, threadArg.Demos);
            }
            catch (Exception exception)
            {
                app.LogError("Caught an exception while searching demos: {0}", exception.Message);
            }
        }
Example #4
0
 public void AddGenericField(string key, IntPtr stringValue)
 {
     if (stringValue != IntPtr.Zero)
     {
         GenericFields.Add(new DemoStatsField {
             Key = key, Value = UDT_DLL.SafeGetUTF8String(stringValue)
         });
     }
 }
Example #5
0
        private void DemoCutThread(object arg)
        {
            var filePaths = arg as List <string>;

            if (filePaths == null)
            {
                _app.LogError("Invalid thread argument");
                return;
            }

            _app.InitParseArg();

            try
            {
                UDT_DLL.TimeShiftDemos(ref _app.ParseArg, filePaths, _app.Config.MaxThreadCount, _app.Config.TimeShiftSnapshotCount);
            }
            catch (Exception exception)
            {
                _app.LogError("Caught an exception while modifying demos: {0}", exception.Message);
            }
        }
Example #6
0
        private FrameworkElement CreateSettingsControl()
        {
            var startTimeOffsetEditBox = new TextBox();

            _startTimeOffsetEditBox        = startTimeOffsetEditBox;
            startTimeOffsetEditBox.Width   = 40;
            startTimeOffsetEditBox.Text    = _app.Config.CutStartOffset.ToString();
            startTimeOffsetEditBox.ToolTip = "How many seconds before the (first) pattern matching event do we start the cut?";

            var endTimeOffsetEditBox = new TextBox();

            _endTimeOffsetEditBox        = endTimeOffsetEditBox;
            endTimeOffsetEditBox.Width   = 40;
            endTimeOffsetEditBox.Text    = _app.Config.CutEndOffset.ToString();
            endTimeOffsetEditBox.ToolTip = "How many seconds after the (last) pattern matching event event do we end the cut?";

            var outputModeCheckBox = new CheckBox();

            _outputModeCheckBox = outputModeCheckBox;
            outputModeCheckBox.HorizontalAlignment = HorizontalAlignment.Left;
            outputModeCheckBox.VerticalAlignment   = VerticalAlignment.Center;
            outputModeCheckBox.IsChecked           = _app.Config.OutputToInputFolder;
            outputModeCheckBox.Content             = " Output cut demos to the input demos' folders?";
            outputModeCheckBox.Checked            += (obj, args) => OnSameOutputChecked();
            outputModeCheckBox.Unchecked          += (obj, args) => OnSameOutputUnchecked();

            var outputFolderRow = CreateFolderRow(
                ref _outputFolderTextBox,
                _app.Config.OutputFolder,
                "Browse for the folder the processed demos will get written to");

            var skipChatOffsetsDialogCheckBox = new CheckBox();

            skipChatOffsetsDialogCheckBox.HorizontalAlignment = HorizontalAlignment.Left;
            skipChatOffsetsDialogCheckBox.VerticalAlignment   = VerticalAlignment.Center;
            skipChatOffsetsDialogCheckBox.IsChecked           = _app.Config.SkipChatOffsetsDialog;
            skipChatOffsetsDialogCheckBox.Content             = " Skip the 'Cut Offsets' dialog?";
            skipChatOffsetsDialogCheckBox.Checked            += (obj, args) => OnSkipChatOffsetsChecked();
            skipChatOffsetsDialogCheckBox.Unchecked          += (obj, args) => OnSkipChatOffsetsUnchecked();

            var skipFolderScanModeCheckBox = new CheckBox();

            _skipFolderScanModeCheckBox = skipFolderScanModeCheckBox;
            skipFolderScanModeCheckBox.HorizontalAlignment = HorizontalAlignment.Left;
            skipFolderScanModeCheckBox.VerticalAlignment   = VerticalAlignment.Center;
            skipFolderScanModeCheckBox.IsChecked           = _app.Config.SkipScanFoldersRecursivelyDialog;
            skipFolderScanModeCheckBox.Content             = " Skip the dialog asking if folder scanning should be recursive?";
            skipFolderScanModeCheckBox.Checked            += (obj, args) => OnSkipFolderScanRecursiveChecked();
            skipFolderScanModeCheckBox.Unchecked          += (obj, args) => OnSkipFolderScanRecursiveUnchecked();

            var folderScanModeCheckBox = new CheckBox();

            _folderScanModeCheckBox = folderScanModeCheckBox;
            folderScanModeCheckBox.HorizontalAlignment = HorizontalAlignment.Left;
            folderScanModeCheckBox.VerticalAlignment   = VerticalAlignment.Center;
            folderScanModeCheckBox.IsChecked           = _app.Config.ScanFoldersRecursively;
            folderScanModeCheckBox.Content             = " Scan subfolders recursively?";
            folderScanModeCheckBox.Checked            += (obj, args) => OnFolderScanRecursiveChecked();
            folderScanModeCheckBox.Unchecked          += (obj, args) => OnFolderScanRecursiveUnchecked();

            var maxThreadCountTextBox = new TextBox();

            _maxThreadCountTextBox        = maxThreadCountTextBox;
            maxThreadCountTextBox.ToolTip =
                "The maximum number of threads that you allow UDT to use during batch process operations\n" +
                "Only set this to a number greater than 1 if you read your demo files from an SSD\n" +
                "Otherwise, performance will decrease";
            maxThreadCountTextBox.HorizontalAlignment = HorizontalAlignment.Left;
            maxThreadCountTextBox.VerticalAlignment   = VerticalAlignment.Center;
            maxThreadCountTextBox.Text  = _app.Config.MaxThreadCount.ToString();
            maxThreadCountTextBox.Width = 25;

            var useInputFolderForBrowsingCheckBox = new CheckBox();

            _useInputFolderForBrowsingCheckBox = useInputFolderForBrowsingCheckBox;
            useInputFolderForBrowsingCheckBox.HorizontalAlignment = HorizontalAlignment.Left;
            useInputFolderForBrowsingCheckBox.VerticalAlignment   = VerticalAlignment.Center;
            useInputFolderForBrowsingCheckBox.IsChecked           = _app.Config.UseInputFolderAsDefaultBrowsingLocation;
            useInputFolderForBrowsingCheckBox.Content             = " Use input folder as default browsing location?";
            useInputFolderForBrowsingCheckBox.Checked            += (obj, args) => OnInputFolderForBrowsingChecked();
            useInputFolderForBrowsingCheckBox.Unchecked          += (obj, args) => OnInputFolderForBrowsingUnchecked();

            var useInputFolderOnStartUpCheckBox = new CheckBox();

            _useInputFolderOnStartUpCheckBox = useInputFolderOnStartUpCheckBox;
            useInputFolderOnStartUpCheckBox.HorizontalAlignment = HorizontalAlignment.Left;
            useInputFolderOnStartUpCheckBox.VerticalAlignment   = VerticalAlignment.Center;
            useInputFolderOnStartUpCheckBox.IsChecked           = _app.Config.OpenDemosFromInputFolderOnStartUp;
            useInputFolderOnStartUpCheckBox.Content             = " Open demos from input folder on application start-up?";
            useInputFolderOnStartUpCheckBox.Checked            += (obj, args) => OnUseInputFolderOnStartUpChecked();
            useInputFolderOnStartUpCheckBox.Unchecked          += (obj, args) => OnUseInputFolderOnStartUpUnchecked();

            var inputFolderRow = CreateFolderRow(
                ref _inputFolderTextBox,
                _app.Config.InputFolder,
                "Browse for the folder demos will be read or searched from");

            var analyzeOnLoadCheckBox = new CheckBox();

            _analyzeOnLoadCheckBox = analyzeOnLoadCheckBox;
            analyzeOnLoadCheckBox.HorizontalAlignment = HorizontalAlignment.Left;
            analyzeOnLoadCheckBox.VerticalAlignment   = VerticalAlignment.Center;
            analyzeOnLoadCheckBox.IsChecked           = _app.Config.AnalyzeOnLoad;
            analyzeOnLoadCheckBox.Content             = " Analyze demos when loading them into the list?";
            analyzeOnLoadCheckBox.Checked            += (obj, args) => _app.Config.AnalyzeOnLoad = true;
            analyzeOnLoadCheckBox.Unchecked          += (obj, args) => _app.Config.AnalyzeOnLoad = false;
            analyzeOnLoadCheckBox.ToolTip             = " You can always launch the analysis pass from the \"Manage\" tab.";

            var mergeCutSectionsCheckBox = new CheckBox();

            _mergeCutSectionsCheckBox = mergeCutSectionsCheckBox;
            mergeCutSectionsCheckBox.HorizontalAlignment = HorizontalAlignment.Left;
            mergeCutSectionsCheckBox.VerticalAlignment   = VerticalAlignment.Center;
            mergeCutSectionsCheckBox.IsChecked           = _app.Config.MergeCutSectionsFromDifferentPatterns;
            mergeCutSectionsCheckBox.Content             = " Merge overlapping cut sections matched by different pattern types?";
            mergeCutSectionsCheckBox.Checked            += (obj, args) => _app.Config.MergeCutSectionsFromDifferentPatterns = true;
            mergeCutSectionsCheckBox.Unchecked          += (obj, args) => _app.Config.MergeCutSectionsFromDifferentPatterns = false;

            var colorLogMessagesCheckBox = new CheckBox();

            _colorLogMessagesCheckBox = colorLogMessagesCheckBox;
            colorLogMessagesCheckBox.HorizontalAlignment = HorizontalAlignment.Left;
            colorLogMessagesCheckBox.VerticalAlignment   = VerticalAlignment.Center;
            colorLogMessagesCheckBox.IsChecked           = _app.Config.ColorLogWarningsAndErrors;
            colorLogMessagesCheckBox.Content             = " Color the log window's warning and error messages?";
            colorLogMessagesCheckBox.Checked            += (obj, args) => _app.Config.ColorLogWarningsAndErrors = true;
            colorLogMessagesCheckBox.Unchecked          += (obj, args) => _app.Config.ColorLogWarningsAndErrors = false;
            colorLogMessagesCheckBox.ToolTip             = "The option is disabled by default because it might not integrate well with your current theme.";

            var runUpdaterAtStartUpCheckBox = new CheckBox();

            _runUpdaterAtStartUpCheckBox = runUpdaterAtStartUpCheckBox;
            runUpdaterAtStartUpCheckBox.HorizontalAlignment = HorizontalAlignment.Left;
            runUpdaterAtStartUpCheckBox.VerticalAlignment   = VerticalAlignment.Center;
            runUpdaterAtStartUpCheckBox.IsChecked           = _app.Config.RunUpdaterAtStartUp;
            runUpdaterAtStartUpCheckBox.Content             = " Run the updater at application start-up time?";
            runUpdaterAtStartUpCheckBox.Checked            += (obj, args) => _app.Config.RunUpdaterAtStartUp = true;
            runUpdaterAtStartUpCheckBox.Unchecked          += (obj, args) => _app.Config.RunUpdaterAtStartUp = false;

            const int OutputFolderIndex        = 1;
            const int SkipRecursiveDialogIndex = 4;
            const int InputFolderIndex         = 8;
            var       panelList = new List <Tuple <FrameworkElement, FrameworkElement> >();

            panelList.Add(App.CreateTuple("Output Mode", outputModeCheckBox));
            panelList.Add(App.CreateTuple("=>  Output Folder", outputFolderRow));
            panelList.Add(App.CreateTuple("Chat/Death History", skipChatOffsetsDialogCheckBox));
            panelList.Add(App.CreateTuple("Recursive Scan", skipFolderScanModeCheckBox));
            panelList.Add(App.CreateTuple("=> Recursive", folderScanModeCheckBox));
            panelList.Add(App.CreateTuple("Max Thread Count", maxThreadCountTextBox));
            panelList.Add(App.CreateTuple("Browsing Location", useInputFolderForBrowsingCheckBox));
            panelList.Add(App.CreateTuple("Open on Start-up", useInputFolderOnStartUpCheckBox));
            panelList.Add(App.CreateTuple("=> Input Folder", inputFolderRow));
            panelList.Add(App.CreateTuple("Analyze on Load", analyzeOnLoadCheckBox));
            panelList.Add(App.CreateTuple("Start Time Offset [s]", startTimeOffsetEditBox));
            panelList.Add(App.CreateTuple("End Time Offset [s]", endTimeOffsetEditBox));
            panelList.Add(App.CreateTuple("Merge Cut Sections", mergeCutSectionsCheckBox));
            panelList.Add(App.CreateTuple("Color Log Messages", colorLogMessagesCheckBox));
            panelList.Add(App.CreateTuple("Start-up Updates", runUpdaterAtStartUpCheckBox));

            var settingsPanel = WpfHelper.CreateDualColumnPanel(panelList, 135, 2);

            settingsPanel.HorizontalAlignment = HorizontalAlignment.Left;
            settingsPanel.VerticalAlignment   = VerticalAlignment.Top;
            settingsPanel.Margin = new Thickness(0);

            var settingStackPanel = settingsPanel as StackPanel;

            _outputFolderRow = settingStackPanel.Children[OutputFolderIndex] as FrameworkElement;
            SetActive(_outputFolderRow, !_app.Config.OutputToInputFolder);
            _skipRecursiveDialog = settingStackPanel.Children[SkipRecursiveDialogIndex] as FrameworkElement;
            SetActive(_skipRecursiveDialog, _app.Config.SkipScanFoldersRecursivelyDialog);
            _inputFolderRow = settingStackPanel.Children[InputFolderIndex] as FrameworkElement;
            UpdateInputFolderActive();

            var settingsGroupBox = new GroupBox();

            settingsGroupBox.HorizontalAlignment = HorizontalAlignment.Left;
            settingsGroupBox.VerticalAlignment   = VerticalAlignment.Top;
            settingsGroupBox.Margin  = new Thickness(5);
            settingsGroupBox.Header  = "Settings";
            settingsGroupBox.Content = settingsPanel;

            var plugInNames           = UDT_DLL.GetStringArray(UDT_DLL.udtStringArray.PlugInNames);
            var jsonPlugInsStackPanel = new StackPanel();

            jsonPlugInsStackPanel.HorizontalAlignment = HorizontalAlignment.Stretch;
            jsonPlugInsStackPanel.VerticalAlignment   = VerticalAlignment.Stretch;
            jsonPlugInsStackPanel.Margin = new Thickness(5);
            jsonPlugInsStackPanel.Children.Add(new TextBlock {
                Text = "Select which analyzers are enabled"
            });
            for (int i = 0; i < (int)UDT_DLL.udtParserPlugIn.Count; ++i)
            {
                var checkBox = new CheckBox();
                checkBox.Margin    = new Thickness(5, 5, 0, 0);
                checkBox.Content   = " " + plugInNames[i].Capitalize();
                checkBox.IsChecked = BitManip.IsBitSet(_app.Config.JSONPlugInsEnabled, i);
                var iCopy = i; // Make sure we capture a local copy in the lambda.
                checkBox.Checked   += (obj, args) => BitManip.SetBit(ref _app.Config.JSONPlugInsEnabled, iCopy);
                checkBox.Unchecked += (obj, args) => BitManip.ClearBit(ref _app.Config.JSONPlugInsEnabled, iCopy);

                _jsonEnabledPlugInsCheckBoxes.Add(checkBox);
                jsonPlugInsStackPanel.Children.Add(checkBox);
            }

            var jsonPlugInsGroupBox = new GroupBox();

            jsonPlugInsGroupBox.HorizontalAlignment = HorizontalAlignment.Left;
            jsonPlugInsGroupBox.VerticalAlignment   = VerticalAlignment.Top;
            jsonPlugInsGroupBox.Margin  = new Thickness(5);
            jsonPlugInsGroupBox.Header  = "JSON Export";
            jsonPlugInsGroupBox.Content = jsonPlugInsStackPanel;

            var perfStatsNames      = UDT_DLL.GetStringArray(UDT_DLL.udtStringArray.PerfStatsNames);
            var perfStatsStackPanel = new StackPanel();

            perfStatsStackPanel.HorizontalAlignment = HorizontalAlignment.Stretch;
            perfStatsStackPanel.VerticalAlignment   = VerticalAlignment.Stretch;
            perfStatsStackPanel.Margin = new Thickness(5);
            perfStatsStackPanel.Children.Add(new TextBlock {
                Text = "Select which job stats are printed in the log window"
            });
            for (int i = 0; i < (int)CSharpPerfStats.Count; ++i)
            {
                var checkBox = new CheckBox();
                checkBox.Margin    = new Thickness(5, 5, 0, 0);
                checkBox.Content   = " " + CSharpPerfStatsConstants.Strings[i].Capitalize();
                checkBox.IsChecked = BitManip.IsBitSet(_app.Config.CSharpPerfStatsEnabled, i);
                var iCopy = i; // Make sure we capture a local copy in the lambda.
                checkBox.Checked   += (obj, args) => BitManip.SetBit(ref _app.Config.CSharpPerfStatsEnabled, iCopy);
                checkBox.Unchecked += (obj, args) => BitManip.ClearBit(ref _app.Config.CSharpPerfStatsEnabled, iCopy);

                _enabledCSharpPerfStatsCheckBoxes.Add(checkBox);
                perfStatsStackPanel.Children.Add(checkBox);
            }
            for (int i = 0; i < (int)UDT_DLL.StatsConstants.PerfFieldCount; ++i)
            {
                var checkBox = new CheckBox();
                checkBox.Margin    = new Thickness(5, 5, 0, 0);
                checkBox.Content   = " " + perfStatsNames[i].Capitalize();
                checkBox.IsChecked = BitManip.IsBitSet(_app.Config.PerfStatsEnabled, i);
                var iCopy = i; // Make sure we capture a local copy in the lambda.
                checkBox.Checked   += (obj, args) => BitManip.SetBit(ref _app.Config.PerfStatsEnabled, iCopy);
                checkBox.Unchecked += (obj, args) => BitManip.ClearBit(ref _app.Config.PerfStatsEnabled, iCopy);

                _enabledPerfStatsCheckBoxes.Add(checkBox);
                perfStatsStackPanel.Children.Add(checkBox);
            }

            var perfStatsGroupBox = new GroupBox();

            perfStatsGroupBox.HorizontalAlignment = HorizontalAlignment.Left;
            perfStatsGroupBox.VerticalAlignment   = VerticalAlignment.Top;
            perfStatsGroupBox.Margin  = new Thickness(5);
            perfStatsGroupBox.Header  = "Performance Logging";
            perfStatsGroupBox.Content = perfStatsStackPanel;

            var rootPanel = new WrapPanel();

            rootPanel.HorizontalAlignment = HorizontalAlignment.Stretch;
            rootPanel.VerticalAlignment   = VerticalAlignment.Stretch;
            rootPanel.Children.Add(settingsGroupBox);
            rootPanel.Children.Add(perfStatsGroupBox);
            rootPanel.Children.Add(jsonPlugInsGroupBox);

            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);
        }
Example #7
0
        static private void DoAction(PatternAction action, uint selectedPatterns, bool saveConfigs)
        {
            var app = App.Instance;

            var demos = app.SelectedWriteDemos;

            if (demos == null)
            {
                return;
            }

            if (selectedPatterns == 0)
            {
                app.LogError("You didn't check any pattern. Please check at least one to proceed.");
                return;
            }

            if (saveConfigs)
            {
                app.SaveBothConfigs();
            }
            var privateConfig = app.PrivateConfig;

            if (privateConfig.PatternCutPlayerIndex == int.MinValue && string.IsNullOrEmpty(privateConfig.PatternCutPlayerName))
            {
                app.LogError("The selected player name is empty. Please specify a player name or select a different matching method to proceed.");
                return;
            }

            var filePaths = new List <string>();

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

            var config    = app.Config;
            var patterns  = new List <UDT_DLL.udtPatternInfo>();
            var resources = new ArgumentResources();

            if (IsPatternActive(selectedPatterns, UDT_DLL.udtPatternType.Chat))
            {
                if (config.ChatRules.Count == 0)
                {
                    app.LogError("[chat] No chat matching rule defined. Please add at least one to proceed.");
                    return;
                }

                var pattern = new UDT_DLL.udtPatternInfo();
                UDT_DLL.CreateChatPatternInfo(ref pattern, resources, config.ChatRules);
                patterns.Add(pattern);
            }

            if (IsPatternActive(selectedPatterns, UDT_DLL.udtPatternType.FragSequences))
            {
                if (privateConfig.FragCutAllowedMeansOfDeaths == 0)
                {
                    app.LogError("[frag sequence] You didn't check any Mean of Death. Please check at least one to proceed.");
                    return;
                }
                if (config.FragCutMinFragCount < 2)
                {
                    app.LogError("[frag sequence] 'Min. Frag Count' must be 2 or higher.");
                    return;
                }
                if (config.FragCutTimeBetweenFrags < 1)
                {
                    app.LogError("[frag sequence] 'Time Between Frags' must be strictly positive.");
                    return;
                }

                var pattern = new UDT_DLL.udtPatternInfo();
                var rules   = UDT_DLL.CreateCutByFragArg(config, app.PrivateConfig);
                UDT_DLL.CreateFragPatternInfo(ref pattern, resources, rules);
                patterns.Add(pattern);
            }

            if (IsPatternActive(selectedPatterns, UDT_DLL.udtPatternType.MidAirFrags))
            {
                if (!config.MidAirCutAllowRocket && !config.MidAirCutAllowBFG)
                {
                    app.LogError("[mid-air frags] You didn't check any weapon. Please check at least one to proceed.");
                    return;
                }

                var pattern = new UDT_DLL.udtPatternInfo();
                var rules   = UDT_DLL.CreateCutByMidAirArg(config);
                UDT_DLL.CreateMidAirPatternInfo(ref pattern, resources, rules);
                patterns.Add(pattern);
            }

            if (IsPatternActive(selectedPatterns, UDT_DLL.udtPatternType.MultiFragRails))
            {
                var pattern = new UDT_DLL.udtPatternInfo();
                var rules   = UDT_DLL.CreateCutByMultiRailArg(config);
                UDT_DLL.CreateMultiRailPatternInfo(ref pattern, resources, rules);
                patterns.Add(pattern);
            }

            if (IsPatternActive(selectedPatterns, UDT_DLL.udtPatternType.FlagCaptures))
            {
                if (!config.FlagCaptureAllowBaseToBase && !config.FlagCaptureAllowMissingToBase)
                {
                    app.LogError("[flag captures] You disabled both base and non-base pick-ups. Please enable at least one of them to proceed.");
                    return;
                }

                var pattern = new UDT_DLL.udtPatternInfo();
                var rules   = UDT_DLL.CreateCutByFlagCaptureArg(config);
                UDT_DLL.CreateFlagCapturePatternInfo(ref pattern, resources, rules);
                patterns.Add(pattern);
            }

            if (IsPatternActive(selectedPatterns, UDT_DLL.udtPatternType.FlickRails))
            {
                if (config.FlickRailMinSpeed <= 0.0f && config.FlickRailMinAngleDelta <= 0.0f)
                {
                    app.LogError("[flick rails] Both thresholds are negative or zero, which will match all railgun frags.");
                    return;
                }

                var pattern = new UDT_DLL.udtPatternInfo();
                var rules   = UDT_DLL.CreateCutByFlickRailArg(config);
                UDT_DLL.CreateFlickRailPatternInfo(ref pattern, resources, rules);
                patterns.Add(pattern);
            }

            if (IsPatternActive(selectedPatterns, UDT_DLL.udtPatternType.Matches))
            {
                var pattern = new UDT_DLL.udtPatternInfo();
                var rules   = UDT_DLL.CreateCutByMatchArg(config);
                UDT_DLL.CreateMatchPatternInfo(ref pattern, resources, rules);
                patterns.Add(pattern);
            }

            var threadArg = new ThreadArg();

            threadArg.Demos     = demos;
            threadArg.FilePaths = filePaths;
            threadArg.Patterns  = patterns.ToArray();
            threadArg.Resources = resources;

            app.DisableUiNonThreadSafe();
            app.JoinJobThread();

            switch (action)
            {
            case PatternAction.Cut:
                app.StartJobThread(DemoCutThread, threadArg);
                break;

            case PatternAction.Search:
                app.StartJobThread(DemoSearchThread, threadArg);
                break;

            default:
                break;
            }
        }
Example #8
0
        public FilterGroupBox(string header, UDT_DLL.udtStringArray stringArrayId, int columnCount = 2)
        {
            var enableAllButton = new Button();

            enableAllButton.HorizontalAlignment = HorizontalAlignment.Left;
            enableAllButton.VerticalAlignment   = VerticalAlignment.Top;
            enableAllButton.Content             = "Check All";
            enableAllButton.Width  = 75;
            enableAllButton.Height = 25;
            enableAllButton.Margin = new Thickness(5);
            enableAllButton.Click += (obj, args) => SetAllChecked(true);

            var disableAllButton = new Button();

            disableAllButton.HorizontalAlignment = HorizontalAlignment.Left;
            disableAllButton.VerticalAlignment   = VerticalAlignment.Top;
            disableAllButton.Content             = "Uncheck All";
            disableAllButton.Width  = 75;
            disableAllButton.Height = 25;
            disableAllButton.Margin = new Thickness(5);
            disableAllButton.Click += (obj, args) => SetAllChecked(false);

            var rootPanel = new StackPanel();

            rootPanel.Margin              = new Thickness(5);
            rootPanel.Orientation         = Orientation.Vertical;
            rootPanel.HorizontalAlignment = HorizontalAlignment.Stretch;
            rootPanel.VerticalAlignment   = VerticalAlignment.Stretch;

            var panel = new Grid();

            panel.Margin = new Thickness(5);
            panel.HorizontalAlignment = HorizontalAlignment.Stretch;
            panel.VerticalAlignment   = VerticalAlignment.Stretch;

            const int rowOffset = 1; // One additional row for the EnableAll/DisableAll buttons.
            var       itemNames = UDT_DLL.GetStringArray(stringArrayId);
            var       rowCount  = (itemNames.Count + columnCount - 1) / columnCount;
            var       maxCheckBoxesPerColumn = rowCount;

            rowCount += rowOffset;

            for (var i = 0; i < rowCount; ++i)
            {
                panel.RowDefinitions.Add(new RowDefinition());
            }

            for (var i = 0; i < columnCount; ++i)
            {
                panel.ColumnDefinitions.Add(new ColumnDefinition());
            }

            panel.Children.Add(enableAllButton);
            panel.Children.Add(disableAllButton);
            Grid.SetRow(enableAllButton, 0);
            Grid.SetColumn(enableAllButton, 0);
            Grid.SetRow(disableAllButton, 0);
            Grid.SetColumn(disableAllButton, 1);

            for (var i = 0; i < itemNames.Count; ++i)
            {
                var name      = itemNames[i];
                var rowIdx    = i % maxCheckBoxesPerColumn;
                var columnIdx = i / maxCheckBoxesPerColumn;
                rowIdx += rowOffset;

                var checkBox = new CheckBox();
                checkBox.Margin = new Thickness(5, 0, 5, 5);
                checkBox.HorizontalAlignment = HorizontalAlignment.Left;
                checkBox.VerticalAlignment   = VerticalAlignment.Center;
                checkBox.IsChecked           = true;
                checkBox.Content             = " " + name.Substring(0, 1).ToUpper() + name.Substring(1);
                Grid.SetRow(checkBox, rowIdx);
                Grid.SetColumn(checkBox, columnIdx);
                _checkBoxes.Add(checkBox);

                panel.Children.Add(checkBox);
            }

            rootPanel.Children.Add(panel);

            var groupBox = new GroupBox();

            groupBox.Header = header;
            groupBox.HorizontalAlignment = HorizontalAlignment.Stretch;
            groupBox.VerticalAlignment   = VerticalAlignment.Stretch;
            groupBox.Margin  = new Thickness(5);
            groupBox.Content = rootPanel;

            RootElement = groupBox;
        }