Example #1
0
        protected void DrawUsableMinMaxNumericField <T>(UsableMinMaxNumericItem <T> numericItem, string label,
                                                        float min = 0f, float max = 1E+09f) where T : struct, IComparable, IConvertible
        {
            var tmpCheckedOn = numericItem.Use;

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

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

            var minValue          = numericItem.Min;
            var minValueString    = numericItem.MinString;
            var minValueLabelRect = ListingStandard.GetRect(DefaultElementHeight);

            Verse.Widgets.TextFieldNumericLabeled(minValueLabelRect, $"{textMin}: ", ref minValue, ref minValueString, min, max);
            numericItem.Min       = minValue;
            numericItem.MinString = minValueString;

            var maxValue          = numericItem.Max;
            var maxValueString    = numericItem.MaxString;
            var maxValueLabelRect = ListingStandard.GetRect(DefaultElementHeight);

            Verse.Widgets.TextFieldNumericLabeled(maxValueLabelRect, $"{textMax}: ", ref maxValue, ref maxValueString, min, max);
            numericItem.Max       = maxValue;
            numericItem.MaxString = maxValueString;
        }
Example #2
0
        private void DrawTileHighlighterOptions()
        {
            DrawEntryHeader("PLOPT_TileHighlighterOptions".Translate(), backgroundColor: Color.cyan);

            var disableTileHighligthing = _gameData.UserData.Options.DisableTileHighlighting;

            ListingStandard.CheckboxLabeled("PLOPT_DisableTileHighlighting".Translate(), ref disableTileHighligthing,
                                            "PLOPT_DisableTileHighlightingToolTip".Translate());
            _gameData.UserData.Options.DisableTileHighlighting = disableTileHighligthing;

            var disableTileBlinking = _gameData.UserData.Options.DisableTileBlinking;

            ListingStandard.CheckboxLabeled("PLOPT_DisableTileBlinking".Translate(), ref disableTileBlinking,
                                            "PLOPT_DisableTileBlinkingToolTip".Translate());
            _gameData.UserData.Options.DisableTileBlinking = disableTileBlinking;

            // allow to show the debug tile ID on the highlighted tile
            var showDebugTileId = _gameData.UserData.Options.ShowDebugTileId;

            ListingStandard.CheckboxLabeled("PLOPT_ShowDebugTileId".Translate(), ref showDebugTileId,
                                            "PLOPT_ShowDebugTileIdToolTip".Translate());
            _gameData.UserData.Options.ShowDebugTileId = showDebugTileId;

            var bypassMaxHighlightedTiles = _gameData.UserData.Options.BypassMaxHighlightedTiles;
            var msgBypassTileHighlighterMaximumToolTip = string.Format(
                "PLOPT_BypassTileHighlighterMaximumToolTip".Translate(), TileHighlighter.MaxHighlightedTiles);

            ListingStandard.CheckboxLabeled("PLOPT_BypassTileHighlighterMaximum".Translate(), ref bypassMaxHighlightedTiles,
                                            msgBypassTileHighlighterMaximumToolTip);
            _gameData.UserData.Options.BypassMaxHighlightedTiles = bypassMaxHighlightedTiles;
        }
        protected virtual void DrawUsableMinMaxNumericField <T>(UsableMinMaxNumericItem <T> numericItem, string label,
                                                                float min = 0f, float max = 1E+09f) where T : struct, IComparable, IConvertible
        {
            var tmpCheckedOn = numericItem.Use;

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

            var minValue          = numericItem.Min;
            var minValueString    = numericItem.MinString;
            var minValueLabelRect = ListingStandard.GetRect(DefaultElementHeight);

            Widgets.TextFieldNumericLabeled(minValueLabelRect, "Min: ", ref minValue, ref minValueString, min, max);
            numericItem.Min       = minValue;
            numericItem.MinString = minValueString;

            var maxValue          = numericItem.Max;
            var maxValueString    = numericItem.MaxString;
            var maxValueLabelRect = ListingStandard.GetRect(DefaultElementHeight);

            Widgets.TextFieldNumericLabeled(maxValueLabelRect, "Max: ", ref maxValue, ref maxValueString, min, max);
            numericItem.Max       = maxValue;
            numericItem.MaxString = maxValueString;
        }
        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());
        }
        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);
            }
        }
