protected float DrawEntryHeader(string entryLabel, bool useStartingGap = true, bool useFollowingGap = false, Color?backgroundColor = null, float colorAlpha = 0.2f) { if (useStartingGap) { ListingStandard.Gap(); } var textHeight = Text.CalcHeight(entryLabel, ListingStandard.ColumnWidth); var r = ListingStandard.GetRect(0f); r.height = textHeight; var bgColor = backgroundColor.GetValueOrDefault(DefaultMenuSectionBgFillColor); if (backgroundColor != null) { bgColor.a = colorAlpha; } Verse.Widgets.DrawBoxSolid(r, bgColor); ListingStandard.Label($"{entryLabel}:", DefaultElementHeight); ListingStandard.GapLine(DefaultGapLineHeight); if (useFollowingGap) { ListingStandard.Gap(); } return(ListingStandard.CurHeight); }
private void DrawOverLaySelection() { DrawEntryHeader("Overlay Selection", backgroundColor: ColorLibrary.BurntOrange); var boxRect = ListingStandard.GetRect(DefaultElementHeight); // draw the map colors GUI.DrawTexture(boxRect, _gameData.WorldData.TemperatureData.TemperatureGradientTexure); ListingStandard.GapLine(DefaultGapLineHeight); var buttonsRect = ListingStandard.GetRect(DefaultElementHeight); var drawOverlayButtonRect = buttonsRect.LeftHalf(); var clearOverlayButtonRect = buttonsRect.RightHalf(); if (Widgets.ButtonText(drawOverlayButtonRect, "Draw Overlay")) { _gameData.WorldData.TemperatureData.AllowDrawOverlay = true; } if (Widgets.ButtonText(clearOverlayButtonRect, "Clear Overlay")) { _gameData.WorldData.TemperatureData.AllowDrawOverlay = false; } #if DEBUG if (ListingStandard.ButtonText("DebugLog")) { _gameData.WorldData.TemperatureData.DebugLog(); } #endif }
protected void DrawSaveFileName(Rect inRect) { DrawEntryHeader("Preset Files: Save mode", backgroundColor: Color.red); var fileNameRect = ListingStandard.GetRect(DefaultElementHeight); var fileNameLabelRect = fileNameRect.LeftPart(0.2f); Widgets.Label(fileNameLabelRect, "FileName:"); var fileNameTextRect = fileNameRect.RightPart(0.8f); if (string.IsNullOrEmpty(_selectedFileName)) { _selectedFileName = _userData.PresetManager.NextPresetFileName; } _selectedFileName = Widgets.TextField(fileNameTextRect, _selectedFileName); ListingStandard.GapLine(DefaultGapLineHeight); ListingStandard.CheckboxLabeled("Save Options", ref _saveOptions, "Check to also save options alongside filters."); ListingStandard.GapLine(DefaultGapLineHeight); DrawEntryHeader($"Author: [optional; {MaxAuthorNameLength} chars max]"); _presetAuthorSave = ListingStandard.TextEntry(_presetAuthorSave); if (_presetAuthorSave.Length >= MaxAuthorNameLength) { _presetAuthorSave = _presetAuthorSave.Substring(0, MaxAuthorNameLength); } ListingStandard.GapLine(DefaultGapLineHeight); DrawEntryHeader($"Description: [optional; {MaxDescriptionLength} chars max]"); var descriptionRect = ListingStandard.GetRect(80f); _presetDescriptionSave = Widgets.TextAreaScrollable(descriptionRect, _presetDescriptionSave, ref _scrollPosPresetDescription); if (_presetDescriptionSave.Length >= MaxDescriptionLength) { _presetDescriptionSave = _presetDescriptionSave.Substring(0, MaxDescriptionLength); } }
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); }
private void DrawMostLeastCharacteristicSelection() { DrawEntryHeader("PLMWT2T_MostLeastCharacteristics".Translate(), backgroundColor: ColorFromFilterType(typeof(TileFilterMostLeastCharacteristic))); /* * Select Characteristic */ var selectCharacteristic = "PLMWT2T_MostLeastSelectCharacteristic".Translate(); if (ListingStandard.ButtonText(selectCharacteristic)) { var floatMenuOptions = new List <FloatMenuOption>(); foreach (var characteristic in Enum.GetValues(typeof(MostLeastCharacteristic)).Cast <MostLeastCharacteristic>()) { var menuOption = new FloatMenuOption(characteristic.ToString(), delegate { _gameData.UserData.MostLeastItem.Characteristic = characteristic; }); floatMenuOptions.Add(menuOption); } var floatMenu = new FloatMenu(floatMenuOptions, selectCharacteristic); Find.WindowStack.Add(floatMenu); } /* * Number of tiles to select. */ ListingStandard.GapLine(DefaultGapLineHeight); var tilesNumberRect = ListingStandard.GetRect(DefaultElementHeight); var leftRect = tilesNumberRect.LeftPart(0.80f); var rightRect = tilesNumberRect.RightPart(0.20f); Widgets.Label(leftRect, $"{"PLMWT2T_MostLeastNumberOfTiles".Translate()} [1, 10000]:"); _numberOfTilesForCharacteristic = _gameData.UserData.MostLeastItem.NumberOfItems; Widgets.TextFieldNumeric(rightRect, ref _numberOfTilesForCharacteristic, ref _numberOfTilesForCharacteristicString, 1, 10000); _gameData.UserData.MostLeastItem.NumberOfItems = _numberOfTilesForCharacteristic; /* * Select Characteristic Type (most / least) */ var selectCharacteristicType = "PLMWT2T_MostLeastSelectCharacteristicType".Translate(); if (ListingStandard.ButtonText(selectCharacteristicType)) { var floatMenuOptions = new List <FloatMenuOption>(); foreach (var characteristicType in Enum.GetValues(typeof(MostLeastType)).Cast <MostLeastType>()) { var menuOption = new FloatMenuOption(characteristicType.ToString(), delegate { _gameData.UserData.MostLeastItem.CharacteristicType = characteristicType; }); floatMenuOptions.Add(menuOption); } var floatMenu = new FloatMenu(floatMenuOptions, selectCharacteristicType); Find.WindowStack.Add(floatMenu); } /* * Result label */ string text; if (_gameData.UserData.MostLeastItem.Characteristic == MostLeastCharacteristic.None) { text = string.Format("PLMWT2T_MostLeastPressButtonFirst".Translate(), selectCharacteristic); } else if (_gameData.UserData.MostLeastItem.CharacteristicType == MostLeastType.None) { text = string.Format("PLMWT2T_MostLeastNowUseButton".Translate(), selectCharacteristicType); } else { var highestLowest = _gameData.UserData.MostLeastItem.CharacteristicType == MostLeastType.Most ? "PLMWT2T_MostLeastHighest".Translate() : "PLMWT2T_MostLeastLowest".Translate(); var tileString = _gameData.UserData.MostLeastItem.NumberOfItems > 1 ? "PLMW_Tiles".Translate() : "PLMW_Tile".Translate(); text = string.Format("PLMWT2T_MostLeastSelectingTiles".Translate(), _gameData.UserData.MostLeastItem.NumberOfItems, tileString, highestLowest, _gameData.UserData.MostLeastItem.Characteristic); } ListingStandard.Label($"{"PLMWT2T_MostLeastResult".Translate()}: {text}", DefaultElementHeight * 2); }
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); } }
private void DrawStoneTypesSelection() { DrawEntryHeader("PLMWTT_StoneTypes".Translate(), backgroundColor: ColorFromFilterType(typeof(TileFilterStones))); var selectedStoneDefs = _gameData.UserData.SelectedStoneDefs; /* * Buttons */ const int numButtons = 2; var buttonsRect = ListingStandard.GetRect(DefaultElementHeight).SplitRectWidthEvenly(numButtons); if (buttonsRect.Count != numButtons) { Log.ErrorOnce($"[PrepareLanding] DrawStoneTypesSelection: couldn't get the right number of buttons: {numButtons}", 0x123acafe); return; } // Reset button: reset all entries to Partial state if (Verse.Widgets.ButtonText(buttonsRect[0], "PLMW_Reset".Translate())) { selectedStoneDefs.Reset(_gameData.DefData.StoneDefs, nameof(_gameData.UserData.SelectedStoneDefs)); _gameData.UserData.StoneTypesNumberOnly = false; } // order / no order button TooltipHandler.TipRegion(buttonsRect[1], "PLMWTT_StoneOrderTooltip".Translate()); var orderText = selectedStoneDefs.OrderedFiltering ? "PLMWTT_Ordered".Translate() : "PLMWTT_NoOrder".Translate(); var savedColor = GUI.color; GUI.color = selectedStoneDefs.OrderedFiltering ? Color.green : Color.red; if (Verse.Widgets.ButtonText(buttonsRect[1], $"{"PLMWTT_Filter".Translate()}: {orderText}")) { selectedStoneDefs.OrderedFiltering = !selectedStoneDefs.OrderedFiltering; } GUI.color = savedColor; // re-orderable list group var reorderableGroup = ReorderableWidget.NewGroup(delegate(int from, int to) { //TODO find a way to raise an event to tell an observer that the list order has changed selectedStoneDefs.ReorderElements(from, to); SoundDefOf.TickHigh.PlayOneShotOnCamera(); }); var maxNumStones = (InRect.height - ListingStandard.CurHeight - DefaultGapLineHeight - DefaultElementHeight - 15f) / DefaultElementHeight; var maxHeight = maxNumStones * DefaultElementHeight; var height = Mathf.Min(selectedStoneDefs.Count * DefaultElementHeight, maxHeight); if (!_gameData.UserData.StoneTypesNumberOnly) { // stone types, standard selection var inLs = ListingStandard.BeginScrollView(height, selectedStoneDefs.Count * DefaultElementHeight, ref _scrollPosStoneSelection, DefaultScrollableViewShrinkWidth); foreach (var currentOrderedStoneDef in selectedStoneDefs.OrderedItems) { if (!selectedStoneDefs.TryGetValue(currentOrderedStoneDef, out var threeStateItem)) { Log.ErrorOnce("A stoneDef wasn't found in selectedStoneDefs", 0x1cafe9); continue; } var flag = currentOrderedStoneDef == _selectedStoneDef; // save temporary state as it might change in CheckBoxLabeledMulti var tmpState = threeStateItem.State; var itemRect = inLs.GetRect(DefaultElementHeight); if (Widgets.CheckBoxLabeledSelectableMulti(itemRect, currentOrderedStoneDef.LabelCap, ref flag, ref tmpState)) { _selectedStoneDef = currentOrderedStoneDef; } // if the state changed, update the item with the new state threeStateItem.State = tmpState; ReorderableWidget.Reorderable(reorderableGroup, itemRect); TooltipHandler.TipRegion(itemRect, currentOrderedStoneDef.description); } ListingStandard.EndScrollView(inLs); } else { // just keep the height of what should have been the scroll view but don't draw it. Put a big red cross on it. var scrollViewRect = ListingStandard.GetRect(height); GUI.DrawTexture(scrollViewRect, Verse.Widgets.CheckboxOffTex); } // choose stone types depending on their number on tiles. ListingStandard.GapLine(DefaultGapLineHeight); var stoneTypesNumberRect = ListingStandard.GetRect(DefaultElementHeight); var leftRect = stoneTypesNumberRect.LeftPart(0.80f); var rightRect = stoneTypesNumberRect.RightPart(0.20f); var filterByStoneNumber = _gameData.UserData.StoneTypesNumberOnly; Verse.Widgets.CheckboxLabeled(leftRect, $"{"PLMWTT_UseNumberOfStoneTypes".Translate()}:", ref filterByStoneNumber); _gameData.UserData.StoneTypesNumberOnly = filterByStoneNumber; var numberOfStones = _gameData.UserData.StoneTypesNumber; Verse.Widgets.TextFieldNumeric(rightRect, ref numberOfStones, ref _bufferStringNumberOfStones, 2, 3); _gameData.UserData.StoneTypesNumber = numberOfStones; TooltipHandler.TipRegion(leftRect, "PLMWTT_UseNumberOfStoneTypesToolTip".Translate()); }
private void DrawSelectedTileInfo() { DrawEntryHeader("PLMWFTIL_SelectedTileInfo".Translate(), backgroundColor: Color.yellow); var matchingTiles = PrepareLanding.Instance.TileFilter.AllMatchingTiles; if (_selectedTileIndex < 0 || _selectedTileIndex >= matchingTiles.Count) { return; } ListingStandard.verticalSpacing = 0f; var selTileId = matchingTiles[_selectedTileIndex]; var selTile = Find.World.grid[selTileId]; ListingStandard.Label(selTile.biome.description); ListingStandard.Gap(8f); ListingStandard.GapLine(); if (!selTile.biome.implemented) { ListingStandard.Label(selTile.biome.LabelCap + " " + "BiomeNotImplemented".Translate()); } ListingStandard.LabelDouble("Terrain".Translate(), selTile.hilliness.GetLabelCap()); if (selTile.Roads != null) { ListingStandard.LabelDouble("Road".Translate(), (from roadlink in selTile.Roads select roadlink.road.label).Distinct().ToCommaList(true).CapitalizeFirst()); } if (selTile.Rivers != null) { ListingStandard.LabelDouble("River".Translate(), selTile.Rivers.MaxBy(riverlink => riverlink.river.degradeThreshold).river.LabelCap); } if (!Find.World.Impassable(selTileId)) { var stringBuilder = new StringBuilder(); var tile = selTileId; const bool perceivedStatic = false; var explanation = stringBuilder; var rightLabel = (WorldPathGrid.CalculatedMovementDifficultyAt(tile, perceivedStatic, null, explanation) * Find.WorldGrid.GetRoadMovementDifficultyMultiplier(selTileId, -1, stringBuilder)).ToString("0.#"); if (WorldPathGrid.WillWinterEverAffectMovementDifficulty(selTileId) && WorldPathGrid.GetCurrentWinterMovementDifficultyOffset(selTileId, null) < 2f) { stringBuilder.AppendLine(); stringBuilder.AppendLine(); stringBuilder.Append(" ("); stringBuilder.Append("MovementDifficultyOffsetInWinter".Translate("+" + 2f.ToString("0.#"))); stringBuilder.Append(")"); } ListingStandard.LabelDouble("MovementDifficulty".Translate(), rightLabel, stringBuilder.ToString()); } if (selTile.biome.canBuildBase) { ListingStandard.LabelDouble("StoneTypesHere".Translate(), (from rt in Find.World.NaturalRockTypesIn(selTileId) select rt.label).ToCommaList(true).CapitalizeFirst()); } ListingStandard.LabelDouble("Elevation".Translate(), selTile.elevation.ToString("F0") + "m"); ListingStandard.GapLine(); ListingStandard.LabelDouble("AvgTemp".Translate(), GenTemperature.GetAverageTemperatureLabel(selTileId)); ListingStandard.LabelDouble("OutdoorGrowingPeriod".Translate(), Zone_Growing.GrowingQuadrumsDescription(selTileId)); ListingStandard.LabelDouble("Rainfall".Translate(), selTile.rainfall.ToString("F0") + "mm"); if (selTile.biome.foragedFood != null && selTile.biome.forageability > 0f) { ListingStandard.LabelDouble("Forageability".Translate(), selTile.biome.forageability.ToStringPercent() + " (" + selTile.biome.foragedFood.label + ")"); } else { ListingStandard.LabelDouble("Forageability".Translate(), "0%"); } ListingStandard.LabelDouble("AnimalsCanGrazeNow".Translate(), (!VirtualPlantsUtility.EnvironmentAllowsEatingVirtualPlantsNowAt(selTileId)) ? "No".Translate() : "Yes".Translate()); ListingStandard.GapLine(); ListingStandard.LabelDouble("AverageDiseaseFrequency".Translate(), $"{(60f / selTile.biome.diseaseMtbDays):F1} {"PerYear".Translate()}"); ListingStandard.LabelDouble("TimeZone".Translate(), GenDate.TimeZoneAt(Find.WorldGrid.LongLatOf(selTileId).x).ToStringWithSign()); var stringBuilder2 = new StringBuilder(); var rot = Find.World.CoastDirectionAt(selTileId); if (rot.IsValid) { stringBuilder2.AppendWithComma(("HasCoast" + rot).Translate()); } if (Find.World.HasCaves(selTileId)) { stringBuilder2.AppendWithComma("HasCaves".Translate()); } if (stringBuilder2.Length > 0) { ListingStandard.LabelDouble("SpecialFeatures".Translate(), stringBuilder2.ToString().CapitalizeFirst()); } if (Prefs.DevMode) { ListingStandard.LabelDouble("Debug world tile ID", selTileId.ToString()); } }
private void DrawForageability() { DrawEntryHeader($"{"Forageability".Translate()} (%)", false, backgroundColor: ColorFromFilterType(typeof(TileFilterForageability))); DrawUsableMinMaxNumericField(_gameData.UserData.Forageability, "Forageability".Translate()); ListingStandard.GapLine(); // "Select" button if (ListingStandard.ButtonText("Select Forageable Food")) { var floatMenuOptions = new List <FloatMenuOption>(); // add a dummy 'Any' fake biome type. This sets the chosen biome to null. Action actionClick = delegate { _gameData.UserData.ForagedFood = null; }; // tool-tip when hovering above the 'Any' biome name on the floating menu Action mouseOverAction = delegate { var mousePos = Event.current.mousePosition; var rect = new Rect(mousePos.x, mousePos.y, DefaultElementHeight, DefaultElementHeight); TooltipHandler.TipRegion(rect, "Any Food"); }; var menuOption = new FloatMenuOption("PLMW_SelectAny".Translate(), actionClick, MenuOptionPriority.Default, mouseOverAction); floatMenuOptions.Add(menuOption); var foragedFoods = _gameData.DefData.ForagedFoodsPerBiome.Values.Where(x => x != null).Distinct().ToList(); // loop through all known biomes foreach (var foragedFood in foragedFoods) { Log.Message($"[PL] foragedFood: label: {foragedFood.label}; labelCap: {foragedFood.LabelCap}"); // clicking on the floating menu saves the selected biome actionClick = delegate { _gameData.UserData.ForagedFood = foragedFood; }; // tool-tip when hovering above the biome name on the floating menu mouseOverAction = delegate { var mousePos = Event.current.mousePosition; var rect = new Rect(mousePos.x, mousePos.y, DefaultElementHeight, DefaultElementHeight); TooltipHandler.TipRegion(rect, foragedFood.description); }; //create the floating menu menuOption = new FloatMenuOption(foragedFood.LabelCap, actionClick, MenuOptionPriority.Default, mouseOverAction); // add it to the list of floating menu options floatMenuOptions.Add(menuOption); } // create the floating menu var floatMenu = new FloatMenu(floatMenuOptions, "Select Forageable Food"); // add it to the window stack to display it Find.WindowStack.Add(floatMenu); } var currHeightBefore = ListingStandard.CurHeight; var rightLabel = _gameData.UserData.ForagedFood != null ? _gameData.UserData.ForagedFood.LabelCap : "Select Any"; ListingStandard.LabelDouble("Forageable Food: ", rightLabel); var currHeightAfter = ListingStandard.CurHeight; // display tool-tip over label if (_gameData.UserData.ForagedFood != null) { var currentRect = ListingStandard.GetRect(0f); currentRect.height = currHeightAfter - currHeightBefore; if (!string.IsNullOrEmpty(_gameData.UserData.ForagedFood.description)) { TooltipHandler.TipRegion(currentRect, _gameData.UserData.ForagedFood.description); } } }
private void DrawCoastalSelection() { DrawEntryHeader("PLMWTT_CoastalTiles".Translate(), false, backgroundColor: ColorFromFilterType(typeof(TileFilterCoastalTiles))); // coastal tiles (sea) var rect = ListingStandard.GetRect(DefaultElementHeight); var tmpCheckState = _gameData.UserData.ChosenCoastalTileState; Widgets.CheckBoxLabeledMulti(rect, $"{"PLMWTT_IsCoastalTileOcean".Translate()}:", ref tmpCheckState); _gameData.UserData.ChosenCoastalTileState = tmpCheckState; ListingStandard.GapLine(); /* * Coastal rotation */ var filterCoastalRotation = _gameData.UserData.CoastalRotation.Use; ListingStandard.CheckboxLabeled("PLMWTT_UseCoastalRoation".Translate(), ref filterCoastalRotation, "PLMWTT_UseCoastalRoationTooltip".Translate()); _gameData.UserData.CoastalRotation.Use = filterCoastalRotation; // "Select" button if (ListingStandard.ButtonText("PLMWTT_SelectCoastRotation".Translate())) { var floatMenuOptions = new List <FloatMenuOption>(); // loop through all meaningful rotations foreach (var currentRotation in TileFilterCoastRotation.PossibleRotations) { // clicking on the floating menu saves the selected rotation void ActionClick() { _gameData.UserData.CoastalRotation.Selected = currentRotation.AsInt; } // tool-tip when hovering above the rotation name on the floating menu void MouseOverAction() { var mousePos = Event.current.mousePosition; rect = new Rect(mousePos.x, mousePos.y, DefaultElementHeight, DefaultElementHeight); TooltipHandler.TipRegion(rect, ("HasCoast" + currentRotation).Translate()); } //create the floating menu var menuOption = new FloatMenuOption(currentRotation.ToStringHuman(), ActionClick, MenuOptionPriority.Default, MouseOverAction); // add it to the list of floating menu options floatMenuOptions.Add(menuOption); } // create the floating menu var floatMenu = new FloatMenu(floatMenuOptions, "PLMWTT_SelectCoastRotation".Translate()); // add it to the window stack to display it Find.WindowStack.Add(floatMenu); } var rightLabel = _gameData.UserData.CoastalRotation.Use /*&& _gameData.UserData.CoastalRotation.Selected != Rot4.Invalid*/ ? ("HasCoast" + _gameData.UserData.CoastalRotation.Selected).Translate().CapitalizeFirst() : "PLMW_None".Translate(); ListingStandard.LabelDouble($"{"PLMWTT_SelectedCoastRotation".Translate()}:", rightLabel); /* * coastal tiles (lake) */ ListingStandard.GapLine(); rect = ListingStandard.GetRect(DefaultElementHeight); TooltipHandler.TipRegion(rect, "PLMWTT_IsCoastalTileLakeTooltip".Translate()); tmpCheckState = _gameData.UserData.ChosenCoastalLakeTileState; Widgets.CheckBoxLabeledMulti(rect, $"{"PLMWTT_IsCoastalTileLake".Translate()}:", ref tmpCheckState); _gameData.UserData.ChosenCoastalLakeTileState = tmpCheckState; }
protected virtual void DrawStoneTypesSelection() { DrawEntryHeader("StoneTypesHere".Translate(), backgroundColor: ColorFromFilterSubjectThingDef("Stones")); var selectedStoneDefs = _userData.SelectedStoneDefs; var orderedStoneDefs = _userData.OrderedStoneDefs; // Reset button: reset all entries to Off state if (ListingStandard.ButtonText("Reset All")) { foreach (var stoneDefEntry in selectedStoneDefs) { stoneDefEntry.Value.State = stoneDefEntry.Value.DefaultState; } _userData.StoneTypesNumberOnly = false; } // re-orderable list group var reorderableGroup = ReorderableWidget.NewGroup(delegate(int from, int to) { //TODO find a way to raise an event to tell an observer that the list order has changed ReorderElements(from, to, orderedStoneDefs); SoundDefOf.TickHigh.PlayOneShotOnCamera(); }); var maxNumStones = (InRect.height - ListingStandard.CurHeight - DefaultGapLineHeight - DefaultElementHeight - 15f) / DefaultElementHeight; var maxHeight = maxNumStones * DefaultElementHeight; var height = Mathf.Min(selectedStoneDefs.Count * DefaultElementHeight, maxHeight); if (!_userData.StoneTypesNumberOnly) { // stone types, standard selection var inLs = ListingStandard.BeginScrollView(height, selectedStoneDefs.Count * DefaultElementHeight, ref _scrollPosStoneSelection, DefaultScrollableViewShrinkWidth); foreach (var currentOrderedStoneDef in orderedStoneDefs) { ThreeStateItem threeStateItem; if (!selectedStoneDefs.TryGetValue(currentOrderedStoneDef, out threeStateItem)) { Log.Message("A stoneDef wasn't found in selectedStoneDefs"); continue; } var flag = currentOrderedStoneDef == _selectedStoneDef; // save temporary state as it might change in CheckBoxLabeledMulti var tmpState = threeStateItem.State; var itemRect = inLs.GetRect(DefaultElementHeight); if (Widgets.CheckBoxLabeledSelectableMulti(itemRect, currentOrderedStoneDef.LabelCap, ref flag, ref tmpState)) { _selectedStoneDef = currentOrderedStoneDef; } // if the state changed, update the item with the new state threeStateItem.State = tmpState; ReorderableWidget.Reorderable(reorderableGroup, itemRect); TooltipHandler.TipRegion(itemRect, currentOrderedStoneDef.description); } ListingStandard.EndScrollView(inLs); } else { // just keep the height of what should have been the scroll view but don't draw it. Put a big red cross on it. var scrollViewRect = ListingStandard.GetRect(height); GUI.DrawTexture(scrollViewRect, Verse.Widgets.CheckboxOffTex); } // choose stone types depending on their number on tiles. ListingStandard.GapLine(DefaultGapLineHeight); var stoneTypesNumberRect = ListingStandard.GetRect(DefaultElementHeight); var leftRect = stoneTypesNumberRect.LeftPart(0.80f); var rightRect = stoneTypesNumberRect.RightPart(0.20f); var filterByStoneNumber = _userData.StoneTypesNumberOnly; Verse.Widgets.CheckboxLabeled(leftRect, "Use # of stone types [2,3]:", ref filterByStoneNumber); _userData.StoneTypesNumberOnly = filterByStoneNumber; var numberOfStones = _userData.StoneTypesNumber; Verse.Widgets.TextFieldNumeric(rightRect, ref numberOfStones, ref _bufferStringNumberOfStones, 2, 3); _userData.StoneTypesNumber = numberOfStones; const string tooltipText = "Filter tiles that have only the given number of stone types (whatever the types are). This disables the other stone filters."; TooltipHandler.TipRegion(leftRect, tooltipText); }
protected void DrawSelectedTileInfo() { DrawEntryHeader("Selected Tile Info", backgroundColor: Color.yellow); var matchingTiles = PrepareLanding.Instance.TileFilter.AllMatchingTiles; if (_selectedTileIndex < 0 || _selectedTileIndex >= matchingTiles.Count) { return; } ListingStandard.verticalSpacing = 0f; var selTileId = matchingTiles[_selectedTileIndex]; var selTile = Find.World.grid[selTileId]; ListingStandard.Label(selTile.biome.LabelCap); var y = Find.WorldGrid.LongLatOf(selTileId).y; ListingStandard.Label(selTile.biome.description); ListingStandard.Gap(8f); ListingStandard.GapLine(); if (!selTile.biome.implemented) { ListingStandard.Label(selTile.biome.LabelCap + " " + "BiomeNotImplemented".Translate()); } ListingStandard.LabelDouble("Terrain".Translate(), selTile.hilliness.GetLabelCap()); if (selTile.VisibleRoads != null) { ListingStandard.LabelDouble("Road".Translate(), GenText.ToCommaList((from roadlink in selTile.VisibleRoads select roadlink.road.label).Distinct()).CapitalizeFirst()); } if (selTile.VisibleRivers != null) { ListingStandard.LabelDouble("River".Translate(), selTile.VisibleRivers.MaxBy((riverlink) => riverlink.river.degradeThreshold).river.LabelCap); } if (!Find.World.Impassable(selTileId)) { const int num = 2500; var numTicks = Mathf.Min(num + WorldPathGrid.CalculatedCostAt(selTileId, false), 120000); ListingStandard.LabelDouble("MovementTimeNow".Translate(), numTicks.ToStringTicksToPeriod()); var numTicks2 = Mathf.Min(num + WorldPathGrid.CalculatedCostAt(selTileId, false, Season.Summer.GetMiddleYearPct(y)), 120000); ListingStandard.LabelDouble("MovementTimeSummer".Translate(), numTicks2.ToStringTicksToPeriod()); var numTicks3 = Mathf.Min(num + WorldPathGrid.CalculatedCostAt(selTileId, false, Season.Winter.GetMiddleYearPct(y)), 120000); ListingStandard.LabelDouble("MovementTimeWinter".Translate(), numTicks3.ToStringTicksToPeriod()); } if (selTile.biome.canBuildBase) { ListingStandard.LabelDouble("StoneTypesHere".Translate(), GenText.ToCommaList(from rt in Find.World.NaturalRockTypesIn(selTileId) select rt.label).CapitalizeFirst()); } ListingStandard.LabelDouble("Elevation".Translate(), selTile.elevation.ToString("F0") + "m"); ListingStandard.GapLine(); ListingStandard.LabelDouble("AvgTemp".Translate(), selTile.temperature.ToStringTemperature()); var celsiusTemp = GenTemperature.AverageTemperatureAtTileForTwelfth(selTileId, Season.Winter.GetMiddleTwelfth(y)); ListingStandard.LabelDouble("AvgWinterTemp".Translate(), celsiusTemp.ToStringTemperature()); var celsiusTemp2 = GenTemperature.AverageTemperatureAtTileForTwelfth(selTileId, Season.Summer.GetMiddleTwelfth(y)); ListingStandard.LabelDouble("AvgSummerTemp".Translate(), celsiusTemp2.ToStringTemperature()); ListingStandard.LabelDouble("OutdoorGrowingPeriod".Translate(), Zone_Growing.GrowingQuadrumsDescription(selTileId)); ListingStandard.LabelDouble("Rainfall".Translate(), selTile.rainfall.ToString("F0") + "mm"); ListingStandard.LabelDouble("AnimalsCanGrazeNow".Translate(), (!VirtualPlantsUtility.EnvironmentAllowsEatingVirtualPlantsNowAt(selTileId)) ? "No".Translate() : "Yes".Translate()); ListingStandard.GapLine(); ListingStandard.LabelDouble("TimeZone".Translate(), GenDate.TimeZoneAt(Find.WorldGrid.LongLatOf(selTileId).x).ToStringWithSign()); var rot = Find.World.CoastDirectionAt(selTileId); if (rot.IsValid) { ListingStandard.LabelDouble(string.Empty, ("HasCoast" + rot).Translate()); } if (Prefs.DevMode) { ListingStandard.LabelDouble("Debug world tile ID", selTileId.ToString()); } }