Пример #1
0
        public static void Save(string path)
        {
            #region Base

            if (File.Exists(path))
            {
                if (!IsFileUsable(path))
                {
                    Extensions.Error("[Config][Save][Error] Config File is not usable", 0, false);
                    return;
                }
            }

            var configParser = new FileIniDataParser();
            var configData   = new IniData();

            configData["Radar"]["Enabled"] = Settings.Radar.Enabled.ToString();

            configData["Bunnyhop"]["Enabled"] = Settings.Bunnyhop.Enabled.ToString();
            configData["Bunnyhop"]["Key"]     = Settings.Bunnyhop.Key.ToString();

            configData["Trigger"]["Enabled"] = Settings.Trigger.Enabled.ToString();
            configData["Trigger"]["Key"]     = Settings.Trigger.Key.ToString();
            configData["Trigger"]["Delay"]   = Settings.Trigger.Delay.ToString();

            configData["Chams"]["Enabled"] = Settings.Chams.Enabled.ToString();

            configData["Chams"]["Allies"]         = Settings.Chams.Allies.ToString();
            configData["Chams"]["Allies_Color_R"] = Settings.Chams.Allies_Color_R.ToString();
            configData["Chams"]["Allies_Color_G"] = Settings.Chams.Allies_Color_G.ToString();
            configData["Chams"]["Allies_Color_B"] = Settings.Chams.Allies_Color_B.ToString();
            configData["Chams"]["Allies_Color_A"] = Settings.Chams.Allies_Color_A.ToString();

            configData["Chams"]["Enemies"]         = Settings.Chams.Enemies.ToString();
            configData["Chams"]["Enemies_Color_R"] = Settings.Chams.Enemies_Color_R.ToString();
            configData["Chams"]["Enemies_Color_G"] = Settings.Chams.Enemies_Color_G.ToString();
            configData["Chams"]["Enemies_Color_B"] = Settings.Chams.Enemies_Color_B.ToString();
            configData["Chams"]["Enemies_Color_A"] = Settings.Chams.Enemies_Color_A.ToString();

            configData["Glow"]["Enabled"]         = Settings.Glow.Enabled.ToString();
            configData["Glow"]["PlayerColorMode"] = Settings.Glow.PlayerColorMode.ToString();
            configData["Glow"]["FullBloom"]       = Settings.Glow.FullBloom.ToString();

            configData["Glow"]["Allies"]         = Settings.Glow.Allies.ToString();
            configData["Glow"]["Allies_Color_R"] = Settings.Glow.Allies_Color_R.ToString();
            configData["Glow"]["Allies_Color_G"] = Settings.Glow.Allies_Color_G.ToString();
            configData["Glow"]["Allies_Color_B"] = Settings.Glow.Allies_Color_B.ToString();
            configData["Glow"]["Allies_Color_A"] = Settings.Glow.Allies_Color_A.ToString();

            configData["Glow"]["Enemies"]         = Settings.Glow.Enemies.ToString();
            configData["Glow"]["Enemies_Color_R"] = Settings.Glow.Enemies_Color_R.ToString();
            configData["Glow"]["Enemies_Color_G"] = Settings.Glow.Enemies_Color_G.ToString();
            configData["Glow"]["Enemies_Color_B"] = Settings.Glow.Enemies_Color_B.ToString();
            configData["Glow"]["Enemies_Color_A"] = Settings.Glow.Enemies_Color_A.ToString();

            configData["Glow"]["Snipers"]         = Settings.Glow.Snipers.ToString();
            configData["Glow"]["Snipers_Color_R"] = Settings.Glow.Snipers_Color_R.ToString();
            configData["Glow"]["Snipers_Color_G"] = Settings.Glow.Snipers_Color_G.ToString();
            configData["Glow"]["Snipers_Color_B"] = Settings.Glow.Snipers_Color_B.ToString();
            configData["Glow"]["Snipers_Color_A"] = Settings.Glow.Snipers_Color_A.ToString();

            configData["Glow"]["Rifles"]         = Settings.Glow.Rifles.ToString();
            configData["Glow"]["Rifles_Color_R"] = Settings.Glow.Rifles_Color_R.ToString();
            configData["Glow"]["Rifles_Color_G"] = Settings.Glow.Rifles_Color_G.ToString();
            configData["Glow"]["Rifles_Color_B"] = Settings.Glow.Rifles_Color_B.ToString();
            configData["Glow"]["Rifles_Color_A"] = Settings.Glow.Rifles_Color_A.ToString();

            configData["Glow"]["MachineGuns"]         = Settings.Glow.MachineGuns.ToString();
            configData["Glow"]["MachineGuns_Color_R"] = Settings.Glow.MachineGuns_Color_R.ToString();
            configData["Glow"]["MachineGuns_Color_G"] = Settings.Glow.MachineGuns_Color_G.ToString();
            configData["Glow"]["MachineGuns_Color_B"] = Settings.Glow.MachineGuns_Color_B.ToString();
            configData["Glow"]["MachineGuns_Color_A"] = Settings.Glow.MachineGuns_Color_A.ToString();

            configData["Glow"]["MPs"]         = Settings.Glow.MPs.ToString();
            configData["Glow"]["MPs_Color_R"] = Settings.Glow.MPs_Color_R.ToString();
            configData["Glow"]["MPs_Color_G"] = Settings.Glow.MPs_Color_G.ToString();
            configData["Glow"]["MPs_Color_B"] = Settings.Glow.MPs_Color_B.ToString();
            configData["Glow"]["MPs_Color_A"] = Settings.Glow.MPs_Color_A.ToString();

            configData["Glow"]["Pistols"]         = Settings.Glow.Pistols.ToString();
            configData["Glow"]["Pistols_Color_R"] = Settings.Glow.Pistols_Color_R.ToString();
            configData["Glow"]["Pistols_Color_G"] = Settings.Glow.Pistols_Color_G.ToString();
            configData["Glow"]["Pistols_Color_B"] = Settings.Glow.Pistols_Color_B.ToString();
            configData["Glow"]["Pistols_Color_A"] = Settings.Glow.Pistols_Color_A.ToString();

            configData["Glow"]["Shotguns"]         = Settings.Glow.Shotguns.ToString();
            configData["Glow"]["Shotguns_Color_R"] = Settings.Glow.Shotguns_Color_R.ToString();
            configData["Glow"]["Shotguns_Color_G"] = Settings.Glow.Shotguns_Color_G.ToString();
            configData["Glow"]["Shotguns_Color_B"] = Settings.Glow.Shotguns_Color_B.ToString();
            configData["Glow"]["Shotguns_Color_A"] = Settings.Glow.Shotguns_Color_A.ToString();

            configData["Glow"]["C4"]         = Settings.Glow.C4.ToString();
            configData["Glow"]["C4_Color_R"] = Settings.Glow.C4_Color_R.ToString();
            configData["Glow"]["C4_Color_G"] = Settings.Glow.C4_Color_G.ToString();
            configData["Glow"]["C4_Color_B"] = Settings.Glow.C4_Color_B.ToString();
            configData["Glow"]["C4_Color_A"] = Settings.Glow.C4_Color_A.ToString();

            configData["Glow"]["Grenades"]         = Settings.Glow.Grenades.ToString();
            configData["Glow"]["Grenades_Color_R"] = Settings.Glow.Grenades_Color_R.ToString();
            configData["Glow"]["Grenades_Color_G"] = Settings.Glow.Grenades_Color_G.ToString();
            configData["Glow"]["Grenades_Color_B"] = Settings.Glow.Grenades_Color_B.ToString();
            configData["Glow"]["Grenades_Color_A"] = Settings.Glow.Grenades_Color_A.ToString();

            configData["Aimbot"]["Enabled"]                     = Settings.Aimbot.Enabled.ToString();
            configData["Aimbot"]["Fov"]                         = Settings.Aimbot.Fov.ToString();
            configData["Aimbot"]["Bone"]                        = Settings.Aimbot.Bone.ToString();
            configData["Aimbot"]["Smooth"]                      = Settings.Aimbot.Smooth.ToString();
            configData["Aimbot"]["RecoilControl"]               = Settings.Aimbot.RecoilControl.ToString();
            configData["Aimbot"]["YawRecoilReductionFactory"]   = Settings.Aimbot.YawRecoilReductionFactory.ToString();
            configData["Aimbot"]["PitchRecoilReductionFactory"] = Settings.Aimbot.PitchRecoilReductionFactory.ToString();
            configData["Aimbot"]["Curve"]                       = Settings.Aimbot.Curve.ToString();
            configData["Aimbot"]["CurveX"]                      = Settings.Aimbot.CurveX.ToString();
            configData["Aimbot"]["CurveY"]                      = Settings.Aimbot.CurveY.ToString();

            #endregion

            configData["FOVChanger"]["Enabled"]   = Settings.FOVChanger.Enabled.ToString();
            configData["FOVChanger"]["Fov"]       = Settings.FOVChanger.Fov.ToString();
            configData["ViewModelFov"]["Enabled"] = Settings.FOVChanger.ViewModelFov.Enabled.ToString();
            configData["ViewModelFov"]["Fov"]     = Settings.FOVChanger.ViewModelFov.Fov.ToString();

            configData["No_Flash"]["Enabled"]      = Settings.No_Flash.Enabled.ToString();
            configData["AutoPistol"]["Enabled"]    = Settings.AutoPistol.Enabled.ToString();
            configData["StandaloneRCS"]["Enabled"] = Settings.StandaloneRCS.Enabled.ToString();

            configParser.WriteFile(path, configData);

            Extensions.Information("[Config][Save] Saved", true);
        }
        /// <summary>
        /// Прочитать стратегии из ini файла
        /// </summary>
        public void ReadStrategies()
        {
            if (!File.Exists(IniTool.IniFnameStates))
            {
                FileIniDataParser tfileIniData  = new FileIniDataParser();
                IniData           newParsedData = new IniData();
                tfileIniData.WriteFile(IniTool.IniFnameStates, newParsedData);
            }

            FileIniDataParser         fileIniData      = new FileIniDataParser();
            IniData                   parsedDataParams = fileIniData.ReadFile(IniTool.IniFnameParams);
            IniData                   parsedDataStates = fileIniData.ReadFile(IniTool.IniFnameStates);
            IEnumerable <SectionData> StratSectParams  = parsedDataParams.Sections.Where((x) => { return(x.SectionName.Contains("Strategy_")); });

            foreach (SectionData sdata in StratSectParams)
            {
                try
                {
                    Dictionary <string, string> ResDictParam = new Dictionary <string, string>();
                    for (int i = 0; i < sdata.Keys.Count; i++)
                    {
                        ResDictParam.Add(sdata.Keys.ElementAt(i).KeyName, sdata.Keys.ElementAt(i).Value);
                    }
                    Strategy nStrategy = StrategyTool.GetStrategyByName(ResDictParam["StrategyType"], sdata.SectionName);
                    nStrategy.ChangeState += OnStartegyChangeState;
                    nStrategy.Param.LoadData(ResDictParam);

                    if (parsedDataStates.Sections.ContainsSection(sdata.SectionName))
                    {
                        SectionData SDataState = parsedDataStates.Sections.GetSectionData(sdata.SectionName);
                        Dictionary <string, string> ResDictState = new Dictionary <string, string>();
                        for (int i = 0; i < SDataState.Keys.Count; i++)
                        {
                            ResDictState.Add(SDataState.Keys.ElementAt(i).KeyName, SDataState.Keys.ElementAt(i).Value);
                        }
                        nStrategy.State.LoadData(ResDictState);
                    }
                    else
                    {
                        nStrategy.SaveData(false);
                    }

                    StrategiesList.Add(nStrategy.Param.StrategyName, nStrategy);

                    if (nStrategy.State.IsStartegyRun)
                    {
                        nStrategy.State.IsStartegyRun = false;
                        try
                        {
                            ThreadPool.QueueUserWorkItem((x) => nStrategy.Start(false));
                            Print(string.Format("Запущено стратегию: [{0}]", nStrategy.Param.StrategyName));
                        }
                        catch (Exception ex)
                        {
                            System.Media.SystemSounds.Beep.Play();
                            Print(string.Format("Ошибка при запуске стратегии [{0}]: {1}", nStrategy.Param.StrategyName, ex.Message));
                        }
                    }
                }
                catch (Exception ex)
                {
                    System.Media.SystemSounds.Beep.Play();
                    Print("Ошибка при возобновлении стратегии из ini файла: " + ex.Message);
                }
            }
        }
