public new static void ResetHeavy() { if (!ValuesStorage.Contains(CmPreviewsSettingsValues.DefaultKey)) { return; } try { var data = JsonConvert.DeserializeObject <SaveableData>(ValuesStorage.Get <string>(CmPreviewsSettingsValues.DefaultKey)); data.Width = CommonAcConsts.PreviewWidth; data.Height = CommonAcConsts.PreviewHeight; data.SsaaMode = 1; data.MsaaMode = 0; data.SsaaMode = 1; data.ShadowMapSize = 2048; data.CubemapReflectionMapSize = 1024; data.CubemapReflectionFacesPerFrame = 2; data.UsePcss = false; data.UseSslr = false; data.UseAo = false; data.UseDof = false; data.UseAccumulationDof = false; data.FlatMirrorBlurred = false; ValuesStorage.Set(CmPreviewsSettingsValues.DefaultKey, JsonConvert.SerializeObject(data)); } catch (Exception e) { Logging.Warning(e); } }
private SteamIdHelper(string forced) { if (IsValidSteamId(forced)) { _value = forced; _loaded = true; SetSteamIdInner(_value); } else { if (forced != null) { Logging.Warning($"Invalid forced value: “{forced}”"); } else { if (ValuesStorage.Contains(Key)) { var loaded = ValuesStorage.Get <string>(Key); _value = loaded == NoneValue ? null : loaded; _loaded = true; SetSteamIdInner(_value); } } } }
private AcRootDirectory(string directory) { if (!ValuesStorage.Contains(Key)) IsFirstRun = true; Value = (directory ?? ValuesStorage.Get<string>(Key))?.Trim(); if (Value == null || CheckDirectory(Value)) return; Logging.Warning($"AC root directory “{Value}” is not valid anymore"); Value = null; }
private static List <StoredPassword> LoadList() { try { if (ValuesStorage.Contains(KeyPasswords)) { return(JsonConvert.DeserializeObject <List <StoredPassword> >(ValuesStorage.GetEncryptedString(KeyPasswords))); } } catch (Exception e) { Logging.Warning(e); } return(new List <StoredPassword>()); }
private AcRootDirectory(string directory) { if (!ValuesStorage.Contains(Key)) { IsFirstRun = true; } Value = directory ?? ValuesStorage.GetString(Key); if (Value == null || CheckDirectory(Value)) { return; } Logging.Warning($"AC root directory “{Value}” is not valid anymore"); Value = null; }
public static void Revert() { if (!ValuesStorage.Contains(KeyModifiedIds)) { return; } foreach (var car in ValuesStorage.GetStringList(KeyModifiedIds).Select(x => CarsManager.Instance.GetById(x)).NonNull()) { if (car.SetCustomData(false)) { Logging.Write("Original data is reverted: " + car); } else { Logging.Warning("Failed to revert original data: " + car); } } ValuesStorage.Remove(KeyModifiedIds); }
public AppWindowItem(PythonAppWindow window) { _key = "AppIconEditor.Stored:" + window.DisplayName; Window = window; IsInEditMode = !File.Exists(window.IconOff); FontFamily = new FontFamily("Segoe UI"); LabelText = _defaultLabelText = window.DisplayName.Where((x, i) => i == 0 || char.IsWhiteSpace(window.DisplayName[i - 1])) .Take(3).JoinToString().ToUpper(); if (ValuesStorage.Contains(_key)) { try { JsonConvert.PopulateObject(ValuesStorage.Get <string>(_key), this); } catch (Exception e) { NonfatalError.NotifyBackground("Can’t load previous values", e); } } }
public AmbientShadowParams() { if (ValuesStorage.Contains(KeyOldSavedData) && !ValuesStorage.Contains(KeySavedData)) { ValuesStorage.Set(KeySavedData, ValuesStorage.Get <string>(KeyOldSavedData)); } _saveable = new SaveHelper <SaveableData>(KeySavedData, () => new SaveableData { AmbientShadowDiffusion = Diffusion, AmbientShadowBrightness = Brightness, AmbientShadowIterations = Iterations, AmbientShadowHideWheels = HideWheels, AmbientShadowFade = Fade, AmbientShadowCorrectLighting = CorrectLighting, AmbientShadowPoissonSampling = PoissonSampling, AmbientShadowExtraBlur = ExtraBlur, AmbientShadowUpDelta = UpDelta, AmbientShadowBodyMultiplier = BodyMultiplier, AmbientShadowWheelMultiplier = WheelMultiplier, }, Load); _saveable.Initialize(); }
public static string Open([NotNull] OpenDialogParams p, string currentFilename = null) { var key = p.ActualSaveKey; var cached = p.ActualSaveKey + @":cached"; try { if (p.UseCachedIfAny && ValuesStorage.Contains(cached) && File.Exists(ValuesStorage.Get <string>(cached))) { return(ValuesStorage.Get <string>(cached)); } } catch (Exception e) { Logging.Warning(e); } try { var filters = p.GetFilters().ToList(); var dialog = new OpenFileDialog { Filter = string.Join("|", filters.Select(x => x.WinFilter)), CheckFileExists = p.CheckFileExists, RestoreDirectory = p.RestoreDirectory, DereferenceLinks = p.DereferenceLinks, ValidateNames = p.ValidateNames, }; var extension = p.DetaultExtension ?? filters[0].BaseExtension; if (extension != null) { dialog.DefaultExt = extension; } if (p.Title != null) { dialog.Title = p.Title; } var initial = key == null ? p.InitialDirectory : ValuesStorage.Get(key, p.InitialDirectory); if (initial != null) { dialog.InitialDirectory = initial; } foreach (var place in p.CustomPlaces) { dialog.CustomPlaces.Add(place); } if (currentFilename != null) { dialog.InitialDirectory = Path.GetDirectoryName(currentFilename) ?? ""; dialog.FileName = Path.GetFileNameWithoutExtension(currentFilename); } if (dialog.ShowDialog() != true) { return(null); } if (key != null) { ValuesStorage.Set(key, Path.GetDirectoryName(dialog.FileName)); } if (p.UseCachedIfAny) { ValuesStorage.Set(cached, dialog.FileName); } return(dialog.FileName); } catch (Exception e) { NonfatalError.NotifyBackground("Can’t use Open File Dialog properly", e); return(OpenFallback(key)); } }