private void MakeSelectScenarioButton(Listing_Standard sub, QuickstartSettings settings)
        {
            const float GenerateNowWidth  = 120f;
            const float HorizontalSpacing = 6f;
            const float ButtonHeight      = 30f;
            var         buttonRect        = sub.GetRect(ButtonHeight);
            var         leftHalf          = new Rect(buttonRect)
            {
                xMax = buttonRect.xMax - (GenerateNowWidth + HorizontalSpacing)
            };
            var rightHalf = new Rect(buttonRect)
            {
                xMin = buttonRect.xMin + leftHalf.width + HorizontalSpacing
            };
            var selected = settings.ScenarioToGen;

            if (Widgets.ButtonText(leftHalf, selected ?? "Select a scenario"))
            {
                var menu = new FloatMenu(ScenarioLister.AllScenarios().Select(s => {
                    return(new FloatMenuOption(s.name, () => { settings.ScenarioToGen = s.name; }));
                }).ToList());
                Find.WindowStack.Add(menu);
            }
            if (Widgets.ButtonText(rightHalf, "Generate now"))
            {
                if (HugsLibUtility.ShiftIsHeld)
                {
                    settings.OperationMode = QuickstartSettings.QuickstartMode.GenerateMap;
                }
                QuickstartController.InitateMapGeneration();
                Close();
            }
            sub.Gap(sub.verticalSpacing);
        }
Exemple #2
0
        private void MakeSelectSaveButton(Listing_Standard sub, QuickstartSettings settings)
        {
            const float VersionLabelOffset = 10f;
            const float LoadNowWidth       = 120f;
            const float HorizontalSpacing  = 6f;
            const float ButtonHeight       = 30f;
            var         selected           = settings.SaveFileToLoad;
            var         buttonRect         = sub.GetRect(ButtonHeight);
            var         leftHalf           = new Rect(buttonRect)
            {
                xMax = buttonRect.xMax - (LoadNowWidth + HorizontalSpacing)
            };
            var rightHalf = new Rect(buttonRect)
            {
                xMin = buttonRect.xMin + leftHalf.width + HorizontalSpacing
            };

            if (Widgets.ButtonText(leftHalf, selected ?? "Select a save file"))
            {
                var menu = new FloatMenu(saveFiles.Select(s => {
                    return(new FloatMenuOption(s.Label, () => { settings.SaveFileToLoad = s.Name; }, MenuOptionPriority.Default, null, null, Text.CalcSize(s.VersionLabel).x + VersionLabelOffset,
                                               rect => {
                        var prevColor = GUI.color;
                        GUI.color = s.FileInfo.VersionColor;
                        Text.Anchor = TextAnchor.MiddleLeft;
                        Widgets.Label(new Rect(rect.x + VersionLabelOffset, rect.y, 200f, rect.height), s.VersionLabel);
                        Text.Anchor = TextAnchor.UpperLeft;
                        GUI.color = prevColor;
                        return false;
                    }
                                               ));
                }).ToList());
                Find.WindowStack.Add(menu);
            }
            if (Widgets.ButtonText(rightHalf, "Load now"))
            {
                if (!HugsLibUtility.ShiftIsHeld)
                {
                    settings.OperationMode = QuickstartSettings.QuickstartMode.LoadMap;
                }
                QuickstartController.InitateSaveLoading();
                Close();
            }
            sub.Gap(sub.verticalSpacing);
        }
        private void MakeSelectSaveButton(Listing_Standard sub, QuickstartSettings settings)
        {
            const float  LoadNowWidth        = 120f;
            const float  HorizontalSpacing   = 6f;
            const float  ButtonHeight        = 30f;
            const string LatestSaveFileLabel = "Most recent save file";
            var          buttonRect          = sub.GetRect(ButtonHeight);
            var          leftHalf            = new Rect(buttonRect)
            {
                xMax = buttonRect.xMax - (LoadNowWidth + HorizontalSpacing)
            };
            var rightHalf = new Rect(buttonRect)
            {
                xMin = buttonRect.xMin + leftHalf.width + HorizontalSpacing
            };
            var selectedSaveLabel = settings.SaveFileToLoad ?? LatestSaveFileLabel;

            if (Widgets.ButtonText(leftHalf, selectedSaveLabel))
            {
                ShowSaveFileSelectionFloatMenu();
            }
            if (Widgets.ButtonText(rightHalf, "Load now"))
            {
                if (HugsLibUtility.ShiftIsHeld)
                {
                    settings.OperationMode = QuickstartSettings.QuickstartMode.LoadMap;
                }
                QuickstartController.InitateSaveLoading();
                Close();
            }
            sub.Gap(sub.verticalSpacing);

            void ShowSaveFileSelectionFloatMenu()
            {
                var options = new List <FloatMenuOption> {
                    new FloatMenuOption(LatestSaveFileLabel, () => settings.SaveFileToLoad = null)
                };

                options.AddRange(GetSaveFileFloatMenuOptions(settings));
                Find.WindowStack.Add(new FloatMenu(options));
            }
        }
 public override void PostClose()
 {
     QuickstartController.SaveSettings();
 }
