示例#1
0
        public static int DateToGameTicksOffsetAgnostic(int year, Quadrum quadrum, int day, int hour, int offsetHours)
        {
            var yearDiff  = year - GenDate.DefaultStartingYear;
            var yearTicks = yearDiff * GenDate.TicksPerYear;

            var quadrumTicks = (int)quadrum * GenDate.TicksPerQuadrum;

            // day is 1-15, map to 0-14
            var dayTicks = (day - 1) * GenDate.TicksPerDay;

            var hourTicks = hour * GenDate.TicksPerHour;

            var offsetTicks = offsetHours * GenDate.TicksPerHour;

            return(GenDate.TickAbsToGame(yearTicks + quadrumTicks + dayTicks + hourTicks - offsetTicks));
        }
 public void ResolveGraph()
 {
     this.cachedGraph = new Dictionary <Pawn, List <Vector2> >();
     if (this.comp != null)
     {
         foreach (Pawn pawn in this.comp.Colonists)
         {
             ColonistHistoryDataList dataList = this.comp.GetRecords(pawn);
             if (!dataList.log.NullOrEmpty())
             {
                 this.cachedGraph[pawn] = new List <Vector2>();
                 if (dataList != null)
                 {
                     foreach (ColonistHistoryData data in dataList.log)
                     {
                         ColonistHistoryRecord record = data.GetRecord(recordID, false);
                         if ((record != null && !record.IsUnrecorded) || ColonistHistoryMod.Settings.treatingUnrecordedAsZero)
                         {
                             float x = GenDate.TickAbsToGame(data.recordTick);
                             float y = 0f;
                             if (record != null)
                             {
                                 y = record.ValueForGraph;
                             }
                             if (this.cachedGraph[pawn].Count == 0 && ColonistHistoryMod.Settings.addZeroBeforeFirst)
                             {
                                 this.cachedGraph[pawn].Add(new Vector2(x - 0.001f, 0));
                             }
                             this.cachedGraph[pawn].Add(new Vector2(x, y));
                         }
                     }
                 }
             }
         }
     }
 }
示例#3
0
        public static int RelativeTimeToGameTicks(int days, int hours)
        {
            var periodTicks = days * GenDate.TicksPerDay + hours * GenDate.TicksPerHour;

            return(ToNearestHour(GenDate.TickAbsToGame(periodTicks + Find.TickManager.TicksAbs)));
        }
示例#4
0
        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();
        }
示例#5
0
        public static void Draw(Rect rect)
        {
            rect.yMin += 17f;
            GUI.BeginGroup(rect);
            Rect graphRect  = new Rect(0f, 0f, rect.width, rect.height - 100f);
            Rect legendRect = new Rect(468f, graphRect.yMax, rect.width - 468f, 80f);
            Rect rect2      = new Rect(0f, legendRect.yMin + 44f, rect.width, 40f);

            if (RecordGraphUtility.CurRecordGroup != null)
            {
                RecordGraphUtility.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;
                        RecordGraphUtility.marks.Add(new CurveMark(x, tale.ShortSummary, tale.def.historyGraphColor));
                    }
                }
                RecordGraphUtility.CurRecordGroup.DrawGraph(graphRect, legendRect, RecordGraphUtility.graphSection, RecordGraphUtility.marks);
            }
            Text.Font = GameFont.Small;
            float num = (float)Find.TickManager.TicksGame / 60000f;

            if (Widgets.ButtonText(new Rect(0f, legendRect.yMin, 110f, 40f), "Last30Days".Translate(), true, true, true))
            {
                RecordGraphUtility.graphSection = new FloatRange(Mathf.Max(0f, num - 30f), num);
                SoundDefOf.Click.PlayOneShotOnCamera(null);
            }
            if (Widgets.ButtonText(new Rect(114f, legendRect.yMin, 110f, 40f), "Last100Days".Translate(), true, true, true))
            {
                RecordGraphUtility.graphSection = new FloatRange(Mathf.Max(0f, num - 100f), num);
                SoundDefOf.Click.PlayOneShotOnCamera(null);
            }
            if (Widgets.ButtonText(new Rect(228f, legendRect.yMin, 110f, 40f), "Last300Days".Translate(), true, true, true))
            {
                RecordGraphUtility.graphSection = new FloatRange(Mathf.Max(0f, num - 300f), num);
                SoundDefOf.Click.PlayOneShotOnCamera(null);
            }
            if (Widgets.ButtonText(new Rect(342f, legendRect.yMin, 110f, 40f), "AllDays".Translate(), true, true, true))
            {
                RecordGraphUtility.graphSection = new FloatRange(0f, num);
                SoundDefOf.Click.PlayOneShotOnCamera(null);
            }
            if (Widgets.ButtonText(new Rect(rect2.x, rect2.y, 110f, 40f), "SelectGraph".Translate(), true, true, true))
            {
                List <FloatMenuOption> list = new List <FloatMenuOption>();
                foreach (RecordIdentifier recordID in RecordGraphUtility.comp.NumericRecords)
                {
                    RecordIdentifier localRecordID = recordID;
                    list.Add(new FloatMenuOption(localRecordID.Label, delegate() {
                        RecordGraphUtility.CurRecordID = localRecordID;
                    }, MenuOptionPriority.Default, null, null, 0f, null, null));
                }
                FloatMenu window = new FloatMenu(list, "SelectGraph".Translate(), false);
                Find.WindowStack.Add(window);
            }
            if (RecordGraphUtility.CurRecordID.IsVaild)
            {
                Text.Anchor = TextAnchor.MiddleLeft;
                Widgets.Label(new Rect(rect2.x + 118f, rect2.y, 300f, 40f), RecordGraphUtility.CurRecordID.Label);
                Text.Anchor = TextAnchor.UpperLeft;
            }
            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();
        }