Пример #1
0
        public static string PreviewText(this EventSolution solution)
        {
            var result = "";

            result += solution.SolutionText.ToString(); // add main solution string
            if (solution.m_SuccessEffects.Actions.Length > 0 &&
                solution.m_SuccessEffects.Actions.FindOrDefault(act => act is AddItemToPlayer) is AddItemToPlayer addIntermediateItemAct)
            {
                var item = addIntermediateItemAct.ItemToGive;
                if (item != null)
                {
                    var pattern = @"<link=([^>]*)>";
                    var matches = Regex.Matches(result, pattern);
                    if (matches.Cast <Match>().FirstOrDefault()?
                        .Groups.Cast <Group>().FirstOrDefault()?
                        .Captures.Cast <Capture>().FirstOrDefault()?
                        .Value is string link)
                    {
                        result += $" {link}[{item.Name.Rarity(item.Rarity())}]</link>".SizePercent(75);
                    }
                    else
                    {
                        result += $" [{item.Name.Rarity(item.Rarity())}]".SizePercent(75);
                    }
                }
            }
            return(result);
        }
Пример #2
0
            private static bool Prefix(KingdomUIEventWindowFooterSolution __instance,
                                       EventSolution eventSolution,
                                       UnityAction <bool> onToggle,
                                       ToggleGroup toggleGroup,
                                       bool isOn = false)
            {
                // Should it be previewEventResults here?
                // Or previewDialogResults && previewEventResults
                if (!settings.previewDialogResults)
                {
                    return(true);
                }
                __instance.gameObject.SetActive(true);
                __instance.EventSolution = eventSolution;
                __instance.Toggle.group  = toggleGroup;
                __instance.Toggle.onValueChanged.RemoveAllListeners();
                __instance.Toggle.onValueChanged.AddListener(onToggle);
                var extraText = "";
                var isAvail   = eventSolution.IsAvail || settings.toggleIgnoreEventSolutionRestrictions;
                var color     = isAvail ? "#005800><b>" : "#800000>";

                if (eventSolution.m_AvailConditions.HasConditions)
                {
                    extraText += $"\n<color={color}[{string.Join(", ", eventSolution.m_AvailConditions.Conditions.Select(c => c.GetCaption())).MergeSpaces(true)}]</b></color>";
                }
                if (eventSolution.m_SuccessEffects.Actions.Length > 0)
                {
                    extraText += $"\n[{string.Join(", ", eventSolution.m_SuccessEffects.Actions.Select(c => c.GetCaption())).MergeSpaces(true)}]";
                }
                if (isAvail)
                {
                    if (extraText.Length > 0)
                    {
                        __instance.m_TextLabel.text = $"{eventSolution.SolutionText}<size=75%>{extraText}</size>";
                    }
                    else
                    {
                        __instance.m_TextLabel.text = (string)eventSolution.SolutionText;
                    }
                }
                else if (eventSolution.UnavailingBehaviour == UnavailingBehaviour.ShowPlaceholder)
                {
                    if (extraText.Length > 0)
                    {
                        __instance.m_TextLabel.text = $"{eventSolution.UnavailingPlaceholder}<size=75%>{extraText}</size>";
                    }
                    else
                    {
                        __instance.m_TextLabel.text = (string)eventSolution.UnavailingPlaceholder;
                    }
                }
                else
                {
                    __instance.gameObject.SetActive(false);
                }
                __instance.Toggle.interactable = isAvail;
                __instance.Toggle.isOn         = isOn;
                __instance.m_Disposable?.Dispose();
                __instance.m_Disposable = __instance.m_TextLabel.SetLinkTooltip();
                return(false);
            }