Ejemplo n.º 1
0
        public override void CounterInit()
        {
            modifiersModel = SCGameplayModsModel(ref scoreController);
            IDifficultyBeatmap beatmap = data.difficultyBeatmap;
            int maxRawScore            = ScoreModel.MaxRawScoreForNumberOfNotes(noteCountProcessor.NoteCount);

            maxPossibleScore = ScoreModel.GetModifiedScoreForGameplayModifiersScoreMultiplier(maxRawScore,
                                                                                              modifiersModel.GetTotalMultiplier(data.gameplayModifiers));
            stats     = playerDataModel.playerData.GetPlayerLevelStatsData(beatmap);
            highScore = stats.highScore;

            if (scoreConfig.Enabled && Settings.UnderScore)
            {
                HUDCanvas scoreCanvas = CanvasUtility.GetCanvasSettingsFromID(scoreConfig.CanvasID);
                counter = CanvasUtility.CreateTextFromSettings(scoreConfig, SCORE_COUNTER_OFFSET * (3f / scoreCanvas.PositionScale));
            }
            else
            {
                counter = CanvasUtility.CreateTextFromSettings(Settings);
            }
            counter.alignment = TextAlignmentOptions.Top;
            counter.fontSize  = Settings.TextSize;

            pbRatio = (float)highScore / maxPossibleScore;

            SetPersonalBest((float)highScore / maxPossibleScore);
            ScoreUpdated(0);
        }
Ejemplo n.º 2
0
        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);
            }
        }
Ejemplo n.º 3
0
        public override void CounterInit()
        {
            IDifficultyBeatmap beatmap = data.difficultyBeatmap;

            maxPossibleScore = ScoreModel.ComputeMaxMultipliedScoreForBeatmap(beatmapData);

            stats     = playerDataModel.playerData.GetPlayerLevelStatsData(beatmap);
            highScore = stats.highScore;

            if (scoreConfig.Enabled && Settings.UnderScore)
            {
                HUDCanvas scoreCanvas = CanvasUtility.GetCanvasSettingsFromID(scoreConfig.CanvasID);
                counter = CanvasUtility.CreateTextFromSettings(scoreConfig, SCORE_COUNTER_OFFSET * (3f / scoreCanvas.PositionScale));
            }
            else
            {
                counter = CanvasUtility.CreateTextFromSettings(Settings);
            }
            counter.alignment = TextAlignmentOptions.Top;
            counter.fontSize  = Settings.TextSize;

            pbRatio = (float)highScore / maxPossibleScore;

            SetPersonalBest(pbRatio);
            ScoreUpdated(0);
        }
Ejemplo n.º 4
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();
        }
Ejemplo n.º 5
0
        protected override void SpawnBackend(Entity target)
        {
            if (m_Canvas == null)
            {
                m_Canvas = CanvasUtility.Create(World, 0, "ServerRoom", defaultAddRaycaster: true);
                //CanvasUtility.DisableInteractionOnActivePopup(World, m_Canvas);
            }

            base.SpawnBackend(target);
            var rt = LastBackend.GetComponent <RectTransform>();

            rt.SetParent(m_Canvas.transform, false);

            var folder = AddressBuilder.Client()
                         .Interface()
                         .Menu()
                         .Folder("Screens")
                         .Folder("SettingsScreen");

            LastBackend.Data = new SettingsScreenData
            {
                Panels = new []
                {
                    folder.GetAsset("GraphicSettingsPanel"),
                    folder.GetAsset("AudioSettingsPanel")
                }
            };

            CanvasUtility.ExtendRectTransform(rt);
        }
        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();
        }
