Пример #1
0
        public override void CounterInit()
        {
            // Yeah this is required.
            // If the Score Counter is all alone on its own Canvas with nothing to accompany them,
            // I need to give 'em a friend or else they get shy and hide away in the void.
            _ = CanvasUtility.CreateTextFromSettings(Settings, null);

            ScoreUIController scoreUIController = coreGameHUD.GetComponentInChildren <ScoreUIController>();
            TextMeshProUGUI   old           = ScoreUIText(ref scoreUIController);
            GameObject        baseGameScore = RelativeScoreGO(ref coreGameHUD);

            relativeScoreText       = baseGameScore.GetComponent <TextMeshProUGUI>();
            relativeScoreText.color = Color.white;
            GameObject baseGameRank = ImmediateRankGO(ref coreGameHUD);

            rankText       = baseGameRank.GetComponent <TextMeshProUGUI>();
            rankText.color = Color.white;

            Canvas currentCanvas = CanvasUtility.GetCanvasFromID(Settings.CanvasID);

            old.rectTransform.SetParent(currentCanvas.transform, true);
            baseGameScore.transform.SetParent(old.transform, true);
            baseGameRank.transform.SetParent(old.transform, true);

            if (!mainConfig.ItalicText)
            {
                old.fontStyle = relativeScoreText.fontStyle = rankText.fontStyle = FontStyles.Normal;
                Vector3 localPosition = relativeScoreText.rectTransform.localPosition;
                relativeScoreText.rectTransform.localPosition = new Vector3(0, localPosition.y, localPosition.z);
                localPosition = rankText.rectTransform.localPosition;
                rankText.rectTransform.localPosition = new Vector3(0, localPosition.y, localPosition.z);
            }

            switch (Settings.Mode)
            {
            case ScoreMode.RankOnly:
                Object.Destroy(baseGameScore.gameObject);
                break;

            case ScoreMode.ScoreOnly:
                Object.Destroy(baseGameRank.gameObject);
                break;
            }

            RectTransform pointsTextTransform = old.rectTransform;

            HUDCanvas currentSettings = CanvasUtility.GetCanvasSettingsFromID(Settings.CanvasID);

            Vector2 anchoredPos = CanvasUtility.GetAnchoredPositionFromConfig(Settings) + (offset * (3f / currentSettings.PositionScale));

            pointsTextTransform.localPosition    = anchoredPos * currentSettings.PositionScale;
            pointsTextTransform.localPosition    = new Vector3(pointsTextTransform.localPosition.x, pointsTextTransform.localPosition.y, 0);
            pointsTextTransform.localEulerAngles = Vector3.zero;

            Object.Destroy(coreGameHUD.GetComponentInChildren <ImmediateRankUIPanel>());

            relativeScoreAndImmediateRank.relativeScoreOrImmediateRankDidChangeEvent += UpdateText;

            UpdateText();
        }
