Beispiel #1
0
    public async void OnContentLoaded(Content content)
    {
        scrollRect.ClearCells();

        scrollRect.totalCount = content.Season.tiers.Count + 1;
        var tiers = new List <TierData>(content.Season.tiers)
        {
            new TierData {
                isScrollRectFix = true
            }
        };

        for (var i = 0; i < tiers.Count - 1; i++)
        {
            var tier = tiers[i];
            tier.index = i;
            if (tier.Meta.parsedCriteria == default)
            {
                tier.Meta.parsedCriteria = tier.Meta.criteria.Select(Criterion.Parse).ToList();
            }
            if (tier.Meta.parsedStages == default)
            {
                tier.Meta.parsedStages = new List <Level>();
                tier.Meta.validStages  = new List <bool>();
                for (var stage = 0; stage < Math.Min(tier.Meta.stages.Count, 3); stage++)
                {
                    var level = tier.Meta.stages[stage].ToLevel(LevelType.Tier);
                    tier.Meta.parsedStages.Add(level);
                    tier.Meta.validStages.Add(level.IsLocal && level.Type == LevelType.Tier &&
                                              level.Meta.version == tier.Meta.stages[stage].Version);
                }
            }
        }

        scrollRect.objectsToFill = tiers.Cast <object>().ToArray();
        scrollRect.RefillCells();
        scrollRect.GetComponent <TransitionElement>().Apply(it =>
        {
            it.Leave(false, true);
            it.Enter();
        });
        LayoutFixer.Fix(scrollRect.content, count: 6);

        if (lastScrollPosition > -1)
        {
            await UniTask.DelayFrame(5);

            LayoutFixer.Fix(scrollRect.content, count: 6);
            scrollRect.SetVerticalNormalizedPositionFix(lastScrollPosition);
        }
        StartCoroutine(SnapCoroutine());
    }
    protected override void Render()
    {
        var collection = LoadedPayload.Collection;

        titleText.text  = LoadedPayload.TitleOverride ?? collection.title;
        sloganText.text = LoadedPayload.SloganOverride ?? collection.slogan;
        sloganText.transform.parent.RebuildLayout();
        scrollRect.totalCount    = collection.levels.Count;
        scrollRect.objectsToFill = collection.levels.Select(it => new LevelView {
            Level = it.ToLevel(LoadedPayload.Type), DisplayOwner = true
        }).ToArray().Cast <object>().ToArray();
        scrollRect.RefillCells();
        if (LoadedPayload.ScrollPosition > -1)
        {
            scrollRect.SetVerticalNormalizedPositionFix(LoadedPayload.ScrollPosition);
        }

        base.Render();
    }
Beispiel #3
0
    public override void OnScreenInitialized()
    {
        base.OnScreenInitialized();

        searchInputField.onEndEdit.AddListener(value =>
        {
            actionTabs.Close();
            if (LoadedPayload.Query.search.IsNullOrEmptyTrimmed() && !value.IsNullOrEmptyTrimmed())
            {
                LoadedPayload.Query.sort = "relevance"; // Reset to relevance
            }
            LoadedPayload.Query.search = value.Trim();
            LoadLevels(true);
        });
        ownerInputField.onEndEdit.AddListener(value =>
        {
            actionTabs.Close();
            LoadedPayload.Query.owner = value.Trim().ToLower();
            LoadLevels(true);
        });

        Context.LevelManager.OnLevelDeleted.AddListener(_ =>
        {
            if (State != ScreenState.Active)
            {
                return;
            }
            // Reload active content
            if (LoadedPayload.Levels.Count > 0)
            {
                LoadedPayload.ScrollPosition = scrollRect.verticalNormalizedPosition;
                scrollRect.ClearCells();
                RenderLevels();
                scrollRect.SetVerticalNormalizedPositionFix(LoadedPayload.ScrollPosition);
            }
        });
        SetupOptions();
        Context.OnLanguageChanged.AddListener(SetupOptions);
    }