public CustomSortVM(PartyManagerSettings settings) { _settings = settings; _options = new MBBindingList <IPMOptions>(); _name = "Custom Sort"; _titleText = "Custom Sort Options"; var sortOptions = PartyManagerSettings.GetSelectableSortOrderStrings(); _options.Add(new PMStringOptionDataType <CustomSortOrder>(_settings.CustomSortOrderField1, "Custom Sort Field 1", "The first sort option to be applied in your custom sort", sortOptions, b => { _settings.CustomSortOrderField1 = b; }, CampaignOptionItemVM.OptionTypes.Selection)); _options.Add(new PMStringOptionDataType <CustomSortOrder>(_settings.CustomSortOrderField2, "Custom Sort Field 2", "The second sort option to be applied in your custom sort", sortOptions, b => { _settings.CustomSortOrderField2 = b; }, CampaignOptionItemVM.OptionTypes.Selection)); _options.Add(new PMStringOptionDataType <CustomSortOrder>(_settings.CustomSortOrderField3, "Custom Sort Field 3", "The third sort option to be applied in your custom sort", sortOptions, b => { _settings.CustomSortOrderField3 = b; }, CampaignOptionItemVM.OptionTypes.Selection)); _options.Add(new PMStringOptionDataType <CustomSortOrder>(_settings.CustomSortOrderField4, "Custom Sort Field 4", "The fourth sort option to be applied in your custom sort", sortOptions, b => { _settings.CustomSortOrderField4 = b; }, CampaignOptionItemVM.OptionTypes.Selection)); _options.Add(new PMStringOptionDataType <CustomSortOrder>(_settings.CustomSortOrderField5, "Custom Sort Field 5", "The fifth sort option to be applied in your custom sort", sortOptions, b => { _settings.CustomSortOrderField5 = b; }, CampaignOptionItemVM.OptionTypes.Selection)); this.RefreshValues(); }
public HardmodeOptionsVM(Action onClose) { this._onClose = onClose; MBBindingList <CampaignOptionItemVM> mbBindingList = new MBBindingList <CampaignOptionItemVM>(); mbBindingList.Add(new CampaignOptionItemVM("MaximumIndexPlayerCanRecruit")); mbBindingList.Add(new CampaignOptionItemVM("PlayerMapMovementSpeed")); mbBindingList.Add(new CampaignOptionItemVM("AutoAllocateClanMemberPerks")); this.Options = mbBindingList; this.RefreshValues(); }
private static bool AddWeaponItemFlags(ItemMenuVM __instance, ref BasicCharacterObject ____character, MBBindingList <ItemFlagVM> list, WeaponComponentData weapon) { var hero = (CharacterObject)____character; var blowCanMount = weapon.WeaponClass == WeaponClass.Bow && hero.IsHero && (hero.GetPerkValue(DefaultPerks.Bow.MountedArcher) || hero.GetPerkValue(DefaultPerks.Riding.BowExpert)); var crossBlowCanReloadMount = weapon.WeaponClass == WeaponClass.Crossbow && hero.IsHero && (hero.GetPerkValue(DefaultPerks.Crossbow.CrossbowCavalry) || hero.GetPerkValue(DefaultPerks.Riding.CrossbowExpert)); if (weapon.RelevantSkill == DefaultSkills.Bow) { list.Add(new ItemFlagVM("Weapons\\bow", GameTexts.FindText("str_inventory_flag_bow").ToString())); } if (weapon.RelevantSkill == DefaultSkills.Crossbow) { list.Add(new ItemFlagVM("Weapons\\crossbow", GameTexts.FindText("str_inventory_flag_crossbow").ToString())); } if (weapon.RelevantSkill == DefaultSkills.Polearm) { list.Add(new ItemFlagVM("Weapons\\polearm", GameTexts.FindText("str_inventory_flag_polearm").ToString())); } if (weapon.RelevantSkill == DefaultSkills.OneHanded) { list.Add(new ItemFlagVM("Weapons\\one_handed", GameTexts.FindText("str_inventory_flag_one_handed").ToString())); } if (weapon.RelevantSkill == DefaultSkills.TwoHanded) { list.Add(new ItemFlagVM("Weapons\\two_handed", GameTexts.FindText("str_inventory_flag_two_handed").ToString())); } if (weapon.RelevantSkill == DefaultSkills.Throwing) { list.Add(new ItemFlagVM("Weapons\\throwing", GameTexts.FindText("str_inventory_flag_throwing").ToString())); } if (weapon.WeaponFlags.HasAnyFlag(WeaponFlags.CantReloadOnHorseback) && !crossBlowCanReloadMount) { list.Add(new ItemFlagVM("Weapons\\cant_reload_on_horseback", GameTexts.FindText("str_inventory_flag_cant_reload_on_horseback").ToString())); } if (weapon.WeaponFlags.HasAnyFlag(WeaponFlags.BonusAgainstShield)) { list.Add(new ItemFlagVM("Weapons\\bonus_against_shield", GameTexts.FindText("str_inventory_flag_bonus_against_shield").ToString())); } ItemObject.ItemUsageSetFlags p = PerkHelp.GetItemUsageSetFlag(weapon); if (p.HasAnyFlag(ItemObject.ItemUsageSetFlags.RequiresNoMount) && !blowCanMount) { list.Add(new ItemFlagVM("Weapons\\cant_use_with_horse", GameTexts.FindText("str_inventory_flag_cant_use_with_mounts").ToString())); } if (p.HasAnyFlag(ItemObject.ItemUsageSetFlags.RequiresNoShield)) { list.Add(new ItemFlagVM("Weapons\\cant_use_with_shields", GameTexts.FindText("str_inventory_flag_cant_use_with_shields").ToString())); } return(false); }
public static void AddRange <T>(this MBBindingList <T> bindingList, List <T> listToAdd) { if (listToAdd.Count == 1) { bindingList.Add(listToAdd[0]); } else if (listToAdd.Count > 0) { for (var i = listToAdd.Count - 1; i >= 0; i--) { bindingList.Add(listToAdd[i]); } } }
public CESettingsVMCategory(CESettingsVM options, TextObject name, IEnumerable <ICEOptionData> targetList, bool isNative) { _options = new MBBindingList <CEGenericOptionDataVM>(); IsNative = isNative; _nameObj = name; foreach (ICEOptionData optionData in targetList) { string text = optionData.GetName().ToString(); TextObject name2 = new TextObject(text); TextObject textObject = new TextObject(text); textObject.SetTextVariable("newline", "\n"); CEActionOptionData actionOptionData; if (optionData is ICEBooleanOptionData) { CEBooleanOptionDataVM booleanOptionDataVM = new CEBooleanOptionDataVM(options, optionData as ICEBooleanOptionData, name2, textObject) { ImageIDs = new string[] { text + "_0", text + "_1" } }; _options.Add(booleanOptionDataVM); } else if (optionData is ICENumericOptionData) { CENumericOptionDataVM item = new CENumericOptionDataVM(options, optionData as ICENumericOptionData, name2, textObject); _options.Add(item); } else if (optionData is ICESelectionOptionData) { ICESelectionOptionData selectionOptionData = optionData as ICESelectionOptionData; CEStringOptionDataVM stringOptionDataVM = new CEStringOptionDataVM(options, selectionOptionData, name2, textObject); string[] array = new string[selectionOptionData.GetSelectableOptionsLimit()]; for (int i = 0; i < array.Length; i++) { array[i] = text + "_" + i; } stringOptionDataVM.ImageIDs = array; _options.Add(stringOptionDataVM); } else if ((actionOptionData = (optionData as CEActionOptionData)) != null) { TextObject optionActionName = Module.CurrentModule.GlobalTextManager.FindText("str_options_type_action", text); CEActionOptionDataVM item2 = new CEActionOptionDataVM(actionOptionData.OnAction, options, actionOptionData, name2, optionActionName, textObject); _options.Add(item2); } } RefreshValues(); }
public void AddSettingVms() { _options.Add(new BooleanOptionDataVM(_settings.PathSelectTooltips, "Additional Tooltips", "Add the additional tooltip to troop upgrade buttons telling you to use CTRL and SHIFT to select the upgrade paths", (value) => _settings.PathSelectTooltips = value)); _options.Add(new BooleanOptionDataVM(_settings.ShouldShowCompletePartyNumber, "Show Combined Troop Total", "If enabled will change the party label on the top right to display the total amount of troops in your party, instead of healthy + wounded.", (value) => _settings.ShouldShowCompletePartyNumber = value)); _options.Add(new BooleanOptionDataVM(_settings.KeepHeroesOnTop, "Keep Companions On Top", "If enabled sorts your companions to the top of the troop list, if disabled puts them on the bottom instead", (value) => _settings.KeepHeroesOnTop = value)); _options.Add(new BooleanOptionDataVM(_settings.AutomaticSorting, "Automatic Sorting", "Automatically sort everything present upon opening the party screen, or when upgrading/recruiting units using the top buttons", (value) => _settings.AutomaticSorting = value)); _options.Add(new BooleanOptionDataVM(_settings.SeparateSortingProfiles, "Separate Sorting Profiles", "Use different sorting rules for your main party/prisoners/garrisons", (value) => _settings.SeparateSortingProfiles = value)); _options.Add(new BooleanOptionDataVM(_settings.EqualUpgrades, "Equally Distributed Upgrades", "Set the Upgrade All button to distribute the available upgrades equally for units with 2 or more upgrade choices.\nNote, any set path preferences will still be adhered to regardless of this setting.", (value) => _settings.EqualUpgrades = value)); _options.Add(new BooleanOptionDataVM(_settings.DisplayCategoryNumbers, "Display Category Numbers", "Display how many Infantry, Archers, and Cavalry you have on the Party screen", (value) => _settings.DisplayCategoryNumbers = value)); _options.Add(new BooleanOptionDataVM(_settings.RecruitByDefault, "Recruit By Default", "Determines whether all prisoners eligible for recruitment will be enlisted with the Recruit All button.\nIf turned off you'll have to CTRL + click each prisoner's recruitment button to allow their recruitment explicitly.\n\nNote any previously disallowed units will now be allowed", (value) => _settings.RecruitByDefault = value)); _options.Add(new BooleanOptionDataVM(_settings.ShowGeneralLogMessage, "Display Log Messages", "Display log messages on the bottom left detailing how many units were upgraded/recruited.", (value) => _settings.ShowGeneralLogMessage = value)); }
public MBBindingList <ModSettingsViewModel> GetProvidedModSettings() { var modlist = new MBBindingList <ModSettingsViewModel>(); var mod1Settings = new MBBindingList <ModsSettingsProvider.SettingsField>() { new BooleanSettingsFieldViewModel() { Name = "1.Is True", Description = "Boolean Settings Field for Sample mod1" }, new BooleanSettingsFieldViewModel() { Name = "1.Is True two", Description = "Boolean Settings Field for Sample mod1" }, new BooleanSettingsFieldViewModel() { Name = "1.Is True three", Description = "Boolean Settings Field for Sample mod1" }, }; var mod2Settings = new MBBindingList <ModsSettingsProvider.SettingsField>() { new BooleanSettingsFieldViewModel() { Name = "2.Is True", Description = "Boolean Settings Field for Sample mod2" }, new BooleanSettingsFieldViewModel() { Name = "2.Is True two", Description = "Boolean Settings Field for Sample mod2" }, new BooleanSettingsFieldViewModel() { Name = "2.Is True three", Description = "Boolean Settings Field for Sample mod2" }, }; modlist.Add(new ModSettingsViewModel() { ModName = "Sample mod1", ModSettingsList = mod1Settings }); modlist.Add(new ModSettingsViewModel() { ModName = "Sample mod2", ModSettingsList = mod2Settings }); return(modlist); }
public PlotsVM(Action closeScreenAction) { _closeScreenAction = closeScreenAction; ActivePlots = new MBBindingList <PlotItemVM>(); foreach (var gamePlot in GameManager.Instance.PlotManager.GamePlots) { foreach (var plot in gamePlot) { ActivePlots.Add(new PlotItemVM(plot.Title, plot.Description, SetSelectedPlot)); } } AvailablePlots = new MBBindingList <PlotItemVM>(); foreach (var trigger in GameManager.Instance.Triggers.Where(trigger => trigger.CanPlayerStart())) { AvailablePlots.Add(new PlotItemVM(trigger.Title, trigger.Description, SetSelectedPlot)); } SetSelectedPlot(ActivePlots.FirstOrDefault()); IsThereAnyPlot = ActivePlots.Any(); RefreshValues(); }
private void AddNonAggressionPactRelationships(Kingdom kingdom, IFaction faction, MBBindingList <DiplomacyFactionRelationshipVM> FactionPacts) { if (DiplomaticAgreementManager.Instance.HasNonAggressionPact(kingdom, faction as Kingdom, out NonAggressionPactAgreement pact)) { var textObject = new TextObject(StringConstants.DaysRemaining).SetTextVariable("DAYS_LEFT", (int)Math.Round(pact.EndDate.RemainingDaysFromNow)); FactionPacts.Add(new DiplomacyFactionRelationshipVM(kingdom, new HintViewModel(textObject))); } }
//Get and Set Categories public void SetCategories() { foreach (var category in _xmlParse.Entities) { if (category.Key == "") { continue; } _categories.Add(category.Key); } }
public static void AddRange <T>(this MBBindingList <T> bindingList, List <T> listToAdd) { if (listToAdd == null) { throw new ArgumentNullException(nameof(listToAdd)); } if (bindingList == null) { throw new ArgumentNullException(nameof(bindingList)); } if (listToAdd.Count == 1) { bindingList.Add(listToAdd[0]); } else if (listToAdd.Count > 0) { for (int i = listToAdd.Count - 1; i >= 0; i--) { bindingList.Add(listToAdd[i]); } } }
public MissionLibraryGameKeyConfigVM(AGameKeyCategoryManager gameKeyCategoryManager, Action <GameKeyOptionVM> onKeyBindRequest) { _gameKeyCategoryManager = gameKeyCategoryManager; _categories = _gameKeyCategoryManager.Categories.ToDictionary(pair => pair.Key, pair => pair.Value.Value); Groups = new MBBindingList <MissionLibraryGameKeyGroupVM>(); foreach (KeyValuePair <string, AGameKeyCategory> category in _categories) { if (category.Value.GameKeys.Count > 0) { Groups.Add(new MissionLibraryGameKeyGroupVM(category.Key, category.Value.GameKeys, onKeyBindRequest, UpdateKeysOfGameKeysWithId)); } } RefreshValues(); }
public SettlementAssassinateScreenViewModel(ISneakInHandler sneakInHandler, Settlement settlement) { _sneakInHandler = sneakInHandler; _settlement = settlement; var targetsList = new MBBindingList <AssassinationCharacterPanel>(); foreach (var hero in settlement.GetViableAssassinationTargetsInLordsHall(Hero.MainHero)) { targetsList.Add(new AssassinationCharacterPanel(hero, OnSneakIn)); } AssassinationTargets = targetsList; }
public static MBBindingList <SPScoreboardUnitVM> GetOrderedScoreList(SPScoreboardPartyVM party) { List <SPScoreboardUnitVM> list = party.Members.OrderByDescending(vm => vm.IsHero) .ThenByDescending(vm => vm.Score.Kill) .ToList(); MBBindingList <SPScoreboardUnitVM> mbList = new MBBindingList <SPScoreboardUnitVM>(); foreach (var item in GetScoreboardUnits(party)) { mbList.Add(item); } mbList.Add(new SPScoreboardUnitVM(new BasicCharacterObject { Name = TextObject.Empty })); foreach (SPScoreboardUnitVM member in list) { mbList.Add(member); } return(mbList); }
//Game Entity Views public MBBindingList <PrefabVM> Enumerate(int amount) { for (int i = 0; i < amount; i++) { if (_enumerator.Current == null) { _enumerator.MoveNext(); } _pagemodel.Add(_enumerator.Current); _enumerator.MoveNext(); } return(_pagemodel); }
public SPCharactersInGroupVM(CharacterCollection collection) : base(collection) { OccupationText = new TextVM(new TextObject("{=GZxFIeiJ}Occupation")); for (Occupation occupation = Occupation.NotAssigned; occupation < Occupation.NumberOfOccupations; ++occupation) { _occupations.Add(occupation); } Occupations = new SelectorVM <SelectorItemVM>(0, OnSelectedOccupationChanged); var list = new MBBindingList <SelectorItemVM>(); foreach (var item in _occupations.Select(occupation => { switch (occupation) { case Occupation.GoodsTrader: case Occupation.BannerBearer: return(new TextObject(occupation.ToString())); case Occupation.Outlaw: return(GameTexts.FindText("str_outlaw")); case Occupation.RuralNotable: return(GameTexts.FindText("str_rural_notable")); case Occupation.Artisan: case Occupation.Preacher: case Occupation.Headman: case Occupation.GangLeader: return(GameTexts.FindText("str_charactertype_" + occupation.ToString().ToLower())); case Occupation.Judge: return(new TextObject("{=ZRkceJx3}Judge")); case Occupation.CaravanGuard: return(new TextObject("{=jxNe8lH2}Caravan Guard")); } return(GameTexts.FindText("str_occupation", occupation.ToString())); })) { list.Add(new SelectorItemVM(item)); } Occupations.ItemList = list; }
//TODO: Consider using reflection here instead of manual declaration private void InitialisePossibleSettingList() { _possibleSettingList.Add(new SettingSortVM(new AlphabetComparer(null, false), TransferSorter, SettingSide.LEFT, _parent.OpenSubSetting)); _possibleSettingList.Add(new SettingSortVM(new BasicTypeComparer(null, true), TransferSorter, SettingSide.LEFT, _parent.OpenSubSetting)); _possibleSettingList.Add(new SettingSortVM(new TypeComparer(null, false), TransferSorter, SettingSide.LEFT, _parent.OpenSubSetting)); _possibleSettingList.Add(new SettingSortVM(new LevelComparer(null, true), TransferSorter, SettingSide.LEFT, _parent.OpenSubSetting)); _possibleSettingList.Add(new SettingSortVM(new TrueTierComparer(null, true), TransferSorter, SettingSide.LEFT, _parent.OpenSubSetting)); _possibleSettingList.Add(new SettingSortVM(new CultureComparer(null, false), TransferSorter, SettingSide.LEFT, _parent.OpenSubSetting)); _possibleSettingList.Add(new SettingSortVM(new NumberComparer(null, true), TransferSorter, SettingSide.LEFT, _parent.OpenSubSetting)); _possibleSettingList.Add(new SettingSortVM(new UpgradeableComparer(null, true), TransferSorter, SettingSide.LEFT, _parent.OpenSubSetting)); _possibleSettingList.Add(new SettingSortVM(new WoundedComparer(null, true), TransferSorter, SettingSide.LEFT, _parent.OpenSubSetting)); }
public VartsLeaderboardCaravanVM() { Entries = new MBBindingList <VartsLeaderboardCaravanEntryItemVM>(); foreach (var caravanDto in CaravanDto.AllCaravanDto) { Entries.Add(new VartsLeaderboardCaravanEntryItemVM(caravanDto)); } SortController = new VartsLeaderboardCaravanSortControllerVM(ref _entries); // SortController.MovieActionCaravanProfitMadeIsSelected = true; // SortController.MovieActionCaravanProfitMadeSortState = (int) VartsLeaderboardCaravanSortControllerVM.SortState.Descending; // SortController.MovieActionCaravanProfitMadeSort(); // SortController.MovieActionCaravanProfitMadeSort(); RefreshValues(); }
public VartsLeaderboardWorkshopVM() { Entries = new MBBindingList <VartsLeaderboardWorkshopEntryItemVM>(); foreach (var workshopDto in WorkshopDto.AllWorkshopDto) { Entries.Add(new VartsLeaderboardWorkshopEntryItemVM(workshopDto)); } SortController = new VartsLeaderboardWorkshopSortControllerVM(ref _entries); SortController.MovieActionWorkshopProfitMadeIsSelected = true; SortController.MovieActionWorkshopProfitMadeSortState = (int)VartsLeaderboardWorkshopSortControllerVM.SortState.Descending; SortController.MovieActionWorkshopProfitMadeSort(); SortController.MovieActionWorkshopProfitMadeSort(); RefreshValues(); }
private static void Postfix(SmeltingVM __instance, ItemRoster ____playerItemRoster) { // This appears to be how the game works out if an item is locked // From TaleWorlds.CampaignSystem.ViewModelCollection.SPInventoryVM.InitializeInventory() IEnumerable <EquipmentElement> locks = Campaign.Current.GetCampaignBehavior <TaleWorlds.CampaignSystem.SandBox.CampaignBehaviors.IInventoryLockTracker>().GetLocks(); // Updated line 24 to Line 25 which seems to be the updated way game works out item locks in v1.4.3 InitializeInventory() // EquipmentElement[] locked_items = locks?.ToArray<EquipmentElement>(); EquipmentElement[] locked_items = (locks != null) ? locks.ToArray <EquipmentElement>() : null; bool isLocked(EquipmentElement test_item) { return(locked_items != null && locked_items.Any(delegate(EquipmentElement x) { ItemObject lock_item = x.Item; if (lock_item.StringId == test_item.Item.StringId) { ItemModifier itemModifier = x.ItemModifier; string a = itemModifier?.StringId; ItemModifier itemModifier2 = test_item.ItemModifier; return a == (itemModifier2?.StringId); } return false; })); } MBBindingList <SmeltingItemVM> filteredList = new MBBindingList <SmeltingItemVM>(); foreach (SmeltingItemVM sItem in __instance.SmeltableItemList) { if (!____playerItemRoster.Any(rItem => sItem.Item == rItem.EquipmentElement.Item && isLocked(rItem.EquipmentElement) )) { filteredList.Add(sItem); } } __instance.SmeltableItemList = filteredList; if (__instance.SmeltableItemList.Count == 0) { __instance.CurrentSelectedItem = null; } }
public CharacterSelectionVM(CharacterSelectionParams p) : base() { ModuleLogger.Log("begin character selection vm construction"); this._params = p; this.allCharacters = new SortedDictionary <string, SortedDictionary <string, List <CharacterInfo> > >(); foreach (var c1 in p.characters) { if (!this.allCharacters.ContainsKey(c1.culture)) { this.allCharacters.Add(c1.culture, new SortedDictionary <string, List <CharacterInfo> >()); } var cultureDict = this.allCharacters[c1.culture]; if (!cultureDict.ContainsKey(c1.defaultGroup)) { cultureDict.Add(c1.defaultGroup, new List <CharacterInfo>()); } cultureDict[c1.defaultGroup].Add(c1); } var c = p.characters[p.selectedIndex]; Cultures = new MBBindingList <NameVM>(); foreach (var culture in this.allCharacters.Keys) { Cultures.Add(new NameVM { Name = culture }); } Groups = new MBBindingList <NameVM>(); foreach (var group in this.allCharacters[c.culture].Keys) { Groups.Add(new NameVM { Name = group }); } Characters = new MBBindingList <CharacterVM>(); foreach (var character in this.allCharacters[c.culture][c.defaultGroup]) { Characters.Add(new CharacterVM(character)); } SelectedCultureIndex = Cultures.FindIndex(n => n.Name == c.culture); SelectedGroupIndex = Groups.FindIndex(n => n.Name == c.defaultGroup); SelectedCharacterIndex = Characters.FindIndex(n => n.character == c); ModuleLogger.Log("end character selection vm construction"); }
public void PageRange(int range) { var list = new MBBindingList <PrefabVM>(); for (int i = 0; i < range; i++) { if (_enumerator.Current == null) { _enumerator.MoveNext(); } list.Add(_enumerator.Current); _enumerator.MoveNext(); } this._pagemodel = list; }
private void UpdatePrimaryUsageIndex(SelectorVM <CategoryItemVM> selector) { if (selector.SelectedIndex == -1) { return; } //Reset selectedCategory SelectedCategory = new MBBindingList <CategoryItemVM>(); //Add Category Items foreach (var category in _xmlParse.Entities[selector.SelectedItem.StringItem]) { var temp = new CategoryItemVM(category.Key); temp.Category = selector.SelectedItem.StringItem; SelectedCategory.Add(temp); } }
private void RefreshSelector(SelectorVM <SelectorItemVM> selector, List <TextObject> texts, int index, Action <SelectorVM <SelectorItemVM> > action) { if (selector == null) { return; } var bindings = new MBBindingList <SelectorItemVM>(); foreach (var textObject in texts) { bindings.Add(new SelectorItemVM(textObject)); } selector.SetOnChangeAction(null); selector.ItemList = bindings; selector.SelectedIndex = -1; selector.SetOnChangeAction(action); selector.SelectedIndex = index; }
public MissionLibraryGameKeyGroupVM( string categoryId, IEnumerable <GameKey> keys, Action <GameKeyOptionVM> onKeyBindRequest, Action <string, int, InputKey> setAllKeysOfId) { _setAllKeysOfId = setAllKeysOfId; _categoryId = categoryId; _gameKeys = new MBBindingList <GameKeyOptionVM>(); foreach (GameKey key in keys) { Key validInputKey = FindValidInputKey(key); if (validInputKey != null) { _gameKeys.Add(new GameKeyOptionVM(key, onKeyBindRequest, SetGameKey)); } } RefreshValues(); }
private void OnOrderTroopChange(SelectorVM <OrderTroopSelectorItemVM> obj) { if (obj.SelectedItem != null) { SortPartyConfig.SortOrder = obj.SelectedItem.SortType; // obj.SelectedItem.SortType= var newOrders = new MBBindingList <PartyCharacterVM>(); switch (obj.SelectedItem.SortType) { case TroopSortType.None: foreach (var item in _partyVM.MainPartyTroops.OrderBy(a => a.IsHero).ThenBy(a => a.Troop.Character.Tier).ToList()) { newOrders.Add(item); } _partyVM.MainPartyTroops = newOrders; break; } _partyVM.RefreshValues(); } }
public static void RefreshDiplomacyListPatch(KingdomDiplomacyVM __instance) { MBBindingList <KingdomWarItemVM> playerWars = new MBBindingList <KingdomWarItemVM>(); MBBindingList <KingdomTruceItemVM> playerTruces = new MBBindingList <KingdomTruceItemVM>(); MethodInfo onDiplomacyItemSelection = typeof(KingdomDiplomacyVM).GetMethod("OnDiplomacyItemSelection", BindingFlags.NonPublic | BindingFlags.Instance); MethodInfo onDeclareWarMethod = typeof(KingdomDiplomacyVM).GetMethod("OnDeclareWar", BindingFlags.NonPublic | BindingFlags.Instance); MethodInfo onProposePeaceMethod = typeof(KingdomDiplomacyVM).GetMethod("OnDeclarePeace", BindingFlags.NonPublic | BindingFlags.Instance); Action <KingdomTruceItemVM> onDeclareWarAction = (Action <KingdomTruceItemVM>)Delegate.CreateDelegate(typeof(Action <KingdomTruceItemVM>), __instance, onDeclareWarMethod); Action <KingdomWarItemVM> onProposePeaceAction = (Action <KingdomWarItemVM>)Delegate.CreateDelegate(typeof(Action <KingdomWarItemVM>), __instance, onProposePeaceMethod); Action <KingdomDiplomacyItemVM> onItemSelectedAction = (Action <KingdomDiplomacyItemVM>)Delegate.CreateDelegate(typeof(Action <KingdomDiplomacyItemVM>), __instance, onDiplomacyItemSelection); Kingdom playerKingdom = Clan.PlayerClan.Kingdom; foreach (StanceLink stanceLink in from x in playerKingdom.Stances where x.IsAtWar select x into w orderby w.Faction1.Name.ToString() + w.Faction2.Name.ToString() select w) { if (stanceLink.Faction1 is Kingdom && stanceLink.Faction2 is Kingdom && !stanceLink.Faction1.IsMinorFaction && !stanceLink.Faction2.IsMinorFaction) { playerWars.Add(new KingdomWarItemVMExtensionVM(stanceLink, onItemSelectedAction, onProposePeaceAction)); } } foreach (Kingdom kingdom in Kingdom.All) { if (kingdom != playerKingdom && !kingdom.IsEliminated && FactionManager.IsNeutralWithFaction(kingdom, playerKingdom)) { playerTruces.Add(new KingdomTruceItemVMExtensionVM(playerKingdom, kingdom, onItemSelectedAction, onDeclareWarAction)); } } __instance.PlayerTruces = playerTruces; __instance.PlayerWars = playerWars; MethodInfo setDefaultSelectedItem = typeof(KingdomDiplomacyVM).GetMethod("SetDefaultSelectedItem", BindingFlags.NonPublic | BindingFlags.Instance); setDefaultSelectedItem.Invoke(__instance, new object[] { }); }
public static MBBindingList <string> GetSelectableSortOrderStrings() { var sortTypes = new MBBindingList <string>(); try { foreach (var sort in Enum.GetValues(typeof(CustomSortOrder))) { if ((int)sort >= 0) { sortTypes.Add(sort.ToString()); } } } catch (Exception ex) { GenericHelpers.LogException("PartyManagerSettings.GetSelectableSortOrders", ex); } return(sortTypes); }
public GrantFiefVM(Hero hero, Action onComplete) { this._onComplete = onComplete; this._targetHero = hero; this.Settlements = new MBBindingList <GrantFiefItemVM>(); foreach (Town settlement in Clan.PlayerClan.Fortifications) { _settlements.Add(new GrantFiefItemVM(settlement.Owner.Settlement, _targetHero, this.OnSelect)); } this.SelectedSettlementItem = this.Settlements.FirstOrDefault(); this.SelectedSettlementItem.IsSelected = true; this.SortController = new GrantFiefSortControllerVM(ref _settlements); this.GrantFiefActionName = new TextObject("{=LpoyhORp}Grant Fief").ToString(); this.CancelText = GameTexts.FindText("str_cancel", null).ToString(); this.NameText = GameTexts.FindText("str_scoreboard_header", "name").ToString(); this.TypeText = GameTexts.FindText("str_sort_by_type_label", null).ToString(); this.ProsperityText = GameTexts.FindText("str_prosperity_abbr", null).ToString(); this.DefendersText = GameTexts.FindText("str_sort_by_defenders_label", null).ToString(); this.RelationText = new TextObject("{=bCOCjOQM}Relat.").ToString(); this.RelationHint = new HintViewModel(new TextObject("{=RxawrCjg}Relationship Gain with Grantee").ToString()); this.RefreshValues(); }
private static void SortRoster(SorterConfiguration configuration, TroopRoster troopRoster, ICollection <PartyCharacterVM> partyList, Action <MBBindingList <PartyCharacterVM> > apply) { FieldInfo troopRosterDataField = troopRoster.GetType().GetField("data", BindingFlags.NonPublic | BindingFlags.Instance); TroopRosterElement[] originalTroops = (TroopRosterElement[])troopRosterDataField?.GetValue(troopRoster); if (originalTroops == null || originalTroops.All(x => x.Character == null)) { return; } List <TroopRosterElement> originalTroopList = originalTroops.Where(x => x.Character != null).ToList(); List <TroopRosterElement> sortedTroops = originalTroopList.Where(x => !x.Character.IsHero).ToList(); List <TroopRosterElement> heroTroops = originalTroopList.Where(x => x.Character.IsHero && !x.Character.IsPlayerCharacter).ToList(); TroopRosterElement player = originalTroopList.FirstOrDefault(x => x.Character.IsPlayerCharacter); TroopSorterService.Sort(ref sortedTroops, ref heroTroops, configuration); if (heroTroops.Count > 0) { sortedTroops.InsertRange(0, heroTroops); } if (player.Character != null) { sortedTroops.Insert(0, player); } troopRosterDataField.SetValue(troopRoster, sortedTroops.ToArray()); List <PartyCharacterVM> tempTroopList = partyList.ToList(); MBBindingList <PartyCharacterVM> newTroopList = new MBBindingList <PartyCharacterVM>(); partyList.Clear(); foreach (PartyCharacterVM troop in sortedTroops.Select(sortedTroop => tempTroopList.FirstOrDefault(x => x.Troop.Character.ToString() == sortedTroop.Character.ToString()))) { newTroopList.Add(troop); } apply(newTroopList); }