Exemple #1
0
        /// <summary>
        /// Set the global watermark to show that the player has hmd only custom notes.
        /// </summary>
        public static void CreateWatermark()
        {
            if (_watermarkObject != null)
            {
                return;
            }
            _watermarkObject = new GameObject("CustomNotes Watermark");
            _watermarkObject.transform.localScale = new Vector3(0.05f, 0.05f, 0.05f);
            _watermarkObject.transform.position   = new Vector3(0f, 0.025f, 0.8f);
            _watermarkObject.transform.rotation   = Quaternion.Euler(90, 0, 0);

            Canvas watermarkCanvas = _watermarkObject.AddComponent <Canvas>();

            watermarkCanvas.renderMode = RenderMode.WorldSpace;
            ((RectTransform)watermarkCanvas.transform).sizeDelta = new Vector2(100, 50);

            CurvedCanvasSettings canvasSettings = _watermarkObject.AddComponent <CurvedCanvasSettings>();

            canvasSettings.SetRadius(0f);

            CurvedTextMeshPro text = (CurvedTextMeshPro)BeatSaberUI.CreateText((RectTransform)watermarkCanvas.transform, "Custom Notes Enabled", new Vector2(0, 0));

            text.alignment = TextAlignmentOptions.Center;
            text.color     = new Color(0.95f, 0.95f, 0.95f);

            SetLayer(_watermarkObject, NoteLayer.ThirdPerson);
        }
Exemple #2
0
        private void OnEnable()
        {
            if (_cell != null)
            {
                _cell.highlightDidChangeEvent += OnHighlightDidChange;
                _cell.selectionDidChangeEvent += OnSelectionDidChange;

                RefreshBackground();

                SongName      = _cell.transform.Find("SongName").GetComponent <CurvedTextMeshPro>();
                SongAuthor    = _cell.transform.Find("SongAuthor").GetComponent <CurvedTextMeshPro>();
                FavoritesIcon = _cell.transform.Find("FavoritesIcon").GetComponent <ImageView>();
                SongTime      = _cell.transform.Find("SongTime").GetComponent <CurvedTextMeshPro>();
                SongBpm       = _cell.transform.Find("SongBpm").GetComponent <CurvedTextMeshPro>();
                BpmIcon       = _cell.transform.Find("BpmIcon").GetComponent <ImageView>();

                // Re-align BPM text and allow more horizontal space - we use this for extended lobby type
                var songBpmTransform = SongBpm.transform as RectTransform;
                songBpmTransform.anchorMax = new Vector2(1.03f, 0.5f);
                songBpmTransform.offsetMin = new Vector2(-32.00f, -4.60f);

                // Limit text size for server name and song name
                (SongName.transform as RectTransform).anchorMax   = new Vector2(0.8f, 0.5f);
                (SongAuthor.transform as RectTransform).anchorMax = new Vector2(0.8f, 0.5f);

                RefreshContent();
            }

            _enabled = true;
        }
