Exemple #1
0
        /// <inheritdoc/>
        /// <remarks>
        /// When using a non-source locale, will first attempt to find a corresponding record
        /// in the managed text documents, and, if not found, check the character metadata.
        /// In case the display name is found and is wrapped in curly braces, will attempt to evaluate the value from the expression.
        /// </remarks>
        public virtual string GetDisplayName(string characterId)
        {
            if (string.IsNullOrWhiteSpace(characterId))
            {
                return(null);
            }

            var displayName = default(string);

            if (!localizationManager.IsSourceLocaleSelected())
            {
                displayName = textManager.GetRecordValue(characterId, CharactersConfiguration.DisplayNamesCategory);
            }

            if (string.IsNullOrEmpty(displayName))
            {
                displayName = Configuration.GetMetadataOrDefault(characterId).DisplayName;
            }

            if (!string.IsNullOrEmpty(displayName) && displayName.StartsWithFast("{") && displayName.EndsWithFast("}"))
            {
                var expression = displayName.GetAfterFirst("{").GetBeforeLast("}");
                displayName = ExpressionEvaluator.Evaluate <string>(expression, desc => Debug.LogError($"Failed to evaluate `{characterId}` character display name: {desc}"));
            }

            return(string.IsNullOrEmpty(displayName) ? null : displayName);
        }
        /// <inheritdoc/>
        /// <remarks>
        /// When using a non-source locale, will first attempt to find a corresponding record
        /// in the managed text documents, and, if not found, check the character metadata.
        /// In case the display name is found and is wrapped in curely braces, attempt to extract the value
        /// from a custom variable.
        /// </remarks>
        public string GetDisplayName(string characterId)
        {
            if (string.IsNullOrWhiteSpace(characterId))
            {
                return(null);
            }

            var displayName = default(string);

            if (!localizationManager.SourceLocaleSelected())
            {
                displayName = textManager.GetRecordValue(characterId, CharactersConfiguration.DisplayNamesCategory);
            }

            if (string.IsNullOrEmpty(displayName))
            {
                displayName = Configuration.GetMetadataOrDefault(characterId).DisplayName;
            }

            if (!string.IsNullOrEmpty(displayName) && displayName.StartsWithFast("{") && displayName.EndsWithFast("}"))
            {
                var customVarName = displayName.GetAfterFirst("{").GetBeforeLast("}");
                if (!customVariableManager.VariableExists(customVarName))
                {
                    Debug.LogWarning($"Failed to retrieve `{customVarName}` custom variable binded to `{characterId}` character display name.");
                    return(null);
                }
                displayName = customVariableManager.GetVariableValue(customVarName);
            }

            return(string.IsNullOrEmpty(displayName) ? null : displayName);
        }
        private void InvokeValueChanged()
        {
            var recordKey = string.IsNullOrWhiteSpace(key) ? gameObject.name : key;
            var value     = textManager.GetRecordValue(recordKey, category);

            onValueChanged?.Invoke(value ?? DefaultValue);
        }
        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 #5
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);
        }