Beispiel #1
0
        private void DrawTileInfo()
        {
            DrawEntryHeader("PLTFWTW_TileSpecifications".Translate(), backgroundColor: Color.magenta);

            ListingStandard.Label($"Temperature Scale: {Prefs.TemperatureMode.ToStringHuman()}",
                                  tooltip: "The scale in which are displayed all temperatures on this window."); //TODO: translate

            var vectorLongLat = Find.WorldGrid.LongLatOf(_tileId);
            var latitude      = vectorLongLat.y;
            var longitude     = vectorLongLat.x;

            ListingStandard.Label($"{"PLTFWTW_Date".Translate()}: {GenDate.DateReadoutStringAt(_dateTicks, vectorLongLat)}");
            ListingStandard.Label($"{"PLTFWTW_TileId".Translate()}: {_tileId}");

            ListingStandard.Label(
                $"{"PLTFWTW_LatLong".Translate()}: {latitude.ToStringLatitude()} - {longitude.ToStringLongitude()}");

            ListingStandard.Label($"{"PLTFWTW_EquatorialDistance".Translate()}: {Find.WorldGrid.DistanceFromEquatorNormalized(_tileId)}");

            var tileTempCelsius = Find.World.grid[_tileId].temperature;

            ListingStandard.Label(
                $"{"PLTFWTW_TileAvgTemp".Translate()}: {GenTemperature.CelsiusTo(tileTempCelsius, Prefs.TemperatureMode)} {Prefs.TemperatureMode.ToStringHuman()}");

            var seasonalShiftAmplitudeCelsius = GenTemperature.SeasonalShiftAmplitudeAt(_tileId);

            ListingStandard.Label($"{"PLTFWTW_SeasonalShiftAmplitude".Translate()}: {GenTemperature.CelsiusTo(seasonalShiftAmplitudeCelsius, Prefs.TemperatureMode)} {Prefs.TemperatureMode.ToStringHuman()}");
        }
        public static string ConvertToDateTimeString(int tick, int tile)
        {
            Vector2 vector     = Find.WorldGrid.LongLatOf(tile);
            string  hourString = GenDate.HourInteger((long)tick, vector.x) + "LetterHour".Translate();

            return("ColonistHistory.DateString".Translate(GenDate.DateReadoutStringAt((long)tick, vector), hourString));
        }
        public override string GetInspectString()
        {
            StringBuilder stringBuilder = new StringBuilder();

            stringBuilder.Append(base.GetInspectString() + "\n");
            Vector2 vector = Find.WorldGrid.LongLatOf(this.Map.Tile);

            stringBuilder.Append("VBE.NewspaperRelevantUntil".Translate() + GenDate.DateReadoutStringAt((long)this.expireTimeAbs, vector));
            return(stringBuilder.ToString().TrimEndNewlines());
        }
        private void DrawTileInfo()
        {
            DrawEntryHeader("PLTFWTW_TileSpecifications".Translate(), backgroundColor: Color.magenta);

            var vectorLongLat = Find.WorldGrid.LongLatOf(_tileId);
            var latitude      = vectorLongLat.y;
            var longitude     = vectorLongLat.x;

            ListingStandard.Label($"{"PLTFWTW_Date".Translate()}: {GenDate.DateReadoutStringAt(_dateTicks, vectorLongLat)}");
            ListingStandard.Label($"{"PLTFWTW_TileId".Translate()}: {_tileId}");
            ListingStandard.Label(
                $"{"PLTFWTW_LatLong".Translate()}: {latitude.ToStringLatitude()} - {longitude.ToStringLongitude()}");
            ListingStandard.Label($"{"PLTFWTW_EquatorialDistance".Translate()}: {Find.WorldGrid.DistanceFromEquatorNormalized(_tileId)}");
            ListingStandard.Label($"{"PLTFWTW_TileAvgTemp".Translate()}: {Find.World.grid[_tileId].temperature} °C");
            ListingStandard.Label($"{"PLTFWTW_SeasonalShiftAmplitude".Translate()}: {GenTemperature.SeasonalShiftAmplitudeAt(_tileId)} °C");
        }
        public static void ViewTemperatureForecast(int tileId, int dateTicks)
        {
            /*
             * Forecast for twelves of year.
             */
            var tempsForTwelves = TemperatureData.TemperaturesForTwelfth(tileId);
            var twelvesGetters  = new List <ColumnData <TemperatureForecastForTwelfth> >
            {
                new ColumnData <TemperatureForecastForTwelfth>("PLTFW_Quadrum".Translate(), "PLTFW_QuadrumToolTip".Translate(),
                                                               tfft => $"{tfft.Twelfth.GetQuadrum()}"),
                new ColumnData <TemperatureForecastForTwelfth>("PLTFW_Season".Translate(), "PLTFW_SeasonToolTip".Translate(),
                                                               tfft => $"{tfft.Twelfth.GetQuadrum().GetSeason(tfft.Latitude)}"),
                new ColumnData <TemperatureForecastForTwelfth>("PLTFW_Twelfth".Translate(), "PLTFW_TwelfthToolTip".Translate(),
                                                               tfft => $"{tfft.Twelfth}"),
                new ColumnData <TemperatureForecastForTwelfth>("PLTFW_AvgTemp".Translate(), "PLTFW_AvgTempToolTip".Translate(),
                                                               tfft => $"{tfft.AverageTemperatureForTwelfth:F2}")
            };
            var tableViewTempForTwelves =
                new TableView <TemperatureForecastForTwelfth>("PLTFW_ForecastForTwelves".Translate(), tempsForTwelves,
                                                              twelvesGetters);


            var dateString = GenDate.DateReadoutStringAt(dateTicks, Find.WorldGrid.LongLatOf(tileId));

            /*
             * Forecast for hours of day
             */
            var temperaturesForHoursOfDay =
                TemperatureData.TemperaturesForDay(tileId, dateTicks);
            var temperaturesForHoursGetters = new List <ColumnData <TemperatureForecastForDay> >
            {
                new ColumnData <TemperatureForecastForDay>("PLTFW_Hour".Translate(), "PLTFW_HourToolTip".Translate(), tffd => $"{tffd.Hour}"),
                new ColumnData <TemperatureForecastForDay>("PLTFW_OutdoorTemp".Translate(), "PLTFW_OutdoorTempToolTip".Translate(),
                                                           tffd => $"{tffd.OutdoorTemperature:F1}"),
                //new ColumnData<TemperatureForecastForDay>("RandomVar", "Daily Random Variation", tffd => $"{tffd.DailyRandomVariation:F1}"),
                new ColumnData <TemperatureForecastForDay>("PLTFW_OffDRV".Translate(), "PLTFW_OffDRVToolTip".Translate(),
                                                           tffd => $"{tffd.OffsetFromDailyRandomVariation:F1}"),
                new ColumnData <TemperatureForecastForDay>("PLTFW_OffSeason".Translate(), "PLTFW_OffSeasonToolTip".Translate(),
                                                           tffd => $"{tffd.OffsetFromSeasonCycle:F1}"),
                new ColumnData <TemperatureForecastForDay>("PLTFW_SunEff".Translate(), "PLTFW_SunEffToolTip".Translate(),
                                                           tffd => $"{tffd.OffsetFromSunCycle:F1}")
            };

            var tableName           = string.Format("PLTFW_ForecastForHours".Translate(), GenDate.HoursPerDay, dateString);
            var tableViewTempForDay =
                new TableView <TemperatureForecastForDay>(tableName, temperaturesForHoursOfDay,
                                                          temperaturesForHoursGetters);

            /*
             * Forecast for days or year
             */
            var tempsForDaysOfYear =
                TemperatureData.TemperaturesForYear(tileId, dateTicks);
            var temperaturesForDaysOfYearGetters = new List <ColumnData <TemperatureForecastForYear> >
            {
                new ColumnData <TemperatureForecastForYear>("PLTFW_Day".Translate(), "PLTFW_DayToolTip".Translate(), tffy => $"{tffy.Day}"),
                new ColumnData <TemperatureForecastForYear>("PLTFW_Min".Translate(), "PLTFW_MinToolTip".Translate(),
                                                            tffy => $"{tffy.MinTemp:F2}"),
                new ColumnData <TemperatureForecastForYear>("PLTFW_Max".Translate(), "PLTFW_MaxToolTip".Translate(),
                                                            tffy => $"{tffy.MaxTemp:F2}"),
                new ColumnData <TemperatureForecastForYear>("PLTFW_OffSeason".Translate(), "PLTFW_OffSeasonToolTip".Translate(),
                                                            tffy => $"{tffy.OffsetFromSeasonCycle:F2}"),
                new ColumnData <TemperatureForecastForYear>("PLTFW_OffDRV".Translate(), "PLTFW_OffDRVToolTip".Translate(),
                                                            tffy => $"{tffy.OffsetFromDailyRandomVariation:F2}")
            };
            var tableViewTempForYear =
                new TableView <TemperatureForecastForYear>("PLTFW_ForecastForNextYear".Translate(), tempsForDaysOfYear,
                                                           temperaturesForDaysOfYearGetters);

            /*
             * Window and views
             */
            var temperatureWindow = new TableWindow(tileId, dateTicks, 0.33f);

            temperatureWindow.ClearTables();
            temperatureWindow.AddTable(tableViewTempForDay);
            temperatureWindow.AddTable(tableViewTempForTwelves);
            temperatureWindow.AddTable(tableViewTempForYear);

            Find.WindowStack.Add(temperatureWindow);
        }
        private void DrawTemperatureForecast()
        {
            DrawEntryHeader("PLMWT2T_TemperatureForecast".Translate(), backgroundColor: Color.magenta);

            var tileId = Find.WorldSelector.selectedTile;

            if (!Find.WorldSelector.AnyObjectOrTileSelected || tileId < 0)
            {
                var labelRect = ListingStandard.GetRect(DefaultElementHeight);
                Widgets.Label(labelRect, "PLMWT2T_TempPickTileOnWorldMap".Translate());
                _selectedTileIdForTemperatureForecast = -1;
                return;
            }

            ListingStandard.LabelDouble($"{"PLMWT2T_TempSelectedTile".Translate()}: ", tileId.ToString());
            _selectedTileIdForTemperatureForecast = tileId;

            ListingStandard.GapLine(DefaultGapLineHeight);

            /*
             * Day / Quadrum / Year selector
             */
            var backupAnchor = Text.Anchor;

            Text.Anchor = TextAnchor.MiddleLeft;

            // day
            var daySelector  = ListingStandard.GetRect(30f);
            var dayLabelRect = daySelector.LeftPart(0.70f);
            var dayFieldRect = daySelector.RightPart(0.30f);

            Widgets.Label(dayLabelRect, $"{"PLMWT2T_QuadrumDay".Translate()} [1, 15]: ");
            Widgets.TextFieldNumeric(dayFieldRect, ref _dayOfQuadrum, ref _dayOfQuadrumString, 1,
                                     GenDate.DaysPerQuadrum);

            ListingStandard.Gap(6f);

            // quadrum
            var quadrumRect       = ListingStandard.GetRect(30f);
            var quadrumButtonRect = quadrumRect.LeftHalf();

            if (Widgets.ButtonText(quadrumButtonRect, "PLMWT2T_SelectQuadrum".Translate()))
            {
                // get all possible enumeration values for hilliness
                var quadrumList = Enum.GetValues(typeof(Quadrum)).Cast <Quadrum>().ToList();

                var floatMenuOptions = new List <FloatMenuOption>();
                foreach (var quadrum in quadrumList)
                {
                    if (quadrum == Quadrum.Undefined)
                    {
                        continue;
                    }

                    var label = quadrum.Label();

                    var menuOption = new FloatMenuOption(label,
                                                         delegate { _quadrum = quadrum; });
                    floatMenuOptions.Add(menuOption);
                }

                var floatMenu = new FloatMenu(floatMenuOptions, "PLMWT2T_SelectQuadrum".Translate());
                Find.WindowStack.Add(floatMenu);
            }
            var quadrumLabelRect = quadrumRect.RightHalf();

            Widgets.Label(quadrumLabelRect, _quadrum.ToString());

            ListingStandard.Gap(6f);

            // year
            var yearSelector  = ListingStandard.GetRect(30f);
            var yearLabelRect = yearSelector.LeftPart(0.7f);
            var yearFieldRect = yearSelector.RightPart(0.3f);

            Widgets.Label(yearLabelRect, $"{"ClockYear".Translate()} [{GenDate.DefaultStartingYear}, {GenDate.DefaultStartingYear + 50}]: ");
            Widgets.TextFieldNumeric(yearFieldRect, ref _year, ref _yearString, GenDate.DefaultStartingYear,
                                     GenDate.DefaultStartingYear + 50);

            // translate day, quadrum and year to ticks
            _dateTicks = WorldData.DateToTicks(_dayOfQuadrum - 1, _quadrum, _year);

            // date display
            var dateNowRect       = ListingStandard.GetRect(30f);
            var labelDateLeftRect = dateNowRect.LeftPart(0.20f);

            Widgets.Label(labelDateLeftRect, $"{"ClockDate".Translate()}: ");
            var labelDateRightRect = dateNowRect.RightPart(0.60f);
            var dateString         = GenDate.DateReadoutStringAt(_dateTicks,
                                                                 Find.WorldGrid.LongLatOf(_selectedTileIdForTemperatureForecast));

            Widgets.Label(labelDateRightRect, dateString);

            Text.Anchor = backupAnchor;

            ListingStandard.GapLine(DefaultGapLineHeight);

            /*
             * Forecast
             */
            if (ListingStandard.ButtonText("PLMWT2T_ViewTemperatureForecast".Translate()))
            {
                ViewTemperatureForecast(_selectedTileIdForTemperatureForecast, _dateTicks);
            }
        }