Exemple #3
0
        internal void ToggleSelectedDifficultyHighlight()
        {
            if (selectedPlaylistSong != null)
            {
                List <SegmentedControlCell> difficultyCells = Accessors.SegmentedControllerCellsAccessor(ref beatmapDifficultySegmentedControl);
                if (IsSelectedDifficultyHighlighted)
                {
                    selectedPlaylistSong.Difficulties.RemoveAll(d => d.BeatmapDifficulty == beatmapDifficultySegmentedControlController.selectedDifficulty);
                    SegmentedControlCell cellToUnhighlight = difficultyCells[beatmapDifficultySegmentedControlController.GetClosestDifficultyIndex(beatmapDifficultySegmentedControlController.selectedDifficulty)];
                    CurvedTextMeshPro    textToUnhighlight = cellToUnhighlight.GetComponentInChildren <CurvedTextMeshPro>();
                    textToUnhighlight.faceColor = new UnityEngine.Color32(255, 255, 255, 255);
                }
                else
                {
                    if (selectedPlaylistSong.Difficulties == null)
                    {
                        selectedPlaylistSong.Difficulties = new List <Difficulty>();
                    }
                    Difficulty difficulty = new Difficulty();
                    difficulty.BeatmapDifficulty = beatmapDifficultySegmentedControlController.selectedDifficulty;
                    difficulty.Characteristic    = beatmapCharacteristicSegmentedControlController.selectedBeatmapCharacteristic.serializedName;
                    selectedPlaylistSong.AddDifficulty(difficulty);

                    SegmentedControlCell cellToHighlight = difficultyCells[beatmapDifficultySegmentedControlController.GetClosestDifficultyIndex(beatmapDifficultySegmentedControlController.selectedDifficulty)];
                    CurvedTextMeshPro    textToHighlight = cellToHighlight.GetComponentInChildren <CurvedTextMeshPro>();
                    textToHighlight.faceColor = new UnityEngine.Color32(255, 255, 0, 255);
                }
            }
        }
        private void Awake()
        {
            Logger.Log("Awake call");
            this.rootObject = new GameObject("Nowplay Canvas", typeof(Canvas), typeof(CurvedCanvasSettings), typeof(VerticalLayoutGroup), typeof(ContentSizeFitter));

            var sizeFitter = this.rootObject.GetComponent <ContentSizeFitter>();

            sizeFitter.verticalFit     = ContentSizeFitter.FitMode.PreferredSize;
            sizeFitter.horizontalFit   = ContentSizeFitter.FitMode.PreferredSize;
            this._canvas               = this.rootObject.GetComponent <Canvas>();
            this._canvas.sortingOrder  = 3;
            this._curvedCanvasSettings = this.rootObject.GetComponent <CurvedCanvasSettings>();
            this._curvedCanvasSettings.SetRadius(0);
            this._canvas.renderMode = RenderMode.WorldSpace;
            var rectTransform = this._canvas.transform as RectTransform;

            rectTransform.sizeDelta = CanvasSize;
            this.SetLocation((Location)PluginConfig.Instance.NowPlayingLocation);
            this._nowPlayingText = this.CreateText(this._canvas.transform as RectTransform, String.Empty, new Vector2(10, 31));
            rectTransform        = this._nowPlayingText.transform as RectTransform;
            rectTransform.SetParent(this._canvas.transform, false);
            rectTransform.anchoredPosition = Vector2.one / 2;
            this._nowPlayingText.text      = String.Empty;
            this._nowPlayingText.fontSize  = 14;
            this.SetTextColor();
        }
        static void Postfix(List <IConnectedPlayer> sortedPlayers, ILobbyPlayersDataModel lobbyPlayersDataModel, GameServerPlayersTableView __instance)
        {
            IPreviewBeatmapLevel hostBeatmap = lobbyPlayersDataModel.GetPlayerBeatmapLevel(lobbyPlayersDataModel.hostUserId);

            if (hostBeatmap != null && hostBeatmap is PreviewBeatmapStub hostBeatmapStub)
            {
                TableView tableView = __instance.GetField <TableView, GameServerPlayersTableView>("_tableView");
                foreach (TableCell cell in tableView.visibleCells)
                {
                    if (cell is GameServerPlayerTableCell playerCell)
                    {
                        Image             background      = playerCell.GetField <Image, GameServerPlayerTableCell>("_localPlayerBackgroundImage");
                        CurvedTextMeshPro emptySuggestion = playerCell.GetField <CurvedTextMeshPro, GameServerPlayerTableCell>("_emptySuggestedLevelText");
                        CurvedTextMeshPro suggestion      = playerCell.GetField <CurvedTextMeshPro, GameServerPlayerTableCell>("_suggestedLevelText");
                        IConnectedPlayer  player          = sortedPlayers[playerCell.idx];
                        Color             backgroundColor = new Color();

                        if (player.isConnectionOwner)
                        {
                            suggestion.gameObject.SetActive(false);
                            emptySuggestion.gameObject.SetActive(true);
                            emptySuggestion.text = "Loading...";
                            hostBeatmapStub.isDownloadable.ContinueWith(r =>
                            {
                                HMMainThreadDispatcher.instance.Enqueue(() =>
                                {
                                    suggestion.gameObject.SetActive(true);
                                    emptySuggestion.gameObject.SetActive(false);
                                });
                            });
                        }
                        // TODO: check merge
                        background.enabled = true;
                        if (player.HasState("beatmap_downloaded") || player.HasState("start_primed"))
                        {
                            backgroundColor   = green;
                            backgroundColor.a = player.isMe ? 0.4f : 0.1f;
                            background.color  = backgroundColor;
                        }
                        else
                        {
                            hostBeatmapStub.isDownloadable.ContinueWith(r =>
                            {
                                bool downloadable = r.Result;
                                backgroundColor   = downloadable ? yellow : red;
                                backgroundColor.a = player.isMe ? 0.4f : 0.1f;
                                HMMainThreadDispatcher.instance.Enqueue(() =>
                                {
                                    background.color = backgroundColor;
                                });
                            });
                        }
                    }
                }
            }
        }
