Esempio n. 1
0
        private void BtnSave_Click(object sender, EventArgs e)
        {
            var template = new LogicObjects.TrackerInstance();

            template.RawLogicFile = LogicObjects.MainTrackerInstance.RawLogicFile;
            LogicEditing.PopulateTrackerInstance(template);
            foreach (var i in template.Logic)
            {
                var main = LogicObjects.MainTrackerInstance.Logic[i.ID];
                i.Options      = main.Options;
                i.TrickEnabled = main.TrickEnabled;
            }
            Tools.SaveInstance(template);
        }
Esempio n. 2
0
        public static void RecreateLogic(LogicObjects.TrackerInstance Instance, string[] LogicData = null)
        {
            var LogicFile = LogicData;
            var saveFile  = false;

            LogicObjects.TrackerInstance template = null;
            if (LogicFile == null)
            {
                string file = "";
                file = Utility.FileSelect("Select A Logic File", "Logic File (*.txt;*.MMRTSAV)|*.txt;*.MMRTSAV");
                if (file == "")
                {
                    return;
                }

                saveFile = file.EndsWith(".MMRTSAV");
                string[] SaveFileRawLogicFile = null;
                if (saveFile)
                {
                    try { template = JsonConvert.DeserializeObject <LogicObjects.TrackerInstance>(File.ReadAllText(file)); }
                    catch
                    {
                        MessageBox.Show("Save File Not Valid.");
                        return;
                    }
                    SaveFileRawLogicFile = template.RawLogicFile;
                }

                LogicFile = (saveFile) ? SaveFileRawLogicFile : File.ReadAllLines(file);
            }
            Tools.SaveState(Instance);

            var OldLogic = Utility.CloneLogicList(Instance.Logic);

            Instance.RawLogicFile    = LogicFile;
            Instance.LogicDictionary = null;
            LogicEditing.PopulateTrackerInstance(Instance);

            var logic = Instance.Logic;

            foreach (var entry in OldLogic)
            {
                var logicEntry = logic.Find(x => x.DictionaryName == entry.DictionaryName);
                if (logicEntry == null)
                {
                    continue;
                }
                logicEntry.Aquired        = entry.Aquired;
                logicEntry.Checked        = entry.Checked;
                logicEntry.RandomizedItem = entry.RandomizedItem;
                logicEntry.SpoilerRandom  = entry.SpoilerRandom;
                logicEntry.Starred        = entry.Starred;
                logicEntry.Options        = entry.Options;
                logicEntry.TrickEnabled   = entry.TrickEnabled;
                logicEntry.PlayerData     = entry.PlayerData;
            }
            if (saveFile)
            {
                var Options = MessageBox.Show("Would you like to import the general tracker options from this save file?", "Options", MessageBoxButtons.YesNo);
                if (Options == DialogResult.Yes)
                {
                    LogicObjects.MainTrackerInstance.Options = template.Options;
                }
                var RandOptions = MessageBox.Show("Would you like to import the Item Randomization options from this save file?", "Randomization Options", MessageBoxButtons.YesNo);
                if (RandOptions == DialogResult.Yes)
                {
                    foreach (var i in LogicObjects.MainTrackerInstance.Logic)
                    {
                        var TemplateData = template.Logic.Find(x => x.DictionaryName == i.DictionaryName);
                        if (TemplateData != null)
                        {
                            i.Options      = TemplateData.Options;
                            i.TrickEnabled = TemplateData.TrickEnabled;
                        }
                    }
                }
            }
            Instance.Options.EntranceRadnoEnabled            = Utility.CheckForRandomEntrances(Instance);
            Instance.Options.OverRideAutoEntranceRandoEnable = (Instance.Options.EntranceRadnoEnabled != Instance.EntranceRando);
            CalculateItems(Instance, true);
        }