public override UniTask InitializeAsync()
        {
            tipsSelectedState = stateManager.GlobalState.GetState <TipsSelectedState>() ?? new TipsSelectedState();

            var records = textManager.GetAllRecords(managedTextCategory);

            foreach (var record in records)
            {
                var unlockableId = $"{unlockableIdPrefix}/{record.Key}";
                var title        = record.Value.GetBefore(separatorLiteral) ?? record.Value;
                var selectedOnce = tipsSelectedState.TryGetValue(unlockableId, out var selected) && selected;
                var item         = TipsListItem.Instantiate(itemPrefab, unlockableId, title, selectedOnce, HandleItemClicked);
                item.transform.SetParent(itemsContainer, false);
                listItems.Add(item);
            }

            foreach (var item in listItems)
            {
                item.SetUnlocked(unlockableManager.ItemUnlocked(item.UnlockableId));
            }

            TipsCount = listItems.Count;

            return(UniTask.CompletedTask);
        }
        protected virtual void HandleItemClicked(TipsListItem clickedItem)
        {
            if (!unlockableManager.ItemUnlocked(clickedItem.UnlockableId))
            {
                return;
            }

            tipsSelectedState[clickedItem.UnlockableId] = true;
            foreach (var item in listItems)
            {
                item.SetSelected(item.UnlockableId.EqualsFast(clickedItem.UnlockableId));
            }
            var recordValue = textManager.GetRecordValue(clickedItem.UnlockableId.GetAfterFirst($"{unlockableIdPrefix}/"), managedTextCategory);

            titleText.text       = recordValue.GetBefore(separatorLiteral)?.Trim() ?? recordValue;
            numberText.text      = clickedItem.Number.ToString();
            categoryText.text    = recordValue.GetBetween(separatorLiteral)?.Trim() ?? string.Empty;
            descriptionText.text = recordValue.GetAfter(separatorLiteral)?.Replace("\\n", "\n")?.Trim() ?? string.Empty;
        }
Exemple #3
0
        protected virtual void HandleItemClicked(TipsListItem clickedItem)
        {
            if (!unlockableManager.ItemUnlocked(clickedItem.UnlockableId))
            {
                return;
            }

            SetItemSelectedOnce(clickedItem.UnlockableId);
            foreach (var item in listItems)
            {
                item.SetSelected(item.UnlockableId.EqualsFast(clickedItem.UnlockableId));
            }
            var recordValue = textManager.GetRecordValue(clickedItem.UnlockableId.GetAfterFirst($"{UnlockableIdPrefix}/"), ManagedTextCategory);

            SetTitle(recordValue.GetBefore(separatorLiteral)?.Trim() ?? recordValue);
            SetNumber(clickedItem.Number.ToString());
            SetCategory(recordValue.GetBetween(separatorLiteral)?.Trim() ?? string.Empty);
            SetDescription(recordValue.GetAfter(separatorLiteral)?.Replace("\\n", "\n").Trim() ?? string.Empty);
        }