Example #6
0
        private void DrawFilterOptions()
        {
            DrawEntryHeader("PLOPT_FilterOptions".Translate(), backgroundColor: Color.cyan);

            var allowLiveFiltering = _gameData.UserData.Options.AllowLiveFiltering;

            ListingStandard.CheckboxLabeled("PLOPT_AllowLiveFiltering".Translate(), ref allowLiveFiltering,
                                            "PLOPT_AllowLiveFilteringToolTip".Translate());
            _gameData.UserData.Options.AllowLiveFiltering = allowLiveFiltering;

            var allowImpassableHilliness = _gameData.UserData.Options.AllowImpassableHilliness;

            ListingStandard.CheckboxLabeled("PLOPT_AllowImpassableTiles".Translate(), ref allowImpassableHilliness,
                                            "PLOPT_AllowImpassableTilesToolTip".Translate());
            _gameData.UserData.Options.AllowImpassableHilliness = allowImpassableHilliness;

            var disablePreFilterCheck = _gameData.UserData.Options.DisablePreFilterCheck;

            ListingStandard.CheckboxLabeled("PLOPT_DisablePreFilterCheck".Translate(), ref disablePreFilterCheck,
                                            "PLOPT_DisablePreFilterCheckToolTip".Translate());
            _gameData.UserData.Options.DisablePreFilterCheck = disablePreFilterCheck;

            var viewPartialOffNoSelect = _gameData.UserData.Options.ViewPartialOffNoSelect;

            ListingStandard.CheckboxLabeled("PLOPT_ViewPartialOffNoSelect".Translate(), ref viewPartialOffNoSelect,
                                            "PLOPT_ViewPartialOffNoSelectToolTip".Translate());
            _gameData.UserData.Options.ViewPartialOffNoSelect = viewPartialOffNoSelect;

            var resetAllFieldsOnNewGeneratedWorld = _gameData.UserData.Options.ResetAllFieldsOnNewGeneratedWorld;

            ListingStandard.CheckboxLabeled("PLOPT_ResetAllFiltersOnNewWorld".Translate(), ref resetAllFieldsOnNewGeneratedWorld,
                                            "PLOPT_ResetAllFiltersOnNewWorldToolTip".Translate());
            _gameData.UserData.Options.ResetAllFieldsOnNewGeneratedWorld = resetAllFieldsOnNewGeneratedWorld;

            var showFilterHeaviness = _gameData.UserData.Options.ShowFilterHeaviness;

            ListingStandard.CheckboxLabeled("PLOPT_ShowFilterHeaviness".Translate(), ref showFilterHeaviness,
                                            "PLOPT_ShowFilterHeavinessToolTip".Translate());
            _gameData.UserData.Options.ShowFilterHeaviness = showFilterHeaviness;

            var allowInvalidTilesForNewSettlement = _gameData.UserData.Options.AllowInvalidTilesForNewSettlement;

            ListingStandard.CheckboxLabeled("PLOPT_AllowInvalidTilesForNewSettlement".Translate(),
                                            ref allowInvalidTilesForNewSettlement, "PLOPT_AllowInvalidTilesForNewSettlementToolTip".Translate());
            _gameData.UserData.Options.AllowInvalidTilesForNewSettlement = allowInvalidTilesForNewSettlement;
        }
Example #7
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 #8
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);
        }
