protected override void FillWindow(Rect inRect) { Vector2 vector = new Vector2(inRect.width - 16f, 36f); Vector2 vector2 = new Vector2(100f, vector.y - 2f); inRect.height -= 45f; float num = vector.y + 3f; List<FileInfo> list = BlueprintFiles.AllFiles.ToList(); float height = (float)list.Count * num; Rect viewRect = new Rect(0f, 0f, inRect.width - 16f, height); Rect outRect = new Rect(inRect.AtZero()); outRect.height -= this.bottomAreaHeight; Widgets.BeginScrollView(outRect, ref this.scrollPosition, viewRect); float num2 = 0f; int num3 = 0; foreach (FileInfo current in list) { Rect rect = new Rect(0f, num2, vector.x, vector.y); if (num3 % 2 == 0) { Widgets.DrawAltRect(rect); } Rect position = rect.ContractedBy(1f); GUI.BeginGroup(position); string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(current.Name); GUI.color = Dialog_Blueprint.ManualSaveTextColor; Rect rect2 = new Rect(15f, 0f, position.width, position.height); Text.Anchor = TextAnchor.MiddleLeft; Text.Font = GameFont.Small; Widgets.Label(rect2, fileNameWithoutExtension); GUI.color = Color.white; Rect rect3 = new Rect(270f, 0f, 200f, position.height); GUI.color = Color.white; Text.Anchor = TextAnchor.UpperLeft; Text.Font = GameFont.Small; float num4 = vector.x - 2f - vector2.x - vector2.y; Rect rect4 = new Rect(num4, 0f, vector2.x, vector2.y); if (Widgets.TextButton(rect4, this.interactButLabel, true, false)) { this.DoMapEntryInteraction(Path.GetFileNameWithoutExtension(current.Name)); } Rect rect5 = new Rect(num4 + vector2.x + 5f, 0f, vector2.y, vector2.y); if (Widgets.ImageButton(rect5, TexButton.DeleteX)) { FileInfo localFile = current; Find.LayerStack.Add(new Dialog_Confirm("ConfirmDelete".Translate(new object[] { fileNameWithoutExtension }), delegate { localFile.Delete(); }, true)); } TooltipHandler.TipRegion(rect5, "DeleteThisSavegame".Translate()); GUI.EndGroup(); num2 += vector.y + 3f; num3++; } Widgets.EndScrollView(); this.DoSpecialSaveLoadGUI(inRect.AtZero()); }
public override void DoWindowContents( Rect inRect ) { // set up rects var titleRect = new Rect( inRect.xMin, inRect.yMin, inRect.width, Utilities.TitleHeight ); var listRect = new Rect( inRect.xMin, titleRect.yMax, inRect.width, inRect.height - Utilities.TitleHeight - Utilities.BottomButtonHeight ); var buttonRect = new Rect( inRect.xMax - 200f, listRect.yMax + Utilities.Margin, 200f, Utilities.BottomButtonHeight - Utilities.Margin ); // title Utilities.Label( titleRect, "FMP.IngredientDialogTitle".Translate(), null, TextAnchor.MiddleCenter, 0f, 0f, GameFont.Medium ); // start recursive list of ingredients Rect viewRect = listRect.AtZero(); viewRect.height = _finalListHeight; if ( _finalListHeight > listRect.height ) { viewRect.width -= 20f; // scrollbar } Widgets.DrawMenuSection( listRect ); Widgets.BeginScrollView( listRect, ref _scrollPosition, viewRect ); GUI.BeginGroup( viewRect ); Vector2 cur = Vector2.zero; foreach ( IngredientSelector ingredient in ingredients ) { // each selector row draws it's own children recursively. ingredient.DrawSelectorRow( ref cur, inRect.width, 0, Vector2.zero ); } GUI.EndGroup(); Widgets.EndScrollView(); _finalListHeight = cur.y + _entryHeight; // final button if ( Widgets.ButtonText( buttonRect, "FMP.AddIngredientBills".Translate() ) ) { foreach ( IngredientSelector ingredient in ingredients ) { ingredient.AddBills(); } // we've probably added some bills, so refresh the tab. manager.ManagerTabs.OfType<ManagerTab_Production>().FirstOrDefault()?.Refresh(); // close this window. this.Close(); } }
public void DoContent( Rect canvas ) { Widgets.DrawMenuSection( canvas ); GUI.BeginGroup( canvas ); canvas = canvas.AtZero(); if ( _selected != null ) { // bottom buttons Rect buttonRect = new Rect( canvas.xMax - _button.x, canvas.yMax - _button.y, _button.x - _margin, _button.y - _margin ); Rect ingredientCheck = new Rect( buttonRect.xMin - 300f - _margin, buttonRect.yMin, 300f, buttonRect.height ); // add / remove to the stack if ( Source == SourceOptions.Current ) { if ( Widgets.TextButton( buttonRect, "FM.Delete".Translate() ) ) { _selected.Delete(); _selected = null; Refresh(); return; // just skip to the next tick to avoid null reference errors. } TooltipHandler.TipRegion( buttonRect, "FMP.DeleteBillTooltip".Translate() ); } else { if ( _selected.Trigger.IsValid ) { Widgets.LabelCheckbox(ingredientCheck, "FMP.IngredientDialogTitle".Translate(), ref _selected._createIngredientBills, !_selected._hasMeaningfulIngredientChoices); if ( Widgets.TextButton( buttonRect, "FM.Manage".Translate() ) ) { _selected.Managed = true; Manager.Get.JobStack.Add( _selected ); // refresh source list so that the next added job is not an exact copy. Refresh(); if ( _selected._hasMeaningfulIngredientChoices && _selected._createIngredientBills ) { Find.WindowStack.Add( new Dialog_CreateJobsForIngredients( _selected.Bill.recipe, _selected.Trigger.Count ) ); } Source = SourceOptions.Current; Refresh(); SourceFilter = ""; } TooltipHandler.TipRegion( buttonRect, "FMP.ManageBillTooltip".Translate() ); } else { GUI.color = new Color( .6f, .6f, .6f ); Widgets.DrawBox( buttonRect ); Utilities.Label( buttonRect, "FMP.NoThreshold".Translate(), "FMP.NoThresholdTooltip".Translate(), TextAnchor.MiddleCenter ); GUI.color = Color.white; } } // options Rect optionsColumnRect = new Rect( _margin / 2, _topAreaHeight, canvas.width / 2 - _margin, canvas.height - _topAreaHeight - _margin - _button.y ); Rect recipeColumnRect = new Rect( optionsColumnRect.xMax + _margin, _topAreaHeight, canvas.width / 2 - _margin, canvas.height - _topAreaHeight - _margin - _button.y ); Rect optionsColumnTitle = new Rect( optionsColumnRect.xMin, 0f, optionsColumnRect.width, _topAreaHeight ); Rect recipeColumnTitle = new Rect( recipeColumnRect.xMin, 0f, recipeColumnRect.width, _topAreaHeight ); // backgrounds GUI.DrawTexture( optionsColumnRect, Resources.SlightlyDarkBackground ); GUI.DrawTexture( recipeColumnRect, Resources.SlightlyDarkBackground ); // titles Utilities.Label( optionsColumnTitle, "FMP.Options".Translate(), anchor: TextAnchor.LowerLeft, lrMargin: _margin * 2, font: GameFont.Tiny ); Utilities.Label( recipeColumnTitle, "FMP.Recipe".Translate(), anchor: TextAnchor.LowerLeft, lrMargin: _margin * 2, font: GameFont.Tiny ); // options GUI.BeginGroup( optionsColumnRect ); Vector2 cur = Vector2.zero; float width = optionsColumnRect.width; // keep track of optionIndex for shading purposes (lazy way to avoid having to redo this all the damn time). int optionindex = 0; // suspended Rect suspendedRect = new Rect( cur.x, cur.y, width, _entryHeight ); if (optionindex++ % 2 == 0) Widgets.DrawAltRect( suspendedRect ); Utilities.DrawToggle( suspendedRect, "Suspended".Translate(), _selected.Suspended, delegate { _selected.Suspended = !_selected.Suspended; } ); cur.y += _entryHeight; // store mode Rect takeToStockRect = new Rect( cur.x, cur.y, width, _entryHeight ); if( optionindex++ % 2 == 0 ) Widgets.DrawAltRect( takeToStockRect ); Utilities.DrawToggle( takeToStockRect, "BillStoreMode_BestStockpile".Translate(), _selected.Bill.storeMode == BillStoreMode.BestStockpile, delegate { _selected.Bill.storeMode = BillStoreMode.BestStockpile; }, delegate { _selected.Bill.storeMode = BillStoreMode.DropOnFloor; } ); cur.y += _entryHeight; // ingredient search radius (3) Rect searchRadiusLabelRect = new Rect( cur.x, cur.y, width, _entryHeight ); if( optionindex % 2 == 0 ) Widgets.DrawAltRect( searchRadiusLabelRect ); Utilities.Label( searchRadiusLabelRect, "IngredientSearchRadius".Translate() + ": " + _selected.Bill.ingredientSearchRadius.ToString( " #####0" ), anchor: TextAnchor.MiddleLeft, lrMargin: _margin ); cur.y += _entryHeight; Rect searchRadiusRect = new Rect( cur.x, cur.y, width, Utilities.SliderHeight ); if( optionindex++ % 2 == 0 ) Widgets.DrawAltRect( searchRadiusRect ); _selected.Bill.ingredientSearchRadius = (int)GUI.HorizontalSlider( searchRadiusRect, _selected.Bill.ingredientSearchRadius, 0f, 250f ); cur.y += Utilities.SliderHeight; // prioritize over manually set jobs (4) Rect prioritizeRect = new Rect( cur.x, cur.y, width, _entryHeight ); if( optionindex++ % 2 == 0 ) Widgets.DrawAltRect( prioritizeRect ); Utilities.DrawToggle(prioritizeRect, "FMP.PrioritizeManual".Translate(), ref ManagerJob_Production.prioritizeManual); cur.y += _entryHeight; // min skill (5) if ( _selected.Bill.recipe.workSkill != null ) { Rect skillLabelRect = new Rect( cur.x, cur.y, width, _entryHeight ); if( optionindex % 2 == 0 ) Widgets.DrawAltRect( skillLabelRect ); Utilities.Label( skillLabelRect, "MinimumSkillLevel".Translate( _selected.Bill.recipe.workSkill.label.ToLower() ) + ": " + _selected.Bill.minSkillLevel.ToString( "#####0" ), anchor: TextAnchor.MiddleLeft, lrMargin: 6f ); cur.y += _entryHeight; Rect skillRect = new Rect( cur.x, cur.y, width, Utilities.SliderHeight ); if( optionindex % 2 == 0 ) Widgets.DrawAltRect( skillRect ); _selected.Bill.minSkillLevel = (int)GUI.HorizontalSlider( skillRect, _selected.Bill.minSkillLevel, 0f, 20f ); cur.y += Utilities.SliderHeight; Rect snapToHighestRect = new Rect( cur.x, cur.y, width, _entryHeight ); if( optionindex++ % 2 == 0 ) Widgets.DrawAltRect( snapToHighestRect ); Utilities.DrawToggle( snapToHighestRect, "FMP.SnapToHighestSkill".Translate(), ref _selected.maxSkil ); cur.y += _entryHeight; } // draw threshold and billgiver config (6, 7) _selected.Trigger.DrawTriggerConfig( ref cur, optionsColumnRect.width, _entryHeight, optionindex++ % 2 == 0 ); _selected.BillGivers.DrawBillGiverConfig( ref cur, optionsColumnRect.width, _entryHeight, optionindex++ % 2 == 0 ); // add a better recipe available notification with corresponding float menu if other recipe options are available. if( _selected.Managed && _selected.OtherRecipeAvailable() ) { Rect otherRecipeAvailableRect = new Rect(cur.x, cur.y, width, _entryHeight); Utilities.Label( otherRecipeAvailableRect, "FMP.OtherRecipeAvailable".Translate(), "FMP.OtherRecipeAvailableTooltip".Translate() ); Widgets.DrawHighlightIfMouseover( otherRecipeAvailableRect ); if ( optionindex++ % 2 == 0 ) Widgets.DrawAltRect(otherRecipeAvailableRect); // add a little icon to mark interactivity Rect searchIconRect = new Rect( otherRecipeAvailableRect.xMax - Utilities.Margin - _entryHeight, cur.y, _entryHeight, _entryHeight ); if( searchIconRect.height > Utilities.SmallIconSize ) { // center it. searchIconRect = searchIconRect.ContractedBy( ( searchIconRect.height - Utilities.SmallIconSize ) / 2 ); } GUI.DrawTexture( searchIconRect, Resources.Search ); // draw a floatmenu on click if( Widgets.InvisibleButton( otherRecipeAvailableRect ) ) { List<FloatMenuOption> options = new List<FloatMenuOption>(); string curLabel = "Current: " + _selected.Label + " (<i>" + string.Join( ", ", _selected.Targets ) + "</i>)"; options.Add(new FloatMenuOption( curLabel, null)); foreach( RecipeDef recipe in _selected.OtherRecipeDefs ) { string label = recipe.LabelCap + " (<i>" + string.Join( ", ", recipe.GetRecipeUsers().Select( td => td.LabelCap ).ToArray()) + "</i>)"; Action action = delegate { _selected.SetNewRecipe( recipe ); _selected.ForceRecacheOtherRecipe(); }; options.Add( new FloatMenuOption( label, action ) ); } Find.WindowStack.Add( new FloatMenu( options ) ); } cur.y += _entryHeight; } GUI.EndGroup(); // options // bill GUI.BeginGroup( recipeColumnRect ); cur = Vector2.zero; width = recipeColumnRect.width; // bill information Rect infoRect = new Rect( cur.x, cur.y, width, ( recipeColumnRect.height - cur.y ) / 2 ); string text = GetInfoText(); float actualHeight = Text.CalcHeight( text, infoRect.width ); // if required height is small, cull info area if ( infoRect.height > actualHeight ) { infoRect.height = actualHeight; } // set up scrolling region Rect infoViewRect = infoRect; if ( actualHeight > infoRect.height ) { infoViewRect.width -= 16f; // scrollbar infoViewRect.height = Text.CalcHeight( text, infoViewRect.width ); } Widgets.BeginScrollView( infoRect, ref _infoScrollPosition, infoViewRect ); Utilities.Label( infoRect, text, anchor: TextAnchor.UpperLeft, lrMargin: _margin ); Widgets.EndScrollView(); // if there is one or more products known to us (so not smelting, ugh!) display an infocard button if ( _selected.Bill.recipe.products.Count > 0 ) { Widgets.InfoCardButton( infoRect.xMax - Widgets.InfoCardButtonSize - _margin, infoRect.yMin + _margin, _selected.Bill.recipe.products[0].thingDef ); } cur.y += infoRect.height; // ingredients label Rect ingredientsLabelRect = new Rect( cur.x, cur.y, width, _entryHeight ); Utilities.Label( ingredientsLabelRect, "FMP.AllowedIngredients".Translate(), anchor: TextAnchor.MiddleLeft, lrMargin: _margin ); cur.y += _entryHeight; // ingredients picker, fill available space Rect ingredientsRect = new Rect( cur.x, cur.y, width, recipeColumnRect.height - cur.y ); filterUI.DoThingFilterConfigWindow( ingredientsRect, ref IngredientsScrollPosition, _selected.Bill.ingredientFilter, _selected.Bill.recipe.fixedIngredientFilter, 4 ); GUI.EndGroup(); // bill } GUI.EndGroup(); // window }
public void DoThingFilterConfigWindow( Rect canvas, ref Vector2 scrollPosition, ThingFilter filter, ThingFilter parentFilter = null, int openMask = 1, bool buttonsAtBottom = false ) { // respect your bounds! GUI.BeginGroup( canvas ); canvas = canvas.AtZero(); // set up buttons Text.Font = GameFont.Tiny; float width = canvas.width - 2f; var clearButtonRect = new Rect( canvas.x + 1f, canvas.y + 1f, width / 2f, 24f ); var allButtonRect = new Rect( clearButtonRect.xMax + 1f, clearButtonRect.y, width / 2f, 24f ); // offset canvas position for buttons. if ( buttonsAtBottom ) { clearButtonRect.y = canvas.height - clearButtonRect.height; allButtonRect.y = canvas.height - clearButtonRect.height; canvas.yMax -= clearButtonRect.height; } else { canvas.yMin = clearButtonRect.height; } // draw buttons + logic if ( Widgets.ButtonTextSubtle( clearButtonRect, "ClearAll".Translate() ) ) { filter.SetDisallowAll(); } if ( Widgets.ButtonTextSubtle( allButtonRect, "AllowAll".Translate() ) ) { filter.SetAllowAll( parentFilter ); } Text.Font = GameFont.Small; // do list var curY = 2f; var viewRect = new Rect( 0f, 0f, canvas.width - 16f, viewHeight ); // scrollview Widgets.BeginScrollView( canvas, ref scrollPosition, viewRect ); // slider(s) DrawHitPointsFilterConfig( ref curY, viewRect.width, filter ); DrawQualityFilterConfig( ref curY, viewRect.width, filter ); // main listing var listingRect = new Rect( 0f, curY, viewRect.width, 9999f ); var listingTreeThingFilter = new Listing_TreeThingFilter( listingRect, filter, parentFilter, null, null ); TreeNode_ThingCategory node = ThingCategoryNodeDatabase.RootNode; if ( parentFilter != null ) { if ( parentFilter.DisplayRootCategory == null ) { parentFilter.RecalculateDisplayRootCategory(); } node = parentFilter.DisplayRootCategory; } // draw the actual thing listingTreeThingFilter.DoCategoryChildren( node, 0, openMask, true ); listingTreeThingFilter.End(); // update height. viewHeight = curY + listingTreeThingFilter.CurHeight; Widgets.EndScrollView(); GUI.EndGroup(); }
public override void DoWindowContents( Rect inRect ) { base.DoWindowContents( inRect ); var topWidth = 2 * 24f + 4f; var topRect = new Rect( ( inRect.width - topWidth ) / 2.0f, 0.0f, 24.0f, 24.0f ); if( CCL_Widgets.ButtonImage( topRect, Data.Icons.WorkAssignments, "W", Data.Strings.SlaveWorkAssignments.Translate() ) ) { CurrentTab = SlaveTabs.WorkAssignment; } topRect.x += 24f + 4f; if( CCL_Widgets.ButtonImage( topRect, Data.Icons.Restrictions, "A", Data.Strings.SlaveRestrictions.Translate() ) ) { CurrentTab = SlaveTabs.TimeTable; } topRect.x += 24f + 4f; var subRect = new Rect( 0.0f, 24.0f + 16.0f, inRect.width, inRect.height - 24.0f - 4.0f ); GUI.BeginGroup( subRect ); { switch( CurrentTab ) { case SlaveTabs.WorkAssignment: DoWindowContents_WorkAssignments( subRect.AtZero() ); break; case SlaveTabs.TimeTable: DoWindowContents_Restrictions( subRect.AtZero() ); break; } } GUI.EndGroup(); }
private void DrawSelectionArea(Rect rect) { try { Widgets.DrawMenuSection(rect); GUI.BeginGroup(rect); Rect outRect = rect.AtZero(); float height = _cachedHelpCategories.Sum((c) => c.DrawHeight); Rect viewRect = new Rect(0f, 0f, outRect.width - 16f, height); float curY = outRect.y; Widgets.BeginScrollView(outRect, ref selectionScrollPos, viewRect); if (_cachedHelpCategories.Count < 1) { Rect messageRect = outRect.AtZero(); Widgets.Label(messageRect, "NoHelpDefs".Translate()); } else { foreach (var m in _cachedHelpCategories) { Rect entryRect = new Rect(0f, curY, viewRect.width, m.DrawHeight); DrawModCategory(entryRect, m); curY += m.DrawHeight; } } } catch (Exception e) { Log.Error("Exception while drawing selection error: \n" + e.ToString()); } finally { Widgets.EndScrollView(); GUI.EndGroup(); } }
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 }
protected override void FillWindow(Rect inRect) { base.FillWindow(inRect); //First we draw the header Text.Font = GameFont.Medium; Text.Anchor = TextAnchor.UpperCenter; Widgets.Label(new Rect(0f, 0f, 300f, 300f), "ManufacturingPlant".Translate()); Text.Anchor = TextAnchor.UpperLeft; //This float is used to set the padding at the bottom of the window. float bottomPaddingHeight = 50f; //The mainRect is the rectangle which contains the listbox Rect mainRect = new Rect(0f, bottomPaddingHeight, inRect.width, inRect.height - bottomPaddingHeight - 50f); //We initialise the entry and button sizes according to the main rect, which is sized depending on the window size. This lets the window be resized easily without (hoepfully) creating too many problems. this.lineEntrySize = new Vector2(mainRect.width - 16f, 100f); this.interactButtonSize = new Vector2(100f, this.lineEntrySize.y / 2 - 14f); //We begin the group to tell the system that the following elements are grouped together. GUI.BeginGroup(mainRect); //This float is the height of the entry with a small margin added to it. float entryHeightWithMargin = this.lineEntrySize.y + 8f; //This float is the height of the entire list with all included entries and margins. This is used for the rect which houses all the entries, even though we wont see all of them at once. float height = (float)assemblyLines.Count * entryHeightWithMargin; //This rect is used inside the scroll view, and is moved up and down to show the entries. Rect viewRect = new Rect(0f, 0f, mainRect.width - 16f, height); //This is the rect on the screen to be used for the ScrollView Rect outRect = new Rect(mainRect.AtZero()); //This function starts the scrolling view, and uses the scrollPosition variable to record where in the scrollview we are looking Widgets.BeginScrollView(outRect, ref this.scrollPosition, viewRect); //This float is the current y position in the scrollview, we use this for drawing each entry under each other. float currentY = 0f; //We first check to see if there are any entries. If no, then give a small message if (assemblyLines.Count == 0) { Rect rect2 = new Rect(0f, currentY, this.lineEntrySize.x, this.lineEntrySize.y); Text.Font = GameFont.Small; Widgets.Label(rect2, "NoAssemblyLines".Translate()); } //If there are entries, then we draw the entry for each element in the list, calling our Draw...() function. else { foreach (AssemblyLine line in assemblyLines) { line.OnGUI(currentY, this.lineEntrySize, this.interactButtonSize, this); //Increment the current y position for the next entry to be drawn currentY += entryHeightWithMargin; } } //Must remember to end the view once it has been drawn. Widgets.EndScrollView(); //Likewise, remember to end the group GUI.EndGroup(); //This draws the button in the bottom right corner of the window. It uses the same size as the Close button Rect lineManagerButRect = new Rect(inRect.width - this.lineManagerButtonSize.x, inRect.height - this.lineManagerButtonSize.y, this.lineManagerButtonSize.x, this.lineManagerButtonSize.y); if (Widgets.TextButton(lineManagerButRect, "ConstructNewAssemblyLine".Translate())) { if (MPmanager.manager.CanAddAssemblyLine) { string costString = ""; if (Game.GodMode && AssemblyLine.Settings.instaBuild) costString = "Nothing".Translate(); else { foreach (var item in AssemblyLine.Settings.BuildingCost) { costString += string.Format("{1} {0}\n", item.thing.label, item.amount); } } Find.LayerStack.Add(new Dialog_Confirm("BuildNewAssemblyLineDialog".Translate(costString, TicksToTime.GetTime((float)AssemblyLine.ConstructionTicksRequired)), delegate { MPmanager.manager.AddNewAssemblyLine((Game.GodMode && AssemblyLine.Settings.instaBuild)); })); } else { Dialog_Message m = new Dialog_Message("MaximumAssemblyLines".Translate()); Find.LayerStack.Add(m); SoundDefOf.ClickReject.PlayOneShot(SoundInfo.OnCamera()); } } }
private void DrawRecipeList(Rect inRect) { Rect availableRecipeMainRect = new Rect(0f, currentYMaxLeft, availableRecipeMainRectSize.x, availableRecipeMainRectSize.y); this.bottom = availableRecipeMainRect.yMax; this.recipeEntrySize = new Vector2(availableRecipeMainRect.width - 16f, 48f); this.recipeAddButtonSize = new Vector2(120f, this.recipeEntrySize.y - 12f); Widgets.DrawMenuSection(availableRecipeMainRect); GUI.BeginGroup(availableRecipeMainRect); if (enteredText != "") { list = ( from t in this.recipesList where t.label.ToLower().Contains(enteredText.ToLower()) select t).ToList(); } else { list = this.recipesList; } float entryHeight = this.recipeEntrySize.y; float height = (float)list.Count * entryHeight; Rect viewRect = new Rect(0f, 0f, availableRecipeMainRect.width - 16f, height); Rect outRect = new Rect(availableRecipeMainRect.AtZero()); Widgets.BeginScrollView(outRect, ref this.scrollPosition, viewRect); float currentY = 0f; float num3 = 0f; if (recipesList.Count == 0) { Rect rect = new Rect(0f, currentY, this.recipeEntrySize.x, this.recipeEntrySize.y); Text.Font = GameFont.Small; Widgets.Label(rect, "NoRecipesFound".Translate()); } else { foreach (RecipeDef def in list) { Rect rect2 = new Rect(0f, currentY, this.recipeEntrySize.x, this.recipeEntrySize.y); if ((rect2.Contains(Event.current.mousePosition)) || (selectedDef != null && def == selectedDef)) { GUI.color = MouseHoverColor; GUI.DrawTexture(rect2, BaseContent.WhiteTex); } else if (num3 % 2 == 0) { GUI.DrawTexture(rect2, AltTexture); } Rect innerRect = rect2.ContractedBy(3f); GUI.BeginGroup(innerRect); string recipeName = def.label.CapitalizeFirst(); GUI.color = Color.white; Text.Font = GameFont.Small; Text.Anchor = TextAnchor.MiddleLeft; Rect rect = new Rect(15f, 0f, innerRect.width, innerRect.height); Widgets.Label(rect, recipeName); float buttonX = recipeEntrySize.x - 6f - recipeAddButtonSize.x; Rect butRect = new Rect(buttonX, 0f, recipeAddButtonSize.x, recipeAddButtonSize.y); if (Widgets.InvisibleButton(rect)) { this.selectedDef = def; this.config = new OrderConfig(def); //Log.Message("Clicked " + def.defName); } GUI.EndGroup(); currentY += entryHeight; num3++; } } GUI.EndGroup(); Text.Anchor = TextAnchor.UpperLeft; Widgets.EndScrollView(); }
protected override void FillWindow(Rect inRect) { base.FillWindow(inRect); bottomLine = CloseButSize.y + margin; float m = 15f; maxXHorizontalLeft = inRect.width / 2 - m; minXHorizontalRight = inRect.width / 2 + m; if (Widgets.TextButton(new Rect(0f, inRect.height - buttonSize.y, buttonSize.x, buttonSize.y), "Back")) { this.Close(); Find.LayerStack.Add(previousPage); } Rect labelRect = new Rect(0f, 0f, inRect.width, 30f); curYLeft += labelRect.yMax + margin; Text.Font = GameFont.Medium; Text.Anchor = TextAnchor.MiddleCenter; Widgets.Label(labelRect, line.label); Text.Font = GameFont.Small; Text.Anchor = TextAnchor.UpperLeft; Widgets.DrawLineHorizontal(0, curYLeft, inRect.width); curYLeft += 10f; curYRight += curYLeft; //Draw the list box of all orders float rectheight = inRect.height - curYLeft - bottomLine; orderStackRect = new Rect(0f, curYLeft, maxXHorizontalLeft, rectheight); if (line.OrderStack.Count <= 0) { Text.Font = GameFont.Medium; Text.Anchor = TextAnchor.MiddleCenter; Widgets.Label(orderStackRect, "NoOrders".Translate()); Text.Font = GameFont.Small; Text.Anchor = TextAnchor.UpperLeft; } else { this.orderEntrySize = new Vector2(orderStackRect.width - 16f, 120f); try { GUI.BeginGroup(orderStackRect); float entryHeightWithMargin = orderEntrySize.y + 8f; float height = (float)line.OrderStack.Count * entryHeightWithMargin; Rect viewRect = new Rect(0f, 0f, orderEntrySize.x, height); Rect outRect = new Rect(orderStackRect.AtZero()); try { Widgets.BeginScrollView(outRect, ref this.scrollPosition, viewRect); float currentScrollY = 0f; foreach (var current in this.orders) { DrawOrderEntry(current, currentScrollY); currentScrollY += entryHeightWithMargin; } } finally { Widgets.EndScrollView(); } } finally { GUI.EndGroup(); } } //Draw the options buttons on the right side float paddingBetweenButtons = 12f; Vector2 optionsRectSize = new Vector2(inRect.width - minXHorizontalRight, CloseButSize.y * 2 + paddingBetweenButtons + 4f); Rect optionsButtonsRect = new Rect(minXHorizontalRight, curYRight, optionsRectSize.x, optionsRectSize.y); curYRight += optionsRectSize.y + 6f; Widgets.DrawMenuSection(optionsButtonsRect); Rect innerOptions = optionsButtonsRect.ContractedBy(2f); try { GUI.BeginGroup(innerOptions); float buttonXSize = (innerOptions.width / 2) - paddingBetweenButtons / 2; //float butY = innerOptions.height / 2 - (this.CloseButSize.y / 2); float butY = CloseButSize.y / 2; float butY2 = innerOptions.height - (this.CloseButSize.y + (CloseButSize.y / 2)); //Add recipe button Rect recipeButtonRect = new Rect(0f, innerOptions.height / 2 - CloseButSize.y / 2, buttonXSize, CloseButSize.y); if (Widgets.TextButton(recipeButtonRect, "AddOrder".Translate())) { Find.LayerStack.Add(new Page_RecipeManagement(line, this)); } //Options button //Rect optionsButtonRect = new Rect(innerOptions.width - buttonXSize, 0f, buttonXSize, CloseButSize.y); //Widgets.TextButton(optionsButtonRect, "MD2Options".Translate()); //Upgrades button Rect upgradesButtonRect = new Rect(innerOptions.width-buttonXSize, innerOptions.height /2 - CloseButSize.y/2, buttonXSize, CloseButSize.y); if (Widgets.TextButton(upgradesButtonRect, "Upgrades".Translate())) { Find.LayerStack.Add(new Dialog_UpgradeManager(this.line)); } } finally { GUI.EndGroup(); } //Draw the box for the selected def's config float configHeight = inRect.height - bottomLine - curYRight; Rect configBox = new Rect(minXHorizontalRight, curYRight, inRect.width - minXHorizontalRight, configHeight); Widgets.DrawMenuSection(configBox); Rect innerConfig = configBox.ContractedBy(6f); if (this.selectedOrder != null) { try { GUI.BeginGroup(innerConfig); float labelWidth = 30f; float y = 0f; Rect selectedLabelRect = new Rect(0f, 0f, innerConfig.width, labelWidth); y += labelWidth + margin; Text.Anchor = TextAnchor.MiddleCenter; Widgets.Label(selectedLabelRect, "Selected".Translate() + ": " + selectedOrder.Recipe.LabelCap); Text.Anchor = TextAnchor.UpperLeft; Rect configRect = new Rect(0f, y, innerConfig.width, innerConfig.height - y); this.selectedOrder.Config.OnGUI(configRect); } finally { Text.Anchor = TextAnchor.UpperLeft; GUI.EndGroup(); } } else { Text.Font = GameFont.Medium; Text.Anchor = TextAnchor.MiddleCenter; Widgets.Label(innerConfig, "NoCurrentOrder".Translate()); Text.Font = GameFont.Small; Text.Anchor = TextAnchor.UpperLeft; } curYLeft = 0f; curYRight = 0f; }
private void DrawFileEntry( Rect rect, SaveFileInfo file ) { GUI.BeginGroup( rect ); // set up rects Rect nameRect = rect.AtZero(); nameRect.width -= 200f + _iconSize + 4 * _margin; nameRect.xMin += _margin; Rect timeRect = new Rect( nameRect.xMax + _margin, 0f, 100f, rect.height ); Rect buttonRect = new Rect( timeRect.xMax + _margin, 1f, 100f, rect.height - 2f ); Rect deleteRect = new Rect( buttonRect.xMax + _margin, ( rect.height - _iconSize ) / 2, _iconSize, _iconSize ); // name Text.Anchor = TextAnchor.MiddleLeft; Widgets.Label( nameRect, Path.GetFileNameWithoutExtension( file.FileInfo.Name ) ); Text.Anchor = TextAnchor.UpperLeft; // timestamp GUI.color = Color.gray; Dialog_MapList.DrawDateAndVersion( file, timeRect ); Text.Font = GameFont.Small; GUI.color = Color.white; // load button if ( Widgets.TextButton( buttonRect, "FM.Import".Translate() ) ) { TryImport( file ); } // delete button if ( Widgets.ImageButton( deleteRect, Resources.DeleteX ) ) { Find.WindowStack.Add( new Dialog_Confirm( "ConfirmDelete".Translate( file.FileInfo.Name ), delegate { file.FileInfo.Delete(); Refresh(); }, true ) ); } GUI.EndGroup(); }
void DrawSelectionArea(Rect rect) { Widgets.DrawMenuSection(rect); GUI.BeginGroup(rect); Rect outRect = rect.AtZero(); float height = _cachedHelpCategories.Sum(c => c.DrawHeight); var viewRect = new Rect(0f, 0f, outRect.width - 16f, height); float curY = outRect.y; Widgets.BeginScrollView(outRect, ref selectionScrollPos, viewRect); if (_cachedHelpCategories.Count < 1) { Rect messageRect = outRect.AtZero(); Widgets.Label(messageRect, "NoHelpDefs".Translate()); } else { foreach (var m in _cachedHelpCategories) { var entryRect = new Rect(0f, curY, viewRect.width, m.DrawHeight); DrawModCategory(entryRect, m); curY += m.DrawHeight; } } Widgets.EndScrollView(); GUI.EndGroup(); }
/// <summary> /// Draws the mod configuration window contents. /// </summary> /// <returns>The final height of the window rect.</returns> /// <param name="rect">Rect</param> public override float DoWindowContents( Rect rect ) { var listing = new Listing_Standard( rect ); { listing.ColumnWidth = rect.width - 4f; #region Main Toggle var toggleLabel = "MiniMap.MCMToggleMain".Translate(); listing.CheckboxLabeled( toggleLabel, ref MiniMap.MiniMapController.visible ); listing.Gap(); #endregion #region Handle all MiniMaps and Overlays foreach( var minimap in Controller.Data.MiniMaps ) { if( minimap.IsOrHasIConfigurable ) { var iMinimap = minimap as IConfigurable; #region Minimap Header MinimapHeader( listing, minimap ); #endregion #region Handle MiniMap IConfigurable if( iMinimap != null ) { #region Minimap IConfigurable var iMinimapRect = new Rect( listing.Indentation(), listing.CurHeight, listing.ColumnWidth, 9999f ); GUI.BeginGroup( iMinimapRect ); var iMinimapHeight = iMinimap.DrawMCMRegion( iMinimapRect.AtZero() ); GUI.EndGroup(); listing.Gap( iMinimapHeight + 6f ); #endregion } #endregion #region Handle all MiniMap Overlays foreach( var overlay in minimap.overlayWorkers ) { var iOverlay = overlay as IConfigurable; #region Handle Overlay IConfigurable if( iOverlay != null ) { #region Overlay Header OverlayHeader( listing, overlay ); #endregion #region Overlay IConfigurable var iOverlayRect = new Rect( listing.Indentation(), listing.CurHeight, listing.ColumnWidth, 9999f ); GUI.BeginGroup( iOverlayRect ); var iOverlayHeight = iOverlay.DrawMCMRegion( iOverlayRect.AtZero() ); GUI.EndGroup(); listing.Gap( iOverlayHeight + 6f ); listing.Undent(); #endregion } #endregion } #endregion #region Final Undentation listing.Gap(); listing.Undent(); #endregion } } #endregion } listing.End(); return listing.CurHeight; }
protected override void FillWindow(Rect inRect) { Vector2 vector = new Vector2(inRect.width - 16f, 48f); Vector2 vector2 = new Vector2(100f, vector.y - 12f); inRect.height -= 45f; List<FileInfo> list = SaveFiles.AllSaveFiles.ToList<FileInfo>(); float num = vector.y + 8f; float height = (float)list.Count * num; Rect viewRect = new Rect(0f, 0f, inRect.width - 16f, height); Rect position = new Rect(inRect.AtZero()); position.height -= this.bottomAreaHeight; this.scrollPosition = GUI.BeginScrollView(position, this.scrollPosition, viewRect); float num2 = 0f; foreach (FileInfo current in list) { Rect rect = new Rect(0f, num2, vector.x, vector.y); Widgets.DrawMenuSection(rect); Rect innerRect = rect.GetInnerRect(6f); GUI.BeginGroup(innerRect); string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(current.Name); if (MapFiles.IsAutoSave(fileNameWithoutExtension)) { GUI.color = DialogList.AutosaveTextColor; } else { GUI.color = DialogList.ManualSaveTextColor; } Rect position2 = new Rect(15f, 0f, innerRect.width, innerRect.height); GUI.skin.label.alignment = TextAnchor.MiddleLeft; GenFont.SetFontSmall(); GUI.Label(position2, fileNameWithoutExtension); GUI.color = Color.white; Rect position3 = new Rect(220f, 0f, innerRect.width, innerRect.height); GenFont.SetFontTiny(); GUI.color = new Color(1f, 1f, 1f, 0.5f); GUI.Label(position3, current.LastWriteTime.ToString()); GUI.color = Color.white; GUI.skin.label.alignment = TextAnchor.UpperLeft; GenFont.SetFontSmall(); float num3 = vector.x - 12f - vector2.x - vector2.y; Rect butRect = new Rect(num3, 0f, vector2.x, vector2.y); if (Widgets.TextButton(butRect, this.interactButLabel)) { this.DoMapEntryInteraction(Path.GetFileNameWithoutExtension(current.Name)); } Rect rect2 = new Rect(num3 + vector2.x + 5f, 0f, vector2.y, vector2.y); if (Widgets.ImageButton(rect2, ButtonText.DeleteX)) { FileInfo localFile = current; Find.UIRoot.layers.Add(new Dialog_Confirm("ConfirmDelete".Translate(new object[] { localFile.Name }), delegate { localFile.Delete(); }, true)); } TooltipHandler.TipRegion(rect2, "DeleteThisSavegame".Translate()); GUI.EndGroup(); num2 += vector.y + 8f; } GUI.EndScrollView(); this.DoSpecialSaveLoadGUI(inRect.AtZero()); }
public override void DoWindowContents( Rect inRect ) { // Close if work tab closed if( Find.WindowStack.WindowOfType<MainTabWindow_Work>() == null ) { Find.WindowStack.TryRemove( this ); } float areaHeight = (inRect.height - 50f - _margin)/2f; // the space reserved on the UI Rect headerRect = new Rect(inRect.xMin, _margin, inRect.width, 50f - _margin); Rect workTypeListRect = new Rect(inRect.xMin, 50f, inRect.width, areaHeight); Rect workGiverListRect = new Rect(inRect.xMin, workTypeListRect.yMax + _margin, inRect.width, areaHeight); // leave room for buttons workGiverListRect.width -= _buttonSize.x + _margin; workTypeListRect.width -= _buttonSize.x + _margin; // button areas Rect workTypeSortRect = new Rect(workTypeListRect.xMax + _margin, workTypeListRect.yMin, _buttonSize.x, areaHeight); Rect workGiverSortRect = new Rect(workGiverListRect.xMax + _margin, workGiverListRect.yMin, _buttonSize.x, areaHeight); Rect resetRect = new Rect(inRect.width - 27f, 13f - _margin / 2, 24f, 24f); // draw backgrounds Widgets.DrawMenuSection( workTypeListRect ); Widgets.DrawMenuSection( workGiverListRect ); // leave a tiny margin around the scrollbar if necessary if (_workTypeListHeight > workTypeListRect.height) { workTypeListRect.xMax -= 2f; } if( _workGiverListHeight > workGiverListRect.height ) { workGiverListRect.xMax -= 2f; } // the canvas for the (scrollable) lists Rect workTypeListContent = new Rect(workTypeListRect.AtZero()); Rect workGiverListContent = new Rect(workGiverListRect.AtZero()); // set height to calculated height after first (every) pass. workTypeListContent.height = _workTypeListHeight; workGiverListContent.height = _workGiverListHeight; // leave room for scrollbar if necessary. workTypeListContent.width -= _workTypeListHeight > workTypeListRect.height ? 16f : 0f; workGiverListContent.width -= _workGiverListHeight > workGiverListRect.height ? 16f : 0f; // header Text.Font = GameFont.Medium; Widgets.Label(headerRect, "Fluffy.WorkPrioritiesDetails".Translate() ); Text.Font = GameFont.Small; // reset button TooltipHandler.TipRegion(resetRect, "Fluffy.ResetPriorities".Translate()); if (Widgets.ImageButton(resetRect, ResetButton)) { MapComponent_Priorities.ResetPriorities(); RebuildWorkTypeDefsList(); } // worktype lister GUI.BeginGroup( workTypeListRect ); Widgets.BeginScrollView( workTypeListRect.AtZero(), ref _workTypeScrollPosition, workTypeListContent ); // keep track of position Vector2 cur = Vector2.zero; // draw the listings foreach (WorkTypeDef workType in WorkTypeDefs) { // move with selected when reordering if (_workTypeMoved && workType == _selectedWorkTypeDef) { _workTypeScrollPosition.y = cur.y - 2 * _entryHeight; _workTypeMoved = false; } if (DrawEntry(ref cur, workTypeListContent, workType == _selectedWorkTypeDef, workType)) { _selectedWorkTypeDef = workType; _selectedWorkGiverDef = null; } } // set the actual height after having drawn everything _workTypeListHeight = cur.y; Widgets.EndScrollView(); GUI.EndGroup(); // draw buttons DrawSortButtons( workTypeSortRect, _selectedWorkTypeDef != null, _selectedWorkTypeDef ); // START WORKGIVERS if( _selectedWorkTypeDef != null) { // workgiver lister GUI.BeginGroup( workGiverListRect ); Widgets.BeginScrollView( workGiverListRect.AtZero(), ref _workGiverScrollPosition, workGiverListContent ); // keep track of position cur = Vector2.zero; // draw the listings foreach( WorkGiverDef workGiver in _selectedWorkTypeDef.workGiversByPriority ) { // move with selected when reordering if( _workGiverMoved && workGiver == _selectedWorkGiverDef ) { _workGiverScrollPosition.y = cur.y - 2 * _entryHeight; _workGiverMoved = false; } if( DrawEntry( ref cur, workGiverListContent, workGiver == _selectedWorkGiverDef, _selectedWorkTypeDef, workGiver ) ) { _selectedWorkGiverDef = workGiver; } } _workGiverListHeight = cur.y; Widgets.EndScrollView(); GUI.EndGroup(); // draw buttons DrawSortButtons( workGiverSortRect, _selectedWorkGiverDef != null, _selectedWorkTypeDef, _selectedWorkGiverDef ); } }
public void DrawPlot( Rect rect, int target = 0, string label = "", bool positiveOnly = false, bool negativeOnly = false ) { // set sign int sign = negativeOnly ? -1 : 1; // subset chapters List<Chapter> chapters = _chaptersShown.Where( chapter => !positiveOnly || chapter.pages[periodShown].Any( i => i > 0 ) ) .Where( chapter => !negativeOnly || chapter.pages[periodShown].Any( i => i < 0 ) ) .ToList(); // get out early if no chapters. if ( chapters.Count == 0 ) { GUI.DrawTexture( rect.ContractedBy(Utilities.Margin), _plotBG ); Utilities.Label( rect, "FM.HistoryNoChapters".Translate(), null, TextAnchor.MiddleCenter, color: Color.grey ); return; } // stuff we need Rect plot = rect.ContractedBy( Utilities.Margin ); plot.xMin += _yAxisMargin; // maximum of all chapters. int max = CeilToPrecision( Math.Max( chapters.Select( c => c.Max( periodShown, !negativeOnly ) ).Max(), target ) * 1.2f ); // size, and pixels per node. float w = plot.width; float h = plot.height; float wu = w / Size; // width per section float hu = h / max; // height per count int bi = max / ( Breaks + 1 ); // count per break float bu = hu * bi; // height per break // plot the line(s) GUI.DrawTexture( plot, _plotBG ); GUI.BeginGroup( plot ); foreach ( Chapter chapter in chapters ) { chapter.Plot( periodShown, plot.AtZero(), wu, hu, sign ); } // handle mouseover events if ( Mouse.IsOver( plot.AtZero() ) ) { // very conveniently this is the position within the current group. Vector2 pos = Event.current.mousePosition; Vector2 upos = new Vector2(pos.x / wu, (plot.height - pos.y) / hu); // get distances float[] distances = chapters.Select( c => Math.Abs( c.ValueAt( periodShown, (int)upos.x, sign ) - upos.y ) ).ToArray(); // get the minimum index float min = int.MaxValue; int minIndex = 0; for ( int i = 0; i < distances.Count(); i++ ) { if ( distances[i] < min ) { minIndex = i; min = distances[i]; } } // closest line Chapter closest = chapters[minIndex]; // do minimum stuff. Vector2 realpos = new Vector2( pos.x, plot.height - closest.ValueAt( periodShown, (int)upos.x, sign ) * hu ); Rect blipRect = new Rect(realpos.x - Utilities.SmallIconSize / 2f, realpos.y - Utilities.SmallIconSize / 2f, Utilities.SmallIconSize, Utilities.SmallIconSize ); GUI.color = closest.lineColor; GUI.DrawTexture( blipRect, Resources.StageB ); GUI.color = DefaultLineColor; // get orientation of tooltip Vector2 tippos = realpos + new Vector2( Utilities.Margin, Utilities.Margin ); string tip = chapters[minIndex].label + ": " + FormatCount( chapters[minIndex].ValueAt( periodShown, (int)upos.x, sign )); Vector2 tipsize = Text.CalcSize( tip ); bool up = false, left = false; if ( tippos.x + tipsize.x > plot.width ) { left = true; tippos.x -= tipsize.x + 2 * + Utilities.Margin; } if ( tippos.y + tipsize.y > plot.height ) { up = true; tippos.y -= tipsize.y + 2 * Utilities.Margin; } TextAnchor anchor = TextAnchor.UpperLeft; if (up && left) anchor = TextAnchor.LowerRight; if ( up && !left ) anchor = TextAnchor.LowerLeft; if ( !up && left ) anchor = TextAnchor.UpperRight; Rect tooltipRect = new Rect( tippos.x, tippos.y, tipsize.x, tipsize.y ); Utilities.Label( tooltipRect, tip, anchor: anchor, font: GameFont.Tiny ); } // draw target line if ( DrawTargetLine ) { GUI.color = Color.gray; for ( int i = 0; i < plot.width / DashLength; i += 2 ) { Widgets.DrawLineHorizontal( i * DashLength, plot.height - target * hu, DashLength ); } } // draw legend int lineCount = _chapters.Count; if ( AllowTogglingLegend && lineCount > 1 && DrawInlineLegend ) { float rowHeight = 20f; float lineLength = 30f; float labelWidth = 100f; Vector2 cur = Vector2.zero; foreach ( Chapter chapter in _chapters ) { GUI.color = chapter.lineColor; Widgets.DrawLineHorizontal(cur.x, cur.y + rowHeight / 2f, lineLength); cur.x += lineLength; Utilities.Label( ref cur, labelWidth, rowHeight, chapter.label, font: GameFont.Tiny ); cur.x = 0f; } GUI.color = Color.white; } GUI.EndGroup(); // plot axis GUI.BeginGroup( rect ); Text.Anchor = TextAnchor.MiddleRight; Text.Font = GameFont.Tiny; // draw ticks + labels for ( int i = 1; i < Breaks + 1; i++ ) { Widgets.DrawLineHorizontal( _yAxisMargin + Margin / 2, plot.height - i * bu, Margin ); Rect labRect = new Rect( 0f, plot.height - i * bu - 4f, _yAxisMargin, 20f ); Widgets.Label( labRect, FormatCount( i * bi ) ); } Text.Font = GameFont.Small; Text.Anchor = TextAnchor.UpperLeft; GUI.color = Color.white; rect = rect.AtZero(); // ugh, I'm tired, just work. // period / variables picker if ( DrawOptions ) { Rect switchRect = new Rect( rect.xMax - Utilities.SmallIconSize - Utilities.Margin, rect.yMin + Utilities.Margin, Utilities.SmallIconSize, Utilities.SmallIconSize ); Widgets.DrawHighlightIfMouseover( switchRect ); if ( Widgets.ImageButton( switchRect, Resources.Cog ) ) { List<FloatMenuOption> options = periods.Select( p => new FloatMenuOption( "FM.HistoryPeriod".Translate() + ": " + p.ToString(), delegate { periodShown = p; } ) ).ToList(); if ( AllowTogglingLegend && _chapters.Count > 1 ) // add option to show/hide legend if appropriate. { options.Add( new FloatMenuOption( "FM.HistoryShowHideLegend".Translate(), delegate { DrawInlineLegend = !DrawInlineLegend; } ) ); } Find.WindowStack.Add( new FloatMenu( options ) ); } } GUI.EndGroup(); }
public void OnGUI(Rect inRect) { upgradeEntrySize = new Vector2(inRect.width - (margin * 6), 70f); //List of available upgrades List<AssemblyLineUpgradeDef> availableList = ( from t in AvailableUpgrades where !CompletedUpgrades.Contains(t) && !UpgradesInProgress.DefIsBeingUsed(t) && (t.alwaysDisplay || (t.Prerequisites == null || CompletedUpgrades.ContainsAll(t.Prerequisites))) orderby t.label select t).ToList(); if (availableList.Count <= 0 && UpgradesInProgress.Count <= 0) { Text.Font = GameFont.Medium; Text.Anchor = TextAnchor.MiddleCenter; Widgets.Label(inRect, "NoAvailableUpgrades".Translate()); Text.Font = GameFont.Small; Text.Anchor = TextAnchor.UpperLeft; } else { try { GUI.BeginGroup(inRect); float entryHeightWithMargin = upgradeEntrySize.y + 8f; float currentScrollY = 3f; float height; if (UpgradesInProgress.Count > 0) { height = currentScrollY + (float)availableList.Count * entryHeightWithMargin + (float)UpgradesInProgress.Count * entryHeightWithMargin; } else { height = currentScrollY + (float)availableList.Count * entryHeightWithMargin; } Rect viewRect = new Rect(0, 0, upgradeEntrySize.x, height); Rect outRect = new Rect(inRect.AtZero()); try { Widgets.BeginScrollView(outRect, ref scrollPosition, viewRect); if (UpgradesInProgress.Count > 0) { foreach (var current in UpgradesInProgress) { DrawUpgradeInProgressEntry(current, currentScrollY); currentScrollY += entryHeightWithMargin; } } if (availableList.Count > 0) { foreach (var current in availableList) { DrawAvailableUpgradeEntry(current, currentScrollY); currentScrollY += entryHeightWithMargin; } } } finally { Widgets.EndScrollView(); } } finally { GUI.EndGroup(); } } }