Create a New INI file to store or load data
예제 #1
0
        private void SetIni(Parameter parameter)
        {
            //TODO Check if ini file exists

            Ini.IniFile ini = new IniFile("");

            ini = new Ini.IniFile(parameter.Path);

            List <string> iniSettings = parameter.GetSettings();

            ini.IniWriteValue(iniSettings[0], iniSettings[1], iniSettings[2]);
        }
예제 #2
0
        public IniFile ReadIni()
        {
            IniFile ini = new Ini.IniFile("sys.ini");

            if (ini.Exists())
            {
                ini.Load();
            }
            else
            {
                IniSection section = new IniSection();
                section.Add("startdate", "1-05-2011");
                section.Add("enddate", "15-05-2011");
                ini.Add("DATES", section);

                section = new IniSection();
                section.Add("email_user", "*****@*****.**");
                section.Add("email_password", "Paz.planner01");
                section.Add("email_from", "*****@*****.**");
                section.Add("email_host", "smtp.gmail.com");
                section.Add("email_port", "587");
                section.Add("email_onderwerp", "Afstudeerzitting(en)");
                ini.Add("EMAILSETTINGS", section);

                section = new IniSection();
                section.Add("this.DB_host", "student.aii.avans.nl");
                section.Add("this.DB_username", "MI4Ie");
                section.Add("this.DB_password", "4DRcUrzV");
                section.Add("this.DB_database", "MI4Ie_this.DB");
                ini.Add("DATABASESETTINGS", section);

                ini.Save();
            }

            return(ini);
        }
예제 #3
0
파일: INI.cs 프로젝트: SGCSam/Underlauncher
        //ReadINI reads, well, the INI.
        public static INIFile ReadINI(SAVE.SAVEFile save)
        {
            var iniReader = new Ini.IniFile(Constants.SavesPath + save.SaveName + "//undertale.ini");

            staticINIFile.defaultINI = false;

            staticINIFile.timePlayed      = ConvertFramesToTimePlayed(iniReader.IniReadValue("General", "Time"));
            staticINIFile.deaths          = FromININumber(iniReader.IniReadValue("General", "Gameover"));
            staticINIFile.FUN             = FromININumber(iniReader.IniReadValue("General", "fun"));
            staticINIFile.skipAsrielStory = FromINIBool(iniReader.IniReadValue("General", "Tale"));
            staticINIFile.beatNeutralRun  = FromINIBool(iniReader.IniReadValue("General", "Won"));

            staticINIFile.trueResetted = FromINIBool(iniReader.IniReadValue("reset", "reset"));
            staticINIFile.doorUnlocked = FromINIBool(iniReader.IniReadValue("reset", "s_key"));

            staticINIFile.timesMetFlowey = FromININumber(iniReader.IniReadValue("Flowey", "Met1"));

            if (FromINIBool(iniReader.IniReadValue("Flowey", "IK")))
            {
                save.floweyState = CharacterStates.Killed;
            }

            else
            {
                save.floweyState = CharacterStates.Default;
            }

            staticINIFile.floweyChatProgress = FromININumber(iniReader.IniReadValue("Flowey", "EX"));

            staticINIFile.piePreference = FromININumber(iniReader.IniReadValue("Toriel", "Bscotch"));

            if (FromINIBool(iniReader.IniReadValue("Toriel", "TK")))
            {
                save.torielState = CharacterStates.Killed;
            }

            else
            {
                save.torielState = CharacterStates.Default;
            }

            staticINIFile.timesMetSans         = FromININumber(iniReader.IniReadValue("Sans", "M1"));
            staticINIFile.sansMetInJudgment    = FromINIBool(iniReader.IniReadValue("Sans", "EndMet"));
            staticINIFile.sansPasswordProgress = FromININumber(iniReader.IniReadValue("Sans", "Pass"));
            staticINIFile.killedSans           = FromINIBool(iniReader.IniReadValue("Sans", "SK"));
            staticINIFile.timesReachedMid      = FromININumber(iniReader.IniReadValue("Sans", "MP"));
            staticINIFile.timesFoughtSans      = FromININumber(iniReader.IniReadValue("Sans", "F"));
            staticINIFile.timesHeardIntro      = FromININumber(iniReader.IniReadValue("Sans", "Intro"));

            staticINIFile.timesMetPapyrus = FromININumber(iniReader.IniReadValue("Papyrus", "M1"));
            save.papyrusState             = FromINICharacterState(iniReader.IniReadValue("Papyrus", "PK"));
            save.papyrusDated             = FromINIDateState(iniReader.IniReadValue("Papyrus", "PD"));

            save.undyneDated = FromINIDateState(iniReader.IniReadValue("Undyne", "UD"));

            staticINIFile.mettatonSkip = FromINIBool(iniReader.IniReadValue("Mettaton", "BossMet"));

            save.alphysDated = FromINIDateState(iniReader.IniReadValue("Alphys", "AD"));

            staticINIFile.fightStage = FromININumber(iniReader.IniReadValue("FFFFF", "P"));
            staticINIFile.skipFight  = FromINIBool(iniReader.IniReadValue("FFFFF", "E"));

            staticINIFile.barrierDestroyed = FromINIBool(iniReader.IniReadValue("F7", "F7"));
            staticINIFile.canTrueReset     = FromINIBool(iniReader.IniReadValue("EndF", "EndF"));

            return(staticINIFile);
        }
