Esempio n. 1
0
        private static void postCompile(List <Error> errors)
        {
            CompilePalLogger.LogLineColor(string.Format("'{0}' compile finished in {1}", ConfigurationManager.CurrentPreset, compileTimeStopwatch.Elapsed.ToString(@"hh\:mm\:ss")), Brushes.ForestGreen);

            if (errors != null && errors.Any())
            {
                int maxSeverity = errors.Max(s => s.Severity);

                var severityBrush = Error.GetSeverityBrush(maxSeverity);

                CompilePalLogger.LogLineColor("{0} errors/warnings logged:", severityBrush, errors.Count);

                int i = 0;
                foreach (var error in errors)
                {
                    i++;

                    string errorText = string.Format("({0}) - ({1})", i, Error.GetSeverityText(error.Severity)) + Environment.NewLine;

                    CompilePalLogger.LogCompileError(errorText, error);

                    if (error.Severity >= 3)
                    {
                        AnalyticsManager.CompileError();
                    }
                }
            }

            OnFinish();

            compileTimeStopwatch.Reset();

            IsCompiling = false;
        }
Esempio n. 2
0
        private void AddProcessButton_Click(object sender, RoutedEventArgs e)
        {
            ProcessAdder c = new ProcessAdder();

            c.ShowDialog();

            if (c.ProcessDataGrid.SelectedItem != null)
            {
                CompileProcess ChosenProcess = (CompileProcess)c.ProcessDataGrid.SelectedItem;
                ChosenProcess.Metadata.DoRun = true;
                if (!ChosenProcess.PresetDictionary.ContainsKey(ConfigurationManager.CurrentPreset))
                {
                    ChosenProcess.PresetDictionary.Add(ConfigurationManager.CurrentPreset, new ObservableCollection <ConfigItem>());
                }
            }

            AnalyticsManager.ModifyPreset();

            UpdateParameterTextBox();
            UpdateProcessList();

            if (processModeEnabled)
            {
                OrderManager.UpdateOrder();
            }
        }
Esempio n. 3
0
        private void AddParameterButton_Click(object sender, RoutedEventArgs e)
        {
            if (selectedProcess != null)
            {
                //Skip Paramater Adder for Custom Process
                if (selectedProcess.Name == "CUSTOM")
                {
                    selectedProcess.PresetDictionary[ConfigurationManager.CurrentPreset].Add((ConfigItem)selectedProcess.ParameterList[0].Clone());
                }
                else
                {
                    ParameterAdder c = new ParameterAdder(selectedProcess.ParameterList);
                    c.ShowDialog();

                    if (c.ChosenItem != null)
                    {
                        if (c.ChosenItem.CanBeUsedMoreThanOnce)
                        {
                            // .clone() removes problems with parameters sometimes becoming linked
                            selectedProcess.PresetDictionary[ConfigurationManager.CurrentPreset].Add((ConfigItem)c.ChosenItem.Clone());
                        }
                        else if (!selectedProcess.PresetDictionary[ConfigurationManager.CurrentPreset].Contains(c.ChosenItem))
                        {
                            selectedProcess.PresetDictionary[ConfigurationManager.CurrentPreset].Add(c.ChosenItem);
                        }
                    }
                }

                AnalyticsManager.ModifyPreset();

                UpdateParameterTextBox();
            }
        }
Esempio n. 4
0
        public static void LogException(Exception e, bool crash = true)
        {
            if (!Directory.Exists("CrashLogs"))
            {
                Directory.CreateDirectory("CrashLogs");
            }


            CompilePalLogger.LogLine("An exception was caught by the ExceptionHandler:");
            CompilePalLogger.LogLine(e.ToString());
            if (e.InnerException != null)
            {
                CompilePalLogger.LogLine(e.InnerException.ToString());
            }

            AnalyticsManager.Error();//risky, but /interesting/

            if (crash)
            {
                string crashLogName = DateTime.Now.ToString("s").Replace(":", "-");

                File.WriteAllText(Path.Combine("CrashLogs", crashLogName + ".txt"), e.ToString() + e.InnerException ?? "");

                Thread.Sleep(2000);
                Environment.Exit(0);
            }
        }
