//Tracker Version Handeling
        public static bool GetLatestTrackerVersion()
        {
            var CheckForUpdate = false;

            if (File.Exists("options.txt"))
            {
                foreach (var file in File.ReadAllLines("options.txt"))
                {
                    if (file.Contains("CheckForUpdates:1"))
                    {
                        CheckForUpdate = true;
                    }
                }
            }
            if (!CheckForUpdate && (Control.ModifierKeys != Keys.Shift))
            {
                return(false);
            }

            var client  = new GitHubClient(new ProductHeaderValue("MMR-Tracker"));
            var lateset = client.Repository.Release.GetLatest("Thedrummonger", "MMR-Tracker").Result;

            Console.WriteLine($"Latest Version: { lateset.TagName } Current Version { trackerVersion }");

            if (VersionHandeling.CompareVersions(lateset.TagName, trackerVersion))
            {
                if (Debugging.ISDebugging && (Control.ModifierKeys != Keys.Shift))
                {
                    Console.WriteLine($"Tracker Out of Date. Latest Version: { lateset.TagName } Current Version { trackerVersion }");
                }
                else
                {
                    var Download = MessageBox.Show($"Your tracker version { trackerVersion } is out of Date. Would you like to download the latest version { lateset.TagName }?", "Tracker Out of Date", MessageBoxButtons.YesNo);
                    if (Download == DialogResult.Yes)
                    {
                        { Process.Start(lateset.HtmlUrl); return(true); }
                    }
                }
            }
            return(false);
        }
Exemple #2
0
        //Tracker Version Handeling
        public static bool GetLatestTrackerVersion()
        {
            var CheckForUpdate = File.Exists("options.txt") && File.ReadAllLines("options.txt").Any(x => x.Contains("CheckForUpdates:1"));

            if (!CheckForUpdate && (Control.ModifierKeys != Keys.Shift))
            {
                return(false);
            }

            var client  = new GitHubClient(new ProductHeaderValue("MMR-Tracker"));
            var lateset = client.Repository.Release.GetLatest("Thedrummonger", "MMR-Tracker").Result;

            Debugging.Log($"Latest Version: { lateset.TagName } Current Version { trackerVersion }");
            if (VersionHandeling.CompareVersions(lateset.TagName, trackerVersion) == 0)
            {
                Debugging.Log($"Using Current Version");
            }
            if (VersionHandeling.CompareVersions(lateset.TagName, trackerVersion) < 0)
            {
                Debugging.Log($"Using Unreleased Dev Version"); TrackerVersionStatus = 1;
            }

            if (VersionHandeling.CompareVersions(lateset.TagName, trackerVersion) > 0)
            {
                if (Debugging.ISDebugging && (Control.ModifierKeys != Keys.Shift))
                {
                    Debugging.Log($"Using Outdated Version");
                }
                else
                {
                    var Download = MessageBox.Show($"Your tracker version { trackerVersion } is out of Date. Would you like to download the latest version { lateset.TagName }?", "Tracker Out of Date", MessageBoxButtons.YesNo);
                    if (Download == DialogResult.Yes)
                    {
                        { Process.Start(lateset.HtmlUrl); return(true); }
                    }
                }
                TrackerVersionStatus = -1;
            }
            return(false);
        }
