Exemplo n.º 1
0
        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
        }
Exemplo n.º 2
0
        public static void ParseToExcel(string[] settings)
        {
            string savedVariables = GetSavedVariables(settings[0]);
            var    lson           = LsonVars.Parse(savedVariables);
            var    donators       = lson["ZLM_Donators"];

            Application oXL;
            _Workbook   oWB;
            _Worksheet  oSheet;

            oXL         = new Application();
            oXL.Visible = true;

            oWB         = (_Workbook)(oXL.Workbooks.Add(Missing.Value));
            oSheet      = (_Worksheet)oWB.ActiveSheet;
            oSheet.Name = "Donations";

            oSheet.get_Range("A1").Value2 = "Character";
            oSheet.get_Range("B1").Value2 = "Item";
            oSheet.get_Range("C1").Value2 = "Quantity";

            oSheet.get_Range("O1").Value2 = "Name";
            oSheet.get_Range("P1").Value2 = "Total Points";

            try
            {
                WriteMaterialsTable(oSheet);
                var row      = 1;
                var donorRow = 1;
                foreach (var key in donators.Keys)
                {
                    donorRow += 1;
                    var donator   = donators[key];
                    var name      = donator["name"].GetStringLenientSafe() ?? "NAME UNKNOWN";
                    var donations = donator["donations"];

                    oSheet.get_Range("O" + donorRow).Value2 = name;
                    oSheet.get_Range("P" + donorRow).Value2 = "=SUMIF($A$2:$A$1000,$O" + donorRow + ",$D$2:$D$1000)";

                    foreach (var donationKey in donations.Keys)
                    {
                        row += 1;
                        var donation = donations[donationKey];
                        oSheet.get_Range("A" + row).Value2 = name;
                        oSheet.get_Range("B" + row).Value2 = donation["item"].GetStringLenientSafe() ?? "NO ITEM FOUND";
                        oSheet.get_Range("C" + row).Value2 = donation["quantity"].GetIntLenientSafe().HasValue ? donation["quantity"].GetIntLenientSafe().Value : 0;
                        oSheet.get_Range("D" + row).Value2 = "=VLOOKUP($B2,$F$2:$M$29,4,FALSE)*C" + row;
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            try
            {
                oWB.SaveAs(Path.Combine(settings[1], "TCAccounting_" + DateTime.Now.AddHours(-1).ToString("hh-mm-ss-MM-dd-yyyy")));
            }
            catch { }
        }
Exemplo n.º 3
0
        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));
        }
        public IEnumerable <Raid> GetRaids()
        {
            var raids = new List <Raid>();

            var cepgpFilePath = Path.Combine(_cepgpDirectory.FullName, "CEPGP.lua");

            if (!System.IO.File.Exists(cepgpFilePath))
            {
                return(raids);
            }

            var lson = LsonVars.Parse(System.IO.File.ReadAllText(cepgpFilePath));

            var raidsraidSnapshots = lson["CEPGP_raid_logs"];

            if (raidsraidSnapshots == null)
            {
                return(raids);
            }

            foreach (var raidsSnapshot in raidsraidSnapshots.Values)
            {
                var raid = new Raid("");

                for (var i = 0; i < raidsSnapshot.Values.Count; i++)
                {
                    var entry = raidsSnapshot.Values.ElementAt(i);

                    if (i == 0)
                    {
                        var raidUnixDate = entry.GetDouble();
                        var raidDate     = UnixTimeStampToDateTime(raidUnixDate);
                        raid.SetDate(raidDate);
                    }
                    else
                    {
                        raid.Members.Add(entry.GetStringSafe());
                    }
                }

                raids.Add(raid);
            }

            return(raids);
        }
