示例#1
0
        public override void DoCell(Rect rect, Pawn pawn, PawnTable table)
        {
            Pair <string, Color> painLabel = HealthCardUtility.GetPainLabel(pawn);
            string painTip = HealthCardUtility.GetPainTip(pawn);

            painTip += "\n\n";
            painTip += "MedicalTab.XClickToY".Translate("", "MedicalTab.ShowSurgeryOptionsThat".Translate(
                                                            "MedicalTab.Reduce"
                                                            .Translate
                                                                (),
                                                            "Pain"
                                                            .Translate
                                                                ()))
                       .Trim().CapitalizeFirst();

            // draw label (centered)
            GUI.color   = painLabel.Second;
            Text.Anchor = TextAnchor.LowerCenter;
            Widgets.Label(rect, pawn.health.hediffSet.PainTotal.ToStringPercent());
            Text.Anchor = TextAnchor.UpperLeft;
            GUI.color   = Color.white;

            // tooltip
            TooltipHandler.TipRegion(rect, painTip);

            // click
            Widgets.DrawHighlightIfMouseover(rect);
            if (Widgets.ButtonInvisible(rect))
            {
                IEnumerable <RecipeDef> recipes = pawn.def.AllRecipes
                                                  .Where(
                    r => r.AvailableNow &&
                    (r.AddsHediffThatReducesPain() ||
                     (Settings.SuggestDrugs && r.AdministersDrugThatReducesPain())) &&
                    NotMissingVitalIngredient(pawn, r)
                    );
                var options = new List <FloatMenuOption>();
                foreach (RecipeDef recipe in recipes)
                {
                    options.Add(GenerateSurgeryOption(pawn, pawn, recipe,
                                                      recipe.PotentiallyMissingIngredients(null, pawn.Map)));
                }

                if (options.Count == 0)
                {
                    options.Add(new FloatMenuOption("None".Translate(), null));
                }

                Find.WindowStack.Add(new FloatMenu(options));
            }
        }
示例#2
0
        private void DoPain(Rect rect, Pawn pawn)
        {
            var painLabel = HealthCardUtility.GetPainLabel(pawn);
            var painTip   = HealthCardUtility.GetPainTip(pawn);

            if (Mouse.IsOver(rect))
            {
                Widgets.DrawHighlight(rect);
            }
            GUI.color   = painLabel.Second;
            Text.Anchor = TextAnchor.MiddleCenter;
            Widgets.Label(rect, painLabel.First);
            GUI.color   = Color.white;
            Text.Anchor = TextAnchor.UpperLeft;
            TooltipHandler.TipRegion(rect, painTip);
        }