public Trigger_Threshold(ManagerJob_Foraging job) : base(job.manager)
 {
     Op = Ops.LowerThan;
     MaxUpperThreshold = DefaultMaxUpperThreshold;
     TargetCount       = DefaultCount;
     ThresholdFilter   = new ThingFilter();
     ThresholdFilter.SetDisallowAll();
 }
 public Trigger_Threshold( ManagerJob_Foraging job )
     : base(job.manager)
 {
     Op = Ops.LowerThan;
     MaxUpperThreshold = DefaultMaxUpperThreshold;
     Count = DefaultCount;
     ThresholdFilter = new ThingFilter();
     ThresholdFilter.SetDisallowAll();
 }
 public ManagerTab_Foraging(Manager manager) : base(manager)
 {
     _selected = new ManagerJob_Foraging(manager);
 }
        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 DoLeftRow(Rect rect)
        {
            Widgets.DrawMenuSection(rect);

            // content
            float height     = _leftRowHeight;
            var   scrollView = new Rect(0f, 0f, rect.width, height);

            if (height > rect.height)
            {
                scrollView.width -= ScrollbarWidth;
            }

            Widgets.BeginScrollView(rect, ref _scrollPosition, scrollView);
            Rect scrollContent = scrollView;

            GUI.BeginGroup(scrollContent);
            Vector2 cur = Vector2.zero;
            var     i   = 0;

            foreach (ManagerJob_Foraging job in _jobs)
            {
                var row = new Rect(0f, cur.y, scrollContent.width, LargeListEntryHeight);
                Widgets.DrawHighlightIfMouseover(row);
                if (_selected == job)
                {
                    Widgets.DrawHighlightSelected(row);
                }

                if (i++ % 2 == 1)
                {
                    Widgets.DrawAltRect(row);
                }

                Rect jobRect = row;

                if (ManagerTab_Overview.DrawOrderButtons(new Rect(row.xMax - 50f, row.yMin, 50f, 50f), manager, job))
                {
                    Refresh();
                }
                jobRect.width -= 50f;

                job.DrawListEntry(jobRect, false);
                if (Widgets.ButtonInvisible(jobRect))
                {
                    _selected = job;
                }

                cur.y += LargeListEntryHeight;
            }

            // row for new job.
            var newRect = new Rect(0f, cur.y, scrollContent.width, LargeListEntryHeight);

            Widgets.DrawHighlightIfMouseover(newRect);

            if (i % 2 == 1)
            {
                Widgets.DrawAltRect(newRect);
            }

            Text.Anchor = TextAnchor.MiddleCenter;
            Widgets.Label(newRect, "<" + "FMG.NewForagingJob".Translate() + ">");
            Text.Anchor = TextAnchor.UpperLeft;

            if (Widgets.ButtonInvisible(newRect))
            {
                Selected = new ManagerJob_Foraging(manager);
            }

            TooltipHandler.TipRegion(newRect, "FMG.NewForagingJobTooltip".Translate());

            cur.y += LargeListEntryHeight;

            _leftRowHeight = cur.y;
            GUI.EndGroup();
            Widgets.EndScrollView();
        }
        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], "FMG.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.CurrentDesignatedCount;
            int targetCount = _selected.Trigger.Count;
            _selected.Trigger.DrawTriggerConfig( ref cur, colRects[0].width, EntryHeight, true,
                                                 "FMG.TargetCount".Translate( currentCount, designatedCount, targetCount ),
                                                 "FMG.TargetCountTooltip".Translate( currentCount, designatedCount,
                                                                                     targetCount ) );

            // Force mature plants only (2)
            var forceMatureRect = new Rect( cur.x, cur.y, colWidth, EntryHeight );
            Utilities.DrawToggle( forceMatureRect, "FMG.ForceMature".Translate(), ref _selected.ForceFullyMature );
            cur.y += EntryHeight;

            // Foraging area (3)
            var foragingAreaTitleRect = new Rect( cur.x, cur.y, colWidth, EntryHeight );
            Widgets.DrawAltRect( foragingAreaTitleRect );
            Utilities.Label( foragingAreaTitleRect, "FMG.ForagingArea".Translate(), anchor: TextAnchor.MiddleLeft,
                             lrMargin: Margin );
            cur.y += EntryHeight;

            var foragingAreaRect = new Rect( cur.x, cur.y, colWidth, EntryHeight );
            Widgets.DrawAltRect( foragingAreaRect );
            AreaAllowedGUI.DoAllowedAreaSelectors( foragingAreaRect, ref _selected.ForagingArea, manager, lrMargin: Margin );
            cur.y += EntryHeight;

            GUI.EndGroup();

            // plantdefs.
            Text.Anchor = TextAnchor.LowerLeft;
            Text.Font = GameFont.Tiny;
            Widgets.Label( colTitleRects[1], "FMG.Plants".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.AllowedPlants.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 plantDefs = new List<ThingDef>( _selected.AllowedPlants.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.AllowedPlants.Values.All( v => v ), delegate
                                                                                    {
                                                                                        foreach (
                                                                                            ThingDef def in plantDefs )
                                                                                        {
                                                                                            _selected.AllowedPlants[def]
                                                                                                = true;
                                                                                        }
                                                                                    }, delegate
                                                                                           {
                                                                                               foreach (
                                                                                                   ThingDef def in
                                                                                                       plantDefs )
                                                                                               {
                                                                                                   _selected
                                                                                                       .AllowedPlants[
                                                                                                                      def
                                                                                                       ] = false;
                                                                                               }
                                                                                           } );

            cur.y += EntryHeight;

            // toggle for each plant
            var i = 1;

            foreach ( ThingDef def in plantDefs )
            {
                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.AllowedPlants[def],
                                      delegate { _selected.AllowedPlants[def] = !_selected.AllowedPlants[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 ManagerTab_Foraging( Manager manager )
     : base(manager)
 {
     _selected = new ManagerJob_Foraging( manager );
 }
        public void DoLeftRow( Rect rect )
        {
            Widgets.DrawMenuSection( rect );

            // content
            float height = _leftRowHeight;
            var scrollView = new Rect( 0f, 0f, rect.width, height );
            if ( height > rect.height )
            {
                scrollView.width -= 16f;
            }

            Widgets.BeginScrollView( rect, ref _scrollPosition, scrollView );
            Rect scrollContent = scrollView;

            GUI.BeginGroup( scrollContent );
            Vector2 cur = Vector2.zero;
            var i = 0;

            foreach ( ManagerJob_Foraging job in _jobs )
            {
                var row = new Rect( 0f, cur.y, scrollContent.width, Utilities.LargeListEntryHeight );
                Widgets.DrawHighlightIfMouseover( row );
                if ( _selected == job )
                {
                    Widgets.DrawHighlightSelected( row );
                }

                if ( i++ % 2 == 1 )
                {
                    Widgets.DrawAltRect( row );
                }

                Rect jobRect = row;

                if ( ManagerTab_Overview.DrawOrderButtons( new Rect( row.xMax - 50f, row.yMin, 50f, 50f ), manager, job ) )
                {
                    Refresh();
                }
                jobRect.width -= 50f;

                job.DrawListEntry( jobRect, false );
                if ( Widgets.ButtonInvisible( jobRect ) )
                {
                    _selected = job;
                }

                cur.y += Utilities.LargeListEntryHeight;
            }

            // row for new job.
            var newRect = new Rect( 0f, cur.y, scrollContent.width, Utilities.LargeListEntryHeight );
            Widgets.DrawHighlightIfMouseover( newRect );

            if ( i % 2 == 1 )
            {
                Widgets.DrawAltRect( newRect );
            }

            Text.Anchor = TextAnchor.MiddleCenter;
            Widgets.Label( newRect, "<" + "FMG.NewForagingJob".Translate() + ">" );
            Text.Anchor = TextAnchor.UpperLeft;

            if ( Widgets.ButtonInvisible( newRect ) )
            {
                Selected = new ManagerJob_Foraging( manager );
            }

            TooltipHandler.TipRegion( newRect, "FMG.NewForagingJobTooltip".Translate() );

            cur.y += Utilities.LargeListEntryHeight;

            _leftRowHeight = cur.y;
            GUI.EndGroup();
            Widgets.EndScrollView();
        }
Example #9
0
        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], "FMG.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.CurrentDesignatedCount;
            int targetCount     = _selected.Trigger.Count;

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

            // Force mature plants only (2)
            var forceMatureRect = new Rect(cur.x, cur.y, colWidth, EntryHeight);

            Utilities.DrawToggle(forceMatureRect, "FMG.ForceMature".Translate(), ref _selected.ForceFullyMature);
            cur.y += EntryHeight;

            // Foraging area (3)
            var foragingAreaTitleRect = new Rect(cur.x, cur.y, colWidth, EntryHeight);

            Widgets.DrawAltRect(foragingAreaTitleRect);
            Utilities.Label(foragingAreaTitleRect, "FMG.ForagingArea".Translate(), anchor: TextAnchor.MiddleLeft,
                            lrMargin: Margin);
            cur.y += EntryHeight;

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

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

            GUI.EndGroup();

            // plantdefs.
            Text.Anchor = TextAnchor.LowerLeft;
            Text.Font   = GameFont.Tiny;
            Widgets.Label(colTitleRects[1], "FMG.Plants".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.AllowedPlants.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 plantDefs = new List <ThingDef>(_selected.AllowedPlants.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.AllowedPlants.Values.All(v => v), delegate
            {
                foreach (
                    ThingDef def in plantDefs)
                {
                    _selected.AllowedPlants[def]
                        = true;
                }
            }, delegate
            {
                foreach (
                    ThingDef def in
                    plantDefs)
                {
                    _selected
                    .AllowedPlants[
                        def
                    ] = false;
                }
            });

            cur.y += EntryHeight;

            // toggle for each plant
            var i = 1;

            foreach (ThingDef def in plantDefs)
            {
                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.AllowedPlants[def],
                                     delegate
                                     { _selected.AllowedPlants[def] = !_selected.AllowedPlants[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();
        }