예제 #4
0
파일: INI.cs 프로젝트: SGCSam/Underlauncher
        //WriteINI writes, well, the INI.
        public static bool WriteINI(INIFile INItoWrite, SAVE.SAVEFile save)
        {
            try
            {
                var iniWriter = new Ini.IniFile(Constants.SavesPath + save.SaveName + "//undertale.ini");

                iniWriter.IniWriteValue("General", "Name", save.PlayerName);
                iniWriter.IniWriteValue("General", "Time", ConvertTimePlayedToFrames(INItoWrite.timePlayed));
                iniWriter.IniWriteValue("General", "Room", save.Location.ToString());
                iniWriter.IniWriteValue("General", "Gameover", INItoWrite.deaths.ToString());
                iniWriter.IniWriteValue("General", "Kills", save.KillCount.ToString());
                iniWriter.IniWriteValue("General", "Love", save.LOVE.ToString());
                iniWriter.IniWriteValue("General", "fun", INItoWrite.FUN.ToString());
                iniWriter.IniWriteValue("General", "Tale", ToINIBool(INItoWrite.skipAsrielStory));
                iniWriter.IniWriteValue("General", "Won", ToININumber(Convert.ToInt16(INItoWrite.beatNeutralRun) + Convert.ToInt16(INItoWrite.floweyChatProgress)));

                iniWriter.IniWriteValue("reset", "reset", ToINIBool(INItoWrite.trueResetted));
                iniWriter.IniWriteValue("reset", "s_key", ToINIBool(INItoWrite.doorUnlocked));

                iniWriter.IniWriteValue("Flowey", "Met1", ToININumber(INItoWrite.timesMetFlowey));

                if (save.floweyState == CharacterStates.Killed)
                {
                    iniWriter.IniWriteValue("Flowey", "IK", "1.000000");
                }

                else if (INItoWrite.beatNeutralRun)
                {
                    iniWriter.IniWriteValue("Flowey", "NK", "1.000000");
                }

                iniWriter.IniWriteValue("Flowey", "EX", ToININumber(INItoWrite.floweyChatProgress));

                iniWriter.IniWriteValue("Toriel", "Bscotch", ToININumber(INItoWrite.piePreference));

                if (save.torielState == CharacterStates.TorielKilled)
                {
                    iniWriter.IniWriteValue("Toriel", "TK", "1.000000");
                }

                else if (save.torielState == CharacterStates.Spared)
                {
                    iniWriter.IniWriteValue("Toriel", "TS", "1.000000");
                }

                else if (save.torielState == CharacterStates.Default)
                {
                    iniWriter.IniWriteValue("Toriel", "TS", "0.000000");
                }

                iniWriter.IniWriteValue("Sans", "M1", ToININumber(INItoWrite.timesMetSans));
                iniWriter.IniWriteValue("Sans", "EndMet", ToINIBool(INItoWrite.sansMetInJudgment));


                if (save.LOVE == 1)
                {
                    iniWriter.IniWriteValue("Sans", "MeetLv1", ToININumber(INItoWrite.timesMetSans));
                }

                else
                {
                    iniWriter.IniWriteValue("Sans", "MeetLv2", ToININumber(INItoWrite.timesMetSans));
                }

                iniWriter.IniWriteValue("Sans", "Pass", ToININumber(INItoWrite.sansPasswordProgress));
                iniWriter.IniWriteValue("Sans", "SK", ToINIBool(INItoWrite.killedSans));
                iniWriter.IniWriteValue("Sans", "MP", ToININumber(INItoWrite.timesReachedMid));
                iniWriter.IniWriteValue("Sans", "F", ToININumber(INItoWrite.timesFoughtSans));
                iniWriter.IniWriteValue("Sans", "Intro", ToININumber(INItoWrite.timesHeardIntro));

                iniWriter.IniWriteValue("Papyrus", "M1", ToININumber(INItoWrite.timesMetPapyrus));

                if (save.papyrusState == CharacterStates.Killed)
                {
                    iniWriter.IniWriteValue("Papyrus", "PK", "1.000000");
                }

                else if (save.papyrusState == CharacterStates.Spared)
                {
                    iniWriter.IniWriteValue("Papyrus", "PS", "1.000000");
                }

                else if (save.papyrusState == CharacterStates.Default)
                {
                    iniWriter.IniWriteValue("Papyrus", "PS", "0.000000");
                }

                iniWriter.IniWriteValue("Papyrus", "PD", ToINIDateState(save.papyrusDated));

                iniWriter.IniWriteValue("Undyne", "UD", ToINIDateState(save.undyneDated));

                iniWriter.IniWriteValue("Mettaton", "BossMet", ToINIBool(INItoWrite.mettatonSkip));

                iniWriter.IniWriteValue("Alphys", "AD", ToINIDateState(save.alphysDated));

                iniWriter.IniWriteValue("F7", "F7", ToINIBool(INItoWrite.barrierDestroyed));

                iniWriter.IniWriteValue("EndF", "EndF", ToINIBool(INItoWrite.canTrueReset));

                iniWriter.IniWriteValue("FFFFF", "F", ToINIBool(INItoWrite.photoshopFight));
                iniWriter.IniWriteValue("FFFFF", "P", ToININumber(INItoWrite.fightStage));
                iniWriter.IniWriteValue("FFFFF", "E", ToINIBool(INItoWrite.skipFight));

                return(true);
            }

            catch (Exception ex)
            {
                System.Windows.MessageBox.Show("An exception occurred when attempting to write the INI file. Cannot continue. The exception was: \n\n" + ex +
                                               "\n\n Please notify me of this issue via reddit or Skype. ", "Error!", MessageBoxButton.OK, MessageBoxImage.Error);
                return(false);
            }
        }
