/// <summary>
 /// Registers a control for showing tooltips; or removes it if null is passed.
 /// </summary>
 internal override sealed void RegisterControlForTooltip(ZenControlBase ctrl, IZenTooltip tt)
 {
     lock (tooltipInfos)
     {
         // Removing existing tooltip?
         if (tt == null && tooltipInfos.ContainsKey(ctrl))
         {
             // Tooltip will disappear when timer next hits.
             tooltipInfos[ctrl].AnimState = float.MinValue;
             // Make sure timer does hit.
             SubscribeToTimer();
         }
         // Adding or resetting tooltip?
         else if (tt != null)
         {
             // Not there yet: add now
             if (!tooltipInfos.ContainsKey(ctrl))
             {
                 TooltipInfo tti = new TooltipInfo(tt);
                 tooltipInfos[ctrl] = tti;
             }
             // There already: replace; keep animation state; make it repaint
             else
             {
                 TooltipInfo ttiExisting = tooltipInfos[ctrl];
                 TooltipInfo tti = new TooltipInfo(tt);
                 tti.AnimState = ttiExisting.AnimState;
                 tti.Repaint = ttiExisting.AnimState != 0;
                 tooltipInfos[ctrl] = tti;
                 // If we need a repaint, make sure timer does hit.
                 if (tti.Repaint) SubscribeToTimer();
             }
         }
     }
 }
Exemple #2
0
 public FloatingButtonWindow()
 {
     InitializeComponent();
     TooltipInfo = new TooltipInfo("", "", 1);
     MainContent = WindowContent;
     ButtonsRef  = null;
     Init(Settings.SettingsHolder.FloatingButtonSettings, perClassPosition: false);
 }
Exemple #3
0
    public void OpenTooltipAtPosWithInfo(Vector3 pos, TooltipInfo info)
    {
        transform.position = pos;

        titleText.text     = info.Title;
        categoryText.text  = info.Category;
        mainText.text      = info.MainText;
        secondaryText.text = info.SecondaryText;
    }
Exemple #4
0
 private void Row_EventNodeHover(Point mousePos, Rect rect, ThreadRow row, EventNode node)
 {
     if (node != null)
     {
         //HoverLines.AddRect(rect, FrameHover.Color);
         ToolTip = new TooltipInfo {
             Text = String.Format("{0}   {1:0.000}ms", node.Name, node.Duration), Rect = rect
         };
     }
     else
     {
         ToolTip = new TooltipInfo();
     }
 }
Exemple #5
0
 private void reinitVars() {
     _code = null;
     _title = null;
     _type = null;
     _tooltipType = TooltipManager.TooltipType.BIOBRICK;
     _subtitle = null;
     _illustration = null;
     _customField = null;
     _customValue = null;
     _length = null;
     _reference = null;
     _energyConsumption = null;
     _explanation = null;
     _info = null;
 }
Exemple #6
0
 private void reinitVars()
 {
     _code              = null;
     _title             = null;
     _type              = null;
     _tooltipType       = TooltipManager.TooltipType.BIOBRICK;
     _subtitle          = null;
     _illustration      = null;
     _customField       = null;
     _customValue       = null;
     _length            = null;
     _reference         = null;
     _energyConsumption = null;
     _explanation       = null;
     _info              = null;
 }
    private static bool fillInFieldsFromCode(string code)
    {
        //TooltipInfo info = produceTooltipInfo(code);

        TooltipInfo info = retrieveFromDico(code);

        if (null != info)
        {
            setVarsFromTooltipPanel(info._tooltipType);

            _instance._backgroundSprite.spriteName = info._background;
            _instance._titleLabel.key    = info._title;
            _instance._typeLabel.key     = info._type;
            _instance._subtitleLabel.key = info._subtitle;

            if (null != _instance._illustrationSprite)
            {
                _instance._illustrationSprite.spriteName = info._illustration;
            }

            if ((null != _instance._customFieldLabel) && (null != _instance._customValueLabel))
            {
                _instance._customFieldLabel.key = info._customField;
                _instance._customValueLabel.key = info._customValue;
            }

            _instance._lengthValueLabel.key    = info._length;
            _instance._referenceValueLabel.key = info._reference;

            if (null != _instance._energyConsumptionValueLabel)
            {
                _instance._energyConsumptionValueLabel.key = info._energyConsumption;
            }

            _instance._explanationLabel.key = info._explanation;

            return(true);
        }
        else
        {
            return(false);
        }
    }
