public static void GetEncyclopediaPageInstancePatch(ref EncyclopediaPageVM __result) { if (__result is EncyclopediaHeroPageVM) { EncyclopediaPageArgs args = (EncyclopediaPageArgs)typeof(EncyclopediaPageVM).GetField("_args", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(__result); __result = new EncyclopediaHeroPageVMExtensionVM(args); } else if (__result is EncyclopediaFactionPageVM) { EncyclopediaPageArgs args = (EncyclopediaPageArgs)typeof(EncyclopediaPageVM).GetField("_args", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(__result); __result = new EncyclopediaFactionPageVMExtensionVM(args); } }
public static void GetEncyclopediaPageInstancePostfix(ref EncyclopediaPageVM __result) { var args = (EncyclopediaPageArgs)AccessTools.Field(typeof(EncyclopediaPageVM), "_args").GetValue(__result); if (__result is EncyclopediaHeroPageVM) { __result = new EncyclopediaHeroPageVMExtensionVM(args); } else if (__result is EncyclopediaFactionPageVM) { __result = new EncyclopediaFactionPageVMExtensionVM(args); } }
public void ClosePage() { GauntletEncyclopediaScreenManager gauntletEncyclopediaScreenManager = MapScreen.Instance.EncyclopediaScreenManager as GauntletEncyclopediaScreenManager; if (gauntletEncyclopediaScreenManager == null) { return; } EncyclopediaData encyclopediaData = AccessTools.Field(typeof(GauntletEncyclopediaScreenManager), "_encyclopediaData").GetValue(gauntletEncyclopediaScreenManager) as EncyclopediaData; EncyclopediaPageVM encyclopediaPageVM = AccessTools.Field(typeof(EncyclopediaData), "_activeDatasource").GetValue(encyclopediaData) as EncyclopediaPageVM; this.selectedHeroPage = (encyclopediaPageVM as EncyclopediaHeroPageVM); if (this.selectedHeroPage == null) { return; } gauntletEncyclopediaScreenManager.CloseEncyclopedia(); }
public void ClosePage() { GauntletEncyclopediaScreenManager gauntletEncyclopediaScreenManager = MapScreen.Instance.EncyclopediaScreenManager as GauntletEncyclopediaScreenManager; if (gauntletEncyclopediaScreenManager == null) { return; } FieldInfo field = typeof(GauntletEncyclopediaScreenManager).GetField("_encyclopediaData", BindingFlags.Instance | BindingFlags.NonPublic); FieldInfo field2 = typeof(EncyclopediaData).GetField("_activeDatasource", BindingFlags.Instance | BindingFlags.NonPublic); EncyclopediaData encyclopediaData = (EncyclopediaData)field.GetValue(gauntletEncyclopediaScreenManager); EncyclopediaPageVM encyclopediaPageVM = (EncyclopediaPageVM)field2.GetValue(encyclopediaData); this.selectedHeroPage = (encyclopediaPageVM as EncyclopediaHeroPageVM); if (this.selectedHeroPage == null) { return; } gauntletEncyclopediaScreenManager.CloseEncyclopedia(); }
public static void OnTick(ref EncyclopediaPageVM __instance) { try { if (__instance is EncyclopediaUnitPageVM && __instance.Obj is CharacterObject characterObject && BannerlordCheatsSettings.Instance?.EnableHotkeys == true) { if (Keys.IsKeyPressed(InputKey.H, InputKey.LeftShift, InputKey.LeftControl)) { EnableHotkeysAddEncyclopediaTroops.AddTroops(characterObject, 10); } else if (Keys.IsKeyPressed(InputKey.H, InputKey.LeftControl)) { EnableHotkeysAddEncyclopediaTroops.AddTroops(characterObject, 1); } } } catch (Exception e) { SubModule.LogError(e, typeof(EnableHotkeysAddEncyclopediaTroops)); } }
public void OnEncyclopediaPageChanged(EncyclopediaPageChangedEvent e) { EncyclopediaData.EncyclopediaPages newPage = e.NewPage; if ((int)newPage != 12) { selectedHeroPage = null; selectedHero = null; if (gauntletLayerTopScreen != null && gauntletLayer != null) { gauntletLayerTopScreen.RemoveLayer(gauntletLayer); if (gauntletMovie != null) { gauntletLayer.ReleaseMovie(gauntletMovie); } gauntletLayerTopScreen = null; gauntletMovie = null; } return; } GauntletEncyclopediaScreenManager gauntletEncyclopediaScreenManager = MapScreen.Instance.EncyclopediaScreenManager as GauntletEncyclopediaScreenManager; if (gauntletEncyclopediaScreenManager == null) { return; } EncyclopediaData encyclopediaData = ReflectUtils.ReflectField <EncyclopediaData>("_encyclopediaData", gauntletEncyclopediaScreenManager); EncyclopediaPageVM encyclopediaPageVM = ReflectUtils.ReflectField <EncyclopediaPageVM>("_activeDatasource", encyclopediaData); selectedHeroPage = (encyclopediaPageVM as EncyclopediaHeroPageVM); if (selectedHeroPage == null) { return; } selectedHero = (selectedHeroPage.Obj as Hero); if (selectedHero == null) { return; } if (gauntletLayer == null) { gauntletLayer = new GauntletLayer(211, "GauntletLayer"); } try { if (viewModel == null) { viewModel = new HeroBuilderVM(delegate(Hero editHero) { InformationManager.DisplayMessage(new InformationMessage(new TextObject("{=CharacterCreation_EditAppearanceForHeroMessage}Entering edit appearance for: ").ToString() + editHero)); }); } viewModel.SetHero(selectedHero); gauntletMovie = gauntletLayer.LoadMovie("HeroEditor", viewModel); gauntletLayerTopScreen = ScreenManager.TopScreen; gauntletLayerTopScreen.AddLayer(gauntletLayer); gauntletLayer.InputRestrictions.SetInputRestrictions(true, InputUsageMask.MouseButtons); // Refresh selectedHeroPage.Refresh(); } catch (Exception ex) { // MessageBox.Show($"Error :\n{ex.Message} \n\n{ex.InnerException?.Message}"); } }
protected override void OnGameStart(Game game, IGameStarter gameStarterObject) { base.OnGameStart(game, gameStarterObject); if (!(game.GameType is Campaign)) { return; } AddModels(gameStarterObject as CampaignGameStarter); game.EventManager.RegisterEvent(delegate(EncyclopediaPageChangedEvent e) { EncyclopediaData.EncyclopediaPages newPage = e.NewPage; if ((int)newPage != 12) { this.selectedHeroPage = null; this.selectedHero = null; if (this.gauntletLayerTopScreen != null && this.gauntletLayer != null) { this.gauntletLayerTopScreen.RemoveLayer(this.gauntletLayer); if (this.gauntletMovie != null) { this.gauntletLayer.ReleaseMovie(this.gauntletMovie); } this.gauntletLayerTopScreen = null; this.gauntletMovie = null; } return; } GauntletEncyclopediaScreenManager gauntletEncyclopediaScreenManager = MapScreen.Instance.EncyclopediaScreenManager as GauntletEncyclopediaScreenManager; if (gauntletEncyclopediaScreenManager == null) { return; } FieldInfo field = typeof(GauntletEncyclopediaScreenManager).GetField("_encyclopediaData", BindingFlags.Instance | BindingFlags.NonPublic); FieldInfo field2 = typeof(EncyclopediaData).GetField("_activeDatasource", BindingFlags.Instance | BindingFlags.NonPublic); EncyclopediaData encyclopediaData = (EncyclopediaData)field.GetValue(gauntletEncyclopediaScreenManager); EncyclopediaPageVM encyclopediaPageVM = (EncyclopediaPageVM)field2.GetValue(encyclopediaData); this.selectedHeroPage = (encyclopediaPageVM as EncyclopediaHeroPageVM); if (this.selectedHeroPage == null) { return; } this.selectedHero = (this.selectedHeroPage.Obj as Hero); if (this.selectedHero == null) { return; } if (this.gauntletLayer == null) { this.gauntletLayer = new GauntletLayer(211, "GauntletLayer"); } try { if (this.viewModel == null) { this.viewModel = new HeroBuilderVM(this.heroModel, delegate(Hero editHero) { InformationManager.DisplayMessage(new InformationMessage("Entering edit appearance for: " + editHero)); }); } this.viewModel.SetHero(this.selectedHero); this.gauntletMovie = this.gauntletLayer.LoadMovie("HeroEditor", this.viewModel); this.gauntletLayerTopScreen = ScreenManager.TopScreen; this.gauntletLayerTopScreen.AddLayer(this.gauntletLayer); this.gauntletLayer.InputRestrictions.SetInputRestrictions(true, InputUsageMask.MouseButtons); // Refresh this.selectedHeroPage.Refresh(); } catch (Exception ex) { MessageBox.Show($"Error :\n{ex.Message} \n\n{ex.InnerException?.Message}"); } }); }