public DoThingFilterConfigWindow ( |
||
canvas | ||
scrollPosition | ||
filter | ThingFilter | |
parentFilter | ThingFilter | |
openMask | int | |
buttonsAtBottom | bool | |
return | void |
public override void DoWindowContents(Rect inRect) { // set up rects var filterRect = new Rect(inRect.ContractedBy(6f)); filterRect.height -= 2 * (Constants.ListEntryHeight + Margin); var zoneRect = new Rect(filterRect.xMin, filterRect.yMax + Margin, filterRect.width, Constants.ListEntryHeight); var buttonRect = new Rect(filterRect.xMin, zoneRect.yMax + Margin, (filterRect.width - Margin) / 2f, Constants.ListEntryHeight); // draw thingfilter filterUI.DoThingFilterConfigWindow(filterRect, ref FilterScrollPosition, Trigger.ThresholdFilter, Trigger.ParentFilter); // draw zone selector StockpileGUI.DoStockpileSelectors(zoneRect, ref Trigger.stockpile, Trigger.manager); // draw operator button if (Widgets.ButtonText(buttonRect, Trigger.OpString)) { var list = new List <FloatMenuOption> { new FloatMenuOption("Lower than", delegate { Trigger.Op = Trigger_Threshold.Ops.LowerThan; }), new FloatMenuOption("Equal to", delegate { Trigger.Op = Trigger_Threshold.Ops.Equals; }), new FloatMenuOption("Greater than", delegate { Trigger.Op = Trigger_Threshold.Ops.HigherThan; }) }; Find.WindowStack.Add(new FloatMenu(list)); } // move operator button canvas for count input buttonRect.x = buttonRect.xMax + Margin; // if current input is invalid color the element red var oldColor = GUI.color; if (!Input.IsInt()) { GUI.color = new Color(1f, 0f, 0f); } else { Trigger.TargetCount = int.Parse(Input); if (Trigger.TargetCount > Trigger.MaxUpperThreshold) { Trigger.MaxUpperThreshold = Trigger.TargetCount; } } // draw the input field Input = Widgets.TextField(buttonRect, Input); GUI.color = oldColor; // close on enter if (Event.current.type == EventType.KeyDown && Event.current.keyCode == KeyCode.Return) { Event.current.Use(); Find.WindowStack.TryRemove(this); } }
public void DoContent(Rect canvas) { Widgets.DrawMenuSection(canvas); GUI.BeginGroup(canvas); canvas = canvas.AtZero(); if (_selected != null) { // bottom buttons var buttonRect = new Rect(canvas.xMax - _button.x, canvas.yMax - _button.y, _button.x - _margin, _button.y - _margin); var ingredientCheck = new Rect(buttonRect.xMin - 300f - _margin, buttonRect.yMin, 300f, buttonRect.height); // add / remove to the stack if (Source == SourceOptions.Current) { if (Widgets.ButtonText(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.CheckboxLabeled(ingredientCheck, "FMP.IngredientDialogTitle".Translate(), ref _selected._createIngredientBills, !_selected._hasMeaningfulIngredientChoices); if (Widgets.ButtonText(buttonRect, "FM.Manage".Translate())) { _selected.Managed = true; manager.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(manager, _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 var optionsColumnRect = new Rect(_margin / 2, _topAreaHeight, canvas.width / 2 - _margin, canvas.height - _topAreaHeight - _margin - _button.y); var recipeColumnRect = new Rect(optionsColumnRect.xMax + _margin, _topAreaHeight, canvas.width / 2 - _margin, canvas.height - _topAreaHeight - _margin - _button.y); var optionsColumnTitle = new Rect(optionsColumnRect.xMin, 0f, optionsColumnRect.width, _topAreaHeight); var 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). var optionindex = 0; // suspended var 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 var 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) var 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; var 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) var 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; // skill range (5) if (_selected.Bill.recipe.workSkill != null) { var skillLabelRect = new Rect(cur.x, cur.y, width, _entryHeight); if (optionindex % 2 == 0) { Widgets.DrawAltRect(skillLabelRect); } Utilities.Label(skillLabelRect, "FMP.AllowedSkillRange".Translate() + ": " + _selected.Bill.allowedSkillRange); cur.y += _entryHeight; var skillRect = new Rect(cur.x, cur.y, width, Utilities.SliderHeight); if (optionindex % 2 == 0) { Widgets.DrawAltRect(skillRect); } Widgets.IntRange(skillRect, 2134112311, ref _selected.Bill.allowedSkillRange, 0, 20); cur.y += Utilities.SliderHeight; var snapToHighestRect = new Rect(cur.x, cur.y, width, _entryHeight); if (optionindex++ % 2 == 0) { Widgets.DrawAltRect(snapToHighestRect); } Utilities.DrawToggle(snapToHighestRect, "FMP.SnapToHighestSkill".Translate(), ref _selected.restrictToMaxSkill); 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()) { var 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 var 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.ButtonInvisible(otherRecipeAvailableRect)) { var 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 var 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 var 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 var 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 }