コード例 #1
0
        public static byte[] SaveExPresetData(Maid maid)
        {
            if (!Enabled)
            {
                return(null);
            }

            Debug.Log("[PNGPreset] Saving ExtPreset data");

            // Since we save data using memory method, ExtPreset will fill the saved data using its temporary buffer
            var doc = getXmlMemory();

            if (doc == null)
            {
                return(null);
            }

            setXmlMemory(null);

            using (var ms = new MemoryStream())
            {
                doc.Save(ms);
                ms.Position = 0;
                var compressed = LZMA.Compress(ms);

                return(compressed);
            }
        }
コード例 #2
0
        public static void LoadExPresetData(Stream s, Maid maid)
        {
            if (!Enabled)
            {
                return;
            }

            using (var ds = LZMA.Decompress(s, PNGPreset.EXT_DATA_END_MAGIC.Length))
            {
                ds.Position = 0;
                var doc = new XmlDocument();
                doc.Load(ds);
                setXmlMemory(doc);
            }

            Debug.Log("[PNGPreset] Loading ExtPreset data");
            // If we load ex preset while using no file name, ExtPreset will use the temporary buffer
            loadExtPreset(maid, new CharacterMgr.Preset {
                strFileName = string.Empty
            });
            Debug.Log("[PNGPreset] ExtPreset data loaded");

            setXmlMemory(null);
        }