Example #1
0
        private void DrawStoneTypesSelection()
        {
            DrawEntryHeader("StoneTypesHere".Translate(), backgroundColor: ColorLibrary.RoyalPurple);

            var selectedStoneDefs = _gameData.GodModeData.SelectedStoneDefs;
            var orderedStoneDefs  = _gameData.GodModeData.OrderedStoneDefs;

            // Reset button: reset all entries to Off state
            if (ListingStandard.ButtonText("Reset"))
            {
                _gameData.GodModeData.ResetSelectedStoneDefs();
            }

            // re-orderable list group
            var reorderableGroup = ReorderableWidget.NewGroup(delegate(int from, int to)
            {
                orderedStoneDefs.ReorderElements(from, to);
                SoundDefOf.Tick_High.PlayOneShotOnCamera();
            }, ReorderableDirection.Vertical);

            var maxNumStones = (InRect.height - ListingStandard.CurHeight - DefaultGapLineHeight -
                                DefaultElementHeight - 15f) / DefaultElementHeight;
            var maxHeight = maxNumStones * DefaultElementHeight;
            var height    = Mathf.Min(selectedStoneDefs.Count * DefaultElementHeight, maxHeight);

            // stone types, standard selection

            var inLs = ListingStandard.BeginScrollView(height, selectedStoneDefs.Count * DefaultElementHeight,
                                                       ref _scrollPosStoneSelection, DefaultScrollableViewShrinkWidth);

            foreach (var currentOrderedStoneDef in orderedStoneDefs)
            {
                var itemRect = inLs.GetRect(DefaultElementHeight);


                var tmpState = selectedStoneDefs[currentOrderedStoneDef];
                var selected = currentOrderedStoneDef == _selectedStoneDef;

                if (Widgets.CheckboxLabeledSelectable(itemRect, currentOrderedStoneDef.LabelCap, ref selected,
                                                      ref tmpState))
                {
                    _selectedStoneDef = currentOrderedStoneDef;
                }

                // if the state changed, update the item with the new state
                if (tmpState != selectedStoneDefs[currentOrderedStoneDef])
                {
                    selectedStoneDefs[currentOrderedStoneDef] = tmpState;
                }

                ReorderableWidget.Reorderable(reorderableGroup, itemRect);

                if (!string.IsNullOrEmpty(currentOrderedStoneDef.description))
                {
                    TooltipHandler.TipRegion(itemRect, currentOrderedStoneDef.description);
                }
            }

            ListingStandard.EndScrollView(inLs);
        }
Example #2
0
        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
        }
Example #3
0
        private void DrawHillinessTypeSelection()
        {
            DrawEntryHeader("PLMWTT_TerrainTypes".Translate(),
                            backgroundColor: ColorFromFilterType(typeof(TileFilterHilliness)));

            if (ListingStandard.ButtonText("PLMWTT_SelectTerrain".Translate()))
            {
                var floatMenuOptions = new List <FloatMenuOption>();
                foreach (var hillinessValue in _gameData.DefData.HillinessCollection)
                {
                    var label = "PLMW_SelectAny".Translate();

                    if (hillinessValue != Hilliness.Undefined)
                    {
                        label = hillinessValue.GetLabelCap();
                    }

                    var menuOption = new FloatMenuOption(label,
                                                         delegate { _gameData.UserData.ChosenHilliness = hillinessValue; });
                    floatMenuOptions.Add(menuOption);
                }

                var floatMenu = new FloatMenu(floatMenuOptions, "PLMWTT_SelectTerrain".Translate());
                Find.WindowStack.Add(floatMenu);
            }

            // note: RimWorld logs an error when .GetLabelCap() is used on Hilliness.Undefined
            var rightLabel = _gameData.UserData.ChosenHilliness != Hilliness.Undefined
                ? _gameData.UserData.ChosenHilliness.GetLabelCap()
                : "PLMW_SelectAny".Translate();

            ListingStandard.LabelDouble($"{"Terrain".Translate()}:", rightLabel);
        }
