Ejemplo n.º 1
0
        public static void DoInspectPaneButtons(Rect rect, ref float lineEndWidth, MainTabWindow_Inspect __instance)
        {
            if (Find.Selector.NumSelected == 1)
            {
                Thing singleSelectedThing = Find.Selector.SingleSelectedThing;
                if (singleSelectedThing != null)
                {
                    Widgets.InfoCardButton(rect.width - 48f, 0f, Find.Selector.SingleSelectedThing);
                    lineEndWidth += 24f;
                    Pawn pawn = singleSelectedThing as Pawn;
                    if (pawn != null && pawn.playerSettings != null && pawn.playerSettings.UsesConfigurableHostilityResponse)
                    {
                        HostilityResponseModeUtility.DrawResponseButton(new Vector2(rect.width - 72f, 0f), pawn);
                        lineEndWidth += 24f;
                    }

                    if (pawn != null)
                    {
                        Need_Soul soul;
                        if ((soul = pawn.needs.TryGetNeed <Need_Soul>()) != null)
                        {
                            float num = rect.height - 48;
                            Widgets.ListSeparator(ref num, rect.width, "PawnAlignment".Translate());
                            ColorInt  colorInt  = new ColorInt(65, 25, 25);
                            Texture2D soultex   = SolidColorMaterials.NewSolidColorTexture(colorInt.ToColor);
                            ColorInt  colorInt2 = new ColorInt(10, 10, 10);
                            Texture2D bgtex     = SolidColorMaterials.NewSolidColorTexture(colorInt2.ToColor);
                            WidgetRow row       = new WidgetRow(0f, rect.height - 24f);
                            row.FillableBar(93f, 16f, soul.CurLevelPercentage, soul.CurCategory.ToString(), soultex, bgtex);
                            String desc = "PawnAlignmentButtonDescription".Translate();
                            if (row.ButtonIcon(HarmonyPatches.patronIcon, desc))
                            {
                                Find.WindowStack.Add(new MainTabWindow_Alignment());
                            }
                            string culturalTolerance = "Cultural Tolerance: " + soul.CulturalTolerance.ToString();
                            Widgets.Label(new Rect(rect.width / 2, rect.height - 24, rect.width / 2, 16f), culturalTolerance);
                        }
                    }
                }
            }
        }