Пример #3
0
        public static void SaveConfig()
        {
            var path = Path.Combine(Directory.GetCurrentDirectory(), "Settings.ini");

            if (!File.Exists(path))
            {
                using (var sw = File.AppendText(path))
                    sw.WriteLine("");
            }


            var parser = new FileIniDataParser();
            var data   = parser.ReadFile("Settings.ini");

            // Keep ^^

            data["GLOW TEAM"]["Enabled"] = Settings.GlowTeam.Enabled.ToString();
            data["GLOW TEAM"]["Chams"]   = Settings.GlowTeam.ChamsEnabled.ToString();
            data["GLOW TEAM"]["Alpha"]   = Settings.GlowTeam.Alpha.ToString();
            data["GLOW TEAM"]["Red"]     = Settings.GlowTeam.Red.ToString();
            data["GLOW TEAM"]["Green"]   = Settings.GlowTeam.Green.ToString();
            data["GLOW TEAM"]["Blue"]    = Settings.GlowTeam.Blue.ToString();

            data["GLOW ENEMY"]["Enabled"] = Settings.GlowEnemy.Enabled.ToString();
            data["GLOW ENEMY"]["Chams"]   = Settings.GlowEnemy.ChamsEnabled.ToString();
            data["GLOW ENEMY"]["Alpha"]   = Settings.GlowEnemy.Alpha.ToString();
            data["GLOW ENEMY"]["Red"]     = Settings.GlowEnemy.Red.ToString();
            data["GLOW ENEMY"]["Green"]   = Settings.GlowEnemy.Green.ToString();
            data["GLOW ENEMY"]["Blue"]    = Settings.GlowEnemy.Blue.ToString();

            data["FOV"]["Enabled"] = Settings.Fovchanger.Enabled.ToString();
            data["FOV"]["Fov"]     = Settings.Fovchanger.Fov.ToString();

            data["BUNNY"]["Enabled"]   = Settings.Bhop.Enabled.ToString();
            data["BUNNY"]["JumpLimit"] = Settings.Bhop.JumpLimit.ToString();
            data["BUNNY"]["MaxJumps"]  = Settings.Bhop.MaxJumps.ToString();

            data["NO FLASH"]["Enabled"]      = Settings.NoFlash.Enabled.ToString();
            data["NO FLASH"]["Flash Amount"] = Settings.NoFlash.Flash.ToString();

            data["NOHANDS"]["Enabled"] = Settings.NoFlash.Enabled.ToString();

            data["HITSOUND"]["Enabled"] = Settings.Hitsound.Enabled.ToString();
            data["HITSOUND"]["Mode"]    = Settings.Hitsound.Mode.ToString();

            data["TRIGGER"]["Enabled"] = Settings.Trigger.Enabled.ToString();

            data["AUTOPISTOL"]["Enabled"] = Settings.Autopistol.Enabled.ToString();
            data["AUTOPISTOL"]["AnyGun"]  = Settings.Autopistol.AnyGun.ToString();

            data["RADAR"]["Enabled"] = Settings.Radar.Enabled.ToString();

            data["AIMBOT"]["Enabled"] = Settings.Aimbot.Enabled.ToString();

            data["RCS"]["Enabled"] = Settings.RCS.Enabled.ToString();
            data["RCS"]["X"]       = Settings.RCS.X.ToString();
            data["RCS"]["Y"]       = Settings.RCS.Y.ToString();

            data["OVERLAY"]["Enabled"]   = Settings.Overlay.Enabled.ToString();
            data["OVERLAY"]["Crosshair"] = Settings.Overlay.Crosshair.ToString();

            data["SKINCHANGER"]["Enabled"]       = Settings.Skinchanger.Enabled.ToString();
            data["SKINCHANGER"]["DEAGLESkin"]    = Settings.Skinchanger.WEAPON_DEAGLE.ToString();
            data["SKINCHANGER"]["ELITESkin"]     = Settings.Skinchanger.WEAPON_ELITE.ToString();
            data["SKINCHANGER"]["FIVESEVENSkin"] = Settings.Skinchanger.WEAPON_FIVESEVEN.ToString();
            data["SKINCHANGER"]["GLOCKSkin"]     = Settings.Skinchanger.WEAPON_GLOCK.ToString();
            data["SKINCHANGER"]["AK47Skin"]      = Settings.Skinchanger.WEAPON_AK47.ToString();
            data["SKINCHANGER"]["AUGSkin"]       = Settings.Skinchanger.WEAPON_AUG.ToString();
            data["SKINCHANGER"]["AWPSkin"]       = Settings.Skinchanger.WEAPON_AWP.ToString();
            data["SKINCHANGER"]["FAMASSkin"]     = Settings.Skinchanger.WEAPON_FAMAS.ToString();
            data["SKINCHANGER"]["G3SG1Skin"]     = Settings.Skinchanger.WEAPON_G3SG1.ToString();
            data["SKINCHANGER"]["GALILSkin"]     = Settings.Skinchanger.WEAPON_GALILAR.ToString();
            data["SKINCHANGER"]["M249Skin"]      = Settings.Skinchanger.WEAPON_M249.ToString();
            data["SKINCHANGER"]["M4A1Skin"]      = Settings.Skinchanger.WEAPON_M4A1.ToString();
            data["SKINCHANGER"]["MAC10Skin"]     = Settings.Skinchanger.WEAPON_MAC10.ToString();
            data["SKINCHANGER"]["P90Skin"]       = Settings.Skinchanger.WEAPON_P90.ToString();
            data["SKINCHANGER"]["UMP45Skin"]     = Settings.Skinchanger.WEAPON_UMP45.ToString();
            data["SKINCHANGER"]["XM1014Skin"]    = Settings.Skinchanger.WEAPON_XM1014.ToString();
            data["SKINCHANGER"]["BIZONSkin"]     = Settings.Skinchanger.WEAPON_BIZON.ToString();
            data["SKINCHANGER"]["MAG7Skin"]      = Settings.Skinchanger.WEAPON_MAG7.ToString();
            data["SKINCHANGER"]["NEGEVSkin"]     = Settings.Skinchanger.WEAPON_NEGEV.ToString();
            data["SKINCHANGER"]["SAWEDOFFSkin"]  = Settings.Skinchanger.WEAPON_SAWEDOFF.ToString();
            data["SKINCHANGER"]["TEC9Skin"]      = Settings.Skinchanger.WEAPON_TEC9.ToString();
            data["SKINCHANGER"]["HKP2000Skin"]   = Settings.Skinchanger.WEAPON_HKP2000.ToString();
            data["SKINCHANGER"]["MP7Skin"]       = Settings.Skinchanger.WEAPON_MP7.ToString();
            data["SKINCHANGER"]["MP9Skin"]       = Settings.Skinchanger.WEAPON_MP9.ToString();
            data["SKINCHANGER"]["NOVASkin"]      = Settings.Skinchanger.WEAPON_NOVA.ToString();
            data["SKINCHANGER"]["P250Skin"]      = Settings.Skinchanger.WEAPON_P250.ToString();
            data["SKINCHANGER"]["SCAR20Skin"]    = Settings.Skinchanger.WEAPON_SCAR20.ToString();
            data["SKINCHANGER"]["SG556Skin"]     = Settings.Skinchanger.WEAPON_SG556.ToString();
            data["SKINCHANGER"]["SSG08Skin"]     = Settings.Skinchanger.WEAPON_SSG08.ToString();

            // Get value ^^

            parser.WriteFile("Settings.ini", data);
            // Save config ^^
        }
