-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add some design data helpers, rework p4kfilesystem
- Loading branch information
Showing
16 changed files
with
127 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
namespace StarBreaker.P4k; | ||
|
||
public class FakeP4kFile : IP4kFile | ||
{ | ||
public string P4KPath { get; } | ||
public ZipEntry[] Entries { get; } | ||
public ZipNode Root { get; } | ||
|
||
public FakeP4kFile(string path, ZipEntry[] entries, ZipNode root) | ||
{ | ||
P4KPath = path; | ||
Root = root; | ||
Entries = entries; | ||
} | ||
|
||
public Stream OpenStream(ZipEntry entry) => new MemoryStream(new byte[entry.UncompressedSize]); | ||
|
||
public byte[] OpenInMemory(ZipEntry entry) => new byte[entry.UncompressedSize]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
namespace StarBreaker.P4k; | ||
|
||
public interface IP4kFile | ||
{ | ||
string P4KPath { get; } | ||
ZipEntry[] Entries { get; } | ||
ZipNode Root { get; } | ||
Stream OpenStream(ZipEntry entry); | ||
byte[] OpenInMemory(ZipEntry entry); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
using StarBreaker.P4k; | ||
|
||
namespace StarBreaker.Services; | ||
|
||
public class DesignP4kService : IP4kService | ||
{ | ||
public P4kFileSystem P4KFileSystem { get; } | ||
|
||
public DesignP4kService() | ||
{ | ||
var entries = GetFakeEntries(); | ||
var root = new ZipNode("Root", entries); | ||
|
||
P4KFileSystem = new P4kFileSystem(new FakeP4kFile(@"C:\This\Is\A\Path", entries, root)); | ||
} | ||
|
||
public void OpenP4k(string path, IProgress<double> progress) | ||
{ | ||
progress.Report(0); | ||
Thread.Sleep(500); | ||
progress.Report(0.5); | ||
Thread.Sleep(500); | ||
progress.Report(1); | ||
} | ||
|
||
private static ZipEntry[] GetFakeEntries() => | ||
[ | ||
new(@"Data\entry1", 69, 69, 0, false, 123, 0xffff, 0xdeadbeef), | ||
new(@"Data\entry2", 69, 69, 0, false, 123, 0xffff, 0xdeadbeef), | ||
new(@"Data\ObjectContainers\entry2", 69, 69, 0, false, 123, 0xffff, 0xdeadbeef), | ||
new(@"Data\Textures\entry2", 69, 69, 0, false, 123, 0xffff, 0xdeadbeef), | ||
new(@"Engine\entry3", 69, 69, 0, false, 123, 0xffff, 0xdeadbeef), | ||
new(@"Engine\entry3", 69, 69, 0, false, 123, 0xffff, 0xdeadbeef) | ||
]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
using StarBreaker.P4k; | ||
|
||
namespace StarBreaker.Services; | ||
|
||
public interface IP4kService | ||
{ | ||
P4kFileSystem P4KFileSystem { get; } | ||
void OpenP4k(string path, IProgress<double> progress); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters