public static void GeneralTab( Rect inRect ) { //TODO GeneralTab: Add thought settings? TextAnchor anchor = Text.Anchor; float rowHeight = Constants.GenRowHeight; var rowRect = new Rect( inRect.width * 0.05f, inRect.height * 0.05f, inRect.width * 0.9f, rowHeight ); Text.Anchor = TextAnchor.MiddleLeft; Widgets.Label(rowRect, "NVVanillaMultiExp".Translate()); rowRect.y += rowHeight + Constants.RowGap; Widgets.DrawLineHorizontal(rowRect.x + 24f, rowRect.y, rowRect.width - 48f); rowRect.y += Constants.RowGap; //Night Vision Settings Widgets.Label( rowRect, "NVMoveWorkSpeedMultipliers" .Translate(VisionType.NVNightVision.ToString().Translate()) .ToLower() .CapitalizeFirst() ); rowRect.y += rowHeight + Constants.RowGap; SettingsCache.NVZeroCache = Widgets.HorizontalSlider( rowRect, (float)SettingsCache.NVZeroCache, (float)SettingsCache.MinCache, (float)SettingsCache.MaxCache, true, string.Format( Constants.ZeroMultiLabel, SettingsCache.NVZeroCache ), string.Format( Constants.XLabel, SettingsCache.MinCache ), string.Format( Constants.XLabel, SettingsCache.MaxCache ), 1 ); SettingsHelpers.DrawIndicator( rowRect, Constants.DefaultZeroLightMultiplier, Constants.NVDefaultOffsets[0], (float)SettingsCache.MinCache, (float)SettingsCache.MaxCache, IndicatorTex.DefIndicator ); rowRect.y += rowHeight * 1.5f; SettingsCache.NVFullCache = Widgets.HorizontalSlider( rowRect, (float)SettingsCache.NVFullCache, (float)SettingsCache.MinCache, (float)SettingsCache.MaxCache, true, string.Format( Constants.FullMultiLabel, SettingsCache.NVFullCache ), string.Format( Constants.XLabel, SettingsCache.MinCache ), string.Format( Constants.XLabel, SettingsCache.MaxCache ), 1 ); SettingsHelpers.DrawIndicator( rowRect, Constants.DefaultFullLightMultiplier, Constants.NVDefaultOffsets[1], (float)SettingsCache.MinCache, (float)SettingsCache.MaxCache, IndicatorTex.DefIndicator ); rowRect.y += rowHeight * 2f; Widgets.DrawLineHorizontal(rowRect.x + 24f, rowRect.y, rowRect.width - 48f); rowRect.y += Constants.RowGap; //Photosensitivity settings Widgets.Label( rowRect, "NVMoveWorkSpeedMultipliers" .Translate(VisionType.NVPhotosensitivity.ToString().Translate()) .ToLower() .CapitalizeFirst() ); rowRect.y += rowHeight * 1.5f; SettingsCache.PSZeroCache = Widgets.HorizontalSlider( rowRect, (float)SettingsCache.PSZeroCache, (float)SettingsCache.MinCache, (float)SettingsCache.MaxCache, true, string.Format( Constants.ZeroMultiLabel, SettingsCache.PSZeroCache ), string.Format( Constants.XLabel, SettingsCache.MinCache ), string.Format( Constants.XLabel, SettingsCache.MaxCache ), 1 ); SettingsHelpers.DrawIndicator( rowRect, Constants.DefaultZeroLightMultiplier, Constants.PSDefaultOffsets[0], (float)SettingsCache.MinCache, (float)SettingsCache.MaxCache, IndicatorTex.DefIndicator ); rowRect.y += rowHeight * 1.5f; SettingsCache.PSFullCache = Widgets.HorizontalSlider( rowRect, (float)SettingsCache.PSFullCache, (float)SettingsCache.MinCache, (float)SettingsCache.MaxCache, true, string.Format( Constants.FullMultiLabel, SettingsCache.PSFullCache ), string.Format( Constants.XLabel, SettingsCache.MinCache ), string.Format( Constants.XLabel, SettingsCache.MaxCache ), 1 ); SettingsHelpers.DrawIndicator( rowRect, Constants.DefaultFullLightMultiplier, Constants.PSDefaultOffsets[1], (float)SettingsCache.MinCache, (float)SettingsCache.MaxCache, IndicatorTex.DefIndicator ); rowRect.y += rowHeight * 2f; Widgets.DrawLineHorizontal(rowRect.x + 24f, rowRect.y, rowRect.width - 48f); rowRect.y += Constants.RowGap; if (Settings.CEDetected) { Widgets.CheckboxLabeled(rowRect, "EnableNVForCE".Translate(), ref Storage.NVEnabledForCE); rowRect.y += rowHeight * 2f; Widgets.DrawLineHorizontal(rowRect.x + 24f, rowRect.y, rowRect.width - 48f); rowRect.y += Constants.RowGap; } if (DrawSettings._askToConfirmReset) { if (!DrawSettings.confirmTimer.IsRunning) { DrawSettings.confirmTimer.Start(); } Color color = GUI.color; GUI.color = Color.red; if (Widgets.ButtonText(rowRect, "NVConfirmReset")) { Log.Message("NightVision.DrawSettings.GeneralTab: NVConfirm"); Storage.ResetAllSettings(); DrawSettings.confirmTimer.Reset(); } GUI.color = color; if (DrawSettings.confirmTimer.ElapsedMilliseconds > 5000) { DrawSettings._askToConfirmReset = false; DrawSettings.confirmTimer.Reset(); } } else { DrawSettings._askToConfirmReset = Widgets.ButtonText(rowRect, "NVReset"); } Text.Anchor = anchor; }
public static void DebugTab( Rect inRect ) { bool playing = Current.ProgramState == ProgramState.Playing; inRect = inRect.AtZero(); Text.Font = GameFont.Tiny; float listingY = default; #if DEBUG var listing = new Listing_Standard(); listing.Begin(inRect); listing.CheckboxLabeled("NVDebugLogComps".Translate(), ref LogPawnComps); listing.GapLine(); listing.LabelDouble("NVDebugAverageTime".Translate(), (NVHarmonyPatcher.TotalGlFactorNanoSec / NVHarmonyPatcher.TotalTicks).ToString("00 ns/tick")); listing.Label($"1 tick = {1000000000 / 60:00} ns"); listing.GapLine(); listingY = listing.CurHeight; listing.End(); #endif var rowRect = new Rect( inRect.width * 0.05f, inRect.height * 0.05f + listingY, inRect.width * 0.9f, Constants.RowHeight ); Text.Anchor = TextAnchor.MiddleLeft; //Multiplier Limits Widgets.CheckboxLabeled(rowRect, "NVCustomCapsEnabled".Translate(), ref Storage.CustomCapsEnabled); if (Storage.CustomCapsEnabled) { rowRect.y += Constants.RowHeight; Text.Font = GameFont.Tiny; Widgets.Label(rowRect, "NVCapsExp".Translate()); //Text.Font = GameFont.Small; rowRect.y += Constants.RowHeight /*+ Constants.RowGap*/; SettingsCache.MinCache = Widgets.HorizontalSlider( rowRect, (float)SettingsCache.MinCache, 1f, 100f, true, "NVSettingsMinCapLabel".Translate( SettingsCache .MinCache ), "1%", "100%", 1 ); SettingsHelpers.DrawIndicator( rowRect.TopPart(0.9f), Constants.DefaultMinCap, 0f, 1f, 100f, IndicatorTex.DefIndicator ); rowRect.y += Constants.RowHeight; SettingsCache.MaxCache = Widgets.HorizontalSlider( rowRect, (float)SettingsCache.MaxCache, 100f, 200f, true, "NVSettingsMaxCapLabel".Translate( SettingsCache .MaxCache ), "100%", "200%", 1 ); SettingsHelpers.DrawIndicator( rowRect.TopPart(0.9f), Constants.DefaultMaxCap, 0f, 100f, 200f, IndicatorTex.DefIndicator ); } rowRect.y += Constants.RowHeight; Widgets.DrawLineHorizontal(rowRect.x + 24f, rowRect.y, rowRect.width - 48f); float endY = rowRect.yMax; if (playing) { if (DrawSettings._allPawns == null) { DrawSettings._allPawns = PawnsFinder.AllMaps_Spawned.Where(pwn => pwn.RaceProps.Humanlike).ToList(); } float height; if (Math.Abs(DrawSettings._maxY) < 0.001) { height = 25 * DrawSettings._allPawns.Count + 200 * DrawSettings._allPawns .FindAll( pawn => pawn.GetComp <Comp_NightVision>() != null ) .Count; } else { height = DrawSettings._maxY; } var remainRect = new Rect( inRect.x, endY + 5f, inRect.width, inRect.yMax - endY + 5f ); var viewRect = new Rect(remainRect.x + 6f, remainRect.y, remainRect.width - 12f, height); rowRect = new Rect( remainRect.x + 10f, remainRect.y + 3f, remainRect.width - 20f, Constants.RowHeight / 2 ); Widgets.BeginScrollView(remainRect, ref DrawSettings._debugScrollPos, viewRect); Text.Font = GameFont.Tiny; foreach (Pawn pawn in DrawSettings._allPawns) { Widgets.Label(rowRect.LeftPart(0.1f), pawn.Name.ToStringShort); if (pawn.GetComp <Comp_NightVision>() is Comp_NightVision comp) { Rect rightRect = rowRect.RightPart(0.8f); Widgets.Label( rightRect, $"Number of eyes: {comp.NumberOfRemainingEyes}/{comp.RaceSightParts.Count} Natural modifier: {comp.NaturalLightModifiers.IntSetting}" ); rightRect.y += Constants.RowHeight / 2; Widgets.Label( rightRect, $"0% light modifier: {comp.ZeroLightModifier} 100% light modifier: {comp.FullLightModifier}" ); rightRect.y += Constants.RowHeight / 2; Widgets.Label( rightRect, $"Psych: {comp.PsychDark} Apparel: NightVis: {comp.ApparelGrantsNV} Anti-brightness: {comp.ApparelNullsPS}" ); rightRect.y += Constants.RowHeight / 2; Widgets.Label( rightRect, $"Health (pre-cap) [0%,100%] : NightV mod: [{comp.NvhediffMods[0]}, {comp.NvhediffMods[1]}] PhotoS mod: [{comp.PshediffMods[0]}, {comp.PshediffMods[1]}] Custom: [{comp.HediffMods[0]},{comp.HediffMods[1]}]" ); rightRect.y += Constants.RowHeight / 2; Widgets.Label(rightRect, "Body Parts & their hediffs"); foreach (KeyValuePair <string, List <HediffDef> > hedifflist in comp.PawnsNVHediffs ) { rightRect.y += Constants.RowHeight / 2; Widgets.Label( rightRect, $" Body part: {hedifflist.Key} has hediffs: " ); foreach (HediffDef hediff in hedifflist.Value) { if (Storage.HediffLightMods.TryGetValue( hediff, out Hediff_LightModifiers value )) { rightRect.y += Constants.RowHeight / 2; Widgets.Label( rightRect, $" {hediff.LabelCap}: current setting = {value.IntSetting}" ); } else { rightRect.y += Constants.RowHeight / 2; Widgets.Label( rightRect, $" {hediff.LabelCap}: No Setting" ); } } } rightRect.y += Constants.RowHeight / 2; Widgets.Label(rightRect, "Eye covering or nightvis Apparel:"); foreach (Apparel apparel in comp.PawnsNVApparel) { if (Storage.NVApparel.TryGetValue( apparel.def, out ApparelVisionSetting appSet )) { rightRect.y += Constants.RowHeight / 2; Widgets.Label( rightRect, $" {apparel.LabelCap}: nightvis: {appSet.GrantsNV} anti-bright: {appSet.NullifiesPS} - def file setting: NV:{appSet.CompGrantsNV} A-B:{appSet.CompNullifiesPS}" ); } else { rightRect.y += Constants.RowHeight / 2; Widgets.Label(rightRect, $" {apparel.LabelCap}: No Setting"); } } rightRect.y += Constants.RowHeight / 2; rowRect.y = rightRect.y; } else { Widgets.Label(rowRect.RightHalf(), "No Night Vision component found."); } rowRect.y += Constants.RowHeight / 2; Widgets.DrawLineHorizontal(rowRect.x + 10f, rowRect.y, rowRect.width - 20f); rowRect.y += Constants.RowHeight / 2; } if (Math.Abs(DrawSettings._maxY) < 0.001) { DrawSettings._maxY = rowRect.yMax; } Widgets.EndScrollView(); } }
public void DrawTab(Rect inRect) { TextAnchor anchor = Text.Anchor; float rowHeight = Constants.GEN_ROW_HEIGHT; var cache = Settings.Cache; var rowRect = new Rect( inRect.width * 0.05f, inRect.height * 0.05f, inRect.width * 0.9f, rowHeight ); Text.Anchor = TextAnchor.MiddleLeft; Widgets.Label(rowRect, "NVVanillaMultiExp".Translate()); rowRect.y += rowHeight + Constants.ROW_GAP; Widgets.DrawLineHorizontal(rowRect.x + 24f, rowRect.y, rowRect.width - 48f); rowRect.y += Constants.ROW_GAP; //Night Vision Settings Widgets.Label( rowRect, "NightVisionNVSettingDesc".Translate() .ToLower() .CapitalizeFirst() ); rowRect.y += rowHeight + Constants.ROW_GAP; cache.NVZeroCache = Widgets.HorizontalSlider( rowRect, cache.NVZeroCache.GetValueOrDefault(), cache.MinCache.GetValueOrDefault(), cache.MaxCache.GetValueOrDefault(), true, string.Format( Str.ZeroMultiLabel, cache.NVZeroCache ), string.Format( Str.XLabel, cache.MinCache ), string.Format( Str.XLabel, cache.MaxCache ), 1 ); SettingsHelpers.DrawIndicator( rowRect, Constants.DEFAULT_ZERO_LIGHT_MULTIPLIER, Constants.NVDefaultOffsets[0], cache.MinCache.GetValueOrDefault(), cache.MaxCache.GetValueOrDefault(), IndicatorTex.DefIndicator ); rowRect.y += rowHeight * 1.5f; cache.NVFullCache = Widgets.HorizontalSlider( rowRect, (float)cache.NVFullCache.GetValueOrDefault(), (float)cache.MinCache.GetValueOrDefault(), (float)cache.MaxCache.GetValueOrDefault(), true, string.Format( Str.FullMultiLabel, cache.NVFullCache ), string.Format( Str.XLabel, cache.MinCache ), string.Format( Str.XLabel, cache.MaxCache ), 1 ); SettingsHelpers.DrawIndicator( rowRect, Constants.DEFAULT_FULL_LIGHT_MULTIPLIER, Constants.NVDefaultOffsets[1], (float)cache.MinCache.GetValueOrDefault(), (float)cache.MaxCache.GetValueOrDefault(), IndicatorTex.DefIndicator ); rowRect.y += rowHeight * 2f; Widgets.DrawLineHorizontal(rowRect.x + 24f, rowRect.y, rowRect.width - 48f); rowRect.y += Constants.ROW_GAP; // Photosensitivity settings Widgets.Label( rowRect, "NightVisionPSSettingsDesc".Translate() .ToLower() .CapitalizeFirst() ); rowRect.y += rowHeight * 1.5f; cache.PSZeroCache = Widgets.HorizontalSlider( rowRect, (float)cache.PSZeroCache, (float)cache.MinCache, (float)cache.MaxCache, true, string.Format( Str.ZeroMultiLabel, cache.PSZeroCache ), string.Format( Str.XLabel, cache.MinCache ), string.Format( Str.XLabel, cache.MaxCache ), 1 ); SettingsHelpers.DrawIndicator( rowRect, Constants.DEFAULT_ZERO_LIGHT_MULTIPLIER, Constants.PSDefaultOffsets[0], (float)cache.MinCache, (float)cache.MaxCache, IndicatorTex.DefIndicator ); rowRect.y += rowHeight * 1.5f; cache.PSFullCache = Widgets.HorizontalSlider( rowRect, (float)cache.PSFullCache.GetValueOrDefault(), (float)cache.MinCache.GetValueOrDefault(), (float)cache.MaxCache.GetValueOrDefault(), true, string.Format( Str.FullMultiLabel, cache.PSFullCache ), string.Format( Str.XLabel, cache.MinCache ), string.Format( Str.XLabel, cache.MaxCache ), 1 ); SettingsHelpers.DrawIndicator( rowRect, Constants.DEFAULT_FULL_LIGHT_MULTIPLIER, Constants.PSDefaultOffsets[1], (float)cache.MinCache, (float)cache.MaxCache, IndicatorTex.DefIndicator ); rowRect.y += rowHeight * 2f; Widgets.DrawLineHorizontal(rowRect.x + 24f, rowRect.y, rowRect.width - 48f); rowRect.y += Constants.ROW_GAP; Widgets.CheckboxLabeled(rowRect, "NightVisionFlareRaidEnabled".Translate(), ref NVGameComponent.FlareRaidIsEnabled); rowRect.y += rowHeight * 2f; Widgets.DrawLineHorizontal(rowRect.x + 24f, rowRect.y, rowRect.width - 48f); rowRect.y += Constants.ROW_GAP; if (_askToConfirmReset) { if (!confirmTimer.IsRunning) { confirmTimer.Start(); } Color color = GUI.color; GUI.color = Color.red; if (Widgets.ButtonText(rowRect, "NVConfirmReset".Translate()) && confirmTimer.ElapsedMilliseconds > 500) { Settings.Store.ResetAllSettings(); confirmTimer.Reset(); } GUI.color = color; if (confirmTimer.ElapsedMilliseconds > 5000) { _askToConfirmReset = false; confirmTimer.Reset(); } } else { _askToConfirmReset = Widgets.ButtonText(rowRect, "NVReset".Translate()); } Text.Anchor = anchor; }