Ejemplo n.º 1
0
        public override void DoWindowContents(Rect inRect)
        {
            //grab before anchor/font
            GameFont   fontBefore   = Text.Font;
            TextAnchor anchorBefore = Text.Anchor;

            //top label
            Text.Font   = GameFont.Small;
            Text.Anchor = TextAnchor.MiddleCenter;



            Text.Anchor = TextAnchor.MiddleLeft;

            int i = 0;

            foreach (FCPrisoner prisoner in prisoners)
            {
                Rect Box;
                Rect PawnIcon;
                Rect PawnName;
                Rect PawnHealth;
                Rect PawnUnrest;
                Rect PawnWorkload;
                Rect ButtonInfo;
                Rect ButtonAction;

                Box          = optionBox;
                PawnIcon     = optionPawnIcon;
                PawnName     = optionPawnName;
                PawnHealth   = optionPawnHealth;
                PawnUnrest   = optionPawnUnrest;
                PawnWorkload = optionPawnWorkload;
                ButtonInfo   = optionButtonInfo;
                ButtonAction = optionButtonAction;

                Box.y          += scroll + optionHeight * i;
                PawnIcon.y     += scroll + optionHeight * i;
                PawnName.y     += scroll + optionHeight * i;
                PawnHealth.y   += scroll + optionHeight * i;
                PawnUnrest.y   += scroll + optionHeight * i;
                PawnWorkload.y += scroll + optionHeight * i;
                ButtonInfo.y   += scroll + optionHeight * i;
                ButtonAction.y += scroll + optionHeight * i;


                //display stuff now
                Widgets.DrawMenuSection(Box);
                //on every other box
                if (i % 2 == 0)
                {
                    Widgets.DrawHighlight(Box);
                }

                //show pawn;
                Widgets.ThingIcon(PawnIcon, prisoner.prisoner);
                //Pawn Name
                Widgets.Label(PawnName, prisoner.prisoner.Name.ToString());
                //Pawn Health
                Widgets.Label(PawnHealth, "Health".Translate().CapitalizeFirst() + " " + prisoner.health);
                //Pawn Unrest
                //Widgets.Label(PawnUnrest, "Unrest".Translate().CapitalizeFirst() + " " + prisoner.unrest);



                //Pawn Workload
                string workload;
                switch (prisoner.workload)
                {
                case FCWorkLoad.Heavy:
                    workload = "FCHeavy".Translate().CapitalizeFirst();
                    break;

                case FCWorkLoad.Medium:
                    workload = "FCMedium".Translate().CapitalizeFirst();
                    break;

                case FCWorkLoad.Light:
                    workload = "FCLight".Translate().CapitalizeFirst();
                    break;

                default:
                    workload = "null";
                    break;
                }
                if (Widgets.ButtonText(PawnWorkload, "FCWorkload".Translate().CapitalizeFirst() + ": " + workload))
                {
                    List <FloatMenuOption> list = new List <FloatMenuOption>();
                    list.Add(new FloatMenuOption("FCHeavy".Translate().CapitalizeFirst() + " - " + "FCHeavyExplanation".Translate(), delegate
                    {
                        prisoner.workload = FCWorkLoad.Heavy;
                    }));
                    list.Add(new FloatMenuOption("FCMedium".Translate().CapitalizeFirst() + " - " + "FCMediumExplanation".Translate(), delegate
                    {
                        prisoner.workload = FCWorkLoad.Medium;
                    }));
                    list.Add(new FloatMenuOption("FCLight".Translate().CapitalizeFirst() + " - " + "FCLightExplanation".Translate(), delegate
                    {
                        prisoner.workload = FCWorkLoad.Light;
                    }));
                    FloatMenu menu = new FloatMenu(list);
                    Find.WindowStack.Add(menu);
                }

                //Info Button
                if (Widgets.ButtonTextSubtle(ButtonInfo, "ViewInfo".Translate()))
                {
                    Pawn pawn = new Pawn();
                    pawn = prisoner.prisoner;

                    if (prisoner.healthTracker != null)
                    {
                        prisoner.prisoner.health = prisoner.healthTracker;
                    }
                    else
                    {
                        prisoner.prisoner.health = new Pawn_HealthTracker(prisoner.prisoner);
                        prisoner.healthTracker   = new Pawn_HealthTracker(prisoner.prisoner);
                    }

                    pawn.health = prisoner.healthTracker;


                    Find.WindowStack.Add(new Dialog_InfoCard(pawn));
                }

                //Action button
                if (Widgets.ButtonTextSubtle(ButtonAction, "Actions".Translate()))
                {
                    List <FloatMenuOption> list = new List <FloatMenuOption>();

                    list.Add(new FloatMenuOption("SellPawn".Translate() + " $" + prisoner.prisoner.MarketValue + " " + "SellPawnInfo".Translate(), delegate

                    {
                        settlement.addSilverIncome(prisoner.prisoner.MarketValue);

                        //reset window
                        prisoners.Remove(prisoner);
                        WindowUpdate();
                        return;
                    }));

                    list.Add(new FloatMenuOption("ReturnToPlayer".Translate(), delegate
                    {
                        if (prisoner.healthTracker != null)
                        {
                            prisoner.prisoner.health = prisoner.healthTracker;
                        }
                        else
                        {
                            prisoner.prisoner.health = new Pawn_HealthTracker(prisoner.prisoner);
                            prisoner.healthTracker   = new Pawn_HealthTracker(prisoner.prisoner);
                        }
                        HealthUtility.DamageUntilDowned(prisoner.prisoner, false);
                        if (prisoner.prisoner.guest == null)
                        {
                            prisoner.prisoner.guest = new Pawn_GuestTracker();
                        }
                        prisoner.prisoner.guest.isPrisonerInt = true;
                        FieldInfo hostFaction = typeof(Pawn_GuestTracker).GetField("hostFactionInt", BindingFlags.NonPublic | BindingFlags.Instance);
                        hostFaction.SetValue(prisoner.prisoner.guest, Find.FactionManager.OfPlayer);

                        List <Thing> things = new List <Thing>();
                        things.Add(prisoner.prisoner);
                        Map map = faction.returnCapitalMap();
                        if (map != null)
                        {
                            DropPodUtility.DropThingsNear(DropCellFinder.TradeDropSpot(map), Find.CurrentMap, things);
                        }

                        //reset window
                        prisoners.Remove(prisoner);
                        WindowUpdate();
                        return;
                    }));


                    FloatMenu menu = new FloatMenu(list);
                    Find.WindowStack.Add(menu);
                }



                //increment i
                i++;
            }

            Text.Font   = fontBefore;
            Text.Anchor = anchorBefore;

            if (Event.current.type == EventType.ScrollWheel)
            {
                scrollWindow(Event.current.delta.y);
            }
        }