Пример #1
0
        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();
        }
Пример #2
0
        /// <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();
        }
        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;
        }
 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();
        }
Пример #6
0
        static NewGamePlusSystem()
        {
            if (IsServer)
            {
                return;
            }

            ClientStoredCharacterData = Api.Client.Storage.GetSessionStorage(
                nameof(NewGamePlus) + ".Settings");
            ClientStoredCharacterData.RegisterType(typeof(CharacterProgressData));
            ClientStoredCharacterData.RegisterType(typeof(CharacterHumanFaceStyle));
            BootstrapperClientGame.InitCallback += ClientInitCallbackHandler;
        }
Пример #7
0
        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();
        }
Пример #8
0
        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();
        }
Пример #9
0
        /// <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);
        }
Пример #10
0
 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>();
     }
 }
Пример #11
0
        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);
        }
Пример #12
0
        /// <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);
        }
Пример #13
0
        /// <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]);
            }
        }
Пример #14
0
 public override void RegisterValueType(IClientStorage storage)
 {
     storage.RegisterType(typeof(TEnumValue));
 }
Пример #15
0
 static LandClaimDecayInfoConfirmationHelper()
 {
     Storage = Api.Client.Storage.GetStorage("Servers/ConfirmedDecayInfo");
     Storage.RegisterType(typeof(ServerAddress));
     Storage.RegisterType(typeof(AtomicGuid));
 }