Example #9
0
        protected virtual void DrawOptions()
        {
            DrawEntryHeader("Filter Options", backgroundColor: Color.cyan);

            var allowLiveFiltering = _userData.Options.AllowLiveFiltering;

            ListingStandard.CheckboxLabeled("Allow Live Filtering", ref allowLiveFiltering,
                                            "[Warning: CPU heavy] Allow filtering without pressing the \"Filter\" button.");
            _userData.Options.AllowLiveFiltering = allowLiveFiltering;

            //TODO: allow unimplemented biomes

            var allowImpassableHilliness = _userData.Options.AllowImpassableHilliness;

            ListingStandard.CheckboxLabeled("Allow Impassable Tiles", ref allowImpassableHilliness,
                                            "Allow selection and filtering of impassable tiles.");
            _userData.Options.AllowImpassableHilliness = allowImpassableHilliness;

            //TODO: allow saving / reading the set of currently applied filters

            // allow to show the debug tile ID on the highlighted tile (instead of 'X')
            var showDebugTileId = _userData.Options.ShowDebugTileId;

            ListingStandard.CheckboxLabeled("Show Debug Tile ID", ref showDebugTileId,
                                            "Show the Debug Tile ID (instead of 'X') for the highlighted tiles.");
            _userData.Options.ShowDebugTileId = showDebugTileId;

            var bypassMaxHighlightedTiles = _userData.Options.BypassMaxHighlightedTiles;

            ListingStandard.CheckboxLabeled("Bypass TileHighlighter Maximum", ref bypassMaxHighlightedTiles,
                                            $"Allow highlighting more than {TileHighlighter.MaxHighlightedTiles} tiles.");
            _userData.Options.BypassMaxHighlightedTiles = bypassMaxHighlightedTiles;

            var disablePreFilterCheck = _userData.Options.DisablePreFilterCheck;

            ListingStandard.CheckboxLabeled("Disable PreFilter Check", ref disablePreFilterCheck,
                                            "Disable the check where Biomes and Terrains must be selected with a world coverage >= 50%.");
            _userData.Options.DisablePreFilterCheck = disablePreFilterCheck;

            var resetAllFieldsOnNewGeneratedWorld = _userData.Options.ResetAllFieldsOnNewGeneratedWorld;

            ListingStandard.CheckboxLabeled("Reset all filters on new world", ref resetAllFieldsOnNewGeneratedWorld,
                                            "If ON, all filters are reset to their default state on a new generated world, otherwise the filters are kept in their previous state.");
            _userData.Options.ResetAllFieldsOnNewGeneratedWorld = resetAllFieldsOnNewGeneratedWorld;

            var disableTileHighligthing = _userData.Options.DisableTileHighlighting;

            ListingStandard.CheckboxLabeled("Disable Tile Highligthing", ref disableTileHighligthing,
                                            "Disable tile highlighting altogether.");
            _userData.Options.DisableTileHighlighting = disableTileHighligthing;

            var disableTileBlinking = _userData.Options.DisableTileBlinking;

            ListingStandard.CheckboxLabeled("Disable Tile Blinking", ref disableTileBlinking,
                                            "Disable tile blinking (\"breathing\") for filtered tiles on the world map.");
            _userData.Options.DisableTileBlinking = disableTileBlinking;

            var showFilterHeaviness = _userData.Options.ShowFilterHeaviness;

            ListingStandard.CheckboxLabeled("Show Filter Heaviness", ref showFilterHeaviness,
                                            "Show filter heaviness (possible filter CPU calculation heaviness) on filter header in the GUI.");
            _userData.Options.ShowFilterHeaviness = showFilterHeaviness;

            var allowInvalidTilesForNewSettlement = _userData.Options.AllowInvalidTilesForNewSettlement;

            ListingStandard.CheckboxLabeled("Allow Invalid Tiles for New Settlement",
                                            ref allowInvalidTilesForNewSettlement,
                                            "If on, this prevents a last pass that would have removed tiles deemed as not valid for a new settlement.");
            _userData.Options.AllowInvalidTilesForNewSettlement = allowInvalidTilesForNewSettlement;

            var goToTileOptionRectSpace = ListingStandard.GetRect(30f);
            var rects = goToTileOptionRectSpace.SplitRectWidth(_goToTileSplitPct);

            Widgets.Label(rects[0], "Go to Tile:");
            Widgets.TextFieldNumeric(rects[1], ref _tileNumber, ref _tileNumberString, -1, 300000);
            if (Widgets.ButtonText(rects[2], "Go!"))
            {
                if ((_tileNumber < 0) || (_tileNumber >= Find.WorldGrid.TilesCount))
                {
                    Messages.Message($"Out of Range: {_tileNumber}; Range: [0, {Find.WorldGrid.TilesCount}).",
                                     MessageSound.RejectInput);
                }
                else
                {
                    Find.WorldInterface.SelectedTile = _tileNumber;
                    Find.WorldCameraDriver.JumpTo(Find.WorldGrid.GetTileCenter(Find.WorldInterface.SelectedTile));
                }
            }
        }