Ejemplo n.º 2
0
        protected override void DrawPawnRow(Rect rect, Pawn p)
        {
            // available space for row
            Rect rowRect = new Rect(rect.x + 175f, rect.y, rect.width - 175f, rect.height);

            // response button rect
            Vector2 responsePos = new Vector2(rowRect.xMin, rowRect.yMin + (rowRect.height - 24f) / 2f);

            // offset rest of row for that button, so we don't have to mess with all the other rect calculations
            rowRect.xMin += 24f + _margin;

            // label + buttons for outfit
            Rect outfitRect = new Rect(rowRect.xMin,
                                       rowRect.yMin,
                                       rowRect.width * (1f / 3f) + (_margin + _buttonSize) / 2f,
                                       rowRect.height);

            Rect labelOutfitRect = new Rect(outfitRect.xMin,
                                            outfitRect.yMin,
                                            outfitRect.width - _margin * 3 - _buttonSize * 2,
                                            outfitRect.height)
                                   .ContractedBy(_margin / 2f);
            Rect editOutfitRect = new Rect(labelOutfitRect.xMax + _margin,
                                           outfitRect.yMin + ((outfitRect.height - _buttonSize) / 2),
                                           _buttonSize,
                                           _buttonSize);
            Rect forcedOutfitRect = new Rect(labelOutfitRect.xMax + _buttonSize + _margin * 2,
                                             outfitRect.yMin + ((outfitRect.height - _buttonSize) / 2),
                                             _buttonSize,
                                             _buttonSize);

            // label + button for loadout
            Rect loadoutRect = new Rect(outfitRect.xMax,
                                        rowRect.yMin,
                                        rowRect.width * (1f / 3f) - (_margin + _buttonSize) / 2f,
                                        rowRect.height);
            Rect labelLoadoutRect = new Rect(loadoutRect.xMin,
                                             loadoutRect.yMin,
                                             loadoutRect.width - _margin * 2 - _buttonSize,
                                             loadoutRect.height)
                                    .ContractedBy(_margin / 2f);
            Rect editLoadoutRect = new Rect(labelLoadoutRect.xMax + _margin,
                                            loadoutRect.yMin + ((loadoutRect.height - _buttonSize) / 2),
                                            _buttonSize,
                                            _buttonSize);

            // fight or flight button
            HostilityResponseModeUtility.DrawResponseButton(responsePos, p);

            // weight + bulk indicators
            Rect weightRect = new Rect(loadoutRect.xMax, rowRect.yMin, rowRect.width * (1f / 6f) - _margin, rowRect.height).ContractedBy(_margin / 2f);
            Rect bulkRect   = new Rect(weightRect.xMax, rowRect.yMin, rowRect.width * (1f / 6f) - _margin, rowRect.height).ContractedBy(_margin / 2f);

            // OUTFITS
            // main button
            if (Widgets.TextButton(labelOutfitRect, p.outfits.CurrentOutfit.label, true, false))
            {
                List <FloatMenuOption> options = new List <FloatMenuOption>();
                foreach (Outfit outfit in Find.Map.outfitDatabase.AllOutfits)
                {
                    // need to create a local copy for delegate
                    Outfit localOutfit = outfit;
                    options.Add(new FloatMenuOption(localOutfit.label, delegate
                    {
                        p.outfits.CurrentOutfit = localOutfit;
                    }, MenuOptionPriority.Medium, null, null));
                }
                Find.WindowStack.Add(new FloatMenu(options, false));
            }

            // edit button
            TooltipHandler.TipRegion(editOutfitRect, "CR.EditX".Translate("CR.outfit".Translate() + " " + p.outfits.CurrentOutfit.label));
            if (Widgets.ImageButton(editOutfitRect, _iconEdit))
            {
                Find.WindowStack.Add(new Dialog_ManageOutfits(p.outfits.CurrentOutfit));
            }

            // clear forced button
            if (p.outfits.forcedHandler.SomethingIsForced)
            {
                TooltipHandler.TipRegion(forcedOutfitRect, "ClearForcedApparel".Translate());
                if (Widgets.ImageButton(forcedOutfitRect, _iconClearForced))
                {
                    p.outfits.forcedHandler.Reset();
                }
                TooltipHandler.TipRegion(forcedOutfitRect, new TipSignal(delegate
                {
                    string text = "ForcedApparel".Translate() + ":\n";
                    foreach (Apparel current2 in p.outfits.forcedHandler.ForcedApparel)
                    {
                        text = text + "\n   " + current2.LabelCap;
                    }
                    return(text);
                }, p.GetHashCode() * 612));
            }

            // LOADOUTS
            // main button
            if (Widgets.TextButton(labelLoadoutRect, p.GetLoadout().LabelCap, true, false))
            {
                List <FloatMenuOption> options = new List <FloatMenuOption>();
                foreach (Loadout loadout in LoadoutManager.Loadouts)
                {
                    // need to create a local copy for delegate
                    Loadout localLoadout = loadout;
                    options.Add(new FloatMenuOption(localLoadout.LabelCap, delegate
                    {
                        p.SetLoadout(localLoadout);
                    }, MenuOptionPriority.Medium, null, null));
                }
                Find.WindowStack.Add(new FloatMenu(options, false));
            }

            // edit button
            TooltipHandler.TipRegion(editLoadoutRect, "CR.EditX".Translate("CR.loadout".Translate() + " " + p.GetLoadout().LabelCap));
            if (Widgets.ImageButton(editLoadoutRect, _iconEdit))
            {
                Find.WindowStack.Add(new Dialog_ManageLoadouts(p.GetLoadout()));
            }

            // STATUS BARS
            // fetch the comp
            CompInventory comp = p.TryGetComp <CompInventory>();

            if (comp != null)
            {
                Utility_Loadouts.DrawBar(bulkRect, comp.currentBulk, comp.capacityBulk, "", p.GetBulkTip());
                Utility_Loadouts.DrawBar(weightRect, comp.currentWeight, comp.capacityWeight, "", p.GetWeightTip());
            }
        }
Ejemplo n.º 3
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) || !PlayerControlled(pawn))
            {
                return;
            }

            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, new TipSignal(() => Lang.Get("InspectPane.MedicalCare", pawn.KindLabel, pawn.playerSettings.medCare.GetLabel()), GUIPlus.TooltipId), 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, new TipSignal(() => selfTendTip, GUIPlus.TooltipId), canDoctor, Textures.SelfTendOnIcon, Textures.SelfTendOffIcon);
            if (selfTend != pawn.playerSettings.selfTend)
            {
                Mod_Multiplayer.SetSelfTend(pawn, selfTend);
            }
            GUIPlus.ResetFont();

            lineEndWidth += GUIPlus.SmallPadding;
        }
