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);
        }
Exemplo n.º 2
0
        private void MakeSelectScenarioButton(Listing_Standard sub, QuickstartSettings settings)
        {
            var selected = settings.ScenarioToGen;

            if (sub.ButtonText(selected ?? "Select a scenario"))
            {
                var menu = new FloatMenu(DefDatabase <ScenarioDef> .AllDefs.Select(s => {
                    return(new FloatMenuOption(s.label, () => { settings.ScenarioToGen = s.defName; }));
                }).ToList());
                Find.WindowStack.Add(menu);
            }
        }
        private void MakeSelectScenarioButton(Listing_Standard sub, QuickstartSettings settings)
        {
            var selected = settings.ScenarioToGen;

            if (sub.ButtonText(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);
            }
        }
        private void MakeSelectMapSizeButton(Listing_Standard sub, QuickstartSettings settings)
        {
            var allSizes = QuickstartController.MapSizes;
            var selected = allSizes.Select(s => s.Size == settings.MapSizeToGen ? s.Label : null).FirstOrDefault(s => s != null);

            if (sub.ButtonText(selected ?? "Select a map size"))
            {
                var menu = new FloatMenu(allSizes.Select(s => {
                    return(new FloatMenuOption(s.Label, () => { settings.MapSizeToGen = s.Size; }));
                }).ToList());
                Find.WindowStack.Add(menu);
            }
        }
 private void EnsureSettingsHaveValidFiles(QuickstartSettings settings)
 {
     // make sure our settings are referencing loadable files
     if (saveFiles.Select(s => s.Name).All(s => s != settings.SaveFileToLoad))
     {
         settings.SaveFileToLoad = null;
     }
     if (settings.ScenarioToGen != null && ScenarioLister.AllScenarios().All(s => s.name != settings.ScenarioToGen))
     {
         settings.ScenarioToGen = null;
     }
     if (settings.ScenarioToGen == null)
     {
         settings.ScenarioToGen = ScenarioDefOf.Crashlanded.defName;
     }
 }
Exemplo n.º 6
0
 private void EnsureSettingsHaveValidFiles(QuickstartSettings settings)
 {
     // make sure our settings are referencing loadable files
     if (saveFiles.Select(s => s.Name).All(s => s != settings.SaveFileToLoad))
     {
         settings.SaveFileToLoad = null;
     }
     if (settings.ScenarioToGen != null && DefDatabase <ScenarioDef> .GetNamedSilentFail(settings.ScenarioToGen) == null)
     {
         settings.ScenarioToGen = null;
     }
     if (settings.ScenarioToGen == null)
     {
         settings.ScenarioToGen = ScenarioDefOf.Crashlanded.defName;
     }
 }
Exemplo n.º 7
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 IEnumerable <FloatMenuOption> GetSaveFileFloatMenuOptions(QuickstartSettings settings)
        {
            const float VersionLabelOffset = 10f;

            return(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;
                }
                                           );
            }));
        }
        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));
            }
        }
Exemplo n.º 10
0
        private void MakeSelectSaveButton(Listing_Standard sub, QuickstartSettings settings)
        {
            const float VersionLabelOffset = 10f;
            var         selected           = settings.SaveFileToLoad;

            if (sub.ButtonText(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);
            }
        }
        private void OperationModeRadioButton(Listing_Standard listing, float labelInset, string label, QuickstartSettings settings, QuickstartSettings.QuickstartMode assignedMode, string tooltip)
        {
            const float labelTopMargin = -4f;
            const float fontSize       = 16f;
            float       lineHeight     = Text.LineHeight;
            var         entryRect      = listing.GetRect(lineHeight + listing.verticalSpacing);
            var         labelRect      = new Rect(entryRect.x + labelInset, entryRect.y + labelTopMargin, entryRect.width - labelInset, entryRect.height - labelTopMargin);
            var         rowRect        = new Rect(entryRect.x, entryRect.y, entryRect.width, entryRect.height);

            if (tooltip != null)
            {
                if (Mouse.IsOver(rowRect))
                {
                    Widgets.DrawHighlight(rowRect);
                }
                TooltipHandler.TipRegion(rowRect, tooltip);
            }
            if (Widgets.ButtonInvisible(rowRect))
            {
                if (settings.OperationMode != assignedMode)
                {
                    SoundDefOf.Click.PlayOneShotOnCamera();
                    QuickstartController.Settings.OperationMode = assignedMode;
                }
            }
            Widgets.RadioButton(entryRect.x, entryRect.y, settings.OperationMode == assignedMode);

            Text.Font = GameFont.Medium;
            var emphasizedLabel = string.Format("<size={0}>{1}</size>", fontSize, label);

            Widgets.Label(labelRect, emphasizedLabel);
            Text.Font = GameFont.Small;
        }
Exemplo n.º 12
0
 // ensure that the settings have a valid map size
 private static void SnapSettingsMapSizeToClosestValue(QuickstartSettings settings, List <MapSizeEntry> sizes)
 {
     Settings.MapSizeToGen = sizes.OrderBy(e => Mathf.Abs(e.Size - settings.MapSizeToGen)).First().Size;
 }