private void DrawKeyEntry(KeyBindingDef keyDef, Rect parentRect, ref float curY, bool skipDrawing) { if (!skipDrawing) { Rect rect = new Rect(parentRect.x, parentRect.y + curY, parentRect.width, 34f).ContractedBy(3f); GenUI.SetLabelAlign(TextAnchor.MiddleLeft); Widgets.Label(rect, keyDef.LabelCap); GenUI.ResetLabelAlign(); float num = 4f; Vector2 vector = new Vector2(140f, 28f); Rect rect2 = new Rect(rect.x + rect.width - vector.x * 2f - num, rect.y, vector.x, vector.y); Rect rect3 = new Rect(rect.x + rect.width - vector.x, rect.y, vector.x, vector.y); TooltipHandler.TipRegion(rect2, new TipSignal("BindingButtonToolTip".Translate())); TooltipHandler.TipRegion(rect3, new TipSignal("BindingButtonToolTip".Translate())); if (Widgets.ButtonText(rect2, keyPrefsData.GetBoundKeyCode(keyDef, KeyPrefs.BindingSlot.A).ToStringReadable())) { SettingButtonClicked(keyDef, KeyPrefs.BindingSlot.A); } if (Widgets.ButtonText(rect3, keyPrefsData.GetBoundKeyCode(keyDef, KeyPrefs.BindingSlot.B).ToStringReadable())) { SettingButtonClicked(keyDef, KeyPrefs.BindingSlot.B); } } curY += 34f; }
public static bool LabelSelectable(Rect rect, string label, ref bool selected, TextAnchor textAnchor = TextAnchor.MiddleLeft) { if (selected) { DrawHighlightColor(rect, Color.green, 0.5f); } else { Verse.Widgets.DrawHighlight(rect.ContractedByButLeft(5f)); } Verse.Widgets.DrawHighlightIfMouseover(rect); GenUI.SetLabelAlign(textAnchor); Verse.Widgets.Label(rect, label); GenUI.ResetLabelAlign(); var flag = selected; var butRect = rect; butRect.width -= 5f; if (!selected && Verse.Widgets.ButtonInvisible(butRect)) { SoundDefOf.Tick_Tiny.PlayOneShotOnCamera(); selected = true; } return(selected && !flag); }
public override void DoCell(Rect rect, Pawn pawn, PawnTable table) { if (pawn.RaceProps.IsMechanoid) { return; } if (pawn.RaceProps.Animal) { return; } SkillRecord skill = pawn.skills?.GetSkill(def.Ext().skill); if (skill == null) { return; } GUI.BeginGroup(rect); Rect position = new Rect(3f, 3f, 24f, 24f); if (skill.passion > Passion.None) { Texture2D image = (skill.passion != Passion.Major) ? passionMinorIcon : passionMajorIcon; GUI.DrawTexture(position, image); } if (!skill.TotallyDisabled) { Rect rect3 = new Rect(position.xMax, 0f, rect.width - position.xMax, rect.height); Widgets.FillableBar(rect3, skill.Level / 20f, SkillBarFillTex, SkillBarBgTex, false); } Rect rect4 = new Rect(position.xMax + 4f, 0f, 999f, rect.height); rect4.yMin += 3f; string label; if (skill.TotallyDisabled) { GUI.color = DisabledSkillColor; label = "-"; } else { label = skill.Level.ToStringCached(); } GenUI.SetLabelAlign(TextAnchor.MiddleLeft); Widgets.Label(rect4, label); GenUI.ResetLabelAlign(); GUI.color = Color.white; GUI.EndGroup(); string tip = GetTip(pawn, skill); if (!tip.NullOrEmpty()) { TooltipHandler.TipRegion(rect, tip); } }
private bool DrawDefaultHandleEntry(SettingHandle handle, Rect trimmedEntryRect, bool mouseOverEntry) { var controlRect = new Rect(trimmedEntryRect.x + trimmedEntryRect.width / 2f, trimmedEntryRect.y, trimmedEntryRect.width / 2f, trimmedEntryRect.height); GenUI.SetLabelAlign(TextAnchor.MiddleLeft); var leftHalfRect = new Rect(trimmedEntryRect.x, trimmedEntryRect.y, trimmedEntryRect.width / 2f - HandleEntryPadding, trimmedEntryRect.height); // give full width to the label if custom control drawer is used- this allows handle titles to be used as section titles var labelRect = handle.CustomDrawer == null ? leftHalfRect : trimmedEntryRect; // reduce text size if label is long and wraps over to the second line var controlInfo = handleControlInfo[handle]; var cachedTitle = controlInfo.handleTitle ?? (controlInfo.handleTitle = new CachedLabel(handle.Title)); if (cachedTitle.GetHeight(labelRect.width) > labelRect.height) { Text.Font = GameFont.Tiny; labelRect = new Rect(labelRect.x, labelRect.y - 1f, labelRect.width, labelRect.height + 2f); } else { Text.Font = GameFont.Small; } Widgets.Label(labelRect, cachedTitle.Text); Text.Font = GameFont.Small; GenUI.ResetLabelAlign(); var valueChanged = false; if (handle.CustomDrawer == null) { var handleType = handle.ValueType; if (handleType.IsEnum) { handleType = typeof(Enum); } handleDrawers.TryGetValue(handleType, out var drawer); if (drawer == null) { drawer = defaultHandleDrawer; } valueChanged = drawer(handle, controlRect, controlInfo); } else { try { valueChanged = handle.CustomDrawer(controlRect); } catch (Exception e) { HugsLibController.Logger.ReportException(e, currentlyDrawnEntry, true, $"{nameof(SettingHandle)}.{nameof(SettingHandle.CustomDrawer)}"); } } if (mouseOverEntry) { DrawEntryHoverMenu(trimmedEntryRect, handle); } return(valueChanged); }
public override void DoWindowContents(Rect inRect) { const float contentRectInset = 10f; var bottomButtonRowHeight = CloseButSize.y; var bottomPadding = bottomButtonRowHeight + (Margin - contentRectInset); var contentRect = new Rect(0, 0, inRect.width, inRect.height - bottomPadding).ContractedBy(contentRectInset); GUI.BeginGroup(contentRect); var titleRect = new Rect(0f, 0f, contentRect.width, HeaderLabelHeight); Text.Font = GameFont.Medium; GenUI.SetLabelAlign(TextAnchor.MiddleCenter); Widgets.Label(titleRect, "HugsLib_features_title".Translate()); if (Mouse.IsOver(titleRect)) { Widgets.DrawHighlight(titleRect); TooltipHandler.TipRegion(titleRect, "HugsLib_features_description".Translate()); } GenUI.ResetLabelAlign(); if (!anyImagesPending) { Text.Font = GameFont.Small; var scrollViewRect = new Rect(0f, titleRect.height, contentRect.width, contentRect.height - titleRect.height); var scrollBarVisible = totalContentHeight > scrollViewRect.height; if (!scrollBarVisible) { scrollViewRect.x += ScrollBarWidthMargin / 2f; } var scrollContentWidth = scrollViewRect.width - ScrollBarWidthMargin; if (totalContentHeight < 0) { CalculateContentHeight(scrollContentWidth); } var scrollContentRect = new Rect(0f, 0f, scrollContentWidth, totalContentHeight); Widgets.BeginScrollView(scrollViewRect, ref scrollPosition, scrollContentRect); var curY = 0f; for (int i = 0; i < entries.Count; i++) { var entry = entries[i]; bool skipDrawing = curY - scrollPosition.y + EntryTitleHeight <0f || curY - scrollPosition.y> scrollViewRect.height; DrawEntryTitle(entry, scrollContentRect.width, ref curY, skipDrawing); var indentedContent = new Rect(EntryContentIndent, 0, scrollContentRect.width - EntryContentIndent, scrollContentRect.height); DescriptionSegment lastSegment = null; for (int j = 0; j < entry.segments.Count; j++) { var segment = entry.segments[j]; skipDrawing = curY - scrollPosition.y + segment.expectedHeight <0f || curY - scrollPosition.y> scrollViewRect.height; segment.Draw(indentedContent, ref curY, resolvedImages, lastSegment, skipDrawing); lastSegment = segment; } curY += EntryFooterHeight; } Widgets.EndScrollView(); } GUI.EndGroup(); DrawBottomButtonRow(inRect.BottomPartPixels(bottomButtonRowHeight)); }
private void DrawCurrentFilterLabel(Rect inRect) { GenUI.SetLabelAlign(TextAnchor.MiddleLeft); var prevColor = GUI.color; GUI.color = new Color(.5f, .5f, .5f); var currentFilterModNameReadable = defFilter.CurrentFilterModNameReadable ?? allModsFilterLabel; Widgets.Label(inRect, currentFilterReadout.Formatted(currentFilterModNameReadable)); GUI.color = prevColor; GenUI.ResetLabelAlign(); }
public static void DrawSkill(SkillRecord skill, Rect holdingRect, SkillDrawMode mode, string tooltipPrefix = "") { if (Mouse.IsOver(holdingRect)) { GUI.DrawTexture(holdingRect, TexUI.HighlightTex); } GUI.BeginGroup(holdingRect); Text.Anchor = TextAnchor.MiddleLeft; Rect rect = new Rect(6f, 0f, levelLabelWidth + 6f, holdingRect.height); Widgets.Label(rect, skill.def.skillLabel.CapitalizeFirst()); Rect position = new Rect(rect.xMax, 0f, 24f, 24f); if (!skill.TotallyDisabled) { if ((int)skill.passion > 0) { Texture2D image = ((skill.passion == Passion.Major) ? PassionMajorIcon : PassionMinorIcon); GUI.DrawTexture(position, image); } Rect rect2 = new Rect(position.xMax, 0f, holdingRect.width - position.xMax, holdingRect.height); float fillPercent = Mathf.Max(0.01f, (float)skill.Level / 20f); Widgets.FillableBar(rect2, fillPercent, SkillBarFillTex, null, doBorder: false); } Rect rect3 = new Rect(position.xMax + 4f, 0f, 999f, holdingRect.height); rect3.yMin += 3f; string label; if (skill.TotallyDisabled) { GUI.color = DisabledSkillColor; label = "-"; } else { label = skill.Level.ToStringCached(); } GenUI.SetLabelAlign(TextAnchor.MiddleLeft); Widgets.Label(rect3, label); GenUI.ResetLabelAlign(); GUI.color = Color.white; GUI.EndGroup(); if (Mouse.IsOver(holdingRect)) { string text = GetSkillDescription(skill); if (tooltipPrefix != "") { text = tooltipPrefix + "\n\n" + text; } TooltipHandler.TipRegion(holdingRect, new TipSignal(text, skill.def.GetHashCode() * 397945)); } }
public override void DoWindowContents(Rect inRect) { var rect = inRect; // set up column size _listingStandard.ColumnWidth = inRect.width; // begin drawing _listingStandard.Begin(rect); // get a Rect for the next label (without actually 'allocating' it in the Listing_Standard) var nextRect = _listingStandard.VirtualRect(30f); // split the Rect var labelRect = nextRect.LeftPart(0.9f); var buttonRect = nextRect.RightPart(0.1f); // add 'title' for the minimized window _listingStandard.GetRect(30f); GenUI.SetLabelAlign(TextAnchor.MiddleCenter); Verse.Widgets.Label(labelRect, WindowLabel); GenUI.ResetLabelAlign(); // add 'maximize' button if (Verse.Widgets.ButtonText(buttonRect, "▲")) { Close(); } TooltipHandler.TipRegion(buttonRect, "Maximize Window"); // make some space before eventual content _listingStandard.GapLine(6f); // subscribers can add new content to the minimized window. AddMinimizedWindowContent?.Invoke(_listingStandard, inRect); // check if the height changed (meaning new content was added) if (Math.Abs(windowRect.height - InitialSize.y) > 1f && !_minimizedWindowHasAddedContent) { // recalculate y position windowRect.y = (UI.screenHeight - windowRect.height) / 2; // do it only once _minimizedWindowHasAddedContent = true; } // end drawing _listingStandard.End(); }
private void DrawSkill(Rect rect, Pawn ownerPawn) { if (ownerPawn.RaceProps.IsMechanoid) { return; } if (ownerPawn.RaceProps.Animal) { return; } SkillRecord skill = ownerPawn.skills.GetSkill((SkillDef)displayObject); GUI.BeginGroup(rect); Rect position = new Rect(3f, 3f, 24f, 24f); if (skill.passion > Passion.None) { Texture2D image = (skill.passion != Passion.Major) ? passionMinorIcon : passionMajorIcon; GUI.DrawTexture(position, image); } if (!skill.TotallyDisabled) { Rect rect3 = new Rect(position.xMax, 0f, rect.width - position.xMax, rect.height); Widgets.FillableBar(rect3, (float)skill.level / 20f, SkillBarFillTex, SkillBarBgTex, false); } Rect rect4 = new Rect(position.xMax + 4f, 0f, 999f, rect.height); rect4.yMin += 3f; string label; if (skill.TotallyDisabled) { GUI.color = DisabledSkillColor; label = "-"; } else { label = skill.level.ToStringCached(); } GenUI.SetLabelAlign(TextAnchor.MiddleLeft); Widgets.Label(rect4, label); GenUI.ResetLabelAlign(); GUI.color = Color.white; GUI.EndGroup(); TooltipHandler.TipRegion(rect, new TipSignal((string)mGetSkillDescription.Invoke(null, new[] { skill }), skill.def.GetHashCode() * 397945)); }
// RimWorld.SkillUI// public static void DrawTier(CosmicEntity entity, Vector2 topLeft) { if (entity == null) { return; } _ = entity.PlayerTier.ToString(); string standingLabel = "Standing".Translate() + ":"; var tierLabelWidth = Text.CalcSize(standingLabel).x; var tierCurrentVal = entity.PlayerFavor; var tierCurrentMax = entity.currentTierMax; var tierPrevMax = entity.prevTierMax; var rect = new Rect(topLeft.x, topLeft.y, 150f, 24f); if (Mouse.IsOver(rect)) { GUI.DrawTexture(rect, TexUI.HighlightTex); } GUI.BeginGroup(rect); Text.Anchor = TextAnchor.MiddleLeft; var rect2 = new Rect(0f, 0f, tierLabelWidth + 5f, rect.height); Widgets.Label(rect2, standingLabel); var position = new Rect(rect2.xMax, 0f, 10f, 24f); var rect3 = new Rect(position.xMax, 0f, rect.width - position.xMax, rect.height); Widgets.FillableBar(rect3, (tierCurrentVal - tierPrevMax) / (tierCurrentMax - tierPrevMax), Buttons.TierBarFillTex, null, false); var rect4 = new Rect(position.xMax + 4f, 0f, 999f, rect.height); //rect4.yMin += 10f; rect4.yMax += 18f; var label = entity.TierString; GenUI.SetLabelAlign(TextAnchor.MiddleLeft); Widgets.Label(rect4, label); GenUI.ResetLabelAlign(); GUI.color = Color.white; GUI.EndGroup(); TooltipHandler.TipRegion(rect, new TipSignal(GetFavorDescription(entity), entity.def.GetHashCode() * 397945)); }
public void Draw(Rect rect, ref float curY, Dictionary <string, Texture2D> images, DescriptionSegment previousSegment, bool skipDrawing) { if (type == SegmentType.Image && imageNames != null) { if (!skipDrawing) { if (cachedTextures == null) { cachedTextures = CacheOwnTextures(images); } var curX = rect.x; for (int i = 0; i < cachedTextures.Count; i++) { var tex = cachedTextures[i]; var texRect = new Rect(curX, curY + SegmentImageMargin, tex.width, tex.height); Widgets.DrawTextureFitted(texRect, tex, 1); curX += tex.width + SegmentImageMargin; } } curY += expectedHeight; } else if (type == SegmentType.Caption && text != null && previousSegment != null) { // can't skipDrawing this one, since it's drawn at a negative offset var offset = previousSegment.expectedWidth + SegmentImageMargin; var textRect = new Rect(offset, curY - previousSegment.expectedHeight, rect.width - offset, previousSegment.expectedHeight); GenUI.SetLabelAlign(TextAnchor.MiddleLeft); Widgets.Label(textRect, text); GenUI.ResetLabelAlign(); } else if (type == SegmentType.Text && text != null) { if (!skipDrawing) { var textRect = new Rect(rect.x, curY + SegmentTextMargin, rect.width, expectedHeight); Widgets.Label(textRect, text); } curY += expectedHeight; } }
public override void DoWindowContents(Rect inRect) { // Title GenUI.SetLabelAlign(TextAnchor.MiddleCenter); Text.Font = GameFont.Medium; var titleRect = new Rect(0f, 0f, inRect.width, 40f); Widgets.Label(titleRect, "Dialog_EditNames_Title".Translate()); Text.Font = GameFont.Tiny; GenUI.ResetLabelAlign(); //Name list var scrollViewVisible = new Rect(0f, titleRect.height + 10, inRect.width, inRect.height - titleRect.height - 60f); var scrollBarVisible = SettingsHandler.STATE_LIMIT * 42f > scrollViewVisible.height; var scrollViewTotal = new Rect(0f, 0f - 10f, scrollViewVisible.width - (scrollBarVisible ? ScrollBarWidthMargin : 0) - 20f, SettingsHandler.STATE_LIMIT * 42f); Widgets.BeginScrollView(scrollViewVisible, ref scrollPosition, scrollViewTotal); if (SettingsHandler.DoStateNamesDrawerContents(scrollViewTotal)) { settingsHaveChanged = true; } Widgets.EndScrollView(); }
public override void DoSettingsWindowContents(Rect rect) { Listing_Standard list = new Listing_Standard() { ColumnWidth = rect.width }; list.Begin(rect); list.Gap(10); { Rect fullRect = list.GetRect(Text.LineHeight); Rect leftRect = fullRect.LeftHalf().Rounded(); Rect rightRect = fullRect.RightHalf().Rounded(); GenUI.SetLabelAlign(TextAnchor.MiddleRight); Widgets.Label(leftRect, Static.LabelStoneTypesAvailable); GenUI.ResetLabelAlign(); Widgets.IntRange(rightRect, 316192000, ref Settings.StoneTypesAvailable, 1, 8); } list.Gap(25); { Rect fullRect = list.GetRect(30f); Rect leftLabelRect = fullRect.LeftHalf().Rounded(); Rect rightLabelRect = fullRect.RightHalf().Rounded(); Text.Font = GameFont.Medium; Text.Anchor = TextAnchor.MiddleCenter; Widgets.Label(leftLabelRect, Static.LabelStoneTypesToSpawn); Text.Anchor = TextAnchor.UpperLeft; Text.Font = GameFont.Small; } list.Gap(10); { Rect fullRect = list.GetRect(30f); Rect rightLabelRect = fullRect.RightHalf().Rounded(); DualCheckboxesWithIcons_ThingDef( fullRect.LeftHalf(), StoneDefOf.ChunkLimestone, StoneDefOf.ChunkSandstone, StoneDefOf.Limestone.LabelCap, StoneDefOf.Sandstone.LabelCap, ref Settings.SpawnLimestone, ref Settings.SpawnSandstone ); } list.Gap(10); { Rect fullRect = list.GetRect(30f); DualCheckboxesWithIcons_ThingDef( fullRect.LeftHalf(), StoneDefOf.ChunkClaystone, StoneDefOf.ChunkAndesite, StoneDefOf.Claystone.LabelCap, StoneDefOf.Andesite.LabelCap, ref Settings.SpawnClaystone, ref Settings.SpawnAndesite ); } list.Gap(10); { Rect fullRect = list.GetRect(30f); DualCheckboxesWithIcons_ThingDef( fullRect.LeftHalf(), StoneDefOf.ChunkSyenite, StoneDefOf.ChunkGneiss, StoneDefOf.Syenite.LabelCap, StoneDefOf.Gneiss.LabelCap, ref Settings.SpawnSyenite, ref Settings.SpawnGneiss ); } list.Gap(10); { Rect fullRect = list.GetRect(30f); DualCheckboxesWithIcons_ThingDef( fullRect.LeftHalf(), StoneDefOf.ChunkMarble, StoneDefOf.ChunkQuartzite, StoneDefOf.Marble.LabelCap, StoneDefOf.Quartzite.LabelCap, ref Settings.SpawnMarble, ref Settings.SpawnQuartzite ); } list.Gap(10); { Rect fullRect = list.GetRect(30f); DualCheckboxesWithIcons_ThingDef( fullRect.LeftHalf(), StoneDefOf.ChunkSlate, StoneDefOf.ChunkSchist, StoneDefOf.Slate.LabelCap, StoneDefOf.Schist.LabelCap, ref Settings.SpawnSlate, ref Settings.SpawnSchist ); } list.Gap(10); { Rect fullRect = list.GetRect(30f); DualCheckboxesWithIcons_ThingDef( fullRect.LeftHalf(), StoneDefOf.ChunkGabbro, StoneDefOf.ChunkGranite, StoneDefOf.Gabbro.LabelCap, StoneDefOf.Granite.LabelCap, ref Settings.SpawnGabbro, ref Settings.SpawnGranite ); } list.Gap(10); { Rect fullRect = list.GetRect(30f); DualCheckboxesWithIcons_ThingDef( fullRect.LeftHalf(), StoneDefOf.ChunkDiorite, StoneDefOf.ChunkDunite, StoneDefOf.Diorite.LabelCap, StoneDefOf.Dunite.LabelCap, ref Settings.SpawnDiorite, ref Settings.SpawnDunite ); } list.Gap(10); { Rect fullRect = list.GetRect(30f); Rect leftRect = fullRect.LeftHalf().LeftHalf().RightPartPixels(150).Rounded(); Rect leftIconRect = fullRect.LeftHalf().LeftHalf().LeftHalf().LeftHalf().RightPartPixels(30).Rounded(); Widgets.ThingIcon(leftIconRect, StoneDefOf.ChunkPegmatite); Widgets.CheckboxLabeled(leftRect, StoneDefOf.Pegmatite.LabelCap, ref Settings.SpawnPegmatite); Widgets.DrawHighlightIfMouseover(leftRect); } GenUI.ResetLabelAlign(); list.End(); }
public override void DoWindowContents(Rect inRect) { Vector2 vector = new Vector2(120f, 40f); float y = vector.y; float num = 600f; float num2 = (float)((inRect.width - num) / 2.0); Rect position = new Rect(num2 + inRect.x, inRect.y, num, (float)(inRect.height - (y + 10.0))).ContractedBy(10f); Rect position2 = new Rect(position.x, (float)(position.y + position.height + 10.0), position.width, y); GUI.BeginGroup(position); Rect rect = new Rect(0f, 0f, position.width, 40f); Text.Font = GameFont.Medium; GenUI.SetLabelAlign(TextAnchor.MiddleCenter); Widgets.Label(rect, "KeyboardConfig".Translate()); GenUI.ResetLabelAlign(); Text.Font = GameFont.Small; Rect outRect = new Rect(0f, rect.height, position.width, position.height - rect.height); Rect rect2 = new Rect(0f, 0f, (float)(outRect.width - 16.0), this.contentHeight); Widgets.BeginScrollView(outRect, ref this.scrollPosition, rect2, true); float num3 = 0f; KeyBindingCategoryDef keyBindingCategoryDef = null; Dialog_KeyBindings.keyBindingsWorkingList.Clear(); Dialog_KeyBindings.keyBindingsWorkingList.AddRange(DefDatabase <KeyBindingDef> .AllDefs); Dialog_KeyBindings.keyBindingsWorkingList.SortBy((KeyBindingDef x) => x.category.index, (KeyBindingDef x) => x.index); for (int i = 0; i < Dialog_KeyBindings.keyBindingsWorkingList.Count; i++) { KeyBindingDef keyBindingDef = Dialog_KeyBindings.keyBindingsWorkingList[i]; if (keyBindingCategoryDef != keyBindingDef.category) { bool skipDrawing = num3 - this.scrollPosition.y + 40.0 < 0.0 || num3 - this.scrollPosition.y > outRect.height; keyBindingCategoryDef = keyBindingDef.category; this.DrawCategoryEntry(keyBindingCategoryDef, rect2.width, ref num3, skipDrawing); } bool skipDrawing2 = num3 - this.scrollPosition.y + 34.0 < 0.0 || num3 - this.scrollPosition.y > outRect.height; this.DrawKeyEntry(keyBindingDef, rect2, ref num3, skipDrawing2); } Widgets.EndScrollView(); GUI.EndGroup(); GUI.BeginGroup(position2); int num4 = 3; float num5 = (float)(vector.x * (float)num4 + 10.0 * (float)(num4 - 1)); float num6 = (float)((position2.width - num5) / 2.0); float num7 = (float)(vector.x + 10.0); Rect rect3 = new Rect(num6, 0f, vector.x, vector.y); Rect rect4 = new Rect(num6 + num7, 0f, vector.x, vector.y); Rect rect5 = new Rect((float)(num6 + num7 * 2.0), 0f, vector.x, vector.y); if (Widgets.ButtonText(rect3, "ResetButton".Translate(), true, false, true)) { this.keyPrefsData.ResetToDefaults(); this.keyPrefsData.ErrorCheck(); SoundDefOf.TickLow.PlayOneShotOnCamera(null); Event.current.Use(); } if (Widgets.ButtonText(rect4, "CancelButton".Translate(), true, false, true)) { this.Close(true); Event.current.Use(); } if (Widgets.ButtonText(rect5, "OK".Translate(), true, false, true)) { KeyPrefs.KeyPrefsData = this.keyPrefsData; KeyPrefs.Save(); this.Close(true); this.keyPrefsData.ErrorCheck(); Event.current.Use(); } GUI.EndGroup(); }
public override void DoSettingsWindowContents(Rect rect) { Listing_Standard list = new Listing_Standard() { ColumnWidth = rect.width }; list.Begin(rect); list.Gap(10); { Rect fullRect = list.GetRect(Text.LineHeight); Rect leftRect = fullRect.LeftHalf().Rounded(); Rect rightRect = fullRect.RightHalf().Rounded(); GenUI.SetLabelAlign(TextAnchor.MiddleRight); Widgets.Label(leftRect, Static.LabelStoneTypesAvailable); GenUI.ResetLabelAlign(); Widgets.IntRange(rightRect, 316192000, ref Settings.StoneTypesAvailable, 1, 8); } list.Gap(25); { Rect fullRect = list.GetRect(30f); Rect leftLabelRect = fullRect.LeftHalf().Rounded(); Rect rightLabelRect = fullRect.RightHalf().Rounded(); Text.Font = GameFont.Medium; Text.Anchor = TextAnchor.MiddleCenter; Widgets.Label(leftLabelRect, Static.LabelStoneTypesToSpawn); PatchDescription GraphicsPatch = patches.Find(x => x.file == "Patches_Core_Stone_CustomGraphics.xml"); var status = settings.PatchDisabled[GraphicsPatch]; Widgets.CheckboxLabeled(rightLabelRect, "Enable Cupro'ss Stone Textures", ref status); settings.PatchDisabled[GraphicsPatch] = status; Text.Anchor = TextAnchor.UpperLeft; Text.Font = GameFont.Small; } list.Gap(10); { Rect fullRect = list.GetRect(30f); Rect rightLabelRect = fullRect.RightHalf().Rounded(); DualCheckboxesWithIcons_ThingDef( fullRect.LeftHalf(), Static.ChunkLimestone, Static.ChunkSandstone, Static.Limestone?.LabelCap, Static.Sandstone?.LabelCap, ref Settings.SpawnLimestone, ref Settings.SpawnSandstone ); } list.Gap(10); { Rect fullRect = list.GetRect(30f); DualCheckboxesWithIcons_ThingDef( fullRect.LeftHalf(), Static.ChunkClaystone, Static.ChunkAndesite, Static.Claystone?.LabelCap, Static.Andesite?.LabelCap, ref Settings.SpawnClaystone, ref Settings.SpawnAndesite ); } list.Gap(10); { Rect fullRect = list.GetRect(30f); DualCheckboxesWithIcons_ThingDef( fullRect.LeftHalf(), Static.ChunkSyenite, Static.ChunkGneiss, Static.Syenite?.LabelCap, Static.Gneiss?.LabelCap, ref Settings.SpawnSyenite, ref Settings.SpawnGneiss ); } list.Gap(10); { Rect fullRect = list.GetRect(30f); DualCheckboxesWithIcons_ThingDef( fullRect.LeftHalf(), Static.ChunkMarble, Static.ChunkQuartzite, Static.Marble?.LabelCap, Static.Quartzite?.LabelCap, ref Settings.SpawnMarble, ref Settings.SpawnQuartzite ); } list.Gap(10); { Rect fullRect = list.GetRect(30f); DualCheckboxesWithIcons_ThingDef( fullRect.LeftHalf(), Static.ChunkSlate, Static.ChunkSchist, Static.Slate?.LabelCap, Static.Schist?.LabelCap, ref Settings.SpawnSlate, ref Settings.SpawnSchist ); } list.Gap(10); { Rect fullRect = list.GetRect(30f); DualCheckboxesWithIcons_ThingDef( fullRect.LeftHalf(), Static.ChunkGabbro, Static.ChunkGranite, Static.Gabbro?.LabelCap, Static.Granite?.LabelCap, ref Settings.SpawnGabbro, ref Settings.SpawnGranite ); } list.Gap(10); { Rect fullRect = list.GetRect(30f); DualCheckboxesWithIcons_ThingDef( fullRect.LeftHalf(), Static.ChunkDiorite, Static.ChunkDunite, Static.Diorite?.LabelCap, Static.Dunite?.LabelCap, ref Settings.SpawnDiorite, ref Settings.SpawnDunite ); } list.Gap(10); { Rect fullRect = list.GetRect(30f); Rect leftRect = fullRect.LeftHalf().LeftHalf().RightPartPixels(150).Rounded(); Rect leftIconRect = fullRect.LeftHalf().LeftHalf().LeftHalf().LeftHalf().RightPartPixels(30).Rounded(); Widgets.ThingIcon(leftIconRect, Static.ChunkPegmatite); Widgets.CheckboxLabeled(leftRect, Static.Pegmatite?.LabelCap, ref Settings.SpawnPegmatite); Widgets.DrawHighlightIfMouseover(leftRect); } GenUI.ResetLabelAlign(); list.End(); }
public override void DoWindowContents(Rect inRect) { var contentRect = new Rect(0, 0, inRect.width, inRect.height - (CloseButSize.y + 10f)).ContractedBy(10f); bool scrollBarVisible = totalContentHeight > contentRect.height; var scrollViewTotal = new Rect(0f, 0f, contentRect.width - (scrollBarVisible ? ScrollBarWidthMargin : 0), totalContentHeight); Widgets.DrawHighlight(contentRect); Widgets.BeginScrollView(contentRect, ref scrollPosition, scrollViewTotal); float curY = 0f; Rect r = new Rect(0, curY, scrollViewTotal.width, LabelHeight); Widgets.CheckboxLabeled(r, "LWMDSperDSUturnOn".Translate(), ref Settings.allowPerDSUSettings);//TODO TooltipHandler.TipRegion(r, "LWMDSperDSUturnOnDesc".Translate()); curY += LabelHeight + 1f; if (!Settings.allowPerDSUSettings) { r = new Rect(5f, curY, scrollViewTotal.width - 10f, LabelHeight); Widgets.Label(r, "LWMDSperDSUWarning".Translate()); curY += LabelHeight; } Widgets.DrawLineHorizontal(0f, curY, scrollViewTotal.width); curY += 10f; // todo: make this static? //List<ThingDef> l=DefDatabase<ThingDef>.AllDefsListForReading.Where(ThingDef d => d.Has // Roll my own buttons, because dammit, I want left-justified buttons: // (mirroring Widgets.ButtonTextWorker) GenUI.SetLabelAlign(TextAnchor.MiddleLeft); var bg = ContentFinder <Texture2D> .Get("UI/Widgets/ButtonBG", true); var bgmouseover = ContentFinder <Texture2D> .Get("UI/Widgets/ButtonBGMouseover", true); var bgclick = ContentFinder <Texture2D> .Get("UI/Widgets/ButtonBGClick", true); // note: make own list b/c this can modify what's in the DefDatabase. foreach (ThingDef u in Settings.AllDeepStorageUnits.ToList()) { //////////////// Disble button: ////////////////// // disabled if it's already been disabled previously // or if it's slated to be disabled on window close bool isEnabled = !tracker.HasDefaultValueFor(u.defName, "def") && (this.unitsToBeDisabled == null || !unitsToBeDisabled.Contains(u)); bool wasEnabled = isEnabled; Rect disableRect = new Rect(5f, curY, LabelHeight, LabelHeight); TooltipHandler.TipRegion(disableRect, "TODO: Add description. But basically, you can disable some units and they won't show up in game.\n\nVERY likely to cause unimportant errors in saved games."); Widgets.Checkbox(disableRect.x, disableRect.y, ref isEnabled, LabelHeight, false, true, null, null); if (!isEnabled && wasEnabled) // newly disabled { Utils.Warn(Utils.DBF.Settings, "Marking unit for disabling: " + u.defName); if (unitsToBeDisabled == null) { unitsToBeDisabled = new HashSet <ThingDef>(); } unitsToBeDisabled.Add(u); // hash sets don't care if it's already there! } if (isEnabled && !wasEnabled) // add back: { Utils.Warn(Utils.DBF.Settings, "Restoring disabled unit: " + u.defName); if (unitsToBeDisabled != null && unitsToBeDisabled.Contains(u)) { unitsToBeDisabled.Remove(u); } if (tracker.HasDefaultValueFor(u.defName, "def")) { tracker.Remove(u.defName, "def"); } if (!DefDatabase <ThingDef> .AllDefsListForReading.Contains(u)) { ReturnDefToUse(u); } } //////////////// Select def: ////////////////// r = new Rect(10f + LabelHeight, curY, (scrollViewTotal.width) * 2 / 3 - 12f - LabelHeight, LabelHeight); // Draw button-ish background: Texture2D atlas = bg; if (Mouse.IsOver(r)) { atlas = bgmouseover; if (Input.GetMouseButton(0)) { atlas = bgclick; } } Widgets.DrawAtlas(r, atlas); // button text: Widgets.Label(r, u.label + " (defName: " + u.defName + ")"); // button clickiness: if (Widgets.ButtonInvisible(r)) { Find.WindowStack.Add(new Dialog_DSU_Settings(u)); } //////////////// Reset button: ////////////////// r = new Rect((scrollViewTotal.width) * 2 / 3 + 2f, curY, (scrollViewTotal.width) / 3 - 7f, LabelHeight); if (tracker.IsChanged(u.defName) && Widgets.ButtonText(r, "ResetBinding".Translate())) { ResetDSUToDefaults(u.defName); } curY += LabelHeight + 2f; } GenUI.ResetLabelAlign(); // end buttons Widgets.EndScrollView(); // close button: r = new Rect(inRect.width / 2 - (CloseButSize.x / 2), inRect.height - CloseButSize.y - 5f, CloseButSize.x, CloseButSize.y); if (Widgets.ButtonText(r, "CloseButton".Translate())) { if (unitsToBeDisabled != null && unitsToBeDisabled.Count > 0) { //TODO: add out-of-order flag. foreach (ThingDef d in unitsToBeDisabled) { Utils.Warn(Utils.DBF.Settings, "Closing Window: Removing def: " + d.defName); RemoveDefFromUse(d); tracker.AddDefaultValue(d.defName, "def", d); } unitsToBeDisabled = null; } Close(); } r = new Rect(10f, inRect.height - CloseButSize.y - 5f, 2 * CloseButSize.x, CloseButSize.y); if (tracker.HasAnyDefaultValues && Widgets.ButtonText(r, "LWM.ResetAllToDefault".Translate())) { Utils.Mess(Utils.DBF.Settings, "Resetting all per-building storage settings to default:"); ResetAllToDefaults(); } totalContentHeight = curY; }
// draws the label and appropriate input for a single setting private void DrawHandleEntry(SettingHandle handle, Rect parentRect, ref float curY, float scrollViewHeight) { var entryHeight = HandleEntryHeight; if (handle.CustomDrawer != null && handle.CustomDrawerHeight > entryHeight) { entryHeight = handle.CustomDrawerHeight + HandleEntryPadding * 2; } var skipDrawing = curY - scrollPosition.y + entryHeight <0f || curY - scrollPosition.y> scrollViewHeight; if (!skipDrawing) { var entryRect = new Rect(parentRect.x, parentRect.y + curY, parentRect.width, entryHeight).ContractedBy(HandleEntryPadding); var mouseOver = Mouse.IsOver(entryRect); if (mouseOver) { Widgets.DrawHighlight(entryRect); } var controlRect = new Rect(entryRect.x + entryRect.width / 2f, entryRect.y, entryRect.width / 2f, entryRect.height); GenUI.SetLabelAlign(TextAnchor.MiddleLeft); var leftHalfRect = new Rect(entryRect.x, entryRect.y, entryRect.width / 2f - HandleEntryPadding, entryRect.height); var labelRect = handle.CustomDrawer == null ? leftHalfRect : entryRect; // give full width to the label just in case Widgets.Label(labelRect, handle.Title); GenUI.ResetLabelAlign(); bool valueChanged = false; if (handle.CustomDrawer == null) { SettingsHandleDrawer drawer; var handleType = handle.ValueType; if (handleType.IsEnum) { handleType = typeof(Enum); } handleDrawers.TryGetValue(handleType, out drawer); if (drawer == null) { drawer = defaultHandleDrawer; } valueChanged = drawer(handle, controlRect, handleControlInfo[handle]); } else { try { valueChanged = handle.CustomDrawer(controlRect); } catch (Exception e) { HugsLibController.Logger.ReportException(e, currentlyDrawnEntry, true, "SettingsHandle.CustomDrawer"); } } if (valueChanged) { settingsHaveChanged = true; } if (mouseOver) { if (!handle.Description.NullOrEmpty()) { TooltipHandler.TipRegion(entryRect, handle.Description); } if (Input.GetMouseButtonUp(1)) { var options = new List <FloatMenuOption>(1); options.Add(new FloatMenuOption("HugsLib_settings_resetValue".Translate(), () => { ResetSetting(handle); })); Find.WindowStack.Add(new FloatMenu(options)); } } } curY += entryHeight; }
private static bool Prefix(ref Dialog_AdvancedGameConfig __instance, Rect inRect) { var listingStandard = new Listing_Standard { ColumnWidth = 200f }; listingStandard.Begin(inRect.AtZero()); listingStandard.Label("MapSize".Translate()); var mapSizes = Traverse.Create(__instance).Field("MapSizes").GetValue <int[]>(); foreach (var mapSize in mapSizes) { switch (mapSize) { case 200: listingStandard.Label("MapSizeSmall".Translate()); break; case 250: listingStandard.Label("MapSizeMedium".Translate()); break; case 300: listingStandard.Label("MapSizeLarge".Translate()); break; case 350: listingStandard.Label("MapSizeExtreme".Translate()); break; } var label = "MapSizeDesc".Translate(mapSize, mapSize * mapSize); if (listingStandard.RadioButton(label, Find.GameInitData.mapSize == mapSize)) { Find.GameInitData.mapSize = mapSize; } } listingStandard.Label("Custom Map Size"); var lab = "MapSizeDesc".Translate(_customSize, _customSize * _customSize); if (listingStandard.RadioButton(lab, Find.GameInitData.mapSize == _customSize)) { Find.GameInitData.mapSize = _customSize; } listingStandard.Label("New Size:"); _settingsString = Widgets.TextField(new Rect(90f, 362f, 60f, 20f), _settingsString); if (Widgets.ButtonText(new Rect(160f, 362f, 40f, 22f), "Apply")) { if (int.TryParse(_settingsString, out var result) && result > 0) { if (mapSizes.Contains(result)) { Messages.Message("Built in maps already has these dimensions", MessageTypeDefOf.NegativeEvent); _settingsString = _customSize.ToStringSafe(); } else { _customSize = result; } } else { Messages.Message("Must be an positive integer", MessageTypeDefOf.NegativeEvent); _settingsString = _customSize.ToStringSafe(); } } listingStandard.NewColumn(); GenUI.SetLabelAlign(TextAnchor.MiddleCenter); listingStandard.Label("MapStartSeason".Translate()); var label1 = Find.GameInitData.startingSeason != Season.Undefined ? Find.GameInitData.startingSeason.LabelCap() : "MapStartSeasonDefault".Translate(); var gridLayout = new GridLayout(listingStandard.GetRect(32f), 5, 1, 0.0f); if (Widgets.ButtonText(gridLayout.GetCellRectByIndex(0), "-")) { var startingSeason = Find.GameInitData.startingSeason; Find.GameInitData.startingSeason = startingSeason != Season.Undefined ? startingSeason - 1 : Season.Winter; } Widgets.Label(gridLayout.GetCellRectByIndex(1, 3), label1); if (Widgets.ButtonText(gridLayout.GetCellRectByIndex(4), "+")) { var startingSeason = Find.GameInitData.startingSeason; Find.GameInitData.startingSeason = startingSeason != Season.Winter ? startingSeason + 1 : Season.Undefined; } GenUI.ResetLabelAlign(); var selTile = Traverse.Create(__instance).Field("selTile").GetValue <int>(); if (selTile >= 0 && Find.GameInitData.startingSeason != Season.Undefined && GenTemperature.AverageTemperatureAtTileForTwelfth(selTile, Find.GameInitData.startingSeason.GetFirstTwelfth(Find.WorldGrid.LongLatOf(selTile).y)) < 3.0) { listingStandard.Label("MapTemperatureDangerWarning".Translate()); } if (Find.GameInitData.mapSize > 250) { listingStandard.Label("MapSizePerformanceWarning".Translate()); } listingStandard.End(); return(false); }
public override void DoWindowContents(Rect inRect) { Listing_Standard listing_Standard = new Listing_Standard(); listing_Standard.ColumnWidth = 200f; listing_Standard.Begin(inRect.AtZero()); listing_Standard.Label("MapSize".Translate(), -1f); int[] mapSizes = Dialog_AdvancedGameConfig.MapSizes; for (int i = 0; i < mapSizes.Length; i++) { int num = mapSizes[i]; if (num == 200) { listing_Standard.Label("MapSizeSmall".Translate(), -1f); } else if (num == 250) { listing_Standard.Label("MapSizeMedium".Translate(), -1f); } else if (num == 300) { listing_Standard.Label("MapSizeLarge".Translate(), -1f); } else if (num == 350) { listing_Standard.Label("MapSizeExtreme".Translate(), -1f); } string label = "MapSizeDesc".Translate(new object[] { num, num * num }); if (listing_Standard.RadioButton(label, Find.GameInitData.mapSize == num, 0f)) { Find.GameInitData.mapSize = num; } } listing_Standard.NewColumn(); GenUI.SetLabelAlign(TextAnchor.MiddleCenter); listing_Standard.Label("MapStartSeason".Translate(), -1f); string label2; if (Find.GameInitData.startingSeason == Season.Undefined) { label2 = "MapStartSeasonDefault".Translate(); } else { label2 = Find.GameInitData.startingSeason.LabelCap(); } Rect rect = listing_Standard.GetRect(32f); GridLayout gridLayout = new GridLayout(rect, 5, 1, 0f, 4f); if (Widgets.ButtonText(gridLayout.GetCellRectByIndex(0, 1, 1), "-", true, false, true)) { Season season = Find.GameInitData.startingSeason; if (season == Season.Undefined) { season = Season.Winter; } else { season = (Season)(season - Season.Spring); } Find.GameInitData.startingSeason = season; } Widgets.Label(gridLayout.GetCellRectByIndex(1, 3, 1), label2); if (Widgets.ButtonText(gridLayout.GetCellRectByIndex(4, 1, 1), "+", true, false, true)) { Season season2 = Find.GameInitData.startingSeason; if (season2 == Season.Winter) { season2 = Season.Undefined; } else { season2 += 1; } Find.GameInitData.startingSeason = season2; } GenUI.ResetLabelAlign(); if (this.selTile >= 0 && Find.GameInitData.startingSeason != Season.Undefined) { float y = Find.WorldGrid.LongLatOf(this.selTile).y; if (GenTemperature.AverageTemperatureAtTileForTwelfth(this.selTile, Find.GameInitData.startingSeason.GetFirstTwelfth(y)) < 3f) { listing_Standard.Label("MapTemperatureDangerWarning".Translate(), -1f); } } if (Find.GameInitData.mapSize > 250) { listing_Standard.Label("MapSizePerformanceWarning".Translate(), -1f); } listing_Standard.End(); }
private void DrawFilteredTiles() { DrawEntryHeader("PLMWFTIL_FilteredTiles".Translate(), backgroundColor: Color.yellow); // default line height const float gapLineHeight = 4f; //check if we have something to display (tiles) var matchingTiles = PrepareLanding.Instance.TileFilter.AllMatchingTiles; var matchingTilesCount = matchingTiles.Count; if (matchingTilesCount == 0) { return; } /* * Buttons */ if (ListingStandard.ButtonText("PLMWFTIL_ClearFilteredTiles".Translate())) { // clear everything PrepareLanding.Instance.TileFilter.ClearMatchingTiles(); // reset starting display index _tileDisplayIndexStart = 0; // reset selected index _selectedTileIndex = -1; // don't go further as there are no tile content to draw return; } var buttonsRectSpace = ListingStandard.GetRect(30f); var splittedRect = buttonsRectSpace.SplitRectWidthEvenly(_minimizedWindowButtonsDescriptorList.Count); for (var i = 0; i < _minimizedWindowButtonsDescriptorList.Count; i++) { // get button descriptor var buttonDescriptor = _minimizedWindowButtonsDescriptorList[i]; // display button; if clicked: call the related action if (Widgets.ButtonText(splittedRect[i], buttonDescriptor.Label)) { buttonDescriptor.Action(); } // display tool-tip (if any) if (!string.IsNullOrEmpty(buttonDescriptor.ToolTip)) { TooltipHandler.TipRegion(splittedRect[i], buttonDescriptor.ToolTip); } } /* * Label */ // number of elements (tiles) to display var itemsToDisplay = Math.Min(matchingTilesCount - _tileDisplayIndexStart, MaxDisplayedTileWhenMinimized); // label to display where we actually are in the tile list GenUI.SetLabelAlign(TextAnchor.MiddleCenter); var heightBefore = ListingStandard.StartCaptureHeight(); ListingStandard.Label( $"{_tileDisplayIndexStart}: {_tileDisplayIndexStart + itemsToDisplay - 1} / {matchingTilesCount - 1}", DefaultElementHeight); GenUI.ResetLabelAlign(); var counterLabelRect = ListingStandard.EndCaptureHeight(heightBefore); Core.Gui.Widgets.DrawHighlightColor(counterLabelRect, Color.cyan, 0.50f); // add a gap before the scroll view ListingStandard.Gap(gapLineHeight); /* * Calculate heights */ // height of the scrollable outer Rect (visible portion of the scroll view, not the 'virtual' one) var maxScrollViewOuterHeight = InRect.height - ListingStandard.CurHeight - 30f; // height of the 'virtual' portion of the scroll view var scrollableViewHeight = itemsToDisplay * DefaultElementHeight + gapLineHeight * MaxDisplayedTileWhenMinimized; /* * Scroll view */ var innerLs = ListingStandard.BeginScrollView(maxScrollViewOuterHeight, scrollableViewHeight, ref _scrollPosMatchingTiles, 16f); var endIndex = _tileDisplayIndexStart + itemsToDisplay; for (var i = _tileDisplayIndexStart; i < endIndex; i++) { var selectedTileId = matchingTiles[i]; var selectedTile = Find.World.grid[selectedTileId]; // get latitude & longitude for the tile var vector = Find.WorldGrid.LongLatOf(selectedTileId); var labelText = $"{i}: {vector.y.ToStringLatitude()} {vector.x.ToStringLongitude()} - {selectedTile.biome.LabelCap} ; {selectedTileId}"; // display the label var labelRect = innerLs.GetRect(DefaultElementHeight); var selected = i == _selectedTileIndex; if (Core.Gui.Widgets.LabelSelectable(labelRect, labelText, ref selected, TextAnchor.MiddleCenter)) { // go to the location of the selected tile _selectedTileIndex = i; Find.WorldInterface.SelectedTile = selectedTileId; Find.WorldCameraDriver.JumpTo(Find.WorldGrid.GetTileCenter(Find.WorldInterface.SelectedTile)); } // add a thin line between each label innerLs.GapLine(gapLineHeight); } ListingStandard.EndScrollView(innerLs); }
protected void AddMinimizedWindowContent(Listing_Standard listingStandard, Rect inRect) { /* constants used for GUI elements */ // default line height const float gapLineHeight = 4f; // default visual element height const float elementHeight = 30f; //check if we have something to display (tiles) var matchingTiles = PrepareLanding.Instance.TileFilter.AllMatchingTiles; var matchingTilesCount = matchingTiles.Count; if (matchingTilesCount == 0) { // revert to initial window size if needed MinimizedWindow.windowRect.height = MinimizedWindow.InitialSize.y; return; } /* * Buttons */ if (listingStandard.ButtonText("Clear Filtered Tiles")) { // clear everything PrepareLanding.Instance.TileFilter.ClearMatchingTiles(); // reset starting display index _tileDisplayIndexStart = 0; // reset selected index _selectedTileIndex = -1; // don't go further as there are no tile content to draw return; } var buttonsRectSpace = listingStandard.GetRect(30f); var splittedRect = buttonsRectSpace.SplitRectWidthEvenly(_minimizedWindowButtonsDescriptorList.Count); for (var i = 0; i < _minimizedWindowButtonsDescriptorList.Count; i++) { // get button descriptor var buttonDescriptor = _minimizedWindowButtonsDescriptorList[i]; // display button; if clicked: call the related action if (Widgets.ButtonText(splittedRect[i], buttonDescriptor.Label)) { buttonDescriptor.Action(); } // display tool-tip (if any) if (!string.IsNullOrEmpty(buttonDescriptor.ToolTip)) { TooltipHandler.TipRegion(splittedRect[i], buttonDescriptor.ToolTip); } } /* * Display label (where we actually are in the tile list) */ // number of elements (tiles) to display var itemsToDisplay = Math.Min(matchingTilesCount - _tileDisplayIndexStart, MaxDisplayedTileWhenMinimized); // label to display where we actually are in the tile list GenUI.SetLabelAlign(TextAnchor.MiddleCenter); var heightBefore = listingStandard.StartCaptureHeight(); listingStandard.Label( $"{_tileDisplayIndexStart}: {_tileDisplayIndexStart + itemsToDisplay - 1} / {matchingTilesCount - 1}", elementHeight); GenUI.ResetLabelAlign(); var counterLabelRect = listingStandard.EndCaptureHeight(heightBefore); Core.Gui.Widgets.DrawHighlightColor(counterLabelRect, Color.cyan, 0.50f); // add a gap before the scroll view listingStandard.Gap(gapLineHeight); /* * Calculate heights */ // height of the scrollable outer Rect (visible portion of the scroll view, not the 'virtual' one) var maxScrollViewOuterHeight = inRect.height - listingStandard.CurHeight; // recalculate window height: initial size + visible scroll view height + current height of the listing standard (hence accounting for all buttons above) var newWindowHeight = MinimizedWindow.InitialSize.y + maxScrollViewOuterHeight + listingStandard.CurHeight; // minimized window height can't be more than 70% of the screen height MinimizedWindow.windowRect.height = Mathf.Min(newWindowHeight, UI.screenHeight * 0.70f); // height of the 'virtual' portion of the scroll view var scrollableViewHeight = itemsToDisplay * elementHeight + gapLineHeight * MaxDisplayedTileWhenMinimized; /* * Scroll view */ var innerLs = listingStandard.BeginScrollView(maxScrollViewOuterHeight, scrollableViewHeight, ref _scrollPosMatchingTiles, 16f); var endIndex = _tileDisplayIndexStart + itemsToDisplay; for (var i = _tileDisplayIndexStart; i < endIndex; i++) { var selectedTileId = matchingTiles[i]; // get latitude & longitude for the tile var vector = Find.WorldGrid.LongLatOf(selectedTileId); var labelText = $"{i}: {vector.y.ToStringLatitude()} {vector.x.ToStringLongitude()}"; // display the label var labelRect = innerLs.GetRect(elementHeight); var selected = i == _selectedTileIndex; if (Core.Gui.Widgets.LabelSelectable(labelRect, labelText, ref selected, TextAnchor.MiddleCenter)) { // go to the location of the selected tile _selectedTileIndex = i; Find.WorldInterface.SelectedTile = selectedTileId; Find.WorldCameraDriver.JumpTo(Find.WorldGrid.GetTileCenter(Find.WorldInterface.SelectedTile)); } // add a thin line between each label innerLs.GapLine(gapLineHeight); } listingStandard.EndScrollView(innerLs); }
private void DrawLeftRect(Rect leftOutRect) { Rect position = leftOutRect; GUI.BeginGroup(position); if (this.selectedProject != null) { Rect outRect = new Rect(0f, 0f, position.width, 500f); Rect viewRect = new Rect(0f, 0f, (float)(outRect.width - 16.0), this.leftScrollViewHeight); Widgets.BeginScrollView(outRect, ref this.leftScrollPosition, viewRect, true); float num = 0f; Text.Font = GameFont.Medium; GenUI.SetLabelAlign(TextAnchor.MiddleLeft); Rect rect = new Rect(0f, num, viewRect.width, 50f); Widgets.LabelCacheHeight(ref rect, this.selectedProject.LabelCap, true, false); GenUI.ResetLabelAlign(); Text.Font = GameFont.Small; num += rect.height; Rect rect2 = new Rect(0f, num, viewRect.width, 0f); Widgets.LabelCacheHeight(ref rect2, this.selectedProject.description, true, false); num = (float)(num + (rect2.height + 10.0)); string text = "ProjectTechLevel".Translate().CapitalizeFirst() + ": " + this.selectedProject.techLevel.ToStringHuman().CapitalizeFirst() + "\n" + "YourTechLevel".Translate().CapitalizeFirst() + ": " + Faction.OfPlayer.def.techLevel.ToStringHuman().CapitalizeFirst(); float num2 = this.selectedProject.CostFactor(Faction.OfPlayer.def.techLevel); if (num2 != 1.0) { string text2 = text; text = text2 + "\n\n" + "ResearchCostMultiplier".Translate().CapitalizeFirst() + ": " + num2.ToStringPercent() + "\n" + "ResearchCostComparison".Translate(this.selectedProject.baseCost.ToString("F0"), this.selectedProject.CostApparent.ToString("F0")); } Rect rect3 = new Rect(0f, num, viewRect.width, 0f); Widgets.LabelCacheHeight(ref rect3, text, true, false); num = (float)(rect3.yMax + 10.0); Rect rect4 = new Rect(0f, num, viewRect.width, 500f); float num3 = this.DrawResearchPrereqs(this.selectedProject, rect4); if (num3 > 0.0) { num = (float)(num + (num3 + 15.0)); } Rect rect5 = new Rect(0f, num, viewRect.width, 500f); num += this.DrawResearchBenchRequirements(this.selectedProject, rect5); num = (this.leftScrollViewHeight = (float)(num + 3.0)); Widgets.EndScrollView(); bool flag = Prefs.DevMode && this.selectedProject.PrerequisitesCompleted && this.selectedProject != Find.ResearchManager.currentProj && !this.selectedProject.IsFinished; Rect rect6 = new Rect(0f, 0f, 90f, 50f); if (flag) { rect6.x = (float)((outRect.width - (rect6.width * 2.0 + 20.0)) / 2.0); } else { rect6.x = (float)((outRect.width - rect6.width) / 2.0); } rect6.y = (float)(outRect.y + outRect.height + 20.0); if (this.selectedProject.IsFinished) { Widgets.DrawMenuSection(rect6); Text.Anchor = TextAnchor.MiddleCenter; Widgets.Label(rect6, "Finished".Translate()); Text.Anchor = TextAnchor.UpperLeft; } else if (this.selectedProject == Find.ResearchManager.currentProj) { Widgets.DrawMenuSection(rect6); Text.Anchor = TextAnchor.MiddleCenter; Widgets.Label(rect6, "InProgress".Translate()); Text.Anchor = TextAnchor.UpperLeft; } else if (!this.selectedProject.CanStartNow) { Widgets.DrawMenuSection(rect6); Text.Anchor = TextAnchor.MiddleCenter; Widgets.Label(rect6, "Locked".Translate()); Text.Anchor = TextAnchor.UpperLeft; } else if (Widgets.ButtonText(rect6, "Research".Translate(), true, false, true)) { SoundDef.Named("ResearchStart").PlayOneShotOnCamera(null); Find.ResearchManager.currentProj = this.selectedProject; TutorSystem.Notify_Event("StartResearchProject"); } if (flag) { Rect rect7 = rect6; rect7.x += (float)(rect7.width + 20.0); if (Widgets.ButtonText(rect7, "Debug Insta-finish", true, false, true)) { Find.ResearchManager.currentProj = this.selectedProject; Find.ResearchManager.InstantFinish(this.selectedProject, false); } } Rect rect8 = new Rect(15f, (float)(rect6.y + rect6.height + 20.0), (float)(position.width - 30.0), 35f); Widgets.FillableBar(rect8, this.selectedProject.ProgressPercent, MainTabWindow_Research.ResearchBarFillTex, MainTabWindow_Research.ResearchBarBGTex, true); Text.Anchor = TextAnchor.MiddleCenter; Widgets.Label(rect8, this.selectedProject.ProgressApparent.ToString("F0") + " / " + this.selectedProject.CostApparent.ToString("F0")); Text.Anchor = TextAnchor.UpperLeft; } GUI.EndGroup(); }
private void DrawLeftRect(Rect leftOutRect) { Rect position = leftOutRect; GUI.BeginGroup(position); if (selectedProject != null) { Rect outRect = new Rect(0f, 0f, position.width, 520f); Rect viewRect = new Rect(0f, 0f, outRect.width - 16f, leftScrollViewHeight); Widgets.BeginScrollView(outRect, ref leftScrollPosition, viewRect); float num = 0f; Text.Font = GameFont.Medium; GenUI.SetLabelAlign(TextAnchor.MiddleLeft); Rect rect = new Rect(0f, num, viewRect.width - 0f, 50f); Widgets.LabelCacheHeight(ref rect, selectedProject.LabelCap); GenUI.ResetLabelAlign(); Text.Font = GameFont.Small; num += rect.height; Rect rect2 = new Rect(0f, num, viewRect.width, 0f); Widgets.LabelCacheHeight(ref rect2, selectedProject.description); num += rect2.height; Rect rect3 = new Rect(0f, num, viewRect.width, 500f); num += DrawTechprintInfo(rect3, selectedProject); if ((int)selectedProject.techLevel > (int)Faction.OfPlayer.def.techLevel) { float num2 = selectedProject.CostFactor(Faction.OfPlayer.def.techLevel); Rect rect4 = new Rect(0f, num, viewRect.width, 0f); string text = "TechLevelTooLow".Translate(Faction.OfPlayer.def.techLevel.ToStringHuman(), selectedProject.techLevel.ToStringHuman(), num2.ToStringPercent()); if (num2 != 1f) { text += " " + "ResearchCostComparison".Translate(selectedProject.baseCost.ToString("F0"), selectedProject.CostApparent.ToString("F0")); } Widgets.LabelCacheHeight(ref rect4, text); num += rect4.height; } if (!ColonistsHaveResearchBench) { GUI.color = ColoredText.RedReadable; Rect rect5 = new Rect(0f, num, viewRect.width, 0f); Widgets.LabelCacheHeight(ref rect5, "CannotResearchNoBench".Translate()); num += rect5.height; GUI.color = Color.white; } num += DrawResearchPrereqs(rect: new Rect(0f, num, viewRect.width, 500f), project: selectedProject); num += DrawResearchBenchRequirements(rect: new Rect(0f, num, viewRect.width, 500f), project: selectedProject); Rect rect8 = new Rect(0f, num, viewRect.width, 500f); num += DrawUnlockableHyperlinks(rect8, selectedProject); num = (leftScrollViewHeight = num + 3f); Widgets.EndScrollView(); Rect rect9 = new Rect(0f, outRect.yMax + 10f, position.width, 68f); if (selectedProject.CanStartNow && selectedProject != Find.ResearchManager.currentProj) { if (Widgets.ButtonText(rect9, "Research".Translate())) { SoundDefOf.ResearchStart.PlayOneShotOnCamera(); Find.ResearchManager.currentProj = selectedProject; TutorSystem.Notify_Event("StartResearchProject"); if (!ColonistsHaveResearchBench) { Messages.Message("MessageResearchMenuWithoutBench".Translate(), MessageTypeDefOf.CautionInput); } } } else { string text2 = ""; if (selectedProject.IsFinished) { text2 = "Finished".Translate(); Text.Anchor = TextAnchor.MiddleCenter; } else if (selectedProject == Find.ResearchManager.currentProj) { text2 = "InProgress".Translate(); Text.Anchor = TextAnchor.MiddleCenter; } else { text2 = "Locked".Translate() + ":"; if (!selectedProject.PrerequisitesCompleted) { text2 += "\n " + "PrerequisitesNotCompleted".Translate(); } if (!selectedProject.TechprintRequirementMet) { text2 += "\n " + "InsufficientTechprintsApplied".Translate(selectedProject.TechprintsApplied, selectedProject.techprintCount); } } Widgets.DrawHighlight(rect9); Widgets.Label(rect9.ContractedBy(5f), text2); Text.Anchor = TextAnchor.UpperLeft; } Rect rect10 = new Rect(0f, rect9.yMax + 10f, position.width, 35f); Widgets.FillableBar(rect10, selectedProject.ProgressPercent, ResearchBarFillTex, ResearchBarBGTex, doBorder: true); Text.Anchor = TextAnchor.MiddleCenter; Widgets.Label(rect10, selectedProject.ProgressApparent.ToString("F0") + " / " + selectedProject.CostApparent.ToString("F0")); Text.Anchor = TextAnchor.UpperLeft; if (Prefs.DevMode && selectedProject != Find.ResearchManager.currentProj && !selectedProject.IsFinished && Widgets.ButtonText(new Rect(rect9.x, rect9.y - 30f, 120f, 30f), "Debug: Finish now")) { Find.ResearchManager.currentProj = selectedProject; Find.ResearchManager.FinishProject(selectedProject); } if (Prefs.DevMode && !selectedProject.TechprintRequirementMet && Widgets.ButtonText(new Rect(rect9.x + 120f, rect9.y - 30f, 120f, 30f), "Debug: Apply techprint")) { Find.ResearchManager.ApplyTechprint(selectedProject, null); SoundDefOf.TechprintApplied.PlayOneShotOnCamera(); } } GUI.EndGroup(); }
public override void DoWindowContents(Rect inRect) { Vector2 vector = new Vector2(120f, 40f); float y = vector.y; float num = 600f; float num2 = (inRect.width - num) / 2f; Rect position = new Rect(num2 + inRect.x, inRect.y, num, inRect.height - (y + 10f)).ContractedBy(10f); Rect position2 = new Rect(position.x, position.y + position.height + 10f, position.width, y); GUI.BeginGroup(position); Rect rect = new Rect(0f, 0f, position.width, 40f); Text.Font = GameFont.Medium; GenUI.SetLabelAlign(TextAnchor.MiddleCenter); Widgets.Label(rect, "KeyboardConfig".Translate()); GenUI.ResetLabelAlign(); Text.Font = GameFont.Small; Rect outRect = new Rect(0f, rect.height, position.width, position.height - rect.height); Rect rect2 = new Rect(0f, 0f, outRect.width - 16f, contentHeight); Widgets.BeginScrollView(outRect, ref scrollPosition, rect2); float curY = 0f; KeyBindingCategoryDef keyBindingCategoryDef = null; keyBindingsWorkingList.Clear(); keyBindingsWorkingList.AddRange(DefDatabase <KeyBindingDef> .AllDefs); keyBindingsWorkingList.SortBy((KeyBindingDef x) => x.category.index, (KeyBindingDef x) => x.index); for (int i = 0; i < keyBindingsWorkingList.Count; i++) { KeyBindingDef keyBindingDef = keyBindingsWorkingList[i]; if (keyBindingCategoryDef != keyBindingDef.category) { bool skipDrawing = curY - scrollPosition.y + 40f < 0f || curY - scrollPosition.y > outRect.height; keyBindingCategoryDef = keyBindingDef.category; DrawCategoryEntry(keyBindingCategoryDef, rect2.width, ref curY, skipDrawing); } bool skipDrawing2 = curY - scrollPosition.y + 34f < 0f || curY - scrollPosition.y > outRect.height; DrawKeyEntry(keyBindingDef, rect2, ref curY, skipDrawing2); } Widgets.EndScrollView(); GUI.EndGroup(); GUI.BeginGroup(position2); int num3 = 3; float num4 = vector.x * (float)num3 + 10f * (float)(num3 - 1); float num5 = (position2.width - num4) / 2f; float num6 = vector.x + 10f; Rect rect3 = new Rect(num5, 0f, vector.x, vector.y); Rect rect4 = new Rect(num5 + num6, 0f, vector.x, vector.y); Rect rect5 = new Rect(num5 + num6 * 2f, 0f, vector.x, vector.y); if (Widgets.ButtonText(rect3, "ResetButton".Translate())) { keyPrefsData.ResetToDefaults(); keyPrefsData.ErrorCheck(); SoundDefOf.Tick_Low.PlayOneShotOnCamera(); Event.current.Use(); } if (Widgets.ButtonText(rect4, "CancelButton".Translate())) { Close(); Event.current.Use(); } if (Widgets.ButtonText(rect5, "OK".Translate())) { KeyPrefs.KeyPrefsData = keyPrefsData; KeyPrefs.Save(); Close(); keyPrefsData.ErrorCheck(); Event.current.Use(); } GUI.EndGroup(); }
public override void DoWindowContents(Rect inRect) { var windowButtonSize = CloseButSize; var contentRect = new Rect(0, 0, inRect.width, inRect.height - (windowButtonSize.y + 10f)).ContractedBy(10f); GUI.BeginGroup(contentRect); var titleRect = new Rect(0f, 0f, contentRect.width, TitleLabelHeight); Text.Font = GameFont.Medium; GenUI.SetLabelAlign(TextAnchor.MiddleCenter); Widgets.Label(titleRect, "HugsLib_settings_windowTitle".Translate()); GenUI.ResetLabelAlign(); Text.Font = GameFont.Small; if (listedMods.Count > 0) { var scrollViewVisible = new Rect(0f, titleRect.height, contentRect.width, contentRect.height - titleRect.height); var scrollBarVisible = totalContentHeight > scrollViewVisible.height; var scrollViewTotal = new Rect(0f, 0f, scrollViewVisible.width - (scrollBarVisible ? ScrollBarWidthMargin : 0), totalContentHeight); Widgets.BeginScrollView(scrollViewVisible, ref scrollPosition, scrollViewTotal); var curY = 0f; for (int i = 0; i < listedMods.Count; i++) { var entry = listedMods[i]; if (!entry.Visible) { continue; } currentlyDrawnEntry = entry.ModName; DrawModEntryHeader(entry, scrollViewTotal.width, ref curY); if ((entry.SettingsPack != null && entry.SettingsPack.AlwaysExpandEntry) || expandedModEntries.Contains(entry)) { for (int j = 0; j < entry.Handles.Count; j++) { var handle = entry.Handles[j]; if (handle.VisibilityPredicate != null) { try { if (!handle.VisibilityPredicate()) { continue; } } catch (Exception e) { HugsLibController.Logger.ReportException(e, currentlyDrawnEntry, true, "SettingsHandle.VisibilityPredicate"); } } DrawHandleEntry(handle, scrollViewTotal, ref curY, scrollViewVisible.height); } } currentlyDrawnEntry = null; } Widgets.EndScrollView(); totalContentHeight = curY; } else { Widgets.Label(new Rect(0, titleRect.height, contentRect.width, titleRect.height), "HugsLib_settings_noSettings".Translate()); } GUI.EndGroup(); Text.Font = GameFont.Small; var resetButtonRect = new Rect(0, inRect.height - windowButtonSize.y, windowButtonSize.x, windowButtonSize.y); if (Widgets.ButtonText(resetButtonRect, "HugsLib_settings_resetAll".Translate())) { ShowResetPrompt("HugsLib_settings_resetAll_prompt".Translate(), HugsLibController.SettingsManager.ModSettingsPacks.SelectMany(p => p.Handles)); } var closeButtonRect = new Rect(inRect.width - windowButtonSize.x, inRect.height - windowButtonSize.y, windowButtonSize.x, windowButtonSize.y); if (closingScheduled) { closingScheduled = false; Close(); } if (Widgets.ButtonText(closeButtonRect, "CloseButton".Translate())) { GUI.FocusControl(null); // unfocus, so that a focused text field may commit its value closingScheduled = true; } }
public override void DoWindowContents(Rect inRect) { var contentRect = new Rect(0, 0, inRect.width, inRect.height - (CloseButSize.y + 10f)).ContractedBy(10f); // var scrollViewVisible = new Rect(0f, titleRect.height, contentRect.width, contentRect.height - titleRect.height); var scrollBarVisible = totalContentHeight > contentRect.height; var scrollViewTotal = new Rect(0f, 0f, contentRect.width - (scrollBarVisible ? ScrollBarWidthMargin : 0), totalContentHeight); Widgets.DrawHighlight(contentRect); Widgets.BeginScrollView(contentRect, ref scrollPosition, scrollViewTotal); var curY = 0f; var r = new Rect(0, curY, scrollViewTotal.width, LabelHeight); // r=new Rect(0,curY,scrollViewTotal.width, LabelHeight); Widgets.CheckboxLabeled(r, "LWMDSperDSUturnOn".Translate(), ref Settings.allowPerDSUSettings); //TODO TooltipHandler.TipRegion(r, "LWMDSperDSUturnOnDesc".Translate()); curY += LabelHeight + 1f; if (!Settings.allowPerDSUSettings) { r = new Rect(5f, curY, scrollViewTotal.width - 10f, LabelHeight); Widgets.Label(r, "LWMDSperDSUWarning".Translate()); curY += LabelHeight; } Widgets.DrawLineHorizontal(0f, curY, scrollViewTotal.width); curY += 10f; // todo: make this static? //List<ThingDef> l=DefDatabase<ThingDef>.AllDefsListForReading.Where(ThingDef d => d.Has // Roll my own buttons, because dammit, I want left-justified buttons: // (mirroring Widgets.ButtonTextWorker) GenUI.SetLabelAlign(TextAnchor.MiddleLeft); var bg = ContentFinder <Texture2D> .Get("UI/Widgets/ButtonBG"); var bgmouseover = ContentFinder <Texture2D> .Get("UI/Widgets/ButtonBGMouseover"); var bgclick = ContentFinder <Texture2D> .Get("UI/Widgets/ButtonBGClick"); foreach (var u in Settings.allDeepStorageUnits) { r = new Rect(5f, curY, scrollViewTotal.width * 2 / 3 - 7f, LabelHeight); // Draw button-ish background: var atlas = bg; if (Mouse.IsOver(r)) { atlas = bgmouseover; if (Input.GetMouseButton(0)) { atlas = bgclick; } } Widgets.DrawAtlas(r, atlas); // button text: Widgets.Label(r, u.label + " (defName: " + u.defName + ")"); // button clickiness: if (Widgets.ButtonInvisible(r)) { Find.WindowStack.Add(new Dialog_DSU_Settings(u)); } // Reset button: r = new Rect(scrollViewTotal.width * 2 / 3 + 2f, curY, scrollViewTotal.width / 3 - 7f, LabelHeight); if (IsDSUChanged(u) && Widgets.ButtonText(r, "ResetBinding".Translate())) { ResetDSUToDefaults(u.defName); } curY += LabelHeight + 2f; } GenUI.ResetLabelAlign(); // end buttons Widgets.EndScrollView(); r = new Rect(10f, inRect.height - CloseButSize.y - 5f, inRect.width / 3, CloseButSize.y); if (defaultDSUValues.Count > 0 && Widgets.ButtonText(r, "LWM.ResetAllToDefault".Translate())) { Utils.Mess(Utils.DBF.Settings, "Resetting all per-building storage settings to default:"); ResetAllToDefaults(); } totalContentHeight = curY; }
protected void DrawLoadPresetList(Rect inRect) { DrawEntryHeader("Preset Files: Load mode", backgroundColor: Color.green); var presetFiles = _userData.PresetManager.AllPresetFiles; if (presetFiles == null) { Log.ErrorOnce("[PrepareLanding] PresetManager.AllPresetFiles is null.", 0x1238cafe); return; } var presetFilesCount = presetFiles.Count; if (presetFiles.Count == 0) { ListingStandard.Label("No existing presets."); return; } // add a gap before the scroll view ListingStandard.Gap(DefaultGapLineHeight); /* * Buttons */ var buttonsRectSpace = ListingStandard.GetRect(30f); var splittedRect = buttonsRectSpace.SplitRectWidthEvenly(_buttonList.Count); for (var i = 0; i < _buttonList.Count; i++) { // get button descriptor var buttonDescriptor = _buttonList[i]; // display button; if clicked: call the related action if (Widgets.ButtonText(splittedRect[i], buttonDescriptor.Label)) { buttonDescriptor.Action(); } // display tool-tip (if any) if (!string.IsNullOrEmpty(buttonDescriptor.ToolTip)) { TooltipHandler.TipRegion(splittedRect[i], buttonDescriptor.ToolTip); } } /* * Label */ // number of elements (tiles) to display var itemsToDisplay = Math.Min(presetFilesCount - _listDisplayStartIndex, MaxItemsToDisplay); // label to display where we actually are in the tile list GenUI.SetLabelAlign(TextAnchor.MiddleCenter); var heightBefore = ListingStandard.StartCaptureHeight(); ListingStandard.Label( $"{_listDisplayStartIndex}: {_listDisplayStartIndex + itemsToDisplay - 1} / {presetFilesCount - 1}", DefaultElementHeight); GenUI.ResetLabelAlign(); var counterLabelRect = ListingStandard.EndCaptureHeight(heightBefore); Core.Gui.Widgets.DrawHighlightColor(counterLabelRect, Color.cyan, 0.50f); // add a gap before the scroll view ListingStandard.Gap(DefaultGapLineHeight); /* * Calculate heights */ // height of the scrollable outer Rect (visible portion of the scroll view, not the 'virtual' one) var maxScrollViewOuterHeight = InRect.height - ListingStandard.CurHeight - 30f; // height of the 'virtual' portion of the scroll view var scrollableViewHeight = itemsToDisplay * DefaultElementHeight + DefaultGapLineHeight * MaxItemsToDisplay; /* * Scroll view */ var innerLs = ListingStandard.BeginScrollView(maxScrollViewOuterHeight, scrollableViewHeight, ref _scrollPosPresetFiles, 16f); var endIndex = _listDisplayStartIndex + itemsToDisplay; for (var i = _listDisplayStartIndex; i < endIndex; i++) { var selectedPresetFile = presetFiles[i]; var labelText = Path.GetFileNameWithoutExtension(selectedPresetFile.Name); // display the label var labelRect = innerLs.GetRect(DefaultElementHeight); var selected = i == _selectedItemIndex; if (Core.Gui.Widgets.LabelSelectable(labelRect, labelText, ref selected, TextAnchor.MiddleCenter)) { // save item index _selectedItemIndex = i; _selectedFileName = labelText; } // add a thin line between each label innerLs.GapLine(DefaultGapLineHeight); } ListingStandard.EndScrollView(innerLs); }
private void DrawLeftRect(Rect leftOutRect) { Rect position = leftOutRect; GUI.BeginGroup(position); if (selectedProject != null) { Rect outRect = new Rect(0f, 0f, position.width, 500f); Rect viewRect = new Rect(0f, 0f, outRect.width - 16f, leftScrollViewHeight); Widgets.BeginScrollView(outRect, ref leftScrollPosition, viewRect); float num = 0f; Text.Font = GameFont.Medium; GenUI.SetLabelAlign(TextAnchor.MiddleLeft); Rect rect = new Rect(0f, num, viewRect.width, 50f); Widgets.LabelCacheHeight(ref rect, selectedProject.LabelCap); GenUI.ResetLabelAlign(); Text.Font = GameFont.Small; num += rect.height; Rect rect2 = new Rect(0f, num, viewRect.width, 0f); Widgets.LabelCacheHeight(ref rect2, selectedProject.description); num += rect2.height + 10f; string text = "ProjectTechLevel".Translate().CapitalizeFirst() + ": " + selectedProject.techLevel.ToStringHuman().CapitalizeFirst() + "\n" + "YourTechLevel".Translate().CapitalizeFirst() + ": " + Faction.OfPlayer.def.techLevel.ToStringHuman().CapitalizeFirst(); float num2 = selectedProject.CostFactor(Faction.OfPlayer.def.techLevel); if (num2 != 1f) { string text2 = text; text = text2 + "\n\n" + "ResearchCostMultiplier".Translate().CapitalizeFirst() + ": " + num2.ToStringPercent() + "\n" + "ResearchCostComparison".Translate(selectedProject.baseCost.ToString("F0"), selectedProject.CostApparent.ToString("F0")); } Rect rect3 = new Rect(0f, num, viewRect.width, 0f); Widgets.LabelCacheHeight(ref rect3, text); num = rect3.yMax + 10f; float num3 = DrawResearchPrereqs(rect: new Rect(0f, num, viewRect.width, 500f), project: selectedProject); if (num3 > 0f) { num += num3 + 15f; } num += DrawResearchBenchRequirements(rect: new Rect(0f, num, viewRect.width, 500f), project: selectedProject); num = (leftScrollViewHeight = num + 3f); Widgets.EndScrollView(); bool flag = Prefs.DevMode && selectedProject != Find.ResearchManager.currentProj && !selectedProject.IsFinished; Rect rect6 = new Rect(0f, 0f, 90f, 50f); if (flag) { rect6.x = (outRect.width - (rect6.width * 2f + 20f)) / 2f; } else { rect6.x = (outRect.width - rect6.width) / 2f; } rect6.y = outRect.y + outRect.height + 20f; if (selectedProject.IsFinished) { Widgets.DrawMenuSection(rect6); Text.Anchor = TextAnchor.MiddleCenter; Widgets.Label(rect6, "Finished".Translate()); Text.Anchor = TextAnchor.UpperLeft; } else if (selectedProject == Find.ResearchManager.currentProj) { Widgets.DrawMenuSection(rect6); Text.Anchor = TextAnchor.MiddleCenter; Widgets.Label(rect6, "InProgress".Translate()); Text.Anchor = TextAnchor.UpperLeft; } else if (!selectedProject.CanStartNow) { Widgets.DrawMenuSection(rect6); Text.Anchor = TextAnchor.MiddleCenter; Widgets.Label(rect6, "Locked".Translate()); Text.Anchor = TextAnchor.UpperLeft; } else if (Widgets.ButtonText(rect6, "Research".Translate())) { SoundDefOf.ResearchStart.PlayOneShotOnCamera(); Find.ResearchManager.currentProj = selectedProject; TutorSystem.Notify_Event("StartResearchProject"); } if (flag) { Rect rect7 = rect6; rect7.x += rect7.width + 20f; if (Widgets.ButtonText(rect7, "Debug Insta-finish")) { Find.ResearchManager.currentProj = selectedProject; Find.ResearchManager.FinishProject(selectedProject); } } Rect rect8 = new Rect(15f, rect6.y + rect6.height + 20f, position.width - 30f, 35f); Widgets.FillableBar(rect8, selectedProject.ProgressPercent, ResearchBarFillTex, ResearchBarBGTex, doBorder: true); Text.Anchor = TextAnchor.MiddleCenter; Widgets.Label(rect8, selectedProject.ProgressApparent.ToString("F0") + " / " + selectedProject.CostApparent.ToString("F0")); Text.Anchor = TextAnchor.UpperLeft; } GUI.EndGroup(); }
public override void DoWindowContents(Rect inRect) { Listing_Standard listing_Standard = new Listing_Standard(); listing_Standard.ColumnWidth = 200f; listing_Standard.Begin(inRect.AtZero()); listing_Standard.Label("MapSize".Translate(), -1f); int[] mapSizes = Dialog_AdvancedGameConfig.MapSizes; foreach (int num in mapSizes) { switch (num) { case 200: listing_Standard.Label("MapSizeSmall".Translate(), -1f); break; case 250: listing_Standard.Label("MapSizeMedium".Translate(), -1f); break; case 300: listing_Standard.Label("MapSizeLarge".Translate(), -1f); break; case 350: listing_Standard.Label("MapSizeExtreme".Translate(), -1f); break; } string label = "MapSizeDesc".Translate(num, num * num); if (listing_Standard.RadioButton(label, Find.GameInitData.mapSize == num, 0f)) { Find.GameInitData.mapSize = num; } } listing_Standard.NewColumn(); GenUI.SetLabelAlign(TextAnchor.MiddleCenter); listing_Standard.Label("MapStartSeason".Translate(), -1f); string label2 = (Find.GameInitData.startingSeason != 0) ? Find.GameInitData.startingSeason.LabelCap() : "MapStartSeasonDefault".Translate(); Rect rect = listing_Standard.GetRect(32f); GridLayout gridLayout = new GridLayout(rect, 5, 1, 0f, 4f); if (Widgets.ButtonText(gridLayout.GetCellRectByIndex(0, 1, 1), "-", true, false, true)) { Season startingSeason = Find.GameInitData.startingSeason; startingSeason = ((startingSeason != 0) ? (startingSeason - 1) : Season.Winter); Find.GameInitData.startingSeason = startingSeason; } Widgets.Label(gridLayout.GetCellRectByIndex(1, 3, 1), label2); if (Widgets.ButtonText(gridLayout.GetCellRectByIndex(4, 1, 1), "+", true, false, true)) { Season startingSeason2 = Find.GameInitData.startingSeason; startingSeason2 = ((startingSeason2 != Season.Winter) ? (startingSeason2 + 1) : Season.Undefined); Find.GameInitData.startingSeason = startingSeason2; } GenUI.ResetLabelAlign(); if (this.selTile >= 0 && Find.GameInitData.startingSeason != 0) { Vector2 vector = Find.WorldGrid.LongLatOf(this.selTile); float y = vector.y; if (GenTemperature.AverageTemperatureAtTileForTwelfth(this.selTile, Find.GameInitData.startingSeason.GetFirstTwelfth(y)) < 3.0) { listing_Standard.Label("MapTemperatureDangerWarning".Translate(), -1f); } } if (Find.GameInitData.mapSize > 250) { listing_Standard.Label("MapSizePerformanceWarning".Translate(), -1f); } listing_Standard.End(); }