Пример #4
0
 public void setIni(String section, String node, String value)
 {
     data[section][node] = value;
     parser.WriteFile(section, data);
 }
Пример #5
0
 /// <summary>
 /// Writes the config data to disk. This method is thread-blocking, and all write operations
 /// are synchronized via lock(WriteLock).
 /// </summary>
 /// <param name="dataParser">The parser dealing with the current data.</param>
 /// <param name="data">The data which should be written to file.</param>
 private static void WriteConfig(FileIniDataParser dataParser, IniData data)
 {
     dataParser.WriteFile(GetConfigurationFilePath(), data);
 }
Пример #6
0
        /// <summary>
        /// Save the style to a file.
        /// </summary>
        /// <param name="themeName">Theme name.</param>
        public static void SaveToFile(string themeName)
        {
            //Init INI.
            IniData ini = new IniData();

            ini.Sections.AddSection("Colors");
            ini.Sections.AddSection("Main");
            ini.Sections.AddSection("Borders");
            ini.Sections.AddSection("Rounding");
            ini.Sections.AddSection("Alignment");
            ini.Sections.AddSection("Font");
            ini.Sections.AddSection("Safe Area Padding");

            //Get style.
            var style = ImGui.GetStyle();

            //Colors.
            var names = Enum.GetNames(typeof(ImGuiCol));

            for (int i = 0; i < names.Length - 1; i++)
            {
                ini["Colors"].AddKey(names[i], ConvVec(style.Colors[i]));
            }

            //Main.
            ini["Main"].AddKey("WindowPadding", ConvVec2(style.WindowPadding));
            ini["Main"].AddKey("FramePadding", ConvVec2(style.FramePadding));
            ini["Main"].AddKey("ItemSpacing", ConvVec2(style.ItemSpacing));
            ini["Main"].AddKey("ItemInnerSpacing", ConvVec2(style.ItemInnerSpacing));
            ini["Main"].AddKey("TouchExtraPadding", ConvVec2(style.TouchExtraPadding));
            ini["Main"].AddKey("IndentSpacing", style.IndentSpacing.ToString());
            ini["Main"].AddKey("ScrollbarSize", style.ScrollbarSize.ToString());
            ini["Main"].AddKey("GrabMinSize", style.GrabMinSize.ToString());

            //Borders.
            ini["Borders"].AddKey("WindowBorderSize", style.WindowBorderSize.ToString());
            ini["Borders"].AddKey("ChildBorderSize", style.ChildBorderSize.ToString());
            ini["Borders"].AddKey("PopupBorderSize", style.PopupBorderSize.ToString());
            ini["Borders"].AddKey("FrameBorderSize", style.FrameBorderSize.ToString());
            ini["Borders"].AddKey("TabBorderSize", style.TabBorderSize.ToString());

            //Rounding.
            ini["Rounding"].AddKey("WindowRounding", style.WindowRounding.ToString());
            ini["Rounding"].AddKey("ChildRounding", style.ChildRounding.ToString());
            ini["Rounding"].AddKey("FrameRounding", style.FrameRounding.ToString());
            ini["Rounding"].AddKey("PopupRounding", style.PopupRounding.ToString());
            ini["Rounding"].AddKey("ScrollbarRounding", style.ScrollbarRounding.ToString());
            ini["Rounding"].AddKey("GrabRounding", style.GrabRounding.ToString());
            ini["Rounding"].AddKey("TabRounding", style.TabRounding.ToString());

            //Alignment.
            ini["Alignment"].AddKey("WindowTitleAlign", ConvVec2(style.WindowTitleAlign));
            ini["Alignment"].AddKey("WindowMenuButtonPosition", style.WindowMenuButtonPosition.ToString());
            ini["Alignment"].AddKey("ColorButtonPosition", style.ColorButtonPosition.ToString());
            ini["Alignment"].AddKey("ButtonTextAlign", ConvVec2(style.ButtonTextAlign));
            ini["Alignment"].AddKey("SelectableTextAlign", ConvVec2(style.SelectableTextAlign));

            //Safe area padding.
            ini["Safe Area Padding"].AddKey("SafeAreaPadding", ConvVec2(style.DisplaySafeAreaPadding));

            //Font.
            ini["Font"].AddKey("Name", Font);
            ini["Font"].AddKey("Size", FontSize.ToString());

            //Save INI.
            FileIniDataParser parser = new FileIniDataParser();

            parser.WriteFile("Res/Themes/" + themeName + ".ini", ini);
        }
Пример #7
0
        private static void RegisterURLHandler_Linux()
        {
            var parser = new FileIniDataParser();

            // Yes, 'Assigment' is the spelling used by the library.
            parser.Parser.Configuration.AssigmentSpacer = "";
            IniData data;

            log.InfoFormat("Trying to register URL handler");

            if (!File.Exists(MimeAppsListPath))
            {
                log.InfoFormat("{0} does not exist, trying to create it", MimeAppsListPath);
                File.WriteAllLines(MimeAppsListPath, new string[] { "[Default Applications]" });
            }

            try
            {
                data = parser.ReadFile(MimeAppsListPath);
            }
            catch (DirectoryNotFoundException ex)
            {
                log.InfoFormat("Skipping URL handler: {0}", ex.Message);
                return;
            }
            catch (FileNotFoundException ex)
            {
                log.InfoFormat("Skipping URL handler: {0}", ex.Message);
                return;
            }
            catch (ParsingException ex)
            {
                log.InfoFormat("Skipping URL handler: {0}", ex.Message);
                return;
            }

            if (data["Added Associations"] == null)
            {
                data.Sections.AddSection("Added Associations");
            }
            data["Added Associations"].RemoveKey("x-scheme-handler/ckan");
            data["Added Associations"].AddKey("x-scheme-handler/ckan", HandlerFileName);

            parser.WriteFile(MimeAppsListPath, data);

            var handlerPath      = Path.Combine(ApplicationsPath, HandlerFileName);
            var handlerDirectory = Path.GetDirectoryName(handlerPath);

            if (handlerDirectory == null || !Directory.Exists(handlerDirectory))
            {
                log.ErrorFormat("Error: {0} doesn't exist", handlerDirectory);
                return;
            }

            if (File.Exists(handlerPath))
            {
                File.Delete(handlerPath);
            }

            File.WriteAllText(handlerPath, "");
            data = parser.ReadFile(handlerPath);
            data.Sections.AddSection("Desktop Entry");
            data["Desktop Entry"].AddKey("Version", "1.0");
            data["Desktop Entry"].AddKey("Type", "Application");
            data["Desktop Entry"].AddKey("Exec", "mono \"" + System.Reflection.Assembly.GetExecutingAssembly().Location + "\" gui %u");
            data["Desktop Entry"].AddKey("Icon", "ckan");
            data["Desktop Entry"].AddKey("StartupNotify", "true");
            data["Desktop Entry"].AddKey("NoDisplay", "true");
            data["Desktop Entry"].AddKey("Terminal", "false");
            data["Desktop Entry"].AddKey("Categories", "Utility");
            data["Desktop Entry"].AddKey("MimeType", "x-scheme-handler/ckan");
            data["Desktop Entry"].AddKey("Name", "CKAN Launcher");
            data["Desktop Entry"].AddKey("Comment", "Launch CKAN");

            parser.WriteFile(handlerPath, data);
            AutoUpdate.SetExecutable(handlerPath);
        }