Exemple #3
0
        public static bool PopulatePost115TrackerInstance(LogicObjects.TrackerInstance instance)
        {
            LogicObjects.LogicFile NewformatLogicFile = LogicObjects.LogicFile.FromJson(string.Join("", instance.RawLogicFile));
            instance.Logic.Clear();
            instance.DicNameToID.Clear();
            instance.EntrancePairs.Clear();
            instance.LogicVersion = NewformatLogicFile.Version;
            instance.GameCode     = "MMR";

            if (instance.LogicDictionary == null || instance.LogicDictionary.Count < 1)
            {
                string DictionaryPath = VersionHandeling.GetDictionaryPath(instance, true);
                if (!string.IsNullOrWhiteSpace(DictionaryPath))
                {
                    try
                    {
                        instance.LogicDictionary = JsonConvert.DeserializeObject <List <LogicObjects.LogicDictionaryEntry> >(Utility.ConvertCsvFileToJsonObject(File.ReadAllLines(DictionaryPath)));
                    }
                    catch { MessageBox.Show($"The Dictionary File \"{DictionaryPath}\" has been corrupted. The tracker will not function correctly."); }
                }
                else
                {
                    MessageBox.Show($"A valid dictionary file could not be found for this logic. The tracker will not function correctly.");
                }
            }

            Dictionary <string, int> LogicNametoId = new Dictionary <string, int>();
            int DicCounter = 0;

            foreach (var i in NewformatLogicFile.Logic)
            {
                LogicNametoId.Add(i.Id, DicCounter);
                DicCounter++;
            }

            LogicObjects.LogicEntry LogicEntry1 = new LogicObjects.LogicEntry();
            foreach (var i in NewformatLogicFile.Logic)
            {
                LogicEntry1.ID             = NewformatLogicFile.Logic.IndexOf(i);
                LogicEntry1.DictionaryName = i.Id;
                LogicEntry1.Checked        = false;
                LogicEntry1.RandomizedItem = -2;
                LogicEntry1.IsFake         = true;
                LogicEntry1.SpoilerRandom  = -2;
                LogicEntry1.Required       = i.RequiredItems.Select(x => LogicNametoId[x]).ToArray();
                LogicEntry1.Conditionals   = i.ConditionalItems.Select(x => x.Select(y => LogicNametoId[y]).ToArray()).ToArray();
                LogicEntry1.NeededBy       = (int)i.TimeNeeded;
                LogicEntry1.AvailableOn    = (int)i.TimeAvailable;
                LogicEntry1.IsTrick        = i.IsTrick;
                LogicEntry1.TrickEnabled   = i.IsTrick;
                LogicEntry1.TrickToolTip   = i.TrickTooltip;

                var DicEntry = instance.LogicDictionary.Find(x => x.DictionaryName == LogicEntry1.DictionaryName);
                if (DicEntry != null)
                {
                    LogicEntry1.IsFake          = false;
                    LogicEntry1.ItemName        = (string.IsNullOrWhiteSpace(DicEntry.ItemName)) ? null : DicEntry.ItemName;
                    LogicEntry1.LocationName    = (string.IsNullOrWhiteSpace(DicEntry.LocationName)) ? null : DicEntry.LocationName;
                    LogicEntry1.LocationArea    = (string.IsNullOrWhiteSpace(DicEntry.LocationArea)) ? "Misc" : DicEntry.LocationArea;
                    LogicEntry1.ItemSubType     = (string.IsNullOrWhiteSpace(DicEntry.ItemSubType)) ? "Item" : DicEntry.ItemSubType;
                    LogicEntry1.SpoilerLocation = (string.IsNullOrWhiteSpace(DicEntry.SpoilerLocation))
                        ? new List <string> {
                        LogicEntry1.LocationName
                    } : DicEntry.SpoilerLocation.Split('|').ToList();
                    LogicEntry1.SpoilerItem = (string.IsNullOrWhiteSpace(DicEntry.SpoilerItem))
                        ? new List <string> {
                        LogicEntry1.ItemName
                    } : DicEntry.SpoilerItem.Split('|').ToList();
                }

                //Push Data to the instance
                instance.Logic.Add(LogicEntry1);
                LogicEntry1 = new LogicObjects.LogicEntry();
            }

            instance.EntranceRando   = instance.IsEntranceRando();
            instance.EntranceAreaDic = CreateAreaClearDictionary(instance);
            CreateDicNameToID(instance);
            if (instance.EntranceRando)
            {
                CreatedEntrancepairDcitionary(instance);
            }
            MarkUniqeItemsUnrandomizedManual(instance);

            return(true);
        }
