Exemple #1
0
        private static void AfterSetRecruitment_ListPerks(HavenFacilityItemController __instance, GeoHaven ____haven)
        {
            try {
                var recruit = ____haven?.AvailableRecruit;
                if (Config.Disable_Zone_Tooltip)
                {
                    __instance.ZoneTooltip.Enabled = recruit == null;
                }
                if (recruit == null)
                {
                    return;
                }
                //Api( "ui.dump", __instance );

                Info("Showing info of {0}", recruit.GetName());
                if (Config.Skills.Enabled)
                {
                    ShowRecruitInfo(__instance, "PersonalSkills", new PersonalSkillInfo(recruit));
                }
                if (Config.Augments.Enabled)
                {
                    ShowRecruitInfo(__instance, "AugmentList", new AugInfo(recruit));
                }
                if (Config.Equipments.Enabled)
                {
                    ShowRecruitInfo(__instance, "EquipmentList", new EquipmentInfo(recruit));
                }
                //ModnixApi?.Invoke( "zy.ui.dump", __instance.gameObject );
            } catch (Exception ex) { Error(ex); }
        }
Exemple #2
0
 private static void ShowRecruitInfo(HavenFacilityItemController __instance, string id, RecruitInfo info)
 {
     try {
         var        names    = info.GetNames();
         GameObject infoText = CreateNameText(__instance, id, info.Config.Mouse_Over_Popup);
         if (!names.Any())
         {
             infoText.SetActive(false);
             return;
         }
         else
         {
             infoText.SetActive(true);
         }
         var text = "     " + info.NameTags[0];
         if (info.Config.List_Names || names.Count() == 1)
         {
             text += names.Join();
         }
         else
         {
             text += TitleCase(new LocalizedTextBind(info.Count_Label).Localize()) + " x" + names.Count();
         }
         infoText.GetComponent <UnityEngine.UI.Text>().text = text + info.NameTags[1];
         if (info.Config.Mouse_Over_Popup)
         {
             info.SetTags();
             infoText.GetComponent <UITooltipText>().TipText = info.GetDesc().Join(e => BuildHint(e, info.DescTags), "\n\n");
         }
     } catch (Exception ex) { Error(ex); }
 }
Exemple #3
0
        private static GameObject CreateNameText(HavenFacilityItemController ctl, string name, bool hasHint)
        {
            var owner = ctl.RecruitName?.transform?.parent?.parent;

            if (owner == null)
            {
                throw new InvalidOperationException("Recruit group not found, cannot add recruit info text");
            }
            var infoText = owner.Find(name)?.gameObject;

            if (infoText != null)
            {
                return(infoText);
            }

            Verbo("Creating {0} Text", name);
            var copyFrom = owner.Find("RecruitCost")?.Find("Name")?.GetComponent <UnityEngine.UI.Text>() ?? ctl.RecruitName;

            infoText = new GameObject(name);
            infoText.transform.SetParent(owner);

            var text = infoText.AddComponent <UnityEngine.UI.Text>();

            text.font                 = copyFrom.font;
            text.fontStyle            = copyFrom.fontStyle; // RecruitName Bold, Cost normal
            text.fontSize             = 42;                 // RecruitName 52, Cost 42
            text.resizeTextForBestFit = true;
            text.resizeTextMinSize    = 10;

            var rect = infoText.GetComponent <Transform>();

            //rect.localPosition = new Vector3( 200, 0, 0 );
            rect.localScale = new Vector3(1, 1, 1);

            var outline = infoText.AddComponent <UnityEngine.UI.Outline>();

            outline.effectColor    = Color.black;
            outline.effectDistance = new Vector2(2, 2);

            if (hasHint)
            {
                infoText.AddComponent <UITooltipText>();
            }
            infoText.AddComponent <CanvasRenderer>();
            return(infoText);
        }