/// <summary> /// Try to load settings from client storage or init deafult one. /// </summary> public static void InitSettings() { settingsStorage = Api.Client.Storage.GetStorage("Mods/CNEI.Settings"); settingsStorage.RegisterType(typeof(ViewType)); settingsStorage.RegisterType(typeof(Settings)); if (!settingsStorage.TryLoad(out settingsInstance)) { // Default settings. settingsInstance.View = ViewType.Default; settingsInstance.DefaultViewPreset = new List <string>() { "ProtoCharacterMob", "ProtoItem", "ProtoObjectLoot", "ProtoObjectLootContainer", "ProtoObjectMineral", "ProtoObjectStructure", "ProtoObjectVegetation" }; settingsInstance.IsTypeVisibile = false; isSettingsChanged = true; } // Temp settings values to check if they changed. tempView = settingsInstance.View; IsTypeVisible = settingsInstance.IsTypeVisibile; ChangeCurrentView(); LoadDefaultViewFromSettings(); }
public static void LoadGlobalSettingsFromClientStorage() { settingsStorage = Api.Client.Storage.GetStorage("Mods/" + ModId + "/GlobalSettings"); settingsStorage.RegisterType(typeof(ViewType)); settingsStorage.RegisterType(typeof(Settings)); if (!settingsStorage.TryLoad(out settingsInstance)) { // Default settings. settingsInstance.View = ViewType.Default; settingsInstance.IsTypeVisible = false; settingsInstance.HideUnreachableObjects = true; isSettingsChanged = true; } // Temp settings values to check if they changed. tempView = settingsInstance.View; IsTypeVisible = settingsInstance.IsTypeVisible; HideUnreachableObjects = settingsInstance.HideUnreachableObjects; ChangeCurrentView(); }
public static void LoadDefaultViewPresetFromClientStorage() { defaultViewStorage = Api.Client.Storage.GetStorage("Mods/" + ModId + "/DefaultView"); bool settingExist = true; // Force reload preset if saved version is too old. if (VersionFromClientStorage.CompareTo(new Version("0.4.7")) < 0 || !defaultViewStorage.TryLoad(out defaultViewPresetFromSettings)) { // Default settings. defaultViewPresetFromSettings = new List <string>() { "ProtoCharacterMob", "ProtoItem", "ProtoObjectHackableContainer", "ProtoObjectLoot", "ProtoObjectLootContainer", "ProtoObjectMineral", "ProtoObjectStructure", "ProtoObjectVegetation", "ProtoStatusEffect", "ProtoVehicle" }; settingExist = false; } LoadDefaultViewFromSettings(); if (!settingExist) { defaultViewStorage.Save(defaultViewPresetFromSettings); } }
public HttpClientWrapper(HttpClient httpClient, JsonMediaTypeFormatter formatter, IClientStorage clientStorage, ApiRecorderSessionItemRepository apiRecorderSessionItemRepository) { _httpClient = httpClient; _clientStorage = clientStorage; _formatter = formatter; _apiRecorderSessionItemRepository = apiRecorderSessionItemRepository; }
static ClientComponentPhysicsSpaceVisualizer() { SessionStorage = Api.Client.Storage.GetSessionStorage( nameof(ClientComponentPhysicsSpaceVisualizer) + ".Settings"); SessionStorage.RegisterType(typeof(Settings)); SessionStorage.RegisterType(typeof(CollisionGroupId)); if (SessionStorage.TryLoad(out settingsInstance)) { EnabledLayers = settingsInstance.EnabledLayers; IsVisualizerEnabled = settingsInstance.IsVisualizerEnabled; } else { // set defaults settingsInstance.EnabledLayers = EnabledLayers = new HashSet <CollisionGroupId>() { CollisionGroupId.Default, CollisionGroupId.HitboxMelee, CollisionGroupId.HitboxRanged, CollisionGroupId.InteractionArea, CollisionGroupId.ClickArea }; } ServerOperatorSystem.ClientIsOperatorChanged += IsServerOperatorChangedHandler; }
public void RegisterStorage() { clientStorage = Api.Client.Storage.GetStorage(optionsStorageLocalFilePath); foreach (var option in optionsWithValue) { option.RegisterValueType(clientStorage); } }
public ViewModelConsoleControl(Action onFilterChanged) { this.onFilterChanged = onFilterChanged; this.sessionStorageFilterString = Api.Client.Storage.GetSessionStorage( $"{nameof(ViewModelConsoleControl)}.{nameof(this.FilterText)}"); this.sessionStorageFilterString.TryLoad(out this.filterString); }
public ReportLogicClient(IClientStorage clientStorage, IVisitStorage visitStorage, IPurchaseStorage purchaseStorage, IProcedureStorage procedureStorage, IDistributionStorage distributionStorage) { _clientStorage = clientStorage; _visitStorage = visitStorage; _purchaseStorage = purchaseStorage; _procedureStorage = procedureStorage; _distributionStorage = distributionStorage; }
static WelcomeMessageSystem() { if (Api.IsClient) { ClientStorageLastServerMessage = Api.Client.Storage.GetStorage("Servers/LastWelcomeMessages"); ClientStorageLastServerMessage.RegisterType(typeof(ServerAddress)); ClientStorageLastServerMessage.RegisterType(typeof(AtomicGuid)); } }
static ClientChatDisclaimerConfirmationHelper() { Storage = Api.Client.Storage.GetStorage("Servers/ConfirmedChatUsage"); Storage.RegisterType(typeof(ServerAddress)); Storage.RegisterType(typeof(AtomicGuid)); Api.Client.CurrentGame.ConnectionStateChanged += Refresh; Refresh(); }
public ToolsController(ISecurityService securityService, IEstablishmentReadService establishmentReadService, ICachedLookupService lookup, IClientStorage clientStorage, ILocalAuthoritySetRepository localAuthoritySetRepository, IEstablishmentDownloadService establishmentDownloadService) { _securityService = securityService; _establishmentReadService = establishmentReadService; _lookup = lookup; _clientStorage = clientStorage; _localAuthoritySetRepository = localAuthoritySetRepository; _establishmentDownloadService = establishmentDownloadService; }
static ClientCurrentCharacterLagPredictionManager() { SessionStorage = Api.Client.Storage.GetSessionStorage(nameof(ClientCurrentCharacterLagPredictionManager)); if (!SessionStorage.TryLoad(out isLagPredictionEnabled)) { // enabled by default isLagPredictionEnabled = true; } }
static ClientTileDecalHelper() { SessionStorage = Api.Client.Storage.GetSessionStorage( $"{nameof(ClientTileDecalHelper)}.{nameof(IsDecalsEnabled)}"); if (!SessionStorage.TryLoad(out isDecalsEnabled)) { isDecalsEnabled = true; } }
static ClientComponentPerformanceIndicatorsManager() { SessionStorage = Api.Client.Storage.GetSessionStorage( $"{nameof(HUDPerformanceIndicatorsPanel)}.{nameof(IsDisplayed)}"); if (!SessionStorage.TryLoad(out isDisplayed)) { // overlay is visible by default isDisplayed = true; } }
protected override void PrepareProto() { if (IsServer) { return; } this.clientStorage = Api.Client.Storage .GetStorage(this.OptionsStorageLocalFilePath); }
static ClientPostEffectsManager() { SessionStorage = Api.Client.Storage.GetSessionStorage( $"{nameof(ClientPostEffectsManager)}.{nameof(IsPostEffectsEnabled)}"); if (!SessionStorage.TryLoad(out isPostEffectsEnabled) && !Api.IsEditor) { // post-effects are enabled by default in non-Editor isPostEffectsEnabled = true; } }
/// <summary> /// Try to load IsEnbled from client storage. /// </summary> private static void LoadIsEnbledFromClientStorage() { // Load settings. isEnabledStorage = Api.Client.Storage.GetStorage("Mods/Automaton/IsEnabled"); if (!isEnabledStorage.TryLoad(out bool status)) { // Init default settings. status = false; } isEnabled = status; }
/// <summary> /// Try to load mod version from client storage. /// </summary> private static void LoadVersionFromClientStorage() { // Load settings. versionStorage = Api.Client.Storage.GetStorage("Mods/Automaton/Version"); versionStorage.RegisterType(typeof(Version)); versionStorage.TryLoad(out VersionFromClientStorage); // Version changes handeling. // if (VersionFromClientStorage.CompareTo(CurrentVersion) > 0) versionStorage.Save(CurrentVersion); }
static VehicleCustomNamingDataManager() { ClientStorage = Api.Client.Storage.GetStorage("Mods/VehicleCustomNaming/VehicleCustomNamingDataManager"); ClientStorage.RegisterType(typeof(Settings)); if (ClientStorage.TryLoad(out settingsInstance)) { RenamedVehicles = settingsInstance.SavedRenamedVehicles; } else { settingsInstance.SavedRenamedVehicles = RenamedVehicles = new Dictionary <uint, string>(); } }
static ClientPostEffectsManager() { SessionStorage = Api.Client.Storage.GetSessionStorage( $"{nameof(ClientPostEffectsManager)}.{nameof(IsPostEffectsEnabled)}"); if (!SessionStorage.TryLoad(out isPostEffectsEnabled) && !Api.IsEditor) { // post-effects are enabled by default in non-Editor isPostEffectsEnabled = true; } ServerOperatorSystem.ClientIsOperatorChanged += IsServerOperatorChangedHandler; }
static NewGamePlusSystem() { if (IsServer) { return; } ClientStoredCharacterData = Api.Client.Storage.GetSessionStorage( nameof(NewGamePlus) + ".Settings"); ClientStoredCharacterData.RegisterType(typeof(CharacterProgressData)); ClientStoredCharacterData.RegisterType(typeof(CharacterHumanFaceStyle)); BootstrapperClientGame.InitCallback += ClientInitCallbackHandler; }
static EditorTerrainCopyPasteHelper() { if (!Api.IsClient) { return; } ClientStorage = Api.Client.Storage.GetStorage("Editor/" + nameof(EditorTerrainCopyPasteHelper)); ClientStorage.RegisterType(typeof(Vector2Ushort)); ClientStorage.RegisterType(typeof(TerrainEditingSystem.TileModifyRequest)); ClientStorage.RegisterType(typeof(BufferEntry)); TryLoadBufferEntry(); }
static EditorStaticObjectsCopyPasteHelper() { if (!Api.IsClient) { return; } ClientStorage = Api.Client.Storage.GetStorage("Editor/" + nameof(EditorStaticObjectsCopyPasteHelper)); ClientStorage.RegisterType(typeof(Vector2Ushort)); ClientStorage.RegisterType(typeof(SpawnObjectRequest)); ClientStorage.RegisterType(typeof(BufferEntry)); TryLoadBufferEntry(); }
static ComponentLagPredictionVisualizer() { SessionStorage = Api.Client.Storage.GetSessionStorage( $"{nameof(ComponentLagPredictionVisualizer)}.{nameof(IsVisualizerEnabled)}"); SessionStorage.TryLoad(out isVisualizerEnabled); ClientCurrentCharacterLagPredictionManager.IsLagPredictionEnabledChanged += () => { if (!ClientCurrentCharacterLagPredictionManager.IsLagPredictionEnabled) { DestroyInstance(); } }; }
/// <summary> /// Try to load mod version from client storage. /// </summary> private static void LoadVersionFromClientStorage() { // Load settings. versionStorage = Api.Client.Storage.GetStorage("Mods/" + ModId + "/Version"); versionStorage.RegisterType(typeof(Version)); if (!versionStorage.TryLoad(out VersionFromClientStorage)) { VersionFromClientStorage = new Version("0.0.1"); } // Version changes handling. // if (VersionFromClientStorage.CompareTo(CurrentVersion) > 0) // Or should I wait until all migration work is done? versionStorage.Save(CurrentVersion); }
protected ProtoOptionsCategory() { var name = this.GetType().Name; // ReSharper disable once CanExtractXamlLocalizableStringCSharp name = name.Replace("OptionsCategory", string.Empty); this.ShortId = name; if (IsClient) { this.Icon = new TextureResource($"Options/{name}.png", qualityOffset: -100); this.OptionsStorageLocalFilePath = "Options/" + this.ShortId; this.clientStorage = Api.Client.Storage .GetStorage(this.OptionsStorageLocalFilePath); } }
static ClientInputManager() { // create storage var storage = Api.Client.Storage.GetStorage(InputSettingsStorageFilePath); storage.RegisterType(typeof(InputKey)); storage.RegisterType(typeof(ButtonMapping)); storage.RegisterType(typeof(InputMappingSnapshot)); Storage = storage; // register default buttons enum RegisterButtonsEnum <GameButton>(); // create input updater (updated every frame) Api.Client.Scene.CreateSceneObject(nameof(ClientComponentInputManagerUpdater)) .AddComponent <ClientComponentInputManagerUpdater>(); }
/// <summary> /// Try to load settings from client storage or init deafult one. /// </summary> private static void LoadSettings() { settingsStorage = Api.Client.Storage.GetStorage("Mods/Automaton.Settings"); settingsStorage.RegisterType(typeof(Settings)); if (!settingsStorage.TryLoad(out settingsInstance)) { // Init default settings. (All disabled by default) settingsInstance.IsEnabled = false; settingsInstance.Features = FeaturesDictionary.ToDictionary(p => p.Key, p => new List <string>()); // TODO: May be add default options in ProtoFeature } foreach (KeyValuePair <string, ProtoFeature> pair in FeaturesDictionary) { if (!settingsInstance.Features.ContainsKey(pair.Key)) { settingsInstance.Features.Add(pair.Key, new List <string>()); } pair.Value.LoadSettings(settingsInstance.Features[pair.Key]); } }
public void Load() { this.markers.Clear(); this.markStorageLocalFilePath = "Mods/MapMarkers/" + Api.Client.CurrentGame.ServerInfo.ServerAddress.PublicGuid.ToString(); clientStorage = Api.Client.Storage.GetStorage(markStorageLocalFilePath); clientStorage.RegisterType(typeof(CustomMarkData)); clientStorage.RegisterType(typeof(Vector2D)); if (!clientStorage.TryLoad <List <CustomMarkData> >(out var snapshot)) { return; } foreach (var mark in snapshot) { this.AddMarker((CustomMarkData)mark, false, false, false); } this.OnMarkListChanged(true); }
public BasketController(Api application, QueryService query_service, IClientStorage client_storage) { _application = application; _query_service = query_service; _client_storage = client_storage; }