private void DrawPawnOutcome(Rect outcomeBox, PawnKindDef pawnKindDef, float chance, bool percentageInfoToLeft = true) { Widgets.DrawBoxSolid(outcomeBox, PawnOutcomeBackground); if (pawnKindDef != null) { GUI.DrawTexture(outcomeBox, pawnKindDef.race.uiIcon); Text.Font = GameFont.Medium; var percentString = chance.ToString("P"); var percentStringSize = Text.CalcSize(percentString); var percentLabelRect = percentageInfoToLeft ? new Rect(outcomeBox.x + outcomeBox.width - percentStringSize.x, outcomeBox.yMax - 30, percentStringSize.x, 30) : new Rect(outcomeBox.x, outcomeBox.yMax - 30, percentStringSize.x, 30); Widgets.Label(percentLabelRect, percentString); } Text.Font = GameFont.Small; var infoBox = new Rect(outcomeBox.x, outcomeBox.yMax + 5, 18, 18); if (pawnKindDef != null) { Widgets.InfoCardButton(infoBox, pawnKindDef?.race); } var pawnName = pawnKindDef?.label.CapitalizeFirst(); var ppawnLabelSize = Text.CalcSize(pawnName); var pawnLabel = new Rect(infoBox.xMax + 5, infoBox.y, ppawnLabelSize.x, 24); Widgets.Label(pawnLabel, pawnName); }
public static void DrawQuestCard(Quest quest, List <Quest> quests, Rect rect) { bgCardColor.a = 150; Widgets.DrawBoxSolid(rect, bgCardColor); GUI.color = GUIUtils.CommBorderColor; Widgets.DrawBox(rect); GUI.color = Color.white; Text.Anchor = TextAnchor.MiddleCenter; Widgets.Label(new Rect(rect.x + 8, rect.y + 8, rect.width - 88, 25), quest.CardLabel); Text.Anchor = TextAnchor.UpperLeft; GUIUtils.DrawLineHorizontal(rect.x + 8, rect.y + 34, rect.width - 88, Color.gray); float y = rect.y + 36; Widgets.Label(new Rect(rect.x + 8, y, rect.width - 88, 150), quest.Description); Text.Anchor = TextAnchor.MiddleCenter; if (GUIUtils.DrawCustomButton(new Rect(rect.x + (rect.width - 200) / 2, rect.y + 175, 200, 25), "DarkNetButtons_TakeQuest".Translate(), Color.white)) { quest.TakeQuestByQuester(null); quests.Remove(quest); } Text.Anchor = TextAnchor.UpperLeft; if (Mouse.IsOver(rect)) { TooltipHandler.TipRegion(rect, quest.GetRewardsString()); } }
public void ColorEntry(string label, ref string buffer, ref Color original) { var rect = GetRect(Text.LineHeight); var rectLeft = rect.LeftHalf().Rounded(); var rectRight = rect.RightHalf().Rounded(); var rectEntry = rectRight.LeftHalf().Rounded(); var rectPreview = rectRight.RightHalf().Rounded(); Widgets.Label(rectLeft, label); Widgets.DrawBoxSolid(rectPreview, original); Widgets.DrawBox(rectPreview); if (buffer == null) { buffer = ColorUtility.ToHtmlStringRGB(original); } buffer = (rect.height <= 30f ? Widgets.TextField(rectEntry, buffer) : Widgets.TextArea(rectEntry, buffer)).ToUpper(); var color = original; var valid = buffer.Length == 6 && ColorUtility.TryParseHtmlString("#" + buffer, out color); if (!valid) { var guiColor = GUI.color; GUI.color = Color.red; Widgets.DrawBox(rectEntry); GUI.color = guiColor; } original = valid ? color : original; Gap(verticalSpacing); }
/// <summary> /// Draws the default Job tab on GUI. /// </summary> /// <param name="tabRect">Area the Job tab got to work with.</param> public virtual void JobGUITab(Rect tabRect, bool isSelected) { //Display at a glance information. if (isSelected) { Widgets.DrawBoxSolid(tabRect, highlightColor); } else { Widgets.DrawBoxSolid(tabRect, Widgets.WindowBGFillColor); } Color color = GUI.color; if (isSelected) { GUI.color = highlightLineColor; } Widgets.DrawBox(tabRect); Text.Font = GameFont.Small; Text.Anchor = TextAnchor.UpperCenter; Widgets.Label(tabRect, def.LabelCap.WrapInBrackets()); Text.Anchor = TextAnchor.LowerCenter; Widgets.Label(tabRect, $"{level + 1} / {def.maxLevel}"); Text.Anchor = TextAnchor.UpperLeft; GUI.color = color; }
private float DrawNeeds(float y) { var rect = new Rect((Rect.x + Rect.width.Half()) - SkillsWindowWidth.Half(), y, SkillsWindowWidth, 20f); Widgets.DrawShadowAround(rect); Widgets.DrawBoxSolid(rect, Color.black); var barGrid = rect.ContractedBy(BarsPadding).GetGrid(BarsPadding, 3, 2); var healthBar = barGrid[0]; healthBar.xMax = barGrid[1].xMax; var moodBar = barGrid[2]; var restBar = barGrid[3]; var foodBar = barGrid[4]; var joyBar = barGrid[5]; DrawBar(healthBar, Pawn.health.summaryHealth.SummaryHealthPercent, BarHealthColor); DrawBar(moodBar, Pawn.needs.mood.CurLevelPercentage, BarMoodColor); DrawBar(foodBar, Pawn.needs.food.CurLevelPercentage, BarFoodColor); DrawBar(restBar, Pawn.needs.rest.CurLevelPercentage, BarRestColor); DrawBar(joyBar, Pawn.needs.joy.CurLevelPercentage, BarJoyColor); return(rect.yMax); }
public override void DoEditInterface(Listing_ScenEdit listing) { phase += Time.deltaTime * step; float r = (Mathf.Sin(phase * 0.75f + 0 * offset) + 1) / 2f; float g = (Mathf.Sin(phase * 1.00f + 1 * offset) + 1) / 2f; float b = (Mathf.Sin(phase * 1.25f + 2 * offset) + 1) / 2f; r = hairColorR.LerpThroughRange(r); g = hairColorG.LerpThroughRange(g); b = hairColorB.LerpThroughRange(b); curCol = new Color(r, g, b); Rect rect = listing.GetScenPartRect(this, RowHeight * 4 + 3 * 31f); Rect[] rows = rect.SplitRows(31f * 3, 4 * RowHeight); Rect[] cols = rows[0].SplitCols(rows[0].width - rows[0].height, rows[0].height); Rect prev = cols[1].ContractedBy(8); Rect[] sliders = cols[0].SplitRows(1, 1, 1); Widgets.FloatRange(sliders[0], listing.CurHeight.GetHashCode() + 0, ref hairColorR); Widgets.FloatRange(sliders[1], listing.CurHeight.GetHashCode() + 1, ref hairColorG); Widgets.FloatRange(sliders[2], listing.CurHeight.GetHashCode() + 2, ref hairColorB); Widgets.DrawBoxSolid(prev, curCol); Log.Message(curCol.ToStringSafe()); DoContextEditInterface(rows[1]); }
public static void Patch_SkillUI_DrawSkill(SkillRecord skill, ref Rect holdingRect) { Pawn pawn = (Pawn)AccessTools.Field(typeof(SkillRecord), "pawn").GetValue(skill); if (pawn != null && pawn.GetJobsComp() is DivineJobsComp jobsComp) { float levelVerticalPosition = 0f; float maxLevel = 5f; if (jobsComp.SkillMaxLevels.FirstOrDefault(sr => sr.skill == skill.def) is SkillRequirement skillMaxLevel) { maxLevel = skillMaxLevel.minLevel; } Rect rect = new Rect(holdingRect.x + 6f, holdingRect.y, (float)AccessTools.Field(typeof(SkillUI), "levelLabelWidth").GetValue(null) + 6f, holdingRect.height); Rect position = new Rect(rect.xMax, 0f, 24f, 24f); Rect rect2 = new Rect(position.xMax, holdingRect.y, holdingRect.width - position.xMax, holdingRect.height); levelVerticalPosition = rect2.width * (maxLevel / SkillRecord.MaxLevel); Rect skillBlip = rect2; skillBlip.width = 3f; skillBlip.x += levelVerticalPosition - 1f; Widgets.DrawBoxSolid(skillBlip, DivineJobsUI.SkillBlipColor); TooltipHandler.TipRegion(holdingRect, "DivineJobs_MaxLevel".Translate(maxLevel)); } }
public static void DrawLordGroups(Rect rect, PawnTable table, Pawn firstPawn) { if (table.SortingBy != null) { return; } if (firstPawn == null) { return; } var lords = firstPawn.Map.GetMapComponent().PresentLords; int index = -table.PawnsListForReading.IndexOf(firstPawn); float yTop = rect.yMin; float cellHeight = rect.height; foreach (var lord in lords) { const int verticalMargin = 6; const float width = 4; var box = rect; box.xMin = box.xMax - width; box.yMin = yTop + index * cellHeight + verticalMargin; box.yMax = box.yMin + lord.ownedPawns.Count * cellHeight - verticalMargin * 2; Widgets.DrawBoxSolid(box, lord.faction.Color); index += lord.ownedPawns.Count; } }
public virtual void DoModButton(Rect canvas, bool alternate = false, Action clickAction = null, Action doubleClickAction = null, bool deemphasizeFiltered = false, string filter = null) { #if DEBUG clickAction += () => Debug.Log("clicked: " + Name); doubleClickAction += () => Debug.Log("doubleClicked: " + Name); #endif if (alternate) { Widgets.DrawBoxSolid(canvas, Resources.SlightlyDarkBackground); } if (Page_BetterModConfig.Instance.Selected == this) { if (Page_BetterModConfig.Instance.SelectedHasFocus) { Widgets.DrawHighlightSelected(canvas); } else { Widgets.DrawHighlight(canvas); } } if (!DraggingManager.Dragging) { HandleInteractions(canvas, clickAction, doubleClickAction); } }
private static void DrawCrossPromotions(ref Rect canvas, IEnumerable <CrossPromotion> promotions) { var backgroundRect = new Rect( canvas.xMin, canvas.yMin, canvas.width, PromotionsHeight); var outRect = backgroundRect.ContractedBy(SmallMargin / 2); var height = (int)outRect.height; var width = promotions.Sum(p => p.NormalizedWidth(height)) + (promotions.Count() - 1) * SmallMargin; if (width > outRect.width) { height -= 16; // recalculate total width width = promotions.Sum(p => p.NormalizedWidth(height)) + (promotions.Count() - 1) * SmallMargin; } var viewRect = new Rect( canvas.xMin, canvas.yMin, width, height); var pos = viewRect.min; canvas.yMin += PromotionsHeight + SmallMargin; Widgets.DrawBoxSolid(backgroundRect, SlightlyDarkBackground); if (Mouse.IsOver(outRect) && Event.current.type == EventType.ScrollWheel) { _scrollPosition.x += Event.current.delta.y * Constants.ScrollSpeed; } Widgets.BeginScrollView(outRect, ref _scrollPosition, viewRect); foreach (var promotion in promotions) { var normalizedWidth = promotion.NormalizedWidth(height); var rect = new Rect(pos.x, pos.y, normalizedWidth, height); if (Widgets.ButtonImage(rect, promotion.Preview, new Color(.9f, .9f, .9f), Color.white)) { if (!promotion.Installed) { var options = Utilities.NewOptions; options.Add(new FloatMenuOption(I18n.WorkshopPage(promotion.Name), () => SteamUtility.OpenWorkshopPage(promotion.FileId))); options.Add(Resolvers.SubscribeOption(promotion.Name, promotion.FileId.ToString())); Utilities.FloatMenu(options); } else { var button = ModButtonManager.AllButtons.FirstOrDefault(b => b.Name == promotion.Name); if (button != null) { Page_BetterModConfig.Instance.Selected = button; } } } TooltipHandler.TipRegion(rect, promotion.Name + "\n\n" + promotion.Description); pos.x += normalizedWidth + SmallMargin; } Widgets.EndScrollView(); }
private void DoDrives(Rect rect) { //Widgets.DrawBox(rect); Widgets.DrawBoxSolid(rect, this.drivesBackgroundColor); Text.Font = GameFont.Small; Text.Anchor = TextAnchor.MiddleLeft; float buttonHeight = 24; Rect rectView = new Rect(0, 0, rect.width - this.scrollBarWidth, buttonHeight * this.drives.Count()); Widgets.BeginScrollView(rect, ref this.drivesScrollPos, rectView); int index = 0; foreach (string drive in this.drives) { Rect rectButton = new Rect(rectView.x, rectView.y + index * buttonHeight, rectView.width + this.scrollBarWidth, buttonHeight); if (Widgets.ButtonText(rectButton, $" {drive}", false, false, true)) { this.currentPath = drive; this.dirInfoDirty = true; this.soundAmbient.PlayOneShotOnCamera(null); } if (drive == Path.GetPathRoot(this.currentPath)) { Widgets.DrawHighlightSelected(rectButton); } else { Widgets.DrawHighlightIfMouseover(rectButton); } index++; } Widgets.EndScrollView(); }
private static void DrawStorageMarker(ResearchProjectDef tech, Rect rect, bool highlighted) { float height = rect.height; float ribbon = ResearchTree_Constants.push.x; Vector2 position = new Vector2(rect.xMax, rect.y); Color techColor = ResearchTree_Assets.ColorCompleted[tech.techLevel]; Color shadedColor = highlighted ? ResearchTree_Patches.ShadedColor : ResearchTree_Assets.ColorAvailable[tech.techLevel]; Color backup = GUI.color; if (unlocked.TechsArchived.ContainsKey(tech)) { bool cloud = tech.IsOnline(); bool book = tech.IsPhysicallyArchived(); bool twin = cloud && book; Vector2 markerSize = new Vector2(ribbon, height); Rect box = new Rect(position, markerSize); Rect inner = box; inner.height = ribbon; if (twin) { inner.y -= height * 0.08f; } else { inner.y += (height - ribbon) / 2; } Widgets.DrawBoxSolid(box, shadedColor); if (cloud) { GUI.DrawTexture(inner.ContractedBy(1f), ContentFinder <Texture2D> .Get("UI/cloud", true)); TooltipHandler.TipRegionByKey(inner, "bookInDatabase"); } if (book) { if (twin) { float reduction = 0.9f; inner.width *= reduction; inner.height *= reduction; inner.y = box.yMax - inner.height - 1f; inner.x += (ribbon - inner.width) / 2; } var material = TechDefOf.TechBook.graphic.MatSingle; material.color = techColor; Graphics.DrawTexture(inner.ContractedBy(1f), ContentFinder <Texture2D> .Get("Things/Item/book", true), material, 0); TooltipHandler.TipRegionByKey(inner, "bookInLibrary"); } } //origin tooltip if necessary else if (tech.IsFinished) { bool fromScenario = unlocked.scenarioTechs.Contains(tech); bool fromFaction = unlocked.factionTechs.Contains(tech); bool startingTech = fromScenario || fromFaction; string source = fromScenario ? Find.Scenario.name : Find.FactionManager.OfPlayer.Name; TooltipHandler.TipRegionByKey(rect, "bookFromStart", source); } GUI.color = backup; return; }
void RenderSingleMod(Rect root, Mod mod, ModState modState) { Color bgColor; if (modState == ModState.Add) { bgColor = ColorPresets.Green; } else if (modState == ModState.Remove) { bgColor = ColorPresets.Red; } else if (useVersionChecking && modState == ModState.VersionChange) { bgColor = ColorPresets.Yellow; } else { bgColor = ColorPresets.Background; } Widgets.DrawBoxSolid(root, bgColor); float leftBoxWidth = 16f; Rect ModStateRect = new Rect(root.x, root.y, leftBoxWidth, root.height); RenderModState(ModStateRect, modState); Rect DescriptionRect = new Rect(ModStateRect.xMax, root.y, root.width - ModStateRect.width, root.height); RenderModDescriptionAndVersion(DescriptionRect, mod); }
public override void Draw(Rect inRect, AutocastFilter filter) { Widgets.DrawBoxSolid(inRect, new Color(21f / 256f, 25f / 256f, 29f / 256f)); var drawBox = inRect.ContractedBy(5f); var yAnchor = drawBox.y; var xAnchor = drawBox.x; // Draw top matter DrawTopMatter(xAnchor, ref yAnchor, drawBox.width); // Draw invert option DrawInvertOption(ref xAnchor, yAnchor); //Draw threshold option Widgets.Label( new Rect(drawBox.xMax - (ThresholdLabelWidth + ThresholdFillableWidth + XSeparation), yAnchor, ThresholdLabelWidth, OptionHeight), ThresholdKey.Translate()); Widgets.TextFieldPercent( new Rect(drawBox.xMax - ThresholdFillableWidth, yAnchor, ThresholdFillableWidth, OptionHeight), ref Threshold, ref thresholdBuffer, 0f, MaxValue); yAnchor += OptionHeight + YSeparation; // Draw bottom matter Text.Anchor = TextAnchor.MiddleCenter; DrawBottomMatter(drawBox.x, yAnchor, drawBox.width, filter); Text.Anchor = TextAnchor.UpperLeft; }
public void DoCustomStats(Rect _rectCard, Pawn _pawn) { rectCard = _rectCard; floPaddingX = rectCard.width * .025f; floPaddingY = rectCard.height * .05f; Rect rectGroup = new Rect(floPaddingX, rectCard.height * .8f, rectCard.width - (floPaddingX * 2f), rectCard.height * .15f); rectGroup = KrozzyUtilities.RectAddition(rectGroup, rectCard); Widgets.DrawBoxSolid(rectGroup, cBackdrop); GUI.BeginGroup(rectGroup); floPaddingX = rectGroup.width * .025f; floPaddingY = rectGroup.height * .2f; floButtonWidth = (rectGroup.width - (floPaddingX * (float)(2 + (floNumOfButtons - 1)))) / floNumOfButtons; floButtonHeight = rectGroup.height - (floPaddingY * 2f); Rect rectAge = new Rect(floPaddingX, floPaddingY, floButtonWidth, floButtonHeight); Rect rectBackstory = new Rect(rectAge.x + rectAge.width + floPaddingX, floPaddingY, floButtonWidth, floButtonHeight); Rect rectInterests = new Rect(rectBackstory.x + rectBackstory.width + floPaddingX, floPaddingY, floButtonWidth, floButtonHeight); Rect rectSkills = new Rect(rectInterests.x + rectInterests.width + floPaddingX, floPaddingY, floButtonWidth, floButtonHeight); Rect rectTraits = new Rect(rectSkills.x + rectSkills.width + floPaddingX, floPaddingY, floButtonWidth, floButtonHeight); EditAge(rectAge, _pawn); EditBackstory(rectBackstory, _pawn); EditPassions(rectInterests, _pawn); EditSkills(rectSkills, _pawn); EditTraits(rectTraits, _pawn); GUI.EndGroup(); }
private void DrawRequirementEntry(ModRequirement entry, Rect entryRect, ref float y) { Widgets.DrawBoxSolid(entryRect, entry.IsSatisfied ? RequirementRowColor : (Mouse.IsOver(entryRect) ? UnmetRequirementRowColorHighlighted : UnmetRequirementRowColor)); Rect rect = entryRect; rect.x += 4f; rect.width = 200f; Widgets.Label(rect, entry.RequirementTypeLabel.Truncate(rect.width, truncatedStringCache)); Rect rect2 = entryRect; rect2.x = rect.xMax + 4f; rect2.width -= rect2.x + 24f; Widgets.Label(rect2, entry.displayName.Truncate(rect2.width, truncatedStringCache)); if (Widgets.ButtonInvisible(entryRect)) { entry.OnClicked(this); } Rect position = default(Rect); position.xMin = entryRect.xMax - 24f - 4f; position.y = entryRect.y + 1f; position.width = 24f; position.height = 24f; GUI.DrawTexture(position, entry.StatusIcon); TooltipHandler.TipRegion(entryRect, new TipSignal(entry.Tooltip)); y += 26f; }
public void OnGUI(Rect graphRect) { Widgets.DrawMenuSection(graphRect); //Columns float spaceBetweenColumn = graphRect.width / maxX; float columnWidth = spaceBetweenColumn * 0.6f; int current = 0; foreach (double pointY in targetData) { { float columnPositionX = (spaceBetweenColumn * 0.5f) + spaceBetweenColumn * current; float columnHeight = (float)(pointY / maxY) * graphRect.height; Rect columnRect = new Rect(graphRect.x + columnPositionX, graphRect.y + graphRect.height - columnHeight, columnWidth / 2f, columnHeight); Widgets.DrawBoxSolid(columnRect, Color.green); Widgets.DrawBox(columnRect); Rect highlightRect = columnRect.ExpandedBy(3f); Widgets.DrawHighlightIfMouseover(highlightRect); if (Mouse.IsOver(highlightRect)) { TooltipHandler.TipRegion(highlightRect, $"{current}: {pointY}"); } } current++; } }
public static void FillSimpleTableRow(ref bool fieldAlternator, Rect rect, string left, string right, float middle = 0.5f) { float middlePosition = rect.width * middle; Rect leftRect = rect; Rect rightRect = rect; leftRect.width = middlePosition; rightRect.width -= leftRect.width; rightRect.x += leftRect.width; leftRect = leftRect.ContractedBy(2f); rightRect = rightRect.ContractedBy(2f); //Draw sides if (fieldAlternator) { Widgets.DrawBoxSolid(leftRect, AlternateColor); Widgets.DrawBoxSolid(rightRect, AlternateColor); } Text.Anchor = TextAnchor.MiddleLeft; Text.Font = GameFont.Small; Widgets.Label(leftRect, left); Widgets.Label(rightRect, right); Text.Anchor = TextAnchor.UpperLeft; //Flip fieldAlternator = !fieldAlternator; }
private void DrawStats(Rect rect) { Widgets.DrawBoxSolid(rect, new Color(1f, 1f, 1f, 0.08f)); rect = rect.ContractedBy(10); var listing = new Listing_Standard(); listing.Begin(rect); { var patrons = Register.restaurant.Patrons; var orders = Register.restaurant.Orders.AllOrders; var debts = Register.restaurant.Debts.AllDebts; var stock = Register.restaurant.Stock.AllStock; var ordersForServing = Register.restaurant.Orders.AvailableOrdersForServing.ToArray(); var ordersForCooking = Register.restaurant.Orders.AvailableOrdersForCooking.ToArray(); listing.LabelDouble("TabRegisterSeats".Translate(), Register.restaurant.Seats.ToString()); listing.LabelDouble("TabRegisterPatrons".Translate(), patrons.Count.ToString(), patrons.Select(p => p.LabelShort).ToCommaList()); DrawOrders(listing, "TabRegisterTotalOrders".Translate(), orders); DrawOrders(listing, "TabRegisterNeedsServing".Translate(), ordersForServing); DrawOrders(listing, "TabRegisterNeedsCooking".Translate(), ordersForCooking); DrawStock(listing, "TabRegisterStocked".Translate(), stock); DrawDebts(listing, "TabRegisterDebts".Translate(), debts); //listing.LabelDouble("TabRegisterStocked".Translate(), stock.Sum(s=>s.stackCount).ToString(), stock.Select(s=>s.def).Distinct().Select(s=>s.label).ToCommaList()); } listing.End(); }
static void Postfix(Bill __instance, float x, float y, float width) { try { if (__instance is Bill_Production bp && __instance.billStack?.billGiver is Building_ForgeRewritten forge && !forge.CanDoBillNow(bp)) { Rect rect1 = new Rect(x, y, width, 53f); Text.Font = GameFont.Small; Text.Anchor = TextAnchor.MiddleCenter; GUI.color = Color.yellow; float reqTemp = bp?.recipe?.TryGetAlloyDef()?.MinTemperature ?? 420f; string text = "RF.Forge.BillNotHot".Translate(reqTemp.ToStringTemperature("F0")); var size = Text.CalcSize(text) + new Vector2(0, -2); Widgets.DrawBoxSolid(new Rect(0, 0, width, size.y).CenteredOnXIn(rect1).CenteredOnYIn(rect1), new Color(0, 0, 0, 0.65f)); Widgets.Label(rect1, "<b>" + text + "</b>"); GUI.color = Color.white; Text.Anchor = TextAnchor.UpperLeft; Text.Font = GameFont.Small; } } catch (Exception e) { Core.Error("Forge bill exception: ", e); } }
public Rect GetPawnFilterPartRect(PawnFilterPart part, float height) { // Make rect. Rect rect = this.GetRect(PawnFilterPart.RowHeight + height); Widgets.DrawBoxSolid(rect, new Color(1, 1, 1, 0.08f)); WidgetRow widgetRow = new WidgetRow(rect.x, rect.y, UIDirection.RightThenDown, 72, 0); // Add removal button. if (widgetRow.ButtonIcon(ContentFinder <Texture2D> .Get("UI/Buttons/Delete", true), null, new Color?(GenUI.SubtleMouseoverColor))) { part.toRemove = true; } // Add label. Rect labelRect = new Rect(rect.x + 32, rect.y, rect.width, PawnFilterPart.RowHeight); Widgets.Label(labelRect, part.label); // Make a space between filter parts. this.Gap(gapSize); // Return remainder for further modification. return(new Rect(rect.x, rect.y + labelRect.height, rect.width, rect.height - labelRect.height)); }
public Rect GetScenPartRect(ScenPart part, float height) { string label = part.Label; Rect rect = GetRect(height); Widgets.DrawBoxSolid(rect, new Color(1f, 1f, 1f, 0.08f)); WidgetRow widgetRow = new WidgetRow(rect.x, rect.y, UIDirection.RightThenDown, 72f, 0f); if (part.def.PlayerAddRemovable && widgetRow.ButtonIcon(TexButton.DeleteX, null, GenUI.SubtleMouseoverColor)) { scen.RemovePart(part); SoundDefOf.Click.PlayOneShotOnCamera(); } if (scen.CanReorder(part, ReorderDirection.Up) && widgetRow.ButtonIcon(TexButton.ReorderUp)) { scen.Reorder(part, ReorderDirection.Up); SoundDefOf.Tick_High.PlayOneShotOnCamera(); } if (scen.CanReorder(part, ReorderDirection.Down) && widgetRow.ButtonIcon(TexButton.ReorderDown)) { scen.Reorder(part, ReorderDirection.Down); SoundDefOf.Tick_Low.PlayOneShotOnCamera(); } Text.Anchor = TextAnchor.UpperRight; Rect rect2 = rect.LeftPart(0.5f).Rounded(); rect2.xMax -= 4f; Widgets.Label(rect2, label); Text.Anchor = TextAnchor.UpperLeft; Gap(4f); return(rect.RightPart(0.5f).Rounded()); }
public static void Postfix(Pawn __instance) { if (!Finder.debug) { return; } List <Thing> others = __instance.Map.GetComponent <ProximityComponent>().GetThingsInRange(__instance.positionInt, 10).ToList(); if (others == null) { return; } var selPos = __instance.DrawPos.MapToUIPosition(); var offset = new Vector2(12, 12); GameFont textSize = Text.Font; TextAnchor anchor = Text.Anchor; Text.Font = GameFont.Tiny; Text.Anchor = TextAnchor.MiddleCenter; foreach (Thing thing in others) { if (thing == null || thing == __instance) { continue; } var drawPos = thing.DrawPos.MapToUIPosition(); var distance = Vector2.Distance(drawPos, selPos); if (distance < 24) { continue; } var midPoint = (drawPos + selPos) / 2; var rect = new Rect(midPoint - offset, offset * 2); var realDistance = Mathf.RoundToInt(thing.Position.DistanceTo(__instance.Position)); if (realDistance <= 10) { var color = new Color(0.1f, 0.5f, 0.1f); Widgets.DrawLine(drawPos, selPos, color, 1); Widgets.DrawWindowBackgroundTutor(rect); Widgets.Label(rect, "" + Mathf.RoundToInt(thing.Position.DistanceTo(__instance.Position))); } else { var color = new Color(1f, 0.1f, 0.1f); Widgets.DrawLine(drawPos, selPos, color, 1); Widgets.DrawBoxSolid(rect, new Color(0.1f, 0.1f, 0.1f)); Widgets.Label(rect, "" + Mathf.RoundToInt(thing.Position.DistanceTo(__instance.Position))); } } Text.Font = textSize; Text.Anchor = anchor; }
public static void DrawTrainingProgress(Rect rect, Pawn pawn, TrainableDef trainable, Color color) { var steps = GetTrainingProgress(pawn, trainable); var progressRect = new Rect(rect.xMin, rect.yMax - rect.height / 5f, rect.width / steps.max * steps.min, rect.height / 5f); Widgets.DrawBoxSolid(progressRect, color); }
private Rect DrawBar(float x, float y, float width, float height) { Rect barRect = new Rect(x, y - height, width, height); Widgets.DrawBoxSolid(barRect, Color.yellow); return(barRect); }
public static void Draw(Rect rect) { var innerRect = rect.AtZero(); innerRect.height = yHeigthCache; viewFrustum = rect.AtZero(); viewFrustum.y += scrollOffset.y; Widgets.BeginScrollView(rect, ref scrollOffset, innerRect, false); GUI.BeginGroup(innerRect); listing.Begin(innerRect); float yHeight = 0; Text.Anchor = TextAnchor.MiddleLeft; Text.Font = GameFont.Tiny; lock (sync) { if (!(cachedEntries.Count == 1 && cachedEntries.First() == searchText)) { foreach (var entry in cachedEntries) { var r = listing.GetRect(Text.LineHeight); yHeight += r.height; if (!r.Overlaps(viewFrustum)) { continue; } if (Widgets.ButtonInvisible(r)) { Panel_DevOptions.currentInput = entry; } Widgets.DrawBoxSolid(r, Modbase.Settings.GraphCol); if (Mouse.IsOver(r)) { Widgets.DrawHighlight(r); } r.width = 2000; Widgets.Label(r, " " + entry); } } } yHeigthCache = yHeight; listing.End(); GUI.EndGroup(); Widgets.EndScrollView(); DubGUI.ResetFont(); }
private static void DrawDay(int col, int row, int size, Vector2 pos, float progress, Color color) { var canvas = new Rect((int)(col * size + pos.x), (int)(row * size + pos.y), Mathf.Clamp01(progress) * (size - 1), size - 1); Widgets.DrawBoxSolid(canvas, color); }
public void DrawCustomItemCard(Rect rect, SellableItemWithModif item, Pawn speaker) { bgCardColor.a = 150; Widgets.DrawBoxSolid(rect, bgCardColor); GUI.color = GUIUtils.CommBorderColor; Widgets.DrawBox(rect); GUI.color = Color.white; Widgets.ThingIcon(new Rect(rect.x + 8, rect.y + 18, 64, 64), item.Item); Text.Anchor = TextAnchor.MiddleCenter; Widgets.Label(new Rect(rect.x + 80, rect.y + 8, rect.width - 88, 25), item.Item.Label); Text.Anchor = TextAnchor.UpperLeft; GUIUtils.DrawLineHorizontal(rect.x + 80, rect.y + 34, rect.width - 88, Color.gray); float y = rect.y + 36; Widgets.Label(new Rect(rect.x + 80, y, rect.width - 88, 25), $"DarkNetModificator_Price".Translate(item.MarketValue)); y += 25; if (item.Modificator != null) { Widgets.Label(new Rect(rect.x + 80, y, rect.width - 88, 40), item.Modificator.LabelCap); } Text.Anchor = TextAnchor.MiddleCenter; if (GUIUtils.DrawCustomButton(new Rect(rect.x, rect.y + 105, rect.width, 25), "DarkNetButtons_Buy".Translate(), Color.white)) { if (DarkNetPriceUtils.BuyAndDropItem(item, speaker.Map)) { if (stock.Contains(item)) { stock.Remove(item); } else { goodOfTheWeek = null; } Text.Anchor = TextAnchor.UpperLeft; return; } } Text.Anchor = TextAnchor.UpperLeft; if (Mouse.IsOver(rect)) { StringBuilder builder = new StringBuilder(); builder.Append("TraderWorker_RogerEdmonson_FullDesc".Translate(item.Item.Label, item.Item.DescriptionFlavor, item.MarketValue)); if (item.Modificator != null) { builder.Append("TraderWorker_RogerEdmonson_Modificator".Translate(item.Modificator.LabelCap, item.Modificator.description, item.Modificator.PriceModficator)); } TooltipHandler.TipRegion(rect, builder.ToString()); } }
public static void CurveEditor(this Listing_Standard instance, ref SimpleCurve curve) { var rect = instance.GetRect(100f); Widgets.DrawBoxSolid(rect, Color.black); var innerRect = rect.ContractedBy(2f); //SimpleCurveDrawer.DrawCurve(innerRect, curve); Widgets.ButtonInvisibleDraggable(innerRect); }
static void Prefix(Window __instance) { if (__instance.ID == -LongEventWindowPreventCameraMotion.LongEventWindowId || __instance.ID == -MainButtonsPatch.SkippingWindowId || __instance is DisconnectedWindow || __instance is MpFormingCaravanWindow ) { Widgets.DrawBoxSolid(new Rect(0, 0, UI.screenWidth, UI.screenHeight), new Color(0, 0, 0, 0.5f)); } }