private void ReadProfiles(string appDataDirectory)
        {
            string text = Path.Combine(appDataDirectory, "profiles.ini");

            if (File.Exists(text))
            {
                IniFileReader iniFileReader = new IniFileReader(text);
                ReadOnlyCollection <string> sectionNames = iniFileReader.SectionNames;
                foreach (string current in sectionNames)
                {
                    if (current.StartsWith("profile", StringComparison.OrdinalIgnoreCase))
                    {
                        string value  = iniFileReader.GetValue(current, "name");
                        bool   flag   = iniFileReader.GetValue(current, "isrelative") == "1";
                        string value2 = iniFileReader.GetValue(current, "path");
                        string value3 = string.Empty;
                        if (flag)
                        {
                            value3 = Path.Combine(appDataDirectory, value2);
                        }
                        else
                        {
                            value3 = value2;
                        }
                        this.profiles.Add(value, value3);
                    }
                }
            }
        }
Exemplo n.º 2
0
        public SkillParser()
        {
            IniFileReader       reader         = new IniFileReader("C:\\Documents and Settings\\Josh\\Desktop\\cskill_t.ini");
            IniFileSectionStart skillList      = reader.GotoSection("All Skills");
            List <IniFileValue> skillListNames = reader.ReadSectionValues();

            foreach (IniFileValue r in skillListNames)
            {
                skill_id = int.Parse(r.Key.ToString());
                String parsedName = r.Value.ToString();
                skill_name = parsedName.Replace("'", "\\'");

                IniFileReader       reader2     = new IniFileReader("C:\\Documents and Settings\\Josh\\Desktop\\cskill_t.ini");
                IniFileSectionStart skills      = reader2.GotoSection(skill_name);
                List <IniFileValue> skillvalues = reader2.ReadSectionValues();

                foreach (IniFileValue r2 in skillvalues)
                {
                    valueLookup(skills, r2);
                }

                insertIntoDB();

                reader2.Close();
            }

            reader.Close();

            Console.Out.WriteLine("***** Finished *****");
        }
        private void ReadProfiles(string appDataDirectory)
        {
            string profilesIniFile = Path.Combine(appDataDirectory, "profiles.ini");

            if (File.Exists(profilesIniFile))
            {
                IniFileReader reader = new IniFileReader(profilesIniFile);
                ReadOnlyCollection <string> sectionNames = reader.SectionNames;
                foreach (string sectionName in sectionNames)
                {
                    if (sectionName.StartsWith("profile", StringComparison.OrdinalIgnoreCase))
                    {
                        string name        = reader.GetValue(sectionName, "name");
                        bool   isRelative  = reader.GetValue(sectionName, "isrelative") == "1";
                        string profilePath = reader.GetValue(sectionName, "path");
                        string fullPath    = string.Empty;
                        if (isRelative)
                        {
                            fullPath = Path.Combine(appDataDirectory, profilePath);
                        }
                        else
                        {
                            fullPath = profilePath;
                        }

                        this.profiles.Add(name, fullPath);
                    }
                }
            }
        }
