DoAllowedAreaSelectors() public static method

public static DoAllowedAreaSelectors ( Rect rect, Area areaIn, Map map, AllowedAreaMode mode = AllowedAreaMode.Humanlike, float lrMargin ) : Area
rect UnityEngine.Rect
areaIn Area
map Map
mode AllowedAreaMode
lrMargin float
return Area
Example #1
0
        public float DrawHuntingGrounds(Vector2 pos, float width)
        {
            var start = pos;

            AreaAllowedGUI.DoAllowedAreaSelectors(ref pos, width, ref _selected.HuntingGrounds, manager);
            return(pos.y - start.y);
        }
        public float DrawAreaRestriction(Vector2 pos, float width)
        {
            var start = pos;

            AreaAllowedGUI.DoAllowedAreaSelectors(ref pos, width, ref _selected.ForagingArea, manager);
            return(pos.y - start.y);
        }
Example #3
0
        private float DrawTamingSection(Vector2 pos, float width)
        {
            var start = pos;

            DrawToggle(ref pos, width,
                       "FML.TameMore".Translate(),
                       "FML.TameMore.Tip".Translate(),
                       ref _selectedCurrent.TryTameMore);

            // area to tame from (if taming more);
            if (_selectedCurrent.TryTameMore)
            {
                AreaAllowedGUI.DoAllowedAreaSelectors(ref pos, width, ref _selectedCurrent.TameArea, manager);
                DrawReachabilityToggle(ref pos, width, ref _selectedCurrent.CheckReachable);
                DrawToggle(ref pos, width,
                           "FM.PathBasedDistance".Translate(),
                           "FM.PathBasedDistance.Tip".Translate(),
                           ref _selectedCurrent.PathBasedDistance, true);
            }

            return(pos.y - start.y);
        }
        public void DoContent(Rect rect)
        {
            // layout: settings | trees
            // draw background
            Widgets.DrawMenuSection(rect);

            // some variables
            float width         = rect.width;
            float height        = rect.height - _topAreaHeight - _button.y - Margin;
            var   cols          = 2;
            float colWidth      = width / cols - Margin;
            var   colRects      = new List <Rect>();
            var   colTitleRects = new List <Rect>();
            var   buttonRect    = new Rect(rect.width - _button.x, rect.height - _button.y, _button.x - Margin,
                                           _button.y - Margin);

            // set up rects
            for (var j = 0; j < cols; j++)
            {
                colRects.Add(new Rect(j * colWidth + j * Margin + Margin / 2, _topAreaHeight, colWidth, height));
                colTitleRects.Add(new Rect(j * colWidth + j * Margin + Margin * 2.5f, 0f, colWidth, _topAreaHeight));
            }

            // keep track of location
            Vector2 cur;

            // begin window
            GUI.BeginGroup(rect);

            // settings.
            Text.Anchor = TextAnchor.LowerLeft;
            Text.Font   = GameFont.Tiny;
            Widgets.Label(colTitleRects[0], "FMF.Options".Translate());
            Text.Font   = GameFont.Small;
            Text.Anchor = TextAnchor.UpperLeft;

            GUI.DrawTexture(colRects[0], Resources.SlightlyDarkBackground);
            GUI.BeginGroup(colRects[0]);
            cur = Vector2.zero;

            // trigger config (1)
            int currentCount    = _selected.Trigger.CurCount;
            int designatedCount = _selected.GetWoodInDesignations();
            int targetCount     = _selected.Trigger.Count;

            _selected.Trigger.DrawTriggerConfig(ref cur, colRects[0].width, EntryHeight, true,
                                                "FMF.TargetCount".Translate(currentCount, designatedCount, targetCount),
                                                "FMF.TargetCountTooltip".Translate(currentCount, designatedCount,
                                                                                   targetCount));

            // Clear wind cells (2)
            var clearWindCellsRect = new Rect(cur.x, cur.y, colWidth, EntryHeight);

            Utilities.DrawToggle(clearWindCellsRect, "FMF.ClearWindCells".Translate(),
                                 ref ManagerJob_Forestry.ClearWindCells);
            cur.y += EntryHeight;

            // clear additional areas(3)
            var clearAdditionalAreasLabelRect = new Rect(cur.x, cur.y, colWidth, EntryHeight);

            Widgets.DrawAltRect(clearAdditionalAreasLabelRect);
            Utilities.Label(clearAdditionalAreasLabelRect, "FMF.ClearAreas".Translate(), anchor: TextAnchor.MiddleLeft,
                            lrMargin: Margin);
            cur.y += EntryHeight;

            var clearAdditionalAreasSelectorRect = new Rect(cur.x, cur.y, colWidth, EntryHeight);

            Widgets.DrawAltRect(clearAdditionalAreasSelectorRect);
            AreaAllowedGUI.DoAllowedAreaSelectorsMC(clearAdditionalAreasSelectorRect, ref _selected.ClearAreas, Margin);
            cur.y += EntryHeight;

            // Allow saplings (4)
            var allowSaplingsRect = new Rect(cur.x, cur.y, colWidth, EntryHeight);

            Utilities.DrawToggle(allowSaplingsRect, "FMF.AllowSaplings".Translate(), ref _selected.AllowSaplings);
            cur.y += EntryHeight;

            // Logging area (5)
            var loggingAreaTitleRect = new Rect(cur.x, cur.y, colWidth, EntryHeight);

            Widgets.DrawAltRect(loggingAreaTitleRect);
            Utilities.Label(loggingAreaTitleRect, "FMF.LoggingArea".Translate(), anchor: TextAnchor.MiddleLeft,
                            lrMargin: Margin);
            cur.y += EntryHeight;

            var loggingAreaRect = new Rect(cur.x, cur.y, colWidth, EntryHeight);

            Widgets.DrawAltRect(loggingAreaRect);
            AreaAllowedGUI.DoAllowedAreaSelectors(loggingAreaRect, ref _selected.LoggingArea, manager, lrMargin: Margin);
            cur.y += EntryHeight;

            GUI.EndGroup();

            // treedefs.
            Text.Anchor = TextAnchor.LowerLeft;
            Text.Font   = GameFont.Tiny;
            Widgets.Label(colTitleRects[1], "FMF.Trees".Translate());
            Text.Font   = GameFont.Small;
            Text.Anchor = TextAnchor.UpperLeft;

            GUI.DrawTexture(colRects[1], Resources.SlightlyDarkBackground);
            GUI.BeginGroup(colRects[1]);
            cur = Vector2.zero;

            Rect outRect  = colRects[1].AtZero().ContractedBy(1f);
            var  viewRect = new Rect(0f, 0f, outRect.width, _selected.AllowedTrees.Count * EntryHeight);

            if (viewRect.height > outRect.height)
            {
                viewRect.width -= 16f;
            }

            // start scrolling view
            Widgets.BeginScrollView(outRect, ref _contentScrollPosition, viewRect);

            // list of keys in allowed trees list (all plans that yield wood in biome, static)
            var treeDefs = new List <ThingDef>(_selected.AllowedTrees.Keys);

            // toggle all
            var toggleAllRect = new Rect(cur.x, cur.y, colWidth, EntryHeight);

            Widgets.DrawAltRect(toggleAllRect);
            Utilities.DrawToggle(toggleAllRect, "<i>" + "FM.All".Translate() + "</i>",
                                 _selected.AllowedTrees.Values.All(v => v), delegate
            {
                foreach (
                    ThingDef def in treeDefs)
                {
                    _selected.AllowedTrees[def] =
                        true;
                }
            }, delegate
            {
                foreach (
                    ThingDef def in
                    treeDefs)
                {
                    _selected.AllowedTrees
                    [def] = false;
                }
            });

            cur.y += EntryHeight;

            // toggle for each tree
            var i = 1;

            foreach (ThingDef def in treeDefs)
            {
                var toggleRect = new Rect(cur.x, cur.y, colWidth, EntryHeight);

                // highlight alternate rows
                if (i++ % 2 == 0)
                {
                    Widgets.DrawAltRect(toggleRect);
                }

                // draw the toggle
                Utilities.DrawToggle(toggleRect, def.LabelCap, _selected.AllowedTrees[def],
                                     delegate
                                     { _selected.AllowedTrees[def] = !_selected.AllowedTrees[def]; });

                // update current position
                cur.y += EntryHeight;
            }

            // close scrolling view
            Widgets.EndScrollView();

            // close tree list
            GUI.EndGroup();

            // do the button
            if (!_selected.Managed)
            {
                if (Widgets.ButtonText(buttonRect, "FM.Manage".Translate()))
                {
                    // activate job, add it to the stack
                    _selected.Managed = true;
                    manager.JobStack.Add(_selected);

                    // refresh source list
                    Refresh();
                }
            }
            else
            {
                if (Widgets.ButtonText(buttonRect, "FM.Delete".Translate()))
                {
                    // inactivate job, remove from the stack.
                    manager.JobStack.Delete(_selected);

                    // remove content from UI
                    _selected = null;

                    // refresh source list
                    Refresh();
                }
            }

            // close window
            GUI.EndGroup();
        }
        public void DoContent(Rect rect)
        {
            // layout: settings | animals
            // draw background
            Widgets.DrawMenuSection(rect);

            // some variables
            float width         = rect.width;
            float height        = rect.height - _topAreaHeight - _button.y - _margin;
            var   cols          = 2;
            float colWidth      = width / cols - _margin;
            var   colRects      = new List <Rect>();
            var   colTitleRects = new List <Rect>();
            var   buttonRect    = new Rect(rect.width - _button.x, rect.height - _button.y, _button.x - _margin,
                                           _button.y - _margin);

            // set up rects
            for (var j = 0; j < cols; j++)
            {
                colRects.Add(new Rect(j * colWidth + j * _margin + _margin / 2, _topAreaHeight, colWidth, height));
                colTitleRects.Add(new Rect(j * colWidth + j * _margin + _margin / 2, 0f, colWidth, _topAreaHeight));
            }

            // keep track of location
            Vector2 cur = Vector2.zero;

            // begin window
            GUI.BeginGroup(rect);

            // settings.
            Utilities.Label(colTitleRects[0], "FMH.Options".Translate(),
                            anchor: TextAnchor.LowerLeft, lrMargin: _margin * 2, font: GameFont.Tiny);

            GUI.DrawTexture(colRects[0], Resources.SlightlyDarkBackground);
            GUI.BeginGroup(colRects[0]);

            // target count (1)
            int currentCount    = _selected.Trigger.CurCount;
            int corpseCount     = _selected.GetMeatInCorpses();
            int designatedCount = _selected.GetMeatInDesignations();
            int targetCount     = _selected.Trigger.Count;

            _selected.Trigger.DrawTriggerConfig(ref cur, colWidth, _entryHeight, true,
                                                "FMH.TargetCount".Translate(currentCount, corpseCount, designatedCount,
                                                                            targetCount),
                                                "FMH.TargetCountTooltip".Translate(currentCount, corpseCount,
                                                                                   designatedCount, targetCount));

            // allow human meat (2)
            var humanMeatRect = new Rect(cur.x, cur.y, colWidth, _entryHeight);

            Utilities.DrawToggle(humanMeatRect, "FMH.AllowHumanMeat".Translate(),
                                 _selected.Trigger.ThresholdFilter.Allows(Utilities_Hunting.HumanMeat),
                                 delegate
                                 { _selected.AllowHumanLikeMeat(true); },
                                 delegate
                                 { _selected.AllowHumanLikeMeat(false); });
            cur.y += _entryHeight;

            // unforbid corpses (3)
            var ufCorpseRect = new Rect(cur.x, cur.y, colWidth, _entryHeight);

            Widgets.DrawAltRect(ufCorpseRect);
            Utilities.DrawToggle(ufCorpseRect, "FMH.UnforbidCorpses".Translate(), ref _selected.UnforbidCorpses);
            cur.y += _entryHeight;

            // hunting grounds (4)
            var huntingGroundsTitleRect = new Rect(cur.x, cur.y, colWidth - 2 * _margin, _entryHeight);

            Utilities.Label(huntingGroundsTitleRect, "FMH.HuntingGrounds".Translate(), anchor: TextAnchor.MiddleLeft,
                            lrMargin: _margin);
            cur.y += _entryHeight;

            var huntingGroundsRect = new Rect(cur.x + _margin, cur.y, colWidth - 2 * _margin, _entryHeight);

            AreaAllowedGUI.DoAllowedAreaSelectors(huntingGroundsRect, ref _selected.HuntingGrounds, manager,
                                                  AllowedAreaMode.Humanlike);
            cur.y += _entryHeight;

            GUI.EndGroup();

            // animals.
            Utilities.Label(colTitleRects[1], "FMH.Animals".Translate(),
                            anchor: TextAnchor.LowerLeft, lrMargin: _margin * 2, font: GameFont.Tiny);

            GUI.DrawTexture(colRects[1], Resources.SlightlyDarkBackground);
            GUI.BeginGroup(colRects[1]);
            cur = Vector2.zero;

            Rect outRect  = colRects[1].AtZero().ContractedBy(1f);
            var  viewRect = new Rect(0f, 0f, outRect.width, _selected.AllowedAnimals.Count * _entryHeight);

            if (viewRect.height > outRect.height)
            {
                viewRect.width -= 16f;
            }

            // start scrolling view
            Widgets.BeginScrollView(outRect, ref _animalsScrollPosition, viewRect);

            // list of keys in allowed animals list (all animals in biome, static)
            var PawnKinds = new List <PawnKindDef>(_selected.AllowedAnimals.Keys);

            // toggle all
            var toggleAllRect = new Rect(cur.x, cur.y, colWidth, _entryHeight);

            Widgets.DrawAltRect(toggleAllRect);
            Dictionary <PawnKindDef, bool> .ValueCollection test = _selected.AllowedAnimals.Values;
            Utilities.DrawToggle(toggleAllRect, "<i>" + "FM.All".Translate() + "</i>",
                                 _selected.AllowedAnimals.Values.All(v => v), delegate
            {
                foreach (
                    PawnKindDef def in
                    PawnKinds)
                {
                    _selected.AllowedAnimals[
                        def
                    ] = true;
                }
            }, delegate
            {
                foreach (
                    PawnKindDef def in
                    PawnKinds)
                {
                    _selected
                    .AllowedAnimals[
                        def
                    ] = false;
                }
            });

            cur.y += _entryHeight;

            // toggle for each animal
            var i = 1;

            foreach (PawnKindDef kind in PawnKinds)
            {
                var toggleRect = new Rect(cur.x, cur.y, colWidth, _entryHeight);

                // highlight alternate rows
                if (i++ % 2 == 0)
                {
                    Widgets.DrawAltRect(toggleRect);
                }

                // draw the toggle
                Utilities.DrawToggle(toggleRect, kind.LabelCap, _selected.AllowedAnimals[kind],
                                     delegate
                                     { _selected.AllowedAnimals[kind] = !_selected.AllowedAnimals[kind]; });

                // update current position
                cur.y += _entryHeight;
            }

            // close scrolling view
            Widgets.EndScrollView();

            // close animal list
            GUI.EndGroup();

            // do the button
            if (!_selected.Managed)
            {
                if (Widgets.ButtonText(buttonRect, "FM.Manage".Translate()))
                {
                    // activate job, add it to the stack
                    _selected.Managed = true;
                    Manager.For(manager).JobStack.Add(_selected);

                    // refresh source list
                    Refresh();
                }
            }
            else
            {
                if (Widgets.ButtonText(buttonRect, "FM.Delete".Translate()))
                {
                    // inactivate job, remove from the stack.
                    Manager.For(manager).JobStack.Delete(_selected);

                    // remove content from UI
                    _selected = null;

                    // refresh source list
                    Refresh();
                }
            }

            // close window
            GUI.EndGroup();
        }
        public override void DoWindowContents(Rect inRect)
        {
            var contentRect = new Rect(inRect);

            GUI.BeginGroup(contentRect);

            //TextAnchor oldAnchor = Text.Anchor;
            Text.Anchor = TextAnchor.MiddleLeft;
            Text.Font   = GameFont.Small;
            float x = 0;
            float y = 6;

            // All workstations
            var all      = new Rect(x, y, contentRect.width, 30f);
            var allLabel = new Rect(30f, y + 3f, contentRect.width - 30f, 27f);

            y += 30;

            if (Job.BillGivers.BillGiverSelection == AssignedBillGiverOptions.All)
            {
                Widgets.DrawMenuSection(all);
            }
            else
            {
                TooltipHandler.TipRegion(all, "FMP.AllWorkstationTooltip");
                if (Mouse.IsOver(all))
                {
                    GUI.DrawTexture(all, TexUI.HighlightTex);
                }
                if (Widgets.ButtonInvisible(all))
                {
                    Job.BillGivers.BillGiverSelection = AssignedBillGiverOptions.All;
                }
            }
            Widgets.RadioButton(new Vector2(all.xMin + 3f, all.yMin + 3f),
                                Job.BillGivers.BillGiverSelection == AssignedBillGiverOptions.All);
            Widgets.Label(allLabel, "FMP.AllWorkstations".Translate());
            y += 6;

            // By area / count
            var area      = new Rect(x, y, contentRect.width, 30f);
            var areaLabel = new Rect(30f, y + 3f, contentRect.width - 30f, 27f);

            y += 30f;

            if (Job.BillGivers.BillGiverSelection == AssignedBillGiverOptions.Count)
            {
                area.height += 60f;
                Widgets.DrawMenuSection(area);
                var areaAreaLabel    = new Rect(6f, y, 50f, 30f);
                var areaAreaSelector = new Rect(56f, y, contentRect.width - 56f, 30f);
                y += 30;
                var areaCountLabel    = new Rect(6f, y, 50f, 30f);
                var areaCountSelector = new Rect(56f, y, contentRect.width - 56f, 30f);
                y += 30;

                Widgets.Label(areaAreaLabel, "FMP.AllowedAreas".Translate());

                AreaAllowedGUI.DoAllowedAreaSelectors(areaAreaSelector, ref Job.BillGivers.AreaRestriction, Job.manager);

                Color oldColor = GUI.color;
                if (_input.IsInt())
                {
                    Job.BillGivers.UserBillGiverCount = int.Parse(_input);
                }
                else
                {
                    GUI.color = new Color(1f, 0f, 0f);
                }
                Widgets.Label(areaCountLabel, "FMP.AllowedWorkstationCount".Translate());
                _input    = Widgets.TextField(areaCountSelector, _input);
                GUI.color = oldColor;
            }
            else
            {
                TooltipHandler.TipRegion(area, "FMP.ByAreaAndCountTooltip");
                if (Mouse.IsOver(area))
                {
                    GUI.DrawTexture(area, TexUI.HighlightTex);
                }
                if (Widgets.ButtonInvisible(area))
                {
                    Job.BillGivers.BillGiverSelection = AssignedBillGiverOptions.Count;
                }
            }
            Widgets.Label(areaLabel, "FMP.ByAreaAndCount".Translate());
            Widgets.RadioButton(new Vector2(area.xMin + 3f, area.yMin + 3f),
                                Job.BillGivers.BillGiverSelection == AssignedBillGiverOptions.Count);
            y += 6f;

            // Specific billgivers
            // todo; add scrolling region.
            var specific      = new Rect(x, y, contentRect.width, 30f);
            var specificLabel = new Rect(36f, y, contentRect.width - 36f, 30f);

            y += 30;

            if (Job.BillGivers.BillGiverSelection == AssignedBillGiverOptions.Specific)
            {
                specific.height += 24f * Job.BillGivers.PotentialBillGivers.Count;

                Widgets.DrawMenuSection(specific, true);

                foreach (Building_WorkTable billgiver in Job.BillGivers.PotentialBillGivers)
                {
                    var row = new Rect(x, y, contentRect.width, 24f);
                    DrawRow(billgiver, row);
                    y += 24f;
                }
            }
            else
            {
                if (Mouse.IsOver(specific))
                {
                    GUI.DrawTexture(specific, TexUI.HighlightTex);
                }
                TooltipHandler.TipRegion(specific, "FMP.SpecificWorkstationsTooltip");
                if (Widgets.ButtonInvisible(specific))
                {
                    Job.BillGivers.BillGiverSelection = AssignedBillGiverOptions.Specific;
                }
            }

            Widgets.RadioButton(new Vector2(specific.xMin + 3f, specific.yMin + 3f),
                                Job.BillGivers.BillGiverSelection == AssignedBillGiverOptions.Specific);
            Widgets.Label(specificLabel, "FMP.SpecificWorkstations".Translate());

            Text.Anchor = TextAnchor.UpperLeft;
            GUI.EndGroup();
        }