Esempio n. 5
0
        public MainWindow()
        {
            Instance = this;

            Application.Current.DispatcherUnhandledException += Current_DispatcherUnhandledException;

            InitializeComponent();

            ActiveDispatcher = Dispatcher;

            CompilePalLogger.OnWrite     += Logger_OnWrite;
            CompilePalLogger.OnBacktrack += Logger_OnBacktrack;
            CompilePalLogger.OnErrorLog  += CompilePalLogger_OnError;

            UpdateManager.OnUpdateFound += UpdateManager_OnUpdateFound;
            UpdateManager.CheckVersion();

            AnalyticsManager.Launch();
            PersistenceManager.Init();
            ErrorFinder.Init();

            ConfigurationManager.AssembleParameters();

            ProgressManager.TitleChange    += ProgressManager_TitleChange;
            ProgressManager.ProgressChange += ProgressManager_ProgressChange;
            ProgressManager.Init(TaskbarItemInfo);


            SetSources();

            CompileProcessesListBox.Items.SortDescriptions.Add(new System.ComponentModel.SortDescription("Ordering", System.ComponentModel.ListSortDirection.Ascending));

            CompileProcessesListBox.SelectedIndex = 0;
            PresetConfigListBox.SelectedIndex     = 0;

            UpdateConfigGrid();

            ConfigSelectButton.Visibility = GameConfigurationManager.GameConfigurations.Count > 1
                ? Visibility.Visible
                : Visibility.Collapsed;

            CompilingManager.OnClear += CompilingManager_OnClear;

            CompilingManager.OnStart  += CompilingManager_OnStart;
            CompilingManager.OnFinish += CompilingManager_OnFinish;

            RowDragHelper.RowSwitched += RowDragHelperOnRowSwitched;

            elapsedTimeDispatcherTimer = new DispatcherTimer(new TimeSpan(0, 0, 0, 1), DispatcherPriority.Background,
                                                             this.TickElapsedTimer, Dispatcher.CurrentDispatcher)
            {
                IsEnabled = false
            };

            HandleArgs();
        }
Esempio n. 6
0
        private static void postCompile(List <MapErrors> errors)
        {
            CompilePalLogger.LogLineColor(
                $"\n'{ConfigurationManager.CurrentPreset}' compile finished in {compileTimeStopwatch.Elapsed.ToString(@"hh\:mm\:ss")}", Brushes.ForestGreen);

            if (errors != null && errors.Any())
            {
                int numErrors   = errors.Sum(e => e.Errors.Count);
                int maxSeverity = errors.Max(e => e.Errors.Any() ? e.Errors.Max(e2 => e2.Severity) : 0);
                CompilePalLogger.LogLineColor("{0} errors/warnings logged:", Error.GetSeverityBrush(maxSeverity), numErrors);

                foreach (var map in errors)
                {
                    CompilePalLogger.Log("  ");

                    if (!map.Errors.Any())
                    {
                        CompilePalLogger.LogLineColor("No errors/warnings logged for {0}", Error.GetSeverityBrush(0), map.MapName);
                        continue;
                    }

                    int mapMaxSeverity = map.Errors.Max(e => e.Severity);
                    CompilePalLogger.LogLineColor("{0} errors/warnings logged for {1}:", Error.GetSeverityBrush(mapMaxSeverity), map.Errors.Count, map.MapName);

                    var distinctErrors = map.Errors.GroupBy(e => e.ID);
                    foreach (var errorList in distinctErrors)
                    {
                        var error = errorList.First();

                        string errorText = $"{errorList.Count()}x: {error.SeverityText}: {error.ShortDescription}";

                        CompilePalLogger.Log("    ● ");
                        CompilePalLogger.LogCompileError(errorText, error);
                        CompilePalLogger.LogLine();

                        if (error.Severity >= 3)
                        {
                            AnalyticsManager.CompileError();
                        }
                    }
                }
            }

            OnFinish();

            compileTimeStopwatch.Reset();

            IsCompiling = false;

            // Tells windows it's now okay to enter sleep
            NativeMethods.SetThreadExecutionState(NativeMethods.ES_CONTINUOUS);
        }
Esempio n. 7
0
        public static void StartCompile()
        {
            AnalyticsManager.Compile();

            IsCompiling = true;

            compileTimeStopwatch.Start();

            OnClear();

            CompilePalLogger.LogLine(string.Format("Starting a '{0}' compile.", ConfigurationManager.CurrentPreset));

            compileThread = new Thread(CompileThreaded);
            compileThread.Start();
        }
