-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
66 changed files
with
1,533 additions
and
2,302 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio Version 17 | ||
VisualStudioVersion = 17.0.31919.166 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Libellus Library", "Libellus Library\Libellus Library.csproj", "{8C8535E3-BA4F-42BD-81E4-D957E5D909DD}" | ||
EndProject | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Libellus Event Tool", "Libellus Event Tool\Libellus Event Tool.csproj", "{ECF2C9F6-3F35-4AE8-B4F6-8E9B82DB3517}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{8C8535E3-BA4F-42BD-81E4-D957E5D909DD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{8C8535E3-BA4F-42BD-81E4-D957E5D909DD}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{8C8535E3-BA4F-42BD-81E4-D957E5D909DD}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{8C8535E3-BA4F-42BD-81E4-D957E5D909DD}.Release|Any CPU.Build.0 = Release|Any CPU | ||
{ECF2C9F6-3F35-4AE8-B4F6-8E9B82DB3517}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{ECF2C9F6-3F35-4AE8-B4F6-8E9B82DB3517}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{ECF2C9F6-3F35-4AE8-B4F6-8E9B82DB3517}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{ECF2C9F6-3F35-4AE8-B4F6-8E9B82DB3517}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(ExtensibilityGlobals) = postSolution | ||
SolutionGuid = {1CE93346-778F-40E8-8E0A-705D29BD9440} | ||
EndGlobalSection | ||
EndGlobal |
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,34 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<RootNamespace>Libellus_Event_Tool</RootNamespace> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
<AssemblyName>Libellus Event Editing Tool</AssemblyName> | ||
<ApplicationIcon>heeho.ico</ApplicationIcon> | ||
<AssemblyVersion>2.0.0</AssemblyVersion> | ||
<FileVersion>2.0.0</FileVersion> | ||
<SignAssembly>False</SignAssembly> | ||
|
||
<TargetFramework>net6.0</TargetFramework> | ||
|
||
</PropertyGroup> | ||
|
||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'"> | ||
<DebugType>portable</DebugType> | ||
</PropertyGroup> | ||
|
||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'"> | ||
<DebugType>portable</DebugType> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<Content Include="heeho.ico" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\Libellus Library\Libellus Library.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
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,47 @@ | ||
using LibellusLibrary.Event; | ||
|
||
|
||
namespace LibellusEventTool | ||
{ | ||
class Program | ||
{ | ||
static async Task Main(string[] args) | ||
{ | ||
|
||
System.Reflection.Assembly assembly = System.Reflection.Assembly.GetExecutingAssembly(); | ||
System.Diagnostics.FileVersionInfo fvi = System.Diagnostics.FileVersionInfo.GetVersionInfo(assembly.Location); | ||
string version = fvi.FileVersion; | ||
Console.WriteLine("Welcome to LEET!\nLibellus Event Editing Tool: v" + version + " \nNow with better syntax!\n"); | ||
|
||
if (args.Length < 1) | ||
{ | ||
Console.WriteLine("Not Enough args!"); | ||
Console.WriteLine("Press Any Button To Exit."); | ||
Console.ReadKey(); | ||
return; | ||
} | ||
foreach (string file in args) | ||
{ | ||
string ext = Path.GetExtension(file).ToLower(); | ||
if (ext == ".pm1" || ext == ".pm2" || ext == ".pm3") | ||
{ | ||
Console.WriteLine("Coverting to Json: ", file);; | ||
PmdReader reader = new PmdReader(); | ||
PolyMovieData pmd = await reader.ReadPmd(file); | ||
pmd.ExtractPmd(file, Path.GetFileNameWithoutExtension(file)); | ||
continue; | ||
} | ||
|
||
if (ext == ".json") | ||
{ | ||
Console.WriteLine("Coverting to PMD: ", file); | ||
PolyMovieData pmd = await PolyMovieData.LoadPmd(Path.Combine(file)); | ||
string pmdext = "PM" + pmd.MagicCode[3]; | ||
pmd.SavePmd(file + "." + pmdext); | ||
} | ||
} | ||
Console.WriteLine("Press Any Button To Exit."); | ||
Console.ReadKey(); | ||
} | ||
} | ||
} |
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,7 @@ | ||
{ | ||
"profiles": { | ||
"Libellus Event Tool": { | ||
"commandName": "Project" | ||
} | ||
} | ||
} |
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,3 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<configuration> | ||
</configuration> |
File renamed without changes.
Binary file not shown.
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,139 @@ | ||
using LibellusLibrary.Event.Types; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using LibellusLibrary.Utils; | ||
using System.Collections.Concurrent; | ||
using LibellusLibrary.Utils.IO; | ||
|
||
namespace LibellusLibrary.Event | ||
{ | ||
internal class PmdBuilder | ||
{ | ||
internal PolyMovieData Pmd; | ||
|
||
public List<PmdTypeID> ExistingTypes = new(); | ||
|
||
internal Dictionary<PmdTypeID, List<byte[]>> ReferenceTables = new(); | ||
|
||
internal Dictionary<IReferenceType, int> nameTableReferenceIndices = new(); | ||
|
||
internal ConcurrentDictionary<PmdTypeID, List<PmdDataType>> typeTable = new(); | ||
|
||
internal PmdBuilder(PolyMovieData Pmd) | ||
{ | ||
this.Pmd = Pmd; | ||
} | ||
|
||
// I sincerely apologize for the absolute hell that is the writing code | ||
//I dont know what the fuck I was smoking but I know if I touch it, the whole thing will explode | ||
internal async Task<MemoryStream> CreatePmd(string path) | ||
{ | ||
|
||
MemoryStream pmdFile = new MemoryStream(); | ||
using var writer = new BinaryWriter(pmdFile); | ||
|
||
//await using DisposableDictionaryAsync<PmdDataType, long> dataTypes = new(); | ||
Dictionary<PmdDataType,long> dataTypes = new(); | ||
// Type, offset | ||
foreach (PmdDataType pmdData in Pmd.PmdDataTypes) | ||
{ | ||
if(pmdData is IReferenceType reference) | ||
{ | ||
reference.SetReferences(this); | ||
} | ||
} | ||
writer.FSeek(0x20 + 0x10 * Pmd.PmdDataTypes.Count + 0x40); | ||
foreach (var referenceType in ReferenceTables) | ||
{ | ||
var dataType = new PmdData_RawData(); | ||
dataType.Type = referenceType.Key; | ||
dataType.Data = referenceType.Value; | ||
var start = writer.FTell(); | ||
dataType.SaveData(this, writer); | ||
dataTypes.Add(dataType, start); | ||
//writer.Write(dataTypes[dataType].Item1.ToArray()); | ||
} | ||
|
||
List<Task<MemoryStream>> writeDataTasks = new(); | ||
foreach (PmdDataType pmdData in Pmd.PmdDataTypes) | ||
{ | ||
var start = writer.FTell(); | ||
pmdData.SaveData(this, writer); | ||
dataTypes.Add(pmdData, start); | ||
//writer.Write(dataTypes[pmdData].Item1.ToArray()); | ||
} | ||
|
||
|
||
/* | ||
// I know this is incredibly cursed and I have no idea why this was neccessary | ||
var reversed = dataStreams.ToDictionary(x => x.Value, x => x.Key); | ||
//reversed.Reverse(); | ||
// Gives us plenty of space to write | ||
pmdFile.Seek(0x20 + 0x10 * Pmd.PmdDataTypes.Count + 0x40, SeekOrigin.Begin); | ||
List<Task> writeFileTasks = new(); | ||
foreach (var bucket in Async.Interleaved<MemoryStream>(writeDataTasks)) | ||
{ // Process tasks as they finish ie. write to file as soon as memory buffer is done | ||
var t = await bucket; | ||
var result = await t; | ||
long offset = pmdFile.Position; | ||
offsets.Add(reversed[result], offset); | ||
writeFileTasks.Add(pmdFile.WriteAsync(result.GetBuffer()).AsTask()); | ||
} | ||
await Task.WhenAll(writeFileTasks); | ||
*/ | ||
// Write Header | ||
|
||
|
||
writer.Seek(0, SeekOrigin.Begin); | ||
writer.Write((int)0); // Filetype/format/userid | ||
writer.Write((int)pmdFile.Length); | ||
writer.Write(Pmd.MagicCode.ToCharArray()); | ||
writer.Write((int)0); // Expand Size | ||
writer.Write(dataTypes.Count); | ||
writer.Write(Pmd.Version); | ||
writer.Write((int)0); //Reserve | ||
writer.Write((int)0); | ||
|
||
|
||
// Create Type table | ||
writer.FSeek(0x20); | ||
// Write the type table in the correct order | ||
//IEnumerable<KeyValuePair<PmdDataType, long>> dataTypes = offsets.Reverse(); | ||
foreach (KeyValuePair<PmdDataType, long> dataType in dataTypes) | ||
{ | ||
writer.Write((int)dataType.Key.Type); | ||
writer.Write((int)dataType.Key.GetSize());// Size | ||
writer.Write((int)dataType.Key.GetCount()); | ||
writer.Write((int)dataType.Value); // Offset | ||
} | ||
|
||
|
||
return pmdFile; | ||
} | ||
|
||
|
||
/// <summary> | ||
/// Creates another datatype and returns it's index | ||
/// </summary> | ||
/// <param name="id"></param> | ||
/// <param name="data"></param> | ||
/// <returns></returns> | ||
internal int AddReference(PmdTypeID id, byte[] data) | ||
{ | ||
if (ReferenceTables.ContainsKey(id)) | ||
{ | ||
ReferenceTables[id].Add(data); | ||
return ReferenceTables.Count-1; | ||
} | ||
ReferenceTables.Add(id, new List<byte[]>()); | ||
ReferenceTables[id].Add(data); | ||
return ReferenceTables.Count - 1; | ||
} | ||
|
||
} | ||
} |
Oops, something went wrong.