public static BoolWithMessage DeleteTextureFiles(TextureMetaData metaData) { if (metaData == null) { return(BoolWithMessage.False($"meta data is null")); } if (metaData.FilePaths?.Count == 0) { return(BoolWithMessage.False($"List of files to delete is unknown for {metaData.Name}.")); } try { BoolWithMessage result = FileUtils.DeleteFiles(metaData.FilePaths); if (result.Result == false) { return(result); } // lastly delete entry from list of installed textures InstalledTexturesMetaData currentlyInstalledTextures = MetaDataManager.LoadTextureMetaData(); currentlyInstalledTextures.Remove(metaData); MetaDataManager.SaveTextureMetaData(currentlyInstalledTextures); return(BoolWithMessage.True($"{metaData.Name} has been deleted!")); } catch (Exception e) { return(BoolWithMessage.False($"Failed to delete files: {e.Message}")); } }
public static BoolWithMessage DeleteMapFiles(MapMetaData metaData) { if (metaData == null) { return(BoolWithMessage.False($"meta data is null")); } if (metaData.FilePaths?.Count == 0) { return(BoolWithMessage.False($"List of files to delete is unknown for {metaData.MapName}. You must manually delete the map files from the following folder: {metaData.MapFileDirectory}")); } try { BoolWithMessage result = FileUtils.DeleteFiles(metaData.FilePaths); if (result.Result == false) { return(result); } // lastly delete meta data file string pathToMetaData = Path.Combine(MetaDataManager.FullPathToMetaFolder, metaData.GetJsonFileName()); if (File.Exists(pathToMetaData)) { File.Delete(pathToMetaData); } return(BoolWithMessage.True($"{metaData.MapName} has been deleted!")); } catch (Exception e) { return(BoolWithMessage.False($"Failed to delete files: {e.Message}")); } }
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 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}")); } }
public BoolWithMessage BackupOriginalMapFiles() { if (SessionPath.IsSessionPathValid() == false) { return(BoolWithMessage.False("Cannot backup: 'Path to Session' is invalid.")); } if (IsOriginalMapFilesBackedUp()) { // the files are already backed up return(BoolWithMessage.False("Skipping backup: original files already backed up.")); } if (DoesOriginalMapFileExistInGameDirectory() == false) { // the original files are missing from the Session directory return(BoolWithMessage.False("Cannot backup: original map files for Session are missing from Session game directory.")); } try { // create folder if it doesn't exist Directory.CreateDirectory(SessionPath.ToOriginalSessionMapFiles); string fileNamePrefix = "NYC01_Persistent"; string[] fileExtensionsToCheck = { ".umap", ".uexp", "_BuiltData.uasset", "_BuiltData.uexp", "_BuiltData.ubulk" }; // copy NYC01_Persistent files to backup folder foreach (string fileExt in fileExtensionsToCheck) { string fullPathToFile = Path.Combine(SessionPath.ToNYCFolder, $"{fileNamePrefix}{fileExt}"); string destFilePath = Path.Combine(SessionPath.ToOriginalSessionMapFiles, $"{fileNamePrefix}{fileExt}"); File.Copy(fullPathToFile, destFilePath, overwrite: true); } } catch (Exception e) { Logger.Error(e); string errorMsg = $"Failed to backup original map files: {e.Message}"; return(BoolWithMessage.False(errorMsg)); } bool originalMapFilesBackedUp = IsOriginalMapFilesBackedUp(); DefaultMaps.ForEach(m => { m.IsEnabled = originalMapFilesBackedUp; m.Tooltip = m.IsEnabled ? null : "The original Session game files have not been backed up to the custom Maps folder."; }); return(new BoolWithMessage(IsOriginalMapFilesBackedUp())); }
public BoolWithMessage LoadDefaultMap(MapListItem defaultMap) { try { DeleteMapFilesFromNYCFolder(); SetGameDefaultMapSetting(defaultMap.GameDefaultMapSetting, defaultMap.GlobalDefaultGameModeSetting); return(BoolWithMessage.True($"{defaultMap.MapName} Loaded!")); } catch (Exception e) { Logger.Error(e); return(BoolWithMessage.False($"Failed to load {defaultMap.MapName} : {e.Message}")); } }
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.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 string 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}")); } }
/// <summary> /// Handles the entire patching process /// ... download zip files /// ... extract zip files /// ... run UnrealPak.exe and EzPz /// </summary> internal void StartPatchingAsync(string pathToSession) { this.PathToSession = pathToSession; bool didEzPzDownload = false; Logger.Info("Starting EzPz Patch Process ..."); // download the zip file in the background Task t = Task.Factory.StartNew(() => { // // Download required files // // download the EzPz .zip if we are NOT skipping the patching step if (SkipEzPzPatchStep == false) { didEzPzDownload = DownloadEzPzModZip(); Logger.Info($"didEzPzDownload: {didEzPzDownload}"); } else { Logger.Info($"... skipping ezpz download"); didEzPzDownload = true; } }); t.ContinueWith((task) => { if (task.IsFaulted) { Logger.Error(task.Exception, "patch task faulted"); PatchCompleted(false); return; } if (!didEzPzDownload) { Logger.Warn("Failed to download files, cannot continue"); PatchCompleted(false); return; } if (SkipEzPzPatchStep == false) { string pathToZip = Path.Combine(SessionPath.ToPaks, DownloadedPatchFileName); Logger.Info($"Extracting Ezpz.zip; File exist? {File.Exists(pathToZip)}"); if (File.Exists(pathToZip)) { ProgressChanged("Extracting EzPz .zip files ..."); BoolWithMessage isEzPzExtracted = BoolWithMessage.False(""); try { FileUtils.ExtractZipFile(pathToZip, SessionPath.ToPaks); } catch (Exception e) { Logger.Error(e, "failed to extract zip"); ProgressChanged($"Failed to unzip file: {e.Message}. Cannot continue."); isEzPzExtracted.Message = e.Message; PatchCompleted(false); } if (isEzPzExtracted.Result == false) { ProgressChanged($"Failed to unzip file: {isEzPzExtracted.Message}. Cannot continue."); PatchCompleted(false); return; } } else { ProgressChanged($".zip file does not exist - {pathToZip}"); PatchCompleted(false); return; } } // // Run EzPz Mod .exe and/or UnrealPak .exe to extract object dropper file // bool runSuccess = true; Task waitTask = Task.Factory.StartNew(() => { try { if (SkipEzPzPatchStep == false) { LaunchEzPzMod(); } } catch (Exception e) { ProgressChanged($"Failed to run UnrealPak.exe or EzPz Mod: {e.Message}. Cannot continue"); runSuccess = false; } }); waitTask.ContinueWith((antecedent) => { if (runSuccess == false) { PatchCompleted(false); return; } DeleteDownloadedFilesInPakFolder(); PatchCompleted(true); }); }); }