Пример #8
0
        public void ImportConfig(string gameId, string emulatorPath)
        {
            if (!(remoteIndex.SelectSingleNode($"//Config[GameIds/GameId = contains(., '{gameId}')]") is XmlElement configElement))
            {
                return;
            }
            var configDirectory = configElement.GetAttribute("Name");
            var configPath      = $"{remoteConfigsPath}\\Game Configs\\{configDirectory}";
            var configName      = Regex.Replace(configDirectory, "id#\\d+", "").Trim().ToLowerInvariant().Replace(" ", "-");
            var inisPath        = emulationService.GetInisPath(emulatorPath);

            var importedConfigPath = configurationService.CreateConfig(configName, inisPath, ConfigOptions.DefaultForRemote);

            // PCSX2_ui.ini
            var targetUiFile   = $"{importedConfigPath}\\{ConfiguratorConstants.UiFileName}";
            var targetUiConfig = iniParser.ReadFile(targetUiFile);
            var sourceUiConfig = new IniData();

            if (File.Exists($"{configPath}\\{ConfiguratorConstants.UiFileName}"))
            {
                MergeUiConfig(sourceUiConfig, iniParser.ReadFile($"{configPath}\\{ConfiguratorConstants.UiFileName}"));
            }
            if (File.Exists($"{configPath}\\pcsx2_ui-tweak.ini"))
            {
                MergeUiConfig(sourceUiConfig, iniParser.ReadFile($"{configPath}\\pcsx2_ui-tweak.ini"));
            }

            targetUiConfig.Merge(sourceUiConfig);
            iniParser.WriteFile(targetUiFile, targetUiConfig, Encoding.UTF8);

            // SPU2-X.ini
            var sourceSpu2xConfigFile = $"{configPath}\\{ConfiguratorConstants.Spu2xFileName}";

            if (File.Exists(sourceSpu2xConfigFile))
            {
                var targetSpu2xFile   = $"{importedConfigPath}\\{ConfiguratorConstants.Spu2xFileName}";
                var targetSpu2xConfig = File.Exists(targetSpu2xFile) ? iniParser.ReadFile(targetSpu2xFile) : new IniData();
                var sourceSpu2xConfig = iniParser.ReadFile(sourceSpu2xConfigFile);

                MergeSpu2xConfig(targetSpu2xConfig, sourceSpu2xConfig);
                iniParser.WriteFile(targetSpu2xFile, targetSpu2xConfig, Encoding.UTF8);
            }

            // PCSX2_vm.ini
            var sourceVmConfigFile = $"{configPath}\\{ConfiguratorConstants.VmFileName}";

            if (File.Exists(sourceVmConfigFile))
            {
                var targetVmFile   = $"{importedConfigPath}\\{ConfiguratorConstants.VmFileName}";
                var targetVmConfig = File.Exists(targetVmFile) ? iniParser.ReadFile(targetVmFile) : new IniData();
                var sourceVmConfig = iniParser.ReadFile(sourceVmConfigFile);

                MergeVmConfig(targetVmConfig, sourceVmConfig);
                iniParser.WriteFile(targetVmFile, targetVmConfig, Encoding.UTF8);
            }

            // GSdx.ini
            fileHelpers.CopyWithoutException($"{configPath}\\{ConfiguratorConstants.GsdxFileName}", $"{importedConfigPath}\\{ConfiguratorConstants.GsdxFileName}");

            // Cheats and Widescreen Patches
            foreach (var file in Directory.GetFiles(configPath, "*.pnach"))
            {
                var fileName    = Path.GetFileName(file);
                var destination = $"{Path.GetDirectoryName(emulatorPath)}\\" + (fileName.EndsWith("_ws.pnach") ? $"cheats_ws\\{fileName.Replace("_ws", "")}" : $"cheats\\{fileName}");
                File.Copy(file, destination, overwrite: true);
            }

            // Game Ids
            var gameIds = configElement.SelectNodes("GameIds/GameId").Cast <XmlNode>().Select(x => Regex.Match(x.InnerText, "[A-Z]{4}-[0-9]{5}").Value);

            if (gameIds.Count() > 0)
            {
                File.WriteAllText($"{importedConfigPath}\\gameids", string.Join(';', gameIds), Encoding.UTF8);
            }

            // Remote File
            var remoteJson = JsonConvert.SerializeObject(new { status = configElement.SelectSingleNode("Status")?.InnerText, notes = configElement.SelectSingleNode("Notes")?.InnerText });

            File.WriteAllText($"{importedConfigPath}\\remote", remoteJson, Encoding.UTF8);
        }
Пример #9
0
        public static void SetConfig(IniData config)
        {
            var parser = new FileIniDataParser();

            parser.WriteFile("config.ini", config);
        }
        private static void WriteUiConfigFile(string targetConfigDirectory, string baseUiFile, string targetUiFile, string settingsFile, string emulatorDirectory, IGame game)
        {
            Directory.CreateDirectory(targetConfigDirectory);
            var targetUiFileStream = File.CreateText(targetUiFile);

            targetUiFileStream.Write("[GeneralSettings]\r\n");
            targetUiFileStream.Dispose();

            var iniParser = new FileIniDataParser();


            var pluginSettings = iniParser.ReadFile(settingsFile)["PCSX2_Configurator"];
            var baseUiConfig   = iniParser.ReadFile(baseUiFile);
            var targetUiConfig = iniParser.ReadFile(targetUiFile);

            // If Program Log Settings Are To Be Imported From Base Config
            if (bool.Parse(pluginSettings["UseCurrentLogSettings"]))
            {
                // Copy Program Log Settings From Base Config To Target Config
                targetUiConfig["ProgramLog"].Merge(baseUiConfig["ProgramLog"]);
            }

            // If Folder Settings Are To Be Imported From Base Config
            if (bool.Parse(pluginSettings["UseCurrentFolderSettings"]))
            {
                // Copy Folders Settings From Base Config To Target Config
                targetUiConfig["Folders"].Merge(baseUiConfig["Folders"]);
            }

            // If File Settings Are To Be Imported From Base Config
            if (bool.Parse(pluginSettings["UseCurrentFileSettings"]))
            {
                // Copy File Names Settings From Base Config To Target Config
                targetUiConfig["Filenames"].Merge(baseUiConfig["Filenames"]);
            }

            // If Window Settings Are To Be Imported From Base Config
            if (bool.Parse(pluginSettings["UseCurrentWindowSettings"]))
            {
                // Copy GS Window Settings From Base Config To Target Config
                targetUiConfig["GSWindow"].Merge(baseUiConfig["GSWindow"]);
            }

            // If Independant Memory Cards Are To Be Used
            if (bool.Parse(pluginSettings["UseIndependantMemoryCards"]))
            {
                var memCardsDirectory = emulatorDirectory + "\\memcards";
                var memCardFile       = memCardsDirectory + "\\" + Utilities.GetSafeTitle(game).Replace(" ", "") + ".ps2";

                // Set One For This Game
                targetUiConfig["MemoryCards"]["Slot1_Enable"]   = "enabled";
                targetUiConfig["MemoryCards"]["Slot1_Filename"] = Path.GetFileName(memCardFile);

                // If It Doesn't Exist
                if (!File.Exists(memCardFile))
                {
                    var sevenZipProcess = new Process
                    {
                        StartInfo =
                        {
                            CreateNoWindow  = true,
                            UseShellExecute = false,
                            FileName        = Utilities.LaunchboxDirectory + "\\7-Zip\\7z.exe",
                            Arguments       = "e \"" + Utilities.PluginDirectory + "\\Assets\\Mcd.7z\" -o\"" + memCardsDirectory + "\""
                        }
                    };

                    // Extract a Newly Formatted Memory Card
                    sevenZipProcess.Start();
                    sevenZipProcess.WaitForExit();
                    File.Move(memCardsDirectory + "\\Mcd.ps2", memCardFile);
                }
            }

            // If All Settings Are To Be Enabled
            if (bool.Parse(pluginSettings["AllowAllSettings"]))
            {
                // Disable Presets, Enabled Game Fixes and Speed Hacks
                targetUiConfig["GeneralSettings"]["EnablePresets"]    = "disabled";
                targetUiConfig["GeneralSettings"]["EnableGameFixes"]  = "enabled";
                targetUiConfig["GeneralSettings"]["EnableSpeedHacks"] = "enabled";
            }

            // Sets Current Iso To This Game
            var isoPath = !Path.IsPathRooted(game.ApplicationPath)
                ? $"{Utilities.LaunchboxDirectory}\\{game.ApplicationPath}"
                : game.ApplicationPath;

            targetUiConfig["GeneralSettings"]["CurrentIso"] = isoPath.Replace("\\", "\\\\");
            targetUiConfig["GeneralSettings"]["AskOnBoot"]  = "disabled";

            // Saves Changes To File
            iniParser.WriteFile(targetUiFile, targetUiConfig);
        }
