protected void ShowChildDialogForGroup(CustomParentChildGroup group, CustomParentChildPawn selected, Action <CustomParentChildPawn> action)
        {
            CustomParentChildPawn           selectedPawn = selected;
            HashSet <CustomParentChildPawn> disabled     = new HashSet <CustomParentChildPawn>();

            if (group != null)
            {
                disabled.AddRange(group.Parents);
                disabled.AddRange(group.Children);
            }
            rowGroups.Clear();
            rowGroups.Add(new WidgetTable <CustomParentChildPawn> .RowGroup("EdB.PC.AddParentChild.Header.SelectColonist".Translate(), PrepareCarefully.Instance.RelationshipManager.ColonyPawns));
            rowGroups.Add(new WidgetTable <CustomParentChildPawn> .RowGroup("EdB.PC.AddParentChild.Header.SelectHidden".Translate(), PrepareCarefully.Instance.RelationshipManager.HiddenPawns));
            WidgetTable <CustomParentChildPawn> .RowGroup newPawnGroup = new WidgetTable <CustomParentChildPawn> .RowGroup(null, newPawns);

            rowGroups.Add(newPawnGroup);
            DialogSelectParentChildPawn pawnDialog = new DialogSelectParentChildPawn()
            {
                HeaderLabel       = "EdB.PC.AddParentChild.Header.AddChild".Translate(),
                SelectAction      = (CustomParentChildPawn pawn) => { selectedPawn = pawn; },
                RowGroups         = rowGroups,
                DisabledPawns     = disabled,
                ConfirmValidation = () => {
                    if (selectedPawn == null)
                    {
                        return("EdB.PC.AddParentChild.Error.ChildRequired");
                    }
                    else
                    {
                        return(null);
                    }
                },
                CloseAction = () => {
                    // If the user selected a new pawn, replace the pawn in the new pawn list with another one.
                    int index = newPawnGroup.Rows.FirstIndexOf((CustomParentChildPawn p) => {
                        return(p == selectedPawn);
                    });
                    if (index > -1 && index < newPawns.Count)
                    {
                        selectedPawn = ReplaceNewHiddenCharacter(index);
                    }
                    action(selectedPawn);
                }
            };

            Find.WindowStack.Add(pawnDialog);
        }
Exemple #2
0
        protected void DoSort(WidgetTable <EquipmentRecord> .Column column, int direction)
        {
            var view = equipmentViews[selectedType];

            if (view == null)
            {
                return;
            }
            if (column != null)
            {
                if (column.Name == ColumnNameName)
                {
                    SortByName(view, direction);
                    SoundDefOf.Tick_Tiny.PlayOneShotOnCamera();
                }
                else if (column.Name == ColumnNameCost)
                {
                    SortByCost(view, direction);
                    SoundDefOf.Tick_Tiny.PlayOneShotOnCamera();
                }
            }
        }
        protected void Resize()
        {
            float headerSize = 0;

            headerSize = HeaderHeight;
            if (HeaderLabel != null)
            {
                headerSize = HeaderHeight;
            }

            HeaderHeight         = 32;
            RowGroupHeaderHeight = 36;
            FooterHeight         = 40f;
            WindowPadding        = 18;
            ContentMargin        = new Vector2(10f, 18f);
            WindowSize           = new Vector2(440f, 584f);
            ButtonSize           = new Vector2(140f, 40f);

            ContentSize = new Vector2(WindowSize.x - WindowPadding * 2 - ContentMargin.x * 2,
                                      WindowSize.y - WindowPadding * 2 - ContentMargin.y * 2 - FooterHeight - headerSize);

            ContentRect = new Rect(ContentMargin.x, ContentMargin.y + headerSize, ContentSize.x, ContentSize.y);

            ScrollRect = new Rect(0, 0, ContentRect.width, ContentRect.height);

            HeaderRect = new Rect(ContentMargin.x, ContentMargin.y, ContentSize.x, HeaderHeight);

            FooterRect = new Rect(ContentMargin.x, ContentRect.y + ContentSize.y + 20,
                                  ContentSize.x, FooterHeight);

            GenderSize = new Vector2(48, 48);

            SingleButtonRect = new Rect(ContentSize.x / 2 - ButtonSize.x / 2,
                                        (FooterHeight / 2) - (ButtonSize.y / 2),
                                        ButtonSize.x, ButtonSize.y);

            CancelButtonRect = new Rect(0,
                                        (FooterHeight / 2) - (ButtonSize.y / 2),
                                        ButtonSize.x, ButtonSize.y);
            ConfirmButtonRect = new Rect(ContentSize.x - ButtonSize.x,
                                         (FooterHeight / 2) - (ButtonSize.y / 2),
                                         ButtonSize.x, ButtonSize.y);

            Vector2 portraitSize      = new Vector2(70, 70);
            float   portraitOverflow  = 8;
            float   nameOffset        = 2;
            float   descriptionOffset = -2;
            float   radioWidth        = 36;
            Vector2 nameSize          = new Vector2(ContentRect.width - portraitSize.x - radioWidth, portraitSize.y * 0.5f);

            table                      = new WidgetTable <CustomPawn>();
            table.Rect                 = new Rect(Vector2.zero, ContentRect.size);
            table.RowHeight            = portraitSize.y;
            table.RowGroupHeaderHeight = RowGroupHeaderHeight;
            table.RowColor             = new Color(28f / 255f, 32f / 255f, 36f / 255f);
            table.AlternateRowColor    = new Color(0, 0, 0, 0);
            table.SelectedRowColor     = new Color(0, 0, 0, 0);
            table.SupportSelection     = true;
            table.SelectedAction       = (CustomPawn pawn) => {
                if (DisabledPawns == null || !DisabledPawns.Contains(pawn))
                {
                    SoundDefOf.Tick_Tiny.PlayOneShotOnCamera();
                    Select(pawn);
                }
            };
            table.AddColumn(new WidgetTable <CustomPawn> .Column()
            {
                Name       = "Portrait",
                DrawAction = (CustomPawn pawn, Rect rect, WidgetTable <CustomPawn> .Metadata metadata) => {
                    GUI.color = Color.white;
                    if (!pawn.Hidden)
                    {
                        var texture = pawn.GetPortrait(new Vector2(portraitSize.x, portraitSize.y + portraitOverflow * 2));
                        GUI.DrawTexture(new Rect(rect.position.x, rect.position.y - portraitOverflow, portraitSize.x, portraitSize.y + portraitOverflow * 2), texture as Texture);
                    }
                    else
                    {
                        GUI.color       = Style.ColorButton;
                        Rect genderRect = new Rect(rect.MiddleX() - GenderSize.HalfX(), rect.MiddleY() - GenderSize.HalfY(), GenderSize.x, GenderSize.y);
                        if (pawn.Gender == Gender.Female)
                        {
                            GUI.DrawTexture(genderRect, Textures.TextureGenderFemaleLarge);
                        }
                        else if (pawn.Gender == Gender.Male)
                        {
                            GUI.DrawTexture(genderRect, Textures.TextureGenderMaleLarge);
                        }
                        else
                        {
                            GUI.DrawTexture(genderRect, Textures.TextureGenderlessLarge);
                        }
                        GUI.color = Color.white;
                    }
                },
                Width = portraitSize.x
            });
            table.AddColumn(new WidgetTable <CustomPawn> .Column()
            {
                Name  = "Description",
                Width = nameSize.x,
                AdjustForScrollbars = true,
                DrawAction          = (CustomPawn pawn, Rect rect, WidgetTable <CustomPawn> .Metadata metadata) => {
                    Text.Anchor = TextAnchor.LowerLeft;
                    Text.Font   = GameFont.Small;
                    Widgets.Label(new Rect(rect.x, rect.y + nameOffset, rect.width, nameSize.y), pawn.FullName);
                    Text.Anchor = TextAnchor.UpperLeft;
                    string description;
                    if (!pawn.Hidden)
                    {
                        string age = pawn.BiologicalAge != pawn.ChronologicalAge ?
                                     "EdB.PC.Pawn.AgeWithChronological".Translate(new object[] { pawn.BiologicalAge, pawn.ChronologicalAge }) :
                                     "EdB.PC.Pawn.AgeWithoutChronological".Translate(new object[] { pawn.BiologicalAge });
                        description = pawn.Gender != Gender.None ?
                                      "EdB.PC.Pawn.PawnDescriptionWithGender".Translate(new object[] { pawn.ProfessionLabelShort, pawn.Gender.GetLabel(), age }) :
                                      "EdB.PC.Pawn.PawnDescriptionNoGender".Translate(new object[] { pawn.ProfessionLabelShort, age });
                    }
                    else
                    {
                        string profession = "EdB.PC.Pawn.HiddenPawnProfession".Translate();
                        description       = pawn.Gender != Gender.None ?
                                            "EdB.PC.Pawn.HiddenPawnDescriptionWithGender".Translate(new object[] { profession, pawn.Gender.GetLabel() }) :
                                            "EdB.PC.Pawn.HiddenPawnDescriptionNoGender".Translate(new object[] { profession });
                    }
                    Text.Font = GameFont.Tiny;
                    Widgets.Label(new Rect(rect.x, rect.y + nameSize.y + descriptionOffset, rect.width, nameSize.y), description);
                    Text.Font   = GameFont.Small;
                    Text.Anchor = TextAnchor.UpperLeft;
                }
            });
            table.AddColumn(new WidgetTable <CustomPawn> .Column()
            {
                Name       = "RadioButton",
                Width      = radioWidth,
                DrawAction = (CustomPawn pawn, Rect rect, WidgetTable <CustomPawn> .Metadata metadata) => {
                    if (DisabledPawns != null && DisabledPawns.Contains(pawn))
                    {
                        GUI.color = Style.ColorControlDisabled;
                        GUI.color = new Color(1, 1, 1, 0.28f);
                        GUI.DrawTexture(new Rect(rect.x, rect.MiddleY() - 12, 24, 24), Textures.TextureRadioButtonOff);
                        GUI.color = Color.white;
                    }
                    else
                    {
                        if (Widgets.RadioButton(new Vector2(rect.x, rect.MiddleY() - 12), this.SelectedPawn == pawn))
                        {
                            Select(pawn);
                        }
                    }
                }
            });
            resizeDirtyFlag = false;
        }
