コード例 #1
0
        private void selectTroops()
        {
            List <InquiryElement> troopElements = new List <InquiryElement>();

            foreach (CharacterObject troop in allTroops)
            {
                CharacterCode charCode = CharacterCode.CreateFrom(troop);
                troopElements.Add(new InquiryElement(troop, troop.Name.ToString(), new ImageIdentifier(charCode)));
            }

            InformationManager.ShowMultiSelectionInquiry(new MultiSelectionInquiryData(
                                                             new TextObject("Select Troop").ToString(),
                                                             new TextObject("Select The Troop Type").ToString(),
                                                             troopElements,
                                                             true,
                                                             1,
                                                             new TextObject("Next").ToString(),
                                                             new TextObject("Cancle").ToString(),
                                                             (troop) =>
            {
                getCount((CharacterObject)troop.First().Identifier);
            },
                                                             null
                                                             ), true);
        }
コード例 #2
0
        public HeroAdminHeroSelectorItemVM(Hero hero, Action <HeroAdminHeroSelectorItemVM> action)
        {
            this._hero = hero;
            this._onSelectedHeroAction = action;
            CharacterCode characterCode = CharacterCode.CreateFrom(hero.CharacterObject);

            this.Visual = new ImageIdentifierVM(characterCode);
        }
コード例 #3
0
        public MemberItemVM(Hero hero, Action <MemberItemVM> onCharacterSelect)
        {
            this._hero = hero;
            this._onCharacterSelect = onCharacterSelect;
            CharacterCode characterCode = CharacterCode.CreateFrom(hero.CharacterObject);

            this.Visual = new ImageIdentifierVM(characterCode);
            //this.IsFamilyMember = Hero.MainHero.Clan.Nobles.Contains(this._hero);
            this.Banner_9 = new ImageIdentifierVM(BannerCode.CreateFrom(hero.ClanBanner), true);
            this.RefreshValues();
        }
コード例 #4
0
 // The original method is async, but the problem spot is not, so...
 public static void Postfix(ImageIdentifierTextureProvider __instance, string id, int typeAsInt, string additionalArgs, ref CharacterCode ____characterCode, ref bool ____creatingTexture)
 {
     if (!string.IsNullOrEmpty(id) && typeAsInt == 5)
     {
         CharacterCode from = CharacterCode.CreateFrom(id);
         ____characterCode = from;
         if (TaleWorlds.Core.FaceGen.GetMaturityTypeWithAge(from.BodyProperties.Age) <= BodyMeshMaturityType.Child && from.BodyProperties.Age >= 3)
         {
             ____creatingTexture = true;
             TableauCacheManager.Current.BeginCreateCharacterTexture(from, new Action <Texture>(__instance.OnTextureCreated), __instance.IsBig);
         }
     }
 }
コード例 #5
0
        public WangLordItemVM(Hero hero, Action <WangLordItemVM> onCharacterSelect)
        {
            _hero = hero;
            _onCharacterSelect = onCharacterSelect;
            CharacterCode characterCode = CharacterCode.CreateFrom(hero.CharacterObject);

            Visual    = new ImageIdentifierVM(characterCode);
            Skills    = new MBBindingList <EncyclopediaSkillVM>();
            Traits    = new MBBindingList <EncyclopediaTraitItemVM>();
            Banner_9  = new ImageIdentifierVM(BannerCode.CreateFrom(hero.ClanBanner), nineGrid: true);
            HeroModel = new HeroViewModel();
            HeroModel.FillFrom(_hero);
            RefreshValues();
        }
コード例 #6
0
        private void ExecuteRangedCavalryTypeSelection()
        {
            if (!Game.Current.IsDevelopmentMode)
            {
                return;
            }
            List <InquiryElement> inquiryElements = new List <InquiryElement>();

            foreach (BasicCharacterObject rangedCavalryType in this._rangedCavalryTypes)
            {
                ImageIdentifier imageIdentifier = new ImageIdentifier(CharacterCode.CreateFrom(rangedCavalryType));
                inquiryElements.Add(new InquiryElement((object)rangedCavalryType, rangedCavalryType.Name.ToString(), imageIdentifier));
            }
            InformationManager.ShowMultiSelectionInquiry(new MultiSelectionInquiryData("Ranged Cavalry Troop Types", string.Empty, inquiryElements, true, -1, "Done", "", new Action <List <InquiryElement> >(this.OnRangedCavalryTypeSelectionOver), new Action <List <InquiryElement> >(this.OnRangedCavalryTypeSelectionOver)));
        }
