mirror of
https://github.com/sbrl/Nibriboard.git
synced 2018-01-10 21:33:49 +00:00
Start creating logic for saving planes & chunks
This commit is contained in:
parent
d79a89423c
commit
3d013e208c
2 changed files with 35 additions and 0 deletions
|
@ -227,6 +227,11 @@ namespace Nibriboard.RippleSpace
|
||||||
return loadedChunk;
|
return loadedChunk;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task SaveTo(Stream destination)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException("Error: Chunk saving hasn't been implemented yet!");
|
||||||
|
}
|
||||||
|
|
||||||
public void OnDeserialization(object sender)
|
public void OnDeserialization(object sender)
|
||||||
{
|
{
|
||||||
UpdateAccessTime();
|
UpdateAccessTime();
|
||||||
|
|
|
@ -164,6 +164,34 @@ namespace Nibriboard.RippleSpace
|
||||||
return loadedChunk;
|
return loadedChunk;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Works out whether a chunk currently exists.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="chunkLocation">The chunk location to check.</param>
|
||||||
|
/// <returns>Whether the chunk at specified location exists or not.</returns>
|
||||||
|
public bool HasChunk(ChunkReference chunkLocation)
|
||||||
|
{
|
||||||
|
if(loadedChunkspace.ContainsKey(chunkLocation))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
string chunkFilePath = Path.Combine(StorageDirectory, chunkLocation.AsFilename());
|
||||||
|
if(File.Exists(chunkFilePath))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task SaveChunk(ChunkReference chunkLocation)
|
||||||
|
{
|
||||||
|
// It doesn't exist, so we can't save it :P
|
||||||
|
if(!loadedChunkspace.ContainsKey(chunkLocation))
|
||||||
|
return;
|
||||||
|
|
||||||
|
Chunk chunk = loadedChunkspace[chunkLocation];
|
||||||
|
string chunkFilePath = Path.Combine(StorageDirectory, chunkLocation.AsFilename());
|
||||||
|
await chunk.SaveTo(File.OpenWrite(chunkFilePath));
|
||||||
|
}
|
||||||
|
|
||||||
public async Task AddLine(DrawnLine newLine)
|
public async Task AddLine(DrawnLine newLine)
|
||||||
{
|
{
|
||||||
List<DrawnLine> chunkedLineParts;
|
List<DrawnLine> chunkedLineParts;
|
||||||
|
@ -216,6 +244,8 @@ namespace Nibriboard.RippleSpace
|
||||||
|
|
||||||
public void Save(Stream destination)
|
public void Save(Stream destination)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
WriterOptions packingOptions = new WriterOptions(CompressionType.GZip);
|
WriterOptions packingOptions = new WriterOptions(CompressionType.GZip);
|
||||||
|
|
||||||
IEnumerable<string> chunkFiles = Directory.GetFiles(StorageDirectory);
|
IEnumerable<string> chunkFiles = Directory.GetFiles(StorageDirectory);
|
||||||
|
|
Loading…
Reference in a new issue