public void Load(UserDataPath baseLocalPath, UserDataPath baseDedicatedServerHostPath, UserDataPath baseDedicatedServerServicePath) { BaseLocalPath = baseLocalPath; BaseDedicatedServerHostPath = baseDedicatedServerHostPath; BaseDedicatedServerServicePath = baseDedicatedServerServicePath; LoadSaveList(); }
public static void Save() { lock (_updatelock) { string cpath = Path.Combine(UserDataPath.Get(), updatehistory); File.WriteAllText(cpath, JsonConvert.SerializeObject(_updates)); } }
public void Load() { string cpath = Path.Combine(UserDataPath.Get(), follows); if (File.Exists(cpath)) { string str = File.ReadAllText(cpath); JsonConvert.PopulateObject(str, this); } }
public IEnumerable <string> Serialize() { yield return(AssemblyPath.NativePath); yield return(InputPipe.ToString()); yield return(OutputPipe.ToString()); yield return(UserDataPath.ToString()); }
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); } }
public void BrowseExecuted() { var openFileDialog = _openFileDialogFactory(); openFileDialog.CheckFileExists = true; openFileDialog.CheckPathExists = true; openFileDialog.DefaultExt = "sbc"; openFileDialog.FileName = "Sandbox.sbc"; openFileDialog.Filter = AppConstants.SandboxFilter; openFileDialog.Multiselect = false; openFileDialog.Title = Res.DialogLocateSandboxTitle; if (_dialogService.ShowOpenFileDialog(this, openFileDialog) == DialogResult.OK) { IsBusy = true; var savePath = Path.GetDirectoryName(openFileDialog.FileName); var userName = Environment.UserName; var saveType = SaveWorldType.Custom; try { using (var fs = File.OpenWrite(openFileDialog.FileName)) { // test opening the file to verify that we have Write Access. } } catch { saveType = SaveWorldType.CustomAdminRequired; } // Determine the correct UserDataPath for this custom save game if at all possible for the mods. var dp = UserDataPath.FindFromSavePath(savePath); var saveResource = _dataModel.LoadSaveFromPath(savePath, userName, saveType, dp); string errorInformation; if (saveResource.LoadCheckpoint(out errorInformation)) { if (saveResource.LoadSector(out errorInformation)) { SelectedWorld = saveResource; IsBusy = false; CloseResult = true; return; } } IsBusy = false; SystemSounds.Beep.Play(); _dialogService.ShowErrorDialog(this, Res.ErrorLoadSaveGameFileError, errorInformation, true); } }
public void Save() { lock (_downloadslock) { List <EpisodeWithDownloadSettings> sv = new List <EpisodeWithDownloadSettings>(); foreach (DownloadItem d in _downloads) { EpisodeWithDownloadSettingAndStatus dk = new EpisodeWithDownloadSettingAndStatus(); d.Episode.CopyTo(dk); dk.DownloadStatus = d.Status; sv.Add(dk); } string cpath = Path.Combine(UserDataPath.Get(), downloads); File.WriteAllText(cpath, JsonConvert.SerializeObject(sv)); } }
public static void Load() { lock (_updatelock) { string cpath = Path.Combine(UserDataPath.Get(), updatehistory); if (File.Exists(cpath)) { string str = File.ReadAllText(cpath); _updates = JsonConvert.DeserializeObject <Dictionary <string, string> >(str); } else { _updates = new Dictionary <string, string>(); } IsLoaded = true; } }
public List <DownloadItem> Load(string template, string downloadpath) { List <DownloadItem> downs = new List <DownloadItem>(); string cpath = Path.Combine(UserDataPath.Get(), downloads); if (File.Exists(cpath)) { string str = File.ReadAllText(cpath); List <EpisodeWithDownloadSettingAndStatus> dm = JsonConvert.DeserializeObject <List <EpisodeWithDownloadSettingAndStatus> >(str); foreach (EpisodeWithDownloadSettingAndStatus ep in dm) { if (ep.DownloadStatus == DownloadStatus.Queue || ep.DownloadStatus == DownloadStatus.Downloading) { ep.DownloadStatus = DownloadStatus.Queue; } downs.Add(Add(ep, template, downloadpath, ep.DownloadStatus)); } } return(downs); }
internal static WorldResource LoadSession(string savePath) { if (Directory.Exists(savePath)) { var userPath = Path.GetDirectoryName(savePath); var saveResource = new WorldResource { Savename = Path.GetFileName(savePath), UserName = Path.GetFileName(userPath), Savepath = savePath, DataPath = UserDataPath.FindFromSavePath(savePath) }; saveResource.LoadCheckpoint(); return(saveResource); } return(null); }
internal static bool LoadSession(string savePath, out WorldResource saveResource, out string errorInformation) { if (Directory.Exists(savePath)) { var userPath = Path.GetDirectoryName(savePath); saveResource = new WorldResource { Savename = Path.GetFileName(savePath), UserName = Path.GetFileName(userPath), Savepath = savePath, DataPath = UserDataPath.FindFromSavePath(savePath) }; return(saveResource.LoadCheckpoint(out errorInformation)); } saveResource = null; errorInformation = Res.ErrorDirectoryNotFound; return(false); }
internal static WorldResource FindSaveSession(string baseSavePath, string findSession) { if (Directory.Exists(baseSavePath)) { var userPaths = Directory.GetDirectories(baseSavePath); foreach (var userPath in userPaths) { var lastLoadedFile = Path.Combine(userPath, SpaceEngineersConsts.LoadLoadedFilename); // Ignore any other base Save paths without the LastLoaded file. if (File.Exists(lastLoadedFile)) { var savePaths = Directory.GetDirectories(userPath); // Still check every potential game world path. foreach (var savePath in savePaths) { var saveResource = new WorldResource { Savename = Path.GetFileName(savePath), UserName = Path.GetFileName(userPath), Savepath = savePath, DataPath = UserDataPath.FindFromSavePath(savePath) }; saveResource.LoadCheckpoint(); if (saveResource.Savename.ToUpper() == findSession || saveResource.SessionName.ToUpper() == findSession) { return(saveResource); } } } } } return(null); }
internal static bool FindSaveSession(string baseSavePath, string findSession, out WorldResource saveResource, out string errorInformation) { if (Directory.Exists(baseSavePath)) { var userPaths = Directory.GetDirectories(baseSavePath); foreach (var userPath in userPaths) { // Ignore any other base Save paths without the LastLoaded file. if (Directory.Exists(userPath)) { var savePaths = Directory.GetDirectories(userPath); // Still check every potential game world path. foreach (var savePath in savePaths) { saveResource = new WorldResource { Savename = Path.GetFileName(savePath), UserName = Path.GetFileName(userPath), Savepath = savePath, DataPath = UserDataPath.FindFromSavePath(savePath) }; saveResource.LoadWorldInfo(); if (saveResource.IsValid && (saveResource.Savename.ToUpper() == findSession || saveResource.SessionName.ToUpper() == findSession)) { return(saveResource.LoadCheckpoint(out errorInformation)); } } } } } saveResource = null; errorInformation = Res.ErrorGameNotFound; return(false); }
public void Save() { string cpath = Path.Combine(UserDataPath.Get(), follows); File.WriteAllText(cpath, JsonConvert.SerializeObject(this)); }
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); }
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); }
private IEnumerable <WorldResource> FindSaveFiles(string lastLoadedPath, string userName, SaveWorldType saveType, UserDataPath dataPath) { var list = new List <WorldResource>(); // Ignore any other base Save paths without the LastLoaded file. if (Directory.Exists(lastLoadedPath)) { var savePaths = Directory.GetDirectories(lastLoadedPath); // Still check every potential game world path. foreach (var savePath in savePaths) { var saveResource = LoadSaveFromPath(savePath, userName, saveType, dataPath); // This should still allow Games to be copied into the Save path manually. saveResource.LoadWorldInfo(); list.Add(saveResource); } } return(list); }