Exemple #5
0
        public override void DoWindowContents(Rect inRect)
        {
            const float  categoryPadding      = 10f;
            const float  categoryInset        = 30f;
            const float  radioLabelInset      = 40f;
            const float  mainListingSpacing   = 6f;
            const float  subListingSpacing    = 6f;
            const float  subListingLabelWidth = 100f;
            const float  subListingRowHeight  = 30f;
            const float  checkboxListingWidth = 280f;
            const float  listingColumnSpacing = 17f;
            const string shiftTip             = "Hold Shift while starting up to prevent the quickstart.";
            var          settings             = QuickstartController.Settings;
            var          mainListing          = new Listing_Standard();

            mainListing.verticalSpacing = mainListingSpacing;
            mainListing.Begin(inRect);
            Text.Font = GameFont.Medium;
            mainListing.Label("Quickstart settings");
            Text.Font = GameFont.Small;
            mainListing.GapLine();
            mainListing.Gap();
            OperationModeRadioButton(mainListing, radioLabelInset, "Quickstart off", settings, QuickstartSettings.QuickstartMode.Disabled,
                                     "Quickstart functionality is disabled.\nThe game starts normally.");
            OperationModeRadioButton(mainListing, radioLabelInset, "Quickstart: load save file", settings, QuickstartSettings.QuickstartMode.LoadMap,
                                     "Load the selected saved game right after launch.\n" + shiftTip);
            var expectedHeight = categoryPadding * 2 + (subListingRowHeight + subListingSpacing) * 1;

            MakeSubListing(mainListing, 0, expectedHeight, categoryPadding, categoryInset, subListingSpacing, (sub, width) => {
                sub.ColumnWidth = subListingLabelWidth;
                Text.Anchor     = TextAnchor.MiddleLeft;
                var rect        = sub.GetRect(subListingRowHeight);
                Widgets.Label(rect, "Save file:");
                Text.Anchor = TextAnchor.UpperLeft;
                sub.NewColumn();
                sub.ColumnWidth = width - subListingLabelWidth - listingColumnSpacing;
                MakeSelectSaveButton(sub, settings);
            });
            OperationModeRadioButton(mainListing, radioLabelInset, "Quickstart: generate map", settings, QuickstartSettings.QuickstartMode.GenerateMap,
                                     "Generate a new map right after launch.\nWorks the same as using the \"quicktest\" command line option.\n" + shiftTip);
            expectedHeight = categoryPadding * 2 + (subListingRowHeight + subListingSpacing) * 2;
            MakeSubListing(mainListing, 0, expectedHeight, categoryPadding, categoryInset, subListingSpacing, (sub, width) => {
                sub.ColumnWidth = subListingLabelWidth;
                Text.Anchor     = TextAnchor.MiddleLeft;
                var rect        = sub.GetRect(subListingRowHeight);
                Widgets.Label(rect, "Scenario:");
                rect = sub.GetRect(subListingRowHeight);
                Widgets.Label(rect, "Map size:");
                Text.Anchor = TextAnchor.UpperLeft;
                sub.NewColumn();
                sub.ColumnWidth = width - subListingLabelWidth - listingColumnSpacing;
                MakeSelectScenarioButton(sub, settings);
                MakeSelectMapSizeButton(sub, settings);
            });
            expectedHeight = categoryPadding * 2 + (subListingRowHeight + subListingSpacing) * 3;
            MakeSubListing(mainListing, checkboxListingWidth, expectedHeight, categoryPadding, 0f, subListingSpacing, (sub, width) => {
                sub.CheckboxLabeled("Abort quickstart on error", ref settings.StopOnErrors, "Prevent quickstart if errors are detected during startup.");
                sub.CheckboxLabeled("Abort quickstart on warning", ref settings.StopOnWarnings, "Prevent quickstart if warnings are detected during startup.");
                sub.CheckboxLabeled("Ignore version & mod config mismatch", ref settings.BypassSafetyDialog, "Skip the mod config mismatch dialog and load all saved games regardless.");
            });
            mainListing.End();
            Text.Anchor = TextAnchor.UpperLeft;

            var btnSize      = new Vector2(180f, 40f);
            var buttonYStart = inRect.height - btnSize.y;

            if (Widgets.ButtonText(new Rect(inRect.x, buttonYStart, btnSize.x, btnSize.y), "Generate map now"))
            {
                Close();
                QuickstartController.InitateMapGeneration();
            }
            if (Widgets.ButtonText(new Rect(inRect.width - btnSize.x, buttonYStart, btnSize.x, btnSize.y), "Close"))
            {
                Close();
            }
        }