public TemperatureForecastForDay(int tileId, int ticks, int hour) { TileId = tileId; Ticks = ticks; Hour = hour; var outdoorTemperature = Find.World.tileTemperatures.OutdoorTemperatureAt(tileId, Ticks); OutdoorTemperature = GenTemperature.CelsiusTo(outdoorTemperature, Prefs.TemperatureMode); var offsetFromSunCycle = GenTemperature.OffsetFromSunCycle(Ticks, TileId); // this is a temperature delta, so it's not a straight Celsius to another temperature unit. We use an extension method. OffsetFromSunCycle = TemperatureDisplayMode.Celsius.TempDelta(offsetFromSunCycle, Prefs.TemperatureMode); var offsetFromDailyRandomVariation = Find.World.tileTemperatures.OffsetFromDailyRandomVariation(TileId, Ticks); OffsetFromDailyRandomVariation = TemperatureDisplayMode.Celsius.TempDelta(offsetFromDailyRandomVariation, Prefs.TemperatureMode); var offsetFromSeasonCycle = GenTemperature.OffsetFromSeasonCycle(Ticks, tileId); OffsetFromSeasonCycle = TemperatureDisplayMode.Celsius.TempDelta(offsetFromSeasonCycle, Prefs.TemperatureMode); var dailyRandomVariation = Find.WorldGrid[TileId].temperature - (OffsetFromSeasonCycle + OffsetFromDailyRandomVariation + OffsetFromSunCycle); DailyRandomVariation = TemperatureDisplayMode.Celsius.TempDelta(dailyRandomVariation, Prefs.TemperatureMode); }
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 TemperatureForecastForTwelfth(int tileId, Twelfth twelfth) { Latitude = Find.WorldGrid.LongLatOf(tileId).y; Twelfth = twelfth; var averageTemperatureForTwelfth = Find.World.tileTemperatures.AverageTemperatureForTwelfth(tileId, twelfth); AverageTemperatureForTwelfth = GenTemperature.CelsiusTo(averageTemperatureForTwelfth, Prefs.TemperatureMode); }
private void DrawTemperatureSelection() { DrawEntryHeader("Temperature", backgroundColor: ColorLibrary.RoyalPurple); // min and max possible temperatures, in C/F/K (depending on user preferences). // note that TemperatureTuning temps are in Celsius. var tempMinUnit = GenTemperature.CelsiusTo(TemperatureTuning.MinimumTemperature, Prefs.TemperatureMode); var tempMaxUnit = GenTemperature.CelsiusTo(TemperatureTuning.MaximumTemperature, Prefs.TemperatureMode); var averageTemperature = _gameData.GodModeData.AverageTemperature; _chosenAverageTemperatureString = averageTemperature.ToString("F1", CultureInfo.InvariantCulture); var temperatureRectSpace = ListingStandard.GetRect(DefaultElementHeight * 1.25f); Widgets.Label(temperatureRectSpace.LeftPart(0.8f), $"{"AvgTemp".Translate()} (°{Prefs.TemperatureMode.ToStringHuman()})\n[{tempMinUnit}, {tempMaxUnit}]"); Widgets.TextFieldNumeric(temperatureRectSpace.RightPart(0.2f), ref averageTemperature, ref _chosenAverageTemperatureString, tempMinUnit, tempMaxUnit); _gameData.GodModeData.AverageTemperature = averageTemperature; }
private void DrawTemperaturesSelection() { // min and max possible temperatures, in C/F/K (depending on user prefs). // note that TemperatureTuning temps are in Celsius. var tempMinUnit = GenTemperature.CelsiusTo(TemperatureTuning.MinimumTemperature, Prefs.TemperatureMode); var tempMaxUnit = GenTemperature.CelsiusTo(TemperatureTuning.MaximumTemperature, Prefs.TemperatureMode); DrawEntryHeader($"{"Temperature".Translate()} (°{Prefs.TemperatureMode.ToStringHuman()}) [{tempMinUnit}, {tempMaxUnit}]", backgroundColor: ColorFromFilterType(typeof(TileFilterAverageTemperatures))); DrawUsableMinMaxNumericField(_gameData.UserData.AverageTemperature, "AvgTemp".Translate(), tempMinUnit, tempMaxUnit); ListingStandard.GapLine(); DrawUsableMinMaxNumericField(_gameData.UserData.MinTemperature, "Minimum Temperature", //TODO: translate tempMinUnit, tempMaxUnit); ListingStandard.GapLine(); DrawUsableMinMaxNumericField(_gameData.UserData.MaxTemperature, "Maximum Temperature", // TODO: translate tempMinUnit, tempMaxUnit); }
public TemperatureForecastForYear(int tileId, int ticks, int day) { Day = day; /* * Get min & max temperatures for the day */ var tempsForHourOfDay = new List <float>(GenDate.HoursPerDay); for (var hour = 0; hour < GenDate.HoursPerDay; hour++) { var hourTicks = ticks + hour * GenDate.TicksPerHour; var outdoorTemperatureinCelsius = Find.World.tileTemperatures.OutdoorTemperatureAt(tileId, hourTicks); var outdoorTemperature = GenTemperature.CelsiusTo(outdoorTemperatureinCelsius, Prefs.TemperatureMode); tempsForHourOfDay.Add(outdoorTemperature); } // get min & max from list of temperatures for the day MinTemp = tempsForHourOfDay.Min(); MaxTemp = tempsForHourOfDay.Max(); // get number of ticks for the maximum temperature var ticksForMaxTemp = ticks + tempsForHourOfDay.IndexOf(MaxTemp) * GenDate.TicksPerHour; var offsetFromSeasonCycle = GenTemperature.OffsetFromSeasonCycle(ticksForMaxTemp, tileId); OffsetFromSeasonCycle = TemperatureDisplayMode.Celsius.TempDelta(offsetFromSeasonCycle, Prefs.TemperatureMode); var offsetFromDailyRandomVariation = Find.World.tileTemperatures.OffsetFromDailyRandomVariation(tileId, ticksForMaxTemp); OffsetFromDailyRandomVariation = TemperatureDisplayMode.Celsius.TempDelta(offsetFromDailyRandomVariation, Prefs.TemperatureMode); }
public override void DefsLoaded() { _opacity = Settings.GetHandle( "opacity", "FALCHM.OverlayOpacity".Translate(), "FALCHM.OverlayOpacityDesc".Translate(), 30, Validators.IntRangeValidator(1, 100)); _opacity.OnValueChanged = val => { _heatMap?.Reset(); }; _updateDelay = Settings.GetHandle("updateDelay", "FALCHM.UpdateDelay".Translate(), "FALCHM.UpdateDelayDesc".Translate(), 100, Validators.IntRangeValidator(1, 9999)); _showOutdoorThermometer = Settings.GetHandle( "showOutdoorThermometer", "FALCHM.ShowOutDoorThermometer".Translate(), "FALCHM.ShowOutDoorThermometerDesc".Translate(), true); _outdoorThermometerOpacity = Settings.GetHandle( "outdoorThermometerOpacity", "FALCHM.ThermometerOpacity".Translate(), "FALCHM.ThermometerOpacityDesc".Translate(), 30, Validators.IntRangeValidator(1, 100)); _outdoorThermometerOpacity.OnValueChanged = val => { _temperatureTextureCache.Clear(); }; _showTemperatureOverRooms = Settings.GetHandle( "showTemperatureOverRooms", "FALCHM.ShowTemperatureOverRooms".Translate(), "FALCHM.ShowTemperatureOverRoomsDesc".Translate(), true); _useCustomRange = Settings.GetHandle( "useCustomeRange", "FALCHM.UseCustomeRange".Translate(), "FALCHM.UseCustomeRangeDesc".Translate(), false); _useCustomRange.OnValueChanged = val => { ResetAll(); }; _customRangeMin = Settings.GetHandle("customRangeMin", "Unused", "Unused", 0); _customRangeMax = Settings.GetHandle("customRangeMax", "Unused", "Unused", 40); _customRangeMin.VisibilityPredicate = () => false; _customRangeMax.VisibilityPredicate = () => false; var customRangeValidator = Validators.IntRangeValidator( (int)GenTemperature.CelsiusTo(-100, Prefs.TemperatureMode), (int)GenTemperature.CelsiusTo(100, Prefs.TemperatureMode)); var customRangeMin = Settings.GetHandle( "customRangeMinPlaceholder", "FALCHM.CustomRangeMin".Translate(), $"{"FALCHM.CustomRangeMinDesc".Translate()} ({Prefs.TemperatureMode.ToStringHuman()})", (int)GenTemperature.CelsiusTo(_customRangeMin, Prefs.TemperatureMode), customRangeValidator); customRangeMin.Unsaved = true; customRangeMin.VisibilityPredicate = () => _useCustomRange; var customRangeMax = Settings.GetHandle( "customRangeMaxPlaceholder", "FALCHM.CustomRangeMax".Translate(), $"{"FALCHM.CustomRangeMaxDesc".Translate()} ({Prefs.TemperatureMode.ToStringHuman()})", (int)GenTemperature.CelsiusTo(_customRangeMax, Prefs.TemperatureMode), customRangeValidator); customRangeMax.Unsaved = true; customRangeMax.VisibilityPredicate = () => _useCustomRange; customRangeMin.OnValueChanged = val => { if (customRangeMax <= customRangeMin) { customRangeMax.Value = customRangeMin + 1; } _customRangeMin.Value = ConvertToCelcius(customRangeMin); ResetAll(); }; customRangeMax.OnValueChanged = val => { if (customRangeMin >= customRangeMax) { customRangeMin.Value = customRangeMax - 1; } _customRangeMax.Value = ConvertToCelcius(customRangeMax); ResetAll(); }; }
public override void Filter(List <int> inputList) { base.Filter(inputList); if (!IsFilterActive) { return; } // e.g UserData.AverageTemperature, UserData.SummerTemperature or UserData.WinterTemperature var temperatureItem = (UsableMinMaxNumericItem <float>)UserData.GetType().GetProperty(AttachedProperty) ?.GetValue(UserData, null); if (temperatureItem == null) { PrepareLanding.Instance.TileFilter.FilterInfoLogger.AppendErrorMessage( $"{"PLFILT_TemperatureIsNull".Translate()} TileFilterTemperatures.Filter.", sendToLog: true); return; } if (!temperatureItem.IsCorrectRange) { var message = $"{SubjectThingDef}: {"PLFILT_VerifyMinIsLessOrEqualMax".Translate()}: {temperatureItem.Min} <= {temperatureItem.Max})."; PrepareLanding.Instance.TileFilter.FilterInfoLogger.AppendErrorMessage(message); return; } Func <int, float> temperatureFunc; switch (AttachedProperty) { case nameof(UserData.AverageTemperature): temperatureFunc = AverageTemperatureForTile; break; case nameof(UserData.MinTemperature): temperatureFunc = MinTemperatureForTile; break; case nameof(UserData.MaxTemperature): temperatureFunc = MaxTemperatureAtTile; break; default: Log.Error($"[PrepareLanding] Unknown attached property in TileFilterTemperatures.Filter(): {AttachedProperty}"); return; } foreach (var tileId in inputList) { var tileTempInC = temperatureFunc(tileId); var tileTemp = GenTemperature.CelsiusTo(tileTempInC, Prefs.TemperatureMode); if (temperatureItem.InRange(tileTemp)) { _filteredTiles.Add(tileId); } } }
private static string TemperatureString() { IntVec3 intVec = UI.MouseCell(); IntVec3 c = intVec; Room room = intVec.GetRoom(Find.CurrentMap, RegionType.Set_All); if (room == null) { for (int i = 0; i < 9; i++) { IntVec3 intVec2 = intVec + GenAdj.AdjacentCellsAndInside[i]; if (intVec2.InBounds(Find.CurrentMap)) { Room room2 = intVec2.GetRoom(Find.CurrentMap, RegionType.Set_All); if (room2 != null && ((!room2.PsychologicallyOutdoors && !room2.UsesOutdoorTemperature) || (!room2.PsychologicallyOutdoors && (room == null || room.PsychologicallyOutdoors)) || (room2.PsychologicallyOutdoors && room == null))) { c = intVec2; room = room2; } } } } if (room == null && intVec.InBounds(Find.CurrentMap)) { Building edifice = intVec.GetEdifice(Find.CurrentMap); if (edifice != null) { foreach (IntVec3 item in edifice.OccupiedRect().ExpandedBy(1).ClipInsideMap(Find.CurrentMap)) { room = item.GetRoom(Find.CurrentMap, RegionType.Set_All); if (room != null && !room.PsychologicallyOutdoors) { c = item; break; } } } } string text; if (c.InBounds(Find.CurrentMap) && !c.Fogged(Find.CurrentMap) && room != null && !room.PsychologicallyOutdoors) { if (room.OpenRoofCount == 0) { text = "Indoors".Translate(); } else { if (indoorsUnroofedStringCachedRoofCount != room.OpenRoofCount) { indoorsUnroofedStringCached = "IndoorsUnroofed".Translate() + " (" + room.OpenRoofCount.ToStringCached() + ")"; indoorsUnroofedStringCachedRoofCount = room.OpenRoofCount; } text = indoorsUnroofedStringCached; } } else { text = "Outdoors".Translate(); } float num = (room == null || c.Fogged(Find.CurrentMap)) ? Find.CurrentMap.mapTemperature.OutdoorTemp : room.Temperature; int num2 = Mathf.RoundToInt(GenTemperature.CelsiusTo(cachedTemperatureStringForTemperature, Prefs.TemperatureMode)); int num3 = Mathf.RoundToInt(GenTemperature.CelsiusTo(num, Prefs.TemperatureMode)); if (cachedTemperatureStringForLabel != text || num2 != num3) { cachedTemperatureStringForLabel = text; cachedTemperatureStringForTemperature = num; cachedTemperatureString = text + " " + num.ToStringTemperature("F0"); } return(cachedTemperatureString); }
private void DrawWorldRecord() { DrawEntryHeader("PLMWINF_WorldRecords".Translate(), backgroundColor: Color.yellow); if (_gameData.WorldData.WorldCharacteristics == null || _gameData.WorldData.WorldCharacteristics.Count == 0) { //Log.Error("[PrepareLanding] TabInfo.BuildWorldRecords: No Info"); return; } // default line height const float gapLineHeight = 4f; // add a gap before the scroll view ListingStandard.Gap(gapLineHeight); /* * Calculate heights */ // height of the scrollable outer Rect (visible portion of the scroll view, not the 'virtual' one) var maxScrollViewOuterHeight = InRect.height - ListingStandard.CurHeight - DefaultElementHeight; // height of the 'virtual' portion of the scroll view var numElements = _gameData.WorldData.WorldCharacteristics.Count * 3; // 1 label + 2 elements (highest + lowest) = 3 var scrollableViewHeight = (numElements * DefaultElementHeight) + (_gameData.WorldData.WorldCharacteristics.Count * gapLineHeight); /* * Scroll view */ var innerLs = ListingStandard.BeginScrollView(maxScrollViewOuterHeight, scrollableViewHeight, ref _scrollPosWorldRecords, 16f); var selectedTileIndex = 0; foreach (var characteristicData in _gameData.WorldData.WorldCharacteristics) { var characteristicName = characteristicData.CharacteristicName; innerLs.Label(RichText.Bold(RichText.Color($"{characteristicName}:", Color.cyan))); // there might be no characteristics if (characteristicData.WorldTilesCharacteristics.Count == 0) { innerLs.Label("No Info [DisableWorldData enabled]"); continue; } /* * lowest */ var lowestCharacteristicKvp = characteristicData.WorldTilesCharacteristics.First(); // we need to follow user preference for temperature. var value = characteristicData.Characteristic == MostLeastCharacteristic.Temperature ? GenTemperature.CelsiusTo(lowestCharacteristicKvp.Value, Prefs.TemperatureMode) : lowestCharacteristicKvp.Value; var vectorLongLat = Find.WorldGrid.LongLatOf(lowestCharacteristicKvp.Key); var textLowest = $"{"PLMWINF_WorldLowest".Translate()} {characteristicName}: {value:F1} {characteristicData.CharacteristicMeasureUnit} [{lowestCharacteristicKvp.Key}; {vectorLongLat.y.ToStringLatitude()} - {vectorLongLat.x.ToStringLongitude()}]"; var labelRect = innerLs.GetRect(DefaultElementHeight); var selected = selectedTileIndex == _worldRecordSelectedTileIndex; if (Core.Gui.Widgets.LabelSelectable(labelRect, textLowest, ref selected, TextAnchor.MiddleLeft)) { // go to the location of the selected tile _worldRecordSelectedTileIndex = selectedTileIndex; Find.WorldInterface.SelectedTile = lowestCharacteristicKvp.Key; Find.WorldCameraDriver.JumpTo(Find.WorldGrid.GetTileCenter(Find.WorldInterface.SelectedTile)); } selectedTileIndex++; /* * highest */ var highestCharacteristicKvp = characteristicData.WorldTilesCharacteristics.Last(); // we need to follow user preference for temperature. value = characteristicData.Characteristic == MostLeastCharacteristic.Temperature ? GenTemperature.CelsiusTo(highestCharacteristicKvp.Value, Prefs.TemperatureMode) : highestCharacteristicKvp.Value; vectorLongLat = Find.WorldGrid.LongLatOf(highestCharacteristicKvp.Key); var textHighest = $"{"PLMWINF_WorldHighest".Translate()} {characteristicName}: {value:F1} {characteristicData.CharacteristicMeasureUnit} [{highestCharacteristicKvp.Key}; {vectorLongLat.y.ToStringLatitude()} - {vectorLongLat.x.ToStringLongitude()}]"; labelRect = innerLs.GetRect(DefaultElementHeight); selected = selectedTileIndex == _worldRecordSelectedTileIndex; if (Core.Gui.Widgets.LabelSelectable(labelRect, textHighest, ref selected, TextAnchor.MiddleLeft)) { // go to the location of the selected tile _worldRecordSelectedTileIndex = selectedTileIndex; Find.WorldInterface.SelectedTile = highestCharacteristicKvp.Key; Find.WorldCameraDriver.JumpTo(Find.WorldGrid.GetTileCenter(Find.WorldInterface.SelectedTile)); } selectedTileIndex++; // add a thin line between each label innerLs.GapLine(gapLineHeight); } ListingStandard.EndScrollView(innerLs); }
public override float DoWindowContents(Rect rect) { #region Save State var originalFont = Text.Font; #endregion #region MCM Description var descriptionLabel = "MountainTempMCMDescription".Translate(); var descriptionHeight = Text.CalcHeight(descriptionLabel, rect.width); var descriptionRect = new Rect( 0, 0, rect.width, descriptionHeight); DoLabel( descriptionRect, descriptionLabel ); #endregion #region Target Label var targetRect = new Rect( 0, descriptionRect.y + descriptionRect.height + entrySize, rect.width, entrySize); DoLabel( targetRect, "MountainTempMCMTarget".Translate() ); #endregion #region Fixed Temp Radio var radioBool = Config.TargetMode == TemperatureMode.Fixed; var fixedRect = new Rect( 0, targetRect.y + targetRect.height + innerPadding, rect.width, entrySize); DoRadio( fixedRect, ref radioBool, "MountainTempMCMFixed"); if (radioBool) { Config.TargetMode = TemperatureMode.Fixed; } #endregion #region Fixed Temp Slider var sliderMin = GenTemperature.CelsiusTo(-50f, Prefs.TemperatureMode); var sliderMax = GenTemperature.CelsiusTo(50f, Prefs.TemperatureMode); var sliderValue = GenTemperature.CelsiusTo(Config.FixedTarget, Prefs.TemperatureMode); var tempRect = new Rect( 0, fixedRect.y + fixedRect.height + innerPadding, rect.width, entrySize * 2); DoSlider( tempRect, ref sliderValue, "MountainTempMCMSlider", sliderMin, sliderMax ); Config.FixedTarget = GenTemperature_Extensions.CelsiusFrom(sliderValue, Prefs.TemperatureMode); #endregion #region Seasonal Temp Radio radioBool = Config.TargetMode == TemperatureMode.Seasonal; var tempStr = Game.Mode == GameMode.MapPlaying ? string.Format("({0})", GenText.ToStringTemperature(MountainTemp.SeasonalAverage)) : ""; var seasonalRect = new Rect( 0, tempRect.y + tempRect.height + entrySize, rect.width, entrySize); DoRadio( seasonalRect, ref radioBool, "MountainTempMCMSeasonal", tempStr); if (radioBool) { Config.TargetMode = TemperatureMode.Seasonal; } #endregion #region Annual Temp Radio radioBool = Config.TargetMode == TemperatureMode.Annual; tempStr = Game.Mode == GameMode.MapPlaying ? string.Format("({0})", GenText.ToStringTemperature(MountainTemp.AnnualAverage)) : ""; var annualRect = new Rect( 0, seasonalRect.y + seasonalRect.height + innerPadding, rect.width, entrySize); DoRadio( annualRect, ref radioBool, "MountainTempMCMAnnual", tempStr); if (radioBool) { Config.TargetMode = TemperatureMode.Annual; } #endregion #region Restore State Text.Font = originalFont; #endregion return(annualRect.y + annualRect.height + innerPadding); }