/// <summary> /// Initializes static members of the <see cref="Dialog_StuffAndQuality"/> class. /// </summary> static Dialog_StuffAndQuality() { // Set size. float width = GenUI.GetWidthCached(UIText.TenCharsString.Times(12)); _initialSize = new Vector2(width, Verse.UI.screenHeight / 3f + GenUI.ListSpacing); _initialSizeForWeapon = new Vector2(_initialSize.x * 1.1f, _initialSize.y); _initialSizeForNoStuff = new Vector2(_initialSize.x * 0.5f, _initialSize.y); _armorStats = new List <StatDef>() { StatDefOf.MaxHitPoints, StatDefOf.ArmorRating_Sharp, StatDefOf.ArmorRating_Blunt, StatDefOf.ArmorRating_Heat, StatDefOf.Insulation_Cold, StatDefOf.Insulation_Heat, StatDefOf.Mass, }; _baseWeaponStats = new List <StatDef>() { StatDefOf.MaxHitPoints, StatDefOf.MeleeWeapon_AverageDPS, StatDefOf.MeleeWeapon_AverageArmorPenetration, StatDefOf.Mass, }; _meleeWeaponStats = new List <StatDef>() { StatDefOf.MeleeWeapon_CooldownMultiplier, }; _rangedWeaponStats = new List <string>() { RangedWeaponStatsString.ArmorPenetration, RangedWeaponStatsString.Damage, }.Select(s => ToStatDef(s)).ToList(); _generalItemStats = new List <StatDef>() { StatDefOf.MaxHitPoints, StatDefOf.MarketValue, StatDefOf.Mass, }; }
/// <summary> /// Initializes a new instance of the <see cref="Dialog_ManageLoadouts"/> class. /// </summary> /// <param name="loadout"> Selected loadout. </param> /// <param name="pawn"> Selected pawn. </param> public Dialog_ManageLoadouts(AwesomeInventoryLoadout loadout, Pawn pawn) { ValidateArg.NotNull(loadout, nameof(loadout)); _pawn = pawn ?? throw new ArgumentNullException(nameof(pawn)); float width = GenUI.GetWidthCached(UIText.TenCharsString.Times(11)); _initialSize = new Vector2(width, Verse.UI.screenHeight / 2f); _currentLoadout = loadout; _resettables.Add(this); _resettables.Add(new WhiteBlacklistView()); doCloseX = true; forcePause = true; absorbInputAroundWindow = false; closeOnClickedOutside = false; closeOnAccept = false; }
/// <summary> /// Draw choices for preview quality. /// </summary> /// <param name="widgetRow"> Helper for drawing. </param> protected virtual void DrawPreviewQuality(WidgetRow widgetRow) { ValidateArg.NotNull(widgetRow, nameof(widgetRow)); GUI.color = Color.grey; Text.Anchor = TextAnchor.MiddleLeft; widgetRow.LabelWithHighlight(UIText.PreviewQuality.TranslateSimple(), UIText.PreviewQualityTooltip.TranslateSimple()); GUI.color = Color.white; if (widgetRow.ButtonIcon(TexResource.TriangleLeft)) { _qualityPreview = _qualityPreview.Previous(); } Text.Anchor = TextAnchor.MiddleCenter; widgetRow.Label(_qualityPreview.GetLabel(), GenUI.GetWidthCached(UIText.TenCharsString)); if (widgetRow.ButtonIcon(TexResource.TriangleRight)) { _qualityPreview = _qualityPreview.Next(); } }
public void DrawGUI(ref float yref, float width, float maxPowerUsage) { GUI.BeginGroup(new Rect(GenUI.GapWide, yref, width - GenUI.Gap - GenUI.GapTiny * 2, GenUI.ListSpacing)); Rect rect = new Rect(0, 0, width - GenUI.Gap * 2 - GenUI.ScrollBarWidth, GenUI.ListSpacing); Widgets.DrawHighlightIfMouseover(rect); Widgets.ThingIcon(rect.LeftPartPixels(rect.height), parent); if (Widgets.ButtonInvisible(rect)) { CameraJumper.TryJumpAndSelect(new GlobalTargetInfo(parent)); } rect.xMin += rect.height; Widgets.Label(rect.LeftPartPixels(150 - GenUI.GapWide).ContractedBy(GenUI.GapTiny), parent.LabelShortCap); rect.xMin += 150 - GenUI.GapWide; Widgets.FillableBarLabeled(rect.ContractedBy(GenUI.GapTiny), Math.Abs(PowerUsage) / maxPowerUsage, 50, "Power"); string Label = "{0}W".Formatted(PowerUsage.ToString("0")); float Width = GenUI.GetWidthCached(Label); rect = new RectOffset(-58, 0, -4, -4).Add(rect).LeftPartPixels(Width + 4); Widgets.DrawRectFast(new RectOffset(0, 4, -4, -4).Add(rect), Color.black); Widgets.Label(new RectOffset(-4, 4, 0, 0).Add(rect), Label); yref += GenUI.ListSpacing + GenUI.GapTiny; GUI.EndGroup(); }
private Rect GetHeaderRect(float x, string translatedText) { float width = GenUI.GetWidthCached(translatedText) + Widgets.RadioButtonSize + GenUI.GapSmall; return(new Rect(x, GenUI.GapSmall, width, GenUI.ListSpacing)); }
protected override void FillTab() { CompPowerTracker compPower = SelThing.TryGetComp <CompPowerTracker>(); if (compPower == null) { return; } PowerNet powerNet = compPower.powerNet; if (powerNet == null) { return; } Widgets.BeginScrollView( new Rect(default(Vector2), size).ContractedBy(GenUI.GapTiny), ref scrollPos, new Rect(default(Vector2), new Vector2(size.x - GenUI.GapTiny * 2 - GenUI.ScrollBarWidth, lastY)) ); float yref = 10; IEnumerable <IGrouping <CompPowerTracker.PowerType, IGrouping <ThingDef, CompPowerTracker> > > categories = powerNet.batteryComps.ConvertAll((c) => c.parent.GetComp <CompPowerTracker>()) .Concat(powerNet.powerComps.ConvertAll((c) => c.parent.GetComp <CompPowerTracker>())) .GroupBy((c) => c.parent.def) .GroupBy((d) => CompPowerTracker.powerTypeFor(d.Key)); foreach (IGrouping <CompPowerTracker.PowerType, IGrouping <ThingDef, CompPowerTracker> > type in categories) { float p = type.Sum((g) => g.Sum((t) => t.PowerUsage)); float m = type.Sum((g) => g.Sum((t) => t.maxPowerUsage)); Rect rect = new Rect(150, yref, size.x - 172, Text.SmallFontHeight); Widgets.FillableBarLabeled(rect, Math.Abs(p / m), 0, ""); string Label = "{0}W".Formatted(p.ToString("0")); float Width = GenUI.GetWidthCached(Label); Widgets.DrawRectFast(new RectOffset(-4, -4, -4, -4).Add(rect).LeftPartPixels(Width + 4), Color.black); Widgets.Label(new RectOffset(-4, 0, 0, 0).Add(rect), Label); Widgets.ListSeparator(ref yref, rect.width, "{0}".Formatted(CompPowerTracker.powerTypeString[(int)type.Key])); float maxPowerUsage = type.Max((g) => g.Sum((c) => Math.Abs(c.maxPowerUsage))); yref += GenUI.GapTiny; foreach (IGrouping <ThingDef, CompPowerTracker> defs in type) { // Begin group; All future GUI elements are relative to this group GUI.BeginGroup(new Rect(0, yref, size.x, Text.SmallFontHeight + GenUI.GapTiny * 2)); // Make a rect that is the size of our group rect = new Rect(0, 0, size.x - GenUI.GapTiny * 2 - GenUI.ScrollBarWidth, Text.SmallFontHeight + GenUI.GapTiny * 2); // Draw a background behind our group Widgets.DrawOptionSelected(rect); if (!collapseTab.ContainsKey(defs.Key)) { collapseTab.Add(defs.Key, false); } if (Widgets.ButtonText(rect.LeftPartPixels(rect.height).ContractedBy(GenUI.GapTiny), collapseTab[defs.Key] ? "-" : "+")) { collapseTab[defs.Key] = !collapseTab[defs.Key]; } rect.xMin += rect.height; Widgets.Label(rect.LeftPartPixels(150).ContractedBy(GenUI.GapTiny), "{0} {1}".Formatted(defs.Count(), defs.Key.LabelCap)); rect.xMin += 150; Widgets.FillableBarLabeled(rect.ContractedBy(GenUI.GapTiny), defs.Sum((c) => Math.Abs(c.PowerUsage)) / maxPowerUsage, 50, "Power"); Label = "{0}W".Formatted(defs.Sum((c) => c.PowerUsage).ToString("0")); Width = GenUI.GetWidthCached(Label); rect = new RectOffset(-58, 0, -4, -4).Add(rect).LeftPartPixels(Width + 4); Widgets.DrawRectFast(new RectOffset(0, 0, -4, -4).Add(rect), Color.black); Widgets.Label(rect, Label); yref += GenUI.ListSpacing + GenUI.GapTiny; GUI.EndGroup(); if (collapseTab[defs.Key]) { foreach (CompPowerTracker comp in defs) { comp.DrawGUI(ref yref, size.x, defs.Max((c) => c.maxPowerUsage)); } } } } Widgets.EndScrollView(); lastY = yref; }