Пример #2
0
        public override void CounterInit()
        {
            timeText          = CanvasUtility.CreateTextFromSettings(Settings);
            timeText.fontSize = 4;

            length  = atsc.songLength;
            songBPM = gcssd.difficultyBeatmap.level.beatsPerMinute;

            if (coreGameHUD != null)
            {
                GameObject baseGameProgress = SongProgressPanelGO(ref coreGameHUD);
                UnityEngine.Object.Destroy(baseGameProgress); // I'm sorry, little one.
            }

            if (Settings.Mode != ProgressMode.Percent)
            {
                var canvas = CanvasUtility.GetCanvasFromID(Settings.CanvasID);
                if (canvas != null)
                {
                    ImageView backgroundImage = CreateRing(canvas);
                    backgroundImage.rectTransform.anchoredPosition = timeText.rectTransform.anchoredPosition;
                    backgroundImage.CrossFadeAlpha(0.05f, 1f, false);
                    backgroundImage.transform.localScale = ringSize / 10;
                    backgroundImage.type = Image.Type.Simple;

                    progressRing = CreateRing(canvas);
                    progressRing.rectTransform.anchoredPosition = timeText.rectTransform.anchoredPosition;
                    progressRing.transform.localScale           = ringSize / 10;
                }
            }
        }
        public override void CounterInit()
        {
            try
            {
                _logger.Debug("Attempting to Initialize FPS Counter");

                _targetFramerate = (int)XRDevice.refreshRate;
                _logger.Debug($"Target framerate = {_targetFramerate}");

                _counterText             = CanvasUtility.CreateTextFromSettings(Settings);
                _counterText.color       = Color.white;
                _counterText.fontSize    = 2.5f;
                _counterText.lineSpacing = -50f;

                if (!_config.ShowRing)
                {
                    return;
                }

                var canvas = CanvasUtility.GetCanvasFromID(Settings.CanvasID);
                if (canvas == null)
                {
                    return;
                }

                _ringImage = _fpsCounterUtils.CreateRing(canvas);
                _ringImage.rectTransform.anchoredPosition = _counterText.rectTransform.anchoredPosition;
                _ringImage.transform.localScale           = _ringSize / 10;
            }
            catch (Exception ex)
            {
                _logger.Error("FPS Counter Done");
                _logger.Error(ex);
            }
        }
        public override void CounterInit()
        {
            // Reposition/reparent rank counter to destination canvas
            var currentCanvas   = CanvasUtility.GetCanvasFromID(Settings.CanvasID);
            var currentSettings = CanvasUtility.GetCanvasSettingsFromCanvas(currentCanvas);
            var positionScale   = currentSettings?.PositionScale ?? 10;
            var anchoredPos     = (CanvasUtility.GetAnchoredPositionFromConfig(Settings) + offset) * positionScale;

            multiplayerPositionHUDController.transform.SetParent(currentCanvas.transform, true);

            var rect = multiplayerPositionHUDController.transform as RectTransform;

            rect.anchoredPosition = anchoredPos;
            rect.localPosition    = new Vector3(rect.localPosition.x, rect.localPosition.y, 0);
            rect.localEulerAngles = Vector3.zero;

            // Iterate existing text and set italic shit
            if (!mainConfig.ItalicText)
            {
                foreach (var childText in multiplayerPositionHUDController.GetComponentsInChildren <CurvedTextMeshPro>(true))
                {
                    childText.fontStyle = FontStyles.Normal;
                }
            }
        }
        private void InitClassicMode()
        {
            // Yeah this is required.
            // If the Score Counter is all alone on its own Canvas with nothing to accompany them,
            // I need to give 'em a friend or else they get shy and hide away in the void.
            _ = CanvasUtility.CreateTextFromSettings(Settings, null);

            ScoreUIController scoreUIController = coreGameHUD.GetComponentInChildren <ScoreUIController>();
            TextMeshProUGUI   old = ScoreUIText(ref scoreUIController);

            // Setup Score Text
            GameObject baseGameScore = RelativeScoreGO(ref coreGameHUD);

            relativeScoreText       = baseGameScore.GetComponent <TextMeshProUGUI>();
            relativeScoreText.color = Color.white;

            // Setup Rank Text
            GameObject baseGameRank = ImmediateRankGO(ref coreGameHUD);

            rankText       = baseGameRank.GetComponent <TextMeshProUGUI>();
            rankText.color = Color.white;

            // Set up parenting
            Canvas currentCanvas = CanvasUtility.GetCanvasFromID(Settings.CanvasID);

            old.rectTransform.SetParent(currentCanvas.transform, true);
            baseGameScore.transform.SetParent(old.transform, true);

            // Hide score if we're not using it.
            if (!Configuration.Instance.showScore)
            {
                UnityEngine.Object.Destroy(baseGameScore.gameObject);
            }

            // Adjust font sizes.
            // TODO: Pull this from config?
            relativeScoreText.fontSize = 10;
            rankText.fontSize          = 30;


            baseGameRank.transform.SetParent(old.transform, true);
            RectTransform pointsTextTransform = old.rectTransform;
            HUDCanvas     currentSettings     = CanvasUtility.GetCanvasSettingsFromID(Settings.CanvasID);
            Vector2       anchoredPos         = CanvasUtility.GetAnchoredPositionFromConfig(Settings) + (offset * (3f / currentSettings.PositionScale));

            pointsTextTransform.localPosition    = anchoredPos * currentSettings.PositionScale;
            pointsTextTransform.localPosition    = new Vector3(pointsTextTransform.localPosition.x, pointsTextTransform.localPosition.y, 0);
            pointsTextTransform.localEulerAngles = Vector3.zero;

            UnityEngine.Object.Destroy(coreGameHUD.GetComponentInChildren <ImmediateRankUIPanel>());

            InitPercentageRing();

            // Shift text into proper positions
            rankText.rectTransform.anchoredPosition          += rankScoreOffset;
            relativeScoreText.rectTransform.anchoredPosition += rankScoreOffset;

            //relativeScoreAndImmediateRank.relativeScoreOrImmediateRankDidChangeEvent += UpdateClassicModeText;
            UpdateClassicModeText();
        }
        private void InitPercentageRing()
        {
            if (Configuration.Instance.showPercentageRing)
            {
                // Create ring
                var canvas = CanvasUtility.GetCanvasFromID(Settings.CanvasID);
                if (canvas != null)
                {
                    HUDCanvas currentSettings = CanvasUtility.GetCanvasSettingsFromID(Settings.CanvasID);
                    Vector2   ringAnchoredPos = CanvasUtility.GetAnchoredPositionFromConfig(Settings) * currentSettings.PositionScale;

                    ImageView backgroundImage = CreateRing(canvas);
                    backgroundImage.rectTransform.anchoredPosition = ringAnchoredPos;
                    backgroundImage.CrossFadeAlpha(0.05f, 1f, false);
                    backgroundImage.transform.localScale = ringSize / 10;
                    backgroundImage.type = Image.Type.Simple;

                    progressRing = CreateRing(canvas);
                    progressRing.rectTransform.anchoredPosition = ringAnchoredPos;
                    progressRing.transform.localScale           = ringSize / 10;
                }
                //relativeScoreAndImmediateRank.relativeScoreOrImmediateRankDidChangeEvent += UpdateRing;
                UpdateRing();
            }
        }
