public static void CheckboxLabeled(Rect rect, string label, ref bool checkOn, bool disabled = false, Texture2D texChecked = null, Texture2D texUnchecked = null, bool placeTextNearCheckbox = false) { TextAnchor anchor = Text.Anchor; Text.Anchor = TextAnchor.MiddleLeft; if (placeTextNearCheckbox) { float textWidth = Text.CalcSize(label).x; rect.x = rect.xMax - textWidth - 24f - 5f; rect.width = textWidth + 24f + 5f; } Widgets.Label(rect, label); if (!disabled && Widgets.ButtonInvisible(rect, false)) { checkOn = !checkOn; if (checkOn) { SoundDefOf.Checkbox_TurnedOn.PlayOneShotOnCamera(null); } else { SoundDefOf.Checkbox_TurnedOff.PlayOneShotOnCamera(null); } } Widgets.CheckboxDraw(rect.x + rect.width - 24f, rect.y, checkOn, disabled, 24f, null, null); Text.Anchor = anchor; }
public static void TypesBox(Rect rect) { var speng = rect; speng.height = 25f; var glorph = speng.LeftPart(0.9f); speng = speng.RightPart(0.1f); var reod = false; var old1 = TypeSearch; TypeSearch = Widgets.TextField(glorph.LeftHalf(), TypeSearch); if (old1 != TypeSearch) { reod = true; } var old2 = MethSearch; MethSearch = Widgets.TextField(glorph.RightHalf(), MethSearch); if (old2 != MethSearch) { reod = true; } //if (Widgets.ButtonText(speng, "Search")) //{ //} if (reod && (TypeSearch.Length > 2 || MethSearch.Length > 2)) { GotMeth = Dialog_Analyzer.SearchFor().ToList(); } rect.y += 25f; rect.height -= 25f; var innyrek = rect.AtZero(); innyrek.width -= 32f; innyrek.height = groaner; Widgets.BeginScrollView(rect, ref scrolpos, innyrek); GUI.BeginGroup(innyrek); listing.Begin(innyrek); float goat = 0; Text.Anchor = TextAnchor.MiddleLeft; Text.Font = GameFont.Tiny; var coo = 0; foreach (var meth in GotMeth) { coo++; if (coo == 50) { break; } var tp = meth.Name; var r = listing.GetRect(30f); if (Analyzer.Settings.Loggers == null) { Analyzer.Settings.Loggers = new Dictionary <string, bool>(); } if (Widgets.ButtonInvisible(r)) { if (!Analyzer.Settings.Loggers.ContainsKey(tp)) { Analyzer.Settings.Loggers.Add(tp, true); } else { var bam = Analyzer.Settings.Loggers[tp]; Analyzer.Settings.Loggers[tp] = !bam; } } if (Analyzer.Settings.Loggers.ContainsKey(tp)) { var bam = Analyzer.Settings.Loggers[tp]; r = r.LeftPartPixels(75); Widgets.CheckboxDraw(r.x, r.y, bam, true); } else { r = r.LeftPartPixels(75); Widgets.CheckboxDraw(r.x, r.y, false, true); } r.x = r.xMax; r.width = 2000; Widgets.Label(r, $"{meth.ReflectedType} {meth}"); listing.GapLine(0f); goat += 4f; goat += r.height; } listing.End(); groaner = goat; GUI.EndGroup(); Text.Font = GameFont.Small; Text.Anchor = TextAnchor.UpperLeft; Widgets.EndScrollView(); }