public static void OpenWith(FindDescription desc) { MainTabWindow_List tab = ListDefOf.TD_List.TabWindow as MainTabWindow_List; tab.findDesc = desc; tab.RemakeList(); Find.MainTabsRoot.SetCurrentTab(ListDefOf.TD_List); }
//Ctrl-F handler public override void GameComponentOnGUI() { if (ListDefOf.OpenFindTab.IsDownEvent && Event.current.control) { FindDescription desc = new FindDescription(); ListFilter filter = ListFilterMaker.NameFilter(desc); desc.filters.Add(filter); filter.Focus(); MainTabWindow_List.OpenWith(desc); } }
public void DoWindowContents(Rect inRect) { //Scrolling! Rect viewRect = new Rect(0f, 0f, inRect.width - 16f, scrollViewHeight); Widgets.BeginScrollView(inRect, ref scrollPosition, viewRect); Rect rowRect = viewRect; rowRect.height = RowHeight; string remove = null; foreach (var kvp in savedFilters) { string name = kvp.Key; FindDescription desc = kvp.Value; WidgetRow row = new WidgetRow(rowRect.x, rowRect.y, UIDirection.RightThenDown, rowRect.width); rowRect.y += RowHeight; row.Label(name, rowRect.width / 4); if (row.ButtonText("Rename".Translate())) { Find.WindowStack.Add(new Dialog_Name(newName => Rename(name, newName))); } if (Current.Game != null && row.ButtonText("Load".Translate())) { MainTabWindow_List.OpenWith(desc.Clone(Find.CurrentMap)); } if (row.ButtonText("Delete".Translate())) { remove = name; } row.CheckboxLabeled("TD.AllMaps".Translate(), ref desc.allMaps); } scrollViewHeight = RowHeight * savedFilters.Count(); Widgets.EndScrollView(); if (remove != null) { if (Event.current.shift) { savedFilters.Remove(remove); } else { Find.WindowStack.Add(Dialog_MessageBox.CreateConfirmation( "TD.Delete0".Translate(remove), () => savedFilters.Remove(remove))); } } }
public override bool DrawSpecial(Rect rect, WidgetRow row) { if (Sel.degreeDatas.Count > 1 && row.ButtonText(Sel.DataAtDegree(traitDegree).label.CapitalizeFirst())) { List <FloatMenuOption> options = new List <FloatMenuOption>(); foreach (TraitDegreeData deg in Sel.degreeDatas) { options.Add(new FloatMenuOption(deg.label.CapitalizeFirst(), () => traitDegree = deg.degree)); } MainTabWindow_List.DoFloatMenu(options); } return(false); }
public override bool DrawMore(Listing_StandardIndent listing) { listing.Gap(); listing.NestedIndent(Listing_Standard.DefaultIndent); //Draw filters bool changed = MainTabWindow_List.DoFilters(listing, filters); if (!owner.locked) { MainTabWindow_List.DrawAddRow(listing, owner, filters); } listing.NestedOutdent(); return(changed); }
private void DoStageDropdown(WidgetRow row, int setI, Action <int> selectedAction) { if (row.ButtonText(Sel.stages[setI]?.label.CapitalizeFirst() ?? "TD.Invisible".Translate())) { List <FloatMenuOption> options = new List <FloatMenuOption>(); IEnumerable <int> stageIndices = ContentsUtility.onlyAvailable ? ContentsUtility.AvailableInGame(t => ThoughtStagesForThing(t, Sel)) : Enumerable.Range(0, Sel.stages.Count); foreach (int i in stageIndices.Where(i => DebugSettings.godMode || (Sel.stages[i]?.visible ?? false))) { int localI = i; options.Add(new FloatMenuOption(Sel.stages[i]?.label.CapitalizeFirst() ?? "TD.Invisible".Translate(), () => selectedAction(localI))); } MainTabWindow_List.DoFloatMenu(options); } }
public override void GameComponentTick() { if (Find.TickManager.TicksGame % 60 != 0) { return; //every second I guess? } if (continuousRefresh) { MainTabWindow_List tab = ListDefOf.TD_List.TabWindow as MainTabWindow_List; if (tab.IsOpen) { tab.RemakeList(); Log.Message("CONTINUOUS REFRESH!"); } } }
public override Rect DrawAt(float topY, bool minimized) { Text.Font = GameFont.Small; string label = this.GetLabel(); float height = Text.CalcHeight(label, Alert.Width - 6); //Alert.TextWidth = 148f Rect rect = new Rect((float)UI.screenWidth - Alert.Width, topY, Alert.Width, height); //if (this.alertBounce != null) //rect.x -= this.alertBounce.CalculateHorizontalOffset(); if (Event.current.button == 1 && Widgets.ButtonInvisible(rect, false)) { MainTabWindow_List.OpenWith(alertData.desc.Clone(Find.CurrentMap)); Event.current.Use(); } return(base.DrawAt(topY, minimized)); }
public override bool DrawOption(Rect rect) { WidgetRow row = new WidgetRow(rect.x, rect.y); if (row.ButtonText(sel.def.LabelCap)) { List <FloatMenuOption> options = new List <FloatMenuOption>(); foreach (ListFilterDef def in def.subFilters) { options.Add(new FloatMenuOption(def.LabelCap, () => SetSelectedFilter(def))); } MainTabWindow_List.DoFloatMenu(options); return(true); } rect.xMin += row.FinalX; return(sel.DrawOption(rect)); }
public override TaggedString GetExplanation() { var things = FoundThings(); StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append(defaultLabel + " (" + (alertData.map?.Parent.LabelCap ?? "TD.AllMaps".Translate()) + ")"); stringBuilder.AppendLine(" - " + MainTabWindow_List.LabelCountThings(things)); stringBuilder.AppendLine(""); foreach (Thing thing in things.Take(maxItems)) { stringBuilder.AppendLine(" " + thing.Label); } if (things.Count() > maxItems) { stringBuilder.AppendLine("TD.Maximum0Displayed".Translate(maxItems)); } stringBuilder.AppendLine(""); stringBuilder.AppendLine("TD.Right-clickToOpenFindTab".Translate()); return(stringBuilder.ToString().TrimEndNewlines()); }
public override void DoWindowContents(Rect inRect) { //Title var listing = new Listing_Standard(); listing.Begin(inRect); Text.Font = GameFont.Medium; listing.Label("TD.CustomAlerts".Translate()); Text.Font = GameFont.Small; listing.GapLine(); listing.End(); //Check off Rect enableRect = inRect.RightHalf().TopPartPixels(Text.LineHeight); Widgets.CheckboxLabeled(enableRect, "Enable Alerts", ref Alert_Find.enableAll); //Margin inRect.yMin += listing.CurHeight; //Useful things: Map map = Find.CurrentMap; ListEverythingGameComp comp = Current.Game.GetComponent <ListEverythingGameComp>(); string remove = null; //Scrolling! Rect viewRect = new Rect(0f, 0f, inRect.width - 16f, scrollViewHeight); Widgets.BeginScrollView(inRect, ref scrollPosition, viewRect); Rect rowRect = viewRect; rowRect.height = RowHeight; foreach (string name in comp.AlertNames()) { FindAlertData alert = comp.GetAlert(name); FindDescription desc = alert.desc; WidgetRow row = new WidgetRow(rowRect.x, rowRect.y, UIDirection.RightThenDown, rowRect.width); rowRect.y += RowHeight; row.Label(alert.Label, rowRect.width / 4); if (row.ButtonText("Rename".Translate())) { Find.WindowStack.Add(new Dialog_Name(newName => comp.RenameAlert(name, newName))); } if (row.ButtonText("Load".Translate())) { MainTabWindow_List.OpenWith(desc.Clone(map)); } if (row.ButtonText("Delete".Translate())) { remove = name; } bool crit = desc.alertPriority == AlertPriority.Critical; row.ToggleableIcon(ref crit, TexButton.PassionMajorIcon, "TD.CriticalAlert".Translate()); comp.SetPriority(name, crit ? AlertPriority.Critical : AlertPriority.Medium); row.Label("TD.SecondsUntilShown".Translate()); int sec = desc.ticksToShowAlert / 60; string secStr = sec.ToString(); Rect textRect = row.GetRect(64); textRect.height -= 4; textRect.width -= 4; Widgets.TextFieldNumeric(textRect, ref sec, ref secStr, 0, 999999); TooltipHandler.TipRegion(textRect, "TD.Tip1000SecondsInARimworldDay".Translate()); comp.SetTicks(name, sec * 60); row.Label("TD.ShowWhen".Translate()); if (row.ButtonIcon(TexFor(desc.countComp))) { comp.SetComp(name, (CompareType)((int)(desc.countComp + 1) % 3)); } int count = desc.countToAlert; string countStr = count.ToString(); textRect = row.GetRect(64); textRect.height -= 4; textRect.width -= 4; Widgets.TextFieldNumeric(textRect, ref count, ref countStr, 0, 999999); comp.SetCount(name, count); } scrollViewHeight = RowHeight * comp.AlertNames().Count(); Widgets.EndScrollView(); if (remove != null) { if (Event.current.shift) { comp.RemoveAlert(remove); } else { Find.WindowStack.Add(Dialog_MessageBox.CreateConfirmation( "TD.Delete0".Translate(remove), () => comp.RemoveAlert(remove))); } } }