Exemple #8
0
 /// <summary>
 /// Handles UI changes (mouse enter, leave etc.) affecting tooltip visibility
 /// </summary>
 internal sealed override void TooltipMouseAction(ZenControlBase ctrl, bool show)
 {
     lock (tooltipInfos)
     {
         // Control does not have a tooltip - nothing to do
         if (!tooltipInfos.ContainsKey(ctrl))
         {
             return;
         }
         TooltipInfo tti = tooltipInfos[ctrl];
         // Mouse enter: fade in from 0, or fade back in
         if (show)
         {
             // Currently nowhere: start countdown to show
             if (tti.AnimState == 0)
             {
                 tti.AnimState = 0.01F;
             }
             // Countdown already in progress or already fading in: nothing to do
             else if (tti.AnimState > 0 && tti.AnimState <= 100) /* NOP */ } {
    public void OpenTooltipAtPos(TooltipType type, Vector3 pos, TooltipInfo info, string message, bool isTwoDimension = true)
    {
        if (info.Title == "")
        {
            info = new TooltipInfo();
        }
        SwapTooltipObjects(type == TooltipType.Default ? tooltipObject : objectTooltipObject);

        Vector3 _pos = isTwoDimension ? GetPos_2D(pos) : GetPos_3D(pos);

        if (type == TooltipType.Default)
        {
            textTooltip.text = message;

            transformTooltip.position = _pos;
        }
        else
        {
            objectTooltip.OpenTooltipAtPosWithInfo(_pos, info);
        }
    }
Exemple #10
0
 /// <summary>
 /// Registers a control for showing tooltips; or removes it if null is passed.
 /// </summary>
 internal sealed override void RegisterControlForTooltip(ZenControlBase ctrl, IZenTooltip tt)
 {
     lock (tooltipInfos)
     {
         // Removing existing tooltip?
         if (tt == null && tooltipInfos.ContainsKey(ctrl))
         {
             // Tooltip will disappear when timer next hits.
             tooltipInfos[ctrl].AnimState = float.MinValue;
             // Make sure timer does hit.
             SubscribeToTimer();
         }
         // Adding or resetting tooltip?
         else if (tt != null)
         {
             // Not there yet: add now
             if (!tooltipInfos.ContainsKey(ctrl))
             {
                 TooltipInfo tti = new TooltipInfo(tt);
                 tooltipInfos[ctrl] = tti;
             }
             // There already: replace; keep animation state; make it repaint
             else
             {
                 TooltipInfo ttiExisting = tooltipInfos[ctrl];
                 TooltipInfo tti         = new TooltipInfo(tt);
                 tti.AnimState      = ttiExisting.AnimState;
                 tti.Repaint        = ttiExisting.AnimState != 0;
                 tooltipInfos[ctrl] = tti;
                 // If we need a repaint, make sure timer does hit.
                 if (tti.Repaint)
                 {
                     SubscribeToTimer();
                 }
             }
         }
     }
 }
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (!(value is IElementWithTooltip elementWithTooltip))
            {
                return(Binding.DoNothing);
            }

            TooltipInfo tooltipInfo = elementWithTooltip.CalculateTooltip();

            if (tooltipInfo == null)
            {
                return(Binding.DoNothing);
            }

            if (tooltipInfo.TrimExcess)
            {
                return(tooltipInfo.Tooltip.TrimExcess(tooltipInfo.MaxLength, tooltipInfo.OverflowSuffix));
            }
            else
            {
                return(tooltipInfo.Tooltip);
            }
        }
 public FloatingButtonWindow()
 {
     InitializeComponent();
     TooltipInfo = new TooltipInfo("", "", 1);
 }
 public void SetTooltipInfo(string title, string category, string main, string secondary) => info = new TooltipInfo(title, category, main, secondary);
 public void SetTooltipInfo(TooltipInfo _info) => info = _info;
Exemple #15
0
    public LinkedList<TooltipInfo> loadInfoFromFile(string filePath)
    {
        Logger.Log("TooltipLoader::loadInfoFromFile("+filePath+")", Logger.Level.DEBUG);

        LinkedList<TooltipInfo> resultInfo = new LinkedList<TooltipInfo>();

        XmlDocument xmlDoc = Tools.getXmlDocument(filePath);

        XmlNodeList infoList = xmlDoc.GetElementsByTagName(TooltipXMLTags.TOOLTIP);

        foreach (XmlNode infoNode in infoList)
        {
            reinitVars();
            //common info attributes
            try {
                _code = infoNode.Attributes[TooltipXMLTags.CODE].Value;
            }
            catch (NullReferenceException exc) {
                Logger.Log("TooltipLoader::loadInfoFromFile bad xml, missing field\n"+exc, Logger.Level.WARN);
                continue;
            }
            catch (Exception exc) {
                Logger.Log("TooltipLoader::loadInfoFromFile failed, got exc="+exc, Logger.Level.WARN);
                continue;
            }

            if (!String.IsNullOrEmpty(_code))
            {
                foreach (XmlNode attr in infoNode)
                {
                    switch (attr.Name)
                    {
                        case TooltipXMLTags.TITLE:
                            _title = attr.InnerText;
                            break;
                        case TooltipXMLTags.TYPE:
                            _type = attr.InnerText;
                            break;
                        case TooltipXMLTags.SUBTITLE:
                            _subtitle = attr.InnerText;
                            break;
                        case TooltipXMLTags.ILLUSTRATION:
                            _illustration = attr.InnerText;
                            break;
                        case TooltipXMLTags.CUSTOMFIELD:
                            _customField = attr.InnerText;
                            break;
                        case TooltipXMLTags.CUSTOMVALUE:
                            _customValue = attr.InnerText;
                            break;
                        case TooltipXMLTags.LENGTH:
                            _length = attr.InnerText;
                            break;
                        case TooltipXMLTags.REFERENCE:
                            _reference = attr.InnerText;
                            break;
                        case TooltipXMLTags.ENERGYCONSUMPTION:
                            _energyConsumption = attr.InnerText;
                            break;
                        case TooltipXMLTags.EXPLANATION:
                            _explanation = attr.InnerText;
                            break;
                        default:
                            Logger.Log("TooltipLoader::loadInfoFromFile unknown attr "+attr.Name+" for info node", Logger.Level.WARN);
                            break;
                    }
                }
                if(!String.IsNullOrEmpty(_type))
                {
            
                    string root = _tooltipPrefix+_code.ToUpper().Replace(' ','_');
                    _title = string.IsNullOrEmpty(_title)?root+_titleSuffix:_title;
                    _subtitle = string.IsNullOrEmpty(_subtitle)?root+_subtitleSuffix:_subtitle;
                    _customField = string.IsNullOrEmpty(_customField)?getKeyIfExists(root+_customFieldSuffix):_customField;
                    _customValue = string.IsNullOrEmpty(_customValue)?getKeyIfExists(root+_customValueSuffix):_customValue;
                    _length = string.IsNullOrEmpty(_length)?root+_lengthSuffix:_length;
                    _reference = string.IsNullOrEmpty(_reference)?root+_referenceSuffix:_reference;
                    _energyConsumption = string.IsNullOrEmpty(_energyConsumption)?getKeyIfExists(root+_energySuffix):_energyConsumption;
                    _explanation = string.IsNullOrEmpty(_explanation)?root+_explanationSuffix:_explanation;
                    
                    string lower = _type.ToLowerInvariant();
                    if(lower == TooltipManager.TooltipType.DEVICE.ToString().ToLowerInvariant())
                    {
                        _tooltipType = TooltipManager.TooltipType.DEVICE;
                    }
                    else if(lower == TooltipManager.TooltipType.BIOBRICK.ToString().ToLowerInvariant())
                    {
                        _tooltipType = TooltipManager.TooltipType.BIOBRICK;
                    }
                    else
                    {
                        _tooltipType = TooltipManager.TooltipType.BIOBRICK;
                    }
                    
                    _info = new TooltipInfo(
                        _code,
                        _title,
                        _tooltipType,
                        _subtitle,
                        _illustration,
                        _customField,
                        _customValue,
                        _length,
                        _reference,
                        _energyConsumption,
                        _explanation
                    );
                }
                if(null != _info)
                {
                        resultInfo.AddLast(_info);
                }
            } else {
                Logger.Log("TooltipLoader::loadInfoFromFile Error : missing attribute code in info node", Logger.Level.WARN);
            }
        }
        return resultInfo;
    }
 /// <summary>
 /// Ctor: init immutable instance.
 /// </summary>
 public TooltipToPaint(ZenControlBase ctrl, TooltipInfo tti, float strength)
 {
     Ctrl = ctrl;
     TTI = tti;
     Strength = strength;
 }
    public void SetAbilitySkill(AbilitySkillWrapper p_wrapper)
    {
        if (m_modifiableInfo.Count == 0)
        {
            FillModifiableInfo();
        }

        foreach (TooltipInfo info in m_modifiableInfo)
        {
            info.m_info.SetActive(false);
        }

        m_panelHeight       = m_tooltipBorderSize * 2 + 12;
        m_tooltipInfoOffset = -(m_panelHeight / 2);
        Ability ability = p_wrapper.AbilityWrapper != null?p_wrapper.AbilityWrapper.GetAbility() : null;

        Skill skill = p_wrapper.SkillWrapper != null?p_wrapper.SkillWrapper.GetSkill() : null;

        DamageType type = ability != null?DamageType.Get(ability.m_domain) : null;

        TextMeshProUGUI name = m_modifiableInfo.Find(ti => ti.m_name == "AbilitySkill Name Text")
                               .Get <TextMeshProUGUI>(ref m_panelHeight, ref m_tooltipInfoOffset);

        name.text  = Get(p_wrapper.GetDisplayName());
        name.color = ability != null ? type.m_nameColor.Value : skill.m_nameColor.Value;

        if (ability != null)
        {
            TextMeshProUGUI domain = m_modifiableInfo.Find(ti => ti.m_name == "Domain Text").GetAligned <TextMeshProUGUI>(ref m_tooltipInfoOffset);
            domain.text  = Get(ability.m_domain);
            domain.color = type.m_nameColor.Value;

            TextMeshProUGUI active = m_modifiableInfo.Find(ti => ti.m_name == "Active Text")
                                     .Get <TextMeshProUGUI>(ref m_panelHeight, ref m_tooltipInfoOffset);
            active.text = Get(ability.m_isPassive ? "Passive" : "Active");
        }

        ShowSeparator(1);

        string prefixColorTag = "<color=#" + ColorUtility.ToHtmlStringRGBA(Constants.YELLOW) + ">";
        string suffixColorTag = "</color>";

        TextMeshProUGUI trainingLevel = m_modifiableInfo.Find(ti => ti.m_name == "Training Level")
                                        .Get <TextMeshProUGUI>(ref m_panelHeight, ref m_tooltipInfoOffset);

        trainingLevel.text = Game.m_languages.FormatTexts(Get("Training Level: {0}"), prefixColorTag + p_wrapper.GetTrainingLevel().ToString() + suffixColorTag);

        if (p_wrapper.GetTrainingLevel() < p_wrapper.GetMaxTrainingLevel())
        {
            TextMeshProUGUI expToNextLevel = m_modifiableInfo.Find(ti => ti.m_name == "Training Exp Next Level")
                                             .Get <TextMeshProUGUI>(ref m_panelHeight, ref m_tooltipInfoOffset);
            expToNextLevel.text = Game.m_languages.FormatTexts(Get("EXP to next level: {0}"),
                                                               prefixColorTag + p_wrapper.GetTrainingExpCost(p_wrapper.GetTrainingLevel() + 1).ToString() + suffixColorTag);
        }

        if (ability != null && p_wrapper.Learned())
        {
            TextMeshProUGUI cd = m_modifiableInfo.Find(ti => ti.m_name == "Cooldown").Get <TextMeshProUGUI>(ref m_panelHeight, ref m_tooltipInfoOffset);
            cd.text = Game.m_languages.FormatTexts(Get("{0}s cooldown"),
                                                   prefixColorTag + p_wrapper.GetCooldown(p_wrapper.GetTrainingLevel()).ToString() + suffixColorTag);
        }

        ShowSeparator(2);

        TextMeshProUGUI sellPrice = m_modifiableInfo.Find(ti => ti.m_name == "Sell Price").Get <TextMeshProUGUI>(ref m_panelHeight, ref m_tooltipInfoOffset);

        sellPrice.text  = Game.m_languages.FormatTexts(Get("Sell Price: {0}g"), prefixColorTag + p_wrapper.GetSellPrice() + suffixColorTag);
        sellPrice.color = Constants.WHITE;

        TooltipInfo     descInfo    = m_modifiableInfo.Find(ti => ti.m_name == "Item Description Text");
        TextMeshProUGUI description = descInfo.Get <TextMeshProUGUI>();

        description.text     = p_wrapper.GetDescription(p_wrapper.GetTrainingLevel(), true);
        description.color    = Constants.YELLOW;
        m_tooltipInfoOffset += description.rectTransform.rect.y;

        Show(m_panelHeight, true);         // activating the description to allow the preferred height to be fetched

        float descPrefHeight = LayoutUtility.GetPreferredHeight(description.rectTransform);

        m_tooltipInfoOffset += descPrefHeight / 2;

        description = descInfo.Get <TextMeshProUGUI>(ref m_panelHeight, ref m_tooltipInfoOffset, descPrefHeight);

        Show(m_panelHeight, false);         // resizing the panel again to fit
    }
Exemple #18
0
    private void Start()
    {
        if (this.isBigSandboxButton && base.transform.parent != null)
        {
            this.m_sandboxSelector = base.transform.parent.GetComponent <SandboxSelector>();
        }
        if (this.m_sandboxSelector == null && base.transform.parent != null && base.transform.parent.parent != null)
        {
            this.m_sandboxSelector = base.transform.parent.parent.GetComponent <SandboxSelector>();
        }
        this.starSet = base.transform.Find("StarSet");
        if (this.starSet != null && !this.isBigSandboxButton)
        {
            this.starSet.parent = base.transform.parent;
        }
        UnlockSandboxSequence component = base.GetComponent <UnlockSandboxSequence>();
        bool flag      = GameProgress.GetSandboxUnlocked(this.m_sandboxIdentifier);
        bool isOdyssey = Singleton <BuildCustomizationLoader> .Instance.IsOdyssey;

        if (isOdyssey && (this.m_sandboxIdentifier.Equals("S-M") || this.m_sandboxIdentifier.Equals("S-F")))
        {
            flag = true;
        }
        if (!flag && this.m_sandboxIdentifier.Equals("S-M"))
        {
            UnityEngine.Debug.LogError("SandboxLevelButton S-M");
            int cost = this.GetUnlockPrice(this.m_sandboxIdentifier);
            this.AddSMSandboxUnlockDialog(base.GetComponent <Button>(), cost, this.m_sandboxIdentifier, () => GameProgress.SnoutCoinCount() >= cost);
        }
        else if (!flag && this.m_sandboxIdentifier.Equals("S-F"))
        {
            this.AddBuyFieldOfDreamsButton(base.GetComponent <Button>());
        }
        else if (!flag && !isOdyssey)
        {
            if (SandboxLevelButton.sandboxUnlockDialog == null)
            {
                GameObject gameObject = UnityEngine.Object.Instantiate <GameObject>(Singleton <GameManager> .Instance.gameData.m_sandboxUnlockDialog);
                gameObject.transform.position          = new Vector3(0f, 0f, -10f);
                SandboxLevelButton.sandboxUnlockDialog = gameObject.GetComponent <SandboxUnlockDialog>();
                SandboxLevelButton.sandboxUnlockDialog.Close();
            }
            int cost = this.GetUnlockPrice(this.m_sandboxIdentifier);
            this.AddSandboxUnlockDialog(base.GetComponent <Button>(), SandboxLevelButton.sandboxUnlockDialog, this.m_sandboxIdentifier, cost, () => GameProgress.SnoutCoinCount() >= cost);
        }
        else if (!flag && isOdyssey)
        {
            TooltipInfo component2 = base.GetComponent <TooltipInfo>();
            if (component2 != null)
            {
                this.setTooltipButton = base.GetComponent <Button>();
                this.setTooltipButton.MethodToCall.SetMethod(component2, "Show");
            }
        }
        GameProgress.ButtonUnlockState buttonUnlockState = GameProgress.GetButtonUnlockState("SandboxLevelButton_" + this.m_sandboxIdentifier);
        if (flag)
        {
            if (component == null && buttonUnlockState == GameProgress.ButtonUnlockState.Locked)
            {
                base.gameObject.AddComponent <UnlockSandboxSequence>();
            }
            Button component3 = base.GetComponent <Button>();
            component3.MethodToCall.SetMethod(this.m_sandboxSelector, "LoadSandboxLevel", this.m_sandboxIdentifier);
            string str = WPFMonoBehaviour.gameData.m_sandboxLevels.GetLevelData(this.m_sandboxIdentifier).m_starBoxCount.ToString();
            this.m_starsText.text = GameProgress.SandboxStarCount(this.m_sandboxSelector.FindLevelFile(this.m_sandboxIdentifier)).ToString() + "/" + str;
            for (int i = 0; i < this.hideOnContentUnlocked.Length; i++)
            {
                this.hideOnContentUnlocked[i].SetActive(false);
            }
        }
        else if (!flag && this.m_starsText != null)
        {
            string arg = WPFMonoBehaviour.gameData.m_sandboxLevels.GetLevelData(this.m_sandboxIdentifier).m_starBoxCount.ToString();
            this.m_starsText.text = string.Format("{0}/{1}", 0, arg);
            for (int j = 0; j < this.hideOnContentLocked.Length; j++)
            {
                this.hideOnContentLocked[j].SetActive(false);
            }
        }
    }
    private void Start()
    {
        if (base.transform.parent != null)
        {
            this.m_sandboxSelector = base.transform.parent.GetComponent <SandboxSelector>();
        }
        this.starSet    = base.transform.Find("StarSet");
        this.collectSet = base.transform.Find("Set");
        this.m_Limit    = 10;
        bool            isOdyssey       = Singleton <BuildCustomizationLoader> .Instance.IsOdyssey;
        bool            flag            = false;
        string          collectable     = string.Empty;
        string          arg             = string.Empty;
        CollectableType collectableType = this.collectableType;

        if (collectableType != CollectableType.Skull)
        {
            if (collectableType == CollectableType.Statue)
            {
                flag        = (GameProgress.SecretStatueCount() >= this.m_Limit || GameProgress.GetSandboxUnlocked(this.m_sandboxIdentifier));
                collectable = "Statues";
                arg         = "[statue]";
            }
        }
        else
        {
            flag        = (GameProgress.SecretSkullCount() >= this.m_Limit || GameProgress.GetSandboxUnlocked(this.m_sandboxIdentifier));
            collectable = "Skulls";
            arg         = "[skull]";
        }
        GameProgress.ButtonUnlockState buttonUnlockState = GameProgress.GetButtonUnlockState("SandboxLevelButton_" + this.m_sandboxIdentifier);
        if (flag && buttonUnlockState == GameProgress.ButtonUnlockState.Locked && base.GetComponent <UnlockSandboxSequence>() == null)
        {
            base.gameObject.AddComponent <UnlockSandboxSequence>();
        }
        if (flag)
        {
            Button component = base.GetComponent <Button>();
            component.MethodToCall.SetMethod(this.m_sandboxSelector.gameObject.GetComponent <SandboxSelector>(), "LoadSandboxLevel", this.m_sandboxIdentifier);
            if (this.collectSet != null)
            {
                this.collectSet.gameObject.SetActive(false);
            }
            if (this.starSet != null)
            {
                this.starSet.gameObject.SetActive(true);
            }
            string str = WPFMonoBehaviour.gameData.m_sandboxLevels.GetLevelData(this.m_sandboxIdentifier).m_starBoxCount.ToString();
            this.m_starsText.text = GameProgress.SandboxStarCount(this.m_sandboxSelector.FindLevelFile(this.m_sandboxIdentifier)).ToString() + "/" + str;
        }
        else
        {
            if (this.starSet != null)
            {
                this.starSet.gameObject.SetActive(false);
            }
            int             num = 0;
            CollectableType collectableType2 = this.collectableType;
            if (collectableType2 != CollectableType.Skull)
            {
                if (collectableType2 == CollectableType.Statue)
                {
                    num = GameProgress.SecretStatueCount();
                }
            }
            else
            {
                num = GameProgress.SecretSkullCount();
            }
            this.m_Text.text = string.Format("{0} {1}/{2}", arg, num, this.m_Limit);
            this.m_Text.SendMessage("TextUpdated", SendMessageOptions.DontRequireReceiver);
            if (isOdyssey)
            {
                TooltipInfo component2 = base.GetComponent <TooltipInfo>();
                if (component2 != null)
                {
                    Button component3 = base.GetComponent <Button>();
                    component3.MethodToCall.SetMethod(component2, "Show");
                    component3.Lock(false);
                }
            }
            else
            {
                string id   = (this.collectableType != CollectableType.Statue) ? "sandbox_unlock_skull_collectable" : "sandbox_unlock_statue_collectable";
                int    num2 = Singleton <VirtualCatalogManager> .Instance.GetProductPrice(id);

                if (num2 <= 0)
                {
                    num2 = 50;
                }
                int cost = (this.m_Limit - num) * num2;
                this.AddUnlockPopup(base.GetComponent <Button>(), this.m_sandboxIdentifier, collectable, num, this.m_Limit, cost, () => GameProgress.SnoutCoinCount() >= cost);
            }
        }
    }
Exemple #20
0
 /// <summary>
 /// Ctor: init immutable instance.
 /// </summary>
 public TooltipToPaint(ZenControlBase ctrl, TooltipInfo tti, float strength)
 {
     Ctrl     = ctrl;
     TTI      = tti;
     Strength = strength;
 }
Exemple #21
0
 public DisguiseToolTip(Actor self, TooltipInfo info)
 {
     this.self = self;
     this.info = info;
     disguise  = self.Trait <Disguise>();
 }
Exemple #22
0
    public void SetItem(Item p_item)
    {
        Entity holder = p_item.m_holder ? p_item.m_holder : p_item.m_inventory.m_interactor;

        if (m_modifiableInfo.Count == 0)
        {
            FillModifiableInfo();
        }

        foreach (TooltipInfo info in m_modifiableInfo)
        {
            info.m_info.SetActive(false);
        }

        m_panelHeight       = m_tooltipBorderSize * 2 + 12;
        m_tooltipInfoOffset = -(m_panelHeight / 2);
        BaseItem item = p_item.m_item;

        Show(m_panelHeight, true); // activating the tooltip (out of sight) to allow preferred heights to be fetched

        TextMeshProUGUI name = m_modifiableInfo.Find(ti => ti.m_name == "Item Name Text").Get <TextMeshProUGUI>(ref m_panelHeight, ref m_tooltipInfoOffset);

        name.text  = Get(item.GetDisplayName());
        name.color = item.m_nameColor.Value;

        if (item is Armor || item is Weapon)
        {
            TextMeshProUGUI type     = m_modifiableInfo.Find(ti => ti.m_name == "Item Type Text").GetAligned <TextMeshProUGUI>(ref m_tooltipInfoOffset);
            string          itemType = "";

            if (item is Armor)
            {
                itemType = (item as Armor).GetArmorType().ToString();
            }
            if (item is Weapon)
            {
                itemType = (item as Weapon).GetWeaponType().ToString();
            }

            type.text = Get(itemType);
        }

        TextMeshProUGUI slot = m_modifiableInfo.Find(ti => ti.m_name == "Slot Info Text").Get <TextMeshProUGUI>(ref m_panelHeight, ref m_tooltipInfoOffset);

        slot.text = Get(item.GetSlotInfoText());

        ShowSeparator(1);

        bool leftShotPattern  = false;
        bool rightShotPattern = false;

        if (item is Weapon)
        {
            Weapon weapon = item as Weapon;

            leftShotPattern = !String.IsNullOrEmpty(weapon.m_leftClickPattern) && ShotPattern.Get(weapon.m_leftClickPattern, true) != null;

            if (leftShotPattern)
            {
                ShowShotPattern(1, ShotPattern.Get(weapon.m_leftClickPattern, true), ref m_panelHeight);
                ShowSeparator(2);

                rightShotPattern = !String.IsNullOrEmpty(weapon.m_rightClickPattern) && ShotPattern.Get(weapon.m_rightClickPattern, true) != null;

                if (rightShotPattern)
                {
                    ShowShotPattern(2, ShotPattern.Get(weapon.m_rightClickPattern, true), ref m_panelHeight);
                    ShowSeparator(3);
                }
            }
        }

        if (item is Weapon || item is Armor)
        {
            int[] statGains = item is Weapon ? (item as Weapon).m_statGainValues : (item as Armor).m_statGainValues;

            if (statGains.Length == UnitStats.STAT_AMOUNT)
            {
                TextMeshProUGUI statGainText          = m_modifiableInfo.Find(ti => ti.m_name == "Stat Gain Text").Get <TextMeshProUGUI>();
                TextMeshProUGUI statComparisonOneText = m_modifiableInfo.Find(ti => ti.m_name == "Stat Comparison 1").Get <TextMeshProUGUI>();
                TextMeshProUGUI statComparisonTwoText = m_modifiableInfo.Find(ti => ti.m_name == "Stat Comparison 2").Get <TextMeshProUGUI>();
                int[]           comparisonOne         = item.m_equipmentSlots.Count >= 1 ?
                                                        BaseItem.GetStatGainDifferences(item, holder.m_equipment, item.m_equipmentSlots[0]) : new int[UnitStats.STAT_AMOUNT];
                int[] comparisonTwo = item.m_equipmentSlots.Count == 2 ?
                                      BaseItem.GetStatGainDifferences(item, holder.m_equipment, item.m_equipmentSlots[1]) : new int[UnitStats.STAT_AMOUNT];

                if (p_item.m_inventory == holder.m_equipment)
                {
                    comparisonOne = new int[UnitStats.STAT_AMOUNT];
                    comparisonTwo = new int[UnitStats.STAT_AMOUNT];
                }

                for (int i = 0; i < statGains.Length; ++i)
                {
                    if (statGains[i] == 0 && comparisonOne[i] == 0 && comparisonTwo[i] == 0)
                    {
                        continue;
                    }
                    if (!m_modifiableInfo.Exists(ti => ti.m_name == ((Stats)i).ToString() + " Gain Text"))
                    {
                        InstantiateStatText(((Stats)i).ToString() + " Gain Text", statGainText, transform);
                    }

                    TextMeshProUGUI statGain = m_modifiableInfo.Find(ti => ti.m_name == ((Stats)i).ToString() + " Gain Text")
                                               .Get <TextMeshProUGUI>(ref m_panelHeight, ref m_tooltipInfoOffset);
                    if (!m_modifiableInfo.Exists(ti => ti.m_name == ((Stats)i).ToString() + " Comparison 1"))
                    {
                        InstantiateStatText(((Stats)i).ToString() + " Comparison 1", statComparisonOneText, statGain.transform);
                    }
                    if (!m_modifiableInfo.Exists(ti => ti.m_name == ((Stats)i).ToString() + " Comparison 2"))
                    {
                        InstantiateStatText(((Stats)i).ToString() + " Comparison 2", statComparisonTwoText, statGain.transform);
                    }

                    TextMeshProUGUI statComparisonOne = m_modifiableInfo.Find(ti => ti.m_name == ((Stats)i).ToString() + " Comparison 1")
                                                        .Get <TextMeshProUGUI>();
                    TextMeshProUGUI statComparisonTwo = m_modifiableInfo.Find(ti => ti.m_name == ((Stats)i).ToString() + " Comparison 2")
                                                        .Get <TextMeshProUGUI>();

                    statGain.color = statGains[i] > 0 ? Constants.GREEN : (statGains[i] == 0 ? Constants.YELLOW : Constants.RED);
                    statGain.text  = (statGains[i] > 0 ? "+" : "") + statGains[i] + " " + ((Stats)i).ToString();

                    if (comparisonOne[i] != 0)
                    {
                        statComparisonOne.color = comparisonOne[i] > 0 ? Constants.GREEN : Constants.RED;
                        statComparisonOne.text  = "(" + (comparisonOne[i] > 0 ? "+" : "") + comparisonOne[i] + ")";
                    }
                    else
                    {
                        statComparisonOne.text = "";
                    }

                    if (comparisonTwo[i] != 0)
                    {
                        statComparisonTwo.color = comparisonTwo[i] > 0 ? Constants.GREEN : Constants.RED;
                        statComparisonTwo.text  = "(" + (comparisonTwo[i] > 0 ? "+" : "") + comparisonTwo[i] + ")";
                    }
                    else
                    {
                        statComparisonTwo.text = "";
                    }
                }
            }
        }

        string prefixColorTag = "<color=#" + ColorUtility.ToHtmlStringRGBA(Constants.YELLOW) + ">";
        string suffixColorTag = "</color>";

        if (item is Weapon || item is Armor)
        {
            TextMeshProUGUI durability = m_modifiableInfo.Find(ti => ti.m_name == "Durability")
                                         .Get <TextMeshProUGUI>(ref m_panelHeight, ref m_tooltipInfoOffset);
            durability.text  = Game.m_languages.FormatTexts(Get("Durability: {0}%"), prefixColorTag + p_item.m_durability + suffixColorTag);
            durability.color = Constants.WHITE;
        }

        TextMeshProUGUI sellPrice = m_modifiableInfo.Find(ti => ti.m_name == "Sell Price")
                                    .Get <TextMeshProUGUI>(ref m_panelHeight, ref m_tooltipInfoOffset);

        sellPrice.text  = Game.m_languages.FormatTexts(Get("Sell Price: {0}g"), prefixColorTag + item.m_sellPrice + suffixColorTag);
        sellPrice.color = Constants.WHITE;

        TooltipInfo     descInfo    = m_modifiableInfo.Find(ti => ti.m_name == "Item Description Text");
        TextMeshProUGUI description = descInfo.Get <TextMeshProUGUI>();

        description.text = "";

        float basePrefHeight = LayoutUtility.GetPreferredHeight(description.rectTransform);

        description.text     = Get(item.m_description);
        description.color    = Constants.YELLOW;
        m_tooltipInfoOffset += description.rectTransform.rect.y;

        float descPrefHeight = LayoutUtility.GetPreferredHeight(description.rectTransform);

        if (basePrefHeight != descPrefHeight)  // multiline
        {
            m_tooltipInfoOffset += descPrefHeight / 2f;

            description = descInfo.Get <TextMeshProUGUI>(ref m_panelHeight, ref m_tooltipInfoOffset, descPrefHeight);
        }
        else
        {
            description    = descInfo.Get <TextMeshProUGUI>(ref m_panelHeight, ref m_tooltipInfoOffset);
            m_panelHeight += basePrefHeight;
        }

        if (leftShotPattern)
        {
            PositionDamageType(1);
        }
        if (rightShotPattern)
        {
            PositionDamageType(2);
        }

        Show(m_panelHeight, false);         // resizing the panel again to fit and actually showing it
    }
Exemple #23
0
    public LinkedList <TooltipInfo> loadInfoFromFile(string filePath)
    {
        Logger.Log("TooltipLoader::loadInfoFromFile(" + filePath + ")", Logger.Level.DEBUG);

        LinkedList <TooltipInfo> resultInfo = new LinkedList <TooltipInfo>();

        XmlDocument xmlDoc = Tools.getXmlDocument(filePath);

        XmlNodeList infoList = xmlDoc.GetElementsByTagName(TooltipXMLTags.TOOLTIP);

        foreach (XmlNode infoNode in infoList)
        {
            reinitVars();
            //common info attributes
            try {
                _code = infoNode.Attributes[TooltipXMLTags.CODE].Value;
            }
            catch (NullReferenceException exc) {
                Logger.Log("TooltipLoader::loadInfoFromFile bad xml, missing field\n" + exc, Logger.Level.WARN);
                continue;
            }
            catch (Exception exc) {
                Logger.Log("TooltipLoader::loadInfoFromFile failed, got exc=" + exc, Logger.Level.WARN);
                continue;
            }

            if (!String.IsNullOrEmpty(_code))
            {
                foreach (XmlNode attr in infoNode)
                {
                    switch (attr.Name)
                    {
                    case TooltipXMLTags.TITLE:
                        _title = attr.InnerText;
                        break;

                    case TooltipXMLTags.TYPE:
                        _type = attr.InnerText;
                        break;

                    case TooltipXMLTags.SUBTITLE:
                        _subtitle = attr.InnerText;
                        break;

                    case TooltipXMLTags.ILLUSTRATION:
                        _illustration = attr.InnerText;
                        break;

                    case TooltipXMLTags.CUSTOMFIELD:
                        _customField = attr.InnerText;
                        break;

                    case TooltipXMLTags.CUSTOMVALUE:
                        _customValue = attr.InnerText;
                        break;

                    case TooltipXMLTags.LENGTH:
                        _length = attr.InnerText;
                        break;

                    case TooltipXMLTags.REFERENCE:
                        _reference = attr.InnerText;
                        break;

                    case TooltipXMLTags.ENERGYCONSUMPTION:
                        _energyConsumption = attr.InnerText;
                        break;

                    case TooltipXMLTags.EXPLANATION:
                        _explanation = attr.InnerText;
                        break;

                    default:
                        Logger.Log("TooltipLoader::loadInfoFromFile unknown attr " + attr.Name + " for info node", Logger.Level.WARN);
                        break;
                    }
                }
                if (!String.IsNullOrEmpty(_type))
                {
                    string root = _tooltipPrefix + _code.ToUpper().Replace(' ', '_');
                    _title             = string.IsNullOrEmpty(_title)?root + _titleSuffix:_title;
                    _subtitle          = string.IsNullOrEmpty(_subtitle)?root + _subtitleSuffix:_subtitle;
                    _customField       = string.IsNullOrEmpty(_customField)?getKeyIfExists(root + _customFieldSuffix):_customField;
                    _customValue       = string.IsNullOrEmpty(_customValue)?getKeyIfExists(root + _customValueSuffix):_customValue;
                    _length            = string.IsNullOrEmpty(_length)?root + _lengthSuffix:_length;
                    _reference         = string.IsNullOrEmpty(_reference)?root + _referenceSuffix:_reference;
                    _energyConsumption = string.IsNullOrEmpty(_energyConsumption)?getKeyIfExists(root + _energySuffix):_energyConsumption;
                    _explanation       = string.IsNullOrEmpty(_explanation)?root + _explanationSuffix:_explanation;

                    string lower = _type.ToLowerInvariant();
                    if (lower == TooltipManager.TooltipType.DEVICE.ToString().ToLowerInvariant())
                    {
                        _tooltipType = TooltipManager.TooltipType.DEVICE;
                    }
                    else if (lower == TooltipManager.TooltipType.BIOBRICK.ToString().ToLowerInvariant())
                    {
                        _tooltipType = TooltipManager.TooltipType.BIOBRICK;
                    }
                    else
                    {
                        _tooltipType = TooltipManager.TooltipType.BIOBRICK;
                    }

                    _info = new TooltipInfo(
                        _code,
                        _title,
                        _tooltipType,
                        _subtitle,
                        _illustration,
                        _customField,
                        _customValue,
                        _length,
                        _reference,
                        _energyConsumption,
                        _explanation
                        );
                }
                if (null != _info)
                {
                    resultInfo.AddLast(_info);
                }
            }
            else
            {
                Logger.Log("TooltipLoader::loadInfoFromFile Error : missing attribute code in info node", Logger.Level.WARN);
            }
        }
        return(resultInfo);
    }
Exemple #24
0
    private void ShowShotPattern(float p_shotNumber, ShotPattern p_pattern, ref float p_panelHeight)
    {
        string shot           = "Shot " + p_shotNumber;
        string prefixColorTag = "<color=#" + ColorUtility.ToHtmlStringRGBA(Constants.YELLOW) + ">";
        string suffixColorTag = "</color>";

        TextMeshProUGUI cd = m_modifiableInfo.Find(ti => ti.m_name == shot + " CD").GetAligned <TextMeshProUGUI>(ref m_tooltipInfoOffset);

        cd.text  = Game.m_languages.FormatTexts(Get("{0}s cooldown"), prefixColorTag + p_pattern.m_patternCooldown.ToString() + suffixColorTag);
        cd.color = Constants.WHITE;

        string statColor = ColorUtility.ToHtmlStringRGBA(((Stats)Enum.Parse(typeof(Stats), p_pattern.m_projectileInfo.m_statApplied)).GetColor());

        m_modifiableInfo.Find(ti => ti.m_name == shot + " Label").Get <TextMeshProUGUI>(ref p_panelHeight, ref m_tooltipInfoOffset).text =
            Game.m_languages.FormatTexts(Get("Shot {0}"), p_shotNumber.ToString()) +
            " (+<color=#" + statColor + ">" +
            p_pattern.m_projectileInfo.m_statApplied.ToString() + "</color>)";

        if (p_pattern.m_projectileInfo.m_piercing)
        {
            m_modifiableInfo.Find(ti => ti.m_name == shot + " Piercing Text").GetAligned <TextMeshProUGUI>(ref m_tooltipInfoOffset).color = Constants.PURPLE;
        }

        m_modifiableInfo.Find(ti => ti.m_name == shot + " Background").GetAligned <Image>(ref m_tooltipInfoOffset);
        Image shotSprite = m_modifiableInfo.Find(ti => ti.m_name == shot + " Sprite").Get <Image>();

        shotSprite.sprite = Projectile.Get(p_pattern.m_projectile).GetComponent <SpriteRenderer>().sprite;

        TextMeshProUGUI shots = m_modifiableInfo.Find(ti => ti.m_name == shot + " Shots").Get <TextMeshProUGUI>(ref p_panelHeight, ref m_tooltipInfoOffset);

        shots.text  = Game.m_languages.FormatTexts(Get("Shots: {0}"), prefixColorTag + p_pattern.m_shots.ToString() + suffixColorTag);
        shots.color = Constants.WHITE;

        if (p_pattern.m_projectileInfo.m_armorPiercing)
        {
            m_modifiableInfo.Find(ti => ti.m_name == shot + " Armor Piercing Text")
            .GetAligned <TextMeshProUGUI>(ref m_tooltipInfoOffset).color = Constants.RED;
        }

        TextMeshProUGUI damage = m_modifiableInfo.Find(ti => ti.m_name == shot + " Damage").Get <TextMeshProUGUI>(ref p_panelHeight, ref m_tooltipInfoOffset);

        damage.text  = Game.m_languages.FormatTexts(Get("Damage: {0}"), prefixColorTag + p_pattern.m_projectileInfo.m_damage.ToString() + suffixColorTag);
        damage.color = Constants.WHITE;

        Sprite damageTypeIcon = DamageType.Get(p_pattern.m_projectileInfo.m_damageType).m_icon;

        if (damageTypeIcon)
        {
            Image damageType = m_modifiableInfo.Find(ti => ti.m_name == shot + " DamageType").Get <Image>();
            damageType.sprite = damageTypeIcon;
        }

        TextMeshProUGUI mana = m_modifiableInfo.Find(ti => ti.m_name == shot + " Mana").GetAligned <TextMeshProUGUI>(ref m_tooltipInfoOffset);

        mana.text  = Game.m_languages.FormatTexts(Get("{0} Mana"), p_pattern.m_manaPerStep.ToString());
        mana.color = Constants.MANA_BLUE;

        TextMeshProUGUI range = m_modifiableInfo.Find(ti => ti.m_name == shot + " Range").Get <TextMeshProUGUI>(ref p_panelHeight, ref m_tooltipInfoOffset);

        range.text  = Game.m_languages.FormatTexts(Get("Range: {0}"), prefixColorTag + p_pattern.m_projectileInfo.m_range.ToString() + suffixColorTag);
        range.color = Constants.WHITE;

        if (p_pattern.m_extraTooltipInfo.Length > 0)
        {
            TooltipInfo     extraInfo = m_modifiableInfo.Find(ti => ti.m_name == shot + " Extra Text");
            TextMeshProUGUI extra     = extraInfo.Get <TextMeshProUGUI>();
            extra.text = "";

            float basePrefHeight = LayoutUtility.GetPreferredHeight(extra.rectTransform);

            extra.text  = Get(p_pattern.m_extraTooltipInfo);
            extra.color = Constants.YELLOW;

            float extraPrefHeight = LayoutUtility.GetPreferredHeight(extra.rectTransform);
            if (basePrefHeight != extraPrefHeight)  // multiline
            {
                m_tooltipInfoOffset += extra.rectTransform.rect.y;
                m_tooltipInfoOffset += extraPrefHeight / 1.15f;

                // original 1.7f (pre-tmp)
                extra                = extraInfo.Get <TextMeshProUGUI>(ref m_panelHeight, ref m_tooltipInfoOffset, extraPrefHeight * 1.6f);
                m_panelHeight       -= extraPrefHeight * 1.6f - extraPrefHeight;
                m_tooltipInfoOffset -= extra.rectTransform.rect.y / 2;
            }
            else
            {
                extra = extraInfo.Get <TextMeshProUGUI>(ref m_panelHeight, ref m_tooltipInfoOffset);
            }
        }
    }