Exemple #4
0
        public static bool PopulatePre115TrackerInstance(LogicObjects.TrackerInstance instance)
        {
            /* Sets the Values of the follwing using the data in instance.RawLogicFile
             * Version
             * Game
             * Entrance Area Dictionary
             * Logic
             * LogicDictionary
             * Name to ID Dictionary
             * Entrance pair Dictionary
             */
            instance.Logic.Clear();
            instance.DicNameToID.Clear();
            instance.EntrancePairs.Clear();
            LogicObjects.VersionInfo versionData = VersionHandeling.GetVersionDataFromLogicFile(instance.RawLogicFile);
            instance.LogicVersion = versionData.Version;
            instance.GameCode     = versionData.Gamecode;
            int SubCounter = 0;
            int idCounter  = 0;

            if (instance.LogicDictionary == null || instance.LogicDictionary.Count < 1)
            {
                string DictionaryPath = VersionHandeling.GetDictionaryPath(instance);
                if (!string.IsNullOrWhiteSpace(DictionaryPath))
                {
                    try
                    {
                        instance.LogicDictionary = JsonConvert.DeserializeObject <List <LogicObjects.LogicDictionaryEntry> >(Utility.ConvertCsvFileToJsonObject(File.ReadAllLines(DictionaryPath)));
                    }
                    catch { MessageBox.Show($"The Dictionary File \"{DictionaryPath}\" has been corrupted. The tracker will not function correctly."); }
                }
                else
                {
                    MessageBox.Show($"A valid dictionary file could not be found for this logic. The tracker will not function correctly.");
                }
            }

            LogicObjects.LogicEntry LogicEntry1 = new LogicObjects.LogicEntry();
            var NextLine = 1;

            foreach (string line in instance.RawLogicFile)
            {
                if (NextLine == 1)
                {
                    NextLine++; continue;
                }
                if (line.StartsWith("-"))
                {
                    SubCounter = 0;
                }
                switch (SubCounter)
                {
                case 0:
                    LogicEntry1.ID             = idCounter;
                    LogicEntry1.DictionaryName = line.Substring(2);
                    LogicEntry1.Checked        = false;
                    LogicEntry1.RandomizedItem = -2;
                    LogicEntry1.IsFake         = true;
                    LogicEntry1.SpoilerRandom  = -2;

                    var DicEntry = instance.LogicDictionary.Find(x => x.DictionaryName == LogicEntry1.DictionaryName);
                    if (DicEntry == null)
                    {
                        break;
                    }

                    LogicEntry1.IsFake          = false;
                    LogicEntry1.IsTrick         = false;
                    LogicEntry1.TrickEnabled    = true;
                    LogicEntry1.TrickToolTip    = "";
                    LogicEntry1.ItemName        = (string.IsNullOrWhiteSpace(DicEntry.ItemName)) ? null : DicEntry.ItemName;
                    LogicEntry1.LocationName    = (string.IsNullOrWhiteSpace(DicEntry.LocationName)) ? null : DicEntry.LocationName;
                    LogicEntry1.LocationArea    = (string.IsNullOrWhiteSpace(DicEntry.LocationArea)) ? "Misc" : DicEntry.LocationArea;
                    LogicEntry1.ItemSubType     = (string.IsNullOrWhiteSpace(DicEntry.ItemSubType)) ? "Item" : DicEntry.ItemSubType;
                    LogicEntry1.SpoilerLocation = (string.IsNullOrWhiteSpace(DicEntry.SpoilerLocation))
                            ? new List <string> {
                        LogicEntry1.LocationName
                    } : DicEntry.SpoilerLocation.Split('|').ToList();
                    LogicEntry1.SpoilerItem = (string.IsNullOrWhiteSpace(DicEntry.SpoilerItem))
                            ? new List <string> {
                        LogicEntry1.ItemName
                    } : DicEntry.SpoilerItem.Split('|').ToList();
                    break;

                case 1:
                    if (string.IsNullOrWhiteSpace(line))
                    {
                        LogicEntry1.Required = null; break;
                    }
                    LogicEntry1.Required = line.Split(',').Select(y => int.Parse(y)).ToArray();
                    break;

                case 2:
                    if (string.IsNullOrWhiteSpace(line))
                    {
                        LogicEntry1.Conditionals = null; break;
                    }
                    LogicEntry1.Conditionals = line.Split(';').Select(x => x.Split(',').Select(y => int.Parse(y)).ToArray()).ToArray();
                    break;

                case 3:
                    LogicEntry1.NeededBy = Convert.ToInt32(line);
                    break;

                case 4:
                    LogicEntry1.AvailableOn = Convert.ToInt32(line);
                    break;

                case 5:
                    LogicEntry1.IsTrick      = (line.StartsWith(";"));
                    LogicEntry1.TrickEnabled = true;
                    LogicEntry1.TrickToolTip = (line.Length > 1) ? line.Substring(1) : "No Tooltip Available";
                    //if (LogicEntry1.IsTrick) { Debugging.Log($"Trick {LogicEntry1.DictionaryName} Found. ToolTip =  { LogicEntry1.TrickToolTip }"); }
                    break;
                }
                if ((NextLine) >= instance.RawLogicFile.Count() || instance.RawLogicFile[NextLine].StartsWith("-"))
                {
                    //Push Data to the instance
                    instance.Logic.Add(LogicEntry1);
                    LogicEntry1 = new LogicObjects.LogicEntry();
                    idCounter++;
                }
                NextLine++;
                SubCounter++;
            }

            instance.EntranceRando   = instance.IsEntranceRando();
            instance.EntranceAreaDic = CreateAreaClearDictionary(instance);
            CreateDicNameToID(instance);
            if (instance.EntranceRando)
            {
                CreatedEntrancepairDcitionary(instance);
            }
            MarkUniqeItemsUnrandomizedManual(instance);

            return(true);
        }