예제 #5
0
 private MySettings()
 {
     this._settings = new IniFile( "scripts\\EngineOverheat.ini" );
     this.Load();
 }
예제 #6
0
 public void IniWriteValue(string Section, string Key, string Value)
 {
     IniFile.WritePrivateProfileString(Section, Key, Value, path);
 }
예제 #7
0
        public bool InitJob()
        {
            Ini.IniFile ini = new Ini.IniFile(_iniFile);

            var unityDefine = ini.IniReadValue("TableGenerate", "UNITY_DEFINE");

            if (string.IsNullOrEmpty(unityDefine))
            {
                unityDefine = "UNITY_2018_2_OR_NEWER";
            }

            _JobList.Add(new JobImportTable(0, ProgramCmd.TABLE_DIR, "TableGenerate", "TableInput", _srcDir));        // JobList의 Index 0은 항상 Import Table 정보를 저장함.
            if ((_cmdMask & ProgramCmd.EXPORT_CS) > 0)
            {
                _JobList.Add(new JobExportData(new ExportToCS(unityDefine), ProgramCmd.EXPORT_CS, ProgramCmd.CS_DIR, "Directory", "CS", "C#_FILES"));
            }
            if ((_cmdMask & ProgramCmd.EXPORT_CSMGR) > 0)
            {
                _JobList.Add(new JobExportData(new ExportToCSMgr(unityDefine), ProgramCmd.EXPORT_CSMGR, ProgramCmd.CS_DIR, "Directory", "CSMGR", "C#_FILES"));
            }
            if ((_cmdMask & ProgramCmd.EXPORT_CPP) > 0)
            {
                _JobList.Add(new JobExportData(new ExportToCPP(), ProgramCmd.EXPORT_CPP, ProgramCmd.ICECPP_DIR, "Directory", "CPP", "CPP_FILES"));
            }
            if ((_cmdMask & ProgramCmd.EXPORT_CPPHEADER) > 0)
            {
                _JobList.Add(new JobExportData(new ExportToCPPHeader(), ProgramCmd.EXPORT_CPPHEADER, ProgramCmd.ICECPP_DIR, "Directory", "HPP", "CPP_FILES"));
            }
            if ((_cmdMask & ProgramCmd.EXPORT_HPPMGR) > 0)
            {
                _JobList.Add(new JobExportData(new ExportToCppMgrHeader(), ProgramCmd.EXPORT_HPPMGR, ProgramCmd.ICECPP_DIR, "Directory", "HPPMGR", "CPP_FILES"));
            }
            if ((_cmdMask & ProgramCmd.EXPORT_CPPMGR) > 0)
            {
                _JobList.Add(new JobExportData(new ExportToCppMgrImplements(), ProgramCmd.EXPORT_CPPMGR, ProgramCmd.ICECPP_DIR, "Directory", "CPPMGR", "CPP_FILES"));
            }
            if ((_cmdMask & ProgramCmd.EXPORT_TABLE) > 0)
            {
                _JobList.Add(new JobExportData(new ExportToTF(), ProgramCmd.EXPORT_TABLE, ProgramCmd.TF_DIR, "Directory", "TableFile", "TF_FILES"));
            }
            if ((_cmdMask & ProgramCmd.EXPORT_SQLITE) > 0)
            {
                _JobList.Add(new JobExportData(new ExportToSQLLite(), ProgramCmd.EXPORT_SQLITE, ProgramCmd.DB_DIR, "Directory", "SQLITE", "SQLITE_FILES"));
            }
            if ((_cmdMask & ProgramCmd.EXPORT_MSSQL) > 0)
            {
                _JobList.Add(new JobExportData(new ExportToMSSQL(), ProgramCmd.EXPORT_MSSQL, ProgramCmd.DB_DIR, "Directory", "MSSQL", "MSSQL_FILES"));
            }
            if ((_cmdMask & ProgramCmd.EXPORT_MYSQL) > 0)
            {
                _JobList.Add(new JobExportData(new ExportToMySQL(), ProgramCmd.EXPORT_MYSQL, ProgramCmd.DB_DIR, "Directory", "MYSQL", "MYSQL_FILES"));
            }

            //_inputPath = ini.IniReadValue("TableGenerate", "InputPath");
            _dllOutputPath = ini.IniReadValue("TableGenerate", "DllOutputPath").Replace("//", "/");
            _outputPath    = ini.IniReadValue("TableGenerate", "OutputPath").Replace("//", "/");
            _extType       = ini.IniReadValue("TableGenerate", "ExtType");
            _ignoreCase    = ini.IniReadValue("TableGenerate", "IgnoreCase");
            _enumFilePath  = ini.IniReadValue("Directory", "ENUMTYPES");
            System.Reflection.Assembly _Assembly = null;
            if (!string.IsNullOrEmpty(_enumFilePath))
            {
                StringBuilder sb = new StringBuilder();
                foreach (var text in System.IO.Directory.GetFiles(_enumFilePath, "*.cs"))
                {
                    sb.AppendLine(System.IO.File.ReadAllText(text));
                }
                _Assembly = CompileFiles(sb.ToString());
            }

            _except = ini.IniReadValue("TableGenerate", "Except").Split(',').Select(item => item.Trim().ToLower()).ToList();
            if (_except.Count() > 0)
            {
                _except.RemoveAll(compare => compare == string.Empty);
            }

            if (string.IsNullOrEmpty(_extType) == true)
            {
                _extType = ProgramCmd.EXT_TYPE;
            }
            if (string.IsNullOrEmpty(_lang) == true)
            {
                _lang = ini.IniReadValue("Default", "LANG");
            }
            if (string.IsNullOrEmpty(_version) == true)
            {
                _version = ini.IniReadValue("Default", "VERSION");
            }

            string modified = ini.IniReadValue("TableGenerate", "OnlyModifiedFile");

            if (modified.Length > 0 && modified.ToLower().Substring(0, 1) == "y")
            {
                _isWriteLog = true;
            }

            string impFiles = ini.IniReadValue("TableGenerate", "FILES");

            if (impFiles.Length > 0)
            {
                string[] impFileList = impFiles.Split(',');
                foreach (string file in impFileList)
                {
                    _impList.Add(file);
                }
            }


            for (int i = 0; i < _JobList.Count; i++)
            {
                var job = _JobList[i];
                job.SetEtc(_version, _lang, ini.IniReadValue("LANG", _lang + "_TBL"), ini.IniReadValue("LANG", _lang + "_SRC"), ini.IniReadValue("LANG", _lang + "_EXT"));
                job.SetDefaultDir(ini.IniReadValue("Default", job.GetItem()));
                bool sub_folder = ProgramCmd.single_file.Contains(System.IO.Path.DirectorySeparatorChar);
                if (_Assembly != null)
                {
                    job.SetEnumTypesAssembly(_Assembly);
                }
                if (sub_folder && (job.GetExportBase() is ExportToCS || job.GetExportBase() is ExportToCSMgr))
                {
                    job.SetDest(_outputPath, System.IO.Path.GetTempPath());
                }
                else if (sub_folder && job.GetExportBase() is ExportToTF)
                {
                    job.SetDest(_outputPath, ini.IniReadValue(job.GetSection(), job.GetItem()) + System.IO.Path.DirectorySeparatorChar + ProgramCmd.single_file.Substring(0, ProgramCmd.single_file.IndexOf(System.IO.Path.DirectorySeparatorChar)));
                }
                else
                {
                    job.SetDest(_outputPath, ini.IniReadValue(job.GetSection(), job.GetItem()));
                }
                if (job.GetFileItem() != null)
                {
                    job.SetExportFileList(ini.IniReadValue(job.GetSection(), job.GetFileItem()));
                }
                if (!job.IsExistedDir())
                {
                    System.Console.WriteLine("[{0}] Directory is not existed.", job.GetDestDir());
                    return(false);
                }
            }

            if (LoadXlsFileList() == 0)
            {
                System.Console.WriteLine("XLS File not found.");
                return(false);
            }

            {
                JobExportData eCS    = (JobExportData)GetJobItem(ProgramCmd.EXPORT_CS);
                JobExportData eCSMgr = (JobExportData)GetJobItem(ProgramCmd.EXPORT_CSMGR);
                JobExportData eTF    = (JobExportData)GetJobItem(ProgramCmd.EXPORT_TABLE);

                if (eCS != null)
                {
                    ((ExportToCS)eCS.GetExportBase()).SetAsync = this._async;
                }
                if (eTF != null && eCS != null)
                {
                    ((ExportToTF)eTF.GetExportBase()).CSFileDir    = eCS.GetDestDir();
                    ((ExportToTF)eTF.GetExportBase()).DllOutputDir = _dllOutputPath;
                    ((ExportToTF)eTF.GetExportBase()).EnumTypeDir  = _enumFilePath;
                }
                if (eCSMgr != null)
                {
                    var eCSMgrBase = eCSMgr.GetExportBase() as ExportToCSMgr;
                    if (eCSMgrBase != null)
                    {
                        eCSMgrBase.SetAsync = this._async;
                    }
                }
            }
            return(true);
        }
