public override bool DrawSpecial(Rect rect, WidgetRow row) => false; //Too big for one line public override bool DrawMore(Listing_StandardIndent listing) { if (Sel.stages.Count <= 1) { return(false); } //Buttons apparently are too tall for the line height? listing.Gap(listing.verticalSpacing); Rect nextRect = listing.GetRect(Text.LineHeight); WidgetRow row = new WidgetRow(nextRect.x, nextRect.y); //Actually Range from 1 to 2 is fine cause it can match both //if(sel.stages.Count == 2) // DoStageDropdown(row, stageRange.min, i => { stageRange.min = i; stageRange.max = i; }); //else { row.Label("TD.From".Translate()); DoStageDropdown(row, stageRange.min, i => stageRange.min = i); row.Label("RangeTo".Translate()); DoStageDropdown(row, stageRange.max, i => stageRange.max = i); } return(false); }
public static bool DoFilters(Listing_StandardIndent listing, List <ListFilter> filters) { bool changed = false; foreach (ListFilter filter in filters) { Rect highlightRect = listing.GetRect(0); float heightBefore = listing.CurHeight; changed |= filter.Listing(listing); if (!(filter is ListFilterGroup) && Find.Selector.SelectedObjects.Any(o => o is Thing t && filter.AppliesTo(t))) { highlightRect.height = listing.CurHeight - heightBefore; Widgets.DrawHighlight(highlightRect); } } filters.RemoveAll(f => f.delete); return(changed); }
public static void DrawAddRow(Listing_StandardIndent listing, FindDescription owner, List <ListFilter> filters = null) { Rect addRow = listing.GetRect(Text.LineHeight); listing.Gap(listing.verticalSpacing); Rect butRect = addRow; butRect.width = Text.LineHeight; Widgets.DrawTextureFitted(butRect, TexButton.Plus, 1.0f); Rect textRect = addRow; textRect.xMin += Text.LineHeight + WidgetRow.DefaultGap; Widgets.Label(textRect, "TD.AddNewFilter...".Translate()); Widgets.DrawHighlightIfMouseover(addRow); if (Widgets.ButtonInvisible(addRow)) { AddFilterFloat(owner, filters); } }
//Draw Filters public void DoFilter(Rect rect) { bool changed = false; Text.Font = GameFont.Medium; Rect headerRect = rect.TopPartPixels(Text.LineHeight); Rect filterRect = rect.BottomPartPixels(rect.height - Text.LineHeight); //Header Rect headerButRect = headerRect.RightPartPixels(Text.LineHeight).ContractedBy(2f); Rect labelRect = new Rect(headerRect.x, headerRect.y, headerRect.width - Text.LineHeight * 2, headerRect.height); if (Widgets.ButtonImage(headerButRect, TexButton.CancelTex)) { findDesc = new FindDescription(); changed = true; } TooltipHandler.TipRegion(headerButRect, "ClearAll".Translate().CapitalizeFirst()); headerButRect.x -= Text.LineHeight; if (Widgets.ButtonImage(headerButRect, findDesc.locked ? TexButton.LockOn : TexButton.LockOff)) { findDesc.locked = !findDesc.locked; } TooltipHandler.TipRegion(headerButRect, "TD.LockEditing".Translate()); //Header Title Widgets.Label(labelRect, "TD.Listing".Translate() + findDesc.baseType.TranslateEnum()); Widgets.DrawHighlightIfMouseover(labelRect); if (Widgets.ButtonInvisible(labelRect)) { List <FloatMenuOption> types = new List <FloatMenuOption>(); foreach (BaseListType type in Prefs.DevMode ? Enum.GetValues(typeof(BaseListType)) : BaseListNormalTypes.normalTypes) { types.Add(new FloatMenuOption(type.TranslateEnum(), () => findDesc.baseType = type)); } Find.WindowStack.Add(new FloatMenu(types) { onCloseCallback = RemakeList }); } Listing_StandardIndent listing = new Listing_StandardIndent() { maxOneColumn = true }; listing.Begin(filterRect); /* maybe don't show name box * //Filter Name * Rect nameRect = listing.GetRect(Text.LineHeight); * WidgetRow nameRow = new WidgetRow(nameRect.x, nameRect.y); * nameRow.Label("TD.Name".Translate()); * nameRect.xMin = nameRow.FinalX; * findDesc.name = Widgets.TextField(nameRect, findDesc.name); * listing.Gap(); */ listing.GapLine(); //Draw Filters!!! Rect listRect = listing.GetRect(500); Listing_StandardIndent filterListing = new Listing_StandardIndent() { maxOneColumn = true }; float viewWidth = listRect.width; if (scrollViewHeightFilt > listRect.height) { viewWidth -= 16f; } Rect viewRect = new Rect(0f, 0f, viewWidth, scrollViewHeightFilt); //Lock out input to filters. if (findDesc.locked && Event.current.type != EventType.Repaint && Event.current.type != EventType.Layout && Event.current.type != EventType.Ignore && Event.current.type != EventType.Used && Mouse.IsOver(viewRect)) { Event.current.Use(); } filterListing.BeginScrollView(listRect, ref scrollPositionFilt, viewRect); //Draw Scrolling list: if (DoFilters(filterListing, findDesc.filters)) { changed = true; } if (!findDesc.locked) { DrawAddRow(filterListing, findDesc); } filterListing.EndScrollView(ref viewRect); scrollViewHeightFilt = viewRect.height; //Extra options: bool newMaps = findDesc.allMaps; listing.CheckboxLabeled( "TD.AllMaps".Translate(), ref newMaps, "TD.CertainFiltersDontWorkForAllMaps-LikeZonesAndAreasThatAreObviouslySpecificToASingleMap".Translate()); if (findDesc.allMaps != newMaps) { findDesc.allMaps = newMaps; changed = true; } listing.GapLine(); //Manage/Save/Load Buttons Rect savedRect = listing.GetRect(Text.LineHeight); savedRect = savedRect.LeftPart(0.25f); //Saved Filters if (Widgets.ButtonText(savedRect, "SaveButton".Translate())) { Find.WindowStack.Add(new Dialog_Name(findDesc.name, name => Settings.Get().Save(name, findDesc))); } savedRect.x += savedRect.width; if (Settings.Get().SavedNames().Count() > 0 && Widgets.ButtonText(savedRect, "Load".Translate())) { List <FloatMenuOption> options = new List <FloatMenuOption>(); foreach (string name in Settings.Get().SavedNames()) { options.Add(new FloatMenuOption(name, () => findDesc = Settings.Get().Load(name))); } DoFloatMenu(options); } savedRect.x += savedRect.width * 2; if (Widgets.ButtonText(savedRect, "TD.ManageSaved".Translate())) { Find.WindowStack.Add(new Dialog_ManageSavedLists()); } //Alerts Rect alertsRect = listing.GetRect(Text.LineHeight); alertsRect = alertsRect.LeftPart(0.25f); var comp = Current.Game.GetComponent <ListEverythingGameComp>(); if (Widgets.ButtonText(alertsRect, "TD.MakeAlert".Translate())) { Find.WindowStack.Add(new Dialog_Name(findDesc.name, name => comp.AddAlert(name, findDesc))); } alertsRect.x += alertsRect.width; if (comp.AlertNames().Count() > 0 && Widgets.ButtonText(alertsRect, "TD.LoadAlert".Translate())) { List <FloatMenuOption> options = new List <FloatMenuOption>(); foreach (string name in comp.AlertNames()) { options.Add(new FloatMenuOption(name, () => findDesc = comp.LoadAlert(name))); } DoFloatMenu(options); } alertsRect.x += alertsRect.width * 2; if (Widgets.ButtonText(alertsRect, "TD.ManageAlerts".Translate())) { Find.WindowStack.Add(new AlertByFindDialog()); } //Global Options listing.CheckboxLabeled( "TD.OnlyShowFilterOptionsForAvailableThings".Translate(), ref ContentsUtility.onlyAvailable, "TD.ForExampleDontShowTheOptionMadeFromPlasteelIfNothingIsMadeFromPlasteel".Translate()); listing.End(); //Update if needed if (changed) { RemakeList(); } }