public Trigger_Threshold( ManagerJob_Forestry job )
     : base(job.manager)
 {
     Op = Ops.LowerThan;
     MaxUpperThreshold = DefaultMaxUpperThreshold;
     Count = DefaultCount;
     ThresholdFilter = new ThingFilter();
     ThresholdFilter.SetDisallowAll();
     ThresholdFilter.SetAllow( Utilities_Forestry.Wood, true );
 }
Ejemplo n.º 2
0
 public ManagerTab_Forestry(Manager manager) : base(manager)
 {
     _selected = new ManagerJob_Forestry(manager);
 }
Ejemplo n.º 3
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;
            int cols = 2;
            float colWidth = width / cols - Margin;
            List<Rect> colRects = new List<Rect>();
            List<Rect> colTitleRects = new List<Rect>();
            Rect buttonRect = new Rect( rect.width - _button.x, rect.height - _button.y, _button.x - Margin,
                                        _button.y - Margin );

            // set up rects
            for ( int 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;

            // target count (1)
            Rect targetCountTitleRect = new Rect( cur.x, cur.y, colWidth, EntryHeight );
            int currentCount = _selected.Trigger.CurCount;
            int designatedCount = _selected.GetWoodInDesignations();
            int targetCount = _selected.Trigger.Count;
            Widgets.DrawAltRect( targetCountTitleRect );
            Utilities.Label( targetCountTitleRect,
                             "FMF.TargetCount".Translate( currentCount, designatedCount, targetCount ),
                             "FMF.TargetCountTooltip".Translate( currentCount, designatedCount, targetCount ),
                             TextAnchor.MiddleLeft, Margin );
            cur.y += EntryHeight;

            Rect targetCountRect = new Rect( cur.x, cur.y, colWidth, Utilities.SliderHeight );
            Widgets.DrawAltRect( targetCountRect );
            _selected.Trigger.Count = (int)GUI.HorizontalSlider( targetCountRect, _selected.Trigger.Count, 0, 2000 );
            cur.y += Utilities.SliderHeight;

            // Clear wind cells (2)
            Rect clearWindCellsRect = new Rect( cur.x, cur.y, colWidth, EntryHeight );
            Utilities.DrawToggle( clearWindCellsRect, "FMF.ClearWindCells".Translate(), ref ManagerJob_Forestry.ClearWindCells );
            cur.y += EntryHeight;

            // Allow saplings (3)
            Rect allowSaplingsRect = new Rect( cur.x, cur.y, colWidth, EntryHeight );
            Widgets.DrawAltRect( allowSaplingsRect );
            Utilities.DrawToggle( allowSaplingsRect, "FMF.AllowSaplings".Translate(), ref _selected.AllowSaplings );
            cur.y += EntryHeight;

            // Logging area (4)
            Rect loggingAreaTitleRect = new Rect( cur.x, cur.y, colWidth, EntryHeight );
            Utilities.Label( loggingAreaTitleRect, "FMF.LoggingArea".Translate(), anchor: TextAnchor.MiddleLeft,
                             lrMargin: Margin );
            cur.y += EntryHeight;

            Rect loggingAreaRect = new Rect( cur.x + Margin, cur.y, colWidth - 2 * Margin, EntryHeight );
            AreaAllowedGUI.DoAllowedAreaSelectors( loggingAreaRect, ref _selected.LoggingArea );
            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 );
            Rect 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 _animalsScrollPosition, viewRect );

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

            // toggle all
            Rect 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
            int i = 1;

            foreach ( ThingDef def in treeDefs )
            {
                Rect 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.TextButton( buttonRect, "FM.Manage".Translate() ) )
                {
                    // activate job, add it to the stack
                    _selected.Managed = true;
                    Manager.Get.JobStack.Add( _selected );

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

                    // remove content from UI
                    _selected = null;

                    // refresh source list
                    Refresh();
                }
            }

            // close window
            GUI.EndGroup();
        }
Ejemplo n.º 4
0
        public void DoLeftRow( Rect rect )
        {
            Widgets.DrawMenuSection( rect );

            // content
            float height = _leftRowHeight;
            Rect 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;
            int i = 0;

            foreach ( ManagerJob_Forestry job in _jobs )
            {
                Rect 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 ), job ) )
                {
                    Refresh();
                }
                jobRect.width -= 50f;

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

                cur.y += Utilities.LargeListEntryHeight;
            }

            // row for new job.
            Rect 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, "<" + "FMF.NewForestryJob".Translate() + ">" );
            Text.Anchor = TextAnchor.UpperLeft;

            if ( Widgets.InvisibleButton( newRect ) )
            {
                Selected = new ManagerJob_Forestry();
            }

            TooltipHandler.TipRegion( newRect, "FMF.NewForestryJobTooltip".Translate() );

            cur.y += Utilities.LargeListEntryHeight;

            _leftRowHeight = cur.y;
            GUI.EndGroup();
            Widgets.EndScrollView();
        }
Ejemplo n.º 5
0
        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();
                }
            }
        }
Ejemplo n.º 6
0
        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_Forestry 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, "<" + "FMF.NewForestryJob".Translate() + ">");
            Text.Anchor = TextAnchor.UpperLeft;

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

            TooltipHandler.TipRegion(newRect, "FMF.NewForestryJobTooltip".Translate());

            cur.y += LargeListEntryHeight;

            _leftRowHeight = cur.y;
            GUI.EndGroup();
            Widgets.EndScrollView();
        }