private void ContextMenu_ContextMenuOpening(object sender, System.Windows.Controls.ContextMenuEventArgs e) { // disable certain menu items if no map selected bool isMapSelected = (lstMaps.SelectedItem != null); bool isSessionPathValid = SessionPath.IsSessionPathValid(); menuReimporSelectedMap.IsEnabled = isMapSelected; menuOpenSelectedMapFolder.IsEnabled = isMapSelected; menuRenameSelectedMap.IsEnabled = isMapSelected; menuHideSelectedMap.IsEnabled = isMapSelected; menuOpenSessionFolder.IsEnabled = isSessionPathValid; menuOpenMapsFolder.IsEnabled = isSessionPathValid; if (isMapSelected) { MapListItem selected = (lstMaps.SelectedItem as MapListItem); bool hasImportLocation = MetaDataManager.IsImportLocationStored(selected); menuReimporSelectedMap.IsEnabled = hasImportLocation; menuReimporSelectedMap.ToolTip = hasImportLocation ? null : "You can only re-import if you imported the map from 'Import Map > From Computer ...' and imported a folder.\n(does not work with .zip files)"; menuHideSelectedMap.Header = selected.IsHiddenByUser ? "Show Selected Map ..." : "Hide Selected Map ..."; bool canBeDeleted = MetaDataManager.HasPathToMapFilesStored(selected); menuDeleteSelectedMap.IsEnabled = canBeDeleted; menuDeleteSelectedMap.ToolTip = canBeDeleted ? null : "You can only delete a map that has been imported via version 2.2.3 or greater."; } }
private void LoadMapInBackgroundAndContinueWith(Action <Task> continuationTask) { if (SessionPath.IsSessionPathValid() == false) { System.Windows.MessageBox.Show("You have selected an incorrect path to Session. Make sure the directory you choose has the folders 'Engine' and 'SessionGame'.", "Error!", MessageBoxButton.OK, MessageBoxImage.Error); return; } if (EzPzPatcher.IsGamePatched() == false && UnpackUtils.IsSessionUnpacked() == false) { MessageBoxResult result = System.Windows.MessageBox.Show("Session has not been patched yet. Click 'Patch With EzPz' to patch the game.", "Notice!", MessageBoxButton.OK, MessageBoxImage.Warning); return; } if (EzPzPatcher.IsGamePatched() == false && ViewModel.IsSessionUnpacked()) { if (ViewModel.IsOriginalMapFilesBackedUp() == false) { System.Windows.MessageBox.Show("The original Session game map files have not been backed up yet. Click OK to backup the files then click 'Load Map' again.", "Notice!", MessageBoxButton.OK, MessageBoxImage.Information); ViewModel.BackupOriginalMapFiles(); return; } } if (lstMaps.SelectedItem == null) { System.Windows.MessageBox.Show("Select a map to load first!", "Notice!", MessageBoxButton.OK, MessageBoxImage.Information); return; } MapListItem selectedItem = lstMaps.SelectedItem as MapListItem; if (selectedItem.IsValid == false) { System.Windows.MessageBox.Show("This map is missing the required Game Mode Override 'PBP_InGameSessionGameMode'.\n\nAdd a Game Mode to your map in UE4: '/Content/Data/PBP_InGameSessionGameMode.uasset'.\nThen reload the list of available maps.", "Error!", MessageBoxButton.OK, MessageBoxImage.Error); return; } ViewModel.UserMessage = $"Loading {selectedItem.MapName} ..."; ViewModel.InputControlsEnabled = false; Task t = Task.Run(() => ViewModel.LoadSelectedMap(selectedItem)); t.ContinueWith(continuationTask); }
private void SetAndValidateSessionPath(string path) { ViewModel.SetSessionPath(path); // this will save it to app settings ViewModel.SetCurrentlyLoadedMap(); if (SessionPath.IsSessionPathValid()) { ViewModel.ReloadAvailableMapsInBackground(); } else { System.Windows.MessageBox.Show("You may have selected an incorrect path to Session. Make sure the directory you choose has the folders 'Engine' and 'SessionGame'.", "Warning!", MessageBoxButton.OK, MessageBoxImage.Warning); } }
internal void OpenComputerImportWindow() { if (SessionPath.IsSessionPathValid() == false) { ViewModel.UserMessage = "Cannot import: You must set your path to Session before importing maps."; return; } ComputerImportViewModel importViewModel = new ComputerImportViewModel(); ComputerImportWindow importWindow = new ComputerImportWindow(importViewModel); importWindow.ShowDialog(); ViewModel.ReloadAvailableMapsInBackground(); // reload list of available maps as it may have changed }
private void LoadMapInBackgroundAndContinueWith(Action <Task> continuationTask) { if (SessionPath.IsSessionPathValid() == false) { System.Windows.MessageBox.Show("You have selected an incorrect path to Session. Make sure the directory you choose has the folders 'Engine' and 'SessionGame'.", "Error!", MessageBoxButton.OK, MessageBoxImage.Error); return; } if (UeModUnlocker.IsGamePatched() == false) { MessageBoxResult result = System.Windows.MessageBox.Show("Session has not been patched yet. Click 'Patch With Illusory Mod Unlocker' to patch the game.", "Notice!", MessageBoxButton.OK, MessageBoxImage.Warning); return; } if (lstMaps.SelectedItem == null) { System.Windows.MessageBox.Show("Select a map to load first!", "Notice!", MessageBoxButton.OK, MessageBoxImage.Information); return; } MapListItem selectedItem = lstMaps.SelectedItem as MapListItem; if (selectedItem.IsValid == false) { System.Windows.MessageBox.Show("This map is missing the required Game Mode Override 'PBP_InGameSessionGameMode'.\n\nAdd a Game Mode to your map in UE4: '/Content/Data/PBP_InGameSessionGameMode.uasset'.\nThen reload the list of available maps.", "Error!", MessageBoxButton.OK, MessageBoxImage.Error); return; } MessageService.Instance.ShowMessage($"Loading {selectedItem.MapName} ..."); ViewModel.InputControlsEnabled = false; Task t = Task.Run(() => ViewModel.LoadSelectedMap(selectedItem)); t.ContinueWith(continuationTask); }
private void ContextMenu_ContextMenuOpening(object sender, System.Windows.Controls.ContextMenuEventArgs e) { // disable certain menu items if no map selected bool isMapSelected = (lstMaps.SelectedItem != null); bool isSessionPathValid = SessionPath.IsSessionPathValid(); menuReimporSelectedMap.IsEnabled = isMapSelected; menuOpenSelectedMapFolder.IsEnabled = isMapSelected; menuRenameSelectedMap.IsEnabled = isMapSelected; menuHideSelectedMap.IsEnabled = isMapSelected; menuOpenSessionFolder.IsEnabled = isSessionPathValid; menuOpenMapsFolder.IsEnabled = isSessionPathValid; if (isMapSelected) { MapListItem selected = (lstMaps.SelectedItem as MapListItem); bool hasImportLocation = MetaDataManager.IsImportLocationStored(selected); menuReimporSelectedMap.IsEnabled = hasImportLocation; menuReimporSelectedMap.ToolTip = hasImportLocation ? null : "You can only re-import if you imported the map from 'Import Map > From Computer ...' and imported a folder.\n(does not work with .zip files)"; menuHideSelectedMap.Header = selected.IsHiddenByUser ? "Show Selected Map ..." : "Hide Selected Map ..."; if (ViewModel.SecondMapToLoad == null || ViewModel.SecondMapToLoad?.FullPath != selected.FullPath) { menuSecondMapToLoad.Header = "Set As Second Map To Load (When Leaving Apartment) ..."; menuSecondMapToLoad.ToolTip = "Set the map to be loaded after you leave the apartment (before starting the game)"; } else { menuSecondMapToLoad.ToolTip = "This will clear the selected map to not load after you leave the apartment"; menuSecondMapToLoad.Header = "Clear As Second Map To Load ..."; } bool canBeDeleted = MetaDataManager.HasPathToMapFilesStored(selected); menuDeleteSelectedMap.IsEnabled = canBeDeleted; menuDeleteSelectedMap.ToolTip = canBeDeleted ? null : "You can only delete a map that has been imported via version 2.2.3 or greater."; } }