public override void PreOpen() { base.PreOpen(); WorldUtility.ValidateFactions(true); tabs.Clear(); tabs.Add(new TabRecord("RW_Relations".Translate(), delegate { curTab = RimWarTab.Relations; }, () => curTab == RimWarTab.Relations)); tabs.Add(new TabRecord("RW_Events".Translate(), delegate { curTab = RimWarTab.Events; }, () => curTab == RimWarTab.Events)); tabs.Add(new TabRecord("RW_Performance".Translate(), delegate { curTab = RimWarTab.Performance; }, () => curTab == RimWarTab.Performance)); historyAutoRecorderGroup = Find.History.Groups().FirstOrDefault((HistoryAutoRecorderGroup x) => x.def.defName == "RimWar_Power"); if (historyAutoRecorderGroup != null) { graphSection = new FloatRange(0f, (float)Find.TickManager.TicksGame / 60000f); } List <Map> maps = Find.Maps; for (int i = 0; i < maps.Count; i++) { maps[i].wealthWatcher.ForceRecount(); } }
public override void PreOpen() { base.PreOpen(); this.historyAutoRecorderGroup = Find.History.Groups().FirstOrDefault <HistoryAutoRecorderGroup>(); if (this.historyAutoRecorderGroup != null) { this.graphSection = new FloatRange(0f, (float)Find.TickManager.TicksGame / 60000f); } List <Map> maps = Find.Maps; for (int i = 0; i < maps.Count; i++) { maps[i].wealthWatcher.ForceRecount(false); } }
public static void RecalculateGraph(HistoryAutoRecorderGroup recorderGroup) { GraphUtility.cachedGraphTick = Find.TickManager.TicksGame; GraphUtility.curves.Clear(); GraphUtility.activeCurves.Clear(); if (!activeLegends.TryGetValue(recorderGroup, out curActiveLegends)) { curActiveLegends = new List <bool>(); for (int i = 0; i < recorderGroup.recorders.Count; i++) { curActiveLegends.Add(true); } activeLegends.Add(recorderGroup, curActiveLegends); } for (int i = 0; i < recorderGroup.recorders.Count; i++) { HistoryAutoRecorder historyAutoRecorder = recorderGroup.recorders[i]; SimpleCurveDrawInfo simpleCurveDrawInfo = new SimpleCurveDrawInfo(); simpleCurveDrawInfo.color = historyAutoRecorder.def.graphColor; simpleCurveDrawInfo.label = historyAutoRecorder.def.LabelCap; simpleCurveDrawInfo.labelY = historyAutoRecorder.def.GraphLabelY; simpleCurveDrawInfo.curve = new SimpleCurve(); for (int j = 0; j < historyAutoRecorder.records.Count; j++) { simpleCurveDrawInfo.curve.Add(new CurvePoint((float)j * (float)historyAutoRecorder.def.recordTicksFrequency / 60000f, historyAutoRecorder.records[j]), false); } simpleCurveDrawInfo.curve.SortPoints(); if (historyAutoRecorder.records.Count == 1) { simpleCurveDrawInfo.curve.Add(new CurvePoint(1.66666669E-05f, historyAutoRecorder.records[0]), true); } if (curActiveLegends[i]) { GraphUtility.activeCurves.Add(simpleCurveDrawInfo); } GraphUtility.curves.Add(simpleCurveDrawInfo); } }
private void DoPerformancePage(Rect rect) { rect.yMin += 17f; GUI.BeginGroup(rect); Rect graphRect = new Rect(0f, 0f, rect.width, 450f); Rect legendRect = new Rect(0f, graphRect.yMax, rect.width / 2f, 40f); Rect rect2 = new Rect(0f, legendRect.yMax, rect.width, 40f); if (historyAutoRecorderGroup != null) { marks.Clear(); List <Tale> allTalesListForReading = Find.TaleManager.AllTalesListForReading; for (int i = 0; i < allTalesListForReading.Count; i++) { Tale tale = allTalesListForReading[i]; if (tale.def.type == TaleType.PermanentHistorical) { float x = (float)GenDate.TickAbsToGame(tale.date) / 60000f; marks.Add(new CurveMark(x, tale.ShortSummary, tale.def.historyGraphColor)); } } historyAutoRecorderGroup.DrawGraph(graphRect, legendRect, graphSection, marks); } Text.Font = GameFont.Small; float num = (float)Find.TickManager.TicksGame / 60000f; if (Widgets.ButtonText(new Rect(legendRect.xMin + legendRect.width, legendRect.yMin, 110f, 40f), "Last30Days".Translate())) { graphSection = new FloatRange(Mathf.Max(0f, num - 30f), num); } if (Widgets.ButtonText(new Rect(legendRect.xMin + legendRect.width + 110f + 4f, legendRect.yMin, 110f, 40f), "Last100Days".Translate())) { graphSection = new FloatRange(Mathf.Max(0f, num - 100f), num); } if (Widgets.ButtonText(new Rect(legendRect.xMin + legendRect.width + 228f, legendRect.yMin, 110f, 40f), "Last300Days".Translate())) { graphSection = new FloatRange(Mathf.Max(0f, num - 300f), num); } if (Widgets.ButtonText(new Rect(legendRect.xMin + legendRect.width + 342f, legendRect.yMin, 110f, 40f), "AllDays".Translate())) { graphSection = new FloatRange(0f, num); } if (Widgets.ButtonText(new Rect(rect2.x, rect2.y, 110f, 40f), "SelectGraph".Translate())) { List <FloatMenuOption> list = new List <FloatMenuOption>(); List <HistoryAutoRecorderGroup> list2 = Find.History.Groups(); for (int j = 0; j < list2.Count; j++) { HistoryAutoRecorderGroup groupLocal = list2[j]; if (groupLocal.def.defName.Contains("RimWar_")) { list.Add(new FloatMenuOption(groupLocal.def.LabelCap, delegate { historyAutoRecorderGroup = groupLocal; })); } } FloatMenu window = new FloatMenu(list, "SelectGraph".Translate()); Find.WindowStack.Add(window); PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.HistoryTab, KnowledgeAmount.Total); } GUI.EndGroup(); }
private void DoGraphPage(Rect rect) { GUI.BeginGroup(rect); Rect graphRect = new Rect(0f, 0f, rect.width - GraphItemAreaWidth - GraphLegendAreaWidth - FramePadding, GraphAreaHeight); Rect legendRect = new Rect(graphRect.xMax + FramePadding, graphRect.yMin, GraphLegendAreaWidth - FramePadding, GraphAreaHeight); if (this.historyAutoRecorderGroup != null) { MainTabWindow_DetailedHistory.marks.Clear(); List <Tale> allTalesListForReading = Find.TaleManager.AllTalesListForReading; for (int i = 0; i < allTalesListForReading.Count; i++) { Tale tale = allTalesListForReading[i]; if (tale.def.type == TaleType.PermanentHistorical) { float x = (float)GenDate.TickAbsToGame(tale.date) / 60000f; MainTabWindow_DetailedHistory.marks.Add(new CurveMark(x, tale.ShortSummary, tale.def.historyGraphColor)); } } GraphUtility.DrawGraph(graphRect, legendRect, this.graphSection, MainTabWindow_DetailedHistory.marks, this.historyAutoRecorderGroup); } Text.Font = GameFont.Small; float num = (float)Find.TickManager.TicksGame / 60000f; string str; float daysMin; if (this.sliderValue > 300f) { str = "AllDays"; daysMin = 0f; } else { str = "Last {0}Days".Translate(this.sliderValue); daysMin = Mathf.Max(0f, num - this.sliderValue); } Rect horizontalRect = new Rect(0f, GraphAreaHeight, 300f, 40f); this.sliderValue = Widgets.HorizontalSlider(horizontalRect, this.sliderValue, 5, 301f, true, str); this.graphSection = new FloatRange(daysMin, num); List <HistoryAutoRecorderGroup> list2 = Find.History.Groups(); Rect outRect = new Rect(legendRect.xMax + FramePadding, graphRect.yMin, GraphItemAreaWidth - FramePadding, GraphAreaHeight); Rect viewRect = new Rect(0f, 2f, outRect.width, 24f * list2.Count); GUI.color = Color.white; Widgets.DrawBox(outRect, 1); Widgets.BeginScrollView(outRect, ref this.graphItemScrollPosition, viewRect, true); Listing_Standard listing = new Listing_Standard(); listing.Begin(new Rect(0f, 2f, viewRect.width, 9999f)); for (int i = 0; i < list2.Count; i++) { HistoryAutoRecorderGroup groupLocal = list2[i]; if (listing.RadioButton(groupLocal.def.LabelCap, this.historyAutoRecorderGroup == groupLocal)) { this.historyAutoRecorderGroup = groupLocal; GraphUtility.RecalculateGraph(groupLocal); PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.HistoryTab, KnowledgeAmount.Total); } } listing.End(); Widgets.EndScrollView(); GUI.EndGroup(); }
public static void DrawGraph(Rect graphRect, Rect legendRect, FloatRange section, List <CurveMark> marks, HistoryAutoRecorderGroup recorderGroup) { if (Find.TickManager.TicksGame != GraphUtility.cachedGraphTick) { GraphUtility.RecalculateGraph(recorderGroup); } if (Mathf.Approximately(section.min, section.max)) { section.max += 1.66666669E-05f; } SimpleCurveDrawerStyle curveDrawerStyle = Find.History.curveDrawerStyle; curveDrawerStyle.FixedSection = section; curveDrawerStyle.UseFixedScale = recorderGroup.def.useFixedScale; curveDrawerStyle.FixedScale = recorderGroup.def.fixedScale; curveDrawerStyle.YIntegersOnly = recorderGroup.def.integersOnly; GraphUtility.DrawCurves(graphRect, curveDrawerStyle, marks); GraphUtility.DrawLegends(legendRect, curveDrawerStyle); Text.Anchor = TextAnchor.UpperLeft; }