Пример #11
0
        public static void WriteFile(this IniData param, string path)
        {
            var fidp = new FileIniDataParser();

            fidp.WriteFile(path, param);
        }
Пример #12
0
        private static IMessageBase CheckMember(string id, MiraiHttpSession Session)
        {
            Logger.Instance.AddLog(LogType.Debug, "判断的部落ID为" + id);
            ICocCorePlayers players = BaseData.Instance.container.Resolve <ICocCorePlayers>();
            Player          player  = players.GetPlayer(id);

            if (player != null && string.IsNullOrEmpty(player.Reason))
            {
                StringBuilder sb = new StringBuilder();
                bool          troopFull = true, spellFull = true, heroFull = true;
                int           heroLvNeed = 0;
                var           troopsLV   = BaseData.GetTownhallTroopsLV(player.TownHallLevel - 1);
                sb.AppendLine("大本营等级:" + player.TownHallLevel + ",名字:" + player.Name);
                sb.AppendLine("兵力:");
                foreach (var troop in player.Troops)
                {
                    if (troop.Village != "home")
                    {
                        continue;
                    }
                    if (!troopsLV.Keys.Contains(troop.Name.Replace(" ", "_")))
                    {
                        for (int x = 1; x < BaseData.Instance.THLevels.Length; x++)
                        {
                            BaseData.Instance.thConfig[x.ToString() + "本"].AddKey(troop.Name.Replace(" ", "_"), troop.MaxLevel.ToString());
                        }
                        BaseData.Instance.config["兵种翻译"].AddKey(troop.Name.Replace(" ", "_"), troop.Name);
                        FileIniDataParser parser = new FileIniDataParser();
                        parser.WriteFile("Townhall.ini", BaseData.Instance.thConfig);
                        parser.WriteFile("config.ini", BaseData.Instance.config);
                        sb.AppendLine("* " + troop.Name + " 还缺" + (troop.MaxLevel - troop.Level) + "级 (Townhall.ini设置丢失,自动生成)");
                    }
                    else
                    {
                        if (troopsLV[troop.Name.Replace(" ", "_")] == 99)
                        {
                            BaseData.Instance.thConfig[player.TownHallLevel.ToString() + "本"][troop.Name.Replace(" ", "_")] = troop.MaxLevel.ToString();
                            FileIniDataParser parser = new FileIniDataParser();
                            parser.WriteFile("Townhall.ini", BaseData.Instance.thConfig);
                        }
                        if (troopsLV[troop.Name.Replace(" ", "_")] > troop.Level)
                        {
                            troopFull = false;
                            try
                            {
                                sb.AppendLine("* " + BaseData.Instance.config["兵种翻译"][troop.Name.Replace(" ", "_")] + " 还缺" + (troopsLV[troop.Name.Replace(" ", "_")] - troop.Level) + "级");
                            }
                            catch
                            {
                                sb.AppendLine("* " + troop.Name + " 还缺" + (troopsLV[troop.Name.Replace(" ", "_")] - troop.Level) + "级");
                            }
                        }
                    }
                }
                if (troopFull)
                {
                    sb.AppendLine("已满级");
                }
                sb.AppendLine("==================================");
                sb.AppendLine("药水:");
                foreach (var spell in player.Spells)
                {
                    if (!troopsLV.Keys.Contains(spell.Name.Replace(" ", "_")))
                    {
                        for (int x = 1; x < BaseData.Instance.THLevels.Length; x++)
                        {
                            BaseData.Instance.thConfig[x.ToString() + "本"].AddKey(spell.Name.Replace(" ", "_"), spell.MaxLevel.ToString());
                        }
                        BaseData.Instance.config["兵种翻译"].AddKey(spell.Name.Replace(" ", "_"), spell.Name);
                        FileIniDataParser parser = new FileIniDataParser();
                        parser.WriteFile("Townhall.ini", BaseData.Instance.thConfig);
                        parser.WriteFile("config.ini", BaseData.Instance.config);
                        sb.AppendLine("* " + spell.Name + " 还缺" + (spell.MaxLevel - spell.Level) + "级 (Townhall.ini设置丢失,自动生成)");
                    }
                    else
                    {
                        if (troopsLV[spell.Name.Replace(" ", "_")] == 99)
                        {
                            BaseData.Instance.thConfig[player.TownHallLevel + "本"][spell.Name.Replace(" ", "_")] = spell.MaxLevel.ToString();
                            FileIniDataParser parser = new FileIniDataParser();
                            parser.WriteFile("Townhall.ini", BaseData.Instance.thConfig);
                        }
                        if (troopsLV[spell.Name.Replace(" ", "_")] > spell.Level)
                        {
                            spellFull = false;
                            try
                            {
                                sb.AppendLine("* " + BaseData.Instance.config["兵种翻译"][spell.Name.Replace(" ", "_")] + " 还缺" + (troopsLV[spell.Name.Replace(" ", "_")] - spell.Level) + "级");
                            }
                            catch
                            {
                                sb.AppendLine("* " + spell.Name + " 还缺" + (troopsLV[spell.Name.Replace(" ", "_")] - spell.Level) + "级");
                            }
                        }
                    }
                }
                if (spellFull)
                {
                    sb.AppendLine("已满级");
                }
                if (player.Heroes.Count > 0)
                {
                    sb.AppendLine("==================================");
                    sb.AppendLine("英雄:");
                    foreach (var hero in player.Heroes)
                    {
                        if (hero.Village != "home")
                        {
                            continue;
                        }
                        if (!troopsLV.Keys.Contains(hero.Name.Replace(" ", "_")))
                        {
                            for (int x = 1; x < BaseData.Instance.THLevels.Length; x++)
                            {
                                BaseData.Instance.thConfig[x.ToString() + "本"].AddKey(hero.Name.Replace(" ", "_"), hero.MaxLevel.ToString());
                            }
                            BaseData.Instance.config["兵种翻译"].AddKey(hero.Name.Replace(" ", "_"), hero.Name);
                            FileIniDataParser parser = new FileIniDataParser();
                            parser.WriteFile("Townhall.ini", BaseData.Instance.thConfig);
                            parser.WriteFile("config.ini", BaseData.Instance.config);
                            sb.AppendLine("* " + hero.Name + " 还缺" + (hero.MaxLevel - hero.Level) + "级 (Townhall.ini设置丢失,自动生成)");
                        }
                        else
                        {
                            if (troopsLV[hero.Name.Replace(" ", "_")] == 99)
                            {
                                BaseData.Instance.thConfig[player.TownHallLevel + "本"][hero.Name.Replace(" ", "_")] = hero.MaxLevel.ToString();
                                FileIniDataParser parser = new FileIniDataParser();
                                parser.WriteFile("Townhall.ini", BaseData.Instance.thConfig);
                            }
                            if (troopsLV[hero.Name.Replace(" ", "_")] > hero.Level)
                            {
                                heroLvNeed += (troopsLV[hero.Name.Replace(" ", "_")] - hero.Level);
                                heroFull    = false;
                                try
                                {
                                    sb.AppendLine("* " + BaseData.Instance.config["兵种翻译"][hero.Name.Replace(" ", "_")] + " 还缺" + (troopsLV[hero.Name.Replace(" ", "_")] - hero.Level) + "级");
                                }
                                catch
                                {
                                    sb.AppendLine("* " + hero.Name + " 还缺" + (troopsLV[hero.Name.Replace(" ", "_")] - hero.Level) + "级");
                                }
                            }
                        }
                    }
                    if (heroFull)
                    {
                        sb.AppendLine("已满级");
                    }
                }
                if (sb.ToString().Split('\n').Length > 13 || heroLvNeed >= 10)
                {
                    sb.AppendLine("==================================");
                    sb.AppendLine("注意:严禁升本!否则将会被机票!");
                }
                if (!Directory.Exists("Buffer"))
                {
                    Directory.CreateDirectory("Buffer");
                }
                return(BaseData.TextToImg(sb.ToString(), Session));
            }
            else
            {
                if (player == null)
                {
                    return(new PlainMessage("未知的部落冲突ID,无法搜索该玩家资料!"));
                }
                else
                {
                    return(new PlainMessage("出现错误,请稍后再试!错误详情:" + player.Reason));
                }
            }
        }
Пример #13
0
        private static void SaveSettings()
        {
            var parser = new FileIniDataParser();

            parser.WriteFile("Settings.ini", settingsData);
        }