コード例 #7
0
        private void ExecuteRangedCavalryTypeSelection()
        {
            if (!Game.Current.IsDevelopmentMode)
            {
                return;
            }
            List <InquiryElement> inquiryElementList = new List <InquiryElement>();

            using (List <BasicCharacterObject> .Enumerator enumerator = this._rangedCavalryTypes.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    BasicCharacterObject current         = enumerator.Current;
                    ImageIdentifier      imageIdentifier = new ImageIdentifier(CharacterCode.CreateFrom(current));
                    inquiryElementList.Add(new InquiryElement((object)current, ((object)current.Name).ToString(), imageIdentifier));
                }
            }
            InformationManager.ShowMultiSelectionInquiry(new MultiSelectionInquiryData("Ranged Cavalry Troop Types", string.Empty, inquiryElementList, true, false, "Done", "", new Action <List <InquiryElement> >(this.OnRangedCavalryTypeSelectionOver), new Action <List <InquiryElement> >(this.OnRangedCavalryTypeSelectionOver), ""), false);
        }
        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));
            }
        }
コード例 #9
0
        // all of this is really really bad but idc
        public static List <InquiryElement> AssemblePatrolSizes(PatrolData dat)
        {
            MBObjectManager       objManager = Game.Current.ObjectManager;
            List <InquiryElement> list       = new List <InquiryElement>();

            CharacterObject ch1 = objManager.GetObject <CharacterObject>("looter");
            CharacterObject ch2 = objManager.GetObject <CharacterObject>("imperial_recruit");
            CharacterObject ch3 = objManager.GetObject <CharacterObject>("imperial_infantryman");
            CharacterObject ch4 = objManager.GetObject <CharacterObject>("imperial_veteran_infantryman");

            if (dat.sizes.Contains("small"))
            {
                list.Add(new InquiryElement(dat, "Small " + "(" + dat.basePrice.ToString() + " gold)", new ImageIdentifier(CharacterCode.CreateFrom(ch1))));
            }
            if (dat.sizes.Contains("medium"))
            {
                if (Hero.MainHero.Gold >= dat.basePrice + dat.priceStep)
                {
                    list.Add(new InquiryElement(dat, "Medium " + "(" + (dat.basePrice + dat.priceStep).ToString() + " gold)", new ImageIdentifier(CharacterCode.CreateFrom(ch2))));
                }
                else
                {
                    list.Add(new InquiryElement(dat, "Medium " + "(" + (dat.basePrice + dat.priceStep).ToString() + " gold)", new ImageIdentifier(CharacterCode.CreateFrom(ch2)), false, "You do not have enough gold to purchase this size"));
                }
            }
            if (dat.sizes.Contains("large"))
            {
                if (Hero.MainHero.Gold >= dat.basePrice + (dat.priceStep * 2))
                {
                    list.Add(new InquiryElement(dat, "Large " + "(" + (dat.basePrice + (dat.priceStep * 2)).ToString() + " gold)", new ImageIdentifier(CharacterCode.CreateFrom(ch3))));
                }
                else
                {
                    list.Add(new InquiryElement(dat, "Large " + "(" + (dat.basePrice + (dat.priceStep * 2)).ToString() + " gold)", new ImageIdentifier(CharacterCode.CreateFrom(ch3)), false, "You do not have enough gold to purchase this size"));
                }
            }
            if (dat.sizes.Contains("huge"))
            {
                if (Hero.MainHero.Gold >= dat.basePrice + (dat.priceStep * 3))
                {
                    list.Add(new InquiryElement(dat, "Large " + "(" + (dat.basePrice + (dat.priceStep * 3)).ToString() + " gold)", new ImageIdentifier(CharacterCode.CreateFrom(ch4))));
                }
                else
                {
                    list.Add(new InquiryElement(dat, "Large " + "(" + (dat.basePrice + (dat.priceStep * 3)).ToString() + " gold)", new ImageIdentifier(CharacterCode.CreateFrom(ch4)), false, "You do not have enough gold to purchase this size"));
                }
            }

            if (list.Count == 0)
            {
                throw new Exception("Assembling sizes of patrol {" + dat.templateName + "} failed");
            }
            else
            {
                return(list);
            }
        }