Exemple #4
0
        public override void Resize(Rect rect)
        {
            base.Resize(rect);

            Vector2 padding = new Vector2(12, 12);

            RectDropdownTypes     = new Rect(padding.x, padding.y, 140, 28);
            RectDropdownMaterials = new Rect(RectDropdownTypes.xMax + 8, RectDropdownTypes.yMin, 160, 28);

            Vector2 sizeInfoButton = new Vector2(24, 24);
            Vector2 sizeAddButton  = new Vector2(160, 34);

            RectAddButton = new Rect(PanelRect.HalfWidth() - sizeAddButton.HalfX(),
                                     PanelRect.height - padding.y - sizeAddButton.y, sizeAddButton.x, sizeAddButton.y);

            Vector2 listSize = new Vector2();

            listSize.x = rect.width - padding.x * 2;
            listSize.y = rect.height - RectDropdownTypes.yMax - (padding.y * 3) - RectAddButton.height;
            float listHeaderHeight = 20;
            float listBodyHeight   = listSize.y - listHeaderHeight;

            Rect rectTable = new Rect(padding.x, padding.y + RectDropdownTypes.yMax, listSize.x, listSize.y);

            RectListHeader = new Rect(padding.x, RectDropdownTypes.yMax + 4, listSize.x, listHeaderHeight);
            RectListBody   = new Rect(padding.x, RectListHeader.yMax, listSize.x, listBodyHeight);

            RectColumnHeaderName = new Rect(RectListHeader.x + 64, RectListHeader.y, 240, RectListHeader.height);
            RectColumnHeaderCost = new Rect(RectListHeader.xMax - 100, RectListHeader.y, 100, RectListHeader.height);

            RectScrollFrame = RectListBody;
            RectScrollView  = new Rect(0, 0, RectScrollFrame.width, RectScrollFrame.height);

            RectRow  = new Rect(0, 0, RectScrollView.width, 42);
            RectItem = new Rect(10, 2, 38, 38);

            Vector2 nameOffset      = new Vector2(10, 0);
            float   columnWidthInfo = 36;
            float   columnWidthIcon = 42;
            float   columnWidthCost = 100;
            float   columnWidthName = RectRow.width - columnWidthInfo - columnWidthIcon - columnWidthCost - 10;

            if (providerEquipment == null)
            {
                providerEquipment = new ProviderEquipmentTypes();
            }
            if (!providerEquipment.DatabaseReady)
            {
                return;
            }
            foreach (var type in providerEquipment.Types)
            {
                if (!equipmentViews.ContainsKey(type))
                {
                    WidgetTable <EquipmentRecord> table = new WidgetTable <EquipmentRecord>();
                    table.Rect              = rectTable;
                    table.BackgroundColor   = Style.ColorPanelBackgroundDeep;
                    table.RowColor          = Style.ColorTableRow1;
                    table.AlternateRowColor = Style.ColorTableRow2;
                    table.SelectedRowColor  = Style.ColorTableRowSelected;
                    table.SupportSelection  = true;
                    table.RowHeight         = 42;
                    table.ShowHeader        = true;
                    table.SortAction        = DoSort;
                    table.SelectedAction    = (EquipmentRecord entry) => {
                        SoundDefOf.Tick_Tiny.PlayOneShotOnCamera();
                    };
                    table.DoubleClickAction = (EquipmentRecord entry) => {
                        SoundDefOf.Tick_High.PlayOneShotOnCamera();
                        EquipmentAdded(entry);
                    };
                    table.AddColumn(new WidgetTable <EquipmentRecord> .Column()
                    {
                        Width      = columnWidthInfo,
                        Name       = ColumnNameInfo,
                        DrawAction = (EquipmentRecord entry, Rect columnRect, WidgetTable <EquipmentRecord> .Metadata metadata) => {
                            Rect infoRect = new Rect(columnRect.MiddleX() - sizeInfoButton.HalfX(), columnRect.MiddleY() - sizeInfoButton.HalfY(), sizeInfoButton.x, sizeInfoButton.y);
                            Style.SetGUIColorForButton(infoRect);
                            GUI.DrawTexture(infoRect, Textures.TextureButtonInfo);
                            if (Widgets.ButtonInvisible(infoRect))
                            {
                                if (entry.animal)
                                {
                                    Find.WindowStack.Add((Window) new Dialog_InfoCard(entry.thing));
                                }
                                else if (entry.stuffDef != null)
                                {
                                    Find.WindowStack.Add((Window) new Dialog_InfoCard(entry.def, entry.stuffDef));
                                }
                                else
                                {
                                    Find.WindowStack.Add((Window) new Dialog_InfoCard(entry.def));
                                }
                            }
                            GUI.color = Color.white;
                        }
                    });
                    table.AddColumn(new WidgetTable <EquipmentRecord> .Column()
                    {
                        Width      = columnWidthIcon,
                        Name       = ColumnNameIcon,
                        DrawAction = (EquipmentRecord entry, Rect columnRect, WidgetTable <EquipmentRecord> .Metadata metadata) => {
                            WidgetEquipmentIcon.Draw(columnRect, entry);
                        }
                    });
                    table.AddColumn(new WidgetTable <EquipmentRecord> .Column()
                    {
                        Width = columnWidthName,
                        Name  = ColumnNameName,
                        Label = "Name",
                        AdjustForScrollbars = true,
                        AllowSorting        = true,
                        DrawAction          = (EquipmentRecord entry, Rect columnRect, WidgetTable <EquipmentRecord> .Metadata metadata) => {
                            columnRect  = columnRect.InsetBy(nameOffset.x, 0, 0, 0);
                            GUI.color   = Style.ColorText;
                            Text.Font   = GameFont.Small;
                            Text.Anchor = TextAnchor.MiddleLeft;
                            Widgets.Label(columnRect, entry.Label);
                            GUI.color   = Color.white;
                            Text.Anchor = TextAnchor.UpperLeft;
                        }
                    });
                    table.AddColumn(new WidgetTable <EquipmentRecord> .Column()
                    {
                        Width = columnWidthCost,
                        Name  = ColumnNameCost,
                        Label = "Cost",
                        AdjustForScrollbars = false,
                        AllowSorting        = true,
                        DrawAction          = (EquipmentRecord entry, Rect columnRect, WidgetTable <EquipmentRecord> .Metadata metadata) => {
                            GUI.color   = Style.ColorText;
                            Text.Font   = GameFont.Small;
                            Text.Anchor = TextAnchor.MiddleRight;
                            Widgets.Label(new Rect(columnRect.x, columnRect.y, columnRect.width, columnRect.height),
                                          "" + entry.cost);
                            GUI.color   = Color.white;
                            Text.Anchor = TextAnchor.UpperLeft;
                        },
                        Alignment = TextAnchor.LowerRight
                    });
                    table.SetSortState(ColumnNameName, 1);
                    ViewEquipmentList view = new ViewEquipmentList()
                    {
                        Table = table,
                        List  = providerEquipment.AllEquipmentOfType(type).ToList()
                    };
                    SortByName(view, 1);
                    equipmentViews.Add(type, view);
                }
            }
        }
        protected void Resize()
        {
            float headerSize = 0;

            headerSize = HeaderHeight;
            if (HeaderLabel != null)
            {
                headerSize = HeaderHeight;
            }

            LineHeight    = 30;
            LinePadding   = 2;
            HeaderHeight  = 32;
            FooterHeight  = 40f;
            WindowPadding = 18;
            ContentMargin = new Vector2(10f, 18f);
            WindowSize    = new Vector2(440f, 584f);
            ButtonSize    = new Vector2(140f, 40f);

            ContentSize = new Vector2(WindowSize.x - WindowPadding * 2 - ContentMargin.x * 2,
                                      WindowSize.y - WindowPadding * 2 - ContentMargin.y * 2 - FooterHeight - headerSize);

            ContentRect = new Rect(ContentMargin.x, ContentMargin.y + headerSize, ContentSize.x, ContentSize.y);

            ScrollRect = new Rect(0, 0, ContentRect.width, ContentRect.height);

            HeaderRect = new Rect(ContentMargin.x, ContentMargin.y, ContentSize.x, HeaderHeight);

            FooterRect = new Rect(ContentMargin.x, ContentRect.y + ContentSize.y + 20,
                                  ContentSize.x, FooterHeight);

            SingleButtonRect = new Rect(ContentSize.x / 2 - ButtonSize.x / 2,
                                        (FooterHeight / 2) - (ButtonSize.y / 2),
                                        ButtonSize.x, ButtonSize.y);

            CancelButtonRect = new Rect(0,
                                        (FooterHeight / 2) - (ButtonSize.y / 2),
                                        ButtonSize.x, ButtonSize.y);
            ConfirmButtonRect = new Rect(ContentSize.x - ButtonSize.x,
                                         (FooterHeight / 2) - (ButtonSize.y / 2),
                                         ButtonSize.x, ButtonSize.y);

            Vector2 portraitSize = new Vector2(70, 70);
            float   radioWidth   = 36;
            Vector2 nameSize     = new Vector2(ContentRect.width - portraitSize.x - radioWidth, portraitSize.y * 0.5f);

            table                   = new WidgetTable <ImplantRecipe>();
            table.Rect              = new Rect(Vector2.zero, ContentRect.size);
            table.RowHeight         = LineHeight;
            table.RowColor          = new Color(0, 0, 0, 0);
            table.AlternateRowColor = new Color(0, 0, 0, 0);
            table.SelectedAction    = (ImplantRecipe recipe) => {
            };
            table.AddColumn(new WidgetTable <ImplantRecipe> .Column()
            {
                Name = "Recipe",
                AdjustForScrollbars = true,
                DrawAction          = (ImplantRecipe recipe, Rect rect, WidgetTable <ImplantRecipe> .Metadata metadata) => {
                    GUI.color           = Color.white;
                    Text.Anchor         = TextAnchor.LowerLeft;
                    Rect labelRect      = new Rect(rect.x, rect.y, rect.width, LineHeight);
                    Rect dottedLineRect = new Rect(labelRect.x, labelRect.y + 21, DottedLineSize.x, DottedLineSize.y);
                    Rect checkboxRect   = new Rect(labelRect.width - 22 - 6, labelRect.MiddleY() - 12, 22, 22);
                    Rect clickRect      = new Rect(labelRect.x, labelRect.y, labelRect.width - checkboxRect.width, labelRect.height);
                    GUI.color           = DottedLineColor;
                    GUI.DrawTexture(dottedLineRect, Textures.TextureDottedLine);
                    Vector2 labelSize = Text.CalcSize(recipe.Recipe.LabelCap);
                    GUI.color         = Style.ColorWindowBackground;
                    GUI.DrawTexture(new Rect(labelRect.x, labelRect.y, labelSize.x + 2, labelRect.height), BaseContent.WhiteTex);
                    GUI.DrawTexture(checkboxRect.InsetBy(-2, -2, -40, -2), BaseContent.WhiteTex);
                    if (!recipe.Disabled)
                    {
                        Style.SetGUIColorForButton(labelRect, recipe.Selected, Style.ColorText, Style.ColorButtonHighlight, Style.ColorButtonHighlight);
                        Widgets.Label(labelRect, recipe.Recipe.LabelCap);
                        if (Widgets.ButtonInvisible(clickRect))
                        {
                            ClickRecipeAction(recipe);
                        }
                        GUI.color = Color.white;
                        Texture2D checkboxTexture = Textures.TextureCheckbox;
                        if (recipe.PartiallySelected)
                        {
                            checkboxTexture = Textures.TextureCheckboxPartiallySelected;
                        }
                        else if (recipe.Selected)
                        {
                            checkboxTexture = Textures.TextureCheckboxSelected;
                        }
                        if (Widgets.ButtonImage(checkboxRect, checkboxTexture))
                        {
                            ClickRecipeAction(recipe);
                        }
                    }
                    else
                    {
                        GUI.color = Style.ColorControlDisabled;
                        Widgets.Label(labelRect, recipe.Recipe.LabelCap);
                        GUI.DrawTexture(checkboxRect, recipe.Selected ? Textures.TextureCheckboxPartiallySelected : Textures.TextureCheckbox);
                        if (Widgets.ButtonInvisible(checkboxRect))
                        {
                            ClickRecipeAction(recipe);
                        }
                        if (recipe.BlockingImplant != null)
                        {
                            TooltipHandler.TipRegion(labelRect, "EdB.PC.Dialog.Implant.Conflict".Translate(new object[] { recipe.BlockingImplant.recipe.LabelCap, recipe.BlockingImplant.BodyPartRecord.Label }));
                        }
                    }
                    if (recipe.Selected && recipe.RequiresPartSelection)
                    {
                        float partInset = 32;
                        float cursor    = labelRect.yMax;
                        foreach (var part in recipe.Parts)
                        {
                            string labelText = part.Part.LabelCap;
                            labelRect        = new Rect(rect.x + partInset, cursor, rect.width - partInset * 2, LineHeight);
                            dottedLineRect   = new Rect(labelRect.x, labelRect.y + 21, DottedLineSize.x, DottedLineSize.y);
                            checkboxRect     = new Rect(labelRect.x + labelRect.width - 22 - 6, labelRect.MiddleY() - 12, 22, 22);
                            clickRect        = new Rect(labelRect.x, labelRect.y, labelRect.width - checkboxRect.width, labelRect.height);
                            GUI.color        = DottedLineColor;
                            GUI.DrawTexture(dottedLineRect, Textures.TextureDottedLine);
                            labelSize = Text.CalcSize(labelText);
                            GUI.color = Style.ColorWindowBackground;
                            GUI.DrawTexture(new Rect(labelRect.x, labelRect.y, labelSize.x + 2, labelRect.height), BaseContent.WhiteTex);
                            GUI.DrawTexture(checkboxRect.InsetBy(-2, -2, -80, -2), BaseContent.WhiteTex);
                            if (!part.Disabled)
                            {
                                Style.SetGUIColorForButton(labelRect, part.Selected, Style.ColorText, Style.ColorButtonHighlight, Style.ColorButtonHighlight);
                                Widgets.Label(labelRect, labelText);
                                if (Widgets.ButtonInvisible(clickRect))
                                {
                                    ClickPartAction(recipe, part);
                                }
                                GUI.color = Color.white;
                                if (Widgets.ButtonImage(checkboxRect, part.Selected ? Textures.TextureCheckboxSelected : Textures.TextureCheckbox))
                                {
                                    ClickPartAction(recipe, part);
                                }
                            }
                            else
                            {
                                GUI.color = Style.ColorControlDisabled;
                                Widgets.Label(labelRect, labelText);
                                GUI.DrawTexture(checkboxRect, part.Selected ? Textures.TextureCheckboxPartiallySelected : Textures.TextureCheckbox);
                                if (Widgets.ButtonInvisible(checkboxRect))
                                {
                                    ClickPartAction(recipe, part);
                                }
                                if (part.BlockingImplant != null)
                                {
                                    TooltipHandler.TipRegion(labelRect, "EdB.PC.Dialog.Implant.Conflict".Translate(new object[] { part.BlockingImplant.recipe.LabelCap, part.BlockingImplant.BodyPartRecord.Label }));
                                }
                            }
                            cursor += labelRect.height;
                        }
                    }
                    Text.Anchor = TextAnchor.UpperLeft;
                },
                MeasureAction = (ImplantRecipe recipe, float width, WidgetTable <ImplantRecipe> .Metadata metadata) => {
                    if (recipe.Selected && recipe.Parts.Count > 1)
                    {
                        return(LineHeight + (LineHeight * recipe.Parts.Count));
                    }
                    else
                    {
                        return(LineHeight);
                    }
                },
                Width = ContentSize.x
            });

            resizeDirtyFlag = false;
        }