Пример #7
0
        public override void CounterInit()
        {
            ScoreUIController scoreUIController = coreGameHUD.GetComponentInChildren <ScoreUIController>();
            TextMeshProUGUI   old           = ScoreUIText(ref scoreUIController);
            GameObject        baseGameScore = RelativeScoreGO(ref coreGameHUD);

            relativeScoreText       = baseGameScore.GetComponent <TextMeshProUGUI>();
            relativeScoreText.color = Color.white;
            GameObject baseGameRank = ImmediateRankGO(ref coreGameHUD);

            rankText       = baseGameRank.GetComponent <TextMeshProUGUI>();
            rankText.color = Color.white;

            Canvas currentCanvas = CanvasUtility.GetCanvasFromID(Settings.CanvasID);

            old.rectTransform.SetParent(currentCanvas.transform, true);
            baseGameScore.transform.SetParent(old.transform, true);
            baseGameRank.transform.SetParent(old.transform, true);

            switch (Settings.Mode)
            {
            case ScoreMode.RankOnly:
                Object.Destroy(baseGameScore.gameObject);
                break;

            case ScoreMode.ScoreOnly:
                Object.Destroy(baseGameRank.gameObject);
                break;
            }

            RectTransform pointsTextTransform = old.rectTransform;

            HUDCanvas currentSettings = CanvasUtility.GetCanvasSettingsFromID(Settings.CanvasID);
            float     positionScale   = currentSettings?.PositionScale ?? 10;

            Vector2 anchoredPos = (CanvasUtility.GetAnchoredPositionFromConfig(Settings, currentSettings.IsMainCanvas) + offset) * positionScale;

            Plugin.Logger.Warn(anchoredPos.ToString());

            pointsTextTransform.anchoredPosition = anchoredPos;
            // I dont know why Personal Best has even the SLIGHTEST of influence on the position of Score Counter... but it does?
            if (!personalBest.Enabled)
            {
                pointsTextTransform.anchoredPosition -= new Vector2(0, 25);
            }
            pointsTextTransform.localPosition    = new Vector3(pointsTextTransform.localPosition.x, pointsTextTransform.localPosition.y, 0);
            pointsTextTransform.localEulerAngles = Vector3.zero;

            Object.Destroy(coreGameHUD.GetComponentInChildren <ImmediateRankUIPanel>());

            relativeScoreAndImmediateRank.relativeScoreOrImmediateRankDidChangeEvent += UpdateText;

            UpdateText();
        }
        private void InitPercentMode()
        {
            // Required. We need to get a handle to the game's default score counter and destroy it.
            _ = CanvasUtility.CreateTextFromSettings(Settings, null);
            ScoreUIController scoreUIController = coreGameHUD.GetComponentInChildren <ScoreUIController>();
            TextMeshProUGUI   old = ScoreUIText(ref scoreUIController);

            GameObject baseGameScore = RelativeScoreGO(ref coreGameHUD);
            GameObject baseGameRank  = ImmediateRankGO(ref coreGameHUD);

            // Set up parenting
            Canvas currentCanvas = CanvasUtility.GetCanvasFromID(Settings.CanvasID);

            old.rectTransform.SetParent(currentCanvas.transform, true);
            baseGameScore.transform.SetParent(old.transform, true);
            baseGameRank.transform.SetParent(old.transform, true);

            // Destroy Score
            UnityEngine.Object.Destroy(baseGameScore.gameObject);

            // Destroy Rank
            UnityEngine.Object.Destroy(baseGameRank.gameObject);

            if (!Configuration.Instance.showScore)
            {
                old.fontSize = 0;
            }

            percentMajorText          = CanvasUtility.CreateTextFromSettings(Settings);
            percentMajorText.fontSize = 7;
            percentMinorText          = CanvasUtility.CreateTextFromSettings(Settings);
            percentMinorText.fontSize = 3;

            RectTransform pointsTextTransform = old.rectTransform;
            HUDCanvas     currentSettings     = CanvasUtility.GetCanvasSettingsFromID(Settings.CanvasID);
            Vector2       anchoredPos         = CanvasUtility.GetAnchoredPositionFromConfig(Settings) + (offset * (3f / currentSettings.PositionScale));

            pointsTextTransform.localPosition    = anchoredPos * currentSettings.PositionScale;
            pointsTextTransform.localPosition    = new Vector3(pointsTextTransform.localPosition.x, pointsTextTransform.localPosition.y, 0);
            pointsTextTransform.localEulerAngles = Vector3.zero;
            UnityEngine.Object.Destroy(coreGameHUD.GetComponentInChildren <ImmediateRankUIPanel>());

            InitPercentageRing();

            percentMajorText.rectTransform.anchoredPosition += new Vector2(0.0f, 0.7f);
            percentMinorText.rectTransform.anchoredPosition += new Vector2(0.0f, -3.0f);

            prevPercentMajor = -1;
            prevPercentMinor = -1;
            //relativeScoreAndImmediateRank.relativeScoreOrImmediateRankDidChangeEvent += UpdatePercentModeText;
            UpdatePercentModeText();
        }