Пример #14
0
        public static bool LoadSettings()
        {
            if (!File.Exists("Configuration.ini"))
            {
                CreateSettings();
                return(false);
            }
            try
            {
                var     parser = new FileIniDataParser();
                IniData data   = parser.ReadFile("Configuration.ini");

                DriveLetter    = data["Satisfactory"]["DriveLetter"];
                FolderPath     = data["Satisfactory"]["FolderPath"];
                ProgramName    = data["Satisfactory"]["ProgramName"];
                SFSM_Installed = bool.Parse(data["Satisfactory"]["SFSM_Installed"]);
                SFSM_Port      = int.Parse(data["Satisfactory"]["SFSM_Port"]);
                try
                {
                    if (!Enum.TryParse <GameTypes>(data["Satisfactory"]["GameType"], true, out GameType))
                    {
                        GameType = GameTypes.DedicatedServer;
                    }
                } catch (Exception ex)
                {
                    GameType = GameTypes.DedicatedServer;
                }

                try
                {
                    if (!Enum.TryParse <StartLocations>(data["Session"]["StartLoc"], true, out StartLoc))
                    {
                        StartLoc = StartLocations.Grass_Fields;
                    }
                } catch (Exception ex)
                {
                    StartLoc = StartLocations.Grass_Fields;
                }
                WorldName     = data["Session"]["WorldName"];
                SaveName      = data["Session"]["SaveName"];
                AdminPassword = data["Session"]["AdminPassword"];

                MultiHome = bool.Parse(data["Network"]["MultiHome"]);
                LanOnly   = bool.Parse(data["Network"]["LanOnly"]);

                EnableAutoRestart          = bool.Parse(data["Timers"]["EnableAutoRestart"]);
                AutoRestartMinutesInterval = int.Parse(data["Timers"]["AutoRestartMinutesInterval"]);

                WebListenIP  = (data["Web"]["WebListenIP"]);
                WebPort      = int.Parse(data["Web"]["WebPort"]);
                AccessSecret = data["Web"]["AccessSecret"];

                parser.WriteFile("Configuration.ini", data);
            }
            catch (Exception ex)
            {
                //Crap, barf to console and stop.
                Console.WriteLine(ex);
                Program.Restart();
                CreateSettings();
                return(false);
            }

            return(true);
        }
Пример #15
0
 public static void save()
 {
     parser.WriteFile(dosyaAdi, data);
 }
Пример #16
0
        public static void WriteConfig()
        {
            var parser = new FileIniDataParser();

            parser.WriteFile("Config.ini", INI);
        }
Пример #17
0
 private void SaveGameServerButton_Click(object sender, EventArgs e)
 {
     _segatools["dns"]["default"]    = GameServerTextBox.Text;
     _segatools["keychip"]["subnet"] = SubnetTextBox.Text;
     _segatoolsIniParser.WriteFile("segatools.ini", _segatools, Encoding.Default);
 }
Пример #18
0
        private void Form1_Load(object sender, EventArgs e)
        {
            madHax.GUIConsoleWriter();
            madHax.readIP();
            var     parser = new FileIniDataParser();
            IniData data   = parser.ReadFile("Configuration.ini");

            #region Station Buttons

            station1.Text  = madHax.dynStationName(1);
            station2.Text  = madHax.dynStationName(2);
            station3.Text  = madHax.dynStationName(3);
            station4.Text  = madHax.dynStationName(4);
            station5.Text  = madHax.dynStationName(5);
            station6.Text  = madHax.dynStationName(6);
            station7.Text  = madHax.dynStationName(7);
            station8.Text  = madHax.dynStationName(8);
            station9.Text  = madHax.dynStationName(9);
            station10.Text = madHax.dynStationName(10);

            #region Station Button ToolTips

            toolTip1.SetToolTip(station1, madHax.dynStationTip(1));
            toolTip1.SetToolTip(station2, madHax.dynStationTip(2));
            toolTip1.SetToolTip(station3, madHax.dynStationTip(3));
            toolTip1.SetToolTip(station4, madHax.dynStationTip(4));
            toolTip1.SetToolTip(station5, madHax.dynStationTip(5));
            toolTip1.SetToolTip(station6, madHax.dynStationTip(6));
            toolTip1.SetToolTip(station7, madHax.dynStationTip(7));
            toolTip1.SetToolTip(station8, madHax.dynStationTip(8));
            toolTip1.SetToolTip(station9, madHax.dynStationTip(9));
            toolTip1.SetToolTip(station10, madHax.dynStationTip(10));

            #endregion Station Button ToolTips

            #endregion Station Buttons
            #region MiniPlayer Color
            try
            {
                checkBox1.Checked = Convert.ToBoolean(data["Config"]["Notifications"]);
            }
            catch
            {
                checkBox1.Checked = false;
            }

            foreach (PropertyInfo prop in typeof(Color).GetProperties())
            {
                if (prop.PropertyType.FullName == "System.Drawing.Color")
                {
                    comboBox1.Items.Add(prop.Name);
                }
            }
            if (comboBox1.Items.Contains(data["Config"]["MiniPlayerColor"]) == true)
            {
                comboBox1.SelectedItem = data["Config"]["MiniPlayerColor"];
            }
            else if (comboBox1.Items.Contains(data["Config"]["MiniPlayerColor"]) == true ||
                     data["Config"]["MiniPlayerColor"] == "" ||
                     data["Config"]["MiniPlayerColor"] == null)
            {
                comboBox1.SelectedItem            = "White";
                data["Config"]["MiniPlayerColor"] = "White";
                parser.WriteFile("Configuration.ini", data);
            }
            #endregion

            label1.Text = "Now Playing" + Environment.NewLine + madHax.SongInformation();
            SongTimer.RunWorkerAsync();
        }
Пример #19
0
 public void SaveIniFile()
 {
     _iniParser.WriteFile(ApplicationSettingsFilePath, _iniData);
 }
 /// <summary>
 /// Save settings to disk.
 /// </summary>
 public static void SaveSettings(Mod mod, IniData settings)
 {
     parser.WriteFile(SettingsPath(mod), settings);
 }
        private void Bfbc2_Launch_Click(object sender, RoutedEventArgs e)
        {
            FileIniDataParser Ini = new FileIniDataParser();

            // save config
            Properties.Settings.Default.BFBC2_LastGameDir    = Bfbc2_Path_Textbox.Text;
            Properties.Settings.Default.BFBC2_MasterServerIP = Bfbc2_MasterServerIP_Textbox.Text;
            Properties.Settings.Default.BFBC2_SkipIntro      = Convert.ToBoolean(Bfbc2_SkipIntro_CheckBox.IsChecked);
            Properties.Settings.Default.BFBC2_ModeKentang    = Convert.ToBoolean(Bfbc2_ModeKentang_CheckBox.IsChecked);
            Properties.Settings.Default.BFBC2_FOV            = Bfbc2_Fov_ComboBox.SelectedIndex;
            Properties.Settings.Default.BFBC2_Resolution     = Bfbc2_Resolusi_ComboBox.SelectedIndex;
            Properties.Settings.Default.Save();

            // set server ip
            IniData serverConfig = Ini.ReadFile(binFolderPath + "bfbc2.ini");

            serverConfig["info"]["host"]           = Bfbc2_MasterServerIP_Textbox.Text;
            serverConfig["client"]["reroute_http"] = "1";
            Ini.WriteFile(binFolderPath + "bfbc2.ini", serverConfig);

            // mode kentang
            if (Bfbc2_ModeKentang_CheckBox.IsChecked == true)
            {
                string pilihanResolusiWidth  = "800";
                string pilihanResolusiHeight = "600";

                if (!File.Exists(cfgFolderPath + @"\settings.ini"))
                {
                    Directory.CreateDirectory(cfgFolderPath);

                    var createConfig = File.Create(cfgFolderPath + @"\settings.ini");
                    createConfig.Close();
                }
                IniData config = Ini.ReadFile(cfgFolderPath + @"\settings.ini");

                switch (Bfbc2_Resolusi_ComboBox.Text)
                {
                case "800x600":
                    pilihanResolusiWidth  = "800";
                    pilihanResolusiHeight = "600";

                    break;

                case "1280x720":
                    pilihanResolusiWidth  = "1280";
                    pilihanResolusiHeight = "720";

                    break;

                case "1366x768":
                    pilihanResolusiWidth  = "1366";
                    pilihanResolusiHeight = "768";

                    break;
                }

                if (Convert.ToInt16(Bfbc2_Fov_ComboBox.Text) != 55)
                {
                    config["Graphics"]["Fov"] = Bfbc2_Fov_ComboBox.Text;
                }
                else
                {
                    config["Graphics"]["Fov"] = "55";
                }

                config["WindowSettings"]["Width"]      = pilihanResolusiWidth;
                config["WindowSettings"]["Height"]     = pilihanResolusiHeight;
                config["WindowSettings"]["Fullscreen"] = "true";
                config["WindowSettings"]["VSync"]      = "false";
                config["Sound"]["Quality"]             = "low";
                config["Graphics"]["Effects"]          = "low";
                config["Graphics"]["Vehicles"]         = "low";
                config["Graphics"]["Overgrowth"]       = "low";
                config["Graphics"]["Undergrowth"]      = "low";
                config["Graphics"]["StaticObjects"]    = "low";
                config["Graphics"]["Terrain"]          = "low";
                config["Graphics"]["Shadows"]          = "low";
                config["Graphics"]["Bloom"]            = "false";
                config["Graphics"]["HSAO"]             = "false";
                config["Graphics"]["MSAA"]             = "0";
                config["Graphics"]["Water"]            = "low";
                config["Graphics"]["MainQuality"]      = "custom";
                config["Graphics"]["Texture"]          = "low";
                config["Graphics"]["DxVersion"]        = "9";
                config["Graphics"]["Aniso"]            = "0";
                config["Graphics"]["Detail"]           = "low";
                config["Graphics"]["RenderAheadLimit"] = "0";

                Ini.WriteFile(cfgFolderPath + @"\settings.ini", config);
            }

            Function.RunExe(dir: binFolderPath, filename: "BFBC2Game.exe", param: "");
            this.Close();
        }