Exemple #5
0
        public static bool PopulateTrackerInstance(LogicObjects.TrackerInstance instance)
        {
            /* Sets the Values of the follwing using the data in instance.RawLogicFile
             * Version
             * Game
             * Entrance Area Dictionary
             * Logic
             * LogicDictionary
             * Name to ID Dictionary
             * Entrance pair Dictionary
             */
            instance.Logic.Clear();
            instance.DicNameToID.Clear();
            instance.EntrancePairs.Clear();
            LogicObjects.VersionInfo version = VersionHandeling.GetVersionFromLogicFile(instance.RawLogicFile); //Returns [0] The logic Version, [1] The game this logic file is for
            instance.LogicVersion = version.Version;
            instance.GameCode     = version.Gamecode;
            string[] VersionData = VersionHandeling.GetDictionaryPath(instance); //Returns [0] Path To Dictionary, [1] path to Entrance Pairs
            int      SubCounter  = 0;
            int      idCounter   = 0;

            LogicObjects.LogicEntry LogicEntry1 = new LogicObjects.LogicEntry();
            if (VersionData.Count() > 0 && VersionData[0] != "")
            {
                instance.LogicDictionary = JsonConvert.DeserializeObject <List <LogicObjects.LogicDictionaryEntry> >(Utility.ConvertCsvFileToJsonObject(VersionData[0]));
            }
            var NextLine = 1;

            foreach (string line in instance.RawLogicFile)
            {
                if (NextLine == 1)
                {
                    NextLine++; continue;
                }
                if (line.StartsWith("-"))
                {
                    SubCounter = 0;
                }
                switch (SubCounter)
                {
                case 0:
                    LogicEntry1.ID             = idCounter;
                    LogicEntry1.DictionaryName = line.Substring(2);
                    LogicEntry1.Checked        = false;
                    LogicEntry1.RandomizedItem = -2;
                    LogicEntry1.IsFake         = true;
                    LogicEntry1.SpoilerRandom  = -2;

                    var DicEntry = instance.LogicDictionary.Find(x => x.DictionaryName == LogicEntry1.DictionaryName);
                    if (DicEntry == null)
                    {
                        break;
                    }

                    LogicEntry1.IsFake          = false;
                    LogicEntry1.IsTrick         = false;
                    LogicEntry1.TrickEnabled    = true;
                    LogicEntry1.TrickToolTip    = "";
                    LogicEntry1.ItemName        = (DicEntry.ItemName == "") ? null : DicEntry.ItemName;
                    LogicEntry1.LocationName    = (DicEntry.LocationName == "") ? null : DicEntry.LocationName;
                    LogicEntry1.LocationArea    = (DicEntry.LocationArea == "") ? "Misc" : DicEntry.LocationArea;
                    LogicEntry1.ItemSubType     = (DicEntry.ItemSubType == "") ? "Item" : DicEntry.ItemSubType;
                    LogicEntry1.SpoilerLocation = (DicEntry.SpoilerLocation == "") ? LogicEntry1.LocationName : DicEntry.SpoilerLocation;
                    LogicEntry1.SpoilerItem     = (DicEntry.SpoilerItem == "") ? LogicEntry1.ItemName : DicEntry.SpoilerItem;
                    break;

                case 1:
                    if (line == null || line == "")
                    {
                        LogicEntry1.Required = null; break;
                    }
                    string[] req = line.Split(',');
                    LogicEntry1.Required = Array.ConvertAll(req, s => int.Parse(s));
                    break;

                case 2:
                    if (line == null || line == "")
                    {
                        LogicEntry1.Conditionals = null; break;
                    }
                    string[] ConditionalSets = line.Split(';');
                    int[][]  Conditionals    = new int[ConditionalSets.Length][];
                    for (int j = 0; j < ConditionalSets.Length; j++)
                    {
                        string[] condtional = ConditionalSets[j].Split(',');
                        Conditionals[j] = Array.ConvertAll(condtional, s => int.Parse(s));
                    }
                    LogicEntry1.Conditionals = Conditionals;
                    break;

                case 3:
                    LogicEntry1.NeededBy = Convert.ToInt32(line);
                    break;

                case 4:
                    LogicEntry1.AvailableOn = Convert.ToInt32(line);
                    break;

                case 5:
                    LogicEntry1.IsTrick      = (line.StartsWith(";"));
                    LogicEntry1.TrickEnabled = true;
                    LogicEntry1.TrickToolTip = (line.Length > 1) ? line.Substring(1) : "No Tooltip Available";
                    if (LogicEntry1.IsTrick)
                    {
                        Console.WriteLine($"Trick {LogicEntry1.DictionaryName} Found. ToolTip =  { LogicEntry1.TrickToolTip }");
                    }
                    break;
                }
                if ((NextLine) >= instance.RawLogicFile.Count() || instance.RawLogicFile[NextLine].StartsWith("-"))
                {
                    //Push Data to the instance
                    instance.Logic.Add(LogicEntry1);
                    LogicEntry1 = new LogicObjects.LogicEntry();
                    idCounter++;
                }
                NextLine++;
                SubCounter++;
            }

            instance.EntranceRando   = instance.IsEntranceRando();
            instance.EntranceAreaDic = VersionHandeling.AreaClearDictionary(instance);
            CreateDicNameToID(instance.DicNameToID, instance.Logic);
            if (VersionData.Count() > 1 && VersionData[1] != "")
            {
                CreatedEntrancepairDcitionary(instance.EntrancePairs, instance.DicNameToID, VersionData);
            }

            return(true);
        }