public override void PreOpen() { base.PreOpen(); this.tabs.Clear(); this.tabs.Add(new TabRecord("ColonistHistory.TabHome".Translate(), delegate() { MainTabWindow_ColonistHistory.curTab = MainTabWindow_ColonistHistory.TabType.Home; }, () => MainTabWindow_ColonistHistory.curTab == MainTabWindow_ColonistHistory.TabType.Home)); this.tabs.Add(new TabRecord("ColonistHistory.TabTable".Translate(), delegate() { MainTabWindow_ColonistHistory.curTab = MainTabWindow_ColonistHistory.TabType.Table; RefreshDrawEntries(); }, () => MainTabWindow_ColonistHistory.curTab == MainTabWindow_ColonistHistory.TabType.Table)); this.tabs.Add(new TabRecord("ColonistHistory.TabGraph".Translate(), delegate() { MainTabWindow_ColonistHistory.curTab = MainTabWindow_ColonistHistory.TabType.Graph; RefreshGraph(); }, () => MainTabWindow_ColonistHistory.curTab == MainTabWindow_ColonistHistory.TabType.Graph)); MainTabWindow_ColonistHistory.curPawn = CompRecorder.Colonists.First(); RecordReportUtility.Reset(); RefreshDrawEntries(); RefreshGraph(); Pawn pawn = MainTabWindow_ColonistHistory.curPawn; int lastIndex = CompRecorder.GetRecords(pawn).log.Count - 1; MainTabWindow_ColonistHistory.curDateIndex = Mathf.Clamp(MainTabWindow_ColonistHistory.curDateIndex, 0, lastIndex); }
private Vector2 DrawHeaderOnTable(Rect rect) { Text.Font = GameFont.Small; Text.Anchor = TextAnchor.MiddleLeft; GUI.BeginGroup(rect); float num = 0f; float height = rect.height; MainTabWindow_ColonistHistory.curDateIndex = Mathf.Clamp(MainTabWindow_ColonistHistory.curDateIndex, 0, CurRecords.log.Count - 1); //Log.Message(MainTabWindow_ColonistHistory.curDateIndex + "/" + CurRecords.log.Count); { Rect rectButton = new Rect(num, 0f, 140f, height); if (Widgets.ButtonText(rectButton, MainTabWindow_ColonistHistory.curPawn.Name.ToStringShort)) { List <FloatMenuOption> list = new List <FloatMenuOption>(); Func <Pawn, bool> pred = delegate(Pawn p) { return(ColonistHistoryMod.Settings.showOtherFactionPawn || !p.ExistExtraNoPlayerFactions()); }; foreach (Pawn colonist in CompRecorder.Colonists.Where(pred)) { //Log.Message(colonist.Name.ToStringShort + "/" + colonist.GetExtraHomeFaction().ToStringSafe() + ":" + colonist.GetExtraHostFaction().ToStringSafe()); Pawn p = colonist; list.Add(new FloatMenuOption(p.Name.ToStringShort, delegate() { int previousSelectedRecordsTick = !CurRecords.log.NullOrEmpty() ? this.CurData.recordTick : 0; MainTabWindow_ColonistHistory.curPawn = p; int nextIndex = CurRecords.log.FindIndex(data => data.recordTick == previousSelectedRecordsTick); if (nextIndex == -1) { nextIndex = 0; } MainTabWindow_ColonistHistory.curDateIndex = nextIndex; RefreshDrawEntries(); }, MenuOptionPriority.Default, null, null, 0f, null, null)); } Find.WindowStack.Add(new FloatMenu(list)); } num += rectButton.width; } num += 12f; Pawn pawn = MainTabWindow_ColonistHistory.curPawn; int logCount = CompRecorder.GetRecords(pawn).log.Count; int lastIndex = CompRecorder.GetRecords(pawn).log.Count - 1; int currentIndex = curDateIndex; { Rect rectButton = new Rect(num, 0f, height, height); if (logCount > 0 && Widgets.ButtonText(rectButton, "<") && curDateIndex > 0) { curDateIndex--; } num += rectButton.width; } num += 4f; { Rect rectSlider = new Rect(num, 0f, 640f, height); if (logCount > 0) { string labelSlider = CompRecorder.GetRecords(pawn).log[curDateIndex].dateString; curDateIndex = Mathf.RoundToInt(Widgets.HorizontalSlider(rectSlider, curDateIndex, 0f, lastIndex, true, labelSlider)); } num += rectSlider.width; } num += 4f; { Rect rectButton = new Rect(num, 0f, height, height); if (logCount > 0 && Widgets.ButtonText(rectButton, ">") && curDateIndex < lastIndex) { curDateIndex++; } num += rectButton.width; } if (curDateIndex != currentIndex) { RefreshDrawEntries(); } num += 12f; { Rect rectButton = new Rect(num, 0f, 40f, height); if (Widgets.ButtonText(rectButton, "...")) { Find.WindowStack.Add(new Dialog_RecordTableOption(this)); } num += rectButton.width; } num += 12f; GUI.color = new Color(1f, 0.3f, 0.35f); { Rect rectButton = new Rect(num, 0f, 40f, height); if (Widgets.ButtonText(rectButton, "x")) { Find.WindowStack.Add(new Dialog_DeleteLog(this)); } num += rectButton.width; } GUI.color = Color.white; Text.Anchor = TextAnchor.UpperLeft; GUI.EndGroup(); return(new Vector2(num, height)); }