示例#1
0
        private void DoContent(Rect rect)
        {
            // background
            Widgets.DrawMenuSection(rect);

            // cop out if nothing is selected.
            if (_selectedCurrent == null)
            {
                Label(rect, "FM.Livestock.SelectPawnKind".Translate(), TextAnchor.MiddleCenter);
                return;
            }

            // rects
            var optionsColumnRect = new Rect(
                rect.xMin,
                rect.yMin,
                rect.width * 3 / 5f,
                rect.height - Margin - ButtonSize.y);
            var animalsColumnRect = new Rect(
                optionsColumnRect.xMax,
                rect.yMin,
                rect.width * 2 / 5f,
                rect.height - Margin - ButtonSize.y);
            var buttonRect = new Rect(
                rect.xMax - ButtonSize.x,
                rect.yMax - ButtonSize.y,
                ButtonSize.x - Margin,
                ButtonSize.y - Margin);

            Vector2 position;
            float   width;

            Widgets_Section.BeginSectionColumn(optionsColumnRect, "Livestock.Options", out position, out width);

            Widgets_Section.Section(ref position, width, DrawTargetCountsSection, "FM.Livestock.TargetCountsHeader".Translate());
            Widgets_Section.Section(ref position, width, DrawTamingSection, "FM.Livestock.TamingHeader".Translate());
            Widgets_Section.Section(ref position, width, DrawButcherSection, "FM.Livestock.ButcherHeader".Translate());
            Widgets_Section.Section(ref position, width, DrawTrainingSection, "FM.Livestock.TrainingHeader".Translate());
            Widgets_Section.Section(ref position, width, DrawAreaRestrictionsSection, "FM.Livestock.AreaRestrictionsHeader".Translate());
            Widgets_Section.Section(ref position, width, DrawFollowSection, "FM.Livestock.FollowHeader".Translate());

            Widgets_Section.EndSectionColumn("Livestock.Options", position);

            // Start animals list
            // get our pawnkind
            Widgets_Section.BeginSectionColumn(animalsColumnRect, "Livestock.Animals", out position, out width);

            Widgets_Section.Section(ref position, width, DrawTamedAnimalSection, "FM.Livestock.AnimalsHeader".Translate("FML.Tame".Translate(), _selectedCurrent.Trigger.pawnKind.GetLabelPlural()).CapitalizeFirst());
            Widgets_Section.Section(ref position, width, DrawWildAnimalSection, "FM.Livestock.AnimalsHeader".Translate("FML.Wild".Translate(), _selectedCurrent.Trigger.pawnKind.GetLabelPlural()).CapitalizeFirst());

            Widgets_Section.EndSectionColumn("Livestock.Animals", position);


            // 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());
            }
        }
        public void DoContent(Rect rect)
        {
            // layout: settings | trees
            // draw background
            Widgets.DrawMenuSection(rect);

            // rects
            var optionsColumnRect = new Rect(
                rect.xMin,
                rect.yMin,
                rect.width * 3 / 5f,
                rect.height - Margin - ButtonSize.y);
            var plantsColumnRect = new Rect(
                optionsColumnRect.xMax,
                rect.yMin,
                rect.width * 2 / 5f,
                rect.height - Margin - ButtonSize.y);
            var buttonRect = new Rect(
                rect.xMax - ButtonSize.x,
                rect.yMax - ButtonSize.y,
                ButtonSize.x - Margin,
                ButtonSize.y - Margin);

            Vector2 position;
            float   width;

            Widgets_Section.BeginSectionColumn(optionsColumnRect, "Foraging.Options", out position, out width);
            Widgets_Section.Section(ref position, width, DrawThreshold, "FM.Threshold".Translate());
            Widgets_Section.Section(ref position, width, DrawAreaRestriction, "FMG.ForagingArea".Translate());
            Widgets_Section.Section(ref position, width, DrawMaturePlants);
            Widgets_Section.EndSectionColumn("Foraging.Options", position);

            Widgets_Section.BeginSectionColumn(plantsColumnRect, "Foraging.Plants", out position, out width);
            var refreshRect = new Rect(
                position.x + width - SmallIconSize - 2 * Margin,
                position.y + Margin,
                SmallIconSize,
                SmallIconSize);

            if (Widgets.ButtonImage(refreshRect, Resources.Refresh, Color.grey))
            {
                _selected.RefreshAllowedPlants();
            }
            Widgets_Section.Section(ref position, width, DrawPlantShortcuts, "FMG.Plants".Translate());
            Widgets_Section.Section(ref position, width, DrawPlantList);
            Widgets_Section.EndSectionColumn("Foraging.Plants", position);


            // 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();
                }
            }
        }
        public void DoContent(Rect rect)
        {
            // layout: settings | trees
            // draw background
            Widgets.DrawMenuSection(rect);


            // rects
            var optionsColumnRect = new Rect(
                rect.xMin,
                rect.yMin,
                rect.width * 3 / 5f,
                rect.height - Margin - ButtonSize.y);
            var treesColumnRect = new Rect(
                optionsColumnRect.xMax,
                rect.yMin,
                rect.width * 2 / 5f,
                rect.height - Margin - ButtonSize.y);
            var buttonRect = new Rect(
                rect.xMax - ButtonSize.x,
                rect.yMax - ButtonSize.y,
                ButtonSize.x - Margin,
                ButtonSize.y - Margin);

            Vector2 position;
            float   width;

            Widgets_Section.BeginSectionColumn(optionsColumnRect, "Forestry.Options", out position, out width);
            Widgets_Section.Section(ref position, width, DrawJobType, "FMF.JobType".Translate());

            if (_selected.Type == ManagerJob_Forestry.ForestryJobType.ClearArea)
            {
                Widgets_Section.Section(ref position, width, DrawClearArea, "FMF.JobType.ClearArea".Translate());
            }

            if (_selected.Type == ManagerJob_Forestry.ForestryJobType.Logging)
            {
                Widgets_Section.Section(ref position, width, DrawThreshold, "FM.Threshold".Translate());
                Widgets_Section.Section(ref position, width, DrawAreaRestriction, "FMF.LoggingArea".Translate());
                Widgets_Section.Section(ref position, width, DrawAllowSaplings);
            }
            Widgets_Section.EndSectionColumn("Forestry.Options", position);

            Widgets_Section.BeginSectionColumn(treesColumnRect, "Forestry.Trees", out position, out width);
            Widgets_Section.Section(ref position, width, DrawTreeShortcuts, "FMF.Trees".Translate());
            Widgets_Section.Section(ref position, width, DrawTreeList);
            Widgets_Section.EndSectionColumn("Forestry.Trees", position);

            // 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();
                }
            }
        }