コード例 #10
0
        private void ExecuteAssignGovernor()
        {
            if (this.CurrentSelectedFief == null)
            {
                return;
            }
            List <InquiryElement> inquiryElements = new List <InquiryElement>();

            foreach (Hero hero in this._faction.Heroes.Where <Hero>((Func <Hero, bool>)(h => !h.IsDisabled)).Union <Hero>((IEnumerable <Hero>) this._faction.Companions))
            {
                if (hero.IsActive && !hero.IsChild)
                {
                    if (hero.PartyBelongedToAsPrisoner != null)
                    {
                        string hint = new TextObject("{=knwId8DG}You cannot assign a prisoner as a governor of a settlement", (Dictionary <string, TextObject>)null).ToString();
                        inquiryElements.Add(new InquiryElement((object)hero, hero.Name.ToString(), new ImageIdentifier(CharacterCode.CreateFrom((BasicCharacterObject)hero.CharacterObject)), false, hint));
                    }
                    else if (hero == Hero.MainHero)
                    {
                        string hint = new TextObject("{=uoDuiBZR}You cannot assign yourself as a governor", (Dictionary <string, TextObject>)null).ToString();
                        inquiryElements.Add(new InquiryElement((object)hero, hero.Name.ToString(), new ImageIdentifier(CharacterCode.CreateFrom((BasicCharacterObject)hero.CharacterObject)), false, hint));
                    }
                    else if (hero.PartyBelongedTo != null && hero.PartyBelongedTo.LeaderHero == hero)
                    {
                        string hint = new TextObject("{=pWObBhj5}You cannot assign a party leader as a new governor of a settlement", (Dictionary <string, TextObject>)null).ToString();
                        inquiryElements.Add(new InquiryElement((object)hero, hero.Name.ToString(), new ImageIdentifier(CharacterCode.CreateFrom((BasicCharacterObject)hero.CharacterObject)), false, hint));
                    }
                    else if (hero.GovernorOf != null)
                    {
                        TextObject textObject = new TextObject("{=YbGu9rSH}This character is already the governor of {SETTLEMENT_NAME}", (Dictionary <string, TextObject>)null);
                        textObject.SetTextVariable("SETTLEMENT_NAME", hero.GovernorOf.Name);
                        inquiryElements.Add(new InquiryElement((object)hero, hero.Name.ToString(), new ImageIdentifier(CharacterCode.CreateFrom((BasicCharacterObject)hero.CharacterObject)), false, textObject.ToString()));
                    }
                    else
                    {
                        inquiryElements.Add(new InquiryElement((object)hero, hero.Name.ToString(), new ImageIdentifier(CharacterCode.CreateFrom((BasicCharacterObject)hero.CharacterObject))));
                    }
                }
            }
            if (inquiryElements.Count > 0)
            {
                string title = new TextObject("{=koX9okuG}None", (Dictionary <string, TextObject>)null).ToString();
                inquiryElements.Add(new InquiryElement((object)null, title, new ImageIdentifier(ImageIdentifierType.Null)));
                InformationManager.ShowMultiSelectionInquiry(new MultiSelectionInquiryData(new TextObject("{=PAUsUq4Z}Select the Leader of the Settlement", (Dictionary <string, TextObject>)null).ToString(), string.Empty, inquiryElements, true, true, GameTexts.FindText("str_done", (string)null).ToString(), "", new Action <List <InquiryElement> >(this.OnGovernorSelectionOver), new Action <List <InquiryElement> >(this.OnGovernorSelectionOver), ""), false);
            }
            else
            {
                InformationManager.AddQuickInformation(new TextObject("{=JzrodcIR}There is no one available in your clan who can govern this settlement right now.", (Dictionary <string, TextObject>)null), 0, (BasicCharacterObject)null, "");
            }
        }
コード例 #11
0
        public static void game_menu_cps_town_courier_missive_on_consequence(MenuCallbackArgs args)
        {
            // TODO: select recipient and type of missive
            //ImageIdentifierType.Character

            var contacts = PostalServiceModel.GetValidMissiveRecipients(Hero.MainHero);
            var elements = (from c in contacts select new InquiryElement(c.StringId, c.Name.ToString(), new ImageIdentifier(CharacterCode.CreateFrom(c.CharacterObject)))).DefaultIfEmpty().ToList();

            InformationManager.ShowMultiSelectionInquiry(new MultiSelectionInquiryData("Send Missive", "To whom should we deliver this missive?", elements, true, true,
                                                                                       "Send", "Cancel", OnSendMissive, (List <InquiryElement> r) => { }));
        }
