Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

V1 #53

Merged
merged 18 commits into from
Oct 9, 2023
Merged

V1 #53

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ dotnet_style_qualification_for_method = false:suggestion
dotnet_style_qualification_for_event = false:suggestion

# Types: use keywords instead of BCL types, and permit var only when the type is clear
csharp_style_var_for_built_in_types = false:suggestion
csharp_style_var_for_built_in_types = true:suggestion
csharp_style_var_when_type_is_apparent = false:none
csharp_style_var_elsewhere = false:suggestion
dotnet_style_predefined_type_for_locals_parameters_members = true:suggestion
Expand Down
22 changes: 11 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,27 +82,27 @@ might not work with them.

```cs
// Read file with default episode (EP5) and encoding (ASCII)
var svmap = Reader.ReadFromFile<Svmap>("0.svmap");
var svmap = ParsecReader.FromFile<Svmap>("0.svmap");

// Read file with a specific episode and default encoding
var svmap = Reader.ReadFromFile<Svmap>("0.svmap", Episode.Ep6);
var svmap = ParsecReader.FromFile<Svmap>("0.svmap", Episode.Ep6);

// Read file with a specific episode and a specific encoding
var windows1252Encoding = CodePagesEncodingProvider.Instance.GetEncoding(1252);
var svmap = Reader.ReadFromFile<Svmap>("0.svmap", Episode.Ep6, windows1252Encoding);
var svmap = ParsecReader.FromFile<Svmap>("0.svmap", Episode.Ep6, windows1252Encoding);
```

#### From data.saf

```cs
// Load data (sah and saf)
var data = new Data("data.sah");
var data = new Data("data.sah", "data.saf");

// Find the file you want to read
var file = data.GetFile("world/0.svmap");

// Read and parse the file's content directly from the saf file
var svmap = Reader.ReadFromBuffer<Svmap>(file.Name, data.GetFileBuffer(file));
var svmap = ParsecReader.FromBuffer<Svmap>(file.Name, data.GetFileBuffer(file));
```

#### From a JSON file
Expand All @@ -113,7 +113,7 @@ format.

```cs
// Read JSON file
var svmap = Reader.ReadFromJsonFile<Svmap>("0_svmap.json");
var svmap = ParsecReader.FromJsonFile<Svmap>("0_svmap.json");
```

It is advised to first read a file from its original format, export it as JSON, edit it, and import it once again as
Expand All @@ -126,13 +126,13 @@ All of the Episode 8 `BinarySData` formats have `CSV` support.

```cs
// Read csv file
var item = Item.ReadFromCsv("Item.csv");
var item = Item.FromCsv("Item.csv");
```

### Encoding

When reading files, the default encoding is `ASCII`. If you want to read a file with a different encoding, you can
specify it as a parameter when calling the ReadFromFile/Json/Csv methods.
specify it as a parameter when calling the FromFile/Json/Csv methods.

### Writing

Expand Down Expand Up @@ -186,7 +186,7 @@ specify it as a parameter when calling the `Write`, `WriteJson` and `WriteCsv` m

```cs
// Load data (sah and saf)
var data = new Data("data.sah");
var data = new Data("data.sah", "data.saf");

// Find the file you want to extract
var file = data.GetFile("world/2.svmap");
Expand All @@ -206,8 +206,8 @@ DataBuilder.CreateFromDirectory("input", "output");

```cs
// Load target data and patch data
var data = new Data("data.sah");
var update = new Data("update.sah");
var data = new Data("data.sah", "data.saf");
var update = new Data("update.sah", "update.saf");

// Patch data
using (var dataPatcher = new DataPatcher())
Expand Down
6 changes: 2 additions & 4 deletions samples/Data/Program.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using Parsec;
using Parsec.Shaiya.Data;
using Parsec.Shaiya.Svmap;

Expand All @@ -12,16 +11,15 @@ private static void Main(string[] args)
#region Read Data

// Read data from .sah and .saf files
Parsec.Shaiya.Data.Data data = new("data.sah");
Parsec.Shaiya.Data.Data data = new("data.sah", "data.saf");

// Find the file you want to extract with it's full relative path
// Keep in mind that in Episode 8, the relative path for this same case would be "data/world/2.svmap
var file = data.GetFile("world/2.svmap");
// Extract the selected file
data.Extract(file, "extracted");

// Read and parse the file's content directly from the saf file
Svmap svmap = Reader.ReadFromBuffer<Svmap>(file.Name, data.GetFileBuffer(file));
Svmap svmap = Parsec.ParsecReader.FromBuffer<Svmap>(file.Name, data.GetFileBuffer(file));

