public static Dictionary <string, Scenario> AllScenarios() { var res = new Dictionary <string, Scenario>(); ScenarioLister.AllScenarios().ToList(); foreach (ScenarioDef allDef in DefDatabase <ScenarioDef> .AllDefs) { if (!res.ContainsKey(allDef.defName)) { res.Add(allDef.defName, allDef.scenario); } } foreach (Scenario item in ScenarioFiles.AllScenariosLocal) { if (!res.ContainsKey(item.fileName)) { res.Add(item.fileName, item); } } foreach (Scenario item2 in ScenarioFiles.AllScenariosWorkshop) { if (!res.ContainsKey(item2.fileName)) { res.Add(item2.fileName, item2); } } return(res); }
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); }
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 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; } }
private static Scenario TryGetScenarioByName(string name) { return(ScenarioLister.AllScenarios().FirstOrDefault(s => s.name == name)); }