Пример #9
0
        public override void CounterInit()
        {
            length  = atsc.songLength;
            songBPM = gcssd.difficultyBeatmap.level.beatsPerMinute;

            timeText          = CanvasUtility.CreateTextFromSettings(Settings);
            timeText.fontSize = 4;

            // Set default text, which is visible in Multiplayer
            // Missing cases are covered by the default "_" case
            timeText.text = Settings.Mode switch
            {
                ProgressMode.Percent when Settings.ProgressTimeLeft => "100%",
                                                   ProgressMode.Percent when !Settings.ProgressTimeLeft => "0%",

                                                   ProgressMode.TimeInBeats when Settings.ProgressTimeLeft
                => $"{Mathf.Round(songBPM / 60 * length / 0.25f) * 0.25f:F2}",
                                                   ProgressMode.TimeInBeats when !Settings.ProgressTimeLeft => "0.00",

                                                   _ when Settings.ProgressTimeLeft => $"{atsc.songLength:F2}",
                                                   _ when !Settings.ProgressTimeLeft => "0:00"
            };

            // I'm sorry, little one.
            GameObject baseGameProgress = SongProgressPanelGO(ref coreGameHUD);

            UnityEngine.Object.Destroy(baseGameProgress);

            if (Settings.Mode != ProgressMode.Percent)
            {
                var canvas = CanvasUtility.GetCanvasFromID(Settings.CanvasID);
                if (canvas != null)
                {
                    ImageView backgroundImage = CreateRing(canvas);
                    backgroundImage.rectTransform.anchoredPosition = timeText.rectTransform.anchoredPosition;
                    backgroundImage.CrossFadeAlpha(0.05f, 1f, false);
                    backgroundImage.transform.localScale = ringSize / 10;
                    backgroundImage.type = Image.Type.Simple;

                    progressRing = CreateRing(canvas);
                    progressRing.rectTransform.anchoredPosition = timeText.rectTransform.anchoredPosition;
                    progressRing.transform.localScale           = ringSize / 10;

                    // Start progress ring at 100% or 0%, depending on how the ring will behave
                    progressRing.fillAmount = (Settings.ProgressTimeLeft && Settings.IncludeRing) ? 1 : 0;
                }
            }
        }
        public void Initialize()
        {
            coreGameHUDCanvasGroup = coreGameHUDController.GetComponent <CanvasGroup>();

            for (int i = -1; i < hudConfig.OtherCanvasSettings.Count; i++)
            {
                var canvas = canvasUtility.GetCanvasFromID(i).gameObject;

                var canvasGroup = canvas.AddComponent <CanvasGroup>();
                canvasGroup.alpha = 0;

                countersPlusCanvasGroups.Add(canvasGroup);
            }

            multiplayerController.stateChangedEvent += MultiplayerController_stateChangedEvent;
        }