Exemple #6
0
        protected void Resize()
        {
            float headerSize = 0;

            headerSize = HeaderHeight;
            if (HeaderLabel != null)
            {
                headerSize = HeaderHeight;
            }

            HeaderHeight         = 32;
            RowGroupHeaderHeight = 36;
            FooterHeight         = 40f;
            WindowPadding        = 18;
            ContentMargin        = new Vector2(10f, 18f);
            WindowSize           = new Vector2(440f, 584f);
            ButtonSize           = new Vector2(140f, 40f);

            ContentSize = new Vector2(WindowSize.x - WindowPadding * 2 - ContentMargin.x * 2,
                                      WindowSize.y - WindowPadding * 2 - ContentMargin.y * 2 - FooterHeight - headerSize);

            ContentRect = new Rect(ContentMargin.x, ContentMargin.y + headerSize, ContentSize.x, ContentSize.y);

            ScrollRect = new Rect(0, 0, ContentRect.width, ContentRect.height);

            HeaderRect = new Rect(ContentMargin.x, ContentMargin.y, ContentSize.x, HeaderHeight);

            FooterRect = new Rect(ContentMargin.x, ContentRect.y + ContentSize.y + 20,
                                  ContentSize.x, FooterHeight);

            GenderSize = new Vector2(48, 48);

            SingleButtonRect = new Rect(ContentSize.x / 2 - ButtonSize.x / 2,
                                        (FooterHeight / 2) - (ButtonSize.y / 2),
                                        ButtonSize.x, ButtonSize.y);

            CancelButtonRect = new Rect(0,
                                        (FooterHeight / 2) - (ButtonSize.y / 2),
                                        ButtonSize.x, ButtonSize.y);
            ConfirmButtonRect = new Rect(ContentSize.x - ButtonSize.x,
                                         (FooterHeight / 2) - (ButtonSize.y / 2),
                                         ButtonSize.x, ButtonSize.y);

            float   nameOffset = 16;
            float   radioWidth = 36;
            Vector2 nameSize   = new Vector2(ContentRect.width - radioWidth, 42);

            table                      = new WidgetTable <CustomFaction>();
            table.Rect                 = new Rect(Vector2.zero, ContentRect.size);
            table.RowHeight            = 42;
            table.RowGroupHeaderHeight = RowGroupHeaderHeight;
            table.RowColor             = new Color(28f / 255f, 32f / 255f, 36f / 255f);
            table.AlternateRowColor    = new Color(0, 0, 0, 0);
            table.SelectedRowColor     = new Color(0, 0, 0, 0);
            table.SupportSelection     = true;
            table.SelectedAction       = (CustomFaction faction) => {
                if (!DisabledFactions.Contains(faction))
                {
                    SoundDefOf.Tick_Tiny.PlayOneShotOnCamera();
                    Select(faction);
                }
            };
            table.AddColumn(new WidgetTable <CustomFaction> .Column()
            {
                Name  = "NameAndDescription",
                Width = nameSize.x,
                AdjustForScrollbars = true,
                DrawAction          = (CustomFaction faction, Rect rect, WidgetTable <CustomFaction> .Metadata metadata) => {
                    string description = null;
                    if (faction.Faction != null && faction.Faction.Name.ToLower() != faction.Def.label.ToLower())
                    {
                        description = faction.Def.LabelCap;
                    }
                    if (description == null)
                    {
                        Text.Anchor = TextAnchor.MiddleLeft;
                        Text.Font   = GameFont.Small;
                        Widgets.Label(new Rect(rect.x + nameOffset, rect.y + 1, rect.width, nameSize.y), faction.Name.CapitalizeFirst());
                        Text.Anchor = TextAnchor.UpperLeft;
                    }
                    else
                    {
                        Text.Anchor = TextAnchor.LowerLeft;
                        Text.Font   = GameFont.Small;
                        Widgets.Label(new Rect(rect.x + nameOffset, rect.y + 5, rect.width, nameSize.y * 0.5f), faction.Name.CapitalizeFirst());
                        Text.Anchor = TextAnchor.UpperLeft;
                        Text.Font   = GameFont.Tiny;
                        Widgets.Label(new Rect(rect.x + nameOffset, rect.y + nameSize.y * 0.5f - 1, rect.width, nameSize.y * 0.5f), description);
                        Text.Font   = GameFont.Small;
                        Text.Anchor = TextAnchor.UpperLeft;
                    }
                }
            });
            table.AddColumn(new WidgetTable <CustomFaction> .Column()
            {
                Name       = "RadioButton",
                Width      = radioWidth,
                DrawAction = (CustomFaction faction, Rect rect, WidgetTable <CustomFaction> .Metadata metadata) => {
                    if (DisabledFactions != null && DisabledFactions.Contains(faction))
                    {
                        GUI.color = Style.ColorControlDisabled;
                        GUI.color = new Color(1, 1, 1, 0.28f);
                        GUI.DrawTexture(new Rect(rect.x, rect.MiddleY() - 12, 24, 24), Textures.TextureRadioButtonOff);
                        GUI.color = Color.white;
                    }
                    else
                    {
                        if (Widgets.RadioButton(new Vector2(rect.x, rect.MiddleY() - 12), this.SelectedFaction == faction))
                        {
                            Select(faction);
                        }
                    }
                }
            });
            resizeDirtyFlag = false;
        }
