diff --git a/CompilePalX/Compilers/CustomProcess.cs b/CompilePalX/Compilers/CustomProcess.cs index 976a3ec0..ee469e88 100644 --- a/CompilePalX/Compilers/CustomProcess.cs +++ b/CompilePalX/Compilers/CustomProcess.cs @@ -28,9 +28,9 @@ public List BuildProgramList() //Set default order to 15 int order = 15; - //Use parameter to hold custom order - if (!string.IsNullOrWhiteSpace(parameter.Parameter)) - Int32.TryParse(parameter.Parameter, out order); + //Use warning to hold custom order + if (!string.IsNullOrWhiteSpace(parameter.Warning)) + Int32.TryParse(parameter.Warning, out order); if (string.IsNullOrWhiteSpace(path)) continue; @@ -198,7 +198,7 @@ protected bool Equals(ConfigItem other) if (other == null) return false; - return (ReadOutput == other.ReadOutput && string.Equals(Path, other.Value) && string.Equals(CustomOrder.ToString(), other.Parameter) && Equals(Args, other.Value2)); + return (ReadOutput == other.ReadOutput && string.Equals(Path, other.Value) && string.Equals(CustomOrder.ToString(), other.Warning) && Equals(Args, other.Value2)); } public override int GetHashCode() diff --git a/CompilePalX/Configuration/ConfigurationManager.cs b/CompilePalX/Configuration/ConfigurationManager.cs index 8531c9d7..19cdb666 100644 --- a/CompilePalX/Configuration/ConfigurationManager.cs +++ b/CompilePalX/Configuration/ConfigurationManager.cs @@ -108,7 +108,7 @@ private static void AssemblePresets() foreach (var line in lines) { - var item = ParsePresetLine(line); + var item = ParsePresetLine(line); if (process.ParameterList.Any(c => c.Parameter == item.Parameter)) { @@ -117,6 +117,14 @@ private static void AssemblePresets() equivalentItem.Value = item.Value; + //Copy extra information stored for custom programs + if (item.Parameter == "program") + { + equivalentItem.Value2 = item.Value2; + equivalentItem.Warning = item.Warning; + } + + process.PresetDictionary[preset].Add(equivalentItem); } } @@ -278,16 +286,25 @@ private static ConfigItem ParsePresetLine(string line) item.Parameter = pieces[0]; if (pieces.Count() >= 2) item.Value = pieces[1]; + //Handle extra information stored for custom programs + if (pieces.Count() >= 3) + item.Value2 = pieces[2]; + if (pieces.Length >= 4) + item.ReadOutput = Convert.ToBoolean(pieces[3]); + if (pieces.Length >= 5) + item.Warning = pieces[4]; } return item; } - private static string WritePresetLine(ConfigItem item) + private static string WritePresetLine(ConfigItem item) { - return string.Format("{0},{1}", item.Parameter, item.Value); + //Handle extra information stored for custom programs + if (item.Name == "Run Program") + return $"{item.Parameter},{item.Value},{item.Value2},{item.ReadOutput},{item.Warning}"; + return $"{item.Parameter},{item.Value}"; } - private static ConfigItem ParseBaseLine(string line) { var item = new ConfigItem(); diff --git a/CompilePalX/MainWindow.xaml.cs b/CompilePalX/MainWindow.xaml.cs index 7e9f660c..d387a729 100644 --- a/CompilePalX/MainWindow.xaml.cs +++ b/CompilePalX/MainWindow.xaml.cs @@ -213,7 +213,6 @@ void Current_DispatcherUnhandledException(object sender, DispatcherUnhandledExce void SetSources() { CompileProcessesListBox.ItemsSource = CompileProcessesSubList; - PresetConfigListBox.ItemsSource = ConfigurationManager.KnownPresets; MapListBox.ItemsSource = CompilingManager.MapFiles; @@ -481,7 +480,9 @@ private void UpdateConfigGrid() ProcessDataGrid.BeginAnimation(OpacityProperty, new DoubleAnimation(0, 1, new Duration(TimeSpan.FromMilliseconds(50)))); processModeEnabled = true; - ConfigDataGrid.IsEnabled = false; + ProcessDataGrid.ItemsSource = selectedProcess.PresetDictionary[ConfigurationManager.CurrentPreset]; + + ConfigDataGrid.IsEnabled = false; ConfigDataGrid.Visibility = Visibility.Hidden; ParametersTextBox.Visibility = Visibility.Hidden; @@ -491,8 +492,6 @@ private void UpdateConfigGrid() ProcessTab.IsEnabled = true; ProcessTab.Visibility = Visibility.Visible; - ProcessDataGrid.ItemsSource = selectedProcess.PresetDictionary[ConfigurationManager.CurrentPreset]; - //Hide parameter buttons if ORDER is the current tab if ((string)(ProcessTab.SelectedItem as TabItem)?.Header == "ORDER") { @@ -703,7 +702,7 @@ public void SetOrder(T target, int newOrder) return; program.CustomOrder = newOrder; - programConfig.Parameter = newOrder.ToString(); + programConfig.Warning = newOrder.ToString(); } diff --git a/CompilePalX/Parameters/CUSTOM/parameters.json b/CompilePalX/Parameters/CUSTOM/parameters.json index 760ed7ce..0b1ce1fc 100644 --- a/CompilePalX/Parameters/CUSTOM/parameters.json +++ b/CompilePalX/Parameters/CUSTOM/parameters.json @@ -1,13 +1,13 @@ [ { "Name": "Run Program", - "Parameter": "15", + "Parameter": "program", "Description": "Run a program with command line arguments", "Value": null, "Value2": null, "ReadOutput": true, "CanHaveValue": true, "CanBeUsedMoreThanOnce": true, - "Warning": "" + "Warning": "15" } ] \ No newline at end of file