Using a "MenuOverlayType" other than "None" results in a NullReferenceException

Users who are viewing this thread

naiski3

Recruit
I made a mod to allow mercenary contracts to expire (https://www.nexusmods.com/mountandblade2bannerlord/mods/147/) and I used a "GameMenu" to prompt the player with the decision to renew the contract or allow it to expire:

Code:
obj.AddGameMenu(
                "merc_contract_expiration",
                "Your mercenary contract has expired. You may choose to renew the contract for an additional 30 days or end the contract and surrender any fiefs.",
                null,
                TaleWorlds.CampaignSystem.Overlay.GameOverlays.MenuOverlayType.None,
                GameMenu.MenuFlags.none,
                null);

"MenuOverlayType.None" has "TEMP" written on it in big ugly red letters but any other overlay type results in a null reference exception:

Code:
System.NullReferenceException
  HResult=0x80004003
  Message=Object reference not set to an instance of an object.
  Source=TaleWorlds.CampaignSystem.ViewModelCollection
  StackTrace:
   at TaleWorlds.CampaignSystem.ViewModelCollection.GameMenu.SettlementMenuOverlayVM..ctor(MenuOverlayType type)
   at TaleWorlds.MountAndBlade.ViewModelCollection.GameMenu.GameMenuOverlay.GetOverlay(MenuOverlayType menuOverlayType)
   at SandBox.GauntletUI.Menu.GauntletMenuOverlayBase.OnInitialize()
   at SandBox.View.Menu.MenuViewContext.AddMenuView[T](Object[] parameters)
   at SandBox.View.Menu.MenuViewContext.CheckAndInitializeOverlay()
   at SandBox.View.Menu.MenuViewContext.TaleWorlds.CampaignSystem.IMenuContextHandler.OnMenuCreate()
   at SandBox.View.Menu.MenuViewContext..ctor(ScreenBase screen, MenuContext menuContext)
   at SandBox.View.Map.MapScreen.EnterMenuContext(MenuContext menuContext)
   at SandBox.View.Map.MapScreen.UpdateMenuView()
   at SandBox.View.Map.MapScreen.OnFrameTick(Single dt)
   at TaleWorlds.Engine.Screens.ScreenBase.FrameTick(Single dt)
   at TaleWorlds.Engine.Screens.ScreenManager.Tick(Single dt)

Wondering if I'm doing something wrong or if the other overlay types are just broken.

Full source available here: https://github.com/naiski/MercFix/blob/master/MercFix.cs
 
Back
Top Bottom