Esempio n. 8
0
        private void AddParameterButton_Click(object sender, RoutedEventArgs e)
        {
            ParameterAdder c = new ParameterAdder(selectedProcess.ParameterList);

            c.ShowDialog();

            if (c.ChosenItem != null && !selectedProcess.PresetDictionary[ConfigurationManager.CurrentPreset].Contains(c.ChosenItem))
            {
                selectedProcess.PresetDictionary[ConfigurationManager.CurrentPreset].Add(c.ChosenItem);
            }

            AnalyticsManager.ModifyPreset();

            UpdateParameterTextBox();
        }
        public MainWindow()
        {
            GetMainWindow = this;

            Application.Current.DispatcherUnhandledException += Current_DispatcherUnhandledException;

            InitializeComponent();

            ActiveDispatcher = Dispatcher;

            CompilePalLogger.OnWrite     += Logger_OnWrite;
            CompilePalLogger.OnBacktrack += Logger_OnBacktrack;
            CompilePalLogger.OnErrorLog  += CompilePalLogger_OnError;

            UpdateManager.OnUpdateFound += UpdateManager_OnUpdateFound;
            UpdateManager.CheckVersion();

            AnalyticsManager.Launch();
            PersistenceManager.Init();
            ErrorFinder.Init();

            ConfigurationManager.AssembleParameters();

            ProgressManager.TitleChange    += ProgressManager_TitleChange;
            ProgressManager.ProgressChange += ProgressManager_ProgressChange;
            ProgressManager.Init(TaskbarItemInfo);


            SetSources();

            CompileProcessesListBox.Items.SortDescriptions.Add(new System.ComponentModel.SortDescription("Ordering", System.ComponentModel.ListSortDirection.Ascending));

            CompileProcessesListBox.SelectedIndex = 0;
            PresetConfigListBox.SelectedIndex     = 0;

            UpdateConfigGrid();

            CompilingManager.OnClear += CompilingManager_OnClear;

            CompilingManager.OnStart  += CompilingManager_OnStart;
            CompilingManager.OnFinish += CompilingManager_OnFinish;

            RowDragHelper.RowSwitched += RowDragHelperOnRowSwitched;

            HandleArgs();
        }
Esempio n. 10
0
        private async void AddPresetButton_Click(object sender, RoutedEventArgs e)
        {
            var dialog = new InputDialog("Preset Name");

            dialog.ShowDialog();

            if (dialog.Result)
            {
                string presetName = dialog.Text;

                ConfigurationManager.NewPreset(presetName);

                AnalyticsManager.NewPreset();

                SetSources();
                CompileProcessesListBox.SelectedIndex = 0;
                PresetConfigListBox.SelectedItem      = presetName;
            }
        }
Esempio n. 11
0
        public static void StartCompile()
        {
            OnStart();

            // Tells windows to not go to sleep during compile
            NativeMethods.SetThreadExecutionState(NativeMethods.ES_CONTINUOUS | NativeMethods.ES_SYSTEM_REQUIRED);

            AnalyticsManager.Compile();

            IsCompiling = true;

            compileTimeStopwatch.Start();

            OnClear();

            CompilePalLogger.LogLine($"Starting a '{ConfigurationManager.CurrentPreset}' compile.");

            compileThread = new Thread(CompileThreaded);
            compileThread.Start();
        }
Esempio n. 12
0
        private async void ClonePresetMapButton_OnClick(object sender, RoutedEventArgs e)
        {
            if (!string.IsNullOrWhiteSpace(ConfigurationManager.CurrentPresetMap))
            {
                var dialog = new InputDialog("Map Preset Name");
                dialog.ShowDialog();

                if (dialog.Result)
                {
                    string presetMapName = dialog.Text;

                    ConfigurationManager.ClonePresetMap(presetMapName);

                    AnalyticsManager.NewPresetMap();

                    SetSources(true);
                    CompileProcessesListBox.SelectedIndex = 0;
                    PresetMapConfigListBox.SelectedItem   = PresetMapConfigListBox.ItemsSource.Cast <PresetMapCheckbox>().FirstOrDefault(x => x.PresetMap == presetMapName);
                    SetPreviousPresetMapSelectedItem(PresetMapConfigListBox.SelectedItem);
                }
            }
        }
Esempio n. 13
0
        public static async void LogException(Exception e, bool crash = true)
        {
            if (!Directory.Exists(CompilePalPath.Directory + "CrashLogs"))
            {
                Directory.CreateDirectory(CompilePalPath.Directory + "CrashLogs");
            }


            CompilePalLogger.LogLine("An exception was caught by the ExceptionHandler:");
            CompilePalLogger.LogLine(e.ToString());
            if (e.InnerException != null)
            {
                CompilePalLogger.LogLine(e.InnerException.ToString());
            }

            try {
                AnalyticsManager.Error();//risky, but /interesting/
            } catch (Exception) {}

            if (crash)
            {
                string crashLogName = DateTime.Now.ToString("s").Replace(":", "-");

                File.WriteAllText(Path.Combine("CrashLogs", crashLogName + ".txt"), e.ToString() + e.InnerException ?? "");

                ProgressManager.ErrorProgress();
                var modalDialogSettings = new MetroDialogSettings
                {
                    AffirmativeButtonText = "Exit",
                    ColorScheme           = MetroDialogColorScheme.Theme
                };
                await MainWindow.Instance.ShowModal("A fatal exception has occured", e.Message, settings : modalDialogSettings);

                Environment.Exit(0);
            }
        }