public static TabRecord DrawTabs(Rect baseRect, List <TabRecord> tabs, int rows) { if (rows <= 1) { return(DrawTabs(baseRect, tabs)); } int num = Mathf.FloorToInt(tabs.Count / rows); int num2 = 0; TabRecord result = null; Rect rect = baseRect; baseRect.yMin -= (float)(rows - 1) * 31f; Rect rect2 = baseRect; rect2.yMax = rect.y; Widgets.DrawMenuSection(rect2); for (int i = 0; i < rows; i++) { int num3 = ((i == 0) ? (tabs.Count - (rows - 1) * num) : num); tmpTabs.Clear(); for (int j = num2; j < num2 + num3; j++) { tmpTabs.Add(tabs[j]); } TabRecord tabRecord = DrawTabs(baseRect, tmpTabs, baseRect.width); if (tabRecord != null) { result = tabRecord; } baseRect.yMin += 31f; num2 += num3; } tmpTabs.Clear(); return(result); }
internal Rect <> m__0(TabRecord tab) { int num = this.tabs.IndexOf(tab); float x = (float)num * (this.tabWidth - 10f); return(new Rect(x, 1f, this.tabWidth, 32f)); }
public override void DoWindowContents(Rect inRect) { Rect rect = new Rect(inRect); rect = rect.ContractedBy(18f); rect.height = 34f; Text.Font = GameFont.Medium; Widgets.Label(rect, this.GetTitle()); Rect rect2 = new Rect(inRect); rect2.yMin = rect.yMax; rect2.yMax -= 38f; Rect rect3 = rect2; rect3.yMin += 45f; List <TabRecord> list = new List <TabRecord>(); TabRecord item = new TabRecord("TabStats".Translate(), delegate { this.tab = Dialog_InfoCard.InfoCardTab.Stats; }, this.tab == Dialog_InfoCard.InfoCardTab.Stats); list.Add(item); if (this.ThingPawn != null) { if (this.ThingPawn.RaceProps.Humanlike) { TabRecord item2 = new TabRecord("TabCharacter".Translate(), delegate { this.tab = Dialog_InfoCard.InfoCardTab.Character; }, this.tab == Dialog_InfoCard.InfoCardTab.Character); list.Add(item2); } TabRecord item3 = new TabRecord("TabHealth".Translate(), delegate { this.tab = Dialog_InfoCard.InfoCardTab.Health; }, this.tab == Dialog_InfoCard.InfoCardTab.Health); list.Add(item3); TabRecord item4 = new TabRecord("TabRecords".Translate(), delegate { this.tab = Dialog_InfoCard.InfoCardTab.Records; }, this.tab == Dialog_InfoCard.InfoCardTab.Records); list.Add(item4); } TabDrawer.DrawTabs(rect3, list); this.FillCard(rect3.ContractedBy(18f)); }
public static TabRecord DrawTabs(Rect baseRect, List <TabRecord> tabs, int rows) { TabRecord result; if (rows <= 1) { result = TabDrawer.DrawTabs(baseRect, tabs, 200f); } else { int num = Mathf.FloorToInt((float)(tabs.Count / rows)); int num2 = 0; TabRecord tabRecord = null; Rect rect = baseRect; baseRect.yMin -= (float)(rows - 1) * 31f; Rect rect2 = baseRect; rect2.yMax = rect.y; Widgets.DrawMenuSection(rect2); for (int i = 0; i < rows; i++) { int num3 = (i != 0) ? num : (tabs.Count - (rows - 1) * num); TabDrawer.tmpTabs.Clear(); for (int j = num2; j < num2 + num3; j++) { TabDrawer.tmpTabs.Add(tabs[j]); } TabRecord tabRecord2 = TabDrawer.DrawTabs(baseRect, TabDrawer.tmpTabs, baseRect.width); if (tabRecord2 != null) { tabRecord = tabRecord2; } baseRect.yMin += 31f; num2 += num3; } TabDrawer.tmpTabs.Clear(); result = tabRecord; } return(result); }
public override void DoWindowContents(Rect inRect) { Rect rect = new Rect(inRect); rect = rect.ContractedBy(18f); rect.height = 34f; rect.x += 34f; Text.Font = GameFont.Medium; Widgets.Label(rect, GetTitle()); Rect rect2 = new Rect(inRect.x + 9f, rect.y, 34f, 34f); if (thing != null) { Widgets.ThingIcon(rect2, thing); } else { Widgets.DefIcon(rect2, def, stuff, 1f, drawPlaceholder: true); } Rect rect3 = new Rect(inRect); rect3.yMin = rect.yMax; rect3.yMax -= 38f; Rect rect4 = rect3; List <TabRecord> list = new List <TabRecord>(); TabRecord item = new TabRecord("TabStats".Translate(), delegate { tab = InfoCardTab.Stats; }, tab == InfoCardTab.Stats); list.Add(item); if (ThingPawn != null) { if (ThingPawn.RaceProps.Humanlike) { TabRecord item2 = new TabRecord("TabCharacter".Translate(), delegate { tab = InfoCardTab.Character; }, tab == InfoCardTab.Character); list.Add(item2); } TabRecord item3 = new TabRecord("TabHealth".Translate(), delegate { tab = InfoCardTab.Health; }, tab == InfoCardTab.Health); list.Add(item3); if (ModsConfig.RoyaltyActive && ThingPawn.RaceProps.Humanlike && ThingPawn.Faction == Faction.OfPlayer && !ThingPawn.IsQuestLodger() && ThingPawn.royalty != null && PermitsCardUtility.selectedFaction != null) { TabRecord item4 = new TabRecord("TabPermits".Translate(), delegate { tab = InfoCardTab.Permits; }, tab == InfoCardTab.Permits); list.Add(item4); } TabRecord item5 = new TabRecord("TabRecords".Translate(), delegate { tab = InfoCardTab.Records; }, tab == InfoCardTab.Records); list.Add(item5); } if (list.Count > 1) { rect4.yMin += 45f; TabDrawer.DrawTabs(rect4, list); } FillCard(rect4.ContractedBy(18f)); if (def != null && def is BuildableDef) { IEnumerable <ThingDef> enumerable = GenStuff.AllowedStuffsFor((BuildableDef)def); if (enumerable.Count() > 0 && ShowMaterialsButton(inRect, history.Count > 0)) { List <FloatMenuOption> list2 = new List <FloatMenuOption>(); foreach (ThingDef item6 in enumerable) { ThingDef localStuff = item6; list2.Add(new FloatMenuOption(item6.LabelCap, delegate { stuff = localStuff; Setup(); }, item6)); } Find.WindowStack.Add(new FloatMenu(list2)); } } if (history.Count > 0 && Widgets.BackButtonFor(inRect)) { Hyperlink hyperlink = history[history.Count - 1]; history.RemoveAt(history.Count - 1); Find.WindowStack.TryRemove(typeof(Dialog_InfoCard), doCloseSound: false); hyperlink.OpenDialog(); } }
public static TabRecord DrawTabs(Rect baseRect, List <TabRecord> tabs, float maxTabWidth = 200f) { TabRecord tabRecord = null; TabRecord tabRecord2 = tabs.Find((TabRecord t) => t.Selected); float num = baseRect.width + (float)(tabs.Count - 1) * 10f; float tabWidth = num / (float)tabs.Count; if (tabWidth > maxTabWidth) { tabWidth = maxTabWidth; } Rect position = new Rect(baseRect); position.y -= 32f; position.height = 9999f; GUI.BeginGroup(position); Text.Anchor = TextAnchor.MiddleCenter; Text.Font = GameFont.Small; Func <TabRecord, Rect> func = (TabRecord tab) => new Rect((float)tabs.IndexOf(tab) * (tabWidth - 10f), 1f, tabWidth, 32f); List <TabRecord> list = tabs.ListFullCopy(); if (tabRecord2 != null) { list.Remove(tabRecord2); list.Add(tabRecord2); } TabRecord tabRecord3 = null; List <TabRecord> list2 = list.ListFullCopy(); list2.Reverse(); for (int i = 0; i < list2.Count; i++) { TabRecord tabRecord4 = list2[i]; Rect rect = func(tabRecord4); if (tabRecord3 == null && Mouse.IsOver(rect)) { tabRecord3 = tabRecord4; } MouseoverSounds.DoRegion(rect, SoundDefOf.Mouseover_Tab); if (Widgets.ButtonInvisible(rect)) { tabRecord = tabRecord4; } } foreach (TabRecord item in list) { Rect rect2 = func(item); item.Draw(rect2); } Text.Anchor = TextAnchor.UpperLeft; GUI.EndGroup(); if (tabRecord != null && tabRecord != tabRecord2) { SoundDefOf.RowTabSelect.PlayOneShotOnCamera(); if (tabRecord.clickedAction != null) { tabRecord.clickedAction(); } } return(tabRecord); }
public static TabRecord DrawTabs(Rect baseRect, IEnumerable <TabRecord> tabsEnum) { TabDrawer.tabList.Clear(); foreach (TabRecord item in tabsEnum) { TabDrawer.tabList.Add(item); } TabRecord tabRecord = null; TabRecord tabRecord2 = (from t in TabDrawer.tabList where t.selected select t).FirstOrDefault(); if (tabRecord2 == null) { Log.ErrorOnce("Drew tabs without any being selected.", 5509712); return(TabDrawer.tabList[0]); } float num = (float)(baseRect.width + (float)(TabDrawer.tabList.Count - 1) * 10.0); float tabWidth = num / (float)TabDrawer.tabList.Count; if (tabWidth > 200.0) { tabWidth = 200f; } Rect position = new Rect(baseRect); position.y -= 32f; position.height = 9999f; GUI.BeginGroup(position); Text.Anchor = TextAnchor.MiddleCenter; Text.Font = GameFont.Small; Func <TabRecord, Rect> func = delegate(TabRecord tab) { int num2 = TabDrawer.tabList.IndexOf(tab); float x = (float)((float)num2 * (tabWidth - 10.0)); return(new Rect(x, 1f, tabWidth, 32f)); }; List <TabRecord> list = TabDrawer.tabList.ListFullCopy(); list.Remove(tabRecord2); list.Add(tabRecord2); TabRecord tabRecord3 = null; List <TabRecord> list2 = list.ListFullCopy(); list2.Reverse(); for (int i = 0; i < list2.Count; i++) { TabRecord tabRecord4 = list2[i]; Rect rect = func(tabRecord4); if (tabRecord3 == null && Mouse.IsOver(rect)) { tabRecord3 = tabRecord4; } MouseoverSounds.DoRegion(rect, SoundDefOf.MouseoverTab); if (Widgets.ButtonInvisible(rect, false)) { tabRecord = tabRecord4; } } foreach (TabRecord item2 in list) { Rect rect2 = func(item2); item2.Draw(rect2); } Text.Anchor = TextAnchor.UpperLeft; GUI.EndGroup(); if (tabRecord != null && tabRecord != tabRecord2) { SoundDefOf.RowTabSelect.PlayOneShotOnCamera(null); if (tabRecord.clickedAction != null) { tabRecord.clickedAction(); } } return(tabRecord); }
private static bool <DrawTabs> m__0(TabRecord t) { return(t.Selected); }