示例#1
0
        public bool SaveChain(string path, List <int> headerIndices)
        {
            //save plugins to temp
            ChainChompApplication.FlushTempDir();

            for (int i = 0; i < plugins.Count(); i++)
            {
                if (!plugins[i].SaveSettings(ChainChompApplication.tempPath + plugins[i].ToString() + i + ".donut"))
                {
                    return(false);
                }
            }

            //save offsets & backgrounds
            ChainSettings settings = new ChainSettings();

            settings.Store(startOffset, endOffset, headerIndices);
            if (!FileIO.Write(ChainChompApplication.tempPath + "vanilla.dome", settings, typeof(ChainSettings)))
            {
                return(false);
            }

            //zip files to destination
            if (File.Exists(path))
            {
                File.Delete(path);
            }
            ZipFile.CreateFromDirectory(ChainChompApplication.tempPath, path);
            name = Path.GetFileName(path);

            return(true);
        }
示例#2
0
        public void LoadChain(string path)
        {
            //extract to
            DirectoryInfo temp = ChainChompApplication.ExtractToTemp(path);

            if (temp == null)
            {
                return;
            }

            foreach (FileInfo file in temp.EnumerateFiles("*.donut"))
            {
                Plugin p = new Plugin(file.FullName);
                plugins.Add(p);
            }

            ChainSettings settings = (ChainSettings)FileIO.Read(ChainChompApplication.tempPath + "vanilla.dome", typeof(ChainSettings));

            if (settings != null)
            {
                startOffset   = settings.start;
                endOffset     = settings.end;
                name          = Path.GetFileName(path);
                headerIndices = settings.headerIndices;
            }
        }
示例#3
0
        private PluginManager()
        {
            //populate dictionary
            _plugins = new List <IChainChompCorruptor>();
            ICollection <IChainChompCorruptor> loadedPlugins = LoadPlugins(pluginPath);

            loadedPlugins.ToList().ForEach(item =>
            {
                //found a plugin! stick it in the list
                _plugins.Add(item);

                //check for factory presets
                string path = ChainChompApplication.factoryPresetsPath + item.Name + @"\";
                //create dir
                if (!Directory.Exists(path))
                {
                    Directory.CreateDirectory(path);
                }

                byte[] presets = (byte[])item.GetFactoryPresets();
                if (presets != null)
                {
                    string tmp = ChainChompApplication.tempPath + "tmp";
                    //extract zip (cannot use ZipFile.ExtractTo because we are overwriting
                    ChainChompApplication.FlushTempDir();
                    FileIO.WriteAllBytes(tmp, presets);

                    //overwrite factory presets
                    ZipArchive z = null;
                    try
                    {
                        z = ZipFile.OpenRead(tmp);
                        z.Entries.ToList().ForEach(e => e.ExtractToFile(path + e.FullName, true));
                        z.Dispose();
                    }
                    catch (IOException e)
                    {
                        MessageBox.Show("Factory presets could not be created");
                        z.Dispose();
                    }
                }
            });
        }
 private void ChainChompApplication_Load(object sender, EventArgs e)
 {
     mainForm = this;
     RTC.RTC_RPC.Plugin_Loaded(this);
 }