Exemplo n.º 4
0
        protected override void HandleFile(string file)
        {
            MemoryStream iniStream = fileStreams[file];
            Dictionary <string, string> itemFields   = new Dictionary <string, string>();
            Dictionary <string, string> playerFields = new Dictionary <string, string>();

            IniFileReader reader  = new IniFileReader(iniStream);
            IniFile       iniFile = IniFile.FromStream(reader);

            string internalName    = $"{modName}:{Path.GetFileNameWithoutExtension(file).RemoveIllegalCharacters()}";
            bool   addToSuffixBag  = false;
            string name            = null;
            string requirementType = null;
            string weight          = null;

            foreach (IniFileSection section in iniFile.sections)
            {
                foreach (IniFileElement element in section.elements)
                {
                    var splitElement = element.Content.Split('=');

                    switch (section.Name)
                    {
                    case "Stats": {
                        switch (splitElement[0])
                        {
                        case "name": {
                            name = splitElement[1];
                            continue;
                        }

                        case "suffix" when splitElement[1] == "True": {
                            addToSuffixBag = true;
                            continue;
                        }
Exemplo n.º 5
0
        /// <summary>
        /// Lee un valor de un xml como un ini
        /// </summary>
        /// <param name="nameXml">Nombre del xml</param>
        /// <param name="seccion">Seccion</param>
        /// <param name="key">key</param>
        /// <returns></returns>
        public static string LeeConfiguracion(string nameXml, string seccion, string key)
        {
            string        fileIniLoc;
            IniFileReader loc;
            IniFileReader red;
            bool          exsRd = false;


            fileIniLoc = string.IsNullOrEmpty(nameXml) ? NameXML : nameXml;
            apl.Log.LogDebug.Escribe(String.Format("Lee configuracion: s:{0}, k:{1}, f:{2}",
                                                   seccion, key, fileIniLoc));
            if (File.Exists(fileIniLoc))
            {
                string pathRed    = LeeConfiguracionOld(nameXml, seccion, "Red");
                string fileIniRed = string.IsNullOrEmpty(nameXml)
                    ? Path.Combine(pathRed ?? string.Empty, Path.GetFileName(NameXML))
                    : Path.Combine(pathRed, nameXml);
                exsRd = File.Exists(fileIniRed);

                red = new IniFileReader(fileIniRed, true);
                loc = new IniFileReader(fileIniLoc, true);

                string valR = exsRd ? red.GetIniValue(seccion, key) : string.Empty;
                string valL = loc.GetIniValue(seccion, key);
                return(!string.IsNullOrEmpty(valL) ? valL : valR);
            }
            return(string.Empty);
        }
Exemplo n.º 6
0
        public EffectsParser(int start, int end)
        {
            for (int i = start; i < end; i++)
            {
                try
                {
                    IniFileReader       reader = new IniFileReader("C:\\Documents and Settings\\Josh\\Desktop\\effect.ini");
                    IniFileSectionStart test   = reader.GotoSection("EFFECT-" + i);
                    List <IniFileValue> test2  = reader.ReadSectionValues();

                    //Console.Out.WriteLine(test.SectionName);
                    foreach (IniFileValue r in test2)
                    {
                        sectionLookup(test, r);
                    }

                    int effectID = int.Parse(test.SectionName.Replace("EFFECT-", ""));

                    String query = "INSERT INTO effects SET effect_id='" + effectID + "', effect_class='" + effectClass + "', descriiption='" + description + "', " +
                                   "start_link_id='" + startLinkID + "', next_link_id='" + nextLinkID + "', base_asset_id='" + baseAssetID + "', " +
                                   "sound_fx_file='" + soundFxFile + "';";

                    DataTable effectInsert = Database.executeQuery(Database.DatabaseName.net7, query);
                    Console.Out.WriteLine(query);
                    reader.Close();
                }
                catch (Exception e)
                {
                    //Console.Out.WriteLine(e+", "+ e.Message);
                    //throw;
                }
            }

            Console.Out.WriteLine("***** Finished *****");
        }
        public BuffParser(int start, int end)
        {
            for (int i = start; i < end; i++)
            {
                try
                {
                    IniFileReader       reader = new IniFileReader("C:\\Documents and Settings\\Josh\\Desktop\\buffdef.ini");
                    IniFileSectionStart test   = reader.GotoSection("BUFF-" + i);
                    List <IniFileValue> test2  = reader.ReadSectionValues();

                    foreach (IniFileValue r in test2)
                    {
                        valueLookup(test, r);
                    }

                    id = int.Parse(test.SectionName.Replace("BUFF-", ""));

                    String query = "INSERT INTO buffs SET buff_id='" + id + "', type='" + type + "', " +
                                   "asset_name='" + asset_name + "', asset_id='" + asset_id + "', tooltip='" + tooltip + "', " +
                                   "alt_tooltip='" + alt_tooltip + "', is_good_buff='" + is_good_buff + "';";

                    DataTable buffInsert = Database.executeQuery(Database.DatabaseName.net7, query);
                    Console.Out.WriteLine(query);
                    reader.Close();
                }
                catch (Exception e)
                {
                    //Console.Out.WriteLine(e+", "+ e.Message);
                    //throw;
                }
            }

            Console.Out.WriteLine("***** Finished *****");
        }
        public static Dictionary <string, string> GetProfiles()
        {
            var profiles         = new Dictionary <string, string>();
            var userDir          = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
            var appDataDirectory = Path.Combine(userDir, "Mozilla", "Firefox");
            var profilesIniFile  = Path.Combine(appDataDirectory, "profiles.ini");

            if (File.Exists(profilesIniFile))
            {
                var reader       = new IniFileReader(profilesIniFile);
                var sectionNames = reader.SectionNames;
                foreach (var sectionName in sectionNames)
                {
                    if (sectionName.StartsWith("profile", StringComparison.OrdinalIgnoreCase))
                    {
                        var name        = reader.GetValue(sectionName, "name");
                        var isRelative  = reader.GetValue(sectionName, "isrelative") == "1";
                        var profilePath = reader.GetValue(sectionName, "path");
                        var fullPath    = string.Empty;
                        if (isRelative)
                        {
                            fullPath = Path.Combine(appDataDirectory, profilePath);
                        }
                        else
                        {
                            fullPath = profilePath;
                        }

                        profiles.Add(name, fullPath);
                    }
                }
            }
            return(profiles);
        }
Exemplo n.º 9
0
        private string GetInformationOfIniFile(string filePath)
        {
            IniFileReader ifd = new IniFileReader(filePath);

            return("Data Source=" + ifd.IniReadValue("Database", "RCM_V2").Split(',')[0] +
                   ";Initial Catalog=" + ifd.IniReadValue("Database", "RCM_V2").Split(',')[1] +
                   ";Persist Security Info=True;User ID=" + ifd.IniReadValue("Database", "RCM_V2").Split(',')[2] +
                   ";Password="******"Database", "RCM_V2").Split(',')[3] +
                   ";");
        }
        /// <summary>
        /// load from properties file
        /// </summary>
        /// <param name="propsFilePath">
        ///         properties file path, eg:
        ///                      "fastdfs-client.properties"
        ///                      "config/fastdfs-client.properties"
        ///                      "/opt/fastdfs-client.properties"
        ///                      "C:\\Users\\James\\config\\fastdfs-client.properties"
        ///                      properties文件至少包含一个配置项 fastdfs.tracker_servers 例如:
        ///                      fastdfs.tracker_servers = 10.0.11.245:22122,10.0.11.246:22122
        ///                      server的IP和端口用冒号':'分隔
        ///                      server之间用逗号','分隔
        /// </param>
        public static void initByProperties(string propsFilePath)
        {
            Properties props  = new Properties();
            Stream     stream = IniFileReader.loadFromOsFileSystemOrClasspathAsStream(propsFilePath);

            if (stream != null)
            {
                props.load(stream);
            }
            initByProperties(props);
        }
Exemplo n.º 11
0
        public static string LeeConfiguracionOld(string nameXml, string seccion, string key)
        {
            string        fileIni;
            IniFileReader ini;

            apl.Log.LogDebug.Escribe(String.Format("Lee configuracion: {0}, {1}", seccion, key));

            fileIni = string.IsNullOrEmpty(nameXml) ? NameXML : nameXml;
            if (File.Exists(fileIni))
            {
                ini = new IniFileReader(fileIni, true);

                return(ini.GetIniValue(seccion, key));
            }
            return(string.Empty);
        }
Exemplo n.º 12
0
        /// <summary>
        /// Guarda la configuracion en el xml
        /// </summary>
        /// <param name="nameXml"></param>
        /// <param name="seccion"></param>
        /// <param name="key"></param>
        /// <param name="value"></param>
        public static void GuardaConfiguracion(string nameXml, string seccion, string key, string value)
        {
            try
            {
                string        fileIni;
                IniFileReader ini;

                fileIni = string.IsNullOrEmpty(nameXml) ? NameXML : nameXml;
                ini     = new IniFileReader(fileIni, true);

                ini.OutputFilename = fileIni;
                ini.SetIniValue(seccion, key, value);
                ini.Save();
                apl.Log.LogDebug.Escribe("Guarda configuracion");
            }
            catch (Exception ex)
            {
                apl.Log.LogDebug.Escribe("No pude guardar configuracion" + ex.Message);
            }
        }
        public static void main(string[] args)
        {
            string        conf_filename = "fdfs_client.conf";
            IniFileReader iniFileReader = new IniFileReader(conf_filename);

            Console.WriteLine("getConfFilename: " + iniFileReader.getConfFilename());
            Console.WriteLine("connect_timeout: " + iniFileReader.getIntValue("connect_timeout", 3));
            Console.WriteLine("network_timeout: " + iniFileReader.getIntValue("network_timeout", 45));
            Console.WriteLine("charset: " + iniFileReader.getStrValue("charset"));
            Console.WriteLine("http.tracker_http_port: " + iniFileReader.getIntValue("http.tracker_http_port", 8080));
            Console.WriteLine("http.anti_steal_token: " + iniFileReader.getBoolValue("http.anti_steal_token", false));
            Console.WriteLine("http.secret_key: " + iniFileReader.getStrValue("http.secret_key"));
            string[] tracker_servers = iniFileReader.getValues("tracker_server");
            if (tracker_servers != null)
            {
                Console.WriteLine("tracker_servers.Length: " + tracker_servers.Length);
                for (int i = 0; i < tracker_servers.Length; i++)
                {
                    Console.WriteLine(string.Format("tracker_servers[%s]: %s", i, tracker_servers[i]));
                }
            }
        }
Exemplo n.º 14
0
        private void loadIni()
        {
            File file = new File(iniFile);

            ini = new BasicIniFile();

            IniFileReader reader = new IniFileReader(ini, file);

            try
            {
                reader.read();
            }
            catch (FormatException e)
            {
                // e.printStackTrace();
            }
            catch (IOException e)
            {
                // e.printStackTrace();
            }
            initSettingsSection();
        }
        public BaseAssetParser()
        {
            for (int i = 0; i < 2411; i++)
            {
                rslid = -1;
                try
                {
                    IniFileReader       reader = new IniFileReader("C:\\Documents and Settings\\Josh\\Desktop\\basset.ini");
                    IniFileSectionStart test   = reader.GotoSection("BASE-" + i);
                    List <IniFileValue> test2  = reader.ReadSectionValues();

                    foreach (IniFileValue r in test2)
                    {
                        if (r.Key == "RSLID")
                        {
                            rslid = int.Parse(r.Value.ToString());
                        }
                    }

                    int id = int.Parse(test.SectionName.Replace("BASE-", ""));

                    String query = "UPDATE assets SET rslid='" + rslid + "' where base_id='" + id + "';";

                    DataTable insert = Database.executeQuery(Database.DatabaseName.net7, query);
                    Console.Out.WriteLine(query);
                    reader.Close();
                }
                catch (Exception e)
                {
                    //Console.Out.WriteLine(e+", "+ e.Message);
                    //throw;
                }
            }

            Console.Out.WriteLine("***** Finished *****");
        }
Exemplo n.º 16
0
        public static void RemoveProfile(string profileName, bool deleteDir = true)
        {
            var userDir          = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
            var appDataDirectory = Path.Combine(userDir, "Mozilla", "Firefox");
            var profilesIniFile  = Path.Combine(appDataDirectory, "profiles.ini");

            if (File.Exists(profilesIniFile))
            {
                var reader = new IniFileReader(profilesIniFile);
                var dir    = GetProfileDir(profileName);
                var prKey  = reader.iniFileStore.FirstOrDefault(v => v.Value.Any(v2 => v2.Key == "Name" && v2.Value == profileName)).Key;
                if (!string.IsNullOrWhiteSpace(prKey))
                {
                    reader.iniFileStore.Remove(prKey);
                }
                reader.SaveSettings();
                if (deleteDir && !string.IsNullOrWhiteSpace(dir) && Directory.Exists(dir))
                {
                    try
                    {
                        Directory.Delete(dir, true);
                    }
                    catch
                    {
                        try
                        {
                            Thread.Sleep(2000);
                            Directory.Delete(dir, true);
                        }
                        catch
                        {
                        }
                    }
                }
            }
        }
Exemplo n.º 17
0
        protected override void HandleFile(string file)
        {
            MemoryStream iniStream = fileStreams[file];

            IniFileReader reader  = new IniFileReader(iniStream);
            IniFile       iniFile = IniFile.FromStream(reader);

            object info = new ProjectileInfo();

            string projectileName          = Path.GetFileNameWithoutExtension(file);
            string internalName            = $"{modName}:{projectileName.RemoveIllegalCharacters()}";
            bool   logProjectileAndModName = false;

            foreach (IniFileSection section in iniFile.sections)
            {
                foreach (IniFileElement element in section.elements)
                {
                    switch (section.Name)
                    {
                    case "Stats": {
                        var splitElement = element.Content.Split('=');

                        var statField = typeof(ProjectileInfo).GetField(splitElement[0]);

                        switch (splitElement[0])
                        {
                        case "type": {
                            continue;
                        }

                        default: {
                            if (statField == null)
                            {
                                Mod.Logger.Debug($"Projectile field not found or invalid field! -> {splitElement[0]}");
                                logProjectileAndModName     = true;
                                tConfigWrapper.ReportErrors = true;
                                continue;
                            }

                            break;
                        }
                        }

                        //Conversion garbage
                        TypeConverter converter = TypeDescriptor.GetConverter(statField.FieldType);
                        object        realValue = converter.ConvertFromString(splitElement[1]);
                        statField.SetValue(info, realValue);
                        break;
                    }
                    }
                }
            }

            string    texturePath       = Path.ChangeExtension(file, "png");
            Texture2D projectileTexture = null;

            if (!Main.dedServ && fileStreams.TryGetValue(texturePath, out MemoryStream textureStream))
            {
                projectileTexture = Texture2D.FromStream(Main.instance.GraphicsDevice, textureStream);
            }

            if (logProjectileAndModName)
            {
                Mod.Logger.Debug($"{internalName}");
            }

            projectilesToLoad.Add(internalName, new BaseProjectile((ProjectileInfo)info, projectileName, projectileTexture));
        }
Exemplo n.º 18
0
        protected override void HandleFile(string file)
        {
            List <(int, int?, string, float)> dropList = new List <(int, int?, string, float)>();
            MemoryStream  iniStream = fileStreams[file];
            IniFileReader reader    = new IniFileReader(iniStream);
            IniFile       iniFile   = IniFile.FromStream(reader);

            object info = new NpcInfo();

            string npcName          = Path.GetFileNameWithoutExtension(file);
            string internalName     = $"{modName}:{npcName.RemoveIllegalCharacters()}";
            bool   logNPCAndModName = false;

            foreach (IniFileSection section in iniFile.sections)
            {
                foreach (IniFileElement element in section.elements)
                {
                    if (string.IsNullOrWhiteSpace(element.Content))
                    {
                        continue;
                    }

                    switch (section.Name)
                    {
                    case "Stats": {
                        var splitElement = element.Content.Split('=');

                        string split1Correct = Utilities.ConvertField13(splitElement[0]);
                        var    statField     = typeof(NpcInfo).GetField(split1Correct);

                        switch (splitElement[0])
                        {
                        case "soundHit": {
                            var soundStyleID = int.Parse(splitElement[1]);
                            var soundStyle   = new LegacySoundStyle(3, soundStyleID);                                   // All NPC hit sounds use 3
                            statField = typeof(NpcInfo).GetField("HitSound");
                            statField.SetValue(info, soundStyle);
                            continue;
                        }

                        case "soundKilled": {
                            var soundStyleID = int.Parse(splitElement[1]);
                            var soundStyle   = new LegacySoundStyle(4, soundStyleID);                                   // All death sounds use 4
                            statField = typeof(NpcInfo).GetField("DeathSound");
                            statField.SetValue(info, soundStyle);
                            continue;
                        }

                        case "type":
                            continue;

                        default: {
                            if (statField == null)
                            {
                                Mod.Logger.Debug($"NPC field not found or invalid field! -> {splitElement[0]}");
                                logNPCAndModName            = true;
                                tConfigWrapper.ReportErrors = true;
                                continue;
                            }

                            break;
                        }
                        }

                        TypeConverter converter = TypeDescriptor.GetConverter(statField.FieldType);
                        object        realValue = converter.ConvertFromString(splitElement[1]);
                        statField.SetValue(info, realValue);
                        break;
                    }

                    case "Buff Immunities": {
                        var splitElement = element.Content.Split('=');
                        splitElement[0] = splitElement[0].Replace(" ", "").Replace("!", "");

                        FieldInfo npcInfoImmunity = typeof(NpcInfo).GetField("buffImmune");
                        if (BuffID.Search.ContainsName(splitElement[0]))
                        {
                            // Will 100% need to adjust this once we get mod buff loading implemented
                            bool[] immunity = new bool[BuffLoader.BuffCount];
                            immunity[BuffID.Search.GetId(splitElement[0])] = bool.Parse(splitElement[1]);
                            npcInfoImmunity.SetValue(info, immunity);
                        }
                        else
                        {
                            Mod.Logger.Debug($"{splitElement[0]} doesn't exist!");                             // Will have to manually convert
                        }
                        break;
                    }

                    case "Drops":
                        // example of drop string: 1-4 Golden Flame=0.7
                        string dropRangeString =
                            element.Content.Split(new[] { ' ' }, 2)[0];                           // This gets the drop range, everthing before the first space
                        string dropItemString =
                            element.Content.Split(new[] { ' ' }, 2)[1]
                            .Split('=')[
                                0];                                              // This gets everything after the first space, then it splits at the = and gets everything before it
                        string dropChanceString = element.Content.Split('=')[1]; // Gets everything after the = sign
                        int    min;
                        int?   max = null;
                        if (dropRangeString.Contains("-"))
                        {
                            min = int.Parse(dropRangeString.Split('-')[0]);
                            max = int.Parse(dropRangeString.Split('-')[1]) + 1;                             // + 1 because the max is exclusive in Main.rand.Next()
                        }
                        else
                        {
                            min = int.Parse(dropRangeString);
                        }

                        dropList.Add((min, max, $"{modName}:{dropItemString}", float.Parse(dropChanceString) / 100));
                        break;
                    }
                }
            }

            if (logNPCAndModName)
            {
                Mod.Logger.Debug($"{internalName}");                 //Logs the npc and mod name if "Field not found or invalid field". Mod and npc name show up below the other log line
            }
            // Check if a texture for the .ini file exists
            string    texturePath = Path.ChangeExtension(file, "png");
            Texture2D npcTexture  = null;

            if (!Main.dedServ && fileStreams.TryGetValue(texturePath, out MemoryStream textureStream))
            {
                npcTexture = Texture2D.FromStream(Main.instance.GraphicsDevice, textureStream);                 // Load a Texture2D from the stream
            }

            npcToLoad.Add(internalName, new BaseNPC((NpcInfo)info, dropList, npcName, npcTexture));

            reader.Dispose();
        }
Exemplo n.º 19
0
    void ReadIniFile(string filePath)
    {
        IniFileReader iniFR = new IniFileReader();

        if (iniFR.ReadFile(Path.Combine(Application.dataPath, filePath)))
        {
            string value = null;
            iniFR.GetParameter("Background", "speed", out value);
            float.TryParse(value, out startingParams.background.speed);

            value = null;
            iniFR.GetParameter("Ballon", "moveTime", out value);
            float.TryParse(value, out startingParams.ballon.moveTime);

            value = null;
            iniFR.GetParameter("Ballon", "canRoll", out value);
            bool.TryParse(value, out startingParams.ballon.canRoll);

            value = null;
            iniFR.GetParameter("Ballon", "rotationSpeed", out value);
            float.TryParse(value, out startingParams.ballon.rotationSpeed);

            value = null;
            iniFR.GetParameter("Ballon", "canKill", out value);
            bool.TryParse(value, out startingParams.ballon.canKill);

            value = null;
            iniFR.GetParameter("Bomb", "moveTime", out value);
            float.TryParse(value, out startingParams.bomb.moveTime);

            value = null;
            iniFR.GetParameter("Bomb", "canRoll", out value);
            bool.TryParse(value, out startingParams.bomb.canRoll);

            value = null;
            iniFR.GetParameter("Bomb", "rotationSpeed", out value);
            float.TryParse(value, out startingParams.bomb.rotationSpeed);

            value = null;
            iniFR.GetParameter("Bomb", "explosionLenghtTime", out value);
            float.TryParse(value, out startingParams.bomb.explosionLenghtTime);

            value = null;
            iniFR.GetParameter("Bomb", "destroyDelayTime", out value);
            float.TryParse(value, out startingParams.bomb.destroyDelayTime);

            value = null;
            iniFR.GetParameter("Bomb", "canKill", out value);
            bool.TryParse(value, out startingParams.bomb.canKill);

            value = null;
            iniFR.GetParameter("Crystal", "moveTime", out value);
            float.TryParse(value, out startingParams.crystal.moveTime);

            value = null;
            iniFR.GetParameter("Crystal", "canRoll", out value);
            bool.TryParse(value, out startingParams.crystal.canRoll);

            value = null;
            iniFR.GetParameter("Crystal", "rotationSpeed", out value);
            float.TryParse(value, out startingParams.crystal.rotationSpeed);

            value = null;
            iniFR.GetParameter("Crystal", "canKill", out value);
            bool.TryParse(value, out startingParams.crystal.canKill);

            //value = null;
            //iniFR.GetParameter("Mineral", "moveTime", out value);
            //float.TryParse(value, out startingParams.mineral.moveTime);

            //value = null;
            //iniFR.GetParameter("Mineral", "canRoll", out value);
            //bool.TryParse(value, out startingParams.mineral.canRoll);

            //value = null;
            //iniFR.GetParameter("Mineral", "rotationSpeed", out value);
            //float.TryParse(value, out startingParams.mineral.rotationSpeed);

            //value = null;
            //iniFR.GetParameter("Mineral", "canKill", out value);
            //bool.TryParse(value, out startingParams.mineral.canKill);

            value = null;
            iniFR.GetParameter("Player", "moveTime", out value);
            float.TryParse(value, out startingParams.player.moveTime);

            value = null;
            iniFR.GetParameter("Player", "secondsForBallon", out value);
            int.TryParse(value, out startingParams.player.secondsForBallon);

            value = null;
            iniFR.GetParameter("Player", "startingSecondsOfOxygen", out value);
            int.TryParse(value, out startingParams.player.startingSecondsOfOxygen);

            value = null;
            iniFR.GetParameter("Player", "deathDelaySeconds", out value);
            int.TryParse(value, out startingParams.player.deathDelay);

            value = null;
            iniFR.GetParameter("Stone", "moveTime", out value);
            float.TryParse(value, out startingParams.stone.moveTime);

            value = null;
            iniFR.GetParameter("Stone", "canRoll", out value);
            bool.TryParse(value, out startingParams.stone.canRoll);

            value = null;
            iniFR.GetParameter("Stone", "rotationSpeed", out value);
            float.TryParse(value, out startingParams.stone.rotationSpeed);

            value = null;
            iniFR.GetParameter("Stone", "canKill", out value);
            bool.TryParse(value, out startingParams.stone.canKill);
        }
    }
Exemplo n.º 20
0
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        static void Main()
        {
            // Watch files in this project:
            //		Sources: "test.txt", "win.ini"
            //		Results: "bin\..\test1.txt", "bin\..\mail.txt", "new.ini", "light.txt"

            //   After first run of demo, try uncomment these and compare result with the previous output:

            ////If you uncomment this, you will get traditional-looking INI files
            //IniFileSettings.PreserveFormatting = false;
            ////If you uncomment these, you will get a custom formatted files
            //IniFileSettings.QuoteChar = '\"';
            //IniFileSettings.DefaultSectionFormatting = "[ $ ]   ;";
            //IniFileSettings.DefaultValueFormatting = " ? = $           ;";
            //IniFileSettings.CommentChars = new string[] { "//", ";" };
            ////Uncomment both of above will force the custom formatting.

            #region USER MODE ("test.txt" -> "test1.txt")

            // Here are listed a few possible operations
            // Read the comments, see the effects :) (in the "test1.txt" file)
            IniFile file = IniFile.FromFile("test.txt");
            // Adds a new section
            file["New section"]["KEYE"] = "geage";
            // Adds new values to an existing section
            file["First"]["NewOne"]   = "aaa";
            file["First"]["NewTwo"]   = "bbb";
            file["First"]["NewThree"] = "ccc";
            // Sets an existing value
            file["First"]["Number"] = "666";
            // Overrides a comment of a section
            file["Another"].Comment = @"Override multiline comment of 'Another'"
                                      + (IniFileSettings.PreserveFormatting ? Environment.NewLine +
                                         "Spaces surrounding section name are preserved." : "");
            // Rename secion
            file["Another"].Name = "Section Another was renamed";
            // Adds a comment of value "KEYE".
            file["New section"].SetComment("KEYE", "Comment for a newly created key");
            // Adds an inline comment of value "KEYE".
            file["New section"].SetInlineComment("KEYE", "Inline comment for a newly created key");
            // Comment at the end of file
            file.Foot = "As you see, it is cool.";
            // Header
            if (IniFileSettings.PreserveFormatting)
            {
                file.Header += Environment.NewLine + Environment.NewLine + @"Preserving format feature is ON.
Note that new values in [First] section look the same as
the one which already existed.";
            }
            else
            {
                file.Header += Environment.NewLine + Environment.NewLine + @"Preserving format feature is OFF.";
            }

            // Save file to the disc
            file.Save("test1.txt");
            //U can comment this out and add "file" to watches for more reflection.
            //file = IniFile.FromFile("test1.txt");
            #endregion

            #region HARDCORE MODE ("win.ini" -> "mail.ini")
            IniFileReader reader = new IniFileReader("win.ini");
            // Extract "Mail" section to another file.
            IniFileSectionStart sss;
            sss = reader.GotoSection("Mail");
            List <IniFileElement> sectionElements = reader.ReadSection();
            reader.Close();
            // Create an IniFile
            IniFile mailSection = IniFile.FromElements(sectionElements);
            mailSection.Header = "This is an extracted 'Mail' section";
            mailSection.Save("mail.ini");

            //Rusty alternative:
            //IniFileWriter writer = new IniFileWriter("mail.ini");
            //writer.WriteElement(IniFileCommentary.FromComment("This is an extracted \"Mail\" section"));
            //writer.WriteElement(new IniFileBlankLine(1));
            //writer.WriteElements(sectionElements);
            //writer.Close();
            #endregion

            #region SAMPLE FROM THE ARTICLE ("new.ini")
            // SAMPLE FROM THE ARTICLE ("new.ini")
            file = new IniFile();
            // Adds a new section
            file["LastUser"]["Name"] = "Gajatko";
            // Add comments
            file["LastUser"].Comment =
                @"This section contains information about user
which logged in at previous program run";
            file["LastUser"].SetComment("Name", "Name of user");
            // Rename sections and keys
            file["LastUser"].Name = "RecentUser";
            file["RecentUser"].RenameKey("Name", "Login");
            // Get names of all section:
            string[] sections = file.GetSectionNames();
            // Set existing values:
            file["RecentUser"]["Login"] = "******";
            // Override existing comment:
            file["RecentUser"].Comment = "New Comment";
            // Save to disc
            file.Save("new.ini");
            #endregion

            #region LIGHT MODE ("light.txt")
            Gajatko.IniFiles.Light.IniFileLight light = new Gajatko.IniFiles.Light.IniFileLight();
            // Set data
            light.Sections.Add("Data", new Dictionary <string, string>());
            light.Sections["Data"].Add("Name", "Mickey");
            light.Sections["Data"].Add("Surname", "Mouse");
            // Value comment
            light.Comments.Add("Data.Surname", "This is a surname");
            // Section comment
            light.Comments.Add("Data", "This is a section");
            // Footer
            light.Comments.Add("", "Footer");
            // Save INI
            light.Save("light.txt");
            // Read it back for testing
            light = new Gajatko.IniFiles.Light.IniFileLight("light.txt");
            string commentOfSurname = light.Comments["Data.Surname"];
            string commentOfSection = light.Comments["Data"];
            #endregion

            // ... that's it!

            Console.WriteLine(
                @"Watch these files in this project: 
Sources: 'test.txt', 'win.ini'
Results: 'bin\..\test1.txt', 'bin\..\mail.txt', 'new.ini', 'light.txt'");
            Console.ReadLine();
        }
Exemplo n.º 21
0
        protected override void HandleFile(string file)
        {
            MemoryStream iniStream = fileStreams[file];

            IniFileReader reader  = new IniFileReader(iniStream);
            IniFile       iniFile = IniFile.FromStream(reader);

            object        info        = new ItemInfo();
            List <string> toolTipList = new List <string>();

            // Get the mod name
            string itemName     = Path.GetFileNameWithoutExtension(file);
            string internalName = $"{modName}:{itemName.RemoveIllegalCharacters()}";

            // TODO: If the item is from Terraria, make it a GlobalItem
            if (ItemID.FromLegacyName(itemName, 4) != 0)
            {
                internalName = itemName;
            }
            bool   logItemAndModName = false;
            string createWall        = null;
            string createTile        = null;
            string shoot             = null;

            foreach (IniFileSection section in iniFile.sections)
            {
                foreach (IniFileElement element in section.elements)
                {
                    switch (section.Name)
                    {
                    case "Stats": {
                        var splitElement = element.Content.Split('=');

                        var statField = typeof(ItemInfo).GetField(splitElement[0]);

                        switch (splitElement[0])
                        {
                        // Set the tooltip, has to be done manually since the toolTip field doesn't exist in 1.3
                        case "toolTip":
                        case "toolTip1":
                        case "toolTip2":
                        case "toolTip3":
                        case "toolTip4":
                        case "toolTip5":
                        case "toolTip6":
                        case "toolTip7": {
                            toolTipList.Add(splitElement[1]);
                            continue;
                        }

                        case "useSound": {
                            var soundStyleId = int.Parse(splitElement[1]);
                            var soundStyle   = new LegacySoundStyle(2, soundStyleId);                                                           // All items use the second sound ID
                            statField = typeof(ItemInfo).GetField("UseSound");
                            statField.SetValue(info, soundStyle);
                            continue;
                        }

                        case "createTileName": {
                            createTile = $"{modName}:{splitElement[1]}";
                            continue;
                        }

                        case "projectile": {
                            shoot = $"{modName}:{splitElement[1]}";
                            continue;
                        }

                        case "createWallName": {
                            createWall = $"{modName}:{splitElement[1]}";
                            continue;
                        }

                        case "type":
                            continue;

                        default: {
                            if (statField == null)
                            {
                                Mod.Logger.Debug($"Item field not found or invalid field! -> {splitElement[0]}");
                                logItemAndModName           = true;
                                tConfigWrapper.ReportErrors = true;
                                continue;
                            }
                            break;
                        }
                        }

                        // Convert the value to an object of type statField.FieldType
                        TypeConverter converter = TypeDescriptor.GetConverter(statField.FieldType);
                        object        realValue = converter.ConvertFromString(splitElement[1]);
                        statField.SetValue(info, realValue);
                        break;
                    }

                    case "Recipe": {
                        if (!LoadStep.recipeDict.ContainsKey(internalName))
                        {
                            LoadStep.recipeDict.TryAdd(internalName, section);
                        }
                        break;
                    }
                    }
                }
            }

            if (logItemAndModName)
            {
                Mod.Logger.Debug($"{internalName}");                 //Logs the item and mod name if "Field not found or invalid field". Mod and item name show up below the other log line
            }
            string toolTip = string.Join("\n", toolTipList);

            // Check if a texture for the .ini file exists
            string    texturePath = Path.ChangeExtension(file, "png");
            Texture2D itemTexture = null;

            if (!Main.dedServ && fileStreams.TryGetValue(texturePath, out MemoryStream textureStream))
            {
                itemTexture = Texture2D.FromStream(Main.instance.GraphicsDevice, textureStream);                 // Load a Texture2D from the stream
            }

            int id = ItemID.FromLegacyName(itemName, 4);

            if (id != 0)
            {
                if (!LoadStep.globalItemInfos.ContainsKey(id))
                {
                    LoadStep.globalItemInfos.TryAdd(id, (ItemInfo)info);
                }
                else
                {
                    LoadStep.globalItemInfos[id] = (ItemInfo)info;
                }

                reader.Dispose();
                return;
            }

            _itemsToLoad.Add(internalName, new BaseItem((ItemInfo)info, internalName, itemName, createTile, shoot, createWall, toolTip, itemTexture));
            reader.Dispose();
        }
        private void SetBiffDirectories()
        {
            GameConfig game = _games[_gameEnum];

            if (game == null || game.IniFile.IsNullOrEmpty())
            {
                return;
            }

            var reader = new IniFileReader();

            string iniPath = Path.Combine(_rootPath, game.IniFile);
            IniFile iniFile = reader.GetIniFile(iniPath);

            foreach (var iniCategory in iniFile.IniCategories)
            {
                foreach (var iniKey in iniCategory.Keys)
                {
                    string value = iniKey.Value;

                    string[] directories = value.Split(';');

                    foreach (var directory in directories)
                    {
                        if (Directory.Exists(directory) && !_biffDirs.Contains(directory))
                        {
                            _biffDirs.Add(directory);
                        }
                    }
                }
            }
        }
Exemplo n.º 23
0
        private void setSystemsFromINI()
        {
            try
            {
                Pinxsystem = new List<PinXSystem>();
                IniFileReader ini_read = new IniFileReader(ConfigPath);
                string id = "VisualPinball";
                bool enabled;
                bool.TryParse(ini_read.IniReadValue("VisualPinball", "Enabled"), out enabled);
                string sysName = "Visual Pinball";
                string workpath = ini_read.IniReadValue("VisualPinball", "WorkingPath");
                string tablepath = ini_read.IniReadValue("VisualPinball", "TablePath");
                string parameters = ini_read.IniReadValue("VisualPinball", "Parameters");
                string exe = ini_read.IniReadValue("VisualPinball", "Executable");
                string nvram = ini_read.IniReadValue("VisualPinball", "NVRAMPath");
                int systemType;
                bool lbEnabled = Convert.ToBoolean(ini_read.IniReadValue("VisualPinball", "LaunchBeforeEnabled"));
                string lbPath = ini_read.IniReadValue("VisualPinball", "LaunchBeforeWorkingPath");
                string lbExe = ini_read.IniReadValue("VisualPinball", "LaunchBeforeExecutable");
                string lbParams = ini_read.IniReadValue("VisualPinball", "LaunchBeforeParameters");
                bool lbWaitExit = Convert.ToBoolean(ini_read.IniReadValue("VisualPinball", "LaunchBeforeWaitForExit"));
                bool lbHideWindow = Convert.ToBoolean(ini_read.IniReadValue("VisualPinball", "LaunchBeforeHideWindow"));

                bool laEnabled = Convert.ToBoolean(ini_read.IniReadValue("VisualPinball", "LaunchAfterEnabled"));
                string laPath = ini_read.IniReadValue("VisualPinball", "LaunchAfterWorkingPath");
                string laExe = ini_read.IniReadValue("VisualPinball", "LaunchAfterExecutable");
                bool laHideWindow = Convert.ToBoolean(ini_read.IniReadValue("VisualPinball", "LaunchAfterHideWindow"));
                string laParams = ini_read.IniReadValue("VisualPinball", "LaunchAfterParameters");
                bool laWaitExit = Convert.ToBoolean(ini_read.IniReadValue("VisualPinball", "LaunchAfterWaitForExit"));

                Pinxsystem.Add(new PinXSystem(1, enabled, id, sysName, workpath, tablepath, exe, parameters, lbEnabled, lbPath, lbExe, lbParams,
                    lbWaitExit, lbHideWindow, laEnabled, laWaitExit, laExe, laParams, laHideWindow, laPath, nvram));

                id = "FuturePinball";
                bool.TryParse(ini_read.IniReadValue("FuturePinball", "Enabled"), out enabled);
                sysName = "Future Pinball";
                workpath = ini_read.IniReadValue("FuturePinball", "WorkingPath");
                tablepath = ini_read.IniReadValue("FuturePinball", "TablePath");
                parameters = ini_read.IniReadValue("FuturePinball", "Parameters");
                exe = ini_read.IniReadValue("FuturePinball", "Executable");
                nvram = ini_read.IniReadValue("FuturePinball", "NVRAMPath");

                lbEnabled = Convert.ToBoolean(ini_read.IniReadValue("FuturePinball", "LaunchBeforeEnabled"));
                lbPath = ini_read.IniReadValue("FuturePinball", "LaunchBeforeWorkingPath");
                lbExe = ini_read.IniReadValue("FuturePinball", "LaunchBeforeExecutable");
                lbParams = ini_read.IniReadValue("FuturePinball", "LaunchBeforeParameters");
                lbWaitExit = Convert.ToBoolean(ini_read.IniReadValue("FuturePinball", "LaunchBeforeWaitForExit"));
                lbHideWindow = Convert.ToBoolean(ini_read.IniReadValue("FuturePinball", "LaunchBeforeHideWindow"));

                laEnabled = Convert.ToBoolean(ini_read.IniReadValue("FuturePinball", "LaunchAfterEnabled"));
                laPath = ini_read.IniReadValue("FuturePinball", "LaunchAfterWorkingPath");
                laExe = ini_read.IniReadValue("FuturePinball", "LaunchAfterExecutable");
                laHideWindow = Convert.ToBoolean(ini_read.IniReadValue("FuturePinball", "LaunchAfterHideWindow"));
                laParams = ini_read.IniReadValue("FuturePinball", "LaunchAfterParameters");
                laWaitExit = Convert.ToBoolean(ini_read.IniReadValue("FuturePinball", "LaunchAfterWaitForExit"));

                Pinxsystem.Add(new PinXSystem(2, enabled, id, sysName, workpath, tablepath, exe, parameters, lbEnabled, lbPath, lbExe, lbParams,
                    lbWaitExit, lbHideWindow, laEnabled, laWaitExit, laExe, laParams, laHideWindow, laPath, nvram));

                int i = 1;

                while (sysName != string.Empty)
                {
                    id = "System_" + i;
                    sysName = ini_read.IniReadValue(id, "Name");
                    workpath = ini_read.IniReadValue("System_" + i, "WorkingPath");
                    tablepath = ini_read.IniReadValue("System_" + i, "TablePath");
                    parameters = ini_read.IniReadValue("System_" + i, "Parameters");
                    exe = ini_read.IniReadValue("System_" + i, "Executable");
                    nvram = ini_read.IniReadValue("System_" + i, "NVRAMPath");

                    int.TryParse(ini_read.IniReadValue("System_" + i, "SystemType"), out systemType);

                    bool.TryParse(ini_read.IniReadValue("System_" + i, "Enabled"), out enabled);
                    bool.TryParse(ini_read.IniReadValue("System_" + i, "LaunchBeforeEnabled"), out lbEnabled);
                    bool.TryParse(ini_read.IniReadValue("System_" + i, "LaunchBeforeWaitForExit"), out lbWaitExit);
                    bool.TryParse(ini_read.IniReadValue("System_" + i, "LaunchBeforeHideWindow"), out lbHideWindow);

                    bool.TryParse(ini_read.IniReadValue("System_" + i, "LaunchAfterEnabled"), out laEnabled);
                    bool.TryParse(ini_read.IniReadValue("System_" + i, "LaunchAfterHideWindow"), out laHideWindow);
                    bool.TryParse(ini_read.IniReadValue("System_" + i, "LaunchAfterWaitForExit"), out laWaitExit);

                    lbPath = ini_read.IniReadValue("System_" + i, "LaunchBeforeWorkingPath");
                    lbExe = ini_read.IniReadValue("System_" + i, "LaunchBeforeExecutable");
                    lbParams = ini_read.IniReadValue("System_" + i, "LaunchBeforeParameters");
                    laPath = ini_read.IniReadValue("System_" + i, "LaunchAfterWorkingPath");
                    laExe = ini_read.IniReadValue("System_" + i, "LaunchAfterExecutable");
                    laParams = ini_read.IniReadValue("System_" + i, "LaunchAfterParameters");

                    if (sysName != string.Empty)
                    {
                        Pinxsystem.Add(new PinXSystem(systemType, enabled, id, sysName, workpath, tablepath, exe, parameters, lbEnabled, lbPath, lbExe, lbParams,
                            lbWaitExit, lbHideWindow, laEnabled, laWaitExit, laExe, laParams, laHideWindow, laPath, nvram));
                        i++;
                    }
                    else
                        return;
                }
            }
            catch (Exception)
            {

                throw;
            }
        }
        /// <summary>
        /// load global variables
        /// </summary>
        /// <param name="conf_filename">config filename</param>
        public static void init(string conf_filename)
        {
            IniFileReader iniReader;

            string[] szTrackerServers;
            string[] parts;
            iniReader = new IniFileReader(conf_filename);

            g_connect_timeout = iniReader.getIntValue("connect_timeout", DEFAULT_CONNECT_TIMEOUT);
            if (g_connect_timeout < 0)
            {
                g_connect_timeout = DEFAULT_CONNECT_TIMEOUT;
            }
            g_connect_timeout *= 1000; //millisecond
            g_network_timeout  = iniReader.getIntValue("network_timeout", DEFAULT_NETWORK_TIMEOUT);
            if (g_network_timeout < 0)
            {
                g_network_timeout = DEFAULT_NETWORK_TIMEOUT;
            }
            g_network_timeout *= 1000; //millisecond
            var charset = iniReader.getStrValue("charset");

            if (charset == null || charset.Length == 0)
            {
                charset = "ISO8859-1";
            }
            g_charset        = Encoding.GetEncoding(charset);
            szTrackerServers = iniReader.getValues("tracker_server");
            if (szTrackerServers == null)
            {
                throw new MyException("item \"tracker_server\" in " + conf_filename + " not found");
            }
            InetSocketAddress[] tracker_servers = new InetSocketAddress[szTrackerServers.Length];
            for (int i = 0; i < szTrackerServers.Length; i++)
            {
                parts = szTrackerServers[i].Split("\\:", 2);
                if (parts.Length != 2)
                {
                    throw new MyException("the value of item \"tracker_server\" is invalid, the correct format is host:port");
                }
                tracker_servers[i] = new InetSocketAddress(parts[0].Trim(), int.Parse(parts[1].Trim()));
            }
            g_tracker_group = new TrackerGroup(tracker_servers);

            g_tracker_http_port = iniReader.getIntValue("http.tracker_http_port", 80);
            g_anti_steal_token  = iniReader.getBoolValue("http.anti_steal_token", false);
            if (g_anti_steal_token)
            {
                g_secret_key = iniReader.getStrValue("http.secret_key");
            }
            g_connection_pool_enabled             = iniReader.getBoolValue("connection_pool.enabled", DEFAULT_CONNECTION_POOL_ENABLED);
            g_connection_pool_max_count_per_entry = iniReader.getIntValue("connection_pool.max_count_per_entry", DEFAULT_CONNECTION_POOL_MAX_COUNT_PER_ENTRY);
            g_connection_pool_max_idle_time       = iniReader.getIntValue("connection_pool.max_idle_time", DEFAULT_CONNECTION_POOL_MAX_IDLE_TIME);
            if (g_connection_pool_max_idle_time < 0)
            {
                g_connection_pool_max_idle_time = DEFAULT_CONNECTION_POOL_MAX_IDLE_TIME;
            }
            g_connection_pool_max_idle_time      *= 1000;
            g_connection_pool_max_wait_time_in_ms = iniReader.getIntValue("connection_pool.max_wait_time_in_ms", DEFAULT_CONNECTION_POOL_MAX_WAIT_TIME_IN_MS);
            if (g_connection_pool_max_wait_time_in_ms < 0)
            {
                g_connection_pool_max_wait_time_in_ms = DEFAULT_CONNECTION_POOL_MAX_WAIT_TIME_IN_MS;
            }
        }
Exemplo n.º 25
0
        private void MenuItem_Click(object sender, RoutedEventArgs e)
        {
            var t = tables_grid.SelectedItem as Table;
            var s = Pinxsystem.ElementAt(comboBox_syslist.SelectedIndex);

            if (!t.TableFileExists)
                return;

            string ext = string.Empty;
            string ext2 = string.Empty;
            if (systemName == "P-ROC" || systemName == "Visual Pinball")
            {
                ext = ".vpt";
                ext2 = ".vpx";
            }
            else if (systemName == "Future Pinball")
            { }
            else
                return;

            IniFileReader ini_read = new IniFileReader(ConfigPath);
            var mi = e.Source as System.Windows.Controls.MenuItem;
            string menuItemHeader = mi.Header.ToString();
            int keyc = Convert.ToInt32(ini_read.IniReadValue("KeyCodes", "exitemulator"));

            //System.Windows.MessageBox.Show(keyc.ToString());
            bool UsingVPX = false;

            DirectoryInfo di = new DirectoryInfo(s.TablePath);
            VPLaunch vp = new VPLaunch();
            FileInfo[] fi=null;
            if (systemName == "P-ROC" || systemName == "Visual Pinball")
            {
                fi = di.GetFiles(t.Name + ext2);
                if (fi.Length == 0)
                    fi = di.GetFiles(t.Name + ext);
                else
                    UsingVPX = true;
            }
            else if (systemName == "Future Pinball")
            {
                fi = di.GetFiles(t.Name + ".fpt");
            }

            if (systemName == "P-ROC")
            {
                if (menuItemHeader == "Load Camera")
                {
                    if (UsingVPX)
                        vp.launchPROC("\"" + s.TablePath + "\"", "\"" + fi[0].Name + "\"", t.AlternateExe, "\"" + s.WorkingPath + "\"", s.Executable, keyc, systemName, "none", t.Desktop, 1);
                }
                else if (menuItemHeader == "Cam Setup")
                {
                    if (UsingVPX)
                        vp.launchPROC("\"" + s.TablePath + "\"", "\"" + fi[0].Name + "\"", t.AlternateExe, "\"" + s.WorkingPath + "\"", s.Executable, keyc, systemName, "none", t.Desktop, 2);
                }
                else if (menuItemHeader == "Launch editor")
                    vp.launchPROC("\"" + s.TablePath + "\"", "\"" + fi[0].Name + "\"", t.AlternateExe, "\"" + s.WorkingPath + "\"", s.Executable, keyc, systemName, "none", t.Desktop,3);
                else if (menuItemHeader == "Launch to script")
                    vp.launchPROC("\"" + s.TablePath + "\"", "\"" + fi[0].Name + "\"", t.AlternateExe, "\"" + s.WorkingPath + "\"", s.Executable, keyc, systemName, "none", t.Desktop,4);
                else if (menuItemHeader == "Play Bsc Script")
                    vp.launchPROC("\"" + s.TablePath + "\"", "\"" + fi[0].Name + "\"", t.AlternateExe, "\"" + s.WorkingPath + "\"", s.Executable, keyc, systemName, "Basic", t.Desktop,5);
                else if (menuItemHeader == "Edit Bsc Script")
                    vp.launchPROC("\"" + s.TablePath + "\"", "\"" + fi[0].Name + "\"", t.AlternateExe, "\"" + s.WorkingPath + "\"", s.Executable, keyc, systemName, "Basic", t.Desktop);
                else if (menuItemHeader == "Play Full Script")
                    vp.launchPROC("\"" + s.TablePath + "\"", "\"" + fi[0].Name + "\"", t.AlternateExe, "\"" + s.WorkingPath + "\"", s.Executable, keyc, systemName, "Full", t.Desktop,5);
                else if (menuItemHeader == "Edit Full Script")
                    vp.launchPROC("\"" + s.TablePath + "\"", "\"" + fi[0].Name + "\"", t.AlternateExe, "\"" + s.WorkingPath + "\"", s.Executable, keyc, systemName, "Full", t.Desktop);
                else
                    vp.launchPROC("\"" + s.TablePath + "\"", "\"" + fi[0].Name + "\"", t.AlternateExe, "\"" + s.WorkingPath + "\"", s.Executable, keyc, systemName, "none", t.Desktop);
            }
            else if (systemName == "Visual Pinball")
            {
                if (menuItemHeader == "Load Camera")
                {
                    if (UsingVPX)
                        vp.launchVP("\"" + s.TablePath + "\"", "\"" + fi[0].Name + "\"", t.AlternateExe, "\"" + s.WorkingPath + "\"", s.Executable, keyc, systemName, "none", t.Desktop, 1);
                }
                else if (menuItemHeader == "Cam Setup")
                {
                    if (UsingVPX)
                        vp.launchVP("\"" + s.TablePath + "\"", "\"" + fi[0].Name + "\"", t.AlternateExe, "\"" + s.WorkingPath + "\"", s.Executable, keyc, systemName, "none", t.Desktop, 2);
                }
                else if (menuItemHeader == "Launch editor")
                {
                   // System.Windows.MessageBox.Show("\"" + s.TablePath + "\"" + "\"" + fi[0].Name + "\"" + t.AlternateExe + "\"" + s.WorkingPath + "\"" + s.Executable + keyc + systemName + " none" + t.Desktop + " 3");
                    vp.launchVP("\"" + s.TablePath + "\"", "\"" + fi[0].Name + "\"", t.AlternateExe, "\"" + s.WorkingPath + "\"", s.Executable, keyc, systemName, "none", t.Desktop, 3);
                }
                else if (menuItemHeader == "Launch to script")
                    vp.launchVP("\"" + s.TablePath + "\"", "\"" + fi[0].Name + "\"", t.AlternateExe, "\"" + s.WorkingPath + "\"", s.Executable, keyc, systemName, "none", t.Desktop, 4);
                else if (menuItemHeader == "Play Bsc Script")
                    vp.launchVP("\"" + s.TablePath + "\"", "\"" + fi[0].Name + "\"", t.AlternateExe, "\"" + s.WorkingPath + "\"", s.Executable, keyc, systemName, "Basic", t.Desktop, 5);
                else if (menuItemHeader == "Edit Bsc Script")
                    vp.launchVP("\"" + s.TablePath + "\"", "\"" + fi[0].Name + "\"", t.AlternateExe, "\"" + s.WorkingPath + "\"", s.Executable, keyc, systemName, "Basic", t.Desktop);
                else if (menuItemHeader == "Play Full Script")
                    vp.launchVP("\"" + s.TablePath + "\"", "\"" + fi[0].Name + "\"", t.AlternateExe, "\"" + s.WorkingPath + "\"", s.Executable, keyc, systemName, "Full", t.Desktop, 5);
                else if (menuItemHeader == "Edit Full Script")
                    vp.launchVP("\"" + s.TablePath + "\"", "\"" + fi[0].Name + "\"", t.AlternateExe, "\"" + s.WorkingPath + "\"", s.Executable, keyc, systemName, "Full", t.Desktop);
                else
                    vp.launchVP("\"" + s.TablePath + "\"", "\"" + fi[0].Name + "\"", t.AlternateExe, "\"" + s.WorkingPath + "\"", s.Executable, keyc, systemName, "none", t.Desktop, 0);

            }
            else if (systemName == "Future Pinball")
            {
                try
                {
                    if (t.AlternateExe == "")
                        t.AlternateExe = "Future Pinball.exe";
                    vp.lanuchBAM(s.TablePath, fi[0].Name, t.AlternateExe, s.WorkingPath, s.Executable, keyc, systemName, "none", t.Desktop, 0, s.Executable);
                }
                catch (Exception)
                {

                }
                //string PinballXExe = Convert.ToInt32(ini_read.IniReadValue("FuturePinball", "exitemulator"));

            }
        }
Exemplo n.º 26
0
        private void SaveSystemsIni()
        {
            IniFileReader ini_file = new IniFileReader(ConfigPath);
            //ini_file.IniWriteValue("VisualPinball", "WorkingPath","");
            foreach (var item in Pinxsystem)
            {
                ini_file.IniWriteValue(item.ID, "Enabled", item.Enabled.ToString());
                ini_file.IniWriteValue(item.ID, "WorkingPath", item.WorkingPath);
                ini_file.IniWriteValue(item.ID, "TablePath", item.TablePath);
                ini_file.IniWriteValue(item.ID, "Executable", item.Executable);
                ini_file.IniWriteValue(item.ID, "Parameters", item.Parameters);

                ini_file.IniWriteValue(item.ID, "LaunchBeforeEnabled", item.LaunchBefore.ToString());
                ini_file.IniWriteValue(item.ID, "LaunchBeforeWorkingPath", item.LaunchBeforePath);
                ini_file.IniWriteValue(item.ID, "LaunchBeforeExecutable", item.LaunchBeforeexe);
                ini_file.IniWriteValue(item.ID, "LaunchBeforeParameters", item.LaunchBeforeParams);
                ini_file.IniWriteValue(item.ID, "LaunchBeforeWaitForExit", item.LaunchBeforeWaitForExit.ToString());
                ini_file.IniWriteValue(item.ID, "LaunchBeforeHideWindow", item.LaunchBeforeHideWindow.ToString());

                ini_file.IniWriteValue(item.ID, "LaunchAfterEnabled", item.LaunchAfter.ToString());
                ini_file.IniWriteValue(item.ID, "LaunchAfterWorkingPath", item.LaunchAfterWorkingPath);
                ini_file.IniWriteValue(item.ID, "LaunchAfterExecutable", item.LaunchAfterexe);
                ini_file.IniWriteValue(item.ID, "LaunchAfterParameters", item.LaunchAfterParams);
                ini_file.IniWriteValue(item.ID, "LaunchAfterWaitForExit", item.LaunchAfterWaitForExit.ToString());
                ini_file.IniWriteValue(item.ID, "LaunchAfterHideWindow", item.LaunchAfterHideWindow.ToString());

                if (item.ID == "VisualPinball")
                {
                    ini_file.IniWriteValue(item.ID, "NVRAMPath", item.NVRAMPATH);
                    ini_file.IniWriteValue(item.ID, "Bypass", "True");
                }

                if (item.ID == "FuturePinball")
                {
                    ini_file.IniWriteValue(item.ID, "FPRAMPath", item.NVRAMPATH);
                    ini_file.IniWriteValue(item.ID, "MouseClickFocus", "True");
                }

            }
        }
Exemplo n.º 27
0
 /// <summary>
 /// Supply the bezels ini file and return a string array with the points
 /// </summary>
 /// <param name="Filename"></param>
 /// <returns></returns>
 public string[] GetValueFromINI(string Filename)
 {
     string[] bezelInipoints = new string[4];
     IniFileReader ini = new IniFileReader(Filename);
     bezelInipoints[0] = ini.IniReadValue("General", "Bezel Screen Top Left X Coordinate");
     bezelInipoints[1] = ini.IniReadValue("General", "Bezel Screen Top Left Y Coordinate");
     bezelInipoints[2] = ini.IniReadValue("General", "Bezel Screen Bottom Right X Coordinate");
     bezelInipoints[3] = ini.IniReadValue("General", "Bezel Screen Bottom Right Y Coordinate");
     return bezelInipoints;
 }