Beispiel #7
0
        public static bool Prefix(Rect dateRect)
        {
            //--------------------------------------------
            if (GetClocks(Find.VisibleMap).Count() == 0)
            {
                return(true);                                         //use original method
            }
            if (clockAccuracy < 0)
            {
                Log.Warning("Found clock but clockAccuracy not set. Setting to Analog.");
                clockAccuracy = 0;
            }
            //

            //Vector2 location;
            //In event of transpiler just get local variable at end
            if (WorldRendererUtility.WorldRenderedNow && Find.WorldSelector.selectedTile >= 0)
            {
                location = Find.WorldGrid.LongLatOf(Find.WorldSelector.selectedTile);
            }
            else if (WorldRendererUtility.WorldRenderedNow && Find.WorldSelector.NumSelectedObjects > 0)
            {
                location = Find.WorldGrid.LongLatOf(Find.WorldSelector.FirstSelectedObject.Tile);
            }
            else
            {
                if (Find.VisibleMap == null)
                {
                    return(false);
                }
                location = Find.WorldGrid.LongLatOf(Find.VisibleMap.Tile);
            }
            index = GenDate.HourInteger(Find.TickManager.TicksAbs, location.x);
            int     num     = GenDate.DayOfTwelfth(Find.TickManager.TicksAbs, location.x);
            Season  season  = GenDate.Season(Find.TickManager.TicksAbs, location);
            Quadrum quadrum = GenDate.Quadrum(Find.TickManager.TicksAbs, location.x);
            int     num2    = GenDate.Year(Find.TickManager.TicksAbs, location.x);

            if (num != dateStringDay || season != dateStringSeason || quadrum != dateStringQuadrum || num2 != dateStringYear)
            {
                dateString        = GenDate.DateReadoutStringAt(Find.TickManager.TicksAbs, location);
                dateStringDay     = num;
                dateStringSeason  = season;
                dateStringQuadrum = quadrum;
                dateStringYear    = num2;
            }
            Text.Font = GameFont.Small;
            float num3 = Mathf.Max(Text.CalcSize(fastHourStrings[index]).x, Text.CalcSize(dateString).x + 7f);

            dateRect.xMin = dateRect.xMax - num3;
            if (Mouse.IsOver(dateRect))
            {
                Widgets.DrawHighlight(dateRect);
            }
            GUI.BeginGroup(dateRect);
            Text.Font   = GameFont.Small;
            Text.Anchor = TextAnchor.UpperRight;
            Rect rect = dateRect.AtZero();

            rect.xMax -= 7f;
            //-----------------------------------------------------
            hrtime = (index < 12) ? "amannotation".Translate(fastHourStrings[index].ToString() + currentMin) : "pmannotation".Translate(fastHourStrings[index].ToString() + currentMin);
            Widgets.Label(rect, hrtime);
            //
            //Widgets.Label(rect, fastHourStrings[index]); REPLACED
            rect.yMin += 26f;
            Widgets.Label(rect, dateString);
            Text.Anchor = TextAnchor.UpperLeft;
            GUI.EndGroup();
            //Remember - this delegate in itself is its own local method (m_XXX)
            //IL code: ldftn instance string RimWorld.DateReadout/'<DateOnGUI>c__AnonStorey449'::'<>m__64B'()
            TooltipHandler.TipRegion(dateRect, new TipSignal(delegate
            {
                StringBuilder stringBuilder = new StringBuilder();
                for (int i = 0; i < 4; i++)
                {
                    Quadrum quadrum2 = (Quadrum)i;
                    stringBuilder.AppendLine(quadrum2.Label() + " - " + quadrum2.GetSeason(location.y).LabelCap());
                }
                return("DateReadoutTip".Translate(new object[]
                {
                    GenDate.DaysPassed,
                    15,
                    season.LabelCap(),
                    15,
                    GenDate.Quadrum((long)GenTicks.TicksAbs, location.x).Label(),
                    stringBuilder.ToString()
                })
                       //-------------------------------------------
                       + (clockAccuracy > 0 ? "TicksAbsOnGUI".Translate(Find.TickManager.TicksGame) : string.Empty)
                       //
                       );
            }, 86423));
            return(false);
        }
