/// <summary>
        /// Handle full reset on exit
        /// </summary>
        /// <param name="p_Object"></param>
        private static void LevelSearchViewController_didStartLoadingEvent(LevelSearchViewController p_Object)
        {
            if (p_Object != null)
            {
                p_Object.didStartLoadingEvent -= LevelSearchViewController_didStartLoadingEvent;
            }

            if (!p_Object || !p_Object.isInViewControllerHierarchy || p_Object.isInTransition || !p_Object.gameObject.activeInHierarchy)
            {
                return;
            }

            try
            {
                var l_Filter = p_Object.GetField <LevelFilterParams>("_currentFilterParams");
                if (l_Filter != null && l_Filter.filterByLevelIds)
                {
                    p_Object.ResetCurrentFilterParams();
                    var l_InputFieldView = p_Object.GetField <InputFieldView>("_searchTextInputFieldView");
                    if (l_InputFieldView != null && l_InputFieldView)
                    {
                        l_InputFieldView.SetText("");
                        l_InputFieldView.UpdateClearButton();
                        l_InputFieldView.UpdatePlaceholder();
                    }

                    p_Object.UpdateSearchLevelFilterParams(LevelFilterParams.NoFilter());
                }
            }
            catch (System.Exception p_Exception)
            {
                Logger.Instance.Error("[ChatRequest] LevelSearchViewController_didStartLoadingEvent failed : ");
                Logger.Instance.Error(p_Exception);
            }
        }
