//TODO may need to add code that enabels a scroll bar should we ever need a station with that many WorkTypeDef(s). may also depend on resulution / UI Scale. protected override void FillTab() { Listing_Standard list = new Listing_Standard(); Rect inRect = new Rect(0f, 0f, this.size.x, this.size.y).ContractedBy(10f); list.Begin(inRect); list.Gap(); var rect = new Rect(); rect = list.GetRect(30f); Rect rect3 = rect; rect3.y -= 17; Widgets.Label(rect3, "ITab_DroneStation_HeaderLabel".Translate()); //Add Lable Explayning the pannel Widgets.Label(rect, "ITab_DroneStation_InfoLabel".Translate()); rect = list.GetRect(30f); Widgets.DrawLineHorizontal(rect.x, rect.y, itabwidth); foreach (WorkTypeDef def in droneInterface.GetWorkSettings.Keys.ToList()) { droneInterface.GetWorkSettings[def] = CheckboxHelper(rect, list, droneInterface.GetWorkSettings[def], def); } //Add The Sleep Times Overview //If There are Sleep Times configured if (droneInterface.GetSleepTimeList[0] != "") { rect = list.GetRect(30f); Widgets.DrawLineHorizontal(rect.x, rect.y, itabwidth); CommonGUIFunctions.Label(rect, "ITab_DroneStation_Sleeptimes".Translate(), richTextStyle); AddSleepDisplay(rect, list); } //Add the fule display if existing if (droneInterface.compRefuelable != null) { rect = list.GetRect(30f); Widgets.DrawLineHorizontal(rect.x, rect.y, itabwidth); CommonGUIFunctions.Label(rect, "ITab_DroneStation_SetTargetFuel".Translate(), richTextStyle); rect = list.GetRect(30f); list.Gap(); droneInterface.compRefuelable.TargetFuelLevel = Widgets.HorizontalSlider(rect, droneInterface.compRefuelable.TargetFuelLevel, 0, droneInterface.compRefuelable.Props.fuelCapacity, true, "SetTargetFuelLevel".Translate(droneInterface.compRefuelable.TargetFuelLevel), "0", droneInterface.compRefuelable.Props.fuelCapacity.ToString(), 1); } list.End(); }
private void AddSleepDisplay(Rect rect, Listing_Standard list) { rect = list.GetRect(30f); // droneInterface.GetSleepTimeList string txt = ""; for (int i = 0; i < 24; i++) { if (droneInterface.GetSleepTimeList.Contains(i.ToString())) { txt += "<color=red><b>" + i.ToString() + "</b></color> "; } else { txt += i.ToString() + " "; } } CommonGUIFunctions.Label(rect, txt, richTextStyle); }
protected override void FillTab() { Text.Font = GameFont.Small; var curY = 0f; var frame = new Rect(10f, 10f, size.x - 10f, size.y - 10f); GUI.BeginGroup(frame); Widgets.ListSeparator(ref curY, frame.width, labelKey.Translate()); curY += 5f; // Sniper: t.Label also contains the count (Rice x20) do we want that? // Rider: This new search method is REALLLYYYYYY FAST // This is meant to stop a possible spam call of the Fuzzy Search if (itemsToShow == null || searchQuery != oldSearchQuery || SelectedMassStorageUnit.StoredItemsCount != itemsToShow.Count || oldSelectedMassStorageUnit == null || oldSelectedMassStorageUnit != SelectedMassStorageUnit) { itemsToShow = new List <Thing>(from Thing t in SelectedMassStorageUnit.StoredItems where string.IsNullOrEmpty(searchQuery) || t.Label.ToLower().NormalizedFuzzyStrength(searchQuery.ToLower()) < FuzzySearch.Strength.Strong orderby t.Label descending select t); oldSearchQuery = searchQuery; } oldSelectedMassStorageUnit = SelectedMassStorageUnit; var text = SelectedMassStorageUnit.GetITabString(itemsToShow.Count); var MainTabText = new Rect(8f, curY, frame.width - 16f, Text.CalcHeight(text, frame.width - 16f)); Widgets.Label(MainTabText, text); curY += MainTabText.height; searchQuery = Widgets.TextField(new Rect(frame.x, curY, MainTabText.width - 16f, 25f), oldSearchQuery); curY += 28f; GUI.color = Color.white; var outRect = new Rect(0f, curY, frame.width, frame.height - curY); var viewRect = new Rect(0f, 0f, outRect.width - 16f, scrollViewHeight); // Scrollview Start Widgets.BeginScrollView(outRect, ref scrollPos, viewRect); curY = 0f; if (itemsToShow.Count < 1) { Widgets.Label(viewRect, "PRFItemsTabLabel_Empty".Translate()); curY += 22f; } // Iterate backwards to compensate for removing elements from enumerable // Learned this is an issue with List-like structures in AP CS 1A List <Pawn> pawns = SelectedMassStorageUnit.Map.mapPawns.FreeColonists; //Do it once as they are all on the same spot in the DSU //Even if is where to have multible sport's that way should work I think pawnCanReach_Touch_Deadly = pawns.Where(p => p.CanReach(SelectedMassStorageUnit, PathEndMode.ClosestTouch, Danger.Deadly)).ToList(); pawnCanReach_Oncell_Deadly = pawns.Where(p => p.CanReach(SelectedMassStorageUnit, PathEndMode.OnCell, Danger.Deadly)).ToList(); for (var i = itemsToShow.Count - 1; i >= 0; i--) { //Check if we need to display it if (!itemIsVisible(curY, outRect.height, scrollPos.y)) { curY += 28; continue; } Thing thing = itemsToShow[i]; //Construct cache if (!canBeConsumedby.ContainsKey(thing)) { canBeConsumedby.Add(thing, pawns.Where(p => p.RaceProps.CanEverEat(thing) == true).ToList()); } if (!thing_MaxHitPoints.ContainsKey(thing)) { thing_MaxHitPoints.Add(thing, thing.MaxHitPoints); } if (!thingIconCache.ContainsKey(thing)) { Color color; Texture texture = CommonGUIFunctions.GetThingTextue(new Rect(4f, curY, 28f, 28f), thing, out color); thingIconCache.Add(thing, new thingIconTextureData(texture, color)); } DrawThingRow(ref curY, viewRect.width, thing, pawns); } if (Event.current.type == EventType.Layout) { scrollViewHeight = curY + 30f; } //Scrollview End Widgets.EndScrollView(); GUI.EndGroup(); GUI.color = Color.white; Text.Anchor = TextAnchor.UpperLeft; }
public Listing_Standard ITab_Settings_AppendContent(Listing_Standard list, Rect parrent_rect) { var rect = new Rect(); rect = list.GetRect(30f); Rect rect3 = rect; rect3.y -= 17; Widgets.Label(rect3, "ITab_DroneStation_HeaderLabel".Translate()); //Add Lable Explayning the pannel Widgets.Label(rect, "ITab_DroneStation_InfoLabel".Translate()); rect = list.GetRect(30f); Widgets.DrawLineHorizontal(rect.x, rect.y, 400); foreach (WorkTypeDef def in droneStation.GetWorkSettings.Keys.ToList()) { droneStation.GetWorkSettings[def] = CheckboxHelper(rect, list, droneStation.GetWorkSettings[def], def); } //Add The Sleep Times Overview //If There are Sleep Times configured if (droneStation.GetSleepTimeList[0] != "") { rect = list.GetRect(30f); Widgets.DrawLineHorizontal(rect.x, rect.y, 400); CommonGUIFunctions.Label(rect, "ITab_DroneStation_Sleeptimes".Translate(), richTextStyle); rect = list.GetRect(30f); // droneInterface.GetSleepTimeList string txt = ""; for (int i = 0; i < 24; i++) { if (droneStation.GetSleepTimeList.Contains(i.ToString())) { txt += "<color=red><b>" + i.ToString() + "</b></color> "; } else { txt += i.ToString() + " "; } } CommonGUIFunctions.Label(rect, txt, richTextStyle); } //Add the fule display if existing if (droneStation.compRefuelable != null) { rect = list.GetRect(30f); Widgets.DrawLineHorizontal(rect.x, rect.y, 400); CommonGUIFunctions.Label(rect, "ITab_DroneStation_SetTargetFuel".Translate(), richTextStyle); rect = list.GetRect(30f); list.Gap(); droneStation.compRefuelable.TargetFuelLevel = Widgets.HorizontalSlider(rect, droneStation.compRefuelable.TargetFuelLevel, 0, droneStation.compRefuelable.Props.fuelCapacity, true, "SetTargetFuelLevel".Translate(droneStation.compRefuelable.TargetFuelLevel), "0", droneStation.compRefuelable.Props.fuelCapacity.ToString(), 1); } return(list); }
// Attempt at mimicking LWM Deep Storage // Credits to LWM Deep Storage :) private void DrawThingRow(ref float y, float width, Thing thing, List <Pawn> colonists) { if (thing == null || !thing.Spawned) { return; // not here, whatever happened... } //each call to LabelCap also accesses MaxHitPoints therefor it is read here slightly diffrently; string labelMoCount; if (thing is Corpse) { labelMoCount = (thing as Corpse).Label; } else { labelMoCount = GenLabel.ThingLabel(thing, thing.stackCount, false); } string labelCap = labelMoCount.CapitalizeFirst(thing.def); width -= 24f; // row to hold the item in the GUI Widgets.InfoCardButton(width, y, thing); // rect.width -= 84f; width -= 24f; var checkmarkRect = new Rect(width, y, 24f, 24f); var isItemForbidden = !thing.IsForbidden(Faction.OfPlayer); var forbidRowItem = isItemForbidden; TooltipHandler.TipRegion(checkmarkRect, isItemForbidden ? "CommandNotForbiddenDesc".Translate() : "CommandForbiddenDesc".Translate()); Widgets.Checkbox(checkmarkRect.x, checkmarkRect.y, ref isItemForbidden); if (isItemForbidden != forbidRowItem) { thing.SetForbidden(!isItemForbidden, false); } width -= 24f; var dropRect = new Rect(width, y, 24f, 24f); TooltipHandler.TipRegion(dropRect, "PRF_DropThing".Translate(labelMoCount)); if (Widgets.ButtonImage(dropRect, DropUI, Color.gray, Color.white, false)) { dropThing(thing); } Pawn p = colonists?.Where(col => col.IsColonistPlayerControlled && !col.Dead && col.Spawned && !col.Downed).ToArray().FirstOrFallback <Pawn>(null) ?? null; if (p != null && ChoicesForThing(thing, p, labelMoCount).Count > 0) { width -= 24f; var pawnInteract = new Rect(width, y, 24f, 24f); if (Widgets.ButtonImage(pawnInteract, menuUI, Color.gray, Color.white, false)) { var opts = new List <FloatMenuOption>(); foreach (var pawn in from Pawn col in colonists where col.IsColonistPlayerControlled && !col.Dead && col.Spawned && !col.Downed select col) { var choices = ChoicesForThing(thing, pawn, labelMoCount); if (choices.Count > 0) { opts.Add(new FloatMenuOption(pawn.Name.ToStringFull, () => { Find.WindowStack.Add(new FloatMenu(choices)); })); } } Find.WindowStack.Add(new FloatMenu(opts)); } } var thingRow = new Rect(0f, y, width, 28f); // Highlights the row upon mousing over if (Mouse.IsOver(thingRow)) { GUI.color = ITab_Pawn_Gear.HighlightColor; GUI.DrawTexture(thingRow, TexUI.HighlightTex); } //we need to cache the Graphic to save performence // Widgets.ThingIcon dos not do that // Draws the icon of the thingDef in the row if (thing.def.DrawMatSingle != null && thing.def.DrawMatSingle.mainTexture != null) { thingIconTextureData data = thingIconCache[thing]; CommonGUIFunctions.ThingIcon(new Rect(4f, y, 28f, 28f), thing, data.texture, data.color); } // Draws the item name + info Text.Anchor = TextAnchor.MiddleLeft; GUI.color = ITab_Pawn_Gear.ThingLabelColor; var itemName = new Rect(36f, y, thingRow.width - 36f, thingRow.height); Text.WordWrap = false; // LabelCap is interesting to me(rider) // Really useful I would think // LabelCap == "Wort x75" Widgets.Label(itemName, labelCap.Truncate(itemName.width)); Text.WordWrap = true; // For the toolpit var text2 = labelCap; // if uses hitpoints draw it if (thing.def.useHitPoints) { text2 = string.Concat(labelCap, "\n", thing.HitPoints, " / ", thing_MaxHitPoints[thing]); } // Custom rightclick menu TooltipHandler.TipRegion(thingRow, text2); y += 28f; }