Beispiel #1
0
        /// <summary>
        /// Determine the correct UserDataPath for this save game if at all possible to allow finding the mods folder.
        /// </summary>
        /// <param name="savePath"></param>
        /// <returns></returns>
        public static UserDataPath FindFromSavePath(string savePath)
        {
            var dp = SpaceEngineersConsts.BaseLocalPath;
            var basePath = GetPathBase(savePath, "Saves");
            if (basePath != null)
            {
                dp = new UserDataPath(Path.Combine(basePath, "Saves"), Path.Combine(basePath, "Mods"));
            }

            return dp;
        }
Beispiel #2
0
        /// <summary>
        /// Determine the correct UserDataPath for this save game if at all possible to allow finding the mods folder.
        /// </summary>
        /// <param name="savePath"></param>
        /// <returns></returns>
        public static UserDataPath FindFromSavePath(string savePath)
        {
            var dp       = SpaceEngineersConsts.BaseLocalPath;
            var basePath = GetPathBase(savePath, "Saves");

            if (basePath != null)
            {
                dp = new UserDataPath(Path.Combine(basePath, "Saves"), Path.Combine(basePath, "Mods"));
            }

            return(dp);
        }
        static SpaceEngineersConsts()
        {
            // Don't access the ObjectBuilders from the static ctor, as it will cause issues with the Serializer type loader.

            var basePath = "SpaceEngineers";
            if (GlobalSettings.Default.SEBinPath.Contains("MedievalEngineers", StringComparison.InvariantCulture))
                basePath = "MedievalEngineers";

            BaseLocalPath = new UserDataPath(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), basePath + @"\Saves", basePath + @"\Mods"); // Followed by .\%SteamuserId%\LastLoaded.sbl
            BaseDedicatedServerHostPath = new UserDataPath(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), basePath + @"Dedicated\Saves", basePath + @"Dedicated\Mods"); // Followed by .\LastLoaded.sbl
            BaseDedicatedServerServicePath = new UserDataPath(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), basePath + @"Dedicated", ""); // Followed by .\%instancename%\Saves\LastLoaded.sbl  (.\%instancename%\Mods)
        }
Beispiel #4
0
        /// <summary>
        /// Determine the correct UserDataPath for this save game if at all possible to allow finding the mods folder.
        /// </summary>
        /// <param name="savePath"></param>
        /// <returns></returns>
        public static UserDataPath FindFromSavePath(string savePath)
        {
            var dp       = SpaceEngineersConsts.BaseLocalPath;
            var basePath = GetPathBase(savePath, SpaceEngineersConsts.SavesFolder);

            if (basePath != null)
            {
                dp = new UserDataPath(basePath, SpaceEngineersConsts.SavesFolder, SpaceEngineersConsts.ModsFolder, SpaceEngineersConsts.BlueprintsFolder);
            }

            return(dp);
        }
        static SpaceEngineersConsts()
        {
            // Don't access the ObjectBuilders from the static ctor, as it will cause issues with the Serializer type loader.

            var basePath = "SpaceEngineers";

            //if (GlobalSettings.Default.SEBinPath.Contains("MedievalEngineers", StringComparison.InvariantCulture))
            //    basePath = "MedievalEngineers";

            BaseLocalPath = new UserDataPath(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), basePath + @"\Saves", basePath + @"\Mods");                                    // Followed by .\%SteamuserId%\LastLoaded.sbl
            BaseDedicatedServerHostPath    = new UserDataPath(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), basePath + @"Dedicated\Saves", basePath + @"Dedicated\Mods"); // Followed by .\LastLoaded.sbl
            BaseDedicatedServerServicePath = new UserDataPath(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), basePath + @"Dedicated", "");                           // Followed by .\%instancename%\Saves\LastLoaded.sbl  (.\%instancename%\Mods)
        }