Example #4
0
        private void DrawHillinessTypeSelection()
        {
            DrawEntryHeader("Terrain Types", backgroundColor: ColorLibrary.RoyalPurple);

            if (ListingStandard.ButtonText("Select Terrain"))
            {
                var floatMenuOptions = new List <FloatMenuOption>();
                foreach (var hillinessValue in _gameData.DefData.HillinessCollection)
                {
                    var label = "Any";

                    if (hillinessValue != Hilliness.Undefined)
                    {
                        label = hillinessValue.GetLabelCap();
                    }

                    var menuOption = new FloatMenuOption(label,
                                                         delegate { _gameData.GodModeData.Hilliness = hillinessValue; });
                    floatMenuOptions.Add(menuOption);
                }

                var floatMenu = new FloatMenu(floatMenuOptions, "Select terrain");
                Find.WindowStack.Add(floatMenu);
            }

            // note: RimWorld logs an error when .GetLabelCap() is used on Hilliness.Undefined
            var rightLabel = _gameData.GodModeData.Hilliness != Hilliness.Undefined
                ? _gameData.GodModeData.Hilliness.GetLabelCap()
                : "Any";

            ListingStandard.LabelDouble($"{"Terrain".Translate()}:", rightLabel);
        }
        protected virtual void DrawHillinessTypeSelection()
        {
            DrawEntryHeader($"{"Terrain".Translate()} Types",
                            backgroundColor: ColorFromFilterSubjectThingDef("Terrains"));

            if (ListingStandard.ButtonText("Select Terrain"))
            {
                var floatMenuOptions = new List <FloatMenuOption>();
                foreach (var hillinessValue in _userData.HillinessCollection)
                {
                    var label = "Any";

                    if (hillinessValue != Hilliness.Undefined)
                    {
                        label = hillinessValue.GetLabelCap();
                    }

                    var menuOption = new FloatMenuOption(label,
                                                         delegate { _userData.ChosenHilliness = hillinessValue; });
                    floatMenuOptions.Add(menuOption);
                }

                var floatMenu = new FloatMenu(floatMenuOptions, "Select terrain");
                Find.WindowStack.Add(floatMenu);
            }

            // note: RimWorld logs an error when .GetLabelCap() is used on Hilliness.Undefined
            var rightLabel = _userData.ChosenHilliness != Hilliness.Undefined
                ? _userData.ChosenHilliness.GetLabelCap()
                : "Any";

            ListingStandard.LabelDouble($"{"Terrain".Translate()}:", rightLabel);
        }
Example #6
0
        private void DrawTileSelection()
        {
            DrawEntryHeader("Tile Setup", backgroundColor: ColorLibrary.RoyalPurple);

            var tileId = Find.WorldSelector.selectedTile;

            if (!Find.WorldSelector.AnyObjectOrTileSelected || tileId < 0)
            {
                var labelRect = ListingStandard.GetRect(DefaultElementHeight);
                Widgets.Label(labelRect, "Pick a tile on world map!");
                _gameData.GodModeData.SelectedTileId = -1;
                return;
            }

            ListingStandard.LabelDouble("Selected Tile: ", tileId.ToString());

            if (_gameData.GodModeData.SelectedTileId != tileId)
            {
                _gameData.GodModeData.InitFromTileId(tileId);
            }

            if (ListingStandard.ButtonText("Set Tile"))
            {
                if (Find.WorldObjects.AnySettlementBaseAtOrAdjacent(tileId))
                {
                    Messages.Message("You're not allowed to settle on or near another settlement tile.", MessageTypeDefOf.RejectInput);
                    _gameData.GodModeData.SelectedTileId = -1;
                    return;
                }

                PrepareLanding.Instance.TileFilter.ClearMatchingTiles();

                //TODO: you need to clear the temperature cache for the tile, otherwise it's wrong after being changed...
                // see RimWorld.Planet.TileTemperaturesComp.RetrieveCachedData for the cache itself. It's private...
                // but could be cleaned with RimWorld.Planet.TileTemperaturesComp.ClearCaches() but that would invalidate *all* caches...

                _redrawMapEnabled = _gameData.GodModeData.SetupTile();
            }

            var heightBefore = ListingStandard.StartCaptureHeight();

            if (ListingStandard.ButtonText("Redraw Map"))
            {
                if (_redrawMapEnabled)
                {
                    LongEventHandler.QueueLongEvent(delegate { Find.World.renderer.SetAllLayersDirty(); },
                                                    "GeneratingWorld", true, null);
                }
                else
                {
                    Messages.Message("You need to change a tile first to be able to redraw the map.",
                                     MessageTypeDefOf.RejectInput);
                }
            }
            var tooltipRect = ListingStandard.EndCaptureHeight(heightBefore);

            TooltipHandler.TipRegion(tooltipRect,
                                     "[Warning: this redraws the map entirely; use it only when you have finished *all* your modifications.]");
        }