Exemple #6
0
        private void AddMenuOption()
        {
            Transform dropdownTemplate     = _gameplaySetupViewController.transform.Find("EnvironmentOverrideSettings/Settings/Elements/NormalLevels");
            Transform otherSettingsContent = _settingsNavigationController.transform.Find("OtherSettings/Content");

            if (!dropdownTemplate)
            {
                Plugin.Log.Error("Dropdown template not found!");
                return;
            }

            if (!otherSettingsContent)
            {
                Plugin.Log.Error("OtherSettings/Content not found!");
                return;
            }

            GameObject gameObject = _container.InstantiatePrefab(dropdownTemplate.gameObject, otherSettingsContent);

            gameObject.name = "LanguageSetting";

            RectTransform rectTransform = gameObject.GetComponent <RectTransform>();

            rectTransform.offsetMin = new Vector2(0, -14.2f);
            rectTransform.offsetMax = new Vector2(0, -7.2f);

            LocalizedTextMeshProUGUI label = gameObject.transform.Find("Label").GetComponent <LocalizedTextMeshProUGUI>();

            label.Key = "SETTINGS_LANGUAGE";

            _languageSetting = _container.InstantiateComponent <LanguageSetting>(gameObject);

            Plugin.Log.Debug("Created language setting");

            var textGameObject = new GameObject("SiraLocalizerContributorsText");

            _credits = textGameObject.AddComponent <CurvedTextMeshPro>();
            _credits.fontMaterial = label.gameObject.GetComponent <CurvedTextMeshPro>().fontMaterial;

            var textRectTransform = (RectTransform)textGameObject.transform;

            textRectTransform.SetParent(otherSettingsContent, false);
            textRectTransform.offsetMin = new Vector2(-45f, -14.4f);
            textRectTransform.offsetMax = new Vector2(45f, -7.4f);

            _credits.alignment   = TextAlignmentOptions.TopLeft;
            _credits.lineSpacing = -35f;
            _credits.fontSize    = 3f;
            _credits.fontStyle   = FontStyles.Italic;
        }
        private static void Postfix(ref TextMeshProUGUI ____rankText, ref GameObject ____clearedBannerGo, ref GameObject ____failedBannerGo)
        {
            ____rankText.overflowMode = TextOverflowModes.Overflow;
            ____rankText.richText     = true;

            GameObject bannerGo = ____clearedBannerGo.activeInHierarchy ? ____clearedBannerGo : ____failedBannerGo;

            GameObject        bgGo = bannerGo.transform.Find("BG").gameObject;
            CurvedTextMeshPro tmp  = bannerGo.GetComponentInChildren <CurvedTextMeshPro>();

            if (bannerGo == ____failedBannerGo)
            {
                tmp.color = Color.red;
            }
            if (bgGo != null)
            {
                bgGo.SetActive(true);
            }
            if (ScoreSubmission.WasDisabled || ScoreSubmission.prolongedDisable)
            {
                string        color = "<color=#ff0000ff>";
                StringBuilder scoreSubmissionTextBuilder = new StringBuilder("  \r\n").Append(color).Append("<size=50%><b>Score Submission Disabled by: ");
                if (ScoreSubmission.WasDisabled)
                {
                    scoreSubmissionTextBuilder.Append(ScoreSubmission.LastDisabledModString);

                    if (ScoreSubmission.prolongedDisable)
                    {
                        scoreSubmissionTextBuilder.Append(" | ");
                    }
                }

                if (ScoreSubmission.prolongedDisable)
                {
                    scoreSubmissionTextBuilder.Append(ScoreSubmission.ProlongedModString);
                }

                tmp.color = Color.white;
                tmp.text += scoreSubmissionTextBuilder.ToString();
                tmp.enableWordWrapping = false;
                if (bgGo != null)
                {
                    bgGo.SetActive(false);
                }
            }

            ScoreSubmission.ModList.Clear();
            ScoreSubmission.disabled = false;
        }
        public void Init(LevelListTableCell originalTableCell)
        {
            _backgroundImage = transform.Find("Background").GetComponent <ImageView>();
            _nameText        = transform.Find("SongName").GetComponent <CurvedTextMeshPro>();
            _authorText      = transform.Find("SongAuthor").GetComponent <CurvedTextMeshPro>();
            _cover           = transform.Find("CoverImage").GetComponent <ImageView>();

            _nameText.richText   = false;
            _authorText.richText = false;

            _nameText.name   = "AvatarName";
            _authorText.name = "AvatarAuthor";

            _wasPressedSignal = originalTableCell.GetField <Signal, SelectableCell>("_wasPressedSignal");
        }
        static void Postfix(ref TextMeshProUGUI ____rankText, ref GameObject ____clearedBannerGo, ref GameObject ____failedBannerGo)
        {
            ____rankText.overflowMode = TextOverflowModes.Overflow;
            ____rankText.richText     = true;
            //   ____failedDifficultyText.overflowMode = TextOverflowModes.Overflow;
            //   ____failedDifficultyText.richText = true;
            GameObject bannerGo = ____clearedBannerGo.activeInHierarchy ? ____clearedBannerGo : ____failedBannerGo;

            GameObject        bgGo = bannerGo.transform.Find("BG").gameObject;
            CurvedTextMeshPro tmp  = bannerGo.GetComponentInChildren <CurvedTextMeshPro>();

            if (bannerGo == ____failedBannerGo)
            {
                tmp.color = Color.red;
            }
            if (bgGo != null)
            {
                bgGo.SetActive(true);
            }
            if (ScoreSubmission.WasDisabled || ScoreSubmission.disabled || ScoreSubmission.prolongedDisable)
            {
                string color = "<color=#ff0000ff>";
                string scoresubmissiontext = $"  \r\n{color}<size=50%><b>Score Submission Disabled by: " +
                                             ScoreSubmission.LastDisabledModString +
                                             " | " +
                                             ScoreSubmission.ProlongedModString;
                tmp.color = Color.white;
                tmp.text += scoresubmissiontext;
                tmp.enableWordWrapping = false;
                if (bgGo != null)
                {
                    bgGo.SetActive(false);
                }

                /*
                 * ____failedDifficultyText.text += "  \r\n<color=#ff0000ff><size=60%><b>Score Submission Disabled by: " +
                 *  ScoreSubmission.LastDisabledModString +
                 *  " | " +
                 *  ScoreSubmission.ProlongedModString;
                 */
            }


            ScoreSubmission.ModList.Clear();
            ScoreSubmission.disabled = false;
        }
Exemple #10
0
            public void Initialize()
            {
                var bottomContainer = _resultsViewController.GetField <Button, ResultsViewController>("_continueButton").transform.parent;
                var textGameObject  = new GameObject("SiraUtilSubmissionDisplay");

                _curvedText = textGameObject.AddComponent <CurvedTextMeshPro>();
                textGameObject.transform.SetParent(bottomContainer);
                (textGameObject.transform as RectTransform).sizeDelta = new Vector2(40f, 100f);
                textGameObject.transform.localPosition = new Vector2(0f, -51f);
                textGameObject.transform.localScale    = Vector3.one;
                _curvedText.alignment   = TextAlignmentOptions.Top;
                _curvedText.lineSpacing = -45f;
                _curvedText.fontSize    = 3.5f;
                _curvedText.gameObject.SetActive(false);
                _resultsViewController.didActivateEvent   += ResultsViewController_DidActivate;
                _resultsViewController.didDeactivateEvent += ResultsViewController_DidDeactivate;
            }
