public void SyncIndependentConfigFromDisk() { IndependentConfig independentConfig = null; try { independentConfig = JsonConvert.DeserializeObject <IndependentConfig>(File.ReadAllText(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "AstroModLoader", "config.json"))); } catch { independentConfig = null; } if (independentConfig != null) { if (!string.IsNullOrEmpty(independentConfig.AccentColor)) { try { AMLPalette.AccentColor = AMLUtils.ColorFromHTML(independentConfig.AccentColor); } catch { } } AMLPalette.CurrentTheme = independentConfig.Theme; AMLPalette.RefreshTheme(BaseForm); Platform = independentConfig.Platform; if (FirstRecordedIndependentConfigPlatform == PlatformType.Unknown) { FirstRecordedIndependentConfigPlatform = independentConfig.Platform; } if (!string.IsNullOrEmpty(independentConfig.CustomBasePath)) { CustomBasePath = independentConfig.CustomBasePath; } if (!string.IsNullOrEmpty(independentConfig.PlayFabCustomID)) { PlayFabAPI.CustomID = independentConfig.PlayFabCustomID; } if (!string.IsNullOrEmpty(independentConfig.PlayFabToken)) { PlayFabAPI.Token = independentConfig.PlayFabToken; } } }
public void SyncIndependentConfigToDisk() { var newIndConfig = new IndependentConfig(); if (Program.CommandLineOptions.ServerMode) { newIndConfig.Platform = FirstRecordedIndependentConfigPlatform; } else { newIndConfig.Platform = Platform; } newIndConfig.Theme = AMLPalette.CurrentTheme; newIndConfig.AccentColor = AMLUtils.ColorToHTML(AMLPalette.AccentColor); newIndConfig.CustomBasePath = CustomBasePath; newIndConfig.PlayFabCustomID = PlayFabAPI.CustomID; newIndConfig.PlayFabToken = PlayFabAPI.Token; Directory.CreateDirectory(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "AstroModLoader")); File.WriteAllBytes(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "AstroModLoader", "config.json"), Encoding.UTF8.GetBytes(AMLUtils.SerializeObject(newIndConfig))); }