Example #7
0
        private void DrawRiverTypesSelection()
        {
            DrawEntryHeader("River Types", backgroundColor: ColorLibrary.RoyalPurple);

            var riverDefs         = _gameData.DefData.RiverDefs;
            var selectedRiverDefs = _gameData.GodModeData.SelectedRiverDefs;

            if (ListingStandard.ButtonText("Reset"))
            {
                _gameData.GodModeData.ResetSelectedRiverDefs();
            }

            /*
             * ScrollView
             */

            var scrollViewHeight = riverDefs.Count * DefaultElementHeight;
            var inLs             = ListingStandard.BeginScrollView(5 * DefaultElementHeight, scrollViewHeight,
                                                                   ref _scrollPosRiverSelection, DefaultScrollableViewShrinkWidth);

            // display road elements
            foreach (var riverDef in riverDefs)
            {
                // save temporary state as it might change in CheckBoxLabeledMulti
                var tmpState = selectedRiverDefs[riverDef];

                var itemRect = inLs.GetRect(DefaultElementHeight);
                Widgets.CheckboxLabeled(itemRect, riverDef.LabelCap, ref tmpState);

                // if the state changed, update the item with the new state
                if (tmpState != selectedRiverDefs[riverDef])
                {
                    if (tmpState)
                    {
                        var countTrue = selectedRiverDefs.Values.Count(selectedRiverDefValue => selectedRiverDefValue);
                        if (countTrue >= MaxNumberOfRivers)
                        {
                            Messages.Message($"Can't have more than {MaxNumberOfRivers} types of river per tile.",
                                             MessageTypeDefOf.RejectInput);
                            tmpState = false;
                        }
                    }

                    selectedRiverDefs[riverDef] = tmpState;
                }

                if (!string.IsNullOrEmpty(riverDef.description))
                {
                    TooltipHandler.TipRegion(itemRect, riverDef.description);
                }
            }

            ListingStandard.EndScrollView(inLs);
        }
        protected virtual void DrawRoadTypesSelection()
        {
            DrawEntryHeader("Road Types", backgroundColor: ColorFromFilterSubjectThingDef("Roads"));

            var roadDefs         = _userData.RoadDefs;
            var selectedRoadDefs = _userData.SelectedRoadDefs;

            // Reset button: reset all entries to Off state
            if (ListingStandard.ButtonText("Reset All"))
            {
                foreach (var roadDefEntry in selectedRoadDefs)
                {
                    roadDefEntry.Value.State = MultiCheckboxState.Partial;
                }
            }

            var scrollViewHeight = selectedRoadDefs.Count * DefaultElementHeight;
            var inLs             = ListingStandard.BeginScrollView(5 * DefaultElementHeight, scrollViewHeight,
                                                                   ref _scrollPosRoadSelection);

            // display road elements
            foreach (var roadDef in roadDefs)
            {
                ThreeStateItem threeStateItem;
                if (!selectedRoadDefs.TryGetValue(roadDef, out threeStateItem))
                {
                    Log.Error(
                        $"[PrepareLanding] [DrawRoadTypesSelection] an item in RoadDefs is not in SelectedRoadDefs: {roadDef.LabelCap}");
                    continue;
                }

                // save temporary state as it might change in CheckBoxLabeledMulti
                var tmpState = threeStateItem.State;

                var itemRect = inLs.GetRect(DefaultElementHeight);
                Widgets.CheckBoxLabeledMulti(itemRect, roadDef.LabelCap, ref tmpState);

                // if the state changed, update the item with the new state
                // ReSharper disable once RedundantCheckBeforeAssignment
                if (tmpState != threeStateItem.State)
                {
                    threeStateItem.State = tmpState;
                }

                if (!string.IsNullOrEmpty(roadDef.description))
                {
                    TooltipHandler.TipRegion(itemRect, roadDef.description);
                }
            }

            ListingStandard.EndScrollView(inLs);
        }