Пример #22
0
 public void Write(string Key, string Value)
 {
     Data[EXE][Key] = Value;
     Parser.WriteFile(Path, Data);
 }
Пример #23
0
        /// <summary>
        /// 读取流媒体配置文件中关键信息
        /// </summary>
        private static void getMediaServerConfig()
        {
            string  iniPath = checkMediaServerConfig();
            var     parser  = new FileIniDataParser();
            IniData data    = parser.ReadFile(iniPath);
            var     _tmpStr = data["general"]["mediaServerId"];

            if (!string.IsNullOrEmpty(_tmpStr))
            {
                MediaServerId = _tmpStr.Trim();
            }
            else
            {
                //生成一个id
                data["general"]["mediaServerId"] = generalGuid();
                MediaServerId = data["general"]["mediaServerId"];
                parser.WriteFile(iniPath, data);
            }

            _tmpStr = data["http"]["port"];
            if (string.IsNullOrEmpty(_tmpStr))
            {
                data["http"]["port"] = "8818";
                MediaServerHttpPort  = 8818;
                parser.WriteFile(iniPath, data);
            }
            else
            {
                MediaServerHttpPort = ushort.Parse(_tmpStr);
            }

            _tmpStr = data["api"]["secret"];
            if (!string.IsNullOrEmpty(_tmpStr))
            {
                Secret = _tmpStr;
            }
            else
            {
                throw new DataException();
            }

            Uri streamNodeUri = new Uri(StreamNodeServerUrl);

            data["hook"]["enable"]         = "1";
            data["hook"]["on_flow_report"] =
                "http://" + streamNodeUri.Host + ":" + streamNodeUri.Port +
                "/WebHook/OnStop";                                                                           //流量统计,断开连接时超过flowThreshold值时会触发
            data["hook"]["on_http_access"] = "";                                                             //http事件,不作支持
            data["hook"]["on_play"]        =
                "http://" + streamNodeUri.Host + ":" + streamNodeUri.Port + "/WebHook/OnPlay";               //有流被客户端播放时
            data["hook"]["on_publish"] =
                "http://" + streamNodeUri.Host + ":" + streamNodeUri.Port + "/WebHook/OnPublish";            //有流发布时
            data["hook"]["on_record_mp4"] =
                "http://" + streamNodeUri.Host + ":" + streamNodeUri.Port + "/WebHook/OnRecordMp4Completed"; //当录制mp4完成时
            data["hook"]["on_record_ts"] =
                "http://" + streamNodeUri.Host + ":" + streamNodeUri.Port + "/WebHook/OnRecordTsCompleted";  //当录制ts完成时
            data["hook"]["on_rtsp_auth"]      = "";                                                          //rtsp鉴权,不作支持
            data["hook"]["on_rtsp_realm"]     = "";                                                          //rtsp专用鉴权,不作支持
            data["hook"]["on_shell_login"]    = "";                                                          //shell鉴权,不作支持
            data["hook"]["on_stream_changed"] =
                "http://" + streamNodeUri.Host + ":" + streamNodeUri.Port + "/WebHook/OnStreamChange";       //流注册或注销时
            data["hook"]["on_stream_none_reader"] =
                "http://" + streamNodeUri.Host + ":" + streamNodeUri.Port + "/WebHook/OnStreamNoneReader";   //流无人观看时
            data["hook"]["on_stream_not_found"] = "";                                                        //请求没有找到对应流的时候,不作支持
            data["hook"]["on_server_started"]   = "http://" + streamNodeUri.Host + ":" + streamNodeUri.Port +
                                                  "/WebHook/OnMediaServerStart";                             //当流媒体启动时
            data["hook"]["timeoutSec"]       = "5";                                                          //httpclient超时时间5秒
            data["general"]["flowThreshold"] = "1";                                                          //当用户超过1byte流量时,将触发on_flow_report的webhook(/WebHook/OnStop)

            parser.WriteFile(iniPath, data);
        }
Пример #24
0
        public Configuration()
        {
            DB["Host"]          = "127.0.0.1";
            DB["Database"]      = "trickemu";
            DB["Username"]      = "******";
            DB["Password"]      = "******";
            Server["LoginPort"] = "9980";

            Server["ChannelIP"]   = "127.0.0.1";
            Server["ChannelPort"] = "10006";

            Server["GameIP"]   = "127.0.0.1";
            Server["GamePort"] = "22006";

            Server["SystemIP"]      = "127.0.0.1";
            Server["SystemPort"]    = "13336";
            Server["SystemEnabled"] = "0";

            var parser = new FileIniDataParser();

            try
            {
                data = parser.ReadFile("config.ini");

                DB["Host"]     = data["DB"]["Host"];
                DB["Database"] = data["DB"]["Database"];
                DB["Username"] = data["DB"]["Username"];
                DB["Password"] = data["DB"]["Password"];

                Server["LoginPort"] = data["Login"]["Port"];

                Server["ChannelIP"]   = data["Channel"]["IP"];
                Server["ChannelPort"] = data["Channel"]["Port"];

                Server["GameIP"]   = data["Game"]["IP"];
                Server["GamePort"] = data["Game"]["Port"];

                Server["SystemIP"] = data["System"]["IP"];

                try
                {
                    // validate port
                    Server["SystemPort"] = ushort.Parse(data["System"]["Port"]).ToString();
                }
                catch { }

                Server["SystemEnabled"] = data["System"]["Enabled"];
            }
            catch
            {
                data = new IniData();
                data.Sections.AddSection("DB");

                data["DB"]["Host"]     = "127.0.0.1";
                data["DB"]["Database"] = "trickemu";
                data["DB"]["Username"] = "******";
                data["DB"]["Password"] = "******";

                data.Sections.AddSection("Login");
                data["Login"]["Port"] = "9980";

                data.Sections.AddSection("Channel");
                data["Channel"]["IP"]   = "127.0.0.1";
                data["Channel"]["Port"] = "10006";

                data.Sections.AddSection("Game");
                data["Game"]["IP"]   = "127.0.0.1";
                data["Game"]["Port"] = "22006";

                data.Sections.AddSection("System");
                data["System"]["IP"]      = "127.0.0.1";
                data["System"]["Port"]    = "13336";
                data["System"]["Enabled"] = "0";

                parser.WriteFile("config.ini", data);
            }
        }
Пример #25
0
 public void SaveConfig()
 {
     cfgParser.WriteFile(AppSettings.Cfg.FilePath, cfgData);
 }
Пример #26
0
        private static void RegisterURLHandler_Linux()
        {
            var     parser = new FileIniDataParser();
            IniData data   = null;

            log.InfoFormat("Trying to register URL handler");

            try
            {
                data = parser.ReadFile(MimeAppsListPath); //();
            }
            catch (DirectoryNotFoundException ex)
            {
                log.ErrorFormat("Error: {0}", ex.Message);
                return;
            }
            catch (FileNotFoundException ex)
            {
                log.ErrorFormat("Error: {0}", ex.Message);
                return;
            }
            catch (ParsingException ex)
            {
                log.ErrorFormat("Error: {0}", ex.Message);
                return;
            }

            data["Added Associations"].RemoveKey("x-scheme-handler/ckan");
            data["Added Associations"].AddKey("x-scheme-handler/ckan", HandlerFileName);

            parser.WriteFile(MimeAppsListPath, data);

            var handlerPath      = Path.Combine(ApplicationsPath, HandlerFileName);
            var handlerDirectory = Path.GetDirectoryName(handlerPath);

            if (handlerDirectory == null || !Directory.Exists(handlerDirectory))
            {
                log.ErrorFormat("Error: {0} doesn't exist", handlerDirectory);
                return;
            }

            if (File.Exists(handlerPath))
            {
                File.Delete(handlerPath);
            }

            File.WriteAllText(handlerPath, "");
            data = parser.ReadFile(handlerPath);
            data.Sections.AddSection("Desktop Entry");
            data["Desktop Entry"].AddKey("Version", "1.0");
            data["Desktop Entry"].AddKey("Type", "Application");
            data["Desktop Entry"].AddKey("Exec", System.Reflection.Assembly.GetExecutingAssembly().Location + " gui %u");
            data["Desktop Entry"].AddKey("Icon", "ckan");
            data["Desktop Entry"].AddKey("StartupNotify", "true");
            data["Desktop Entry"].AddKey("Terminal", "false");
            data["Desktop Entry"].AddKey("Categories", "Utility");
            data["Desktop Entry"].AddKey("MimeType", "x-scheme-handler/ckan");
            data["Desktop Entry"].AddKey("Name", "CKAN Launcher");
            data["Desktop Entry"].AddKey("Comment", "Launch CKAN");

            parser.WriteFile(handlerPath, data);
        }