Exemple #11
0
 protected override void DidActivate(bool firstActivation, bool addedToHierarchy, bool screenSystemEnabling)
 {
     base.DidActivate(firstActivation, addedToHierarchy, screenSystemEnabling);
     if (firstActivation)
     {
         var textGameObject = gameObject;
         _curvedText = textGameObject.AddComponent <CurvedTextMeshPro>();
         textGameObject.transform.SetParent(transform);
         (textGameObject.transform as RectTransform).sizeDelta = new Vector2(40f, 100f);
         (textGameObject.transform as RectTransform).anchorMin = new Vector2(0f, 0f);
         (textGameObject.transform as RectTransform).anchorMax = new Vector2(0f, 0f);
         textGameObject.transform.localPosition = new Vector2(0f, -51f);
         textGameObject.transform.localScale    = Vector3.one;
         _curvedText.alignment   = TextAlignmentOptions.Center;
         _curvedText.lineSpacing = -45f;
         _curvedText.fontSize    = 3.5f;
         _curvedText.gameObject.SetActive(false);
     }
 }
Exemple #12
0
        private void HighlightDifficultiesForSelectedCharacteristic()
        {
            if (selectedPlaylistSong != null && selectedPlaylistSong.Difficulties != null && selectedPlaylistSong.Difficulties.Count != 0)
            {
                List <Difficulty>           difficultiesToHighlight = selectedPlaylistSong.Difficulties.FindAll(difficulty => difficulty.Characteristic.ToUpper() == beatmapCharacteristicSegmentedControlController.selectedBeatmapCharacteristic.serializedName.ToUpper());
                List <BeatmapDifficulty>    availaibleDifficulties  = Accessors.DifficultiesAccessor(ref beatmapDifficultySegmentedControlController);
                List <SegmentedControlCell> difficultyCells         = Accessors.SegmentedControllerCellsAccessor(ref beatmapDifficultySegmentedControl);

                foreach (var difficulty in difficultiesToHighlight)
                {
                    if (availaibleDifficulties.Contains(difficulty.BeatmapDifficulty))
                    {
                        SegmentedControlCell cellToHighlight = difficultyCells[beatmapDifficultySegmentedControlController.GetClosestDifficultyIndex(difficulty.BeatmapDifficulty)];
                        CurvedTextMeshPro    textToHighlight = cellToHighlight.GetComponentInChildren <CurvedTextMeshPro>();
                        textToHighlight.faceColor = new UnityEngine.Color32(255, 255, 0, 255);
                    }
                }
            }
        }
Exemple #13
0
        public static void Postfix(TextSegmentedControlCell __result)
        {
            CurvedTextMeshPro text = __result.transform.Find("Text").GetComponent <CurvedTextMeshPro>();

            if (text.alignment != TextAlignmentOptions.Midline)
            {
                return;
            }

            // Midline text alignment breaks if certain characters are taller than others
            // e.g. the accent on É makes it taller than regular ASCII letters
            text.alignment = TextAlignmentOptions.Baseline;

            // this value is eyeballed
            Vector2 offset = new Vector2(0, 0.3f * text.fontSize);

            text.rectTransform.offsetMin -= offset;
            text.rectTransform.offsetMax -= offset;
        }
Exemple #14
0
        /// <summary>
        /// Creates a TextMeshProUGUI component.
        /// </summary>
        /// <param name="parent">The transform to parent the new TextMeshProUGUI component to.</param>
        /// <param name="text">The text to be displayed.</param>
        /// <param name="anchoredPosition">The position the text component should be anchored to.</param>
        /// <param name="sizeDelta">The size of the text components RectTransform.</param>
        /// <returns>The newly created TextMeshProUGUI component.</returns>
        public static TextMeshProUGUI CreateText(RectTransform parent, string text, Vector2 anchoredPosition, Vector2 sizeDelta)
        {
            GameObject gameObj = new GameObject("CustomUIText");

            gameObj.SetActive(false);

            CurvedTextMeshPro textMesh = gameObj.AddComponent <CurvedTextMeshPro>();

            textMesh.font = MainTextFont;
            textMesh.rectTransform.SetParent(parent, false);
            textMesh.text     = text;
            textMesh.fontSize = 4;
            textMesh.color    = Color.white;

            textMesh.rectTransform.anchorMin        = new Vector2(0.5f, 0.5f);
            textMesh.rectTransform.anchorMax        = new Vector2(0.5f, 0.5f);
            textMesh.rectTransform.sizeDelta        = sizeDelta;
            textMesh.rectTransform.anchoredPosition = anchoredPosition;

            gameObj.SetActive(true);
            return(textMesh);
        }
        public override GameObject CreateObject(Transform parent)
        {
            GameObject gameObject = Object.Instantiate(safePrefab, parent, false);

            gameObject.name = "BSMLDropdownList";
            SimpleTextDropdown dropdown = gameObject.GetComponentInChildren <SimpleTextDropdown>();

            dropdown.gameObject.SetActive(false);
            dropdown.name = "Dropdown";
            dropdown.GetComponentInChildren <VRGraphicRaycaster>(true).SetField("_physicsRaycaster", BeatSaberUI.PhysicsRaycasterWithCache);
            dropdown.GetComponentInChildren <ModalView>(true).SetField("_container", BeatSaberUI.DiContainer);
            dropdown.GetComponentInChildren <ScrollView>(true).SetField("_platformHelper", BeatSaberUI.PlatformHelper);

            GameObject labelObject = gameObject.transform.Find("Label").gameObject;
            LocalizedTextMeshProUGUI localizedText = ConfigureLocalizedText(labelObject);

            CurvedTextMeshPro textMesh = labelObject.GetComponent <CurvedTextMeshPro>();

            textMesh.text = "Default Text";

            LayoutElement layoutElement = gameObject.AddComponent <LayoutElement>();

            layoutElement.preferredHeight = 8;
            layoutElement.preferredWidth  = 90;

            List <Component> externalComponents = dropdown.gameObject.AddComponent <ExternalComponents>().components;

            externalComponents.Add(textMesh);
            externalComponents.Add(localizedText);
            externalComponents.Add(layoutElement);

            DropDownListSetting dropDownListSetting = dropdown.gameObject.AddComponent <DropDownListSetting>();

            dropDownListSetting.dropdown = dropdown;
            dropdown.gameObject.SetActive(true);
            gameObject.SetActive(true);
            return(dropdown.gameObject);
        }
