public void OpenSettings() { var viewModel = new SettingsDialogViewModel(_configManager, _teamService); #pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed _ = viewModel.InitializeAsync(); #pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed var window = new SettingsDialog { DataContext = viewModel }; window.Closing += (e, cancelEventArgs) => viewModel.OnCloseWindowRequest(cancelEventArgs); viewModel.RequestClose += () => window.Close(); window.ShowDialog(); }
public static void Postfix(ref MainMenuScreen __instance) { // We only need to do this once. In fact, not checking this probably results in the game freezing due // to an infinite recursion. if (!CustomUIManager.AreTemplatesInitalized()) { // Find the current ScreenManager to access the Settigns Screen and Settings Dialog, as the Settings // Dialog contains a lot of UI elements and is helpful in creating templates. ScreenManager screenManager = Traverse.Create(Traverse.Create(__instance).Field("gameStateManager").GetValue <GameStateManager>()).Field("screenManager").GetValue <ScreenManager>(); SettingsScreen settingsScreen = (SettingsScreen)screenManager.GetScreen(ScreenName.Settings); SettingsDialog settingsDialog = Traverse.Create(settingsScreen).Field("settingsDialog").GetValue <SettingsDialog>(); // We need to actually open the Settings Dialog in order for the UI elements to initalize correctly. screenManager.ShowScreen(ScreenName.Settings); settingsDialog.Open(); settingsDialog.Close(); // Use the Patch Notes Dialog as a template for custom dialogs PatchNotesUI patch = Traverse.Create(__instance).Field("patchNotesDialog").GetValue <PatchNotesUI>(); ScreenDialog dialogTemplate = Traverse.Create(patch).Field("dialog").GetValue <ScreenDialog>(); CustomUIManager.InitalizeTemplates(settingsScreen, dialogTemplate, settingsDialog); // Pretend that nothing has happend and return to the main menu. screenManager.ReturnToMainMenu(); } }
public void Dispose() => _dialog?.Close();