Exemplo n.º 5
0
        private void ReadTheLua()
        {
            var mulChatLuaText = LsonVars.Parse(File.ReadAllText(dcsMulChatDirectoryAndName_string));//put the contents of mul_char.dlg into a lua read

            //put the five colors into 5 different variables
            //the following should result in "0x0808dbff" for the default file
            eBlueText_ValueFromDlg = mulChatLuaText["dialog"]["children"]["pNoVisible"]["children"]["eBlueText"]
                                     ["skin"]["states"]["released"][2]["text"]["color"].GetString();
            //MessageBox.Show("The color form the dlg file is: " + eBlueText_ValueFromDlg);//result in "0x0808dbff"
            eRedText_ValueFromDlg = mulChatLuaText["dialog"]["children"]["pNoVisible"]["children"]["eRedText"]
                                    ["skin"]["states"]["released"][2]["text"]["color"].GetString();
            eYellowText_ValueFromDlg = mulChatLuaText["dialog"]["children"]["pNoVisible"]["children"]["eYellowText"]
                                       ["skin"]["states"]["released"][2]["text"]["color"].GetString();
            eWhiteText_ValueFromDlg = mulChatLuaText["dialog"]["children"]["pNoVisible"]["children"]["eWhiteText"]
                                      ["skin"]["states"]["released"][2]["text"]["color"].GetString();
            eOrangeText_ValueFromDlg = mulChatLuaText["dialog"]["children"]["pNoVisible"]["children"]["eOrangeText"]
                                       ["skin"]["states"]["released"][2]["text"]["color"].GetString();
        }
Exemplo n.º 6
0
        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;
                }
            }
        }
Exemplo n.º 7
0
        private void LoadPreset1Colors()
        {
            var savedSettings = LsonVars.Parse(File.ReadAllText(settingsPath));//put the contents of the settings file into a lua read

            //the selected color will equal the string that represents the lua section
            //colorPicker_blueCoalition.SelectedColor =
            //     (Color)ColorConverter.ConvertFromString("#FF0808DB");
            colorPicker_blueCoalition.SelectedColor =
                (Color)ColorConverter.ConvertFromString(savedSettings[appName]["Presets"]["presetName_1"]["color_1"].GetString());
            colorPicker_redCoalition.SelectedColor =
                (Color)ColorConverter.ConvertFromString(savedSettings[appName]["Presets"]["presetName_1"]["color_2"].GetString());
            colorPicker_spectators.SelectedColor =
                (Color)ColorConverter.ConvertFromString(savedSettings[appName]["Presets"]["presetName_1"]["color_3"].GetString());
            colorPicker_selfSay.SelectedColor =
                (Color)ColorConverter.ConvertFromString(savedSettings[appName]["Presets"]["presetName_1"]["color_4"].GetString());
            colorPicker_serverMessages.SelectedColor =
                (Color)ColorConverter.ConvertFromString(savedSettings[appName]["Presets"]["presetName_1"]["color_5"].GetString());
            //Console.WriteLine(savedSettings[appName]["Presets"]["presetName_1"]["color_1"].ToString());
        }
Exemplo n.º 8
0
        public IEnumerable <Transaction> GetTransactions()
        {
            var transactions = new List <Transaction>();

            var cepgpFilePath = Path.Combine(_cepgpDirectory.FullName, "CEPGP.lua");

            if (!System.IO.File.Exists(cepgpFilePath))
            {
                return(transactions);
            }

            var lson = LsonVars.Parse(System.IO.File.ReadAllText(cepgpFilePath));

            var trafficItem = lson["TRAFFIC"];

            if (trafficItem == null)
            {
                return(transactions);
            }

            foreach (var item in trafficItem.Values)
            {
                var transaction = new Transaction();

                transaction.Target   = item.Values.ElementAt(0).GetString();
                transaction.IssuedBy = item.Values.ElementAt(1).GetString();
                transaction.Action   = item.Values.ElementAt(2).GetString();
                transaction.EPBefore = new EP(item.Values.ElementAtOrDefault(3)?.GetDecimalSafe(NumericConversionOptions.AllowConversionFromString) ?? 0);
                transaction.EPAfter  = new EP(item.Values.ElementAtOrDefault(4)?.GetDecimalSafe(NumericConversionOptions.AllowConversionFromString) ?? 0);
                transaction.GPBefore = new GP(item.Values.ElementAtOrDefault(5)?.GetDecimalSafe(NumericConversionOptions.AllowConversionFromString) ?? 0);
                transaction.GPAfter  = new GP(item.Values.ElementAtOrDefault(6)?.GetDecimalSafe(NumericConversionOptions.AllowConversionFromString) ?? 0);
                transaction.Item     = Item.Parse(item.Values.ElementAtOrDefault(7)?.GetStringSafe());

                transactions.Add(transaction);
            }

            transactions.Reverse();

            return(transactions);
        }