Exemple #16
0
        private void Awake()
        {
            ////////////////////////////////////////////////////////////////////////////////////////
            /// Hello!
            /// Please don't look at this code because cloning such a huge object is kinda gross
            ///
            /// It was fun doing this in a really ugly way
            /// Now eventually I'll try to get it to work without ugliness :)
            ////////////////////////////////////////////////////////////////////////////////////////

            // Clone the "main screen" for the lobby, normally used to show currently selected song in the distance
            var screenController = Resources.FindObjectsOfTypeAll <CenterStageScreenController>().First();
            var mainScreen       = screenController.transform.parent;

            _clonedMainScreen      = UnityEngine.Object.Instantiate(mainScreen);
            _clonedMainScreen.name = "SBFNMainScreen";
            _clonedMainScreen.SetParent(gameObject.transform, false);

            _canvasGroup         = _clonedMainScreen.gameObject.AddComponent <CanvasGroup>();
            _canvasGroup.enabled = true;

            // Set base position
            _clonedMainScreen.transform.position = new Vector3(0, _basePosY, 3.0f);

            // Activate all child objects, filtering out game objects we're not interested in
            foreach (var tr in _clonedMainScreen.GetComponentsInChildren <Transform>())
            {
                switch (tr.gameObject.name)
                {
                default:
                    tr.gameObject.SetActive(true);
                    break;

                case "NextLevelBasePosition":
                case "NextLevelCountdownPosition":
                case "Title":
                case "PlaceholderText":
                case "ModifierSelection":
                case "Countdown":
                    Destroy(tr.gameObject);
                    break;
                }
            }

            _clonedMainScreen.gameObject.SetActive(true);

            // Destroy any graphic raycasters, our notifs aren't clickable and they cause issues
            foreach (var vgr in _clonedMainScreen.GetComponentsInChildren <VRGraphicRaycaster>())
            {
                Destroy(vgr);
            }

            // Grab the level bar, which is what will hold our notification content
            _levelBar = GameObject.Find("ServerBrowserFloatingNotification/SBFNMainScreen/CenterStageScreenController/NextLevel/BeatmapWithModifiersNonEditable/BeatmapSelection/LevelBarSimple");
            Destroy(_levelBar.transform.Find("BeatmapDataContainer").gameObject);

            _bgImage = _levelBar.transform.parent.GetComponentInChildren <ImageView>();

            var titleText = _levelBar.transform.Find("SongNameText");

            _titleTextMesh      = titleText.GetComponent <CurvedTextMeshPro>();
            _titleTextMesh.text = "NOTIFICATION_TITLE";

            var subTitleText = _levelBar.transform.Find("AuthorNameText");

            _subTitleTextMesh      = subTitleText.GetComponent <CurvedTextMeshPro>();
            _subTitleTextMesh.text = "NOTIFICATION_MESSAGE";

            var songArtwork = _levelBar.transform.Find("SongArtwork");

            _notificationImage        = songArtwork.GetComponent <Image>();
            _notificationImage.sprite = Assets.Sprites.Portal;

            _levelBar.SetActive(true);

            // Keep our object alive across scenes so we can display ingame
            DontDestroyOnLoad(gameObject);
        }
