コード例 #1
0
        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;
        }
コード例 #2
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);
        }
コード例 #3
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);
        }
コード例 #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);
        }
コード例 #5
0
        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);
        }
コード例 #6
0
        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);
        }
コード例 #7
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;
        }
コード例 #8
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;
        }
コード例 #9
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
        }
コード例 #10
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.]");
        }
コード例 #11
0
        private void DrawWorldInfo()
        {
            var remSpace = DrawEntryHeader("PLMWINF_WorldInfo".Translate(), backgroundColor: Color.yellow);

            var maxOuterRectHeight = (InRect.height - MainWindow.SpaceForBottomButtons - remSpace) / 2;

            ListingStandard.ScrollableTextArea(maxOuterRectHeight, WorldInfo, ref _scrollPosWorldInfo, _styleWorldInfo,
                                               DefaultScrollableViewShrinkWidth);
        }
コード例 #12
0
ファイル: TabInfo.cs プロジェクト: AzureFox4/PrepareLanding
        private void DrawWorldRecord()
        {
            var currHeight = DrawEntryHeader("PLMWINF_WorldRecords".Translate(), backgroundColor: Color.yellow);

            var maxOuterRectHeight = currHeight - MainWindow.SpaceForBottomButtons - DefaultElementHeight;

            ListingStandard.ScrollableTextArea(maxOuterRectHeight, WolrdRecords, ref _scrollPosWorldRecords, _styleWorldInfo,
                                               DefaultScrollableViewShrinkWidth);
        }
コード例 #13
0
        protected void Begin(Rect inRect)
        {
            InRect = inRect;

            // set up column size
            ListingStandard.ColumnWidth = inRect.width * _columnSizePercent;

            // begin Rect position
            ListingStandard.Begin(InRect);
        }
コード例 #14
0
        protected virtual void DrawCoastalSelection()
        {
            DrawEntryHeader("Coastal Tile", false, backgroundColor: ColorFromFilterSubjectThingDef("Coastal Tiles"));

            var rect          = ListingStandard.GetRect(DefaultElementHeight);
            var tmpCheckState = _userData.ChosenCoastalTileState;

            Widgets.CheckBoxLabeledMulti(rect, "Is Coastal Tile:", ref tmpCheckState);

            _userData.ChosenCoastalTileState = tmpCheckState;
        }
コード例 #15
0
        protected virtual void DrawAnimalsCanGrazeNowSelection()
        {
            DrawEntryHeader("Animals", backgroundColor: ColorFromFilterSubjectThingDef("Animals Can Graze Now"));

            var rect          = ListingStandard.GetRect(DefaultElementHeight);
            var tmpCheckState = _userData.ChosenAnimalsCanGrazeNowState;

            Widgets.CheckBoxLabeledMulti(rect, "Animals Can Graze Now:", ref tmpCheckState);

            _userData.ChosenAnimalsCanGrazeNowState = tmpCheckState;
        }
コード例 #16
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);
        }
コード例 #17
0
        private void DrawAnimalsCanGrazeNowSelection()
        {
            DrawEntryHeader($"{"WorkTagAnimals".Translate().CapitalizeFirst()}",
                            backgroundColor: ColorFromFilterType(typeof(TileFilterAnimalsCanGrazeNow)));

            var rect          = ListingStandard.GetRect(DefaultElementHeight);
            var tmpCheckState = _gameData.UserData.ChosenAnimalsCanGrazeNowState;

            Core.Gui.Widgets.CheckBoxLabeledMulti(rect, $"{"AnimalsCanGrazeNow".Translate()}: ", ref tmpCheckState);

            _gameData.UserData.ChosenAnimalsCanGrazeNowState = tmpCheckState;
        }
コード例 #18
0
        /// <summary>
        ///     Draw the "Has Cave" selection.
        /// </summary>
        private void DrawCaveSelection()
        {
            DrawEntryHeader("SpecialFeatures".Translate(),
                            backgroundColor: ColorFromFilterType(typeof(TileFilterHasCave)));

            var rect          = ListingStandard.GetRect(DefaultElementHeight);
            var tmpCheckState = _gameData.UserData.HasCaveState;

            Core.Gui.Widgets.CheckBoxLabeledMulti(rect, $"{"HasCaves".Translate()}:", ref tmpCheckState);

            _gameData.UserData.HasCaveState = tmpCheckState;
        }
コード例 #19
0
        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);
        }
コード例 #20
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));
            }
        }
コード例 #21
0
        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());
        }
コード例 #22
0
        protected void NewColumn(bool drawVerticalSeparator = false)
        {
            ListingStandard.NewColumn();
            if (!drawVerticalSeparator)
            {
                return;
            }

            // draw vertical separator
            var rect = ListingStandard.VirtualRect(InRect.height - DefaultElementHeight - 5f);

            rect.x    -= Listing.ColumnSpacing / 2f;
            rect.width = 1f;
            GUI.DrawTexture(rect, BaseContent.WhiteTex);
        }