Exemple #2
0
        /// <summary>
        /// Level selection, filter
        /// </summary>
        /// <param name="p_LevelSearchViewController">LevelSearchViewController instance</param>
        /// <param name="p_Wait">Should wait for any transition</param>
        /// <returns></returns>
        private static IEnumerator LevelSelection_FilterLevel(LevelSearchViewController p_LevelSearchViewController, bool p_Wait)
        {
            if (SDK.Game.Logic.ActiveScene != SDK.Game.Logic.SceneType.Menu)
            {
                yield break;
            }

            if (p_LevelSearchViewController == null || !p_LevelSearchViewController || m_PendingFilterSong == null)
            {
                yield break;
            }

            if (p_Wait)
            {
                yield return(new WaitUntil(() => !p_LevelSearchViewController || !p_LevelSearchViewController.isInTransition));

                if (!p_LevelSearchViewController || !p_LevelSearchViewController.isInViewControllerHierarchy || !p_LevelSearchViewController.isActiveAndEnabled)
                {
                    yield break;
                }

                if (SDK.Game.Logic.ActiveScene != SDK.Game.Logic.SceneType.Menu)
                {
                    yield break;
                }
            }

            try
            {
                p_LevelSearchViewController.didStartLoadingEvent -= LevelSearchViewController_didStartLoadingEvent;
                p_LevelSearchViewController.ResetCurrentFilterParams();
                var l_InputFieldView = p_LevelSearchViewController.GetField <InputFieldView, LevelSearchViewController>("_searchTextInputFieldView");
                if (l_InputFieldView != null && l_InputFieldView)
                {
                    l_InputFieldView.SetText(m_PendingFilterSong.songName);
                    l_InputFieldView.UpdateClearButton();
                    l_InputFieldView.UpdatePlaceholder();
                }

                p_LevelSearchViewController.UpdateSearchLevelFilterParams(LevelFilterParams.ByBeatmapLevelIds(new HashSet <string>()
                {
                    m_PendingFilterSong.levelID
                }));
                p_LevelSearchViewController.didStartLoadingEvent += LevelSearchViewController_didStartLoadingEvent;
            }
            catch (System.Exception p_Exception)
            {
                Logger.Instance.Error("[ChatRequest] LevelSelection_FilterLevel coroutine failed : ");
                Logger.Instance.Error(p_Exception);

                LevelSearchViewController_didStartLoadingEvent(p_LevelSearchViewController);
            }
        }
        ////////////////////////////////////////////////////////////////////////////
        ////////////////////////////////////////////////////////////////////////////

        /// <summary>
        /// Change current song view to all songs view
        /// </summary>
        /// <param name="p_FirstActivation"></param>
        /// <param name="p_AddedToHierarchy"></param>
        /// <param name="p_ScreenSystemEnabling"></param>
        private static void LevelSelectionNavigationController_didActivateEvent(bool p_FirstActivation, bool p_AddedToHierarchy, bool p_ScreenSystemEnabling)
        {
            var l_LevelSelectionNavigationController = Resources.FindObjectsOfTypeAll <LevelSelectionNavigationController>().FirstOrDefault();

            if (l_LevelSelectionNavigationController == null)
            {
                return;
            }

            l_LevelSelectionNavigationController.didActivateEvent -= LevelSelectionNavigationController_didActivateEvent;

            LevelFilteringNavigationController l_LevelFilteringNavigationController = l_LevelSelectionNavigationController.GetField <LevelFilteringNavigationController>("_levelFilteringNavigationController");

            try
            {
                if (l_LevelFilteringNavigationController != null)
                {
                    var l_Selector = l_LevelFilteringNavigationController.GetField <SelectLevelCategoryViewController>("_selectLevelCategoryViewController");
                    if (l_Selector != null && l_Selector)
                    {
                        var l_Tags = l_Selector.GetField <SelectLevelCategoryViewController.LevelCategoryInfo[]>("_allLevelCategoryInfos");
                        for (int l_I = 0; l_I < l_Tags.Length; ++l_I)
                        {
                            if (l_Tags[l_I].levelCategory != SelectLevelCategoryViewController.LevelCategory.All)
                            {
                                continue;
                            }

                            var l_SegmentControl = l_Selector.GetField <IconSegmentedControl>("_levelFilterCategoryIconSegmentedControl");
                            var l_Cells          = l_Selector != null?l_SegmentControl.GetField <List <SegmentedControlCell> >("_cells") : null as List <SegmentedControlCell>;

                            if (l_Cells != null)
                            {
                                /// Multiplayer fix
                                if (l_Cells.Count == 4)
                                {
                                    l_I = l_I - 1;
                                }

                                l_SegmentControl.SelectCellWithNumber(l_I);
                                l_Selector.LevelFilterCategoryIconSegmentedControlDidSelectCell(l_SegmentControl, l_I);
                                //l_SegmentControl.HandleCellSelectionDidChange(l_Cells.ElementAt(l_I), SelectableCell.TransitionType.Instant, null);
                                //l_SegmentControl.SelectCellWithNumber(l_I);
                            }
                            break;
                        }
                    }

                    /// Wait next frame
                    HMMainThreadDispatcher.instance.Enqueue(() =>
                    {
                        try
                        {
                            var l_LevelSearchViewController = l_LevelFilteringNavigationController.GetField <LevelSearchViewController>("_levelSearchViewController");
                            if (l_LevelSearchViewController != null &&
                                l_LevelSearchViewController &&
                                l_LevelSearchViewController.isInViewControllerHierarchy &&
                                !l_LevelSearchViewController.isInTransition &&
                                l_LevelSearchViewController.gameObject.activeInHierarchy)
                            {
                                l_LevelSearchViewController.didStartLoadingEvent -= LevelSearchViewController_didStartLoadingEvent;
                                l_LevelSearchViewController.ResetCurrentFilterParams();
                                var l_InputFieldView = l_LevelSearchViewController.GetField <InputFieldView>("_searchTextInputFieldView");
                                if (l_InputFieldView != null && l_InputFieldView)
                                {
                                    l_InputFieldView.SetText(m_PendingFilterSong.songName);
                                    l_InputFieldView.UpdateClearButton();
                                    l_InputFieldView.UpdatePlaceholder();
                                }

                                l_LevelSearchViewController.UpdateSearchLevelFilterParams(LevelFilterParams.ByBeatmapLevelIds(new HashSet <string>()
                                {
                                    m_PendingFilterSong.levelID
                                }));
                                l_LevelSearchViewController.didStartLoadingEvent += LevelSearchViewController_didStartLoadingEvent;
                            }
                        }
                        catch (System.Exception p_Exception)
                        {
                            Logger.Instance.Error("[ChatRequest] LevelSelectionNavigationController_didActivateEvent coroutine failed : ");
                            Logger.Instance.Error(p_Exception);

                            LevelSearchViewController_didStartLoadingEvent(l_LevelFilteringNavigationController.GetField <LevelSearchViewController>("_levelSearchViewController"));
                        }
                    });
                }
            }
            catch (System.Exception p_Exception)
            {
                Logger.Instance.Error("[ChatRequest] LevelSelectionNavigationController_didActivateEvent failed : ");
                Logger.Instance.Error(p_Exception);

                LevelSearchViewController_didStartLoadingEvent(l_LevelFilteringNavigationController.GetField <LevelSearchViewController>("_levelSearchViewController"));
            }
        }