public static RoomModel Load(IEditorPlatform platform, IGame game, string path) { var model = AGSProject.LoadJson <RoomModel>(platform, game, path); model.Folder = getDirectoryName(Path.GetDirectoryName(path)); return(model); }
public static void SaveJson(IEditorPlatform platform, IGame game, string path, object model) { var serializer = platform.GetSerialization(game); string json = serializer.Serialize(model); File.WriteAllText(path, json); }
private void loadGameSettings(IEditorPlatform platform, IGame game, string path) { if (!File.Exists(path)) { return; } Settings = AGSProject.LoadJson <AGSGameSettings>(platform, game, path); game.Settings.LoadFrom(Settings); }
private void saveGuis(IEditorPlatform platform, IGame game, string basePath) { Directory.CreateDirectory(basePath); foreach (var id in Guis) { saveEntity(platform, game, basePath, id); } }
public static AGSProject Load(IEditorPlatform platform, IGame game, string path) { var proj = LoadJson <AGSProject>(platform, game, path); proj.AGSProjectPath = path; proj.Model = new StateModel(); proj.Model.Load(platform, game, Path.GetDirectoryName(path)); return(proj); }
private void saveEntity(IEditorPlatform platform, IGame game, string folder, string id) { if (id == null) { return; } if (!Entities.TryGetValue(id, out var entity)) { Debug.WriteLine($"Missing entity {id}, cannot save it in {folder}."); return; } entity.Save(platform, game, folder); }
public static T LoadJson <T>(IEditorPlatform platform, IGame game, string path) { var serializer = platform.GetSerialization(game); var stream = File.OpenRead(path); string json; using (stream) using (StreamReader reader = new StreamReader(stream)) { json = reader.ReadToEnd(); } T obj = serializer.Deserialize <T>(json); return(obj); }
private void saveRooms(IEditorPlatform platform, IGame game, string basePath) { Directory.CreateDirectory(basePath); foreach (var room in Rooms) { room.Save(platform, game, basePath); string roomFolder = Path.Combine(basePath, room.Folder); saveEntity(platform, game, roomFolder, room.BackgroundEntity); foreach (var id in room.Entities) { saveEntity(platform, game, roomFolder, id); } } }
public static EntityModel Load(IEditorPlatform platform, IGame game, string path) { if (!path.EndsWith(".json", StringComparison.InvariantCultureIgnoreCase)) { return(null); } try { var model = AGSProject.LoadJson <EntityModel>(platform, game, path); model.Filename = Path.GetFileName(path); return(model); } catch (JsonReaderException e) { Debug.WriteLine($"Exception while trying to read json from {path}.{Environment.NewLine}Exception: {e}"); throw; } }
private void loadGuis(IEditorPlatform platform, IGame game, string basePath) { if (!Directory.Exists(basePath)) { return; } var guiFiles = Directory.GetFiles(basePath); foreach (var guiFile in guiFiles) { var gui = EntityModel.Load(platform, game, guiFile); if (gui == null) { continue; } Entities.Add(gui.ID, gui); Guis.Add(gui.ID); } }
private void loadRooms(IEditorPlatform platform, IGame game, string basePath) { if (!Directory.Exists(basePath)) { return; } var roomFolders = Directory.GetDirectories(basePath); const string roomFilename = RoomModel.Filename; foreach (var roomFolder in roomFolders) { var roomJsonPath = Path.Combine(roomFolder, roomFilename); if (!File.Exists(roomJsonPath)) { Debug.WriteLine($"Missing room json at {roomFolder}"); continue; } var room = RoomModel.Load(platform, game, roomJsonPath); Rooms.Add(room); var roomFiles = Directory.GetFiles(roomFolder); foreach (var roomFile in roomFiles) { if (roomFile == roomJsonPath) { continue; } var entity = EntityModel.Load(platform, game, roomFile); Entities.Add(entity.ID, entity); if (entity.ID != room.BackgroundEntity) { room.Entities.Add(entity.ID); } } } }
public void Save(IEditorPlatform platform, IGame game, string folderPath) => AGSProject.SaveJson(platform, game, getFilepath(folderPath), this);
public void Save(IEditorPlatform platform, IGame game, string basePath) { saveGuis(platform, game, getGuisFolder(basePath)); saveRooms(platform, game, getRoomsFolder(basePath)); saveGameSettings(platform, game, getSettingsPath(basePath)); }
public void Load(IEditorPlatform platform, IGame game, string basePath) { loadGuis(platform, game, getGuisFolder(basePath)); loadRooms(platform, game, getRoomsFolder(basePath)); loadGameSettings(platform, game, getSettingsPath(basePath)); }
private void saveGameSettings(IEditorPlatform platform, IGame game, string path) { AGSProject.SaveJson(platform, game, path, Settings); }
public void Save(IEditorPlatform platform, IGame game, string folderPath) => AGSProject.SaveJson(platform, game, Path.Combine(getFolder(folderPath), Filename), this);