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}"));
            }
        }
Esempio n. 4
0
        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}"));
            }
        }
Esempio n. 5
0
        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}"));
            }
        }