Exemple #17
0
        private void Awake()
        {
            // Create ModalKeyboard (BSML)
            var modalKeyboardTag = new ModalKeyboardTag();
            var modalKeyboardObj = modalKeyboardTag.CreateObject(transform);

            _modalKeyboard                        = modalKeyboardObj.GetComponent <ModalKeyboard>();
            _modalKeyboard.clearOnOpen            = false;
            _modalKeyboard.keyboard.EnterPressed += OnModalKeyboardSubmit;

            // Create server button
            var createServerButtonTransform = transform.Find("CreateServerButton");

            createServerButtonTransform.localPosition = new Vector3(-76.50f, 40.0f, 0.0f);

            _createServerButton = transform.Find("CreateServerButton").GetComponent <Button>();
            _createServerButton.onClick.AddListener(delegate
            {
                MpModeSelection.OpenCreateServerMenu();
            });

            // Move the top-right loading control up, so the refresh button aligns properly
            (transform.Find("Filters/SmallLoadingControl") as RectTransform).localPosition = new Vector3(62.0f, 3.5f, 0.0f);

            // Resize the filters bar so it doesn't overlap the refresh button
            var filterButtonTransform = (transform.Find("Filters/FilterButton") as RectTransform);

            filterButtonTransform.sizeDelta = new Vector2(-11.0f, 10.0f);
            filterButtonTransform.offsetMax = new Vector2(-11.0f, 5.0f);

            _filterButton = filterButtonTransform.GetComponent <Button>();
            _filterButton.onClick.AddListener(delegate
            {
                _modalKeyboard.keyboard.KeyboardText.text = !String.IsNullOrEmpty(_searchQuery) ? _searchQuery : "";
                //_modalKeyboard.keyboard.KeyboardText.fontSize = 4;

                _modalKeyboard.modalView.Show(true, true, null);
            });

            // Filters lable
            _filterButtonLabel      = transform.Find("Filters/FilterButton/Content/Text").GetComponent <CurvedTextMeshPro>();
            _filterButtonLabel.text = "Hello world!";

            // Hide top-right loading spinners
            Destroy(transform.Find("Filters/SmallLoadingControl/LoadingContainer").gameObject);
            Destroy(transform.Find("Filters/SmallLoadingControl/DownloadingContainer").gameObject);

            // Refresh button (add listener, make visible)
            var smallLoadingControl = transform.Find("Filters/SmallLoadingControl").GetComponent <LoadingControl>();

            smallLoadingControl.didPressRefreshButtonEvent += OnRefreshPressed;

            var refreshContainer = smallLoadingControl.transform.Find("RefreshContainer");

            refreshContainer.gameObject.SetActive(true);

            _refreshButton = refreshContainer.Find("RefreshButton").GetComponent <Button>();

            // Change "Music Packs" table header to "Type"
            transform.Find("GameServersListTableView/GameServerListTableHeader/LabelsContainer/MusicPack").GetComponent <CurvedTextMeshPro>()
            .SetText("Type");

            // Main loading control
            _mainLoadingControl = transform.Find("GameServersListTableView/TableView/Viewport/MainLoadingControl").GetComponent <LoadingControl>();
            _mainLoadingControl.didPressRefreshButtonEvent += OnRefreshPressed;

            _mainLoadingControl.ShowLoading("Initializing");

            // Table view
            _tableView = transform.Find("GameServersListTableView").GetComponent <GameServersListTableView>();

            // Modify content cell prefab (add a background)
            var contentCellPrefab = _tableView.GetField <GameServerListTableCell, GameServersListTableView>("_gameServerListCellPrefab");

            var backgroundBase = Resources.FindObjectsOfTypeAll <ImageView>().First(x => x.gameObject?.name == "Background" &&
                                                                                    x.sprite != null && x.sprite.name.StartsWith("RoundRect10"));

            var backgroundClone = UnityEngine.Object.Instantiate(backgroundBase);

            backgroundClone.transform.SetParent(contentCellPrefab.transform, false);
            backgroundClone.transform.SetAsFirstSibling();
            backgroundClone.name = "Background";

            var backgroundTransform = backgroundClone.transform as RectTransform;

            backgroundTransform.anchorMin = new Vector2(0.0f, 0.0f);
            backgroundTransform.anchorMax = new Vector2(0.95f, 1.0f);
            backgroundTransform.offsetMin = new Vector2(0.5f, 0.0f);
            backgroundTransform.offsetMax = new Vector2(5.0f, 0.0f);
            backgroundTransform.sizeDelta = new Vector2(4.50f, 0.0f);

            var cellBackgroundHelper = contentCellPrefab.gameObject.AddComponent <CellBackgroundHelper>();

            cellBackgroundHelper.Cell       = contentCellPrefab;
            cellBackgroundHelper.Background = backgroundClone;
        }