コード例 #23
0
        protected virtual void DrawWorldInfo()
        {
            DrawEntryHeader("World Info", backgroundColor: Color.yellow);

            var maxHeight    = InRect.height - ListingStandard.CurHeight - 30f;
            var scrollHeight = Text.CalcHeight(WorldInfo, ListingStandard.ColumnWidth);

            scrollHeight = Mathf.Max(maxHeight, scrollHeight);

            var innerLs = ListingStandard.BeginScrollView(maxHeight, scrollHeight, ref _scrollPosWorldInfo);

            GUI.TextField(innerLs.GetRect(maxHeight), WorldInfo, _styleWorldInfo);

            ListingStandard.EndScrollView(innerLs);
        }
コード例 #24
0
        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);
            }
        }
コード例 #25
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;
        }
コード例 #26
0
        private void DrawTemperatureSelection()
        {
            DrawEntryHeader("Temperature", backgroundColor: ColorLibrary.RoyalPurple);

            var averageTemperature = _gameData.GodModeData.AverageTemperature;

            _chosenAverageTemperatureString = averageTemperature.ToString("F1", CultureInfo.InvariantCulture);

            var temperatureRectSpace = ListingStandard.GetRect(DefaultElementHeight);

            Widgets.Label(temperatureRectSpace.LeftPart(0.8f),
                          $"Avg. Temp. (°C) [{TemperatureTuning.MinimumTemperature}, {TemperatureTuning.MaximumTemperature}]");
            Widgets.TextFieldNumeric(temperatureRectSpace.RightPart(0.2f), ref averageTemperature,
                                     ref _chosenAverageTemperatureString, TemperatureTuning.MinimumTemperature,
                                     TemperatureTuning.MaximumTemperature);

            _gameData.GodModeData.AverageTemperature = averageTemperature;
        }
コード例 #27
0
        private void DrawRainfallSelection()
        {
            DrawEntryHeader("Rainfall", backgroundColor: ColorLibrary.RoyalPurple);

            // min is obviously 0; max is defined in RimWorld.Planet.WorldGenStep_Terrain.RainfallFinishFallAltitude
            const float minRainfall = 0f;
            const float maxRainfall = 7000f;

            var rainFall = _gameData.GodModeData.Rainfall;

            _chosenRainfallString = rainFall.ToString("F1", CultureInfo.InvariantCulture);

            var rainfallRectSpace = ListingStandard.GetRect(DefaultElementHeight);

            Widgets.Label(rainfallRectSpace.LeftPart(0.8f), $"Rainfall (mm) [{minRainfall}, {maxRainfall}]");
            Widgets.TextFieldNumeric(rainfallRectSpace.RightPart(0.2f), ref rainFall,
                                     ref _chosenRainfallString, minRainfall, maxRainfall);

            _gameData.GodModeData.Rainfall = rainFall;
        }
コード例 #28
0
        private void DrawElevationSelection()
        {
            DrawEntryHeader("Elevation", backgroundColor: ColorLibrary.RoyalPurple);

            // see RimWorld.Planet.WorldGenStep_Terrain.ElevationRange for min / max
            // max is also defined in RimWorld.Planet.WorldMaterials.ElevationMax
            const float minElevation = -500f;
            const float maxElevation = 5000f;

            var elevation = _gameData.GodModeData.Elevation;

            _chosenElevationString = elevation.ToString("F1", CultureInfo.InvariantCulture);

            var elevationRectSpace = ListingStandard.GetRect(DefaultElementHeight);

            Widgets.Label(elevationRectSpace.LeftPart(0.8f), $"Elevation (m) [{minElevation}, {maxElevation}]");
            Widgets.TextFieldNumeric(elevationRectSpace.RightPart(0.2f), ref elevation,
                                     ref _chosenElevationString, minElevation, maxElevation);

            _gameData.GodModeData.Elevation = elevation;
        }
コード例 #29
0
        private void DrawTemperatureSelection()
        {
            DrawEntryHeader("Temperature", backgroundColor: ColorLibrary.RoyalPurple);

            // min and max possible temperatures, in C/F/K (depending on user preferences).
            // note that TemperatureTuning temps are in Celsius.
            var tempMinUnit = GenTemperature.CelsiusTo(TemperatureTuning.MinimumTemperature, Prefs.TemperatureMode);
            var tempMaxUnit = GenTemperature.CelsiusTo(TemperatureTuning.MaximumTemperature, Prefs.TemperatureMode);

            var averageTemperature = _gameData.GodModeData.AverageTemperature;

            _chosenAverageTemperatureString = averageTemperature.ToString("F1", CultureInfo.InvariantCulture);

            var temperatureRectSpace = ListingStandard.GetRect(DefaultElementHeight * 1.25f);

            Widgets.Label(temperatureRectSpace.LeftPart(0.8f),
                          $"{"AvgTemp".Translate()} (°{Prefs.TemperatureMode.ToStringHuman()})\n[{tempMinUnit}, {tempMaxUnit}]");
            Widgets.TextFieldNumeric(temperatureRectSpace.RightPart(0.2f), ref averageTemperature,
                                     ref _chosenAverageTemperatureString, tempMinUnit, tempMaxUnit);

            _gameData.GodModeData.AverageTemperature = averageTemperature;
        }
コード例 #30
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);
        }