Exemple #1
0
        public static void Create <T>(T settings, string counterName, string counterData, bool UseCounterPositioning = true) where T : ConfigModel
        {
            if (!settings.Enabled)
            {
                return;
            }
            GameObject counter  = new GameObject($"Counters+ | Mock {counterName} Counter");
            GameObject nameGO   = new GameObject($"Counters+ | Mock {counterName} Label");
            Vector3    position = (CountersController.DeterminePosition(counter, settings.Position, settings.Distance) - new Vector3(0, 0.4f, 0));

            nameGO.transform.parent = counter.transform;
            //TextMeshPro name = nameGO.AddComponent<TextMeshPro>();
            TextHelper.CreateText(out TMP_Text name, position);
            name.text      = counterName;
            name.fontSize  = 3;
            name.color     = Color.white;
            name.alignment = TextAlignmentOptions.Center;
            //name.rectTransform.localPosition = new Vector3(0, 0.4f, 0);

            //TextMeshPro data = counter.AddComponent<TextMeshPro>();
            TextHelper.CreateText(out TMP_Text data, position - new Vector3(0, 0.4f, 0));
            data.text      = counterData;
            data.fontSize  = 4;
            data.color     = Color.white;
            data.alignment = TextAlignmentOptions.Center;

            if (loadedMockCounters.Where((KeyValuePair <MockCounterGroup, ConfigModel> x) => x.Value == settings).Any())
            {
                MockCounterGroup group = loadedMockCounters.First((KeyValuePair <MockCounterGroup, ConfigModel> x) => x.Value == settings).Key;
                UnityEngine.Object.Destroy(group.CounterName);
                UnityEngine.Object.Destroy(group.CounterData);
                loadedMockCounters.Remove(group);
            }
            if (settings.DisplayName == HighlightedObject)
            {
                name.color = Color.yellow;
                data.color = Color.yellow;
            }
            loadedMockCounters.Add(new MockCounterGroup(name, data), settings);
        }
        public static void Update <T>(T settings) where T : ConfigModel
        {
            if (settings is null)
            {
                return;
            }

            if (!settings.Enabled)
            {
                if (loadedMockCounters.Where((KeyValuePair <MockCounterGroup, ConfigModel> x) => x.Value == settings).Any())
                {
                    MockCounterGroup group = loadedMockCounters.First((KeyValuePair <MockCounterGroup, ConfigModel> x) => x.Value == settings).Key;
                    UnityEngine.Object.Destroy(group.CounterName);
                    UnityEngine.Object.Destroy(group.CounterData);
                    loadedMockCounters.Remove(group);
                }
            }

            /*Mock Counter creation is here instead of CountersPlusSettingsFlowCoordinator.
             * Holy shit this code is messy, I'm not proud of it.
             *
             * If you want your new Counters+ option to be visible in the Settings UI, go ahead and throw it somewhere in here.
             * If you want to add your new Counter to the Settings UI, like copy MissedConfigModel's mock counter code and use it as a base.
             * Until I rewrite this, god help you.
             */
            if (CountersController.settings.AdvancedCounterInfo)
            {
                if (settings is MissedConfigModel)
                {
                    Create(settings, "Misses", info.notesMissed.ToString());
                }
                else if (settings is NoteConfigModel)
                {
                    Create(settings, "Notes",
                           $"{info.notesCut - info.notesMissed} / {info.notesCut} {(((settings as NoteConfigModel).ShowPercentage) ? $"- ({Math.Round((((double)(info.notesCut - info.notesMissed) / info.notesCut) * 100), (settings as NoteConfigModel).DecimalPrecision)}%)" : "")}");
                }
                else if (settings is ScoreConfigModel)
                {
                    if ((settings as ScoreConfigModel).Mode == ICounterMode.BaseWithOutPoints || (settings as ScoreConfigModel).Mode == ICounterMode.LeavePoints || !(settings as ScoreConfigModel).Enabled)
                    {
                        CreateStatic("123 456", "");
                    }
                    else
                    {
                        UnityEngine.Object.Destroy(GameObject.Find("Counters+ | Static 123 456 Counter"));
                    }
                    Create(settings, $"<size=50%>{(settings as ScoreConfigModel).Mode}</size> {Math.Round(info.score, (settings as ScoreConfigModel).DecimalPrecision).ToString()}%", (settings as ScoreConfigModel).DisplayRank ? info.GetRank() : "");
                }
                else if (settings is SpeedConfigModel)
                {
                    if ((settings as SpeedConfigModel).Mode == ICounterMode.Average || (settings as SpeedConfigModel).Mode == ICounterMode.Both)
                    {
                        Create(settings,
                               $"{((settings as SpeedConfigModel).Mode == ICounterMode.Both ? "Average (Both)" : "Average Speed")}", $"{Math.Round((info.leftSpeedAverage + info.rightSpeedAverage) / 2, (settings as SpeedConfigModel).DecimalPrecision)}");
                    }
                    else if ((settings as SpeedConfigModel).Mode == ICounterMode.SplitAverage || (settings as SpeedConfigModel).Mode == ICounterMode.SplitBoth)
                    {
                        Create(settings,
                               $"{((settings as SpeedConfigModel).Mode == ICounterMode.SplitBoth ? "Split Average (Both)" : "Split Average")}", $"{Math.Round(info.leftSpeedAverage, (settings as SpeedConfigModel).DecimalPrecision)} | {Math.Round(info.rightSpeedAverage, (settings as SpeedConfigModel).DecimalPrecision)}");
                    }
                    else if ((settings as SpeedConfigModel).Mode == ICounterMode.Top5Sec)
                    {
                        Create(settings, "Top Speed (5 Sec.)", $"{Math.Round(info.leftSpeedAverage + 10, (settings as SpeedConfigModel).DecimalPrecision)}");
                    }
                }
                else if (settings is CutConfigModel)
                {
                    if ((settings as CutConfigModel).SeparateSaberCounts)
                    {
                        Create(settings, "Average Cut", $"{Mathf.RoundToInt(info.averageCutScore) - 10}  {Mathf.RoundToInt(info.averageCutScore)}");
                    }
                    else
                    {
                        Create(settings, "Average Cut", $"{Mathf.RoundToInt(info.averageCutScore)}");
                    }
                }
                else if (settings is ProgressConfigModel)
                {
                    Create(settings,
                           $"{(settings as ProgressConfigModel).Mode.ToString()} Progress",
                           $"{(((((settings as ProgressConfigModel).ProgressTimeLeft ? 1f : 0f) - ((float)info.timeElapsed / info.totalTime)) * 100f) * ((settings as ProgressConfigModel).ProgressTimeLeft ? 1f : -1f)).ToString("00")}%");
                }
                else if (settings is SpinometerConfigModel)
                {
                    Create(settings, "Spinometer",
                           $"{((settings as SpinometerConfigModel).Mode == ICounterMode.SplitAverage ? $"{info.leftSpinAverage} | {info.rightSpinAverage}" : $"{(info.leftSpinAverage + info.rightSpinAverage) / 2}")}");
                }
                else if (settings is PBConfigModel)
                {
                    Create(settings, "", $"PB: {Math.Round((info.score / (info.score + UnityEngine.Random.Range(0.05f, 0.25f))) * 100, 2)}%");
                }
                else if (settings is NotesLeftConfigModel)
                {
                    Create(settings, $"Notes Remaining: {UnityEngine.Random.Range((int)15, 50)}", "");
                }
                else if (settings is FailConfigModel)
                {
                    Create(settings, $"Fails", $"{info.GetRandomInsult()}");
                }
            }
            else //Reduces calls to config. However with the new system I'm not sure if it matters all that much anymore.
            {
                if (settings is MissedConfigModel)
                {
                    Create(settings, "Missed", "0");
                }
                else if (settings is NoteConfigModel)
                {
                    Create(settings, "Notes", "0 / 0");
                }
                else if (settings is ScoreConfigModel)
                {
                    Create(settings, "100%", "SSS");
                }
                else if (settings is SpeedConfigModel)
                {
                    Create(settings, "Average Speed", "0");
                }
                else if (settings is CutConfigModel)
                {
                    Create(settings, "Average Cut", "0");
                }
                else if (settings is ProgressConfigModel)
                {
                    Create(settings, "Progress", "0%");
                }
                else if (settings is SpinometerConfigModel)
                {
                    Create(settings, "Spinometer", "0");
                }
                else if (settings is PBConfigModel)
                {
                    Create(settings, "", "PB: 0%");
                }
                else if (settings is NotesLeftConfigModel)
                {
                    Create(settings, "", "Notes Left");
                }
                else if (settings is FailConfigModel)
                {
                    Create(settings, "Fails", "A lot");
                }
            }
            if (settings is CustomConfigModel)
            {
                Create(settings, "", settings.DisplayName);
            }
        }