Ejemplo n.º 1
0
        private static void DrawButtons(Rect rect, ref float lineEndWidth)
        {
            if (Find.Selector.NumSelected != 1)
            {
                return;
            }
            var selected = Find.Selector.SingleSelectedThing;

            if (selected == null)
            {
                return;
            }

            lineEndWidth += ButtonSize;
            Widgets.InfoCardButton(rect.width - lineEndWidth, 0f, selected);

            if (!(selected is Pawn pawn))
            {
                return;
            }

            if (Theme.ShowFactionIcon.Value && pawn.Faction != null)
            {
                lineEndWidth += ButtonSize;
                var factionRect = new Rect(rect.width - lineEndWidth, 0f, ButtonSize, ButtonSize);
                FactionUIUtility.DrawFactionIconWithTooltip(factionRect, pawn.Faction);
                lineEndWidth += GUIPlus.SmallPadding;
            }

            if (Theme.ShowIdeoligionIcon.Value && ModLister.IdeologyInstalled && pawn.Ideo != null)
            {
                lineEndWidth += ButtonSize;
                var ideoligionRect = new Rect(rect.width - lineEndWidth, 0f, ButtonSize, ButtonSize);
                IdeoUIUtility.DoIdeoIcon(ideoligionRect, pawn.Ideo, extraAction: () => IdeoUIUtility.OpenIdeoInfo(pawn.Ideo));
                lineEndWidth += GUIPlus.SmallPadding;
            }

            if (!PlayerControlled(pawn))
            {
                return;
            }

            lineEndWidth += GUIPlus.SmallPadding;

            if (pawn.playerSettings.UsesConfigurableHostilityResponse)
            {
                lineEndWidth += ButtonSize;
                HostilityResponseModeUtility.DrawResponseButton(new Rect(rect.width - lineEndWidth, 0f, ButtonSize, ButtonSize), pawn, false);
                lineEndWidth += GUIPlus.SmallPadding;
            }

            lineEndWidth += ButtonSize;
            var careRect = new Rect(rect.width - lineEndWidth, 0f, ButtonSize, ButtonSize);

            MedicalCareUtility.MedicalCareSelectButton(careRect, pawn);
            GUIPlus.DrawTooltip(careRect, () => Lang.Get("InspectPane.MedicalCare", pawn.KindLabel, pawn.playerSettings.medCare.GetLabel()), true);
            lineEndWidth += GUIPlus.SmallPadding;

            if (!pawn.IsColonist)
            {
                return;
            }

            lineEndWidth += ButtonSize;

            var canDoctor         = !pawn.WorkTypeIsDisabled(WorkTypeDefOf.Doctor);
            var canDoctorPriority = pawn.workSettings == null || pawn.workSettings?.GetPriority(WorkTypeDefOf.Doctor) > 0;

            var selfTendRect = new Rect(rect.width - lineEndWidth, 0f, ButtonSize, ButtonSize);
            var selfTendTip  = "SelfTendTip".Translate(Faction.OfPlayer.def.pawnsPlural, 0.7f.ToStringPercent()).CapitalizeFirst();

            if (!canDoctor)
            {
                selfTendTip += "\n\n" + "MessageCannotSelfTendEver".Translate(pawn.LabelShort, pawn);
            }
            else if (!canDoctorPriority)
            {
                selfTendTip += "\n\n" + "MessageSelfTendUnsatisfied".Translate(pawn.LabelShort, pawn);
            }

            GUIPlus.SetFont(GameFont.Tiny);
            var selfTend = pawn.playerSettings.selfTend;

            selfTend = GUIPlus.DrawToggle(selfTendRect, selfTend, GUIPlus.PrepareTipSignal(() => selfTendTip), canDoctor, Textures.SelfTendOnIcon, Textures.SelfTendOffIcon);
            if (selfTend != pawn.playerSettings.selfTend)
            {
                Mod_Multiplayer.SetSelfTend(pawn, selfTend);
            }
            GUIPlus.ResetFont();
            lineEndWidth += GUIPlus.SmallPadding;
        }