Пример #1
0
        /// <summary>
        /// Load the mod save data. Loads the save data from {UserIO.GetSavePath("Saves")}/{SaveData.GetFilename(index)}-modsave-{Metadata.Name}.celeste by default.
        /// </summary>
        public virtual void LoadSaveData(int index)
        {
            if (SaveDataType == null)
            {
                return;
            }

            _SaveData       = (EverestModuleSaveData)SaveDataType.GetConstructor(Everest._EmptyTypeArray).Invoke(Everest._EmptyObjectArray);
            _SaveData.Index = index;

            string path = patch_UserIO.GetSaveFilePath(patch_SaveData.GetFilename(index) + "-modsave-" + Metadata.Name);

            if (!File.Exists(path))
            {
                return;
            }

            try {
                using (Stream stream = File.OpenRead(path)) {
                    if (_SaveData is EverestModuleBinarySaveData)
                    {
                        using (BinaryReader reader = new BinaryReader(stream))
                            ((EverestModuleBinarySaveData)_SaveData).Read(reader);
                    }
                    else
                    {
                        using (StreamReader reader = new StreamReader(stream))
                            YamlHelper.DeserializerUsing(_SaveData).Deserialize(reader, SaveDataType);
                    }
                }
                _SaveData.Index = index;
            } catch {
            }
        }
Пример #2
0
        /// <summary>
        /// Load the mod save data. Loads the save data from {Everest.PathSettings}/Save{index}/{Metadata.Name}.yaml by default.
        /// </summary>
        public virtual void LoadSaveData(int index)
        {
            if (SaveDataType == null)
            {
                return;
            }
            string path = Path.Combine(Everest.PathSettings, "Save" + index, Metadata.Name + ".yaml");

            if (!File.Exists(path))
            {
                _SaveData = (EverestModuleSaveData)SaveDataType.GetConstructor(Everest._EmptyTypeArray).Invoke(Everest._EmptyObjectArray);
                return;
            }
            using (Stream stream = File.OpenRead(path))
                using (StreamReader reader = new StreamReader(path))
                    _SaveData = (EverestModuleSaveData)YamlHelper.Deserializer.Deserialize(reader, SaveDataType);
        }
Пример #3
0
        /// <summary>
        /// Load the mod save data. Loads the save data from {Everest.PathSettings}/Save{index}/{Metadata.Name}.yaml by default.
        /// </summary>
        public virtual void LoadSaveData(int index)
        {
            if (SaveDataType == null)
            {
                return;
            }

            _SaveData       = (EverestModuleSaveData)SaveDataType.GetConstructor(Everest._EmptyTypeArray).Invoke(Everest._EmptyObjectArray);
            _SaveData.Index = index;

            string extension = ".yaml";

            if (_SaveData is EverestModuleBinarySaveData)
            {
                extension = ".bin";
            }

            string path = Path.Combine(Everest.PathSettings, "Save" + index, Metadata.Name + extension);

            if (!File.Exists(path))
            {
                return;
            }

            try {
                using (Stream stream = File.OpenRead(path)) {
                    if (_SaveData is EverestModuleBinarySaveData)
                    {
                        // .bin
                        using (BinaryReader reader = new BinaryReader(stream))
                            ((EverestModuleBinarySaveData)_SaveData).Read(reader);
                    }
                    else
                    {
                        // .yaml
                        using (StreamReader reader = new StreamReader(path)) {
                            _SaveData       = (EverestModuleSaveData)YamlHelper.Deserializer.Deserialize(reader, SaveDataType);
                            _SaveData.Index = index;
                        }
                    }
                }
            } catch {
            }
        }
Пример #4
0
                internal static void HandleCreateButtons(List <patch_OuiFileSelectSlot.Button> buttons, OuiFileSelectSlot slot, bool fileExists)
                {
                    if (OnCreateButtons == null)
                    {
                        return;
                    }

                    foreach (Delegate del in OnCreateButtons.GetInvocationList())
                    {
                        // find the Everest module this delegate belongs to, and load the mod save data from it for the current slot.
                        EverestModule         matchingModule = _Modules.Find(module => module.GetType().Assembly == del.Method.DeclaringType.Assembly);
                        EverestModuleSaveData modSaveData    = null;
                        if (matchingModule != null)
                        {
                            modSaveData = matchingModule._SaveData;
                        }

                        // call the delegate.
                        del.DynamicInvoke(new object[] { buttons, slot, modSaveData, fileExists });
                    }
                }