Exemple #7
0
        protected void Resize()
        {
            float headerSize = 0;

            headerSize = HeaderHeight;
            if (HeaderLabel != null)
            {
                headerSize = HeaderHeight;
            }

            HeaderHeight  = 32;
            FooterHeight  = 40f;
            WindowPadding = 18;
            ContentMargin = new Vector2(10f, 18f);
            WindowSize    = new Vector2(440f, 584f);
            ButtonSize    = new Vector2(140f, 40f);

            ContentSize = new Vector2(WindowSize.x - WindowPadding * 2 - ContentMargin.x * 2,
                                      WindowSize.y - WindowPadding * 2 - ContentMargin.y * 2 - FooterHeight - headerSize);

            ContentRect = new Rect(ContentMargin.x, ContentMargin.y + headerSize, ContentSize.x, ContentSize.y);

            ScrollRect = new Rect(0, 0, ContentRect.width, ContentRect.height);

            HeaderRect = new Rect(ContentMargin.x, ContentMargin.y, ContentSize.x, HeaderHeight);

            FooterRect = new Rect(ContentMargin.x, ContentRect.y + ContentSize.y + 20,
                                  ContentSize.x, FooterHeight);

            SingleButtonRect = new Rect(ContentSize.x / 2 - ButtonSize.x / 2,
                                        (FooterHeight / 2) - (ButtonSize.y / 2),
                                        ButtonSize.x, ButtonSize.y);

            CancelButtonRect = new Rect(0,
                                        (FooterHeight / 2) - (ButtonSize.y / 2),
                                        ButtonSize.x, ButtonSize.y);
            ConfirmButtonRect = new Rect(ContentSize.x - ButtonSize.x,
                                         (FooterHeight / 2) - (ButtonSize.y / 2),
                                         ButtonSize.x, ButtonSize.y);

            Vector2 portraitSize      = new Vector2(70, 70);
            float   portraitOverflow  = 8;
            float   nameOffset        = 2;
            float   descriptionOffset = -2;
            float   radioWidth        = 36;
            Vector2 nameSize          = new Vector2(ContentRect.width - portraitSize.x - radioWidth, portraitSize.y * 0.5f);

            table                   = new WidgetTable <CustomPawn>();
            table.Rect              = new Rect(Vector2.zero, ContentRect.size);
            table.RowHeight         = portraitSize.y;
            table.RowColor          = new Color(28f / 255f, 32f / 255f, 36f / 255f);
            table.AlternateRowColor = new Color(0, 0, 0, 0);
            table.SelectedRowColor  = new Color(0, 0, 0, 0);
            table.SupportSelection  = true;
            table.SelectedAction    = (CustomPawn pawn) => {
                if (DisabledPawns == null || !DisabledPawns.Contains(pawn))
                {
                    SoundDefOf.TickTiny.PlayOneShotOnCamera();
                    Select(pawn);
                }
            };
            table.AddColumn(new WidgetTable <CustomPawn> .Column()
            {
                Name       = "Portrait",
                DrawAction = (CustomPawn pawn, Rect rect, WidgetTable <CustomPawn> .Metadata metadata) => {
                    GUI.color   = Color.white;
                    var texture = pawn.GetPortrait(new Vector2(portraitSize.x, portraitSize.y + portraitOverflow * 2));
                    GUI.DrawTexture(new Rect(rect.position.x, rect.position.y - portraitOverflow, portraitSize.x, portraitSize.y + portraitOverflow * 2), texture as Texture);
                },
                Width = portraitSize.x
            });
            table.AddColumn(new WidgetTable <CustomPawn> .Column()
            {
                Name  = "Description",
                Width = nameSize.x,
                AdjustForScrollbars = true,
                DrawAction          = (CustomPawn pawn, Rect rect, WidgetTable <CustomPawn> .Metadata metadata) => {
                    Text.Anchor = TextAnchor.LowerLeft;
                    Text.Font   = GameFont.Small;
                    Widgets.Label(new Rect(rect.x, rect.y + nameOffset, rect.width, nameSize.y), pawn.Pawn.LabelShort);
                    Text.Anchor        = TextAnchor.UpperLeft;
                    string description = pawn.IsAdult ? pawn.Adulthood.TitleShort : pawn.Childhood.TitleShort;
                    description       += ", " + pawn.Gender.GetLabel() + ", age " + pawn.BiologicalAge;
                    if (pawn.BiologicalAge != pawn.ChronologicalAge)
                    {
                        description += " (" + pawn.ChronologicalAge + ")";
                    }
                    Text.Font = GameFont.Tiny;
                    Widgets.Label(new Rect(rect.x, rect.y + nameSize.y + descriptionOffset, rect.width, nameSize.y), description);
                    Text.Font   = GameFont.Small;
                    Text.Anchor = TextAnchor.UpperLeft;
                }
            });
            table.AddColumn(new WidgetTable <CustomPawn> .Column()
            {
                Name       = "RadioButton",
                Width      = radioWidth,
                DrawAction = (CustomPawn pawn, Rect rect, WidgetTable <CustomPawn> .Metadata metadata) => {
                    if (DisabledPawns != null && DisabledPawns.Contains(pawn))
                    {
                        GUI.color = Style.ColorControlDisabled;
                        GUI.color = new Color(1, 1, 1, 0.28f);
                        GUI.DrawTexture(new Rect(rect.x, rect.MiddleY() - 12, 24, 24), Textures.TextureRadioButtonOff);
                        GUI.color = Color.white;
                    }
                    else
                    {
                        if (Widgets.RadioButton(new Vector2(rect.x, rect.MiddleY() - 12), this.SelectedPawn == pawn))
                        {
                            Select(pawn);
                        }
                    }
                }
            });
            resizeDirtyFlag = false;
        }
        public override void Resize(Rect rect)
        {
            base.Resize(rect);

            Vector2 padding = new Vector2(12, 12);

            Vector2 sizeInfoButton = new Vector2(24, 24);
            Vector2 sizeButton     = new Vector2(160, 34);

            RectRemoveButton = new Rect(PanelRect.HalfWidth() - sizeButton.HalfX(),
                                        PanelRect.height - padding.y - sizeButton.y, sizeButton.x, sizeButton.y);

            Vector2 listSize = new Vector2();

            listSize.x = rect.width - padding.x * 2;
            listSize.y = rect.height - padding.y * 3 - RectRemoveButton.height;
            float listHeaderHeight = 20;
            float listBodyHeight   = listSize.y - listHeaderHeight;

            Rect rectTable = new Rect(padding.x, padding.y, listSize.x, listSize.y);

            RectRow = new Rect(0, 0, rectTable.width, 42);

            Vector2 nameOffset       = new Vector2(10, 0);
            float   columnWidthInfo  = 36;
            float   columnWidthIcon  = 42;
            float   columnWidthCount = 112;
            float   columnWidthName  = RectRow.width - columnWidthInfo - columnWidthIcon - columnWidthCount;

            table                   = new WidgetTable <EquipmentSelection>();
            table.Rect              = rectTable;
            table.BackgroundColor   = Style.ColorPanelBackgroundDeep;
            table.RowColor          = Style.ColorTableRow1;
            table.AlternateRowColor = Style.ColorTableRow2;
            table.SelectedRowColor  = Style.ColorTableRowSelected;
            table.SupportSelection  = true;
            table.RowHeight         = 42;
            table.SelectedAction    = (EquipmentSelection entry) => {
                SoundDefOf.TickTiny.PlayOneShotOnCamera();
            };
            table.DoubleClickAction = (EquipmentSelection entry) => {
                SoundDefOf.TickHigh.PlayOneShotOnCamera();
                if (entry.Count > 0)
                {
                    EquipmentCountUpdated(entry, entry.Count - 1);
                }
                else
                {
                    EquipmentRemoved(entry);
                }
            };
            table.AddColumn(new WidgetTable <EquipmentSelection> .Column()
            {
                Width      = columnWidthInfo,
                Name       = "Info",
                DrawAction = (EquipmentSelection entry, Rect columnRect, WidgetTable <EquipmentSelection> .Metadata metadata) => {
                    Rect infoRect = new Rect(columnRect.MiddleX() - sizeInfoButton.HalfX(), columnRect.MiddleY() - sizeInfoButton.HalfY(), sizeInfoButton.x, sizeInfoButton.y);
                    Style.SetGUIColorForButton(infoRect);
                    GUI.DrawTexture(infoRect, Textures.TextureButtonInfo);
                    if (Widgets.ButtonInvisible(infoRect))
                    {
                        if (entry.StuffDef != null)
                        {
                            Find.WindowStack.Add((Window) new Dialog_InfoCard(entry.ThingDef, entry.StuffDef));
                        }
                        else
                        {
                            Find.WindowStack.Add((Window) new Dialog_InfoCard(entry.ThingDef));
                        }
                    }
                    GUI.color = Color.white;
                }
            });
            table.AddColumn(new WidgetTable <EquipmentSelection> .Column()
            {
                Width      = columnWidthIcon,
                Name       = "Icon",
                DrawAction = (EquipmentSelection entry, Rect columnRect, WidgetTable <EquipmentSelection> .Metadata metadata) => {
                    WidgetEquipmentIcon.Draw(columnRect, entry.Record);
                }
            });
            table.AddColumn(new WidgetTable <EquipmentSelection> .Column()
            {
                Width      = columnWidthName,
                Name       = "Name",
                Label      = "Name",
                DrawAction = (EquipmentSelection entry, Rect columnRect, WidgetTable <EquipmentSelection> .Metadata metadata) => {
                    columnRect  = columnRect.InsetBy(nameOffset.x, 0, 0, 0);
                    GUI.color   = Style.ColorText;
                    Text.Font   = GameFont.Small;
                    Text.Anchor = TextAnchor.MiddleLeft;
                    Widgets.Label(columnRect, entry.Record.Label);
                    GUI.color   = Color.white;
                    Text.Anchor = TextAnchor.UpperLeft;
                }
            });
            table.AddColumn(new WidgetTable <EquipmentSelection> .Column()
            {
                Width = columnWidthCount,
                Name  = "Count",
                Label = "Count",
                AdjustForScrollbars = true,
                DrawAction          = (EquipmentSelection entry, Rect columnRect, WidgetTable <EquipmentSelection> .Metadata metadata) => {
                    Rect fieldRect = new Rect(columnRect.x + 17, columnRect.y + 7, 60, 28);
                    Widgets.DrawAtlas(fieldRect, Textures.TextureFieldAtlas);

                    if (metadata.rowIndex <= numberFields.Count)
                    {
                        numberFields.Add(new WidgetNumberField()
                        {
                            MaxValue = 100000
                        });
                    }
                    WidgetNumberField field = numberFields[metadata.rowIndex];
                    field.UpdateAction      = (int value) => {
                        EquipmentCountUpdated(entry, value);
                    };
                    field.Draw(fieldRect, entry.Count);
                }
            });
        }
        protected void ShowAddRelationshipDialogs()
        {
            CustomPawn      sourceParentChildPawn = null;
            PawnRelationDef selectedRelationship  = null;
            CustomPawn      targetParentChildPawn = null;

            Dialog_Options <PawnRelationDef> relationshipDialog =
                new Dialog_Options <PawnRelationDef>(null)
            {
                ConfirmButtonLabel = "EdB.PC.Common.Next".Translate(),
                CancelButtonLabel  = "EdB.PC.Common.Cancel".Translate(),
                HeaderLabel        = "EdB.PC.AddRelationship.Header.Relationship".Translate(),
                NameFunc           = (PawnRelationDef def) => {
                    return(def.GetGenderSpecificLabelCap(sourceParentChildPawn.Pawn));
                },
                SelectedFunc = (PawnRelationDef def) => {
                    return(def == selectedRelationship);
                },
                SelectAction = (PawnRelationDef def) => {
                    selectedRelationship = def;
                },
                EnabledFunc = (PawnRelationDef d) => {
                    return(!disabledRelationships.Contains(d));
                },
                ConfirmValidation = () => {
                    if (selectedRelationship == null)
                    {
                        return("EdB.PC.AddRelationship.Error.RelationshipRequired");
                    }
                    else
                    {
                        return(null);
                    }
                }
            };

            List <WidgetTable <CustomPawn> .RowGroup> sourceRowGroups = new List <WidgetTable <CustomPawn> .RowGroup>();

            sourceRowGroups.Add(new WidgetTable <CustomPawn> .RowGroup("EdB.PC.AddParentChild.Header.SelectColonist".Translate(),
                                                                       PrepareCarefully.Instance.RelationshipManager.ColonyAndWorldPawns.Where((CustomPawn pawn) => {
                return(pawn.Type == CustomPawnType.Colonist);
            })));
            List <CustomPawn> hiddenPawnsForSource = PrepareCarefully.Instance.RelationshipManager.HiddenPawns.ToList();

            hiddenPawnsForSource.Sort((a, b) => {
                if (a.Type != b.Type)
                {
                    return(a.Type == CustomPawnType.Hidden ? -1 : 1);
                }
                else
                {
                    int aInt = a.Index == null ? 0 : a.Index.Value;
                    int bInt = b.Index == null ? 0 : b.Index.Value;
                    return(aInt.CompareTo(bInt));
                }
            });
            sourceRowGroups.Add(new WidgetTable <CustomPawn> .RowGroup("<b>" + "EdB.PC.AddParentChild.Header.SelectWorldPawn".Translate() + "</b>",
                                                                       PrepareCarefully.Instance.RelationshipManager.ColonyAndWorldPawns.Where((CustomPawn pawn) => {
                return(pawn.Type != CustomPawnType.Colonist);
            }).Concat(hiddenPawnsForSource)));
            WidgetTable <CustomPawn> .RowGroup sourceNewPawnGroup = new WidgetTable <CustomPawn> .RowGroup("EdB.PC.AddParentChild.Header.CreateTemporaryPawn".Translate(), PrepareCarefully.Instance.RelationshipManager.TemporaryPawns);

            sourceRowGroups.Add(sourceNewPawnGroup);

            DialogSelectParentChildPawn sourcePawnDialog = new DialogSelectParentChildPawn()
            {
                HeaderLabel       = "EdB.PC.AddRelationship.Header.Source".Translate(),
                SelectAction      = (CustomPawn pawn) => { sourceParentChildPawn = pawn; },
                RowGroups         = sourceRowGroups,
                DisabledPawns     = null,
                ConfirmValidation = () => {
                    if (sourceParentChildPawn == null)
                    {
                        return("EdB.PC.AddRelationship.Error.SourceRequired");
                    }
                    else
                    {
                        return(null);
                    }
                },
                CloseAction = () => {
                    // If the user selected a new pawn, replace the pawn in the new pawn list with another one.
                    int index = sourceNewPawnGroup.Rows.FirstIndexOf((CustomPawn p) => {
                        return(p == targetParentChildPawn);
                    });
                    if (index > -1 && index < PrepareCarefully.Instance.RelationshipManager.TemporaryPawns.Count)
                    {
                        targetParentChildPawn = PrepareCarefully.Instance.RelationshipManager.ReplaceNewTemporaryCharacter(index);
                    }
                }
            };

            DialogSelectParentChildPawn targetPawnDialog = new DialogSelectParentChildPawn()
            {
                HeaderLabel       = "EdB.PC.AddRelationship.Header.Target".Translate(),
                SelectAction      = (CustomPawn pawn) => { targetParentChildPawn = pawn; },
                RowGroups         = null, // To be filled out later
                DisabledPawns     = null, // To be filled out later
                ConfirmValidation = () => {
                    if (sourceParentChildPawn == null)
                    {
                        return("EdB.PC.AddRelationship.Error.TargetRequired");
                    }
                    else
                    {
                        return(null);
                    }
                }
            };

            WidgetTable <CustomPawn> .RowGroup targetNewPawnGroup = null;

            sourcePawnDialog.CloseAction = () => {
                List <PawnRelationDef> relationDefs = PrepareCarefully.Instance.RelationshipManager.AllowedRelationships.Select((PawnRelationDef def) => {
                    return(def);
                }).ToList();
                relationDefs.Sort((PawnRelationDef a, PawnRelationDef b) => {
                    return(a.GetGenderSpecificLabelCap(sourceParentChildPawn.Pawn).CompareTo(b.GetGenderSpecificLabelCap(sourceParentChildPawn.Pawn)));
                });
                relationshipDialog.Options = relationDefs;
                Find.WindowStack.Add(relationshipDialog);
            };
            relationshipDialog.CloseAction = () => {
                SetDisabledTargets(sourceParentChildPawn, selectedRelationship);
                targetPawnDialog.DisabledPawns = disabledTargets;

                List <WidgetTable <CustomPawn> .RowGroup> targetRowGroups = new List <WidgetTable <CustomPawn> .RowGroup>();
                targetRowGroups.Add(new WidgetTable <CustomPawn> .RowGroup("EdB.PC.AddParentChild.Header.SelectColonist".Translate(),
                                                                           PrepareCarefully.Instance.RelationshipManager.ColonyAndWorldPawns.Where((CustomPawn pawn) => {
                    return(pawn.Type == CustomPawnType.Colonist && pawn != sourceParentChildPawn);
                })));
                List <CustomPawn> hiddenPawnsForTarget = PrepareCarefully.Instance.RelationshipManager.HiddenPawns.ToList();
                hiddenPawnsForTarget.Sort((a, b) => {
                    if (a.Type != b.Type)
                    {
                        return(a.Type == CustomPawnType.Hidden ? -1 : 1);
                    }
                    else
                    {
                        int aInt = a.Index == null ? 0 : a.Index.Value;
                        int bInt = b.Index == null ? 0 : b.Index.Value;
                        return(aInt.CompareTo(bInt));
                    }
                });
                targetRowGroups.Add(new WidgetTable <CustomPawn> .RowGroup("<b>" + "EdB.PC.AddParentChild.Header.SelectWorldPawn".Translate() + "</b>",
                                                                           PrepareCarefully.Instance.RelationshipManager.ColonyAndWorldPawns.Where((CustomPawn pawn) => {
                    return(pawn.Type != CustomPawnType.Colonist && pawn != sourceParentChildPawn);
                }).Concat(hiddenPawnsForTarget)));
                targetNewPawnGroup = new WidgetTable <CustomPawn> .RowGroup("EdB.PC.AddParentChild.Header.CreateTemporaryPawn".Translate(), PrepareCarefully.Instance.RelationshipManager.TemporaryPawns);

                targetRowGroups.Add(targetNewPawnGroup);
                targetPawnDialog.RowGroups = targetRowGroups;

                Find.WindowStack.Add(targetPawnDialog);
            };
            targetPawnDialog.CloseAction = () => {
                // If the user selected a new pawn, replace the pawn in the new pawn list with another one.
                int index = targetNewPawnGroup.Rows.FirstIndexOf((CustomPawn p) => {
                    return(p == targetParentChildPawn);
                });
                if (index > -1 && index < PrepareCarefully.Instance.RelationshipManager.TemporaryPawns.Count)
                {
                    targetParentChildPawn = PrepareCarefully.Instance.RelationshipManager.ReplaceNewTemporaryCharacter(index);
                }
                this.RelationshipAdded(PrepareCarefully.Instance.RelationshipManager.FindInverseRelationship(selectedRelationship), sourceParentChildPawn, targetParentChildPawn);
            };
            Find.WindowStack.Add(sourcePawnDialog);
        }
        protected void ShowChildDialogForGroup(ParentChildGroup group, CustomPawn selected, Action <CustomPawn> action)
        {
            CustomPawn           selectedPawn = selected;
            HashSet <CustomPawn> disabled     = new HashSet <CustomPawn>();

            if (group != null)
            {
                disabled.AddRange(group.Parents);
                disabled.AddRange(group.Children);
            }
            rowGroups.Clear();
            rowGroups.Add(new WidgetTable <CustomPawn> .RowGroup("<b>" + "EdB.PC.AddParentChild.Header.SelectColonist".Translate() + "</b>",
                                                                 PrepareCarefully.Instance.RelationshipManager.ColonyAndWorldPawns.Where((CustomPawn pawn) => {
                return(pawn.Type == CustomPawnType.Colonist);
            })));
            List <CustomPawn> sortedHiddenPawns = PrepareCarefully.Instance.RelationshipManager.HiddenPawns.ToList();

            sortedHiddenPawns.Sort((a, b) => {
                if (a.Type != b.Type)
                {
                    return(a.Type == CustomPawnType.Hidden ? -1 : 1);
                }
                else
                {
                    int aInt = a.Index == null ? 0 : a.Index.Value;
                    int bInt = b.Index == null ? 0 : b.Index.Value;
                    return(aInt.CompareTo(bInt));
                }
            });
            rowGroups.Add(new WidgetTable <CustomPawn> .RowGroup("<b>" + "EdB.PC.AddParentChild.Header.SelectWorldPawn".Translate() + "</b>",
                                                                 PrepareCarefully.Instance.RelationshipManager.ColonyAndWorldPawns.Where((CustomPawn pawn) => {
                return(pawn.Type != CustomPawnType.Colonist);
            }).Concat(sortedHiddenPawns)));
            WidgetTable <CustomPawn> .RowGroup newPawnGroup = new WidgetTable <CustomPawn> .RowGroup("EdB.PC.AddParentChild.Header.CreateTemporaryPawn".Translate(), PrepareCarefully.Instance.RelationshipManager.TemporaryPawns);

            rowGroups.Add(newPawnGroup);
            DialogSelectParentChildPawn pawnDialog = new DialogSelectParentChildPawn()
            {
                HeaderLabel       = "EdB.PC.AddParentChild.Header.AddChild".Translate(),
                SelectAction      = (CustomPawn pawn) => { selectedPawn = pawn; },
                RowGroups         = rowGroups,
                DisabledPawns     = disabled,
                ConfirmValidation = () => {
                    if (selectedPawn == null)
                    {
                        return("EdB.PC.AddParentChild.Error.ChildRequired");
                    }
                    else
                    {
                        return(null);
                    }
                },
                CloseAction = () => {
                    // If the user selected a new pawn, replace the pawn in the new pawn list with another one.
                    int index = newPawnGroup.Rows.FirstIndexOf((CustomPawn p) => {
                        return(p == selectedPawn);
                    });
                    if (index > -1 && index < PrepareCarefully.Instance.RelationshipManager.TemporaryPawns.Count)
                    {
                        selectedPawn = PrepareCarefully.Instance.RelationshipManager.ReplaceNewTemporaryCharacter(index);
                    }
                    action(selectedPawn);
                }
            };

            Find.WindowStack.Add(pawnDialog);
        }