Beispiel #1
0
    public static string CreateDisplayString(List <CalculatedScoreEntry> scores)
    {
        string output   = "Difficulty Rating\n";
        var    songData = SongDataHolder.I.songData;

        fillData AdditionHolder = new fillData();

        AdditionHolder.easyAdditions     = new List <string>();
        AdditionHolder.advancedAdditions = new List <string>();
        AdditionHolder.standardAdditions = new List <string>();
        AdditionHolder.expertAdditions   = new List <string>();

        if (SongBrowser.songDataLoaderInstalled)
        {
            //fillAdditions() is separated into its own function to avoid errors if !songDataLoaderInstalled

            /*Explanation:
             * When CreateDisplayString() is called the first time it loads in all the functions it needs.
             * If we include anything from the Song Data Loader utility in CreateDisplayString() it will try to
             * load from the dll. In the case they dont have the dll, it will throw an exception and the rest of
             * CreateDisplayString() won't run. Since all mentions of Son Data Loader are in fillAdditions(), which
             * is behind a conditional we wont have that issue.
             */

            AdditionHolder = fillAdditions(songData.songID, AdditionHolder);
        }

        CachedCalculation easy   = DifficultyCalculator.GetRating(songData.songID, KataConfig.Difficulty.Easy.ToString());
        CachedCalculation normal = DifficultyCalculator.GetRating(songData.songID, KataConfig.Difficulty.Normal.ToString());
        CachedCalculation hard   = DifficultyCalculator.GetRating(songData.songID, KataConfig.Difficulty.Hard.ToString());
        CachedCalculation expert = DifficultyCalculator.GetRating(songData.songID, KataConfig.Difficulty.Expert.ToString());


        //add mine tags if it has mines

        if (songData.hasEasy && easy.hasMines)
        {
            AdditionHolder.easyAdditions.Insert(0, "Mines");
        }

        if (songData.hasNormal && normal.hasMines)
        {
            AdditionHolder.standardAdditions.Insert(0, "Mines");
        }

        if (songData.hasHard && hard.hasMines)
        {
            AdditionHolder.advancedAdditions.Insert(0, "Mines");
        }

        if (songData.hasExpert && expert.hasMines)
        {
            AdditionHolder.expertAdditions.Insert(0, "Mines");
        }

        //add 360 if it is

        if (songData.hasEasy && easy.is360)
        {
            AdditionHolder.easyAdditions.Insert(0, "360");
        }

        if (songData.hasNormal && normal.is360)
        {
            AdditionHolder.standardAdditions.Insert(0, "360");
        }

        if (songData.hasHard && hard.is360)
        {
            AdditionHolder.advancedAdditions.Insert(0, "360");
        }

        if (songData.hasExpert && expert.is360)
        {
            AdditionHolder.expertAdditions.Insert(0, "360");
        }

        AdditionHolder.expertAdditions   = AdditionHolder.expertAdditions.Distinct().ToList();
        AdditionHolder.standardAdditions = AdditionHolder.standardAdditions.Distinct().ToList();
        AdditionHolder.advancedAdditions = AdditionHolder.advancedAdditions.Distinct().ToList();
        AdditionHolder.easyAdditions     = AdditionHolder.easyAdditions.Distinct().ToList();


        if (expert.value != 0)
        {
            output += $"<color=#b119f7>{expert.value.ToString("n2")} ";
            output += AdditionHolder.expertAdditions.Count > 0 ? "(" + string.Join(", ", AdditionHolder.expertAdditions.ToArray()) + ")</color> " : "</color> ";
        }
        if (hard.value != 0)
        {
            output += $"<color=#f7a919>{hard.value.ToString("n2")} ";
            output += AdditionHolder.advancedAdditions.Count > 0 ? "(" + string.Join(", ", AdditionHolder.advancedAdditions.ToArray()) + ")</color> " : "</color> ";
        }
        if (normal.value != 0)
        {
            output += $"<color=#19d2f7>{normal.value.ToString("n2")} ";
            output += AdditionHolder.standardAdditions.Count > 0 ? "(" + string.Join(", ", AdditionHolder.standardAdditions.ToArray()) + ")</color> " : "</color> ";
        }
        if (easy.value != 0)
        {
            output += $"<color=#54f719>{easy.value.ToString("n2")} ";
            output += AdditionHolder.easyAdditions.Count > 0 ? "(" + string.Join(", ", AdditionHolder.easyAdditions.ToArray()) + ")</color> " : "</color> ";
        }
        return(output);
    }
