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 (!ConfigurationManager.PresetMapDictionary[ConfigurationManager.CurrentPresetMap].ContainsKey(ChosenProcess.Name)) { ConfigurationManager.PresetMapDictionary[ConfigurationManager.CurrentPresetMap].Add(ChosenProcess.Name, new ObservableCollection <ConfigItem>()); ConfigurationManager.SavePresetsMaps(); // processes in mapfiles.json CompilingManager.MapFiles[ConfigurationManager.CurrentPresetMap].Processes.Add(ChosenProcess.Name, new MapProcess()); PersistenceManager.ForceMapFilesWrite(); } } AnalyticsManager.ModifyPresetMap(); UpdateParameterTextBox(); UpdateProcessList(); if (processModeEnabled) { OrderManager.UpdateOrder(); } }
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(); } }
public static void SaveParameters(CompileProcess process) { string presetMapFolder = Path.Combine(PresetsMapsFolder, CurrentPresetMap); var lines = new List <string>(); foreach (var parameter in PresetMapDictionary[CurrentPresetMap][process.Name]) { string line = string.Concat(parameter.Parameter, ","); if (parameter.Value != null) { line += parameter.Value; } /**** TODO: Check if this is the correct format? ****/ if (parameter.Value2 != null) { line += string.Concat(",", parameter.Value2); } /**** ****/ lines.Add(line); } string processMapPath = Path.Combine(presetMapFolder, process.PresetFile); File.WriteAllLines(processMapPath, lines); }
private static void CompileThreaded() { try { ProgressManager.SetProgress(0); var mapErrors = new List <MapErrors>(); foreach (string mapFile in MapFiles) { string cleanMapName = Path.GetFileNameWithoutExtension(mapFile); var compileErrors = new List <Error>(); CompilePalLogger.LogLine($"Starting compilation of {cleanMapName}"); //Update the grid so we have the most up to date order OrderManager.UpdateOrder(); GameConfigurationManager.BackupCurrentContext(); foreach (var compileProcess in OrderManager.CurrentOrder) { currentCompileProcess = compileProcess; compileProcess.Run(GameConfigurationManager.BuildContext(mapFile)); if (compileProcess is CompileExecutable executable) { compileErrors.AddRange(executable.CompileErrors); //Portal 2 cannot work with leaks, stop compiling if we do get a leak. if (GameConfigurationManager.GameConfiguration.Name == "Portal 2") { if (executable.Name == "VBSP" && executable.CompileErrors.Count > 0) { //we have a VBSP error, aka a leak -> stop compiling; break; } } } ProgressManager.Progress += (1d / ConfigurationManager.CompileProcesses.Count(c => c.Metadata.DoRun && c.PresetDictionary.ContainsKey(ConfigurationManager.CurrentPreset))) / MapFiles.Count; } mapErrors.Add(new MapErrors { MapName = cleanMapName, Errors = compileErrors }); GameConfigurationManager.RestoreCurrentContext(); } MainWindow.ActiveDispatcher.Invoke(() => postCompile(mapErrors)); } catch (ThreadAbortException) { ProgressManager.ErrorProgress(); } }
private void RemoveProcessButton_Click(object sender, RoutedEventArgs e) { if (CompileProcessesListBox.SelectedItem != null) { CompileProcess removed = (CompileProcess)CompileProcessesListBox.SelectedItem; removed.PresetDictionary.Remove(ConfigurationManager.CurrentPreset); ConfigurationManager.RemoveProcess(CompileProcessesListBox.SelectedItem.ToString()); } UpdateProcessList(); CompileProcessesListBox.SelectedIndex = 0; }
private void UpdateConfigGrid() { ConfigurationManager.CurrentPreset = (string)PresetConfigListBox.SelectedItem; selectedProcess = (CompileProcess)CompileProcessesListBox.SelectedItem; if (selectedProcess != null && ConfigurationManager.CurrentPreset != null && selectedProcess.PresetDictionary.ContainsKey(ConfigurationManager.CurrentPreset)) { ConfigDataGrid.ItemsSource = selectedProcess.PresetDictionary[ConfigurationManager.CurrentPreset]; UpdateParameterTextBox(); } }
private static void CompileThreaded() { try { ProgressManager.SetProgress(0); var mapErrors = new List <MapErrors>(); foreach (string mapFile in MapFiles) { string cleanMapName = Path.GetFileNameWithoutExtension(mapFile); var compileErrors = new List <Error>(); CompilePalLogger.LogLine(string.Format("Starting compilation of {0}", cleanMapName)); //Update the grid so we have the most up to date order OrderManager.UpdateOrder(); foreach (var compileProcess in OrderManager.CurrentOrder) { currentCompileProcess = compileProcess; compileProcess.Run(GameConfigurationManager.BuildContext(mapFile)); if (compileProcess is CompileExecutable) { var executable = compileProcess as CompileExecutable; compileErrors.AddRange(executable.CompileErrors); } ProgressManager.Progress += (1d / ConfigurationManager.CompileProcesses.Count(c => c.Metadata.DoRun && c.PresetDictionary.ContainsKey(ConfigurationManager.CurrentPreset))) / MapFiles.Count; } mapErrors.Add(new MapErrors { MapName = cleanMapName, Errors = compileErrors }); } MainWindow.ActiveDispatcher.Invoke(() => postCompile(mapErrors)); } catch (ThreadAbortException) { ProgressManager.ErrorProgress(); } }
private void RemoveProcessButton_Click(object sender, RoutedEventArgs e) { if (CompileProcessesListBox.SelectedItem != null) { CompileProcess removed = (CompileProcess)CompileProcessesListBox.SelectedItem; ConfigurationManager.PresetMapDictionary[ConfigurationManager.CurrentPresetMap].Remove(removed.Name); ConfigurationManager.RemoveProcess(removed.ToString()); // processes in mapfiles.json CompilingManager.MapFiles[ConfigurationManager.CurrentPresetMap].Processes.Remove(removed.Name); PersistenceManager.ForceMapFilesWrite(); } UpdateProcessList(); CompileProcessesListBox.SelectedIndex = 0; // clear parameters box if necessary if (!ConfigurationManager.PresetMapDictionary[ConfigurationManager.CurrentPresetMap].Any()) { ConfigDataGrid.ItemsSource = null; } }
private void UpdateConfigGrid() { ConfigDataGrid.BeginAnimation(OpacityProperty, new DoubleAnimation(0, 1, new Duration(TimeSpan.FromMilliseconds(50)))); ConfigurationManager.CurrentPreset = (string)PresetConfigListBox.SelectedItem; selectedProcess = (CompileProcess)CompileProcessesListBox.SelectedItem; if (selectedProcess != null && ConfigurationManager.CurrentPreset != null && selectedProcess.PresetDictionary.ContainsKey(ConfigurationManager.CurrentPreset)) { ConfigDataGrid.ItemsSource = selectedProcess.PresetDictionary[ConfigurationManager.CurrentPreset]; UpdateParameterTextBox(); } }
private void UpdateConfigGrid() { ConfigurationManager.CurrentPreset = (string)PresetConfigListBox.SelectedItem; selectedProcess = (CompileProcess)CompileProcessesListBox.SelectedItem; if (selectedProcess != null && ConfigurationManager.CurrentPreset != null && selectedProcess.PresetDictionary.ContainsKey(ConfigurationManager.CurrentPreset)) { //Switch to the process grid for custom program screen if (selectedProcess.Name == "CUSTOM") { ProcessDataGrid.BeginAnimation(OpacityProperty, new DoubleAnimation(0, 1, new Duration(TimeSpan.FromMilliseconds(50)))); processModeEnabled = true; ProcessDataGrid.ItemsSource = selectedProcess.PresetDictionary[ConfigurationManager.CurrentPreset]; ConfigDataGrid.IsEnabled = false; ConfigDataGrid.Visibility = Visibility.Hidden; ParametersTextBox.Visibility = Visibility.Hidden; ProcessDataGrid.IsEnabled = true; ProcessDataGrid.Visibility = Visibility.Visible; ProcessTab.IsEnabled = true; ProcessTab.Visibility = Visibility.Visible; //Hide parameter buttons if ORDER is the current tab if ((string)(ProcessTab.SelectedItem as TabItem)?.Header == "ORDER") { AddParameterButton.Visibility = Visibility.Hidden; AddParameterButton.IsEnabled = false; RemoveParameterButton.Visibility = Visibility.Hidden; RemoveParameterButton.IsEnabled = false; } } else { ConfigDataGrid.BeginAnimation(OpacityProperty, new DoubleAnimation(0, 1, new Duration(TimeSpan.FromMilliseconds(50)))); processModeEnabled = false; ConfigDataGrid.IsEnabled = true; ConfigDataGrid.Visibility = Visibility.Visible; ParametersTextBox.Visibility = Visibility.Visible; ProcessDataGrid.IsEnabled = false; ProcessDataGrid.Visibility = Visibility.Hidden; ProcessTab.IsEnabled = false; ProcessTab.Visibility = Visibility.Hidden; ConfigDataGrid.ItemsSource = selectedProcess.PresetDictionary[ConfigurationManager.CurrentPreset]; //Make buttons visible if they were disabled if (!AddParameterButton.IsEnabled) { AddParameterButton.Visibility = Visibility.Visible; AddParameterButton.IsEnabled = true; RemoveParameterButton.Visibility = Visibility.Visible; RemoveParameterButton.IsEnabled = true; } UpdateParameterTextBox(); } } }
private void UpdateConfigGrid() { ConfigurationManager.CurrentPresetMap = PresetMapConfigListBox.SelectedItem == null ? ConfigurationManager.CurrentPresetMap : (string)((PresetMapCheckbox)PresetMapConfigListBox.SelectedItem).PresetMap; selectedProcess = (CompileProcess)CompileProcessesListBox.SelectedItem; if (selectedProcess != null && !string.IsNullOrWhiteSpace(ConfigurationManager.CurrentPresetMap) && ConfigurationManager.PresetMapDictionary.Keys.Any(x => x == ConfigurationManager.CurrentPresetMap) && ConfigurationManager.PresetMapDictionary[ConfigurationManager.CurrentPresetMap].Keys.Any(x => x == selectedProcess.Name)) { //Switch to the process grid for custom program screen if (selectedProcess.Name == "CUSTOM") { ProcessDataGrid.BeginAnimation(OpacityProperty, new DoubleAnimation(0, 1, new Duration(TimeSpan.FromMilliseconds(50)))); processModeEnabled = true; ProcessDataGrid.ItemsSource = ConfigurationManager.PresetMapDictionary[ConfigurationManager.CurrentPresetMap][selectedProcess.Name]; ConfigDataGrid.IsEnabled = false; ConfigDataGrid.Visibility = Visibility.Hidden; ParametersTextBox.Visibility = Visibility.Hidden; ProcessDataGrid.IsEnabled = true; ProcessDataGrid.Visibility = Visibility.Visible; ProcessTab.IsEnabled = true; ProcessTab.Visibility = Visibility.Visible; //Hide parameter buttons if ORDER is the current tab if ((string)(ProcessTab.SelectedItem as TabItem)?.Header == "ORDER") { AddParameterButton.Visibility = Visibility.Hidden; AddParameterButton.IsEnabled = false; RemoveParameterButton.Visibility = Visibility.Hidden; RemoveParameterButton.IsEnabled = false; } } else { ConfigDataGrid.BeginAnimation(OpacityProperty, new DoubleAnimation(0, 1, new Duration(TimeSpan.FromMilliseconds(50)))); processModeEnabled = false; ConfigDataGrid.IsEnabled = true; ConfigDataGrid.Visibility = Visibility.Visible; ParametersTextBox.Visibility = Visibility.Visible; ProcessDataGrid.IsEnabled = false; ProcessDataGrid.Visibility = Visibility.Hidden; ProcessTab.IsEnabled = false; ProcessTab.Visibility = Visibility.Hidden; ConfigDataGrid.ItemsSource = ConfigurationManager.PresetMapDictionary[ConfigurationManager.CurrentPresetMap][selectedProcess.Name]; //Make buttons visible if they were disabled if (!AddParameterButton.IsEnabled) { AddParameterButton.Visibility = Visibility.Visible; AddParameterButton.IsEnabled = true; RemoveParameterButton.Visibility = Visibility.Visible; RemoveParameterButton.IsEnabled = true; } UpdateParameterTextBox(false); } } CompileProcessesListBox.SelectedIndex = CompileProcessesListBox.SelectedIndex > 0 && CompileProcessesListBox.SelectedIndex <= CompileProcessesListBox.Items.Count ? CompileProcessesListBox.SelectedIndex : 0; }