public static void ToggleWindow(Pawn pawn, HediffComp_Menstruation comp)
        {
            Dialog_WombStatus window = (Dialog_WombStatus)Find.WindowStack.Windows.FirstOrDefault(x => x.GetType().Equals(typeof(Dialog_WombStatus)));

            if (window != null)
            {
                List <Pawn> pawns = Find.Selector.SelectedPawns.FindAll(x => x.ShouldShowWombGizmo());
                if (Input.GetKey(VariousDefOf.OpenStatusWindowKey.MainKey) && !pawns.NullOrEmpty() && pawns.Count > 1)
                {
                    int index = pawns.IndexOf(window.pawn);
                    SoundDefOf.TabOpen.PlayOneShotOnCamera();
                    Pawn newpawn = pawns[(index + 1) % pawns.Count];
                    window.ChangePawn(newpawn, newpawn.GetMenstruationComp());
                }
                else if (window.pawn != pawn)
                {
                    SoundDefOf.TabOpen.PlayOneShotOnCamera();
                    window.ChangePawn(pawn, comp);
                }
                else
                {
                    Find.WindowStack.TryRemove(typeof(Dialog_WombStatus), true);
                }
            }
            else
            {
                SoundDefOf.InfoCard_Open.PlayOneShotOnCamera();
                Find.WindowStack.Add(new Dialog_WombStatus(pawn, comp));
            }
        }
 public static void Prefix(Rect rect, Pawn pawn, IEnumerable <Hediff> diffs, ref float curY)
 {
     if (Configurations.EnableButtonInHT && pawn.ShowStatus())
     {
         HediffComp_Menstruation comp = diffs.First().GetMenstruationComp();
         if (comp != null)
         {
             Rect buttonrect = new Rect((rect.xMax) / 2 - 5f, curY + 2f, buttonWidth, buttonHeight);
             if (Widgets.ButtonText(buttonrect, Translations.Button_HealthTab))
             {
                 Dialog_WombStatus.ToggleWindow(pawn, comp);
             }
         }
     }
 }
        public static void ToggleWindow(Pawn pawn, HediffComp_Menstruation comp)
        {
            Dialog_WombStatus window = (Dialog_WombStatus)Find.WindowStack.Windows.FirstOrDefault(x => x.GetType().Equals(typeof(Dialog_WombStatus)));

            if (window != null)
            {
                if (window.pawn != pawn)
                {
                    SoundDefOf.TabOpen.PlayOneShotOnCamera();
                    window.ChangePawn(pawn, comp);
                }
                else
                {
                    Find.WindowStack.TryRemove(typeof(Dialog_WombStatus), true);
                }
            }
            else
            {
                SoundDefOf.InfoCard_Open.PlayOneShotOnCamera();
                Find.WindowStack.Add(new Dialog_WombStatus(pawn, comp));
            }
        }
        private static Gizmo CreateGizmo_WombStatus(Pawn pawn, HediffComp_Menstruation comp)
        {
            Texture2D icon, icon_overay;
            string    description = "";

            if (Configurations.Debug)
            {
                description += comp.curStage + ": " + comp.curStageHrs + "\n" + "fertcums: " + comp.TotalFertCum + "\n" + "ovarypower: " + comp.ovarypower + "\n" + "eggs: " + comp.GetNumofEggs + "\n";
            }
            else
            {
                description += comp.GetCurStageLabel + "\n";
            }
            if (pawn.IsPregnant())
            {
                Hediff hediff = PregnancyHelper.GetPregnancy(pawn);
                if (Utility.ShowFetusImage((Hediff_BasePregnancy)hediff))
                {
                    icon = comp.GetPregnancyIcon(hediff);
                    if (hediff is Hediff_BasePregnancy)
                    {
                        Hediff_BasePregnancy h = (Hediff_BasePregnancy)hediff;
                        if (h.GestationProgress < 0.2f)
                        {
                            icon_overay = comp.GetCumIcon();
                        }
                        else
                        {
                            icon_overay = ContentFinder <Texture2D> .Get(("Womb/Empty"), true);
                        }
                    }
                    else
                    {
                        icon_overay = ContentFinder <Texture2D> .Get(("Womb/Empty"), true);
                    }
                }
                else
                {
                    icon        = comp.GetWombIcon();
                    icon_overay = comp.GetCumIcon();
                }
            }
            else
            {
                Hediff hediff = pawn.health.hediffSet.GetHediffs <Hediff_InsectEgg>().FirstOrDefault();
                if (hediff != null)
                {
                    icon = ContentFinder <Texture2D> .Get(("Womb/Womb_Egged"), true);

                    icon_overay = ContentFinder <Texture2D> .Get(("Womb/Empty"), true);
                }
                else
                {
                    icon        = comp.GetWombIcon();
                    icon_overay = comp.GetCumIcon();
                }
            }
            foreach (string s in comp.GetCumsInfo)
            {
                description += s + "\n";
            }

            Color c = comp.GetCumMixtureColor;

            Gizmo gizmo = new Gizmo_Womb
            {
                defaultLabel = pawn.LabelShort,
                defaultDesc  = description,
                icon         = icon,
                icon_overay  = icon_overay,
                shrinkable   = Configurations.AllowShrinkIcon,
                cumcolor     = c,
                comp         = comp,
                order        = 100,
                hotKey       = VariousDefOf.OpenStatusWindowKey,
                action       = delegate
                {
                    Dialog_WombStatus.ToggleWindow(pawn, comp);
                }
            };

            return(gizmo);
        }