Ejemplo n.º 7
0
        public override void CounterInit()
        {
            ColorUtility.TryParseHtmlString("#FFA500", out orange);

            modifiersModel = SCGameplayModsModel(ref scoreController);
            IDifficultyBeatmap beatmap = data.difficultyBeatmap;
            int maxRawScore            = ScoreModel.MaxRawScoreForNumberOfNotes(beatmap.beatmapData.notesCount);

            maxPossibleScore = ScoreModel.GetModifiedScoreForGameplayModifiersScoreMultiplier(maxRawScore,
                                                                                              modifiersModel.GetTotalMultiplier(data.gameplayModifiers));
            stats     = playerDataModel.playerData.GetPlayerLevelStatsData(beatmap);
            highScore = stats.highScore;

            if (scoreConfig.Enabled && Settings.UnderScore)
            {
                counter = CanvasUtility.CreateTextFromSettings(scoreConfig, SCORE_COUNTER_OFFSET);
            }
            else
            {
                counter = CanvasUtility.CreateTextFromSettings(Settings);
            }
            counter.alignment = TextAlignmentOptions.Top;
            counter.fontSize  = Settings.TextSize;

            SetPersonalBest((float)highScore / maxPossibleScore);
        }
        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;
                }
            }
        }
Ejemplo n.º 9
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;
                }
            }
        }
Ejemplo n.º 10
0
        public static NodePanel CreateDefaultNodePanel(Node node, CanvasState canvasState)
        {
            // create the nodePanel rect
            Rect nodePanelRect = new Rect(new Vector2(0, 0), new Vector2(BehaviourEditorStyles.NODE_DEFAULT_WIDTH, BehaviourEditorStyles.NODE_DEFAULT_HEIGHT));

            int handleSize    = 16;
            int handlePadding = 2;

            Rect inHandleRect = new Rect(Vector2.zero, new Vector2(handleSize, handleSize));

            inHandleRect.center = new Vector2(nodePanelRect.width / 2,
                                              0 - handleSize / 2 - handlePadding);

            Rect outHandleRect = new Rect(Vector2.zero, new Vector2(handleSize, handleSize));

            outHandleRect.center = new Vector2(nodePanelRect.width / 2,
                                               (nodePanelRect.size.y) + (handleSize / 2) + handlePadding);

            //NodePanel nodePanel = new NodePanel(node, nodePanelRect, inHandleRect, outHandleRect);
            NodePanel nodePanel = node.CanHaveChildren ?
                                  new NodePanel(node, nodePanelRect, inHandleRect, outHandleRect, canvasState) :
                                  new NodePanel(node, nodePanelRect, inHandleRect, canvasState);

            nodePanel.SetIcon(CanvasUtility.GetIcon(node.GetType()));
            nodePanel.SetColours(Color.white, BehaviourEditorStyles.nodeNormalColour, 1);

            return(nodePanel);
        }
Ejemplo n.º 11
0
        public override void CounterInit()
        {
            right = saberManager.rightSaber;
            left  = saberManager.leftSaber;

            switch (Settings.Mode)
            {
            case SpeedMode.Average:
            case SpeedMode.SplitAverage:
                GenerateBasicText("Average Speed", out averageCounter);
                break;

            case SpeedMode.Top5Sec:
                GenerateBasicText("Recent Top Speed", out fastestCounter);
                break;

            case SpeedMode.Both:
            case SpeedMode.SplitBoth:
                GenerateBasicText("Average Speed", out averageCounter);
                var label = CanvasUtility.CreateTextFromSettings(Settings, new Vector3(0, -1, 0));
                label.fontSize      = 3;
                label.text          = "Recent Top Speed";
                fastestCounter      = CanvasUtility.CreateTextFromSettings(Settings, new Vector3(0, -1.4f, 0));
                fastestCounter.text = "0";
                break;
            }
        }