Console.WriteLine($"File: {svmap.FileName}");
Console.WriteLine($"MapSize: {svmap.MapSize}");
Expand Down
29 changes: 7 additions & 22 deletions samples/Files/Program.cs
Original file line number Diff line number Diff line change
@@ -1,34 +1,19 @@
using System;
using Parsec;
using Parsec.Shaiya.Svmap;
using Parsec;
using Parsec.Shaiya.SData;
using Parsec.Shaiya.Skill;

namespace Sample.Files;

internal static class Program
{
private static void Main(string[] args)
{
// This sample shows how you can convert a shaiya file format (in this case svmap) into json to be able to
// edit its properties as plain text, and then, convert it back to its original format
SData.DecryptFile("/home/matias/Desktop/DBSkillData.SData", "/home/matias/Desktop/DBSkillData.dec.SData");

// Step 1: Read a svmap from a file
Svmap svmap = Reader.ReadFromFile<Svmap>("2.svmap");
var skillData = ParsecReader.FromFile<DBSkillData>("/home/matias/Desktop/DBSkillData.dec.SData");

// You can go through and modify its properties here too
foreach (Npc npc in svmap.Npcs)
{
Console.WriteLine($"NpcId: {npc.NpcId}, Type: {npc.Type}");
}
skillData.Write("/home/matias/Desktop/DBSkillData.dec.new.SData");

// Step 2: Export svmap as JSON
svmap.WriteJson("2.svmap.json");

// Step 3: Modify the json file in any text editor

// Step 4: Read svmap from the modified JSON file
Svmap svmapFromJson = Reader.ReadFromJsonFile<Svmap>("2.svmap.json");

// Step 5: Write the edited instance as .svmap
svmapFromJson.Write("2.edited.svmap");
var newSkillData = ParsecReader.FromFile<DBSkillData>("/home/matias/Desktop/DBSkillData.dec.new.SData");
}
}
7 changes: 3 additions & 4 deletions samples/SData/Program.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using Parsec;
using Parsec.Common;
using Parsec.Common;
using Parsec.Shaiya.Item;

namespace Sample.SData;
Expand All @@ -12,15 +11,15 @@ private static void Main(string[] args)
Parsec.Shaiya.SData.SData.DecryptFile("ItemEP6.SData", "ItemEP6.Decrypted.SData");

// Read SData from file
Item item = Reader.ReadFromFile<Item>("ItemEP6.SData", Episode.EP6);
Item item = Parsec.ParsecReader.FromFile<Item>("ItemEP6.SData", Episode.EP6);

// or.. export it as csv
item.WriteCsv("Item.csv");

// Modify the csv file

// Load the modified csv
Item itemFromCsv = Item.ReadFromCsv("Item.csv", Episode.EP6);
Item itemFromCsv = Item.FromCsv("Item.csv", Episode.EP6);

// Save the modified file encrypted
itemFromCsv.WriteEncrypted("Item.Encrypted.SData");
Expand Down
14 changes: 0 additions & 14 deletions src/Parsec/Attributes/ConditionalPropertyAttribute.cs

This file was deleted.

14 changes: 0 additions & 14 deletions src/Parsec/Attributes/CustomDefinitionAttribute.cs

This file was deleted.

14 changes: 0 additions & 14 deletions src/Parsec/Attributes/DefaultVersionAttribute.cs

This file was deleted.

16 changes: 0 additions & 16 deletions src/Parsec/Attributes/EpisodeDefinerAttribute.cs

This file was deleted.

14 changes: 0 additions & 14 deletions src/Parsec/Attributes/FixedLengthListAttribute.cs

This file was deleted.

26 changes: 0 additions & 26 deletions src/Parsec/Attributes/FixedLengthStringAttribute.cs

This file was deleted.

19 changes: 0 additions & 19 deletions src/Parsec/Attributes/LengthPrefixedListAttribute.cs

This file was deleted.

18 changes: 0 additions & 18 deletions src/Parsec/Attributes/LengthPrefixedStringAttribute.cs

This file was deleted.

16 changes: 0 additions & 16 deletions src/Parsec/Attributes/ListLengthMultiplierAttribute.cs

This file was deleted.

25 changes: 0 additions & 25 deletions src/Parsec/Attributes/ShaiyaPropertyAttribute.cs

This file was deleted.

12 changes: 0 additions & 12 deletions src/Parsec/Attributes/UsePropertyAttribute.cs

This file was deleted.

Loading
Loading