Example #9
0
        private void DrawTemperatureInfo()
        {
            DrawEntryHeader("Temperature Info", backgroundColor: Color.yellow);

            /*
             * Forecast
             */
            if (ListingStandard.ButtonText("View Temperature Forecast"))
            {
                var tileId = _gameData.GodModeData.SelectedTileId;
                TabTemperature.ViewTemperatureForecast(tileId, WorldData.NowToTicks(tileId));
            }
        }
        protected void DrawGrowingPeriodSelection()
        {
            const string label = "Growing Period";

            DrawEntryHeader($"{label} (days)", backgroundColor: ColorFromFilterSubjectThingDef("Growing Periods"));

            var boundField = _userData.GrowingPeriod;

            var tmpCheckedOn = boundField.Use;

            ListingStandard.Gap();
            ListingStandard.CheckboxLabeled(label, ref tmpCheckedOn, $"Use Min/Max {label}");
            boundField.Use = tmpCheckedOn;

            // MIN

            if (ListingStandard.ButtonText($"Min {label}"))
            {
                var floatMenuOptions = new List <FloatMenuOption>();
                foreach (var growingTwelfth in boundField.Options)
                {
                    var menuOption = new FloatMenuOption(growingTwelfth.GrowingDaysString(),
                                                         delegate { boundField.Min = growingTwelfth; });
                    floatMenuOptions.Add(menuOption);
                }

                var floatMenu = new FloatMenu(floatMenuOptions, $"Select {label}");
                Find.WindowStack.Add(floatMenu);
            }

            ListingStandard.LabelDouble($"Min. {label}:", boundField.Min.GrowingDaysString());

            // MAX

            if (ListingStandard.ButtonText($"Max {label}"))
            {
                var floatMenuOptions = new List <FloatMenuOption>();
                foreach (var growingTwelfth in boundField.Options)
                {
                    var menuOption = new FloatMenuOption(growingTwelfth.GrowingDaysString(),
                                                         delegate { boundField.Max = growingTwelfth; });
                    floatMenuOptions.Add(menuOption);
                }

                var floatMenu = new FloatMenu(floatMenuOptions, $"Select {label}");
                Find.WindowStack.Add(floatMenu);
            }

            ListingStandard.LabelDouble($"Max. {label}:", boundField.Max.GrowingDaysString());
        }
Example #11
0
        protected virtual void DrawFilterInfo()
        {
            DrawEntryHeader("Filter Info", backgroundColor: Color.yellow);

            if (ListingStandard.ButtonText("Clear Info"))
            {
                PrepareLanding.Instance.TileFilter.FilterInfoLogger.Clear();
            }

            ListingStandard.Gap();

            var text = PrepareLanding.Instance.TileFilter.FilterInfoLogger.Text;

            if (text.NullOrEmpty())
            {
                return;
            }

            var maxOuterRectHeight = InRect.height - ListingStandard.CurHeight - 30f;

            ListingStandard.ScrollableTextArea(maxOuterRectHeight, text, ref _scrollPosFilterInfo, _styleFilterInfo,
                                               16f);
        }
Example #12
0
        private void DrawFilterInfo()
        {
            DrawEntryHeader("PLMWINF_FilterInfo".Translate(), backgroundColor: Color.yellow);

            if (ListingStandard.ButtonText("PLMWINF_ClearInfo".Translate()))
            {
                PrepareLanding.Instance.TileFilter.FilterInfoLogger.Clear();
            }

            ListingStandard.Gap();

            var text = PrepareLanding.Instance.TileFilter.FilterInfoLogger.Text;

            if (text.NullOrEmpty())
            {
                return;
            }

            var maxOuterRectHeight = InRect.height - ListingStandard.CurHeight - DefaultElementHeight;

            ListingStandard.ScrollableTextArea(maxOuterRectHeight, text, ref _scrollPosFilterInfo, _styleFilterInfo,
                                               DefaultScrollableViewShrinkWidth);
        }