Exemplo n.º 9
0
        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
        }
Exemplo n.º 10
0
        private void CheckForSaveFile()
        {
            if (File.Exists(settingsPath))                                          //if the safe file exists, load it
            {
                var savedSettings = LsonVars.Parse(File.ReadAllText(settingsPath)); //put the contents of the settings file into a lua read

                selected_selectDcsExe_string = savedSettings[appName]["userFileLocation"].GetString();

                if (selected_selectDcsExe_string.Length > 2)//i just chose two just because
                {
                    selected_selectDcsExe_string = selected_selectDcsExe_string.Replace('|', '\\');
                    Console.WriteLine("DEBUG: The Saved Settings userFileLocation is: " + selected_selectDcsExe_string);
                    textBlock_selectDcsExe.Text = selected_selectDcsExe_string;
                    isDcsExeSelected            = true;
                    GeneratePathsFromDcsExePath();
                    textBlock_selectDcsExe.BorderBrush = Brushes.LightGreen;//visual feedback
                    ReadTheLua();
                    ApplyLuaColors();
                    EnableAllButtons();
                }
            }
            else//if the save file does not exist, make one
            {
                Console.WriteLine("DEBUG: Did not find the Setting file");

                Directory.CreateDirectory(appPath + appName);//creates the save folder
                //https://docs.microsoft.com/en-us/dotnet/api/system.io.streamwriter?redirectedfrom=MSDN&view=netcore-3.1

                //write the following in the text file
                string[] defaultExportString =
                {
                    appName + " = ",
                    //"DcsMultiplayerChatColorPicker = ",
                    "{",
                    "   [\"userFileLocation\"] = \"\",",
                    "   [\"Presets\"] = ",
                    "   {",
                    "       [\"presetName_1\"] = ",
                    "       {",
                    "           [\"color_1\"] = \"#FF1E88E5\",",
                    "           [\"color_2\"] = \"#FFD81B60\",",
                    "           [\"color_3\"] = \"#FFFFFFFF\",",
                    "           [\"color_4\"] = \"#FFFFC107\",",
                    "           [\"color_5\"] = \"#FF004D40\",",
                    "       },",
                    "       [\"presetName_2\"] =",
                    "       {",
                    "           [\"color_1\"] = \"#FFFF8C00\",",
                    "           [\"color_2\"] = \"#FFFFEF00\",",
                    "           [\"color_3\"] = \"#FF00811F\",",
                    "           [\"color_4\"] = \"#FF0044FF\",",
                    "           [\"color_5\"] = \"#FF760089\",",
                    "       },",
                    "       [\"presetName_3\"] =",
                    "       {",
                    "           [\"color_1\"] = \"#FF55CDFC\",",
                    "           [\"color_2\"] = \"#FFF7A8B8\",",
                    "           [\"color_3\"] = \"#FFFEFEFE\",",
                    "           [\"color_4\"] = \"#FFF7A8B8\",",
                    "           [\"color_5\"] = \"#FF55CDFC\",",
                    "       },",
                    "   },",
                    "}",
                };
                System.IO.File.WriteAllLines(settingsPath, defaultExportString);
            }

            //load presets
            dropDownButton_loadPreset.ItemsSource = new List <string> {
                "Current", "Default", "Option 1", "Option 2", "Option 3"
            };
            dropDownButton_loadPreset.SelectedIndex = 0;
        }