예제 #8
0
        private void SetIni(Parameter parameter)
        {
            //TODO Check if ini file exists

            Ini.IniFile ini = new IniFile("");

            ini = new Ini.IniFile(parameter.Path);

            List<string> iniSettings = parameter.GetSettings();

            ini.IniWriteValue(iniSettings[0], iniSettings[1], iniSettings[2]);
        }
예제 #9
0
        public IniFile ReadIni()
        {
            IniFile ini = new Ini.IniFile("sys.ini");
            if (ini.Exists())
            {
                ini.Load();
            }
            else
            {
                IniSection section = new IniSection();
                section.Add("startdate", "1-05-2011");
                section.Add("enddate", "15-05-2011");
                ini.Add("DATES", section);

                section = new IniSection();
                section.Add("email_user", "*****@*****.**");
                section.Add("email_password", "Paz.planner01");
                section.Add("email_from", "*****@*****.**");
                section.Add("email_host", "smtp.gmail.com");
                section.Add("email_port", "587");
                section.Add("email_onderwerp", "Afstudeerzitting(en)");
                ini.Add("EMAILSETTINGS", section);

                section = new IniSection();
                section.Add("this.DB_host", "student.aii.avans.nl");
                section.Add("this.DB_username", "MI4Ie");
                section.Add("this.DB_password", "4DRcUrzV");
                section.Add("this.DB_database", "MI4Ie_this.DB");
                ini.Add("DATABASESETTINGS", section);

                ini.Save();
            }

            return ini;
        }