private static bool game_menu_orphanage_adopt_on_condition(MenuCallbackArgs args) { args.optionLeaveType = GameMenuOption.LeaveType.Recruit; var canAdopt = OrphanAdoptionHelper.ChildrenForAdoptionAtSettlement(Hero.MainHero.CurrentSettlement).Any(); // ReSharper disable once InvertIf if (!canAdopt) { args.Tooltip = new TextObject("There is no one here."); args.IsEnabled = false; } return(true); }
private static void ShowChildrenToAdopt() { var currentSettlement = Hero.MainHero.CurrentSettlement; var lostChildren = OrphanAdoptionHelper.ChildrenForAdoptionAtSettlement(currentSettlement); var inquiryElements = new List <InquiryElement>(); foreach (var hero in lostChildren) { var identifier = new ImageIdentifier(CharacterCode.CreateFrom(hero.CharacterObject)); inquiryElements.Add(new InquiryElement(hero, hero.Name + " - " + Math.Floor(hero.BirthDay.ElapsedYearsUntilNow), identifier)); } if (inquiryElements.Count < 1) { InformationManager.ShowInquiry( new InquiryData("No child", "Empty orphanage", true, false, "OK", "", null, null), true); GameMenu.SwitchToMenu("town"); } else { InformationManager.ShowMultiSelectionInquiry(new MultiSelectionInquiryData( "Children you may adopt", "", inquiryElements, true, 1, "Continue", null, args => { if (args == null) { return; } if (!args.Any()) { return; } InformationManager.HideInquiry(); ConfirmAdoption(args.Select(element => element.Identifier as Hero).First()); }, null)); } }