Ejemplo n.º 12
0
        public override void CounterInit()
        {
            string defaultValue = FormatLabel(0, 0, Settings.AveragePrecision);

            var label = CanvasUtility.CreateTextFromSettings(Settings);

            label.text     = "Average Cut";
            label.fontSize = 3;

            Vector3 leftOffset             = Vector3.up * -0.2f;
            TextAlignmentOptions leftAlign = TextAlignmentOptions.Top;

            if (Settings.SeparateSaberCounts)
            {
                cutCounterRight             = CanvasUtility.CreateTextFromSettings(Settings, new Vector3(0.2f, -0.2f, 0));
                cutCounterRight.lineSpacing = -26;
                cutCounterRight.text        = Settings.SeparateCutValues ? $"{defaultValue}\n{defaultValue}\n{defaultValue}" : $"{defaultValue}";
                cutCounterRight.alignment   = TextAlignmentOptions.TopLeft;

                leftOffset = new Vector3(-0.2f, -0.2f, 0);
                leftAlign  = TextAlignmentOptions.TopRight;
            }

            cutCounterLeft             = CanvasUtility.CreateTextFromSettings(Settings, leftOffset);
            cutCounterLeft.lineSpacing = -26;
            cutCounterLeft.text        = Settings.SeparateCutValues ? $"{defaultValue}\n{defaultValue}\n{defaultValue}" : $"{defaultValue}";
            cutCounterLeft.alignment   = leftAlign;

            scoreController.scoringForNoteFinishedEvent += ScoreController_scoringForNoteFinishedEvent;
        }
        public override void CounterInit()
        {
            string defaultValue = FormatTimeDependence(0, GetDecimals());
            var    label        = CanvasUtility.CreateTextFromSettings(Settings);

            label.text     = "Time Dependence";
            label.fontSize = 3;

            Vector3 leftOffset             = Vector3.up * -0.2f;
            TextAlignmentOptions leftAlign = TextAlignmentOptions.Top;

            if (Configuration.Instance.separateSaber)
            {
                _counterRight             = CanvasUtility.CreateTextFromSettings(Settings, new Vector3(0.2f, -0.2f, 0));
                _counterRight.lineSpacing = -26;
                _counterRight.text        = defaultValue;
                _counterRight.alignment   = TextAlignmentOptions.TopLeft;

                leftOffset = new Vector3(-0.2f, -0.2f, 0);
                leftAlign  = TextAlignmentOptions.TopRight;
            }

            _counterLeft             = CanvasUtility.CreateTextFromSettings(Settings, leftOffset);
            _counterLeft.lineSpacing = -26;
            _counterLeft.text        = defaultValue;
            _counterLeft.alignment   = leftAlign;
        }
Ejemplo n.º 14
0
        public override void OnPointerDrag(PointerEvent evt)
        {
            NodeHandle handle   = (NodeHandle)evt.downObject;
            Vector2    mousePos = evt.mousePos;

            if (_draggingHandle == null)
            {
                if (handle.type == NodeHandle.HandleType.Out)
                {
                    _nodeCanvas.CreatePreviewConnection(handle, evt.mousePos);
                    _draggingHandle = handle;
                }
                else
                {
                    NodePanel parent = handle.NodePanel.Parent;
                    if (parent != null)
                    {
                        _draggingHandle = parent.outHandle;
                        _nodeCanvas.RemoveChild(handle.NodePanel);
                        _nodeCanvas.CreatePreviewConnection(parent.outHandle, evt.mousePos);
                    }
                }
            }

            if (_draggingHandle != null && _nodeCanvas.previewConnection != null)
            {
                _nodeCanvas.previewConnection.SetEndPosition(CanvasUtility.ScreenToCanvasPosition(mousePos, _nodeCanvas.canvasState));
                _nodeCanvas.previewConnection.UpdatePoints(new List <NodeConnection>());
            }
        }
        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();
            }
        }