Beispiel #8
0
 public override string ToString()
 {
     return(String.Format("{0} ancestors from {1} to {2} - fired={3}", this.NumVisitors,
                          GenDate.DateReadoutStringAt((int)this.StartTickAbs), GenDate.DateReadoutStringAt((int)this.EndTickAbs),
                          this.HasFired));
 }
        public virtual void UnlockCard(bool debugTools = false)
        {
            if (!unlocked)
            {
                unlocked = true;

                var vector = Find.WorldGrid.LongLatOf(Find.CurrentMap.Tile);
                dateUnlocked = (Prefs.DevMode || debugTools) ? "UnlockedDevMode".Translate().ToString() : GenDate.DateReadoutStringAt(Find.TickManager.TicksAbs, vector);

                Current.Game.GetComponent <AchievementPointManager>().AddPoints(def.points);
                DefDatabase <SoundDef> .GetNamed("LetterArrive_Good").PlayOneShotOnCamera();

                DebugWriter.Log($"Unlocking: {GetUniqueLoadID()} Card: {def.label}");
                if (debugTools)
                {
                    DebugWriter.Log($"[Unlocked with DebugTools]");
                }
                Current.Game.GetComponent <AchievementPointManager>().DisplayCardWindow(this);
            }
        }
        public static bool Prefix(
            Rect dateRect,
            ref List <string> ___seasonsCached,
            ref int ___dateStringDay,
            ref Season ___dateStringSeason,
            ref Quadrum ___dateStringQuadrum,
            ref int ___dateStringYear,
            ref string ___dateString
            )
        {
            Vector2 vector2;

            if (WorldRendererUtility.WorldRenderedNow && Find.WorldSelector.selectedTile >= 0)
            {
                vector2 = Find.WorldGrid.LongLatOf(Find.WorldSelector.selectedTile);
            }
            else if (WorldRendererUtility.WorldRenderedNow && Find.WorldSelector.NumSelectedObjects > 0)
            {
                vector2 = Find.WorldGrid.LongLatOf(Find.WorldSelector.FirstSelectedObject.Tile);
            }
            else
            {
                if (Find.CurrentMap == null)
                {
                    return(false);
                }
                vector2 = Find.WorldGrid.LongLatOf(Find.CurrentMap.Tile);
            }

            var num1     = GenDate.DayOfTwelfth(Find.TickManager.TicksAbs, vector2.x);
            var season   = GenDate.Season(Find.TickManager.TicksAbs, vector2);
            var quadrum1 = GenDate.Quadrum(Find.TickManager.TicksAbs, vector2.x);
            var num2     = GenDate.Year(Find.TickManager.TicksAbs, vector2.x);
            var str      = true ? ___seasonsCached[(int)season] : "";

            if (num1 != ___dateStringDay || season != ___dateStringSeason || quadrum1 != ___dateStringQuadrum || num2 != ___dateStringYear)
            {
                ___dateString        = GenDate.DateReadoutStringAt(Find.TickManager.TicksAbs, vector2);
                ___dateStringDay     = num1;
                ___dateStringSeason  = season;
                ___dateStringQuadrum = quadrum1;
                ___dateStringYear    = num2;
            }

            var userTime = "";

            if (!BetterTimeFormatMod.UpdateTime)
            {
                userTime = BetterTimeFormatMod.settings.timeFormat;
                var dayPercent = GenLocalDate.DayPercent(Find.CurrentMap);

                if (BetterTimeFormatMod.UpdateHours)
                {
                    var hours = Math.Floor(dayPercent * 24);
                    if (BetterTimeFormatMod.settings.twelveHourFormat)
                    {
                        hours = dayPercent < 0.6 ? hours : hours - 12;
                    }

                    userTime = userTime.ReplaceFirst("HH", $"{hours,0:00}");
                    userTime = userTime.ReplaceFirst("H", $"{hours,0}");
                }

                if (BetterTimeFormatMod.UpdateMinutes)
                {
                    var minutes = Math.Floor(dayPercent * 24 % 1 * 60);
                    userTime = userTime.ReplaceFirst("MM", $"{minutes,0:00}");
                    userTime = userTime.ReplaceFirst("M", $"{minutes,0:0}");
                }

                if (BetterTimeFormatMod.UpdateSeconds)
                {
                    var seconds = Math.Floor(dayPercent * 24 % 1 * 60 % 1 * 60);
                    userTime = userTime.ReplaceFirst("SS", $"{seconds,0:00}");
                    userTime = userTime.ReplaceFirst("S", $"{seconds,0:0}");
                }

                if (BetterTimeFormatMod.settings.twelveHourFormat)
                {
                    var notation = dayPercent < 0.5 ? BetterTimeFormatMod.settings.amString : BetterTimeFormatMod.settings.pmString;
                    userTime = userTime.ReplaceFirst("N", notation);
                }
            }

            Text.Font = GameFont.Small;
            var num3 =
                Mathf.Max(Mathf.Max(Text.CalcSize(userTime).x, Text.CalcSize(___dateString).x), Text.CalcSize(str).x) + 7f;

            dateRect.xMin = dateRect.xMax - num3;
            if (Mouse.IsOver(dateRect))
            {
                Widgets.DrawHighlight(dateRect);
            }
            GUI.BeginGroup(dateRect);
            Text.Font   = GameFont.Small;
            Text.Anchor = TextAnchor.UpperRight;
            var rect = dateRect.AtZero();

            rect.xMax -= 7f;
            Widgets.Label(rect, userTime);
            rect.yMin += 26f;
            Widgets.Label(rect, ___dateString);
            rect.yMin += 26f;
            if (!str.NullOrEmpty())
            {
                Widgets.Label(rect, str);
            }
            Text.Anchor = TextAnchor.UpperLeft;
            GUI.EndGroup();
            if (!Mouse.IsOver(dateRect))
            {
                return(false);
            }
            var stringBuilder = new StringBuilder();

            for (var index2 = 0; index2 < 4; ++index2)
            {
                var quadrum2 = (Quadrum)index2;
                stringBuilder.AppendLine(quadrum2.Label() + " - " + quadrum2.GetSeason(vector2.y).LabelCap());
            }

            var taggedString = "DateReadoutTip".Translate(GenDate.DaysPassed, 15, (NamedArgument)season.LabelCap(), 15,
                                                          (NamedArgument)GenDate.Quadrum(GenTicks.TicksAbs, vector2.x).Label(), (NamedArgument)stringBuilder.ToString());

            TooltipHandler.TipRegion(dateRect, new TipSignal(taggedString, 86423));

            return(false);
        }