Beispiel #2
0
            private static void Postfix(SongSelect __instance, SongSelect.SongSelectItemEntry entry)
            {
                var song = SongList.I.GetSong(entry.songID);

                if (entry.item.mapperLabel != null)
                {
                    //package data to be used for display
                    SongBrowser.SongDisplayPackage songd = new SongBrowser.SongDisplayPackage();

                    songd.hasEasy     = song.hasEasy;
                    songd.hasStandard = song.hasNormal;
                    songd.hasAdvanced = song.hasHard;
                    songd.hasExpert   = song.hasExpert;

                    //if song data loader is installed look for custom tags
                    if (SongBrowser.songDataLoaderInstalled)
                    {
                        songd = SongBrowser.SongDisplayPackage.FillCustomData(songd, song.songID);
                    }


                    CachedCalculation easy   = DifficultyCalculator.GetRating(song.songID, KataConfig.Difficulty.Easy.ToString());
                    CachedCalculation normal = DifficultyCalculator.GetRating(song.songID, KataConfig.Difficulty.Normal.ToString());
                    CachedCalculation hard   = DifficultyCalculator.GetRating(song.songID, KataConfig.Difficulty.Hard.ToString());
                    CachedCalculation expert = DifficultyCalculator.GetRating(song.songID, KataConfig.Difficulty.Expert.ToString());

                    //add mine tag if there are mines
                    if (song.hasEasy && easy.hasMines)
                    {
                        songd.customEasyTags.Insert(0, "Mines");
                    }
                    if (song.hasNormal && normal.hasMines)
                    {
                        songd.customStandardTags.Insert(0, "Mines");
                    }
                    if (song.hasHard && hard.hasMines)
                    {
                        songd.customAdvancedTags.Insert(0, "Mines");
                    }
                    if (song.hasExpert && expert.hasMines)
                    {
                        songd.customExpertTags.Insert(0, "Mines");
                    }

                    //add 360 tag
                    if (song.hasEasy && easy.is360)
                    {
                        songd.customEasyTags.Insert(0, "360");
                    }
                    if (song.hasNormal && normal.is360)
                    {
                        songd.customStandardTags.Insert(0, "360");
                    }
                    if (song.hasHard && hard.is360)
                    {
                        songd.customAdvancedTags.Insert(0, "360");
                    }
                    if (song.hasExpert && expert.is360)
                    {
                        songd.customExpertTags.Insert(0, "360");
                    }

                    songd.customExpertTags   = songd.customExpertTags.Distinct().ToList();
                    songd.customStandardTags = songd.customStandardTags.Distinct().ToList();
                    songd.customAdvancedTags = songd.customAdvancedTags.Distinct().ToList();
                    songd.customEasyTags     = songd.customEasyTags.Distinct().ToList();

                    entry.item.mapperLabel.text += SongBrowser.GetDifficultyString(songd);
                }
            }
Beispiel #3
0
    public static CachedCalculation GetRating(string songID, string difficulty)
    {
        var songData  = SongList.I.GetSong(songID);
        var diffLower = difficulty.ToLower();

        if (calculatorCache.ContainsKey(songID + diffLower))
        {
            return(calculatorCache[songID + diffLower]);
        }
        else
        {
            if (songData == null)
            {
                return(new CachedCalculation());
            }
            var calc = new DifficultyCalculator(songData);
            switch (diffLower)
            {
            case "easy":
                if (calc.beginner != null)
                {
                    CachedCalculation data = new CachedCalculation(calc.beginner.difficultyRating, calc.beginner.is360, calc.beginner.hasMines);
                    calculatorCache.Add(songID + diffLower, data);
                    //MelonLogger.Msg(songData.title + " (beginner) span: " + Math.Abs(calc.beginner.cueExtremesX.highest - calc.beginner.cueExtremesX.lowest));
                    return(data);
                }
                else
                {
                    calculatorCache.Add(songID + diffLower, new CachedCalculation());
                    return(new CachedCalculation());
                }

            case "normal":
                if (calc.standard != null)
                {
                    CachedCalculation data = new CachedCalculation(calc.standard.difficultyRating, calc.standard.is360, calc.standard.hasMines);
                    calculatorCache.Add(songID + diffLower, data);
                    //MelonLogger.Msg(songData.title + " (normal) span: " + Math.Abs(calc.standard.cueExtremesX.highest - calc.standard.cueExtremesX.lowest));

                    return(data);
                }
                else
                {
                    calculatorCache.Add(songID + diffLower, new CachedCalculation());
                    return(new CachedCalculation());
                }

            case "hard":
                if (calc.advanced != null)
                {
                    CachedCalculation data = new CachedCalculation(calc.advanced.difficultyRating, calc.advanced.is360, calc.advanced.hasMines);
                    calculatorCache.Add(songID + diffLower, data);
                    //MelonLogger.Msg(songData.title + " (hard) span: " + Math.Abs(calc.advanced.cueExtremesX.highest - calc.advanced.cueExtremesX.lowest));

                    return(data);
                }
                else
                {
                    calculatorCache.Add(songID + diffLower, new CachedCalculation());
                    return(new CachedCalculation());
                }

            case "expert":
                if (calc.expert != null)
                {
                    CachedCalculation data = new CachedCalculation(calc.expert.difficultyRating, calc.expert.is360, calc.expert.hasMines);
                    calculatorCache.Add(songID + diffLower, data);
                    //MelonLogger.Msg(songData.title + " (expert) span: " + Math.Abs(calc.expert.cueExtremesX.highest - calc.expert.cueExtremesX.lowest));
                    return(data);
                }
                else
                {
                    calculatorCache.Add(songID + diffLower, new CachedCalculation());
                    return(new CachedCalculation());
                }

            default:
                return(new CachedCalculation());
            }
        }
    }