Ejemplo n.º 16
0
        public override void CounterInit()
        {
            right = playerController.rightSaber;
            left  = playerController.leftSaber;

            switch (Settings.Mode)
            {
            case SpeedMode.Average:
            case SpeedMode.SplitAverage:
                GenerateBasicText("Average Speed", out averageCounter);
                break;

            case SpeedMode.Top5Sec:
                GenerateBasicText("Recent Top Speed", out fastestCounter);
                SharedCoroutineStarter.instance.StartCoroutine(FastestSpeed());
                break;

            case SpeedMode.Both:
            case SpeedMode.SplitBoth:
                GenerateBasicText("Average Speed", out averageCounter);
                var label = CanvasUtility.CreateTextFromSettings(Settings, new Vector3(0, -1, 0));
                label.fontSize = 3;
                label.text     = "Recent Top Speed";
                fastestCounter = CanvasUtility.CreateTextFromSettings(Settings, new Vector3(0, -1.4f, 0));
                SharedCoroutineStarter.instance.StartCoroutine(FastestSpeed());
                break;
            }
        }
        /// <summary>
        /// PutReference()
        /// Static method which is responsible
        /// for manually updating the patient list in Canvas Oncology App
        /// </summary>
        public static void doReferenceUpdate()
        {
            API settings = new API();

            // make new canvas object
            Canvas c = new Canvas();

            // set the rows for the object based on the data set
            CanvasUtility.SetCanvasRows(c);

            // set canvas url
            CanvasUtility.SetCanvasURL(c,
                                       Canvas.RequestType.ReferencePut);

            // don't process request if there are no rows avaliable
            if (c.Rows.Count == 0)
            {
                return;
            }

            // get the last identity
            Identity lastIdentity = IdentityController.GetLastIdentity();

            // update the text file
            FileStoreUtility.UpdateIndex(lastIdentity.lastId.ToString());

            // make xml
            XMLController.BuildXML(c);

            // get payload
            string XMLPayload = File.ReadAllText(settings.XML_FILE_NAME);

            // make request to update fields
            XMLController.doRequest(c, XMLPayload);
        }
Ejemplo n.º 18
0
        public override void OnPointerDrag(PointerEvent evt)
        {
            if (evt.shift)
            {
                return;
            }

            if (topLevelPanels == null)
            {
                topLevelPanels = GetTopLevelPanels(_nodeCanvas.selectedPanels);
            }

            float factor = BehaviourEditor.SNAPPING_FACTOR;

            deltaPos += evt.deltaPos;

            float deltaX = Mathf.Abs(deltaPos.x) > factor ? deltaPos.x : 0;
            float deltaY = Mathf.Abs(deltaPos.y) > factor ? deltaPos.y : 0;

            for (int i = 0; i < topLevelPanels.Count; i++)
            {
                NodePanel draggingPanel = topLevelPanels[i];
                draggingPanel.transform.position += new Vector2(deltaX, deltaY);
                draggingPanel.transform.position  = CanvasUtility.SnapPosition(draggingPanel.transform.position, factor);

                if (draggingPanel.Parent != null)
                {
                    draggingPanel.Parent.outHandle.UpdateConnections();
                }

                draggingPanel.UpdateAllConnections();
            }

            deltaPos = new Vector2(deltaX == 0 ? deltaPos.x : 0, deltaY == 0 ? deltaPos.y : 0);
        }
Ejemplo n.º 19
0
        public override void CounterInit()
        {
            if (setupData.practiceSettings != null && setupData.practiceSettings.startInAdvanceAndClearNotes)
            {
                float startTime = setupData.practiceSettings.startSongTime;
                // This LINQ statement is to ensure compatibility with Practice Mode / Practice Plugin
                notesLeft = noteCountProcessor.Data.Count(x => x.time > startTime);
            }
            else
            {
                notesLeft = noteCountProcessor.NoteCount;
            }

            if (Settings.LabelAboveCount)
            {
                GenerateBasicText("Notes Remaining", out counter);
                counter.text = notesLeft.ToString();
            }
            else
            {
                counter          = CanvasUtility.CreateTextFromSettings(Settings);
                counter.text     = $"Notes Remaining: {notesLeft}";
                counter.fontSize = 2;
            }
        }
Ejemplo n.º 20
0
        public override void CounterInit()
        {
            var header = CanvasUtility.CreateTextFromSettings(Settings);

            header.text     = "William Gay";
            header.fontSize = 3;

            williamGayness = CanvasUtility.CreateTextFromSettings(Settings, new Vector3(0, -0.4f, 0));
        }
Ejemplo n.º 21
0
        public override void CounterInit()
        {
            Logger.log.Debug("Creating nightscout counter...");
            bgText       = CanvasUtility.CreateTextFromSettings(Settings);
            bgText.text  = "--- mg/dl";
            bgText.color = Color.white;
            UpdateText(null, NightscoutDataService.cachedData);

            NightscoutDataService.BGEvent += UpdateText;
        }