Exemple #18
0
        private void AddMenuOption()
        {
            Transform dropdownTemplate     = _gameplaySetupViewController.transform.Find("EnvironmentOverrideSettings/Settings/Elements/NormalLevels");
            Transform otherSettingsContent = _settingsNavigationController.transform.Find("OtherSettings/Content");

            if (!dropdownTemplate)
            {
                Plugin.Log.Error("Dropdown template not found!");
                return;
            }

            if (!otherSettingsContent)
            {
                Plugin.Log.Error("OtherSettings/Content not found!");
                return;
            }

            GameObject gameObject = _container.InstantiatePrefab(dropdownTemplate.gameObject, otherSettingsContent);

            gameObject.name = "LanguageSetting";

            RectTransform rectTransform = gameObject.GetComponent <RectTransform>();

            rectTransform.offsetMin = new Vector2(0, -14.2f);
            rectTransform.offsetMax = new Vector2(0, -7.2f);

            LocalizedTextMeshProUGUI label = gameObject.transform.Find("Label").GetComponent <LocalizedTextMeshProUGUI>();

            label.Key = "SETTINGS_LANGUAGE";

            _container.InstantiateComponent <LanguageSetting>(gameObject);

            Plugin.Log.Debug("Created language setting");

            var textGameObject = new GameObject("SiraLocalizerContributorsText");

            _credits = textGameObject.AddComponent <CurvedTextMeshPro>();

            var textRectTransform = (RectTransform)textGameObject.transform;

            textRectTransform.SetParent(otherSettingsContent, false);
            textRectTransform.offsetMin = new Vector2(-45f, -7.4f);
            textRectTransform.offsetMax = new Vector2(45f, -7.4f);

            _credits.alignment   = TextAlignmentOptions.TopLeft;
            _credits.lineSpacing = -35f;
            _credits.fontSize    = 3f;
            _credits.fontStyle   = FontStyles.Italic;
            _credits.gameObject.SetActive(false);

            foreach (var lang in Localization.Instance.SupportedLanguages)
            {
                if (lang == Language.English)
                {
                    continue;
                }
                var contributors = Localization.Get("LANGUAGE_CONTRIBUTORS", lang);
                var name         = Localization.Get("MENU_LANGUAGE_THIS", lang);
                if (!string.IsNullOrEmpty(contributors))
                {
                    _credits.text += $"<b>{name}</b>   <color=#bababa>{contributors}</color>\n";
                }
            }

            _creditsToggle      = _container.InstantiatePrefabForComponent <Button>(_standardLevelDetailViewController.GetField <StandardLevelDetailView, StandardLevelDetailViewController>("_standardLevelDetailView").practiceButton);
            _creditsToggle.name = "LocalizationCreditsButton";
            UnityEngine.Object.Destroy(_creditsToggle.transform.Find("Content").GetComponent <LayoutElement>());
            _creditsToggle.gameObject.transform.SetParent(otherSettingsContent, false);
            var rect = (_creditsToggle.transform as RectTransform);

            rect.localPosition = new Vector3(-5f, -11f, 0f);

            ContentSizeFitter buttonSizeFitter = _creditsToggle.gameObject.AddComponent <ContentSizeFitter>();

            buttonSizeFitter.verticalFit   = ContentSizeFitter.FitMode.PreferredSize;
            buttonSizeFitter.horizontalFit = ContentSizeFitter.FitMode.PreferredSize;
            LocalizedTextMeshProUGUI localizer = _creditsToggle.GetComponentInChildren <LocalizedTextMeshProUGUI>(true);

            localizer.Key = "CREDITS_TITLE";

            _creditsToggle.onClick.AddListener(ToggleCredits);
        }
        IEnumerator Init()
        {
            yield return(new WaitForSeconds(0.1f));

            GameObject display = new GameObject("GMPDisplay");
            GameObject textObj = new GameObject("GMPDisplayText");

            if (Config.uiOnTop)
            {
                textObj.transform.position    = new Vector3(0.1f, 3f, 7f);
                textObj.transform.localScale *= 1.5f;
            }

            else
            {
                textObj.transform.position    = new Vector3(0.2f, -1f, 7f);
                textObj.transform.localScale *= 2.0f;
            }
            textObj.transform.SetParent(display.transform);

            var counterImage = Resources.FindObjectsOfTypeAll <ScoreMultiplierUIController>().First().
                               GetField <Image, ScoreMultiplierUIController>("_multiplierProgressImage");


            GameObject canvasobj = new GameObject("GMPDisplayCanvas");
            Canvas     canvas    = canvasobj.AddComponent <Canvas>();

            canvas.renderMode = RenderMode.WorldSpace;
            CanvasScaler cs = canvasobj.AddComponent <CanvasScaler>();

            cs.scaleFactor          = 10.0f;
            cs.dynamicPixelsPerUnit = 10f;
            GraphicRaycaster gr = canvasobj.AddComponent <GraphicRaycaster>();

            canvasobj.GetComponent <RectTransform>().SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, 1f);
            canvasobj.GetComponent <RectTransform>().SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, 1f);

            GameObject counter = new GameObject("GMPDisplayCounter");

            chargeCounter            = counter.AddComponent <ImageView>();
            counter.transform.parent = canvasobj.transform;
            counter.GetComponent <RectTransform>().SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, 0.5f);
            counter.GetComponent <RectTransform>().SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, 0.5f);
            counter.transform.localScale = new Vector3(1f, 1f, 1f);

            chargeCounter.sprite        = counterImage.sprite;
            chargeCounter.type          = Image.Type.Filled;
            chargeCounter.fillMethod    = Image.FillMethod.Radial360;
            chargeCounter.fillOrigin    = (int)Image.Origin360.Top;
            chargeCounter.fillClockwise = true;
            chargeCounter.fillAmount    = GameModifiersController.charges / Config.maxCharges;
            chargeCounter.color         = Color.green;

            GameObject background = new GameObject("GMPDisplayBackGround");
            var        bg         = background.AddComponent <ImageView>();

            background.transform.parent = canvasobj.transform;
            background.GetComponent <RectTransform>().SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, 0.5f);
            background.GetComponent <RectTransform>().SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, 0.5f);
            background.transform.localScale = new Vector3(1f, 1f, 1f);

            bg.sprite = counterImage.sprite;
            bg.CrossFadeAlpha(0.05f, 1f, false);

            canvasobj.GetComponent <RectTransform>().SetParent(textObj.transform, false);
            canvasobj.transform.localPosition = new Vector3(-0.1f, -.1f, 0f);

            chargeText                       = BeatSaberMarkupLanguage.BeatSaberUI.CreateText(canvas.transform as RectTransform, "Charges", new Vector2(-0.25f, 0.5f)) as CurvedTextMeshPro;
            chargeText.fontSize              = 3;
            chargeText.transform.localScale *= .08f;
            chargeText.color                 = Color.white;
            //    chargeText.font = Resources.Load<TMP_FontAsset>("Teko-Medium SDF No Glow");
            chargeText.GetComponent <RectTransform>().SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, 1f);
            chargeText.GetComponent <RectTransform>().SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, 1f);
            chargeText.GetComponent <RectTransform>().SetParent(canvas.transform, false);


            chargeCountText                       = BeatSaberMarkupLanguage.BeatSaberUI.CreateText(canvas.transform as RectTransform, GameModifiersController.charges.ToString(), new Vector2(0, 0)) as CurvedTextMeshPro;
            chargeCountText.text                  = GameModifiersController.charges.ToString();
            chargeCountText.alignment             = TextAlignmentOptions.Center;
            chargeCountText.transform.localScale *= .08f;
            chargeCountText.fontSize              = 2.5f;
            chargeCountText.color                 = Color.white;
            chargeCountText.GetComponent <RectTransform>().SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, 1f);
            chargeCountText.GetComponent <RectTransform>().SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, 1f);
            chargeCountText.GetComponent <RectTransform>().SetParent(canvas.transform, false);
            //   chargeCountText.transform.localPosition = new Vector3(-0.0925f, -.13f, 0f);

            cooldownText                       = BeatSaberMarkupLanguage.BeatSaberUI.CreateText(canvas.transform as RectTransform, GameModifiersController.charges.ToString(), new Vector2(-1f, 0.015f)) as CurvedTextMeshPro;
            cooldownText.text                  = "";
            cooldownText.alignment             = TextAlignmentOptions.MidlineRight;
            cooldownText.fontSize              = 2.5f;
            cooldownText.transform.localScale *= .08f;
            cooldownText.color                 = Color.red;
            //     cooldownText.font = Resources.Load<TMP_FontAsset>("Teko-Medium SDF No Glow");
            cooldownText.GetComponent <RectTransform>().SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, 10f);
            cooldownText.GetComponent <RectTransform>().SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, 1f);
            cooldownText.GetComponent <RectTransform>().SetParent(canvas.transform, false);

            activeCommandText                       = BeatSaberMarkupLanguage.BeatSaberUI.CreateText(canvas.transform as RectTransform, GameModifiersController.charges.ToString(), new Vector2(1f, 0.015f)) as CurvedTextMeshPro;
            activeCommandText.text                  = "";
            activeCommandText.alignment             = TextAlignmentOptions.MidlineLeft;
            activeCommandText.fontSize              = 2.5f;
            activeCommandText.transform.localScale *= .08f;
            activeCommandText.color                 = Color.yellow;
            //     activeCommandText.font = Resources.Load<TMP_FontAsset>("Teko-Medium SDF No Glow");
            activeCommandText.GetComponent <RectTransform>().SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, 10f);
            activeCommandText.GetComponent <RectTransform>().SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, 1f);
            activeCommandText.GetComponent <RectTransform>().SetParent(canvas.transform, false);

            GameObject            coreGameHUD   = Resources.FindObjectsOfTypeAll <CoreGameHUDController>()?.FirstOrDefault(x => x.isActiveAndEnabled)?.gameObject ?? null;
            FlyingGameHUDRotation flyingGameHUD = Resources.FindObjectsOfTypeAll <FlyingGameHUDRotation>().FirstOrDefault(x => x.isActiveAndEnabled);

            if (coreGameHUD != null)
            {
                display.transform.SetParent(coreGameHUD.transform, true);
            }
            //      textObj.transform.position = new Vector3(0, 0f, 0);
            display.transform.localPosition = new Vector3(0, 0f, 0f);
            display.transform.localRotation = Quaternion.identity;
            if (flyingGameHUD != null)
            {
                display.transform.localPosition = new Vector3(0, 0.75f, 6f);
                display.transform.eulerAngles   = new Vector3(345f, 0f, 0f);
            }
            var canvasSettings = canvasobj.AddComponent <CurvedCanvasSettings>();

            canvasSettings.SetRadius(0);
            display.SetActive(GMPUI.chatIntegration);
            initialized = true;
        }
        static void Postfix(MissionHelpSO missionHelp, MissionHelpViewController __instance)
        {
            if (missionHelp is CustomMissionHelpSO)
            {
                ChallengeInfo     challengeInfo = (missionHelp as CustomMissionHelpSO).challengeInfo;
                string            imagePath     = (missionHelp as CustomMissionHelpSO).imagePath;
                Transform         content       = __instance.transform.GetChild(0);
                CurvedTextMeshPro title         = content.GetChild(0).GetChild(1).GetComponent <CurvedTextMeshPro>();

                Transform seperatorPrefab = content.GetChild(6).GetChild(1);
                Transform segmentPrefab   = content.GetChild(1).GetChild(1);

                GameObject.Destroy(title.GetComponent <LocalizedTextMeshProUGUI>());
                title.text     = challengeInfo.title;
                title.richText = true;
                Transform infoContainer = GameObject.Instantiate(content.GetChild(1), content);
                infoContainer.SetSiblingIndex(content.childCount - 2);

                infoContainer.gameObject.SetActive(true);
                if (lastInfo != null)
                {
                    GameObject.Destroy(lastInfo.gameObject);
                }
                lastInfo = infoContainer;
                foreach (Transform child in infoContainer)
                {
                    GameObject.Destroy(child.gameObject);
                }
                foreach (ChallengeInfo.InfoSegment infoSegment in challengeInfo.segments)
                {
                    Transform segment = GameObject.Instantiate(segmentPrefab, infoContainer);
                    GameObject.Destroy(segment.GetComponentInChildren <LocalizedTextMeshProUGUI>());
                    if (infoSegment.text == "")
                    {
                        GameObject.Destroy(segment.GetComponentInChildren <CurvedTextMeshPro>().gameObject);
                    }
                    else
                    {
                        segment.GetComponentInChildren <CurvedTextMeshPro>().text = infoSegment.text;
                    }

                    ImageView imageView = segment.GetComponentInChildren <ImageView>();
                    if (infoSegment.imageName == "")
                    {
                        GameObject.Destroy(imageView.gameObject);
                    }
                    else
                    {
                        imageView.sprite = null;
                        if (imageLoader == null)
                        {
                            imageLoader = Resources.FindObjectsOfTypeAll <MainFlowCoordinator>().First();
                        }
                        imageLoader.StartCoroutine(LoadSprite("file:///" + imagePath + infoSegment.imageName, imageView));
                    }
                    if (infoSegment.hasSeperator)
                    {
                        GameObject.Instantiate(seperatorPrefab, infoContainer);
                    }
                }
            }
            else
            {
                __instance.transform.GetChild(0).GetComponentInChildren <CurvedTextMeshPro>().text = "NEW OBJECTIVE";
            }
        }