public static void UpdateTooltip(this TooltipVM tooltipVM, CEBrothel brothel) { tooltipVM.Mode = 1; tooltipVM.AddProperty("", new TextObject("{=CEEVENTS1099}Brothel").ToString(), 0, TooltipProperty.TooltipPropertyFlags.Title); tooltipVM.AddProperty(new TextObject("{=qRqnrtdX}Owner").ToString(), brothel.Owner.Name.ToString()); tooltipVM.AddProperty(new TextObject("{=CEBROTHEL0994}Notable Prostitutes").ToString(), "None"); }
public static bool HeroActionPatch(TooltipVM tooltipVM, object[] args) { try { if (!Settings.Instance !.UseAdvancedHeroTooltips) { return(true); } if (args.Length == 2 && args[1] != null && args[1] is Hero) { tooltipVM.UpdateTooltip(args[0] as Hero, args[1] as Hero); } else { tooltipVM.UpdateTooltip(args[0] as Hero); } return(false); } catch (Exception ex) { MethodInfo?methodInfo = MethodBase.GetCurrentMethod() as MethodInfo; DebugHelper.HandleException(ex, methodInfo, "Harmony patch for TooltipVMExtensions.HeroAction"); return(true); } }
private static void PartyTooltipPostfix(TooltipVM __instance, int partyID) { int index = 0; PartyBase party = PartyBase.FindParty(partyID); if (party.IsSettlement) { if (party.Settlement.IsVillage) { foreach (var property in __instance.TooltipPropertyList) { if (property.DefinitionLabel.Equals("Primary Production")) { index = __instance.TooltipPropertyList.IndexOf(property); } } int playerAcres = EntrepreneurModel.GetVillagePlayerAcres(party.Settlement.StringId); int playerRevenue = EntrepreneurModel.GetVillagePlayerRevenue(party.Settlement.StringId); if (playerAcres > 0) { __instance.TooltipPropertyList.Insert(index + 1, new TooltipProperty("Owned farm acres", playerAcres.ToString(), 0, false, TooltipProperty.TooltipPropertyFlags.None)); __instance.TooltipPropertyList.Insert(index + 2, new TooltipProperty("Revenue from farms", playerRevenue.ToString(), 0, false, TooltipProperty.TooltipPropertyFlags.None)); } } } }
private static void InterfaceTooltipPostfix(TooltipVM __instance, List <TooltipProperty> tooltipPropertyList) { TooltipProperty topTooltipProperty = tooltipPropertyList[0]; if (topTooltipProperty.DefinitionLabel.Equals("Current Denars")) { } }
public static void UpdateTooltip(this TooltipVM tooltipVM, Hero?hero, Hero?otherHero) { tooltipVM.UpdateTooltip(hero); if (otherHero != null) { tooltipVM.TooltipPropertyList.Add(new TooltipProperty(TooltipHelper.GetTooltipRelationHeader(otherHero), hero?.GetRelation(otherHero).ToString("N0"), 0, false, TooltipProperty.TooltipPropertyFlags.None)); } }
private static void OpenTooltipPostfix(TooltipVM __instance, Type type, object[] args) { try { ApplyRealTroopCountTooltipFix(__instance); } catch (Exception ex) { Debug.WriteLine("\n\n\n\n\n"); Debug.WriteLine(ex.Message); Debug.WriteLine(ex.StackTrace); Debug.WriteLine("\n\n\n\n\n"); } }
private static void ApplyRealTroopCountTooltipFix(TooltipVM __instance) { Dictionary <string, int> troopCount = CalculateTroopTypes(); foreach (TooltipProperty tooltipProperty in __instance.TooltipPropertyList) { string toolTipPropertyLabel = tooltipProperty.DefinitionLabel.ToLower(); if (toolTipPropertyLabel == "prisoners") { break; } if (troopCount.TryGetValue(toolTipPropertyLabel, out int troopCountValue)) { tooltipProperty.ValueLabel += $" ( {troopCountValue} )"; } } }
private static void UpdateTooltipPostfix(TooltipVM __instance, Type type, object[] args) { try { if (type.ToString().Equals("TaleWorlds.CampaignSystem.PartyBase")) { int partyID = (int)args[0]; int unknown_1 = (int)args[1]; Boolean unkown_2 = (Boolean)args[2]; PartyTooltipPostfix(__instance, partyID); } else if (type.ToString().Equals("System.Collections.Generic.List`1[TaleWorlds.Core.ViewModelCollection.TooltipProperty]")) { List <TooltipProperty> list = (List <TooltipProperty>)args[0]; InterfaceTooltipPostfix(__instance, list); } } catch (Exception ex) { Trace.WriteLine(ex.Message); Trace.WriteLine(ex.StackTrace); } }
public static void UpdateTooltipPatch(TooltipVM tooltipVM, Hero hero) { try { if (hero.Clan is null || !SettingsHelper.SubSystemEnabled(SubSystemType.LoyaltyTooltips, hero.Clan)) { return; } if (hero.Clan.Kingdom != null && hero.Clan.Kingdom.RulingClan != hero.Clan && hero == hero.Clan.Leader) { int RelationWithLiege = hero.GetRelation(hero.Clan.Kingdom.Ruler); tooltipVM.TooltipPropertyList.Add(new TooltipProperty(TooltipHelper.GetTooltipRelationHeader(hero.Clan.Kingdom.Ruler), RelationWithLiege.ToString("N0"), 0, RelationWithLiege < -10 ? Colors.Red : RelationWithLiege > 10 ? Colors.Green : TooltipHelper.DefaultTooltipColor, false, TooltipProperty.TooltipPropertyFlags.None)); LoyaltyManager.GetLoyaltyTooltipInfo(hero.Clan, out string LoyaltyText, out Color LoyaltyTextColor); tooltipVM.TooltipPropertyList.Add(new TooltipProperty(TooltipHelper.GetTooltipLoyaltyHeader(), LoyaltyText, 0, LoyaltyTextColor, false, TooltipProperty.TooltipPropertyFlags.None)); } } catch (Exception ex) { MethodInfo?methodInfo = MethodBase.GetCurrentMethod() as MethodInfo; DebugHelper.HandleException(ex, methodInfo, "Harmony patch for TooltipVMExtensions.UpdateTooltip"); } }
private static void UpdateTooltipPostfix(TooltipVM __instance, Type type, object[] args) { if (args.Length > 0) { if (args[0].GetType() == typeof(Settlement) && (Settlement)args[0] != null) { Settlement settlement = (Settlement)args[0]; if (settlement.IsCastle || settlement.IsTown || settlement.IsVillage) { string factionDefinitionLabel = "Faction"; string troopTypesDefinitionLabel = "Troops"; int indexOfFaction = __instance.TooltipPropertyList.FindIndex(x => x.DefinitionLabel.Equals(factionDefinitionLabel)); MBBindingList <TooltipProperty> tooltipProperties = __instance.TooltipPropertyList; if (indexOfFaction != 0) { //Add Culture to tooltip if (settlement.Culture != null) { tooltipProperties.Insert(indexOfFaction, new TooltipProperty("Culture", settlement.Culture.ToString(), 0, false)); } } __instance.TooltipPropertyList = tooltipProperties; List <TooltipProperty> tooltipPropertyMoreInfoList = __instance.TooltipPropertyList.ToList(); if (DynaCultureManager.Instance.InfluenceMap.Count == 0) { DynaCultureManager.Initialize(); } //Add Influences to tooltip Dictionary <string, decimal> influences = DynaCultureManager.Instance.InfluenceMap[settlement.StringId].CurrentInfluences; if (influences.Count != 0) { int indexForInfluence = __instance.TooltipPropertyList.FindIndex(x => x.DefinitionLabel.Equals(troopTypesDefinitionLabel)); if (indexForInfluence >= 0) { tooltipPropertyMoreInfoList.Insert(indexForInfluence, new TooltipProperty("Influences", " ", 0, true)); indexForInfluence++; tooltipPropertyMoreInfoList.Insert(indexForInfluence, new TooltipProperty("", "", 0, true, TooltipProperty.TooltipPropertyFlags.RundownSeperator)); indexForInfluence++; foreach (KeyValuePair <string, decimal> influence in influences.OrderByDescending(i => i.Value)) { decimal previousInfluenceValue = DynaCultureManager.Instance.InfluenceMap[settlement.StringId].GetPreviousInfluenceForCulture(influence.Key) * 100; decimal influenceValue = influence.Value * 100; decimal differenceInfluenceValue = influenceValue - previousInfluenceValue; string culture = String.Empty; if (influence.Key.Length > 1) { culture = char.ToUpper(influence.Key[0]) + influence.Key.Substring(1); } else { culture = influence.Key; } tooltipPropertyMoreInfoList.Insert(indexForInfluence, new TooltipProperty($"{culture}", $"{influenceValue.ToString("0.##")} ({differenceInfluenceValue.ToString("0.##")})", 0, true)); indexForInfluence++; } tooltipPropertyMoreInfoList.Insert(indexForInfluence, new TooltipProperty("", "", -1, true)); indexForInfluence++; __instance.TooltipPropertyList = new MBBindingList <TooltipProperty>(); __instance.UpdateTooltip(tooltipPropertyMoreInfoList); } } } } } }
private static void UpdateTooltipPostfix(TooltipVM __instance, Type type, object[] args) { try { if (args.Length > 0) { System.Diagnostics.Debug.WriteLine(args[0].GetType()); if (args[0].GetType() == typeof(Settlement) && (Settlement)args[0] != null) { Settlement settlement = (Settlement)args[0]; if (settlement.IsCastle || settlement.IsTown || settlement.IsVillage) { string factionDefinitionLabel = "Faction"; string troopTypesDefinitionLabel = "Troop Types"; int indexOfFaction = __instance.TooltipPropertyList.FindIndex(x => x.DefinitionLabel.Equals(factionDefinitionLabel)); MBBindingList <TooltipProperty> tooltipProperties = __instance.TooltipPropertyList; if (indexOfFaction != 0) { //Add Culture to tooltip if (settlement.Culture != null) { tooltipProperties.Insert(indexOfFaction, new TooltipProperty("Culture", settlement.Culture.ToString(), 0, false)); } } __instance.TooltipPropertyList = tooltipProperties; List <TooltipProperty> tooltipPropertyMoreInfoList = __instance.TooltipPropertyList.ToList(); //Add Influences to tooltip Dictionary <string, decimal> influences = DynaCultureManager.Instance.InfluenceMap[settlement.StringId].getInfluenceForSettlement(); if (influences.Count != 0) { int indexForInfluence = __instance.TooltipPropertyList.FindIndex(x => x.DefinitionLabel.Equals(troopTypesDefinitionLabel)); if (indexForInfluence != 0) { tooltipPropertyMoreInfoList.Insert(indexForInfluence, new TooltipProperty("Influences", " ", 0, true)); indexForInfluence++; tooltipPropertyMoreInfoList.Insert(indexForInfluence, new TooltipProperty("", "", 0, true, TooltipProperty.TooltipPropertyFlags.RundownSeperator)); indexForInfluence++; foreach (KeyValuePair <string, decimal> influence in influences) { decimal targetInfluenceValue = DynaCultureManager.Instance.InfluenceMap[settlement.StringId].getTargetInfluenceValueForSettlement(influence.Key) * 100; decimal influenceValue = influence.Value * 100; decimal differenceInfluenceValue = influenceValue - targetInfluenceValue; string culture = ""; if (influence.Key.Length > 1) { culture = char.ToUpper(influence.Key[0]) + influence.Key.Substring(1); } else { culture = influence.Key; } tooltipPropertyMoreInfoList.Insert(indexForInfluence, new TooltipProperty($"{culture}", $"{influenceValue.ToString("0.##")} ({differenceInfluenceValue.ToString("0.##")})", 0, true)); indexForInfluence++; } tooltipPropertyMoreInfoList.Insert(indexForInfluence, new TooltipProperty("", "", -1, true)); indexForInfluence++; } } __instance.TooltipPropertyList = new MBBindingList <TooltipProperty>(); __instance.UpdateTooltip(tooltipPropertyMoreInfoList); } } } } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.Message); System.Diagnostics.Debug.WriteLine(ex.StackTrace); } }
public static void BrothelTypeTooltipAction(this TooltipVM tooltipVM, object[] args) => UpdateTooltip(tooltipVM, args[0] as CEBrothel);