public BoolWithMessage LoadDefaultMap(MapListItem map) { try { DeleteMapFilesFromNYCFolder(); string fileNamePrefix = "NYC01_Persistent"; string[] fileExtensions = { ".umap", ".uexp", "_BuiltData.uasset", "_BuiltData.uexp", "_BuiltData.ubulk" }; // copy NYC01_Persistent backup files back to original game location foreach (string fileExt in fileExtensions) { string fullPath = Path.Combine(SessionPath.ToOriginalSessionMapFiles, $"{fileNamePrefix}{fileExt}"); string targetPath = Path.Combine(SessionPath.ToNYCFolder, $"{fileNamePrefix}{fileExt}"); Logger.Info($"Copying {fullPath} -> {targetPath}"); File.Copy(fullPath, targetPath, true); } SetGameDefaultMapSetting(map.GameDefaultMapSetting, map.GlobalDefaultGameModeSetting); return(BoolWithMessage.True($"{map.MapName} Loaded!")); } catch (Exception e) { Logger.Error(e); return(BoolWithMessage.False($"Failed to load {map.MapName} : {e.Message}")); } }
public void Test_CopyMapFilesToNYCFolder_CopiesCorrectlyToFolder() { string nycPath = Path.Combine(new string[] { TestPaths.ToSessionTestFolder, "SessionGame", "Content", "Art", "Env", "NYC" }); SessionPath.ToSession = TestPaths.ToSessionTestFolder; MapListItem testMap = new MapListItem() { FullPath = Path.Combine(TestPaths.ToTestFilesFolder, "Mock_Map_Files", "testmap.umap"), MapName = "testmap" }; // delete files from nyc folder before doing actual copy if (Directory.Exists(nycPath)) { Directory.Delete(nycPath, true); Directory.CreateDirectory(nycPath); } EzPzMapSwitcher switcher = new EzPzMapSwitcher(); bool result = switcher.CopyMapFilesToNYCFolder(testMap); Assert.IsTrue(File.Exists(Path.Combine(nycPath, "testmap.umap"))); Assert.IsTrue(File.Exists(Path.Combine(nycPath, "testmap.uexp"))); Assert.IsTrue(File.Exists(Path.Combine(nycPath, "testmap_BuiltData.uexp"))); Assert.IsTrue(File.Exists(Path.Combine(nycPath, "testmap_BuiltData.uasset"))); Assert.IsTrue(File.Exists(Path.Combine(nycPath, "testmap_BuiltData.ubulk"))); }
/// <summary> /// Gets the custom map names from 'customNames.meta' file and updates /// list of maps with their custom names. /// </summary> /// <param name="maps"></param> /// <remarks> /// customNames.meta uses the map directory and the map name as the Key to find the correct custom map name /// </remarks> internal static void SetCustomPropertiesForMaps(IEnumerable <MapListItem> maps) { try { string pathToMetaFile = $"{FullPathToMetaFolder}\\customNames.meta"; if (File.Exists(pathToMetaFile) == false) { return; } foreach (string line in File.ReadAllLines(pathToMetaFile)) { string[] parts = line.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries); string dirPath = parts[0].Trim(); string mapName = parts[1].Trim(); string customName = parts[2].Trim(); string isHidden = parts[3].Trim(); MapListItem foundMap = maps.Where(m => m.DirectoryPath == dirPath && m.MapName == mapName).FirstOrDefault(); if (foundMap != null) { foundMap.CustomName = customName; foundMap.IsHiddenByUser = (isHidden.Equals("true", StringComparison.OrdinalIgnoreCase)); } } } catch (Exception) { } }
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."; } }
public BoolWithMessage LoadMap(MapListItem map) { if (SessionPath.IsSessionPathValid() == false) { return(BoolWithMessage.False("Cannot Load: 'Path to Session' is invalid.")); } if (SessionPath.IsSessionRunning() == false || FirstLoadedMap == null) { FirstLoadedMap = map; } if (map == DefaultSessionMap) { return(LoadOriginalMap()); } try { // delete session map file / custom maps from game DeleteMapFilesFromNYCFolder(); CopyMapFilesToNYCFolder(map); // update the ini file with the new map path string selectedMapPath = "/Game/Art/Env/NYC/" + map.MapName; SetGameDefaultMapSetting(selectedMapPath); return(BoolWithMessage.True($"{map.MapName} Loaded!")); } catch (Exception e) { return(BoolWithMessage.False($"Failed to load {map.MapName}: {e.Message}")); } }
IEnumerator GetMapList() { using (UnityWebRequest www = UnityWebRequest.Get(m_Sdk.ContentServer + EndPoint.MAP_LIST)) { www.SetRequestHeader("dev-token", m_Sdk.developerToken); yield return(www.SendWebRequest()); if (www.isNetworkError || www.isHttpError) { Debug.Log("****************\t" + www.error + "\t****************"); NotificationManager.Instance.GenerateWarning("Error: " + www.error); if (loaderPanel != null) { loaderPanel.SetActive(false); } } else { if (loaderPanel != null) { loaderPanel.SetActive(false); } try { string jsonResult = System.Text.Encoding.UTF8.GetString(www.downloadHandler.data); MapListItem mapListItem = JsonUtility.FromJson <MapListItem>(jsonResult); Debug.Log("Total Maps: " + mapListItem.map_list.Length.ToString()); for (int i = 0; i < mapListItem.map_list.Length; i++) { ItemTemplate = Instantiate(Resources.Load("prefabs/MapItem")) as GameObject; Transform mapItemTransform = ItemTemplate.transform; mapItemTransform.SetParent(listHolder.transform); mapItemTransform.localScale = Vector3.one; mapItemTransform.name = mapListItem.map_list[i].map_id; mapItemTransform.Find("name").GetComponent <Text>().text = mapListItem.map_list[i].map_name; string addressString = UnityWebRequest.UnEscapeURL(mapListItem.map_list[i].map_address); mapItemTransform.Find("address").GetComponent <Text>().text = addressString; if (mapListItem.map_list[i].map_image != null && mapListItem.map_list[i].map_image.Length > 0) { StartCoroutine(StoreImageFromUrl(mapListItem.map_list[i].map_image, mapItemTransform.Find("image").GetComponent <Image>())); } } } catch (Exception e) { Debug.LogException(e, this); } } } }
public static void SendCreateMap(int location, Guid currentMapId, MapListItem parent) { if (location > -1) { Network.SendPacket(new CreateMapPacket(currentMapId, (byte)location)); } else { if (parent == null) { Network.SendPacket(new CreateMapPacket(0, Guid.Empty)); } else { if (parent.GetType() == typeof(MapListMap)) { Network.SendPacket(new CreateMapPacket(1, ((MapListMap)parent).MapId)); } else { Network.SendPacket(new CreateMapPacket(0, ((MapListFolder)parent).FolderId)); } } } }
void Delete_Click(object sender, TomShane.Neoforce.Controls.EventArgs e) { if (MapList.Items.Count == 0) { return; } MapListItem item = (MapList.Items[MapList.ItemIndex] as MapListItem); MapList.Enabled = false; MessageBox confirmDelete = new MessageBox(Manager, MessageBoxType.YesNo, "Are you sure you would like to delete " + item.MapName.Text + " ?\nIt will be lost forever.", "Confirm Deletion"); confirmDelete.Init(); confirmDelete.buttons[0].Text = "Delete"; confirmDelete.buttons[1].Text = "Cancel"; confirmDelete.buttons[0].Color = Color.Red; confirmDelete.Closed += new WindowClosedEventHandler(delegate(object s, WindowClosedEventArgs ev) { if ((s as Dialog).ModalResult == ModalResult.Yes) { IO.DeleteMap(item.MapName.Text); MapList.Items.Remove(item); if (MapList.Items.Count > 0) { MapList.ItemIndex = 0; (MapList.Items[MapList.ItemIndex] as MapListItem).sb.Color = Color.LightGreen; } } MapList.Enabled = true; }); confirmDelete.ShowModal(); Manager.Add(confirmDelete); }
void MapList_ItemIndexChanged(object sender, TomShane.Neoforce.Controls.EventArgs e) { List(); if (MapList.Items.Count > 0) { foreach (MapListItem C in MapList.Items) { C.sb.Color = Color.White; } (MapList.Items[MapList.ItemIndex] as MapListItem).sb.Color = Color.LightGreen; MapListItem item = (MapList.Items[MapList.ItemIndex] as MapListItem); try { string[] Data = IO.GetLevelData(item.MapName.Text); Map.Text = item.MapName.Text; Author.Text = "By: " + Data[0]; Description.Text = "Description: " + Data[1]; Version.Text = "Game Version: " + Data[2]; LastSaved.Text = "Last Played: " + Data[3]; Size.Text = "Size: " + Data[5] + "x" + Data[6]; Seed.Text = "Seed: " + Data[4]; } catch (Exception ex) { System.Diagnostics.Debug.WriteLine("Exception: " + ex.ToString()); } } }
public static MapMetaData LoadMapMetaData(MapListItem mapItem) { try { CreateMetaDataFolder(); string fileName; if (!string.IsNullOrWhiteSpace(mapItem.DirectoryPath)) { DirectoryInfo dirInfo = new DirectoryInfo(mapItem.DirectoryPath); fileName = $"{dirInfo.Name}_{mapItem.MapName}_meta.json"; } else { fileName = $"{mapItem.MapName}_meta.json"; } string pathToFile = Path.Combine(FullPathToMetaFolder, fileName); string fileContents = File.ReadAllText(pathToFile); return(JsonConvert.DeserializeObject <MapMetaData>(fileContents)); } catch (Exception e) { Logger.Error("failed to load map meta data"); Logger.Error(e); return(null); } }
public static void SendAddFolder(MapListItem parent) { if (parent == null) { Network.SendPacket(new MapListUpdatePacket(MapListUpdates.AddFolder, 0, Guid.Empty, 0, Guid.Empty, "")); } else { if (parent.GetType() == typeof(MapListMap)) { Network.SendPacket( new MapListUpdatePacket( MapListUpdates.AddFolder, 0, Guid.Empty, 1, ((MapListMap)parent).MapId, "" ) ); } else { Network.SendPacket( new MapListUpdatePacket( MapListUpdates.AddFolder, 0, Guid.Empty, 0, ((MapListFolder)parent).FolderId, "" ) ); } } }
public static MapListItem GetFirstMapInFolder(string sourceMapFolder, bool isValid) { foreach (string file in Directory.GetFiles(sourceMapFolder, "*.umap")) { FileInfo fileInfo = new FileInfo(file); MapListItem map = new MapListItem() { FullPath = file, MapName = fileInfo.NameWithoutExtension() }; map.Validate(); if (map.IsValid == isValid) { return(map); } } foreach (string dir in Directory.GetDirectories(sourceMapFolder)) { MapListItem foundMap = GetFirstMapInFolder(dir, isValid); if (foundMap != null) { return(foundMap); } } return(null); }
public static MapMetaData CreateMapMetaData(string sourceMapFolder, bool findMapFiles) { MapMetaData metaData = new MapMetaData(); metaData.IsHiddenByUser = false; metaData.CustomName = ""; MapListItem validMap = GetFirstMapInFolder(sourceMapFolder, isValid: true); if (validMap == null) { return(null); } metaData.MapName = validMap.MapName; metaData.MapFileDirectory = ReplaceSourceMapPathWithPathToContent(sourceMapFolder, validMap.DirectoryPath); if (findMapFiles) { metaData.FilePaths = FileUtils.GetAllFilesInDirectory(sourceMapFolder); // modify file paths to match the target folder Session "Content" folder for (int i = 0; i < metaData.FilePaths.Count; i++) { metaData.FilePaths[i] = ReplaceSourceMapPathWithPathToContent(sourceMapFolder, metaData.FilePaths[i]); } } else { metaData.FilePaths = new List <string>(); } return(metaData); }
public EzPzMapSwitcher() { DefaultSessionMap = new MapListItem() { FullPath = SessionPath.ToOriginalSessionMapFiles, MapName = "Session Default Map - Brooklyn Banks" }; }
private async void OnListItemClick(object sender, SelectionChangedEventArgs e) { MapListItem item = (MapListItem)e.AddedItems[0]; await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => Frame.Navigate(item.Type, item.Name) ); }
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 LoadMapInBackgroundAndContinueWith(Action <Task> continuationTask) { if (ViewModel.IsSessionUnpacked() == false) { MessageBoxResult result = System.Windows.MessageBox.Show("It seems the Session game has not been unpacked. This is required before using Map Switcher.\n\nWould you like to download the required files to auto-unpack?", "Notice!", MessageBoxButton.YesNo, MessageBoxImage.Warning, MessageBoxResult.Yes); if (result == MessageBoxResult.Yes) { BeginUnpackingProcess(); } return; } 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); BackupMapFilesInBackground(); 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.DisplayName} ..."; ViewModel.InputControlsEnabled = false; Task t = Task.Run(() => ViewModel.LoadMap(selectedItem)); t.ContinueWith(continuationTask); }
public BoolWithMessage LoadMap(MapListItem map) { if (SessionPath.IsSessionPathValid() == false) { return(BoolWithMessage.False("Cannot Load: 'Path to Session' is invalid.")); } if (map == null) { return(BoolWithMessage.False("Cannot Load: map is null")); } if (SessionPath.IsSessionRunning() == false || FirstLoadedMap == null) { FirstLoadedMap = map; } if (Directory.Exists(SessionPath.ToNYCFolder) == false) { Directory.CreateDirectory(SessionPath.ToNYCFolder); } if (map.IsDefaultMap) { return(LoadDefaultMap(map)); } try { // delete session map file / custom maps from game DeleteMapFilesFromNYCFolder(); CopyMapFilesToNYCFolder(map); // update the ini file with the new map path // .. when the game is running the map file is renamed to NYC01_Persistent so it can load when you leave the apartment string selectedMapPath = "/Game/Art/Env/NYC/NYC01_Persistent"; if (SessionPath.IsSessionRunning() == false) { selectedMapPath = $"/Game/Art/Env/NYC/{map.MapName}"; } SetGameDefaultMapSetting(selectedMapPath); return(BoolWithMessage.True($"{map.MapName} Loaded!")); } catch (Exception e) { Logger.Error(e); return(BoolWithMessage.False($"Failed to load {map.MapName}: {e.Message}")); } }
internal static string GetOriginalImportLocation(MapListItem map) { MapMetaData metaData = LoadMapMetaData(map); if (metaData == null) { return(""); } return(metaData.OriginalImportPath); }
public static bool HasPathToMapFilesStored(MapListItem map) { MapMetaData metaData = LoadMapMetaData(map); if (metaData != null) { return(metaData.FilePaths?.Count > 0); } return(false); }
public static MapMetaData CreateMapMetaData(MapListItem map) { MapMetaData metaData = new MapMetaData(); metaData.MapName = map.MapName; metaData.MapFileDirectory = map.DirectoryPath; metaData.FilePaths = new List <string>(); metaData.IsHiddenByUser = map.IsHiddenByUser; metaData.CustomName = map.CustomName; return(metaData); }
public void Test_DirectoryPath_ReturnsCorrectPath() { MapListItem testItem = new MapListItem() { FullPath = Path.Combine(TestPaths.ToTestFilesFolder, "Mock_Map_Files", "testmap.umap"), MapName = "testmap" }; string expectedPath = Path.Combine(TestPaths.ToTestFilesFolder, "Mock_Map_Files"); Assert.AreEqual(expectedPath, testItem.DirectoryPath); }
private void MenuOpenSelectedMapFolder_Click(object sender, RoutedEventArgs e) { if (lstMaps.SelectedItem == null) { MessageService.Instance.ShowMessage("Cannot open folder: No map selected."); return; } MapListItem selectedMap = lstMaps.SelectedItem as MapListItem; ViewModel.OpenFolderToSelectedMap(selectedMap); }
private void MenuOpenSelectedMapFolder_Click(object sender, RoutedEventArgs e) { if (lstMaps.SelectedItem == null) { ViewModel.UserMessage = "Cannot open folder: No map selected."; return; } MapListItem selectedMap = lstMaps.SelectedItem as MapListItem; ViewModel.OpenFolderToSelectedMap(selectedMap); }
/// <summary> /// Gets the meta .json for the map if it exists and updates /// the custom name and IsHiddenByUser property /// </summary> public static void SetCustomPropertiesForMap(MapListItem map, bool createIfNotExists = false) { if (map.IsDefaultMap) { return; } MapMetaData savedMetaData = LoadMapMetaData(map); if (savedMetaData == null) { if (createIfNotExists) { savedMetaData = CreateMapMetaData(map); SaveMapMetaData(savedMetaData); } else { return; } } // grab image from asset store if exists and path not set yet bool hasChanged = false; if (!string.IsNullOrWhiteSpace(savedMetaData.PathToImage) && !File.Exists(savedMetaData.PathToImage)) { // remove image path if file does not exist savedMetaData.PathToImage = ""; hasChanged = true; } if (string.IsNullOrWhiteSpace(savedMetaData.PathToImage) && !string.IsNullOrEmpty(savedMetaData.AssetNameWithoutExtension)) { string pathToStoreThumbnail = Path.Combine(AssetStoreViewModel.AbsolutePathToThumbnails, savedMetaData.AssetNameWithoutExtension); if (File.Exists(pathToStoreThumbnail)) { savedMetaData.PathToImage = pathToStoreThumbnail; hasChanged = true; } } if (hasChanged) { SaveMapMetaData(savedMetaData); } map.IsHiddenByUser = savedMetaData.IsHiddenByUser; map.CustomName = savedMetaData.CustomName; map.PathToImage = savedMetaData.PathToImage; }
public bool CopyMapFilesToNYCFolder(MapListItem map) { if (SessionPath.IsSessionPathValid() == false) { return(false); } // copy all files related to map to game directory foreach (string fileName in Directory.GetFiles(map.DirectoryPath)) { if (fileName.Contains(map.MapName)) { FileInfo fi = new FileInfo(fileName); string fullTargetFilePath = SessionPath.ToNYCFolder; if (SessionPath.IsSessionRunning() && FirstLoadedMap != null) { // while the game is running, the map being loaded must have the same name as the initial map that was loaded when the game first started. // ... thus we build the destination filename based on what was first loaded. if (FirstLoadedMap.IsDefaultMap) { fullTargetFilePath = Path.Combine(fullTargetFilePath, "NYC01_Persistent"); // this is the name of the default map that is loaded } else { fullTargetFilePath = Path.Combine(fullTargetFilePath, FirstLoadedMap.MapName); } if (fileName.Contains("_BuiltData")) { fullTargetFilePath += $"_BuiltData{fi.Extension}"; } else { fullTargetFilePath += fi.Extension; } } else { // if the game is not running then the files can be copied as-is (file names do not need to be changed) string targetFileName = fileName.Replace(map.DirectoryPath, ""); fullTargetFilePath += targetFileName; } Logger.Info($"... copying {fileName} -> {fullTargetFilePath}"); File.Copy(fileName, fullTargetFilePath, true); } } return(true); }
public void Test_Validate_MissingFile_ValidationHint_Set() { MapListItem testItem = new MapListItem() { FullPath = Path.Combine(TestPaths.ToTestFilesFolder, "Mock_Map_Files", "notAMap.umap"), MapName = "notAMap" }; testItem.Validate(); string expectedHint = "(file missing)"; Assert.AreEqual(expectedHint, testItem.ValidationHint); }
public void StartGameAndLoadSecondMap() { // validate and set game settings bool didSet = UpdateGameSettings(); if (didSet == false) { // do not start game with invalid settings UserMessage = $"NOTE: Cannot apply custom game settings - {UserMessage}"; } Process.Start(SessionPath.ToSessionExe); if (LoadSecondMapIsChecked == false) { return; // do not continue as the second map does not need to be loaded } Task loadTask = Task.Factory.StartNew(() => { MapListItem mapToLoadNext = SecondMapToLoad; if (mapToLoadNext == null) { mapToLoadNext = AvailableMaps.Where(m => m.MapName == CurrentlyLoadedMapName).FirstOrDefault(); } int timeToWaitInMilliseconds = 20000; if (MapSwitcher is UnpackedMapSwitcher) { // wait longer for unpacked games to load since they load slower timeToWaitInMilliseconds = 25000; } System.Threading.Thread.Sleep(timeToWaitInMilliseconds); // wait few seconds before loading the next map to let the game finish loading LoadSelectedMap(mapToLoadNext); }); loadTask.ContinueWith((result) => { if (result.IsFaulted) { Logger.Warn(result.Exception.GetBaseException(), "failed to load second map"); return; } }); }
private void MenuHideSelectedMap_Click(object sender, RoutedEventArgs e) { if (lstMaps.SelectedItem == null) { System.Windows.MessageBox.Show("Select a map to hide/show first!", "Notice!", MessageBoxButton.OK, MessageBoxImage.Information); return; } MapListItem selectedItem = lstMaps.SelectedItem as MapListItem; ViewModel.ToggleVisiblityOfMap(selectedItem); }
public void Test_CopyMapFilesToNYCFolder_ReturnsTrue() { SessionPath.ToSession = TestPaths.ToSessionTestFolder; MapListItem testMap = new MapListItem() { FullPath = Path.Combine(TestPaths.ToTestFilesFolder, "Mock_Map_Files", "testmap.umap"), MapName = "testmap" }; EzPzMapSwitcher switcher = new EzPzMapSwitcher(); bool result = switcher.CopyMapFilesToNYCFolder(testMap); Assert.IsTrue(result); }
public bool OnCreatingResponse(PacketSession session, Packet requestPacket, Packet responsePacket) { // Check the given map code var map = session.Server.AvailableMaps.FirstOrDefault(x => x.Code == requestPacket.Words[1]); if (map == null) { responsePacket.Words.Add(Constants.RESPONSE_INVALID_MAP); return true; } // check the given game mode code var gameMode = session.Server.AvailableModes.FirstOrDefault(x => x.Code == requestPacket.Words[2]); if (gameMode == null) { responsePacket.Words.Add(Constants.RESPONSE_INVALID_GAME_MODE_ON_MAP); return true; } // check game mode available for map if (map.SupportedModes.All(x => x.Code != gameMode.Code)) { responsePacket.Words.Add(Constants.RESPONSE_INVALID_GAME_MODE_ON_MAP); return true; } // check rounds given var rounds = Convert.ToInt32(requestPacket.Words[3]); if (rounds < 1) { responsePacket.Words.Add(Constants.RESPONSE_INVALID_ROUNDS_PER_MAP); return true; } var mapListItem = new MapListItem() { Map = map, Mode = gameMode, Rounds = rounds, }; var mapList = session.Server.MapList; if (requestPacket.Words.Count <= 4) { mapList.Add(mapListItem); } else { // check the index given var index = Convert.ToInt32(requestPacket.Words[4]); if (index <= 0 || index >= mapList.Count) { mapList.Insert(index, mapListItem); } else { responsePacket.Words.Add(Constants.RESPONSE_INVALID_MAP_INDEX); return true; } } responsePacket.Words.Add(Constants.RESPONSE_SUCCESS); return true; }
public MapListItemViewModel(MapListItem item, Action<Action> synchronousInvoker) : base(synchronousInvoker) { Item = item; }