Example #7
0
        private float DrawAreaRestrictionsSection(Vector2 pos, float width)
        {
            var start = pos;
            // restrict to area
            var restrictAreaRect = new Rect(pos.x, pos.y, width, ListEntryHeight);

            DrawToggle(restrictAreaRect,
                       "FML.RestrictToArea".Translate(),
                       "FML.RestrictToArea.Tip".Translate(),
                       ref _selectedCurrent.RestrictToArea);
            pos.y += ListEntryHeight;

            if (_selectedCurrent.RestrictToArea)
            {
                // area selectors table
                // set up a 3x3 table of rects
                var     cols    = 3;
                float   fifth   = width / 5;
                float[] widths  = { fifth, fifth * 2, fifth * 2 };
                float[] heights = { ListEntryHeight * 2 / 3, ListEntryHeight, ListEntryHeight };

                var areaRects = new Rect[cols, cols];
                for (var x = 0; x < cols; x++)
                {
                    for (var y = 0; y < cols; y++)
                    {
                        areaRects[x, y] = new Rect(
                            widths.Take(x).Sum(),
                            pos.y + heights.Take(y).Sum(),
                            widths[x],
                            heights[y]);
                    }
                }

                // headers
                Label(areaRects[1, 0], Gender.Female.ToString(), TextAnchor.LowerCenter, GameFont.Tiny);
                Label(areaRects[2, 0], Gender.Male.ToString(), TextAnchor.LowerCenter, GameFont.Tiny);
                Label(areaRects[0, 1], "FML.Adult".Translate(), TextAnchor.MiddleRight, GameFont.Tiny);
                Label(areaRects[0, 2], "FML.Juvenile".Translate(), TextAnchor.MiddleRight, GameFont.Tiny);

                // do the selectors
                _selectedCurrent.RestrictArea[0] = AreaAllowedGUI.DoAllowedAreaSelectors(areaRects[1, 1],
                                                                                         _selectedCurrent.RestrictArea[0], manager, Margin);
                _selectedCurrent.RestrictArea[1] = AreaAllowedGUI.DoAllowedAreaSelectors(areaRects[2, 1],
                                                                                         _selectedCurrent.RestrictArea[1], manager, Margin);
                _selectedCurrent.RestrictArea[2] = AreaAllowedGUI.DoAllowedAreaSelectors(areaRects[1, 2],
                                                                                         _selectedCurrent.RestrictArea[2], manager, Margin);
                _selectedCurrent.RestrictArea[3] = AreaAllowedGUI.DoAllowedAreaSelectors(areaRects[2, 2],
                                                                                         _selectedCurrent.RestrictArea[3], manager, Margin);

                Text.Anchor = TextAnchor.UpperLeft; // DoAllowedAreaMode leaves the anchor in an incorrect state.
                pos.y      += 3 * ListEntryHeight;
            }

            var sendToSlaughterAreaRect = new Rect(pos.x, pos.y, width, ListEntryHeight);

            pos.y += ListEntryHeight;
            if (_selectedCurrent.ButcherExcess)
            {
                DrawToggle(sendToSlaughterAreaRect,
                           "FML.SendToSlaughterArea".Translate(),
                           "FML.SendToSlaughterArea.Tip".Translate(),
                           ref _selectedCurrent.SendToSlaughterArea);

                if (_selectedCurrent.SendToSlaughterArea)
                {
                    var slaughterAreaRect = new Rect(pos.x, pos.y, width, ListEntryHeight);
                    AreaAllowedGUI.DoAllowedAreaSelectors(slaughterAreaRect, ref _selectedCurrent.SlaughterArea, manager);
                    pos.y += ListEntryHeight;
                }
            }
            else
            {
                sendToSlaughterAreaRect.xMin += Margin;
                Label(sendToSlaughterAreaRect, "FML.SendToSlaughterArea".Translate(),
                      "FM.Livestock.DisabledBecauseSlaughterExcessDisabled".Translate(), TextAnchor.MiddleLeft,
                      color: Color.grey);
            }

            var sendToTrainingAreaRect = new Rect(pos.x, pos.y, width, ListEntryHeight);

            pos.y += ListEntryHeight;
            if (_selectedCurrent.Training.Any)
            {
                DrawToggle(sendToTrainingAreaRect,
                           "FML.SendToTrainingArea".Translate(),
                           "FML.SendToTrainingArea.Tip".Translate(),
                           ref _selectedCurrent.SendToTrainingArea);

                if (_selectedCurrent.SendToTrainingArea)
                {
                    var trainingAreaRect = new Rect(pos.x, pos.y, width, ListEntryHeight);
                    AreaAllowedGUI.DoAllowedAreaSelectors(trainingAreaRect, ref _selectedCurrent.TrainingArea, manager);
                    pos.y += ListEntryHeight;
                }
            }
            else
            {
                sendToTrainingAreaRect.xMin += Margin;
                Label(sendToTrainingAreaRect, "FML.SendToTrainingArea".Translate(),
                      "FM.Livestock.DisabledBecauseNoTrainingSet".Translate(), TextAnchor.MiddleLeft,
                      color: Color.grey);
            }

            return(pos.y - start.y);
        }
        private void DoContent(Rect rect)
        {
            // cop out if nothing is selected.
            if (_selectedCurrent == null)
            {
                return;
            }

            // background
            Widgets.DrawMenuSection(rect);

            // begin window
            GUI.BeginGroup(rect);
            rect = rect.AtZero();

            // rects
            var optionsColumnRect = new Rect(Utilities.Margin / 2,
                                             _topAreaHeight,
                                             rect.width / 2 - Utilities.Margin,
                                             rect.height - _topAreaHeight - Utilities.Margin - Utilities.ButtonSize.y);
            var animalsRect = new Rect(optionsColumnRect.xMax + Utilities.Margin,
                                       _topAreaHeight,
                                       rect.width / 2 - Utilities.Margin,
                                       rect.height - _topAreaHeight - Utilities.Margin - Utilities.ButtonSize.y);

            var optionsColumnTitle = new Rect(optionsColumnRect.xMin,
                                              0f,
                                              optionsColumnRect.width,
                                              _topAreaHeight);
            var animalsColumnTitle = new Rect(animalsRect.xMin,
                                              0f,
                                              animalsRect.width,
                                              _topAreaHeight);

            // backgrounds
            GUI.DrawTexture(optionsColumnRect, Resources.SlightlyDarkBackground);
            GUI.DrawTexture(animalsRect, Resources.SlightlyDarkBackground);

            // titles
            Utilities.Label(optionsColumnTitle, "FMP.Options".Translate(),
                            anchor: TextAnchor.LowerLeft, lrMargin: Utilities.Margin * 2, font: GameFont.Tiny);
            Utilities.Label(animalsColumnTitle, "FML.Animals".Translate(),
                            anchor: TextAnchor.LowerLeft, lrMargin: Utilities.Margin * 2, font: GameFont.Tiny);

            // options
            GUI.BeginGroup(optionsColumnRect);
            Vector2 cur         = Vector2.zero;
            var     optionIndex = 1;

            // counts header
            Utilities.Label(ref cur, optionsColumnRect.width, _entryHeight, "FML.TargetCounts".Translate(),
                            alt: optionIndex % 2 == 0);

            // counts table
            var   cols  = 3;
            float fifth = optionsColumnRect.width / 5;

            float[] widths  = { fifth, fifth * 2, fifth * 2 };
            float[] heights = { _entryHeight / 3 * 2, _entryHeight, _entryHeight };

            // set up a 3x3 table of rects
            var countRects = new Rect[cols, cols];

            for (var x = 0; x < cols; x++)
            {
                for (var y = 0; y < cols; y++)
                {
                    // kindof overkill for a 3x3 table, but ok.
                    countRects[x, y] = new Rect(widths.Take(x).Sum(), cur.y + heights.Take(y).Sum(), widths[x],
                                                heights[y]);
                    if (optionIndex % 2 == 0)
                    {
                        Widgets.DrawAltRect(countRects[x, y]);
                    }
                }
            }

            optionIndex++;

            // headers
            Utilities.Label(countRects[1, 0], Gender.Female.ToString(), null, TextAnchor.LowerCenter,
                            font: GameFont.Tiny);
            Utilities.Label(countRects[2, 0], Gender.Male.ToString(), null, TextAnchor.LowerCenter, font: GameFont.Tiny);
            Utilities.Label(countRects[0, 1], "FML.Adult".Translate(), null, TextAnchor.MiddleRight,
                            font: GameFont.Tiny);
            Utilities.Label(countRects[0, 2], "FML.Juvenile".Translate(), null, TextAnchor.MiddleRight,
                            font: GameFont.Tiny);

            // fields
            DoCountField(countRects[1, 1], Utilities_Livestock.AgeAndSex.AdultFemale);
            DoCountField(countRects[2, 1], Utilities_Livestock.AgeAndSex.AdultMale);
            DoCountField(countRects[1, 2], Utilities_Livestock.AgeAndSex.JuvenileFemale);
            DoCountField(countRects[2, 2], Utilities_Livestock.AgeAndSex.JuvenileMale);
            cur.y += 3 * _entryHeight;

            // restrict to area
            var restrictAreaRect = new Rect(cur.x, cur.y, optionsColumnRect.width, _entryHeight);

            if (optionIndex % 2 == 0)
            {
                Widgets.DrawAltRect(restrictAreaRect);
            }
            Utilities.DrawToggle(restrictAreaRect, "FML.RestrictToArea".Translate(),
                                 ref _selectedCurrent.RestrictToArea);
            cur.y += _entryHeight;
            if (_selectedCurrent.RestrictToArea)
            {
                // area selectors table
                // set up a 3x3 table of rects
                var areaRects = new Rect[cols, cols];
                for (var x = 0; x < cols; x++)
                {
                    for (var y = 0; y < cols; y++)
                    {
                        // kindof overkill for a 3x3 table, but ok.
                        areaRects[x, y] = new Rect(widths.Take(x).Sum(), cur.y + heights.Take(y).Sum(), widths[x],
                                                   heights[y]);
                        if (optionIndex % 2 == 0)
                        {
                            Widgets.DrawAltRect(areaRects[x, y]);
                        }
                    }
                }

                // headers
                Utilities.Label(areaRects[1, 0], Gender.Female.ToString(), null, TextAnchor.LowerCenter,
                                font: GameFont.Tiny);
                Utilities.Label(areaRects[2, 0], Gender.Male.ToString(), null, TextAnchor.LowerCenter,
                                font: GameFont.Tiny);
                Utilities.Label(areaRects[0, 1], "FML.Adult".Translate(), null, TextAnchor.MiddleRight,
                                font: GameFont.Tiny);
                Utilities.Label(areaRects[0, 2], "FML.Juvenile".Translate(), null, TextAnchor.MiddleRight,
                                font: GameFont.Tiny);

                // do the selectors
                _selectedCurrent.RestrictArea[0] = AreaAllowedGUI.DoAllowedAreaSelectors(areaRects[1, 1],
                                                                                         _selectedCurrent.RestrictArea[
                                                                                             0
                                                                                         ],
                                                                                         manager,
                                                                                         AllowedAreaMode.Animal,
                                                                                         Utilities.Margin);
                _selectedCurrent.RestrictArea[1] = AreaAllowedGUI.DoAllowedAreaSelectors(areaRects[2, 1],
                                                                                         _selectedCurrent.RestrictArea[
                                                                                             1
                                                                                         ],
                                                                                         manager,
                                                                                         AllowedAreaMode.Animal,
                                                                                         Utilities.Margin);
                _selectedCurrent.RestrictArea[2] = AreaAllowedGUI.DoAllowedAreaSelectors(areaRects[1, 2],
                                                                                         _selectedCurrent.RestrictArea[
                                                                                             2
                                                                                         ],
                                                                                         manager,
                                                                                         AllowedAreaMode.Animal,
                                                                                         Utilities.Margin);
                _selectedCurrent.RestrictArea[3] = AreaAllowedGUI.DoAllowedAreaSelectors(areaRects[2, 2],
                                                                                         _selectedCurrent.RestrictArea[
                                                                                             3
                                                                                         ],
                                                                                         manager,
                                                                                         AllowedAreaMode.Animal,
                                                                                         Utilities.Margin);

                cur.y += 3 * _entryHeight;
            }

            optionIndex++;

            // train
            Utilities.Label(ref cur, optionsColumnRect.width, _entryHeight, "FML.Training".Translate(),
                            alt: optionIndex % 2 == 0);
            var trainingRect = new Rect(cur.x, cur.y, optionsColumnRect.width, _entryHeight);

            if (optionIndex++ % 2 == 0)
            {
                Widgets.DrawAltRect(trainingRect);
            }
            _selectedCurrent.DrawTrainingSelector(trainingRect, Utilities.Margin);
            cur.y += _entryHeight;

            if (_selectedCurrent.Training.Any)
            {
                var trainYoungRect = new Rect(cur.x, cur.y, optionsColumnRect.width, _entryHeight);
                if (optionIndex++ % 2 == 0)
                {
                    Widgets.DrawAltRect(trainYoungRect);
                }
                Utilities.DrawToggle(trainYoungRect, "FML.TrainYoung".Translate(),
                                     ref _selectedCurrent.Training.TrainYoung);
                cur.y += _entryHeight;
            }

            // butchery stuff
            var butcherExcessRect = new Rect(cur.x, cur.y, optionsColumnRect.width, _entryHeight);

            if (optionIndex++ % 2 == 0)
            {
                Widgets.DrawAltRect(butcherExcessRect);
            }
            Utilities.DrawToggle(butcherExcessRect, "FML.ButcherExcess".Translate(), ref _selectedCurrent.ButcherExcess);
            cur.y += _entryHeight;

            var butcherTrainedRect = new Rect(cur.x, cur.y, optionsColumnRect.width, _entryHeight);

            if (optionIndex++ % 2 == 0)
            {
                Widgets.DrawAltRect(butcherTrainedRect);
            }
            Utilities.DrawToggle(butcherTrainedRect, "FML.ButcherTrained".Translate(),
                                 ref _selectedCurrent.ButcherTrained);
            cur.y += _entryHeight;

            // try tame more?
            var tameMoreRect = new Rect(cur.x, cur.y, optionsColumnRect.width, _entryHeight);

            cur.y += _entryHeight;

            Utilities.DrawToggle(tameMoreRect, "FML.TameMore".Translate(), ref _selectedCurrent.TryTameMore);
            if (optionIndex % 2 == 0)
            {
                Widgets.DrawAltRect(tameMoreRect);
            }

            // area to train from (if taming more);
            if (_selectedCurrent.TryTameMore)
            {
                var tameAreaRect = new Rect(cur.x, cur.y, optionsColumnRect.width, _entryHeight);
                if (optionIndex % 2 == 0)
                {
                    Widgets.DrawAltRect(tameAreaRect);
                }
                cur.y += _entryHeight;
                var tameAreaSelectorRect = new Rect(cur.x, cur.y, optionsColumnRect.width, _entryHeight);
                if (optionIndex % 2 == 0)
                {
                    Widgets.DrawAltRect(tameAreaSelectorRect);
                }
                cur.y += _entryHeight;

                Utilities.Label(tameAreaRect, "FML.TameArea".Translate());
                AreaAllowedGUI.DoAllowedAreaSelectors(tameAreaSelectorRect, ref _selectedCurrent.TameArea, manager,
                                                      AllowedAreaMode.Any, Utilities.Margin);

                // why am I getting an error for not being at upperleft? Oh well, force it.
                Text.Anchor = TextAnchor.UpperLeft;
            }
            optionIndex++;

            GUI.EndGroup(); // options

            // Start animals list
            // get our pawnkind
            PawnKindDef pawnKind = _onCurrentTab ? _selectedCurrent.Trigger.pawnKind : _selectedAvailable;

            if (pawnKind != null)
            {
                Rect viewRect = animalsRect;
                viewRect.height = _actualHeight;
                if (_actualHeight > animalsRect.height)
                {
                    viewRect.width -= 16f;
                }

                Widgets.BeginScrollView(animalsRect, ref _animalsScrollPosition, viewRect);
                GUI.BeginGroup(viewRect);
                cur = Vector2.zero;

                // tamed animals
                DrawAnimalListheader(ref cur, new Vector2(viewRect.width, _entryHeight / 3 * 2), pawnKind,
                                     "FML.Tame".Translate().CapitalizeFirst());
                List <Pawn> tame = pawnKind.GetTame(manager);
                if (tame.Count == 0)
                {
                    Utilities.Label(ref cur, viewRect.width, _entryHeight,
                                    "FML.NoAnimals".Translate("FML.Tame".Translate()),
                                    anchor: TextAnchor.MiddleCenter, color: Color.grey);
                }
                for (var i = 0; i < tame.Count; i++)
                {
                    DrawAnimalRow(ref cur, new Vector2(viewRect.width, _entryHeight), tame[i], i % 2 == 0);
                }

                cur.y += _entryHeight;

                // wild animals
                DrawAnimalListheader(ref cur, new Vector2(viewRect.width, _entryHeight / 3 * 2), pawnKind,
                                     "FML.Wild".Translate().CapitalizeFirst());
                List <Pawn> wild = pawnKind.GetWild(manager);
                if (wild.Count == 0)
                {
                    Utilities.Label(ref cur, viewRect.width, _entryHeight,
                                    "FML.NoAnimals".Translate("FML.Wild".Translate()), null, TextAnchor.MiddleCenter,
                                    color: Color.grey);
                }
                for (var i = 0; i < wild.Count; i++)
                {
                    DrawAnimalRow(ref cur, new Vector2(animalsRect.width, _entryHeight), wild[i], i % 2 == 0);
                }

                // update list height
                _actualHeight = cur.y;

                GUI.EndGroup(); // animals
                Widgets.EndScrollView();
            }

            // bottom button
            var buttonRect = new Rect(rect.xMax - Utilities.ButtonSize.x, rect.yMax - Utilities.ButtonSize.y,
                                      Utilities.ButtonSize.x - Utilities.Margin,
                                      Utilities.ButtonSize.y - Utilities.Margin);

            // add / remove to the stack
            if (_selectedCurrent.Managed)
            {
                if (Widgets.ButtonText(buttonRect, "FM.Delete".Translate()))
                {
                    _selectedCurrent.Delete();
                    _selectedCurrent = null;
                    _onCurrentTab    = false;
                    Refresh();
                    return; // just skip to the next tick to avoid null reference errors.
                }

                TooltipHandler.TipRegion(buttonRect, "FMP.DeleteBillTooltip".Translate());
            }
            else
            {
                if (Widgets.ButtonText(buttonRect, "FM.Manage".Translate()))
                {
                    _selectedCurrent.Managed = true;
                    _onCurrentTab            = true;
                    Manager.For(manager).JobStack.Add(_selectedCurrent);
                    Refresh();
                }
                TooltipHandler.TipRegion(buttonRect, "FMP.ManageBillTooltip".Translate());
            }

            GUI.EndGroup(); // window
        }