private static bool Prefix(Rect cardRect, Dialog_InfoCard __instance, Thing ___thing)
        {
            Pawn p = ___thing as Pawn;

            if (p == null)
            {
                return(true);
            }
            PortraitData portraitData = PortraitLoader.Portraits.Find((PortraitData x) => x.DefinitionKey == p.kindDef.defName);

            if (portraitData != null)
            {
                if (PortraitLoader.CurPortrait != portraitData)
                {
                    PortraitLoader.CurPortrait = portraitData;
                    PortraitLoader.CurTexture  = ContentFinder <Texture2D> .Get(PortraitLoader.CurPortrait.TexturePath, false);

                    if (PortraitLoader.CurTexture == null)
                    {
                        Log.Message("Texture missing " + PortraitLoader.CurPortrait.TexturePath, false);
                        PortraitLoader.CurTexture = ContentFinder <Texture2D> .Get(BaseContent.BadTexPath, true);
                    }
                }
                Rect rect = GenUI.AtZero(cardRect);
                rect.width  = 440f;
                rect.height = 540f;
                rect.x      = cardRect.width - rect.width;
                rect.y      = cardRect.center.y - rect.height / 2f;
                GUI.DrawTexture(rect, PortraitLoader.CurTexture, (ScaleMode)1, true);
            }
            return(true);
        }
        internal static void InGameWikiPostfix(Rect inRect, Dialog_InfoCard __instance, Def ___def, Thing ___thing)
        {
            if (___def == null && ___thing == null)
            {
                return;
            }

            var def = ___def ?? ___thing.def;

            if (def == null)
            {
                return;
            }

            (ModWiki wiki, WikiPage page) = ModWiki.GlobalFindPageFromDef(def.defName);

            if (page == null)
            {
                return;
            }

            if (Widgets.ButtonText(new Rect(inRect.x + inRect.width * 0.5f + 6, inRect.y + 24, 180, 36), "Wiki.OpenWikiPage".Translate()))
            {
                __instance.Close(true);
                ModWiki.ShowPage(wiki, page);
            }
        }
Beispiel #3
0
        static void Postfix(ref StatDrawEntry __result, Thing thing)
        {
            if (!thing.PsiEquipmentTracker()?.IsPsychic ?? true)
            {
                return;
            }

            __result = new StatDrawEntry(StatCategoryDefOf.BasicsImportant, "Description".Translate(), "",
                                         thing.DescriptionFlavor + "PsiTech.PsychicWeaponDesc".Translate(), 99999, null,
                                         Dialog_InfoCard.DefsToHyperlinks(thing.def.descriptionHyperlinks));
        }
Beispiel #4
0
        static void Postfix(Dialog_InfoCard __instance, Rect inRect)
        {
            ThingDef tDef = Traverse.Create(__instance).Property("Def").GetValue() as ThingDef;

            if (tDef == null)
            {
                return;
            }
            bool result = false;

            Utils.MyInfoCardButton(inRect.xMax - 48, inRect.yMin, tDef, ref result);
        }
        public static bool Prefix(Rect cardRect, Dialog_InfoCard __instance, Thing ___thing)
        {
            Pawn pawn = ___thing as Pawn;

            rect = cardRect;
            bool result;

            if (pawn == null)
            {
                result = true;
            }
            else
            {
                if (pawn.def.GetModExtension <AnimalStatExtension>() != null)
                {
                    extension = pawn.def.GetModExtension <AnimalStatExtension>();
                    if (extension.showImageInInfoCard)
                    {
                        Type      typ  = typeof(Dialog_InfoCard);
                        FieldInfo type = typ.GetField("tab", BindingFlags.Instance | BindingFlags.NonPublic);
                        Dialog_InfoCard.InfoCardTab tab = (Dialog_InfoCard.InfoCardTab)type.GetValue(__instance);
                        if (tab == Dialog_InfoCard.InfoCardTab.Stats)
                        {
                            Texture2D texture = ContentFinder <Texture2D> .Get(extension.ImageToShowInInfoCard, false);

                            Rect position = rect.AtZero();
                            position.width  = 384f;
                            position.height = 576f;
                            position.x      = rect.width * 0.75f - position.width / 2f + 18f;
                            position.y      = rect.center.y - position.height / 2f + 120;
                            GUI.DrawTexture(position, texture, ScaleMode.ScaleToFit, true);
                        }
                    }
                }
                result = true;
            }


            return(result);
        }
        public static bool Prefix(Rect cardRect, Dialog_InfoCard __instance, Thing ___thing, Dialog_InfoCard.InfoCardTab ___tab)
        {
            Thing thing = ___thing as Thing;

            rect = cardRect;
            bool result;

            if (thing == null)
            {
                result = true;
            }
            else
            {
                if (thing.def.GetModExtension <AnimalStatExtension>() != null)
                {
                    extension = thing.def.GetModExtension <AnimalStatExtension>();
                    if (extension.showImageInInfoCard)
                    {
                        if (___tab == Dialog_InfoCard.InfoCardTab.Stats)
                        {
                            Texture2D texture = ContentFinder <Texture2D> .Get(extension.ImageToShowInInfoCard, false);

                            Rect position = rect.AtZero();
                            position.width  = 384f;
                            position.height = 576f;
                            position.x      = rect.width * 0.75f - position.width / 2f + 18f;
                            position.y      = rect.center.y - position.height / 2f + 120;
                            GUI.DrawTexture(position, texture, ScaleMode.ScaleToFit, true);
                        }
                    }
                }
                result = true;
            }


            return(result);
        }
Beispiel #7
0
 private static StatDrawEntry DescriptionEntry(Thing thing)
 {
     return(new StatDrawEntry(StatCategoryDefOf.BasicsImportant, "Description".Translate(), "", thing.DescriptionFlavor, 99999, null, Dialog_InfoCard.DefsToHyperlinks(thing.def.descriptionHyperlinks)));
 }
Beispiel #8
0
 private static StatDrawEntry DescriptionEntry(RoyalTitleDef title, Faction faction)
 {
     return(new StatDrawEntry(StatCategoryDefOf.BasicsImportant, "Description".Translate(), "", title.GetReportText(faction), 99999, null, Dialog_InfoCard.TitleDefsToHyperlinks(title.GetHyperlinks(faction))));
 }
Beispiel #9
0
 private static StatDrawEntry DescriptionEntry(Faction faction)
 {
     return(new StatDrawEntry(StatCategoryDefOf.BasicsImportant, "Description".Translate(), "", faction.GetReportText, 99999, null, Dialog_InfoCard.DefsToHyperlinks(faction.def.descriptionHyperlinks)));
 }
Beispiel #10
0
        static StatDrawEntry Postfix(StatDrawEntry entry, Thing thing)
        {
            ThingWithComps t = thing as ThingWithComps;

            if (t == null)
            {
                return(entry);
            }

            IEnumerable <IDefHyperlinkLister> listers = t.Comps().OfType <IDefHyperlinkLister>();

            if (listers.Count() == 0)
            {
                return(entry);
            }

            Traverse.Create(entry).Field <IEnumerable <Dialog_InfoCard.Hyperlink> >("hyperlinks").Value = Dialog_InfoCard.DefsToHyperlinks(listLinks(thing, listers));

            return(entry);
        }
Beispiel #11
0
        private void OpenInfoDialog()
        {
            var infoCard = new Dialog_InfoCard(_current);

            Find.WindowStack.Add(infoCard);
        }