public StudyInformation FileReader() { var parser = new IniFileParser.IniFileParser(); var data = parser.ReadFile(FullFilePath); if (!SectionsExist(data)) { return(null); } var studyParameters = data["PARAMETERS"]; var bottlesInformation = data["BOTTLES"]; if (!AllNeededParametersExist(studyParameters)) { return(null); } SetValuesToStudyInfoParameters(studyParameters, out var studyInfo); if (BottlesExist(bottlesInformation, out var bottleCount)) { SetValuesToAllBottles(bottlesInformation, bottleCount, out var containers); studyInfo.Containers = containers; } studyInfo.ContainerCount = bottleCount; return(studyInfo); }
public static void Initialize() { Parser = new IniFileParser.IniFileParser(); Bindings = new Dictionary <string, Keys>(); Get = Parser.ReadFile("config.ini"); AddBindings(); }
private static void LoadConfigs(string skinFolder) { IniFileParser.IniFileParser parser = new IniFileParser.IniFileParser(); Configs.Add("skin", parser.ReadFile($"{skinFolder}skin.ini")); Configs.Add("gameplay", parser.ReadFile($"{skinFolder}Gameplay/gameplay.ini")); Configs.Add("main_menu", parser.ReadFile($"{skinFolder}UI/MainMenu/main_menu.ini")); Configs.Add("judgements", parser.ReadFile($"{skinFolder}Judgements/judgements.ini")); Configs.Add("result_screen", parser.ReadFile($"{skinFolder}UI/ResultScreen/result_screen.ini")); Configs.Add("song_select", parser.ReadFile($"{skinFolder}UI/SongSelect/song_select.ini")); Configs.Add("audio", parser.ReadFile($"{skinFolder}Audio/audio.ini")); }
/// <summary> /// Loads up the config file and its default elements. /// </summary> private void LoadConfig() { const string name = "skin.ini"; if (!File.Exists($"{Dir}/{name}")) { return; } Config = new IniFileParser.IniFileParser().ReadFile($"{Dir}/{name}"); // Parse very general things in config. Name = ConfigHelper.ReadString(Name, Config["General"]["Name"]); Author = ConfigHelper.ReadString(Author, Config["General"]["Author"]); Version = ConfigHelper.ReadString(Version, Config["General"]["Version"]); }
private void MoveFilesWithErrors(int errorFileCounter, string pathToFile) { var filesWithError = Path.Combine(_logFilePath, "FilesWithErrors"); if (!Directory.Exists(filesWithError)) { Directory.CreateDirectory(filesWithError); } var parser = new IniFileParser.IniFileParser(); var oldData = parser.ReadFile(pathToFile); var newFilePath = Path.Combine(filesWithError, "fileWithError" + errorFileCounter + "_at" + DateTime.Now.ToString("yyyyMMdd") + ".txt"); if (!File.Exists(newFilePath)) { File.Create(newFilePath); } //TODO! add an appropriate method to write INI file ----------> parser.WriteFile(newFilePath, oldData); File.Delete(pathToFile); }
/// <summary> /// Reads a quaver.cfg file and sets all of the successfully read values. /// At the end of reading, we write the config file, changing any invalid data/ /// </summary> private static void ReadConfigFile() { // We'll want to write a quaver.cfg file if it doesn't already exist. // There's no need to read the config file afterwards, since we already have // all of the default values. if (!File.Exists(_gameDirectory + "/quaver.cfg")) { File.WriteAllText(_gameDirectory + "/quaver.cfg", "; Quaver Configuration File"); } var data = new IniFileParser.IniFileParser().ReadFile(_gameDirectory + "/quaver.cfg")["Config"]; // Read / Set Config Values // NOTE: MAKE SURE TO SET THE VALUE TO AUTO-SAVE WHEN CHANGING! THIS ISN'T DONE AUTOMATICALLY. // YOU CAN DO THIS DOWN BELOW, AFTER THE CONFIG HAS WRITTEN FOR THE FIRST TIME. GameDirectory = ReadSpecialConfigType(SpecialConfigType.Directory, @"GameDirectory", _gameDirectory, data); SkinDirectory = ReadSpecialConfigType(SpecialConfigType.Directory, @"SkinDirectory", _skinDirectory, data); ScreenshotDirectory = ReadSpecialConfigType(SpecialConfigType.Directory, @"ScreenshotDirectory", _screenshotDirectory, data); ReplayDirectory = ReadSpecialConfigType(SpecialConfigType.Directory, @"ReplayDirectory", _replayDirectory, data); LogsDirectory = ReadSpecialConfigType(SpecialConfigType.Directory, @"LogsDirectory", _logsDirectory, data); DataDirectory = ReadSpecialConfigType(SpecialConfigType.Directory, @"DataDirectory", _dataDirectory, data); SongDirectory = ReadSpecialConfigType(SpecialConfigType.Directory, @"SongDirectory", _songDirectory, data); SelectedGameMode = ReadValue(@"SelectedGameMode", GameMode.Keys4, data); Username = ReadValue(@"Username", "Player", data); VolumeGlobal = ReadInt(@"VolumeGlobal", 50, 0, 100, data); VolumeEffect = ReadInt(@"VolumeEffect", 20, 0, 100, data); VolumeMusic = ReadInt(@"VolumeMusic", 50, 0, 100, data); BackgroundBrightness = ReadInt(@"BackgroundBrightness", 50, 0, 100, data); WindowHeight = ReadInt(@"WindowHeight", 768, 600, short.MaxValue, data); WindowWidth = ReadInt(@"WindowWidth", 1366, 800, short.MaxValue, data); DisplaySongTimeProgress = ReadValue(@"DisplaySongTimeProgress", true, data); WindowFullScreen = ReadValue(@"WindowFullScreen", false, data); FpsCounter = ReadValue(@"FpsCounter", false, data); FpsLimiterType = ReadValue(@"FpsLimiterType", FpsLimitType.Unlimited, data); CustomFpsLimit = ReadInt(@"CustomFPSLimit", 240, 60, int.MaxValue, data); ScrollSpeed4K = ReadInt(@"ScrollSpeed4K", 15, 0, 100, data); ScrollSpeed7K = ReadInt(@"ScrollSpeed7K", 15, 0, 100, data); DownScroll4K = ReadValue(@"DownScroll4K", true, data); DownScroll7K = ReadValue(@"DownScroll7K", true, data); GlobalAudioOffset = ReadInt(@"GlobalAudioOffset", 0, int.MinValue, int.MaxValue, data); Skin = ReadSpecialConfigType(SpecialConfigType.Skin, @"Skin", "", data); DefaultSkin = ReadValue(@"DefaultSkin", DefaultSkins.Bar, data); Pitched = ReadValue(@"Pitched", true, data); ScoreboardVisible = ReadValue(@"ScoreboardVisible", true, data); AnimateJudgementCounter = ReadValue(@"AnimateJudgementCounter", true, data); SelectOrderMapsetsBy = ReadValue(@"SelectOrderMapsetsBy", OrderMapsetsBy.Artist, data); SelectedOnlineUserFilterType = ReadValue(@"OnlineUserFilterType", OnlineUserFilterType.All, data); LeaderboardSection = ReadValue(@"LeaderboardSection", LeaderboardType.Local, data); OsuDbPath = ReadSpecialConfigType(SpecialConfigType.Path, @"OsuDbPath", "", data); AutoLoadOsuBeatmaps = ReadValue(@"AutoLoadOsuBeatmaps", false, data); AutoLoginToServer = ReadValue(@"AutoLoginToServer", true, data); DisplayTimingLines = ReadValue(@"DisplayTimingLines", true, data); DisplayMenuAudioVisualizer = ReadValue(@"DisplayMenuAudioVisualizer", true, data); EnableHitsounds = ReadValue(@"EnableHitsounds", true, data); KeyMania4K1 = ReadValue(@"KeyMania4K1", Keys.A, data); KeyMania4K2 = ReadValue(@"KeyMania4K2", Keys.S, data); KeyMania4K3 = ReadValue(@"KeyMania4K3", Keys.K, data); KeyMania4K4 = ReadValue(@"KeyMania4K4", Keys.L, data); KeyMania7K1 = ReadValue(@"KeyMania7K1", Keys.A, data); KeyMania7K2 = ReadValue(@"KeyMania7K2", Keys.S, data); KeyMania7K3 = ReadValue(@"KeyMania7K3", Keys.D, data); KeyMania7K4 = ReadValue(@"KeyMania7K4", Keys.Space, data); KeyMania7K5 = ReadValue(@"KeyMania7K5", Keys.J, data); KeyMania7K6 = ReadValue(@"KeyMania7K6", Keys.K, data); KeyMania7K7 = ReadValue(@"KeyMania7K7", Keys.L, data); KeySkipIntro = ReadValue(@"KeySkipIntro", Keys.RightAlt, data); KeyPause = ReadValue(@"KeyPause", Keys.Escape, data); KeyToggleOverlay = ReadValue(@"KeyToggleOverlay", Keys.F8, data); KeyRestartMap = ReadValue(@"KeyRestartMap", Keys.OemTilde, data); KeyDecreaseScrollSpeed = ReadValue(@"KeyDecreaseScrollSpeed", Keys.F3, data); KeyIncreaseScrollSpeed = ReadValue(@"KeyIncreaseScrollSpeed", Keys.F4, data); KeyScoreboardVisible = ReadValue(@"KeyHideScoreboard", Keys.Tab, data); KeyQuickExit = ReadValue(@"KeyQuickExit", Keys.F1, data); // Have to do this manually. if (string.IsNullOrEmpty(Username.Value)) { Username.Value = "Player"; } // Write the config file with all of the changed/invalidated data. Task.Run(async() => await WriteConfigFileAsync()) .ContinueWith(t => { // SET AUTO-SAVE FUNCTIONALITY FOR EACH BINDED VALUE. // This is so shit tbcfh, lol. GameDirectory.ValueChanged += AutoSaveConfiguration; SkinDirectory.ValueChanged += AutoSaveConfiguration; ScreenshotDirectory.ValueChanged += AutoSaveConfiguration; ReplayDirectory.ValueChanged += AutoSaveConfiguration; LogsDirectory.ValueChanged += AutoSaveConfiguration; DataDirectory.ValueChanged += AutoSaveConfiguration; SongDirectory.ValueChanged += AutoSaveConfiguration; OsuDbPath.ValueChanged += AutoSaveConfiguration; AutoLoadOsuBeatmaps.ValueChanged += AutoSaveConfiguration; Username.ValueChanged += AutoSaveConfiguration; VolumeGlobal.ValueChanged += AutoSaveConfiguration; VolumeEffect.ValueChanged += AutoSaveConfiguration; VolumeMusic.ValueChanged += AutoSaveConfiguration; BackgroundBrightness.ValueChanged += AutoSaveConfiguration; WindowHeight.ValueChanged += AutoSaveConfiguration; WindowWidth.ValueChanged += AutoSaveConfiguration; WindowFullScreen.ValueChanged += AutoSaveConfiguration; FpsCounter.ValueChanged += AutoSaveConfiguration; FpsLimiterType.ValueChanged += AutoSaveConfiguration; CustomFpsLimit.ValueChanged += AutoSaveConfiguration; DisplaySongTimeProgress.ValueChanged += AutoSaveConfiguration; ScrollSpeed4K.ValueChanged += AutoSaveConfiguration; ScrollSpeed7K.ValueChanged += AutoSaveConfiguration; DownScroll4K.ValueChanged += AutoSaveConfiguration; DownScroll7K.ValueChanged += AutoSaveConfiguration; GlobalAudioOffset.ValueChanged += AutoSaveConfiguration; Skin.ValueChanged += AutoSaveConfiguration; DefaultSkin.ValueChanged += AutoSaveConfiguration; Pitched.ValueChanged += AutoSaveConfiguration; ScoreboardVisible.ValueChanged += AutoSaveConfiguration; AutoLoginToServer.ValueChanged += AutoSaveConfiguration; DisplayTimingLines.ValueChanged += AutoSaveConfiguration; DisplayMenuAudioVisualizer.ValueChanged += AutoSaveConfiguration; EnableHitsounds.ValueChanged += AutoSaveConfiguration; KeyMania4K1.ValueChanged += AutoSaveConfiguration; KeyMania4K2.ValueChanged += AutoSaveConfiguration; KeyMania4K3.ValueChanged += AutoSaveConfiguration; KeyMania4K4.ValueChanged += AutoSaveConfiguration; KeyMania7K1.ValueChanged += AutoSaveConfiguration; KeyMania7K2.ValueChanged += AutoSaveConfiguration; KeyMania7K3.ValueChanged += AutoSaveConfiguration; KeyMania7K4.ValueChanged += AutoSaveConfiguration; KeyMania7K5.ValueChanged += AutoSaveConfiguration; KeyMania7K6.ValueChanged += AutoSaveConfiguration; KeyMania7K7.ValueChanged += AutoSaveConfiguration; KeySkipIntro.ValueChanged += AutoSaveConfiguration; KeyPause.ValueChanged += AutoSaveConfiguration; KeyToggleOverlay.ValueChanged += AutoSaveConfiguration; KeyRestartMap.ValueChanged += AutoSaveConfiguration; KeyIncreaseScrollSpeed.ValueChanged += AutoSaveConfiguration; KeyDecreaseScrollSpeed.ValueChanged += AutoSaveConfiguration; KeyScoreboardVisible.ValueChanged += AutoSaveConfiguration; AnimateJudgementCounter.ValueChanged += AutoSaveConfiguration; SelectOrderMapsetsBy.ValueChanged += AutoSaveConfiguration; KeyQuickExit.ValueChanged += AutoSaveConfiguration; SelectedGameMode.ValueChanged += AutoSaveConfiguration; SelectedOnlineUserFilterType.ValueChanged += AutoSaveConfiguration; }); }
/// <summary> /// Language files should be setup similar to ini. /// /// Key=Value /// /// Examples: /// * (in en.txt) - Greeting=Hello /// * (in es.txt) - Greeting=¡Hola! /// </summary> /// <returns></returns> private static IniData ParseLanguageFile(Stream file) { var parser = new IniFileParser.IniFileParser(); return(parser.ReadData(new StreamReader(file))); }