Example #13
0
        private void DrawOpenCoordinatesWindow()
        {
            DrawEntryHeader("PLMWT2T_CoordinatesWindow".Translate(), backgroundColor: Color.magenta);

            if (!ListingStandard.ButtonText("PLMWT2T_OpenCoordinatesWindow".Translate()))
            {
                return;
            }

            if (Coordinates.MainWindow.IsInWindowStack)
            {
                return;
            }

            if (!Coordinates.MainWindow.CanBeDisplayed)
            {
                return;
            }

            var coordinatesWindow = new Coordinates.MainWindow();

            Find.WindowStack.Add(coordinatesWindow);
        }
        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);
        }
Example #15
0
        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);
                }
            }
        }
Example #16
0
        private void DrawBiomeTypesSelection() // TODO : factorize this function with the one from TabTerrain
        {
            DrawEntryHeader("Biome Types", backgroundColor: ColorLibrary.RoyalPurple);

            var biomeDefs = _gameData.DefData.BiomeDefs;

            // "Select" button
            if (ListingStandard.ButtonText("Select Biome"))
            {
                var floatMenuOptions = new List <FloatMenuOption>();

                // add a dummy 'Any' fake biome type. This sets the chosen biome to null.
                Action actionClick = delegate { _gameData.GodModeData.Biome = 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 Biome");
                };
                var menuOption = new FloatMenuOption("Any", actionClick, MenuOptionPriority.Default, mouseOverAction);
                floatMenuOptions.Add(menuOption);

                // loop through all known biomes
                foreach (var currentBiomeDef in biomeDefs)
                {
                    // clicking on the floating menu saves the selected biome
                    actionClick = delegate { _gameData.GodModeData.Biome = currentBiomeDef; };
                    // 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, currentBiomeDef.description);
                    };

                    //create the floating menu
                    menuOption = new FloatMenuOption(currentBiomeDef.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 Biome Type");

                // add it to the window stack to display it
                Find.WindowStack.Add(floatMenu);
            }

            var currHeightBefore = ListingStandard.CurHeight;

            var rightLabel = _gameData.GodModeData.Biome != null ? _gameData.GodModeData.Biome.LabelCap : "Any";

            ListingStandard.LabelDouble("Biome:", rightLabel);

            var currHeightAfter = ListingStandard.CurHeight;

            // display tool-tip over label
            if (_gameData.GodModeData.Biome != null)
            {
                var currentRect = ListingStandard.GetRect(0f);
                currentRect.height = currHeightAfter - currHeightBefore;
                if (!string.IsNullOrEmpty(_gameData.GodModeData.Biome.description))
                {
                    TooltipHandler.TipRegion(currentRect, _gameData.GodModeData.Biome.description);
                }
            }
        }
Example #17
0
        private void DrawFilteredTiles()
        {
            DrawEntryHeader("PLMWFTIL_FilteredTiles".Translate(), backgroundColor: Color.yellow);

            // default line height
            const float gapLineHeight = 4f;

            //check if we have something to display (tiles)
            var matchingTiles      = PrepareLanding.Instance.TileFilter.AllMatchingTiles;
            var matchingTilesCount = matchingTiles.Count;

            if (matchingTilesCount == 0)
            {
                return;
            }

            /*
             * Buttons
             */

            if (ListingStandard.ButtonText("PLMWFTIL_ClearFilteredTiles".Translate()))
            {
                // clear everything
                PrepareLanding.Instance.TileFilter.ClearMatchingTiles();

                // reset starting display index
                _tileDisplayIndexStart = 0;

                // reset selected index
                _selectedTileIndex = -1;

                // don't go further as there are no tile content to draw
                return;
            }

            var buttonsRectSpace = ListingStandard.GetRect(30f);
            var splittedRect     = buttonsRectSpace.SplitRectWidthEvenly(_minimizedWindowButtonsDescriptorList.Count);

            for (var i = 0; i < _minimizedWindowButtonsDescriptorList.Count; i++)
            {
                // get button descriptor
                var buttonDescriptor = _minimizedWindowButtonsDescriptorList[i];

                // display button; if clicked: call the related action
                if (Widgets.ButtonText(splittedRect[i], buttonDescriptor.Label))
                {
                    buttonDescriptor.Action();
                }

                // display tool-tip (if any)
                if (!string.IsNullOrEmpty(buttonDescriptor.ToolTip))
                {
                    TooltipHandler.TipRegion(splittedRect[i], buttonDescriptor.ToolTip);
                }
            }

            /*
             * Label
             */

            // number of elements (tiles) to display
            var itemsToDisplay = Math.Min(matchingTilesCount - _tileDisplayIndexStart, MaxDisplayedTileWhenMinimized);

            // label to display where we actually are in the tile list
            GenUI.SetLabelAlign(TextAnchor.MiddleCenter);
            var heightBefore = ListingStandard.StartCaptureHeight();

            ListingStandard.Label(
                $"{_tileDisplayIndexStart}: {_tileDisplayIndexStart + itemsToDisplay - 1} / {matchingTilesCount - 1}",
                DefaultElementHeight);
            GenUI.ResetLabelAlign();
            var counterLabelRect = ListingStandard.EndCaptureHeight(heightBefore);

            Core.Gui.Widgets.DrawHighlightColor(counterLabelRect, Color.cyan, 0.50f);

            // 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 - 30f;

            // height of the 'virtual' portion of the scroll view
            var scrollableViewHeight = itemsToDisplay * DefaultElementHeight + gapLineHeight * MaxDisplayedTileWhenMinimized;

            /*
             * Scroll view
             */
            var innerLs = ListingStandard.BeginScrollView(maxScrollViewOuterHeight, scrollableViewHeight,
                                                          ref _scrollPosMatchingTiles, 16f);

            var endIndex = _tileDisplayIndexStart + itemsToDisplay;

            for (var i = _tileDisplayIndexStart; i < endIndex; i++)
            {
                var selectedTileId = matchingTiles[i];
                var selectedTile   = Find.World.grid[selectedTileId];

                // get latitude & longitude for the tile
                var vector    = Find.WorldGrid.LongLatOf(selectedTileId);
                var labelText =
                    $"{i}: {vector.y.ToStringLatitude()} {vector.x.ToStringLongitude()} - {selectedTile.biome.LabelCap} ; {selectedTileId}";

                // display the label
                var labelRect = innerLs.GetRect(DefaultElementHeight);
                var selected  = i == _selectedTileIndex;
                if (Core.Gui.Widgets.LabelSelectable(labelRect, labelText, ref selected, TextAnchor.MiddleCenter))
                {
                    // go to the location of the selected tile
                    _selectedTileIndex = i;
                    Find.WorldInterface.SelectedTile = selectedTileId;
                    Find.WorldCameraDriver.JumpTo(Find.WorldGrid.GetTileCenter(Find.WorldInterface.SelectedTile));
                }
                // add a thin line between each label
                innerLs.GapLine(gapLineHeight);
            }

            ListingStandard.EndScrollView(innerLs);
        }
Example #18
0
        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.Gap(6f);

            /*
             * 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.Gap(6f);


            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;
        }
Example #19
0
        private void DrawFeatureSelection()
        {
            DrawEntryHeader("PLMWT2T_WorldFeatureSelection".Translate(),
                            backgroundColor: ColorFromFilterType(typeof(TileFilterWorldFeature)));

            var features = _gameData.WorldData.WorldFeatures;

            // "Select" button
            if (ListingStandard.ButtonText("PLMWT2T_SelectWorldFeature".Translate()))
            {
                var floatMenuOptions = new List <FloatMenuOption>();

                // add a dummy 'Any' fake feature type. This sets the chosen feature to null.
                Action actionClick = delegate { _gameData.UserData.WorldFeature = null; };
                // tool-tip when hovering above the 'Any' feature name on the floating menu
                void MouseOverAction()
                {
                    var mousePos = Event.current.mousePosition;
                    var rect     = new Rect(mousePos.x, mousePos.y, DefaultElementHeight, DefaultElementHeight);

                    TooltipHandler.TipRegion(rect, "PLMWT2T_AnyWorldFeature".Translate());
                }

                var menuOption = new FloatMenuOption("PLMW_SelectAny".Translate(), actionClick, MenuOptionPriority.Default, MouseOverAction);
                floatMenuOptions.Add(menuOption);

                // loop through all known feature
                foreach (var currentFeature in features)
                {
                    // do not allow ocean and lakes
                    if (currentFeature.def.rootBiomes.Count != 0)
                    {
                        if (currentFeature.def.rootBiomes.Contains(BiomeDefOf.Ocean) ||
                            currentFeature.def.rootBiomes.Contains(BiomeDefOf.Lake))
                        {
                            continue;
                        }
                    }
                    // TODO: handle other water bodies, you'll need to parse the def name as there are no other ways
                    // see \Mods\Core\Defs\Misc\FeatureDefs\Features.xml
                    // or another solution would be to patch the definition (e.g. OuterOcean) to have a root biome as "Ocean" (or lake or whatever water body).
                    //if(currentFeature.def.defName contains "Ocean")

                    // clicking on the floating menu saves the selected feature
                    actionClick = delegate { _gameData.UserData.WorldFeature = currentFeature; };

                    //create the floating menu
                    menuOption = new FloatMenuOption(currentFeature.name, actionClick);
                    // add it to the list of floating menu options
                    floatMenuOptions.Add(menuOption);
                }

                // create the floating menu
                var floatMenu = new FloatMenu(floatMenuOptions, "PLMWT2T_SelectWorldFeature".Translate());

                // add it to the window stack to display it
                Find.WindowStack.Add(floatMenu);
            }

            var currHeightBefore = ListingStandard.CurHeight;

            var rightLabel = _gameData.UserData.WorldFeature != null ? _gameData.UserData.WorldFeature.name : (string)"PLMW_SelectAny".Translate();

            ListingStandard.LabelDouble($"{"PLMWT2T_WorldFeature".Translate()}:", rightLabel);

            var currHeightAfter = ListingStandard.CurHeight;

            // display tool-tip over label
            if (_gameData.UserData.WorldFeature != null)
            {
                var currentRect = ListingStandard.GetRect(0f);
                currentRect.height = currHeightAfter - currHeightBefore;
                if (!string.IsNullOrEmpty(_gameData.UserData.WorldFeature.name))
                {
                    TooltipHandler.TipRegion(currentRect, _gameData.UserData.WorldFeature.name);
                }
            }
        }
Example #20
0
        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);
        }
Example #21
0
        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);
            }
        }
Example #22
0
        private void DrawBiomeTypesSelection()
        {
            DrawEntryHeader("PLMWTT_BiomeTypes".Translate(), false, backgroundColor: ColorFromFilterType(typeof(TileFilterBiomes)));

            var biomeDefs = _gameData.DefData.BiomeDefs;

            // "Select" button
            if (ListingStandard.ButtonText("PLMWTT_SelectBiome".Translate()))
            {
                var floatMenuOptions = new List <FloatMenuOption>();

                // add a dummy 'Any' fake biome type. This sets the chosen biome to null.
                Action actionClick = delegate { _gameData.UserData.ChosenBiome = 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, "PLMWTT_AnyBiome".Translate());
                };
                var menuOption = new FloatMenuOption("PLMW_SelectAny".Translate(), actionClick, MenuOptionPriority.Default, mouseOverAction);
                floatMenuOptions.Add(menuOption);

                // loop through all known biomes
                foreach (var currentBiomeDef in biomeDefs)
                {
                    // clicking on the floating menu saves the selected biome
                    actionClick = delegate { _gameData.UserData.ChosenBiome = currentBiomeDef; };
                    // 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, currentBiomeDef.description);
                    };

                    //create the floating menu
                    menuOption = new FloatMenuOption(currentBiomeDef.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, "PLMWTT_SelectBiomeType".Translate());

                // add it to the window stack to display it
                Find.WindowStack.Add(floatMenu);
            }

            var currHeightBefore = ListingStandard.CurHeight;

            var rightLabel = _gameData.UserData.ChosenBiome != null ? _gameData.UserData.ChosenBiome.LabelCap : "PLMW_SelectAny".Translate();

            ListingStandard.LabelDouble($"{"Biome".Translate()}:", rightLabel);

            var currHeightAfter = ListingStandard.CurHeight;

            // display tool-tip over label
            if (_gameData.UserData.ChosenBiome != null)
            {
                var currentRect = ListingStandard.GetRect(0f);
                currentRect.height = currHeightAfter - currHeightBefore;
                if (!string.IsNullOrEmpty(_gameData.UserData.ChosenBiome.description))
                {
                    TooltipHandler.TipRegion(currentRect, _gameData.UserData.ChosenBiome.description);
                }
            }
        }
Example #23
0
        protected void DrawUsableMinMaxFromRestrictedListItem <T>(MinMaxFromRestrictedListItem <T> item, string label, Func <T, string> itemToStringFunc = null)
            where T : struct, IConvertible
        {
            var tmpCheckedOn = item.Use;

            var textMin = "PLINT_UsableMinMaxNumFieldMin".Translate();
            var textMax = "PLINT_UsableMinMaxNumFieldMax".Translate();

            // Use
            ListingStandard.Gap();
            ListingStandard.CheckboxLabeled(label, ref tmpCheckedOn, $"{"PLINT_UsableMinMaxNumFieldUse".Translate()} {textMin}/{textMax} {label}");
            item.Use = tmpCheckedOn;

            // MIN
            if (ListingStandard.ButtonText($"{"PLINT_UsableMinMaxNumFieldMin".Translate()} {label}"))
            {
                var floatMenuOptions = new List <FloatMenuOption>();
                foreach (var itemOption in item.Options)
                {
                    var menuOptionString = itemToStringFunc == null
                        ? itemOption.ToString(CultureInfo.InvariantCulture)
                        : itemToStringFunc(itemOption);

                    var menuOption = new FloatMenuOption(menuOptionString, delegate { item.Min = itemOption; });
                    floatMenuOptions.Add(menuOption);
                }

                var floatMenu = new FloatMenu(floatMenuOptions, $"{"PLINT_MinMaxFromRestrictedListItemSelect".Translate()} {label}");
                Find.WindowStack.Add(floatMenu);
            }

            var minValueString = itemToStringFunc == null
                ? item.Min.ToString(CultureInfo.InvariantCulture)
                : itemToStringFunc(item.Min);

            ListingStandard.LabelDouble($"{"PLINT_UsableMinMaxNumFieldMin".Translate()} {label}:", minValueString);

            // MAX
            if (ListingStandard.ButtonText($"{"PLINT_UsableMinMaxNumFieldMax".Translate()} {label}"))
            {
                var floatMenuOptions = new List <FloatMenuOption>();
                foreach (var itemOption in item.Options)
                {
                    var menuOptionString = itemToStringFunc == null
                        ? itemOption.ToString(CultureInfo.InvariantCulture)
                        : itemToStringFunc(itemOption);

                    var menuOption = new FloatMenuOption(menuOptionString, delegate { item.Max = itemOption; });
                    floatMenuOptions.Add(menuOption);
                }

                var floatMenu = new FloatMenu(floatMenuOptions, $"{"PLINT_MinMaxFromRestrictedListItemSelect".Translate()} {label}");
                Find.WindowStack.Add(floatMenu);
            }

            var maxValueString = itemToStringFunc == null
                ? item.Min.ToString(CultureInfo.InvariantCulture)
                : itemToStringFunc(item.Max);

            ListingStandard.LabelDouble($"{"PLINT_UsableMinMaxNumFieldMax".Translate()} {label}:", maxValueString);
        }