Ejemplo n.º 22
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();
        }
Ejemplo n.º 23
0
        private void DrawBoxSelection()
        {
            Rect r = CanvasUtility.WorldToCanvasRect(canvas.boxSelection, canvas.canvasState);

            GUI.color = BehaviourEditorStyles.BOX_SELECTION_COLOUR;
            GUI.DrawTexture(r, new Texture2D(5, 5));
            Handles.color = BehaviourEditorStyles.BOX_SELECTION_OUTLINE_COLOUR;
            Handles.DrawLine(new Vector3(r.min.x, r.min.y, 0), new Vector3(r.max.x, r.min.y, 0));
            Handles.DrawLine(new Vector3(r.max.x, r.min.y, 0), new Vector3(r.max.x, r.max.y, 0));
            Handles.DrawLine(new Vector3(r.min.x, r.max.y, 0), new Vector3(r.max.x, r.max.y, 0));
            Handles.DrawLine(new Vector3(r.min.x, r.min.y, 0), new Vector3(r.min.x, r.max.y, 0));
        }
        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();
        }
        public static void Patch(HarmonyObj obj, CanvasUtility canvas, HUDConfigModel hud, MenuUIInstaller menuUIInstaller)
        {
            if (obj.GetPatchedMethods().Any(x => x == menuTransitions))
            {
                obj.Unpatch(menuTransitions, transpiler);
            }

            canvasUtility = canvas;
            hudConfig     = hud;
            menuInstaller = menuUIInstaller;

            obj.Patch(menuTransitions, null, null, new HarmonyMethod(transpiler));
        }
Ejemplo n.º 26
0
        protected override void SpawnBackend(Entity target)
        {
            if (m_Canvas == null)
            {
                m_Canvas = CanvasUtility.Create(World, 0, "ServerRoom", defaultAddRaycaster: true);
            }

            base.SpawnBackend(target);
            var rt = LastBackend.GetComponent <RectTransform>();

            rt.SetParent(m_Canvas.transform, false);

            CanvasUtility.ExtendRectTransform(rt);
        }
        protected override void OnCreate()
        {
            base.OnCreate();
            EntityManager.CreateEntity(typeof(MenuData));

            m_Canvas = CanvasUtility.Create(World, -1, "Background Canvas");
            var bgGo = new GameObject("BackgroundQuad", typeof(RectTransform), typeof(CanvasRenderer), typeof(Image));

            bgGo.transform.SetParent(m_Canvas.transform, false);

            m_QuadBackground = bgGo.GetComponent <Image>();
            CanvasUtility.ExtendRectTransform(m_QuadBackground.GetComponent <RectTransform>());

            SetBackgroundCanvasColor(Color.clear);
        }
        protected override void SpawnBackend(Entity target)
        {
            base.SpawnBackend(target);

            var rt = LastBackend.GetComponent <RectTransform>();

            CanvasUtility.ExtendRectTransform(rt);

            var layout = LastBackend.GetComponent <LayoutElement>();

            layout.preferredHeight = 60;
            layout.minWidth        = 125;
            layout.minHeight       = 60;
            layout.flexibleWidth   = 1;
        }
Ejemplo n.º 29
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;
                }
            }
        }
Ejemplo n.º 30
0
        void CreatePattern(Texture2D pattern)
        {
            if (parent == null)
            {
                SetParent = CurrentRaycastObject().GetComponent <Image>().canvas.GetComponent <RectTransform>();
            }

            GameObject go    = new GameObject("Pattern");
            Image      image = go.AddComponent <Image>();

            go.transform.SetParent(parent, false);

            go.GetComponent <RectTransform>().ScreenPointToRectPosition(pointerPosition, image.canvas.scaleFactor);
            image.sprite     = CanvasUtility.GetSprite(TextureUtility.CopyTexture(pattern));
            previousPosition = pointerPosition;
        }