コード例 #12
0
        private void TakeCompanion()
        {
            List <InquiryElement> inquiryElements = new List <InquiryElement>();
            ToolMaker             toolMaker;

            if (!ToolMakers.TryGetValue(Settlement.CurrentSettlement.Town, out toolMaker))
            {
                GameMenu.SwitchToMenu("town");
                return;
            }
            foreach (TroopRosterElement troop in toolMaker.Assistants)
            {
                if (troop.Character.IsHero)
                {
                    inquiryElements.Add(new InquiryElement((object)troop.Character.HeroObject, troop.Character.HeroObject.Name.ToString(), new ImageIdentifier(CharacterCode.CreateFrom((BasicCharacterObject)troop.Character.HeroObject.CharacterObject))));
                }
            }
            if (inquiryElements.Count < 1)
            {
                GameMenu.SwitchToMenu("town");
                return;
            }
            else
            {
                InformationManager.ShowMultiSelectionInquiry(new MultiSelectionInquiryData("", "Select companions to take to party", inquiryElements, true, 1000, "Continue", (string)null, (Action <List <InquiryElement> >)(args =>
                {
                    List <InquiryElement> source = args;
                    if (source != null && !source.Any <InquiryElement>())
                    {
                        return;
                    }
                    InformationManager.HideInquiry();

                    IEnumerable <Hero> selected = args.Select <InquiryElement, Hero>((Func <InquiryElement, Hero>)(element => element.Identifier as Hero));
                    foreach (Hero hero in selected)
                    {
                        hero.RemoveEventFromOccupiedHero("tool_making");
                        toolMaker.Assistants.AddToCounts(hero.CharacterObject, -1);
                        Hero.MainHero.PartyBelongedTo.MemberRoster.AddToCounts(hero.CharacterObject, 1);
                    }
                    GameMenu.SwitchToMenu("town");
                }), (Action <List <InquiryElement> >)null));
            }
        }
コード例 #13
0
        private void TransferSettlement()
        {
            List <InquiryElement> inquiryElements = new List <InquiryElement>();

            foreach (Clan clan in Settlement.CurrentSettlement.OwnerClan.Kingdom.Clans)
            {
                if (clan != Hero.MainHero.Clan && !clan.IsEliminated)
                {
                    inquiryElements.Add(new InquiryElement((object)clan, clan.Name.ToString() + " -  tier " + clan.Tier, new ImageIdentifier(CharacterCode.CreateFrom((BasicCharacterObject)clan.Leader.CharacterObject))));
                }
            }

            InformationManager.ShowMultiSelectionInquiry(new MultiSelectionInquiryData("Settlement Transfer", "Select the clan you want to transfer the settlement to", inquiryElements, true, 1, "Continue", (string)null, (Action <List <InquiryElement> >)(args =>
            {
                List <InquiryElement> source = args;
                if (source != null && !source.Any <InquiryElement>())
                {
                    return;
                }
                InformationManager.HideInquiry();
                SubModule.ExecuteActionOnNextTick((Action)(() => InformationManager.ShowInquiry(new InquiryData("", "Transfer the castle of " + Settlement.CurrentSettlement.Town.Name + " to the " + (args.Select <InquiryElement, Clan>((Func <InquiryElement, Clan>)(element => element.Identifier as Clan))).First <Clan>().Name + " clan?", true, true, "Continue", "Cancle", (Action)(() => TransferSettlementAction((args.Select <InquiryElement, Clan>((Func <InquiryElement, Clan>)(element => element.Identifier as Clan))).First <Clan>())), (Action)(() => InformationManager.HideInquiry())))));
            }), (Action <List <InquiryElement> >)null));
        }
コード例 #14
0
        public void onCastClick()
        {
            var elements = new List <InquiryElement>();

            foreach (var el in BuffManager.Instance.GetRegisteredBuffList())
            {
                elements.Add(new InquiryElement(el.stringID, el.Name, new ImageIdentifier(CharacterCode.CreateFrom(Hero.MainHero.CharacterObject))));
            }
            var inquiry = new MultiSelectionInquiryData("Cast a spell",
                                                        "Select a spell to cast from the list",
                                                        elements,
                                                        true,
                                                        1,
                                                        "OK",
                                                        "Cancel",
                                                        onPositiveResult,
                                                        onNegativeResult);

            InformationManager.ShowMultiSelectionInquiry(inquiry, true);
        }