private void WriteTheLua() { var mulChatLuaText = LsonVars.Parse(File.ReadAllText(dcsMulChatDirectoryAndName_string));//put the contents of mul_char.dlg into a lua read mulChatLuaText["dialog"]["children"]["pNoVisible"]["children"] ["eBlueText"]["skin"]["states"]["released"][2]["text"] ["color"] = Convert_ColorpickerHex_to_DcsHex(colorPicker_blueCoalition.SelectedColor.ToString()); mulChatLuaText["dialog"]["children"]["pNoVisible"]["children"] ["eRedText"]["skin"]["states"]["released"][2]["text"] ["color"] = Convert_ColorpickerHex_to_DcsHex(colorPicker_redCoalition.SelectedColor.ToString()); mulChatLuaText["dialog"]["children"]["pNoVisible"]["children"] ["eYellowText"]["skin"]["states"]["released"][2]["text"] ["color"] = Convert_ColorpickerHex_to_DcsHex(colorPicker_selfSay.SelectedColor.ToString()); mulChatLuaText["dialog"]["children"]["pNoVisible"]["children"] ["eWhiteText"]["skin"]["states"]["released"][2]["text"] ["color"] = Convert_ColorpickerHex_to_DcsHex(colorPicker_spectators.SelectedColor.ToString()); mulChatLuaText["dialog"]["children"]["pNoVisible"]["children"] ["eOrangeText"]["skin"]["states"]["released"][2]["text"] ["color"] = Convert_ColorpickerHex_to_DcsHex(colorPicker_serverMessages.SelectedColor.ToString()); File.WriteAllText(dcsMulChatDirectoryAndName_string, LsonVars.ToString(mulChatLuaText)); // serialize back to a file }
private string ConvertTableToString(DataGridView grid) { Dictionary <string, LsonValue> graphics = new Dictionary <string, LsonValue>(); graphics.Add(GraphicsTableName, new LsonDict()); LsonDict g = (LsonDict)graphics[GraphicsTableName]; foreach (DataGridViewRow row in grid.Rows) { string state = GetString(row.Cells[(int)AnimationCell.Name]); if (state == null) { continue; } string path = GetString(row.Cells[(int)AnimationCell.File]); if (path == null) { continue; } DataGridViewCheckBoxCell cell = (DataGridViewCheckBoxCell)row.Cells[(int)AnimationCell.IsAnimated]; bool IsAnimated = cell.Value == cell.TrueValue; int width = row.Cells[(int)AnimationCell.Width].Value != null?GetIntFromString(row.Cells[(int)AnimationCell.Width].Value.ToString()) : -1; int height = row.Cells[(int)AnimationCell.Height].Value != null?GetIntFromString(row.Cells[(int)AnimationCell.Height].Value.ToString()) : -1; float time = row.Cells[(int)AnimationCell.Time].Value != null?GetFloatFromString(row.Cells[(int)AnimationCell.Time].Value.ToString()) : -1; if (width == -1 || height == -1 || time == -1) { IsAnimated = false; } //TODO Added variables for functions so they could be changed via the form if (IsAnimated) { g[state] = new LsonFunc($"{AnimationFn}(\"{path}\", {width}, {height}, {time})"); } else { g[state] = new LsonFunc($"{ImageFn}(\"{path}\")"); } } return(LsonVars.ToString(graphics).Substring(2)); }
private void Button_selectDcsExe_Click(object sender, RoutedEventArgs e) { //this is where the user will select some specific file //after the file is selected, this app will then find the correct file for modification //the name of that file is \DCS World OpenBeta\MissionEditor\modules\dialogs\mul_chat.dlg //Have the select dialog pop up OpenFileDialog openFileDialog_selectDcsExe = new OpenFileDialog(); openFileDialog_selectDcsExe.InitialDirectory = "C:\\Program Files\\Eagle Dynamics\\DCS World\\bin\\"; //likely not necessary, but it may help openFileDialog_selectDcsExe.Filter = "Application files (*.exe)|*.exe"; //pick an exe only //openFileDialog_selectDcsExe.RestoreDirectory = true;//sure, but not necessary openFileDialog_selectDcsExe.Title = "Select DCS.exe (Hint: C:\\Install Location\\bin\\DCS.exe"; //hints for all kinds of installs //the user picks their dcs-updater.exe if (openFileDialog_selectDcsExe.ShowDialog() == true) { var selected_selectDcsExe = openFileDialog_selectDcsExe.FileName; selected_selectDcsExe_string = selected_selectDcsExe.ToString(); //see the "options.lua" check for info on how this works if (selected_selectDcsExe.IndexOf("DCS.exe", 0, StringComparison.CurrentCultureIgnoreCase) != -1)//check to make sure that the file they pick is the correct one { //the user selected the correct correct file //if the file is the correct one, try to make all of the other file paths that are related //to that part of the folder system GeneratePathsFromDcsExePath(); textBlock_selectDcsExe.Text = selected_selectDcsExe; textBlock_selectDcsExe.BorderBrush = Brushes.LightGreen; //visual feedback //save the location of the exe to the settings file here var savedSettings = LsonVars.Parse(File.ReadAllText(settingsPath)); //put the contents of mul_char.dlg into a lua read string tempString = selected_selectDcsExe_string.Replace('\\', '|'); //this prevents a lua read error savedSettings[appName]["userFileLocation"] = tempString; //save the user location File.WriteAllText(settingsPath, LsonVars.ToString(savedSettings)); // serialize back to a file } else { //the user did not select the correct file MessageBox.Show("You picked: " + selected_selectDcsExe + ". This is not the correct file. Please try again."); //textBlock_selectDcsExe.Text = null; } } }
private void SaveAllOfTheData() { //this will be called when all the data needs to be saved. //Most likely only when the user clicks the save button //nevermind. we are going to have 5 presets. //string[] contents = { "hi" }; //string FileLocation = @"G:\Games\DCS World OpenBeta\MissionEditor\modules\dialogs\testArea\masterSave.txt"; //System.IO.File.WriteAllLines(FileLocation, contents); //var masterSaveFile = LsonVars.Parse(File.ReadAllText(FileLocation)); //masterSaveFile["dialog"]["children"]["pNoVisible"]["children"] // ["eOrangeText"]["skin"]["states"]["released"][2]["text"] // ["color"] = Convert_ColorpickerHex_to_DcsHex(colorPicker_serverMessages.SelectedColor.ToString()); var savedSettings = LsonVars.Parse(File.ReadAllText(settingsPath)); //put the contents of mul_char.dlg into a lua read string tempString = selected_selectDcsExe_string.Replace('\\', '|'); //this prevents a lua read error savedSettings[appName]["userFileLocation"] = tempString; //save the user location //case for which preset was enabled and which to overrite, if any switch (dropDownButton_loadPreset.SelectedItem.ToString()) { case "Option 1": //if Option 1 was in the box when the save button was pressed savedSettings[appName]["Presets"]["presetName_1"]["color_1"] = (colorPicker_blueCoalition.SelectedColor.ToString()); savedSettings[appName]["Presets"]["presetName_1"]["color_2"] = (colorPicker_redCoalition.SelectedColor.ToString()); savedSettings[appName]["Presets"]["presetName_1"]["color_3"] = (colorPicker_spectators.SelectedColor.ToString()); savedSettings[appName]["Presets"]["presetName_1"]["color_4"] = (colorPicker_selfSay.SelectedColor.ToString()); savedSettings[appName]["Presets"]["presetName_1"]["color_5"] = (colorPicker_serverMessages.SelectedColor.ToString()); break; case "Option 2": savedSettings[appName]["Presets"]["presetName_2"]["color_1"] = (colorPicker_blueCoalition.SelectedColor.ToString()); savedSettings[appName]["Presets"]["presetName_2"]["color_2"] = (colorPicker_redCoalition.SelectedColor.ToString()); savedSettings[appName]["Presets"]["presetName_2"]["color_3"] = (colorPicker_spectators.SelectedColor.ToString()); savedSettings[appName]["Presets"]["presetName_2"]["color_4"] = (colorPicker_selfSay.SelectedColor.ToString()); savedSettings[appName]["Presets"]["presetName_2"]["color_5"] = (colorPicker_serverMessages.SelectedColor.ToString()); break; case "Option 3": savedSettings[appName]["Presets"]["presetName_3"]["color_1"] = (colorPicker_blueCoalition.SelectedColor.ToString()); savedSettings[appName]["Presets"]["presetName_3"]["color_2"] = (colorPicker_redCoalition.SelectedColor.ToString()); savedSettings[appName]["Presets"]["presetName_3"]["color_3"] = (colorPicker_spectators.SelectedColor.ToString()); savedSettings[appName]["Presets"]["presetName_3"]["color_4"] = (colorPicker_selfSay.SelectedColor.ToString()); savedSettings[appName]["Presets"]["presetName_3"]["color_5"] = (colorPicker_serverMessages.SelectedColor.ToString()); break; //the rest shouldnt do anything to the backup file case "Default": break; case "Presets": break; } File.WriteAllText(settingsPath, LsonVars.ToString(savedSettings)); // serialize back to a file }