Пример #27
0
 /// <summary>
 /// Saves the current config data as represented in this GadgetConfig instance to the config file. Destroys any changes to the file made before a call to <see cref="Load"/>.
 /// </summary>
 public void Save()
 {
     configParser.WriteFile(configFile, configFiles[configFile], Encoding.UTF8);
 }
Пример #28
0
 public void Save()
 {
     parser.WriteFile(dosyaAdi, data);
 }
Пример #29
0
        static async Task Main(string[] args)
        {
            string key = null;

            if (args.Length > 0)
            {
                key = args[0];
            }
            long qqId = -1;

            if (args.Length > 1)
            {
                qqId = Convert.ToInt64(args[1]);
            }
            try
            {
                Logger.Instance.AddLog(LogType.Info, "正在加载...");
                FileIniDataParser parse = new FileIniDataParser();
                if (!File.Exists("config.ini"))
                {
                    BaseData.Instance.config = new IniData();
                    foreach (var section in (configType[])Enum.GetValues(typeof(configType)))
                    {
                        BaseData.Instance.config.Sections.AddSection(section.ToString());
                    }
                    BaseData.InitFirstUse();
                    parse.WriteFile("config.ini", BaseData.Instance.config, Encoding.Unicode);
                }
                BaseData.LoadCOCData();
                Logger.Instance.AddLog(LogType.Info, "已加载" + BaseData.Instance.config.Sections.Count + "区域");
                if (BaseData.Instance.checkClanWar != null)
                {
                    BaseData.Instance.checkClanWar.Abort();
                    BaseData.Instance.checkClanWar = null;
                }
                BaseData.ReadGameData();
            }
            catch (Exception ex)
            {
                Logger.Instance.AddLog(LogType.Error, ex.Message);
            }
            if (key == null)
            {
                if (!BaseData.valuePairs(configType.部落冲突).TryGetValue("AuthKey", out key))
                {
                    Logger.Instance.AddLog(LogType.Error, "法找到可使用的AuthKey! 请在config.ini的部落冲突栏位添加AuthKey = 相应的AuthKey!");
                    Console.ReadLine();
                    return;
                }
            }
            if (qqId == -1)
            {
                if (!BaseData.valuePairs(configType.部落冲突).TryGetValue("QQ号", out string qqString))
                {
                    Logger.Instance.AddLog(LogType.Error, "无法找到可使用的QQ号! 请在config.ini的部落冲突栏位添加QQ号 = 相应的QQ号!");
                    Console.ReadLine();
                    return;
                }
                if (!long.TryParse(qqString, out qqId))
                {
                    Logger.Instance.AddLog(LogType.Error, "QQ号不正确!请确保QQ号只有纯数字!");
                    Console.ReadLine();
                    return;
                }
            }
            LoggedInQQ = qqId;
            AppDomain.CurrentDomain.ProcessExit += CurrentDomain_ProcessExit;
Loop:
            try
            {
                MiraiHttpSessionOptions options = new MiraiHttpSessionOptions("127.0.0.1", 8080, key);
                await using var session        = new MiraiHttpSession();
                BaseData.Instance.checkClanWar = new Thread(new Threading(session).CheckClanWar)
                {
                    IsBackground = true
                };
                BaseData.Instance.checkClanWar.Start();
                session.AddPlugin(new GroupMessageHandler());
                session.AddPlugin(new GroupRequestHandler());
                session.AddPlugin(new GroupExitHandler());
                Logger.Instance.AddLog(LogType.Info, "创建Event监听成功!");
Retry:
                try
                {
                    await session.ConnectAsync(options, qqId, true);
                }
                catch
                {
                    goto Retry;
                }
                Logger.Instance.AddLog(LogType.Info, "监听开始!");
                do
                {
                    var input = Console.ReadLine();
                    switch (input)
                    {
                    case "/D":
                        if (!Directory.Exists("apk"))
                        {
                            Directory.CreateDirectory("apk");
                            Logger.Instance.AddLog(LogType.Info, "把部落冲突APK文件放到这个文件夹内后再输入/D");
                            Process.Start("explorer.exe", Path.Combine(Environment.CurrentDirectory, "apk"));
                            break;
                        }
                        else
                        {
                            foreach (var f in Directory.GetFiles("apk", "*.*", SearchOption.AllDirectories))
                            {
                                if (!f.EndsWith(".apk"))
                                {
                                    File.Delete(f);
                                }
                            }
                        }
                        var files = Directory.GetFiles("apk", "*.apk", SearchOption.TopDirectoryOnly);
                        Array.Sort(files, StringComparer.OrdinalIgnoreCase);
                        var file = files.Last();
                        var zip  = file.Replace(".apk", ".zip");
                        File.Copy(file, zip);
                        ZipArchive zipFile = ZipFile.OpenRead(zip);
                        zipFile.ExtractToDirectory(Path.Combine(Environment.CurrentDirectory, "apk"));
                        foreach (var f in Directory.GetFiles("apk", "*.csv", SearchOption.AllDirectories))
                        {
                            File.WriteAllBytes(f, SCDecompress.Decompress(f));
                            if (f.EndsWith("buildings.csv") || f.EndsWith("characters.csv") || f.EndsWith("heros.csv") || f.EndsWith("spells.csv") || f.EndsWith("texts.csv"))
                            {
                                var local = Path.Combine(Environment.CurrentDirectory, f.Split('\\').Last());
                                if (File.Exists(local))
                                {
                                    File.Delete(local);
                                }
                                File.Copy(f, local);
                            }
                        }
                        FileIniDataParser parser = new FileIniDataParser();
                        BaseData.UpdateTownhallINI(parser);
                        BaseData.UpdateTranslate(parser);
                        BaseData.Instance.chains.Clear();
                        BaseData.Instance.checkClanWar.Abort();
                        BaseData.Instance.config = null;
                        GC.Collect();
                        BaseData.LoadCOCData();
                        break;
                    }
                }while (true);
            }
            catch (Exception ex)
            {
                Logger.Instance.AddLog(LogType.Error, ex.ToString());
                goto Loop;
            }
        }
Пример #30
0
        private async void Connect()
        {
            try
            {
                ConnectCommand.Executable = false;

                if (string.IsNullOrWhiteSpace(ConsensusServerNetworkAddress))
                {
                    MessageBox.Show("Network address is required");
                    return;
                }
                if (string.IsNullOrWhiteSpace(ConsensusServerRpcUsername))
                {
                    MessageBox.Show("RPC username is required");
                    return;
                }
                if (ConsensusServerRpcPassword.Length == 0)
                {
                    MessageBox.Show("RPC password may not be empty");
                    return;
                }
                if (!File.Exists(ConsensusServerCertificateFile))
                {
                    MessageBox.Show("Certificate file not found");
                    return;
                }

                var rpcOptions = new ConsensusServerRpcOptions(ConsensusServerNetworkAddress,
                                                               ConsensusServerRpcUsername, ConsensusServerRpcPassword, ConsensusServerCertificateFile);
                try
                {
                    await App.Current.Synchronizer.WalletRpcClient.StartConsensusRpc(rpcOptions);
                }
                catch (Exception ex) when(ErrorHandling.IsTransient(ex) || ErrorHandling.IsClientError(ex))
                {
                    MessageBox.Show($"Unable to start {ConsensusServerRpcOptions.ApplicationName} RPC.\n\nCheck connection settings and try again.", "Error");
                    return;
                }

                await Task.Run(() =>
                {
                    // save defaults to a file so that the user doesn't have to type this information again
                    var ini = new IniData();
                    ini.Sections.AddSection("Application Options");
                    ini["Application Options"]["rpcuser"]   = ConsensusServerRpcUsername;
                    ini["Application Options"]["rpcpass"]   = ConsensusServerRpcPassword;
                    ini["Application Options"]["rpclisten"] = ConsensusServerNetworkAddress;
                    var appDataDir = Portability.LocalAppData(Environment.OSVersion.Platform,
                                                              AssemblyResources.Organization, AssemblyResources.ProductName);
                    var parser = new FileIniDataParser();
                    parser.WriteFile(Path.Combine(appDataDir, "defaults.ini"), ini);
                });

                var walletExists = await App.Current.Synchronizer.WalletRpcClient.WalletExistsAsync();

                if (!walletExists)
                {
                    _wizard.CurrentDialog = new CreateOrImportSeedDialog(Wizard);
                }
                else
                {
                    // TODO: Determine whether the public encryption is enabled and a prompt for the
                    // public passphrase prompt is needed before the wallet can be opened.  If it
                    // does not, then the wallet can be opened directly here instead of creating
                    // another dialog.
                    _wizard.CurrentDialog = new PromptPublicPassphraseDialog(Wizard);

                    //await _walletClient.OpenWallet("public");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error");
            }
            finally
            {
                ConnectCommand.Executable = true;
            }
        }