private static void DrawFavouriteStar(Rect rect, PersistentColony colony) { var favoured = colony.ColonyData.Favoured; var size = rect.size.x; var starRect = new Rect(rect.x, rect.y, size, size); var starImageRect = new Rect(starRect.x + size * 0.1f, starRect.y + size * 0.05f, starRect.width * 0.9f, starRect.height * 0.9f); if (!favoured) { Widgets.DrawAltRect(starRect); } else { Widgets.DrawHighlight(starRect); } Widgets.DrawHighlightIfMouseover(starRect); if (ButtonTextureHover(starRect, starImageRect, FavouriteStar, FavouriteStarToBe, Color.gray, favoured ? Color.red : Color.green, GenUI.MouseoverColor, favoured)) { colony.ColonyData.Favoured = !favoured; _sorted = null; // Reset favourites list } TooltipHandler.TipRegion(starRect, !favoured ? "FilUnderscore.PersistentRimWorlds.Colony.Favourite.Add".Translate() : "FilUnderscore.PersistentRimWorlds.Colony.Favourite.Remove".Translate()); }
private void DrawListEntry(Rect entryRect, AIPackageDef p, ref AIPackageDef selPackage, ref AIPackageDef unselPackage, bool alternate) { if (IsSelected(p)) { Widgets.DrawHighlightSelected(entryRect); if (Mouse.IsOver(entryRect)) TooltipHandler.TipRegion(entryRect, p.Tooltip); } else if (Mouse.IsOver(entryRect)) { Widgets.DrawHighlight(entryRect); TooltipHandler.TipRegion(entryRect, p.Tooltip); } else if (alternate) Widgets.DrawAltRect(entryRect); Text.Anchor = TextAnchor.MiddleCenter; Widgets.Label(entryRect, $" {p.LabelCap}"); Text.Anchor = TextAnchor.UpperLeft; if (Widgets.ButtonInvisible(entryRect)) { selPackage = p; unselPackage = null; } }
private void DrawSelectedEntry(WorkPackageDef p, Rect entryRect, bool alternate) { try { if (entryRect.Contains(Event.current.mousePosition)) { Widgets.DrawHighlight(entryRect); } else if (alternate) { Widgets.DrawAltRect(entryRect); } TooltipHandler.TipRegion(entryRect, p.Tooltip); GUI.BeginGroup(entryRect); Rect labelRect = new Rect(0f, 0f, entryRect.width - 25f, entryRect.height); Text.Anchor = TextAnchor.MiddleLeft; Widgets.Label(labelRect, p.LabelCap); Text.Anchor = TextAnchor.UpperLeft; Rect buttonRect = new Rect(entryRect.width - 25f, entryRect.height / 2 - 12.5f, 25f, 25f); if (Widgets.ImageButton(buttonRect, Widget.ArrowLeftTex, Color.white)) { _bp.WorkPackages.Remove(p); } } finally { GUI.EndGroup(); } }
private void DrawRequirementRow(ThingDefCount thingCount, Rect listHolder, int listPos, bool canDrawToolTips) { float yPosition = listPos * listElementRectHeight; Rect highlightRect = new Rect(0f, yPosition, listHolder.width, listElementRectHeight); bool rowShouldBeRed = Find.CurrentMap.GetCountOnMapDifference(thingCount) > 0; // Do tool tips and background. if (listPos % 2 == 0 && rowShouldBeRed) { GUI.DrawTexture(highlightRect, redAltTexture); } else if (listPos % 2 == 0) { Widgets.DrawAltRect(highlightRect); } if (canDrawToolTips) { TooltipHandler.TipRegion(highlightRect, new TipSignal(GetReqRowTooltip(thingCount))); } // Draw thingdef icon Rect mainElementsRect = highlightRect.WidthContractedBy(listElementsMargin); Rect iconRect = new Rect(mainElementsRect.x, yPosition, listElementRectHeight, listElementRectHeight); Widgets.ThingIcon(iconRect, thingCount.ThingDef); // Do text labels Rect labelsRect = new Rect(listElementRectHeight, yPosition, listHolder.width - listElementRectHeight, listElementRectHeight).WidthContractedBy(2 * listElementsMargin); if (rowShouldBeRed) { GUI.color = Color.red; } DoTextLabel(labelsRect, thingCount.ThingDef.LabelCap); DoNumberLabel(labelsRect, thingCount); GUI.color = Color.white; }
private void DrawEntry(Rect entryRect, AssemblyBill bill, bool alternate) { try { Rect inRect = entryRect.ContractedBy(5f); if (alternate) { Widgets.DrawAltRect(entryRect); } GUI.BeginGroup(inRect); #region Label Rect labelRect = new Rect(0f, 0f, inRect.width / 2f, inRect.height); string label = "Blueprint".Translate() + ": " + bill.Blueprint.BpName + "\n" + "Name".Translate() + ": " + bill.Blueprint.Name; Text.Anchor = TextAnchor.MiddleCenter; Widgets.Label(labelRect, label); Text.Anchor = TextAnchor.UpperLeft; #endregion } finally { GUI.EndGroup(); } }
private static void DrawScrollBoxEntry(Rect inRect, Rect outRect, WorkPackageDef def, bool alternate) { try { if (inRect.Contains(Event.current.mousePosition) && outRect.Contains(Event.current.mousePosition)) { Widgets.DrawHighlight(inRect); TooltipHandler.TipRegion(inRect, def.Tooltip); } else if (alternate) { Widgets.DrawAltRect(inRect); } GUI.BeginGroup(inRect); Rect labelRect = new Rect(0f, 0f, inRect.width, inRect.height); Text.Anchor = TextAnchor.MiddleCenter; Widgets.Label(labelRect, def.label); Text.Anchor = TextAnchor.UpperLeft; } finally { GUI.EndGroup(); Text.Anchor = TextAnchor.UpperLeft; } }
public static void DrawColonistsMenu(ref Rect inRect, float margin, List <Pawn> colonists, Action <Pawn> set) { const int perRow = 3; var gap = (int)margin; inRect.width += gap; Log.Message("Open " + colonists.Count); UITools.DrawBoxGridView(out _, out _, ref inRect, ref _scrollPosition, perRow, gap, (i, boxRect) => { var colonist = colonists[i]; Widgets.DrawAltRect(boxRect); Widgets.DrawHighlightIfMouseover(boxRect); var portraitSize = new Vector2(boxRect.width / 2, boxRect.height); var portraitRect = new Rect(boxRect.x + boxRect.width * 0.5f - portraitSize.x / 2, boxRect.y, portraitSize.x, portraitSize.y); Texture pawnTexture = PortraitsCache.Get(colonist, portraitSize); GUI.DrawTexture(portraitRect, pawnTexture); TooltipHandler.TipRegion(portraitRect, colonist.Name.ToStringFull); if (Widgets.ButtonInvisible(boxRect)) { set(colonist); } return(true); }, colonists.Count); }
private void DrawQualityProbabilitySection(Dictionary <QualityCategory, float> probability, QualityCategory quality, Rect rect) { byte qualityInt = (byte)quality; GUI.BeginGroup(rect); if (qualityInt % 2 == 1) { Widgets.DrawAltRect(rect.AtZero()); } Text.Font = GameFont.Tiny; Text.Anchor = TextAnchor.MiddleCenter; Widgets.Label(new Rect(0f, 0f, rect.width, 30f), quality.GetLabel()); string probText = "-"; if (probability.ContainsKey(quality)) { probText = probability[quality].ToString("P"); } Widgets.Label(new Rect(0f, 30f, rect.width, rect.height - 30f), probText); Text.Anchor = TextAnchor.UpperLeft; Text.Font = GameFont.Small; GUI.EndGroup(); }
private void DrawDesignEntry(Rect rect, Blueprint bp, bool alternate) { try { GUI.BeginGroup(rect); Rect entryRect = new Rect(0f, 0f, rect.width, rect.height - DesignEntryMargin); if (Widgets.ButtonInvisible(entryRect)) { if (selBlueprint != null && selBlueprint == bp) { selBlueprint = null; } else { selBlueprint = bp; bpHandler = new BlueprintWindowHandler(selBlueprint, BlueprintHandlerState.Normal); bpHandler.CloseButtonVisible = false; bpHandler.EditButtonVisible = true; } } if (selBlueprint != null && selBlueprint == bp) { Widgets.DrawHighlightSelected(entryRect); } else if (Mouse.IsOver(entryRect)) { Widgets.DrawHighlight(entryRect); } else if (alternate) { Widgets.DrawAltRect(entryRect); } Rect textRect = new Rect(SectionMargin, 0, entryRect.width - SectionMargin, entryRect.height); Text.Anchor = TextAnchor.MiddleLeft; Widgets.Label(textRect, bp.Label); Text.Anchor = TextAnchor.UpperLeft; string text = bp.ChassisType == ChassisType.Small ? "SmallChassis".Translate() : bp.ChassisType == ChassisType.Medium ? "MediumChassis".Translate() : bp.ChassisType == ChassisType.Large ? "LargeChassis".Translate() : "Undefined droid chassis "; text += " "; Text.Anchor = TextAnchor.LowerRight; Text.Font = GameFont.Tiny; Widgets.Label(textRect, text); Text.Anchor = TextAnchor.UpperLeft; Text.Font = GameFont.Small; } finally { GUI.EndGroup(); Text.Anchor = TextAnchor.UpperLeft; } }
private void DrawLeftRectAsOptions(Rect rect, IEnumerable <RecipeSpec> options) { Widgets.DrawMenuSection(rect, false); GUI.BeginGroup(rect); float y = 0; int i = 0; Text.Anchor = TextAnchor.MiddleCenter; foreach (var s in options) { var row = new Rect(0f, y, rect.width, 50f); Widgets.DrawHighlightIfMouseover(row); var labelRec = new Rect(row.x, row.y, row.width, row.height); Widgets.Label(labelRec, s.ProductLabel); if (_selected == s.Label) { Widgets.DrawHighlightSelected(row); } if (i++ % 2 == 1) { Widgets.DrawAltRect(row); } y += 50f; if (Widgets.ButtonInvisible(row)) { _selected = s.Label; SoundDefOf.CheckboxTurnedOn.PlayOneShotOnCamera(); } } var buttonRect = new Rect(35f, rect.height - 80f, rect.width - 70f, 50f); Text.Anchor = TextAnchor.MiddleCenter; if (Widgets.ButtonText(buttonRect, "Choose")) { MateriaMod.Instance.SetChoice(_selected); SoundDefOf.Click.PlayOneShotOnCamera(); } Text.Anchor = TextAnchor.UpperLeft; GUI.EndGroup(); }
public static void Label(ref Vector2 cur, float width, float height, string label, string tooltip = null, TextAnchor anchor = TextAnchor.MiddleLeft, float lrMargin = Margin, float tbMargin = 0f, bool alt = false, GameFont font = GameFont.Small, Color?color = null) { var rect = new Rect(cur.x, cur.y, width, height); if (alt) { Widgets.DrawAltRect(rect); } Label(rect, label, tooltip, anchor, lrMargin, tbMargin, font, color); cur.y += height; }
private void DrawLan(Rect inRect) { Text.Anchor = TextAnchor.MiddleCenter; Widgets.Label(new Rect(inRect.x, 8f, inRect.width, 40), "MpLanSearching".Translate() + MpUtil.FixedEllipsis()); Text.Anchor = TextAnchor.UpperLeft; inRect.yMin += 40f; float margin = 100; Rect outRect = new Rect(margin, inRect.yMin + 10, inRect.width - 2 * margin, inRect.height - 20); float height = servers.Count * 40; Rect viewRect = new Rect(0, 0, outRect.width - 16f, height); Widgets.BeginScrollView(outRect, ref lanScroll, viewRect, true); float y = 0; int i = 0; foreach (LanServer server in servers) { Rect entryRect = new Rect(0, y, viewRect.width, 40); if (i % 2 == 0) { Widgets.DrawAltRect(entryRect); } Text.Anchor = TextAnchor.MiddleLeft; Widgets.Label(entryRect.Right(5), "" + server.endpoint); Text.Anchor = TextAnchor.MiddleCenter; Rect playButton = new Rect(entryRect.xMax - 75, entryRect.y + 5, 70, 40 - 10); if (Widgets.ButtonText(playButton, ">>")) { Close(false); Log.Message("Connecting to lan server"); Find.WindowStack.Add(new ConnectingWindow(server.endpoint.Address, server.endpoint.Port) { returnToServerBrowser = true }); } Text.Anchor = TextAnchor.UpperLeft; y += entryRect.height; i++; } Widgets.EndScrollView(); }
private static void DrawAIEntry(Rect entryRect, AIPackageDef p, bool alternate) { if (Mouse.IsOver(entryRect)) { Widgets.DrawHighlight(entryRect); TooltipHandler.TipRegion(entryRect, p.Tooltip); } else if (alternate) { Widgets.DrawAltRect(entryRect); } Text.Anchor = TextAnchor.MiddleCenter; Widgets.Label(entryRect, $" {p.LabelCap}"); Text.Anchor = TextAnchor.UpperLeft; }
public override void DrawTriggerConfig( ref Vector2 cur, float width, float entryHeight, bool alt = false, string label = null, string tooltip = null) { // target threshold var thresholdLabelRect = new Rect( cur.x, cur.y, width, entryHeight ); if ( alt ) { Widgets.DrawAltRect( thresholdLabelRect ); } Widgets.DrawHighlightIfMouseover( thresholdLabelRect ); if ( label.NullOrEmpty() ) { label = "FMP.ThresholdCount".Translate( CurCount, Count ) + ":"; } if ( tooltip.NullOrEmpty() ) { // TODO: Re-implement filter summary method. tooltip = "FMP.ThresholdCountTooltip".Translate( CurCount, Count ); } Utilities.Label( thresholdLabelRect, label, tooltip ); // add a little icon to mark interactivity var searchIconRect = new Rect( thresholdLabelRect.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 ); cur.y += entryHeight; if ( Widgets.ButtonInvisible( thresholdLabelRect ) ) { Find.WindowStack.Add( DetailsWindow ); } var thresholdRect = new Rect( cur.x, cur.y, width, Utilities.SliderHeight ); if ( alt ) { Widgets.DrawAltRect( thresholdRect ); } Count = (int)GUI.HorizontalSlider( thresholdRect, Count, 0, MaxUpperThreshold ); cur.y += Utilities.SliderHeight; }
private void DrawAvailableJobList(Rect outRect, Rect viewRect) { // set sizes viewRect.height = _availablePawnKinds.Count * LargeListEntryHeight; if (viewRect.height > outRect.height) { viewRect.width -= ScrollbarWidth; } Widgets.BeginScrollView(outRect, ref _scrollPosition, viewRect); GUI.BeginGroup(viewRect); for (var i = 0; i < _availablePawnKinds.Count; i++) { // set up rect var row = new Rect(0f, LargeListEntryHeight * i, viewRect.width, LargeListEntryHeight); // highlights Widgets.DrawHighlightIfMouseover(row); if (i % 2 == 0) { Widgets.DrawAltRect(row); } if (_availablePawnKinds[i] == _selectedAvailable) { Widgets.DrawHighlightSelected(row); } // draw label string label = _availablePawnKinds[i].LabelCap + "\n<i>" + "FML.TameWildCount".Translate( _availablePawnKinds[i].GetTame(manager).Count, _availablePawnKinds[i].GetWild(manager).Count) + "</i>"; Label(row, label, TextAnchor.MiddleLeft, margin: Margin * 2); // button if (Widgets.ButtonInvisible(row)) { _selectedAvailable = _availablePawnKinds[i]; // for highlighting to work Selected = new ManagerJob_Livestock(_availablePawnKinds[i], manager); // for details } } GUI.EndGroup(); Widgets.EndScrollView(); }
private static void DrawPartsGroupListing(Rect rect, DroidCustomiseGroupDef group, List <PartCustomisePack> packs) { try { GUI.BeginGroup(rect); Rect labelRect = new Rect(10f, 0f, rect.width - 10f, PartGroupTitleHeight); Text.Anchor = TextAnchor.MiddleLeft; Text.Font = GameFont.Medium; Widgets.Label(labelRect, group.LabelCap); Text.Anchor = TextAnchor.UpperLeft; Text.Font = GameFont.Small; var list = packs.Where(x => x.Part.BasePart == false); float curY = labelRect.yMax; bool alternate = false; foreach (var part in list) { Rect pRect = new Rect(0f, curY, rect.width, PartEntryHeight); if (Mouse.IsOver(pRect)) { Widgets.DrawHighlight(pRect); TooltipHandler.TipRegion(pRect, part.Part.GetTooltip()); } else if (alternate) { Widgets.DrawAltRect(pRect); } Text.Anchor = TextAnchor.MiddleLeft; if (part.Part.color != null) { GUI.color = part.Part.color.GetColor(); } Widgets.Label(pRect, $" {part.Part.LabelCap}"); Text.Anchor = TextAnchor.UpperLeft; GUI.color = Color.white; curY += PartEntryHeight; alternate = !alternate; } } finally { GUI.EndGroup(); } }
public void DrawProgressBar(Rect rect, float value, float maxValue, StatModifier sm, string toolTip = "") { try { GUI.BeginGroup(rect); Rect bgRect = new Rect(0f, 0f, rect.width, rect.height); Widgets.DrawAltRect(bgRect); float percentage = GetFillPercentage(value, maxValue); float width = rect.width * percentage; Rect progressRect = new Rect(0f, 0f, width, rect.height); Color color = Blue; if (percentage > 0.9f) { color = Red; } else if (percentage > 0.75f) { color = Orange; } Widgets.DrawBoxSolid(progressRect, color); Widgets.DrawBox(bgRect); if (Mouse.IsOver(bgRect)) { Widgets.DrawHighlight(bgRect); if (!toolTip.NullOrEmpty()) { TooltipHandler.TipRegion(bgRect, toolTip); } } string text = $"{sm.stat.ValueToString(sm.value)} / {sm.stat.ValueToString(maxValue)}"; Text.Anchor = TextAnchor.MiddleCenter; Widgets.Label(bgRect, text); Text.Anchor = TextAnchor.UpperLeft; } finally { GUI.EndGroup(); } }
private void DrawLan(Rect inRect) { using (MpStyle.Set(TextAnchor.MiddleCenter)) Widgets.Label(new Rect(inRect.x, 8f, inRect.width, 40), "MpLanSearching".Translate() + MpUI.FixedEllipsis()); inRect.yMin += 40f; float margin = 100; Rect outRect = new Rect(margin, inRect.yMin + 10, inRect.width - 2 * margin, inRect.height - 20); float height = servers.Count * 40; Rect viewRect = new Rect(0, 0, outRect.width - 16f, height); Widgets.BeginScrollView(outRect, ref lanScroll, viewRect, true); float y = 0; int i = 0; foreach (LanServer server in servers) { Rect entryRect = new Rect(0, y, viewRect.width, 40); if (i % 2 == 0) { Widgets.DrawAltRect(entryRect); } using (MpStyle.Set(TextAnchor.MiddleLeft)) Widgets.Label(entryRect.Right(5), "" + server.endpoint); Rect playButton = new Rect(entryRect.xMax - 75, entryRect.y + 5, 70, 40 - 10); if (Widgets.ButtonText(playButton, ">>")) { Close(false); Log.Message("Connecting to lan server"); var address = server.endpoint.Address.ToString(); var port = server.endpoint.Port; ClientUtil.TryConnectWithWindow(address, port); } y += entryRect.height; i++; } Widgets.EndScrollView(); }
private static void DrawSkillsEntry(Rect entryRect, SkillLevel skill, Blueprint bp, bool alternate, BlueprintHandlerState state) { try { if (Mouse.IsOver(entryRect)) { Widgets.DrawHighlight(entryRect); } else if (alternate) { Widgets.DrawAltRect(entryRect); } GUI.BeginGroup(entryRect); if (state == BlueprintHandlerState.New || state == BlueprintHandlerState.Edit) { Rect sliderRect = new Rect(0f, 0f, entryRect.width, entryRect.height); int prevLevel = skill.Level; skill.Level = Mathf.RoundToInt(Widgets.HorizontalSlider(sliderRect, skill.Level, 0, 20, true, $"{skill.Skill.LabelCap} ({skill.Level})", "0", "20")); if (skill.Level != prevLevel) { bp.Recache(); bp.AddSkillsToDroid(StatDummy(bp)); StatsReportUtility.Reset(); } } else { Rect skillLabelRect = new Rect(0f, 0f, (entryRect.width / 2), entryRect.height); Text.Anchor = TextAnchor.MiddleLeft; Widgets.Label(skillLabelRect, skill.Skill.LabelCap); Rect skillLevelRect = new Rect(skillLabelRect.xMax, 0f, entryRect.width / 2 - 5f, entryRect.height); Text.Anchor = TextAnchor.MiddleRight; Widgets.Label(skillLevelRect, skill.Level.ToString()); Text.Anchor = TextAnchor.UpperLeft; } } finally { GUI.EndGroup(); } }
protected virtual void DrawElements(Rect inRect) { Text.Anchor = TextAnchor.MiddleLeft; Rect elemRect = new Rect(inRect.x, inRect.y, inRect.width, ElementHeight); Rect nameRect = new Rect(inRect.x, inRect.y, ElementNameWidth, ElementNameHeight); Rect deleteRect = new Rect(inRect.width - inRect.x - ElementDeleteWidth, inRect.y, ElementDeleteWidth, ElementDeleteHeight); Rect importRect = new Rect(deleteRect.x - ElementImportWidth, inRect.y, ElementImportWidth, ElementImportHeight); bool alternate = false; foreach (string name in GetAll()) { if (alternate) { Widgets.DrawAltRect(elemRect); } Widgets.Label(nameRect, name); if (Widgets.ButtonText(importRect, "FCImport".Translate())) { OnImport(name); } if (Widgets.ButtonImage(deleteRect, TexLoad.deleteX)) { OnDelete(name); } elemRect.y += ElementHeight + ElementPadding; nameRect.y += ElementHeight + ElementPadding; importRect.y += ElementHeight + ElementPadding; deleteRect.y += ElementHeight + ElementPadding; alternate ^= true; } Text.Anchor = TextAnchor.UpperLeft; }
private void DrawCurrentJobList(Rect outRect, Rect viewRect) { // set sizes viewRect.height = _currentJobs.Count * LargeListEntryHeight; if (viewRect.height > outRect.height) { viewRect.width -= ScrollbarWidth; } Widgets.BeginScrollView(outRect, ref _scrollPosition, viewRect); GUI.BeginGroup(viewRect); for (var i = 0; i < _currentJobs.Count; i++) { // set up rect var row = new Rect(0f, LargeListEntryHeight * i, viewRect.width, LargeListEntryHeight); // highlights Widgets.DrawHighlightIfMouseover(row); if (i % 2 == 0) { Widgets.DrawAltRect(row); } if (_currentJobs[i] == _selectedCurrent) { Widgets.DrawHighlightSelected(row); } // draw label _currentJobs[i].DrawListEntry(row, false, true); // button if (Widgets.ButtonInvisible(row)) { Selected = _currentJobs[i]; } } GUI.EndGroup(); Widgets.EndScrollView(); }
public Rect DrawItem <T>(Rect inRect, T selectedObj, T obj, int ind, Action <Rect, T, int> drawFunc, Action <T> onClick) where T : class { Rect listItemRect = new Rect(inRect); listItemRect.height = 45f; if (ind % 2 == 0) { Widgets.DrawAltRect(listItemRect); } drawFunc(listItemRect, obj, ind); if (Event.current.type == EventType.MouseDown && Event.current.button == 0 && Mouse.IsOver(listItemRect)) { onClick(obj); SoundDefOf.Click.PlayOneShotOnCamera(); } Widgets.DrawHighlightIfMouseover(listItemRect); if (Mouse.IsOver(listItemRect) && lastMouseoverObj != obj) { SoundDefOf.Mouseover_Standard.PlayOneShotOnCamera(); lastMouseoverObj = obj; } if (!Mouse.IsOver(listItemRect) && lastMouseoverObj == obj) { lastMouseoverObj = null; } if (selectedObj == obj) { Widgets.DrawHighlightSelected(listItemRect); } return(listItemRect); }
/// <summary> /// Draw billgivers info + details button /// </summary> public void DrawBillGiverConfig(ref Vector2 cur, float width, float entryHeight, bool alt = false) { // target threshold string potentialString = string.Join("\n", PotentialBillGivers.Select(b => b.LabelCap).ToArray()); string selectedString = string.Join("\n", SelectedBillGivers.Select(b => b.LabelCap).ToArray()); string assignedString = string.Join("\n", AssignedBillGivers.Select(b => b.LabelCap).ToArray()); string billgiverTooltip = "FMP.BillGiversTooltip".Translate(potentialString, selectedString, assignedString); var billgiverLabelRect = new Rect(cur.x, cur.y, width, entryHeight); if (alt) { Widgets.DrawAltRect(billgiverLabelRect); } Widgets.DrawHighlightIfMouseover(billgiverLabelRect); Utilities.Label(billgiverLabelRect, "FMP.BillGiversCount".Translate(PotentialBillGivers.Count, SelectedBillGivers.Count, AssignedBillGivers.Count), billgiverTooltip, TextAnchor.MiddleLeft, Utilities.Margin); if (Widgets.ButtonInvisible(billgiverLabelRect)) { Find.WindowStack.Add(DetailsWindow); } // add a little icon to mark interactivity var searchIconRect = new Rect(billgiverLabelRect.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); cur.y += entryHeight; }
private static void DrawAbandonColony(Rect rect, PersistentColony colony) { // Delete button. var size = rect.size.x; var abandonRect = new Rect(rect.x, rect.height - size, size, size); Widgets.DrawAltRect(abandonRect); Widgets.DrawHighlightIfMouseover(abandonRect); // Draw delete button first. if (ButtonTextureHover(abandonRect, abandonRect, AbandonHomeButton, AbandonButton, Color.white, GenUI.MouseoverColor)) { ColonyUI.ShowAbandonColonyConfirmationDialog(colony, (colony) => { var persistentWorld = PersistentWorldManager.GetInstance().PersistentWorld; persistentWorld.DeleteColony(colony); }); } TooltipHandler.TipRegion(abandonRect, "FilUnderscore.PersistentRimWorlds.Colony.Abandon".Translate()); }
private void DrawLoadSection(Rect rect) { if (_saveFiles.NullOrEmpty()) { // no saves found. GUI.color = Color.gray; Text.Anchor = TextAnchor.MiddleCenter; Widgets.Label(rect, "FM.NoSaves".Translate()); Text.Anchor = TextAnchor.UpperLeft; GUI.color = Color.white; } else { GUI.BeginGroup(rect); Vector2 cur = Vector2.zero; try { // TODO: Scrollable var i = 1; foreach (SaveFileInfo file in _saveFiles) { var row = new Rect(0f, cur.y, rect.width, _rowHeight); if (i++ % 2 == 0) { Widgets.DrawAltRect(row); } DrawFileEntry(row, file); cur.y += _rowHeight; } } finally { // make sure it gets ended even if something fails. GUI.EndGroup(); } } }
private void DrawEntry(DroidChassisPartDef d, Rect rect, bool alternate, string label = "") { string labelToUse = label.NullOrEmpty() ? d.LabelCap : label; if (d == selPart) { Widgets.DrawHighlightSelected(rect); if (Mouse.IsOver(rect)) { TooltipHandler.TipRegion(rect, d.GetTooltip()); } } else if (Mouse.IsOver(rect)) { Widgets.DrawHighlight(rect); TooltipHandler.TipRegion(rect, d.GetTooltip()); } else if (alternate) { Widgets.DrawAltRect(rect); } if (Widgets.ButtonInvisible(rect)) { selPart = d; } Text.Anchor = TextAnchor.MiddleLeft; if (d.color != null) { GUI.color = d.color.GetColor(); } Widgets.Label(rect, labelToUse); Text.Anchor = TextAnchor.UpperLeft; GUI.color = Color.white; }
/// <summary> /// Draw colonies list on Persistent RimWorlds. /// </summary> /// <param name="inRect"></param> /// <param name="margin"></param> /// <param name="colonies"></param> /// <param name="load"></param> public static void DrawColoniesList(ref Rect inRect, float margin, Vector2 closeButtonSize, List <PersistentColony> colonies, Action <int> load, Action newColony) { const int perRow = 3; var gap = (int)margin; inRect.width += gap; // TODO: Update with sorting option SortColoniesOneTime(ref colonies); UITools.DrawBoxGridView(out _, out var outRect, ref inRect, ref _scrollPosition, perRow, gap, (i, boxRect) => { if (i >= colonies.Count) { return(false); } var colony = colonies[i]; if (colony?.ColonyData == null || (colony.ColonyData.Leader != null && colony.ColonyData.Leader.LoadingTexture)) { return(false); } Widgets.DrawAltRect(boxRect); Widgets.DrawHighlightIfMouseover(boxRect); // Draw whole box button second. if (Widgets.ButtonInvisible(boxRect)) { load(i); } var texture = GetTexture(colony.ColonyData.ColonyFaction); var size = Mathf.Clamp(boxRect.width * 0.65f, 0, texture.width); var textureRect = new Rect(boxRect.x + margin, boxRect.y + boxRect.height / 2 - size / 2, size, size); DrawTexture(textureRect, texture, colony.ColonyData.Color); DrawLeader(boxRect, colony, margin, 0.56f); const float nameMargin = 4f; var colonyNameRect = new Rect(boxRect.x + nameMargin, boxRect.y + nameMargin, boxRect.width - nameMargin, textureRect.y - boxRect.y); DrawNameLabel(colonyNameRect, colony, colony.ColonyData.ColonyFaction); return(true); }, colonies.Count + 1, (width, height) => { /* * New Colony Button */ var y = width * Mathf.Floor((float)colonies.Count / perRow) + (colonies.Count / perRow) * gap; var boxRect = new Rect((width * (colonies.Count % perRow)) + (colonies.Count % perRow) * gap, y, width, width); Widgets.DrawHighlightIfMouseover(boxRect); Widgets.DrawAltRect(boxRect); if (Widgets.ButtonInvisible(boxRect)) { newColony(); } TooltipHandler.TipRegion(boxRect, "FilUnderscore.PersistentRimWorlds.Create.NewColony".Translate()); Widgets.DrawLine(new Vector2(boxRect.x + boxRect.width / 2, boxRect.y + boxRect.height / 3), new Vector2(boxRect.x + boxRect.width / 2, boxRect.y + boxRect.height * 0.66f), Color.white, 1f); Widgets.DrawLine(new Vector2(boxRect.x + boxRect.width / 3, boxRect.y + boxRect.height / 2), new Vector2(boxRect.x + boxRect.width * 0.66f, boxRect.y + boxRect.height / 2), Color.white, 1f); }, closeButtonSize); outRect.height -= closeButtonSize.y + margin; }
/// <summary> /// Draw in-game colonies tab. /// </summary> /// <param name="inRect">The rect that is being modified - the rect that holds the colonies UI elements.</param> /// <param name="margin">The margin spacing/gap between each colony UI element.</param> /// <param name="colonies">List of colonies to be displayed.</param> /// <param name="load">Action to run on click (colony load/switch).</param> /// <param name="tabSize">The size of the tab when opened depending on screen resolution.</param> public static void DrawColoniesTab(ref Rect inRect, float margin, List <PersistentColony> colonies, Action <int> load, Vector2 tabSize) { var gap = (int)margin; var persistentWorld = PersistentWorldManager.GetInstance().PersistentWorld; // TODO: Update with sorting system SortColoniesOneTime(ref colonies); SortColonies(ref colonies); // Scale the number of rows depending on the current resolution. int perRow = ((int)tabSize.x) / 160; // Reference is 6 per row @ 1920 resolution width. const float pct = 0.925f; var insideRect = inRect.BottomPart(pct); UITools.DrawBoxGridView(out _, out _, ref insideRect, ref _scrollPosition, perRow, gap, (i, origBoxRect) => { var boxRect = new Rect(origBoxRect.x, origBoxRect.y, origBoxRect.width * 0.8f, origBoxRect.height); var addRect = new Rect(boxRect.x + boxRect.width, boxRect.y, origBoxRect.width * 0.2f, origBoxRect.height); var colony = colonies[i]; Faction faction; // The top-left most colony is the current colony the player is playing as. if (Equals(colony, persistentWorld.Colony)) { Widgets.DrawHighlight(boxRect); faction = Find.FactionManager.OfPlayer; } else { Widgets.DrawAltRect(boxRect); faction = colony.ColonyData.ColonyFaction; } var texture = GetTexture(faction); var size = Mathf.Clamp(boxRect.width * 0.65f, 0, texture.width); var textureRect = new Rect(boxRect.x, boxRect.y, size, size); if (Equals(colony, persistentWorld.Colony)) { if (Widgets.ButtonImage(textureRect, texture, colony.ColonyData.Color)) { var callback = new Action <Color>(delegate(Color color) { colony.ColonyData.Color = color; }); Find.WindowStack.Add(new Dialog_ColourPicker(colony.ColonyData.Color, callback)); } } else { DrawTexture(textureRect, texture, colony.ColonyData.Color); Widgets.DrawHighlightIfMouseover(boxRect); if (Widgets.ButtonInvisible(boxRect)) { load(i); } } GUI.color = Color.white; DrawDynamicLeader(boxRect, out var leaderRect, colony, persistentWorld, 0.485f); TooltipHandler.TipRegion(textureRect, Equals(colony, persistentWorld.Colony) ? "FilUnderscore.PersistentRimWorlds.Colony.ChangeColor".Translate() : "FilUnderscore.PersistentRimWorlds.Colony.SwitchTo".Translate()); var colonyNameRect = new Rect(boxRect.x + 4f, textureRect.yMax, boxRect.width - leaderRect.width, boxRect.yMax - textureRect.yMax); DrawNameLabel(colonyNameRect, colony, faction); // Drawing additional stuff DrawFavouriteStar(addRect, colony); if (Equals(colony, persistentWorld.Colony)) { DrawAbandonColony(addRect, colony); } return(true); }, colonies.Count); // Draw Sort By Option var topRect = inRect.TopPart(1f - pct); DrawSortingDropdown(topRect); }
public Rect DoInterface(float x, float y, float width, int index) { Rect rect = new Rect(x, y, width, 53f); float num = 0f; if (!this.StatusString.NullOrEmpty()) { num = Mathf.Max(17f, this.StatusLineMinHeight); } rect.height += num; Color white = Color.white; if (!this.ShouldDoNow()) { white = new Color(1f, 0.7f, 0.7f, 0.7f); } GUI.color = white; Text.Font = GameFont.Small; if (index % 2 == 0) { Widgets.DrawAltRect(rect); } GUI.BeginGroup(rect); Rect rect2 = new Rect(0f, 0f, 24f, 24f); if (this.billStack.IndexOf(this) > 0) { if (Widgets.ButtonImage(rect2, TexButton.ReorderUp, white)) { this.billStack.Reorder(this, -1); SoundDefOf.Tick_High.PlayOneShotOnCamera(null); } TooltipHandler.TipRegion(rect2, "ReorderBillUpTip".Translate()); } if (this.billStack.IndexOf(this) < this.billStack.Count - 1) { Rect rect3 = new Rect(0f, 24f, 24f, 24f); if (Widgets.ButtonImage(rect3, TexButton.ReorderDown, white)) { this.billStack.Reorder(this, 1); SoundDefOf.Tick_Low.PlayOneShotOnCamera(null); } TooltipHandler.TipRegion(rect3, "ReorderBillDownTip".Translate()); } Rect rect4 = new Rect(28f, 0f, rect.width - 48f - 20f, rect.height + 5f); Widgets.Label(rect4, this.LabelCap); this.DoConfigInterface(rect.AtZero(), white); Rect rect5 = new Rect(rect.width - 24f, 0f, 24f, 24f); if (Widgets.ButtonImage(rect5, TexButton.DeleteX, white, white * GenUI.SubtleMouseoverColor)) { this.billStack.Delete(this); SoundDefOf.Click.PlayOneShotOnCamera(null); } TooltipHandler.TipRegion(rect5, "DeleteBillTip".Translate()); Rect rect7; if (this.CanCopy) { Rect rect6 = new Rect(rect5); rect6.x -= rect6.width + 4f; if (Widgets.ButtonImageFitted(rect6, TexButton.Copy, white)) { BillUtility.Clipboard = this.Clone(); SoundDefOf.Tick_High.PlayOneShotOnCamera(null); } TooltipHandler.TipRegion(rect6, "CopyBillTip".Translate()); rect7 = new Rect(rect6); } else { rect7 = new Rect(rect5); } rect7.x -= rect7.width + 4f; if (Widgets.ButtonImage(rect7, TexButton.Suspend, white)) { this.suspended = !this.suspended; SoundDefOf.Click.PlayOneShotOnCamera(null); } TooltipHandler.TipRegion(rect7, "SuspendBillTip".Translate()); if (!this.StatusString.NullOrEmpty()) { Text.Font = GameFont.Tiny; Rect rect8 = new Rect(24f, rect.height - num, rect.width - 24f, num); Widgets.Label(rect8, this.StatusString); this.DoStatusLineInterface(rect8); } GUI.EndGroup(); if (this.suspended) { Text.Font = GameFont.Medium; Text.Anchor = TextAnchor.MiddleCenter; Rect rect9 = new Rect(rect.x + rect.width / 2f - 70f, rect.y + rect.height / 2f - 20f, 140f, 40f); GUI.DrawTexture(rect9, TexUI.GrayTextBG); Widgets.Label(rect9, "SuspendedCaps".Translate()); Text.Anchor = TextAnchor.UpperLeft; Text.Font = GameFont.Small; } Text.Font = GameFont.Small; GUI.color = Color.white; return(rect); }
public void DoContent(Rect rect) { // layout: settings | trees // draw background Widgets.DrawMenuSection(rect); // some variables float width = rect.width; float height = rect.height - _topAreaHeight - _button.y - Margin; var cols = 2; float colWidth = width / cols - Margin; var colRects = new List <Rect>(); var colTitleRects = new List <Rect>(); var buttonRect = new Rect(rect.width - _button.x, rect.height - _button.y, _button.x - Margin, _button.y - Margin); // set up rects for (var j = 0; j < cols; j++) { colRects.Add(new Rect(j * colWidth + j * Margin + Margin / 2, _topAreaHeight, colWidth, height)); colTitleRects.Add(new Rect(j * colWidth + j * Margin + Margin * 2.5f, 0f, colWidth, _topAreaHeight)); } // keep track of location Vector2 cur; // begin window GUI.BeginGroup(rect); // settings. Text.Anchor = TextAnchor.LowerLeft; Text.Font = GameFont.Tiny; Widgets.Label(colTitleRects[0], "FMF.Options".Translate()); Text.Font = GameFont.Small; Text.Anchor = TextAnchor.UpperLeft; GUI.DrawTexture(colRects[0], Resources.SlightlyDarkBackground); GUI.BeginGroup(colRects[0]); cur = Vector2.zero; // trigger config (1) int currentCount = _selected.Trigger.CurCount; int designatedCount = _selected.GetWoodInDesignations(); int targetCount = _selected.Trigger.Count; _selected.Trigger.DrawTriggerConfig(ref cur, colRects[0].width, EntryHeight, true, "FMF.TargetCount".Translate(currentCount, designatedCount, targetCount), "FMF.TargetCountTooltip".Translate(currentCount, designatedCount, targetCount)); // Clear wind cells (2) var clearWindCellsRect = new Rect(cur.x, cur.y, colWidth, EntryHeight); Utilities.DrawToggle(clearWindCellsRect, "FMF.ClearWindCells".Translate(), ref ManagerJob_Forestry.ClearWindCells); cur.y += EntryHeight; // clear additional areas(3) var clearAdditionalAreasLabelRect = new Rect(cur.x, cur.y, colWidth, EntryHeight); Widgets.DrawAltRect(clearAdditionalAreasLabelRect); Utilities.Label(clearAdditionalAreasLabelRect, "FMF.ClearAreas".Translate(), anchor: TextAnchor.MiddleLeft, lrMargin: Margin); cur.y += EntryHeight; var clearAdditionalAreasSelectorRect = new Rect(cur.x, cur.y, colWidth, EntryHeight); Widgets.DrawAltRect(clearAdditionalAreasSelectorRect); AreaAllowedGUI.DoAllowedAreaSelectorsMC(clearAdditionalAreasSelectorRect, ref _selected.ClearAreas, Margin); cur.y += EntryHeight; // Allow saplings (4) var allowSaplingsRect = new Rect(cur.x, cur.y, colWidth, EntryHeight); Utilities.DrawToggle(allowSaplingsRect, "FMF.AllowSaplings".Translate(), ref _selected.AllowSaplings); cur.y += EntryHeight; // Logging area (5) var loggingAreaTitleRect = new Rect(cur.x, cur.y, colWidth, EntryHeight); Widgets.DrawAltRect(loggingAreaTitleRect); Utilities.Label(loggingAreaTitleRect, "FMF.LoggingArea".Translate(), anchor: TextAnchor.MiddleLeft, lrMargin: Margin); cur.y += EntryHeight; var loggingAreaRect = new Rect(cur.x, cur.y, colWidth, EntryHeight); Widgets.DrawAltRect(loggingAreaRect); AreaAllowedGUI.DoAllowedAreaSelectors(loggingAreaRect, ref _selected.LoggingArea, manager, lrMargin: Margin); cur.y += EntryHeight; GUI.EndGroup(); // treedefs. Text.Anchor = TextAnchor.LowerLeft; Text.Font = GameFont.Tiny; Widgets.Label(colTitleRects[1], "FMF.Trees".Translate()); Text.Font = GameFont.Small; Text.Anchor = TextAnchor.UpperLeft; GUI.DrawTexture(colRects[1], Resources.SlightlyDarkBackground); GUI.BeginGroup(colRects[1]); cur = Vector2.zero; Rect outRect = colRects[1].AtZero().ContractedBy(1f); var viewRect = new Rect(0f, 0f, outRect.width, _selected.AllowedTrees.Count * EntryHeight); if (viewRect.height > outRect.height) { viewRect.width -= 16f; } // start scrolling view Widgets.BeginScrollView(outRect, ref _contentScrollPosition, viewRect); // list of keys in allowed trees list (all plans that yield wood in biome, static) var treeDefs = new List <ThingDef>(_selected.AllowedTrees.Keys); // toggle all var toggleAllRect = new Rect(cur.x, cur.y, colWidth, EntryHeight); Widgets.DrawAltRect(toggleAllRect); Utilities.DrawToggle(toggleAllRect, "<i>" + "FM.All".Translate() + "</i>", _selected.AllowedTrees.Values.All(v => v), delegate { foreach ( ThingDef def in treeDefs) { _selected.AllowedTrees[def] = true; } }, delegate { foreach ( ThingDef def in treeDefs) { _selected.AllowedTrees [def] = false; } }); cur.y += EntryHeight; // toggle for each tree var i = 1; foreach (ThingDef def in treeDefs) { var toggleRect = new Rect(cur.x, cur.y, colWidth, EntryHeight); // highlight alternate rows if (i++ % 2 == 0) { Widgets.DrawAltRect(toggleRect); } // draw the toggle Utilities.DrawToggle(toggleRect, def.LabelCap, _selected.AllowedTrees[def], delegate { _selected.AllowedTrees[def] = !_selected.AllowedTrees[def]; }); // update current position cur.y += EntryHeight; } // close scrolling view Widgets.EndScrollView(); // close tree list GUI.EndGroup(); // do the button if (!_selected.Managed) { if (Widgets.ButtonText(buttonRect, "FM.Manage".Translate())) { // activate job, add it to the stack _selected.Managed = true; manager.JobStack.Add(_selected); // refresh source list Refresh(); } } else { if (Widgets.ButtonText(buttonRect, "FM.Delete".Translate())) { // inactivate job, remove from the stack. manager.JobStack.Delete(_selected); // remove content from UI _selected = null; // refresh source list Refresh(); } } // close window GUI.EndGroup(); }