Beispiel #6
0
        internal WorldResource LoadSaveFromPath(string savePath, string userName, SaveWorldType saveType, UserDataPath dataPath)
        {
            var saveResource = new WorldResource
            {
                GroupDescription = string.Format("{0}: {1}", new EnumToResouceConverter().Convert(saveType, typeof(string), null, CultureInfo.CurrentUICulture), userName),
                SaveType = saveType,
                Savename = Path.GetFileName(savePath),
                UserName = userName,
                Savepath = savePath,
                DataPath = dataPath,
            };

            return saveResource;
        }
Beispiel #7
0
        private IEnumerable<WorldResource> FindSaveFiles(string lastLoadedPath, string userName, SaveWorldType saveType, UserDataPath dataPath)
        {
            var lastLoadedFile = Path.Combine(lastLoadedPath, SpaceEngineersConsts.LoadLoadedFilename);
            var list = new List<WorldResource>();

            // Ignore any other base Save paths without the LastLoaded file.
            if (File.Exists(lastLoadedFile))
            {
                MyObjectBuilder_LastLoadedTimes lastLoaded = null;
                try
                {
                    lastLoaded = SpaceEngineersApi.ReadSpaceEngineersFile<MyObjectBuilder_LastLoadedTimes>(lastLoadedFile);
                }
                catch { }
                var savePaths = Directory.GetDirectories(lastLoadedPath);

                // Still check every potential game world path.
                foreach (var savePath in savePaths)
                {
                    var saveResource = LoadSaveFromPath(savePath, userName, saveType, dataPath);
                    if (lastLoaded != null)
                    {
                        var last = lastLoaded.LastLoaded.Dictionary.FirstOrDefault(d => d.Key.Equals(savePath, StringComparison.OrdinalIgnoreCase));
                        if (last.Key != null)
                        {
                            saveResource.LastLoadTime = last.Value;
                        }
                    }

                    // This should still allow Games to be copied into the Save path manually.

                    saveResource.LoadCheckpoint();
                    list.Add(saveResource);
                }
            }

            return list;
        }
Beispiel #8
0
        private void LoadSaveList()
        {
            Worlds.Clear();
            var list = new List<WorldResource>();

            #region local saves

            if (Directory.Exists(BaseLocalPath.SavesPath))
            {
                var userPaths = Directory.GetDirectories(BaseLocalPath.SavesPath);

                foreach (var userPath in userPaths)
                {
                    var userName = Path.GetFileName(userPath);
                    list.AddRange(FindSaveFiles(userPath, userName, SaveWorldType.Local, BaseLocalPath));
                }
            }

            #endregion

            #region Host Server

            if (Directory.Exists(BaseDedicatedServerHostPath.SavesPath))
            {
                list.AddRange(FindSaveFiles(BaseDedicatedServerHostPath.SavesPath, "Local / Console", SaveWorldType.DedicatedServerHost, BaseDedicatedServerHostPath));
            }

            #endregion

            #region Service Server

            if (Directory.Exists(BaseDedicatedServerServicePath.SavesPath))
            {
                var instancePaths = Directory.GetDirectories(BaseDedicatedServerServicePath.SavesPath);

                foreach (var instancePath in instancePaths)
                {
                    var lastLoadedPath = Path.Combine(instancePath, "Saves");

                    if (Directory.Exists(lastLoadedPath))
                    {
                        var instanceName = Path.GetFileName(instancePath);
                        var dataPath = new UserDataPath(lastLoadedPath, Path.Combine(instancePath, "Mods"));
                        list.AddRange(FindSaveFiles(lastLoadedPath, instanceName, SaveWorldType.DedicatedServerService, dataPath));
                    }
                }
            }

            #endregion

            foreach (var item in list.OrderByDescending(w => w.LastLoadTime))
                Worlds.Add(item);
        }
Beispiel #9
0
 public void Load(UserDataPath baseLocalPath, UserDataPath baseDedicatedServerHostPath, UserDataPath baseDedicatedServerServicePath)
 {
     BaseLocalPath = baseLocalPath;
     BaseDedicatedServerHostPath = baseDedicatedServerHostPath;
     BaseDedicatedServerServicePath = baseDedicatedServerServicePath;
     LoadSaveList();
 }