Ejemplo n.º 4
0
        protected override void DrawPawnRow(Rect rect, Pawn p)
        {
            // available space for row
            Rect rowRect = new Rect(rect.x + 165f, rect.y, rect.width - 165f, rect.height);

            // response button rect
            Vector2 responsePos = new Vector2(rowRect.xMin, rowRect.yMin + (rowRect.height - 24f) / 2f);

            // offset rest of row for that button, so we don't have to mess with all the other rect calculations
            rowRect.xMin += 24f + _margin;

            // label + buttons for outfit
            Rect outfitRect = new Rect(rowRect.xMin,
                                       rowRect.yMin,
                                       rowRect.width * (1f / 4f) + (_margin + _buttonSize) / 2f,
                                       rowRect.height);

            Rect labelOutfitRect = new Rect(outfitRect.xMin,
                                            outfitRect.yMin,
                                            outfitRect.width - _margin * 3 - _buttonSize * 2,
                                            outfitRect.height)
                                   .ContractedBy(_margin / 2f);
            Rect editOutfitRect = new Rect(labelOutfitRect.xMax + _margin,
                                           outfitRect.yMin + ((outfitRect.height - _buttonSize) / 2),
                                           _buttonSize,
                                           _buttonSize);
            Rect forcedOutfitRect = new Rect(labelOutfitRect.xMax + _buttonSize + _margin * 2,
                                             outfitRect.yMin + ((outfitRect.height - _buttonSize) / 2),
                                             _buttonSize,
                                             _buttonSize);

            // drucg policy
            Rect drugRect = new Rect(outfitRect.xMax,
                                     rowRect.yMin,
                                     rowRect.width * (1f / 4f) - (_margin + _buttonSize) / 2f,
                                     rowRect.height);
            Rect labelDrugRect = new Rect(drugRect.xMin,
                                          drugRect.yMin,
                                          drugRect.width - _margin * 2 - _buttonSize,
                                          drugRect.height)
                                 .ContractedBy(_margin / 2f);
            Rect editDrugRect = new Rect(labelDrugRect.xMax + _margin,
                                         drugRect.yMin + ((drugRect.height - _buttonSize) / 2),
                                         _buttonSize,
                                         _buttonSize);

            // label + button for loadout
            Rect loadoutRect = new Rect(drugRect.xMax,
                                        rowRect.yMin,
                                        rowRect.width * (1f / 4f) - (_margin + _buttonSize) / 2f,
                                        rowRect.height);
            Rect labelLoadoutRect = new Rect(loadoutRect.xMin,
                                             loadoutRect.yMin,
                                             loadoutRect.width - _margin * 2 - _buttonSize,
                                             loadoutRect.height)
                                    .ContractedBy(_margin / 2f);
            Rect editLoadoutRect = new Rect(labelLoadoutRect.xMax + _margin,
                                            loadoutRect.yMin + ((loadoutRect.height - _buttonSize) / 2),
                                            _buttonSize,
                                            _buttonSize);

            // fight or flight button
            HostilityResponseModeUtility.DrawResponseButton(responsePos, p);

            // weight + bulk indicators
            Rect weightRect = new Rect(loadoutRect.xMax, rowRect.yMin, rowRect.width * (1f / 8f) - _margin, rowRect.height).ContractedBy(_margin / 2f);
            Rect bulkRect   = new Rect(weightRect.xMax + _margin, rowRect.yMin, rowRect.width * (1f / 8f) - _margin, rowRect.height).ContractedBy(_margin / 2f);

            // OUTFITS
            // main button
            if (Widgets.ButtonText(labelOutfitRect, p.outfits.CurrentOutfit.label, true, false))
            {
                List <FloatMenuOption> options = new List <FloatMenuOption>();
                foreach (Outfit current in Current.Game.outfitDatabase.AllOutfits)
                {
                    // need to create a local copy for delegate
                    Outfit localOut = current;
                    options.Add(new FloatMenuOption(localOut.label, delegate
                    {
                        p.outfits.CurrentOutfit = localOut;
                    }, MenuOptionPriority.Default, null, null));
                }
                Find.WindowStack.Add(new FloatMenu(options, optionalTitle, false));
            }

            // edit button
            TooltipHandler.TipRegion(editOutfitRect, "CE_EditX".Translate("CE_outfit".Translate() + " " + p.outfits.CurrentOutfit.label));
            if (Widgets.ButtonImage(editOutfitRect, _iconEdit))
            {
                Text.Font = GameFont.Small;
                Find.WindowStack.Add(new Dialog_ManageOutfits(p.outfits.CurrentOutfit));
            }

            // clear forced button
            if (p.outfits.forcedHandler.SomethingIsForced)
            {
                TooltipHandler.TipRegion(forcedOutfitRect, "ClearForcedApparel".Translate());
                if (Widgets.ButtonImage(forcedOutfitRect, _iconClearForced))
                {
                    p.outfits.forcedHandler.Reset();
                }
                TooltipHandler.TipRegion(forcedOutfitRect, new TipSignal(delegate
                {
                    string text = "ForcedApparel".Translate() + ":\n";
                    foreach (Apparel current2 in p.outfits.forcedHandler.ForcedApparel)
                    {
                        text = text + "\n   " + current2.LabelCap;
                    }
                    return(text);
                }, p.GetHashCode() * 612));
            }

            // DRUG POLICY
            // main button
            string textDrug = p.drugs.CurrentPolicy.label;

            if (p.story != null && p.story.traits != null)
            {
                Trait trait = p.story.traits.GetTrait(TraitDefOf.DrugDesire);
                if (trait != null)
                {
                    textDrug = textDrug + " (" + trait.Label + ")";
                }
            }
            if (Widgets.ButtonText(labelDrugRect, textDrug, true, false, true))
            {
                List <FloatMenuOption> list = new List <FloatMenuOption>();
                foreach (DrugPolicy current in Current.Game.drugPolicyDatabase.AllPolicies)
                {
                    DrugPolicy localAssignedDrugs = current;
                    list.Add(new FloatMenuOption(current.label, delegate
                    {
                        p.drugs.CurrentPolicy = localAssignedDrugs;
                    }, MenuOptionPriority.Default, null, null, 0f, null));
                }
                Find.WindowStack.Add(new FloatMenu(list));
                PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.DrugPolicies, KnowledgeAmount.Total);
            }


            // edit button
            TooltipHandler.TipRegion(editDrugRect, "CE_EditX".Translate("CE_drugs".Translate() + " " + p.drugs.CurrentPolicy.label));
            if (Widgets.ButtonImage(editDrugRect, _iconEdit))
            {
                Text.Font = GameFont.Small;
                Find.WindowStack.Add(new Dialog_ManageDrugPolicies(p.drugs.CurrentPolicy));
                PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.DrugPolicies, KnowledgeAmount.Total);
            }

            // LOADOUTS
            // main button
            if (Widgets.ButtonText(labelLoadoutRect, p.GetLoadout().LabelCap, true, false))
            {
                List <FloatMenuOption> options = new List <FloatMenuOption>();
                foreach (Loadout loadout in LoadoutManager.Loadouts)
                {
                    // need to create a local copy for delegate
                    Loadout localLoadout = loadout;
                    options.Add(new FloatMenuOption(localLoadout.LabelCap, delegate
                    {
                        p.SetLoadout(localLoadout);
                    }, MenuOptionPriority.Default, null, null));
                }
                Find.WindowStack.Add(new FloatMenu(options, optionalTitle, false));
            }

            // edit button
            TooltipHandler.TipRegion(editLoadoutRect, "CE_EditX".Translate("CE_loadout".Translate() + " " + p.GetLoadout().LabelCap));
            if (Widgets.ButtonImage(editLoadoutRect, _iconEdit))
            {
                Find.WindowStack.Add(new Dialog_ManageLoadouts(p.GetLoadout()));
            }

            // STATUS BARS
            // fetch the comp
            CompInventory comp = p.TryGetComp <CompInventory>();

            if (comp != null)
            {
                Utility_Loadouts.DrawBar(bulkRect, comp.currentBulk, comp.capacityBulk, "", p.GetBulkTip());
                Utility_Loadouts.DrawBar(weightRect, comp.currentWeight, comp.capacityWeight, "", p.GetWeightTip());
            }
        }