Пример #11
0
        private void ReparentCanvas(Canvas canvas)
        {
            Canvas    currentCanvas   = CanvasUtility.GetCanvasFromID(Settings.CanvasID);
            HUDCanvas currentSettings = CanvasUtility.GetCanvasSettingsFromCanvas(currentCanvas);
            float     positionScale   = currentSettings?.PositionScale ?? 10;
            Vector2   anchoredPos     = CanvasUtility.GetAnchoredPositionFromConfig(Settings) * positionScale;

            canvas.transform.SetParent(currentCanvas.transform, true);

            RectTransform canvasRect = canvas.transform as RectTransform;

            canvasRect.anchoredPosition = anchoredPos;
            canvasRect.localPosition    = new Vector3(canvasRect.localPosition.x, canvasRect.localPosition.y, 0);
            canvasRect.localEulerAngles = Vector3.zero;

            PostReparent();
        }
Пример #12
0
        private bool CreateCounter()
        {
            _logger.Info("Creating counter");
            _counter          = CanvasUtility.CreateTextFromSettings(Settings);
            _counter.fontSize = 3;
            _counter.text     = "";

            var canvas = CanvasUtility.GetCanvasFromID(Settings.CanvasID);

            if (canvas == null)
            {
                Logger.logger.Warn("Cannot find counters+ canvas");
                return(false);
            }

            var counter = AssetBundleManager.SetupCustomCounter();

            _customCounter     = counter.Icon;
            _customCounterText = counter.Numbers;

            if (_customCounter == null || _customCounterText == null)
            {
                _logger.Error("Cannot create custom counter");
                return(false);
            }

            // position the counter as the counters+ one
            _customCounter.transform.localScale = Vector3.one / 30;
            _customCounter.transform.SetParent(canvas.transform, false);
            _customCounter.GetComponent <RectTransform>().anchoredPosition =
                _counter.rectTransform.anchoredPosition;
            _customCounter.transform.localPosition -= new Vector3(2, 0, 0); // recenter

            OnHRUpdate(null, new HRUpdateEventArgs(BPM.Instance.Bpm));      // give it an initial value

            if (counter.CurrentCanvas != null)
            {
                // destroy the unused game obj
                Object.Destroy(counter.CurrentCanvas);
            }
            HRController.OnHRUpdate += OnHRUpdate;
            return(true);
        }
        public override void CounterInit()
        {
            Canvas canvas = coreGameHUDController.GetComponentInChildren <SongProgressUIController>(true).GetComponent <Canvas>();

            canvas.gameObject.SetActive(true);

            Canvas    currentCanvas   = CanvasUtility.GetCanvasFromID(Settings.CanvasID);
            HUDCanvas currentSettings = CanvasUtility.GetCanvasSettingsFromCanvas(currentCanvas);
            float     positionScale   = currentSettings?.PositionScale ?? 10;
            Vector2   anchoredPos     = (CanvasUtility.GetAnchoredPositionFromConfig(Settings, currentSettings.IsMainCanvas) + offset) * positionScale;

            canvas.transform.SetParent(currentCanvas.transform, true);

            RectTransform canvasRect = canvas.transform as RectTransform;

            canvasRect.anchoredPosition = anchoredPos;
            canvasRect.localPosition    = new Vector3(canvasRect.localPosition.x, canvasRect.localPosition.y, 0);
            canvasRect.localEulerAngles = Vector3.zero;
        }