feat: some things

This commit is contained in:
tresabhi committed 2025-04-08 16:25:35 -05:00
1 parent 292f7aeac0
commit ac1323a463
14 files changed
+149 -19

No files matched your search

+3
View File
@@ -4,3 +4,6 @@
[submodule "submodules/CUE4Parse"] [submodule "submodules/CUE4Parse"]
path = submodules/CUE4Parse path = submodules/CUE4Parse
url = https://github.com/FabianFG/CUE4Parse url = https://github.com/FabianFG/CUE4Parse
[submodule "submodules/UAssetAPI"]
path = submodules/UAssetAPI
url = https://github.com/atenfyr/UAssetAPI
+2
View File
@@ -144,6 +144,7 @@
"playerachievements", "playerachievements",
"playerinfo", "playerinfo",
"playform", "playform",
"Playtest",
"pngjs", "pngjs",
"POSITIVEX", "POSITIVEX",
"POSITIVEY", "POSITIVEY",
@@ -197,6 +198,7 @@
"TYPELESS", "TYPELESS",
"uasset", "uasset",
"ubjson", "ubjson",
"uexp",
"Unicum", "Unicum",
"UNLOCALIZED", "UNLOCALIZED",
"UNORM", "UNORM",
+1
View File
@@ -39,6 +39,7 @@
"prunestrings": "cd packages/scripts && bun prunestrings", "prunestrings": "cd packages/scripts && bun prunestrings",
"dev:cli:unpack": "cd src/BlitzKit.CLI && dotnet run unpack \"C:/Program Files (x86)/Steam/steamapps/common/World of Tanks Blitz Playtest\" --no-overwrite", "dev:cli:unpack": "cd src/BlitzKit.CLI && dotnet run unpack \"C:/Program Files (x86)/Steam/steamapps/common/World of Tanks Blitz Playtest\" --no-overwrite",
"mangle": "cd src/BlitzKit.CLI && dotnet run mangle", "mangle": "cd src/BlitzKit.CLI && dotnet run mangle",
"mangle2": "cd src/BlitzKit.CLI && dotnet run mangle2",
"api": "cd src/BlitzKit.CLI && dotnet run api", "api": "cd src/BlitzKit.CLI && dotnet run api",
"dev:api": "cd src/BlitzKit.CLI && dotnet watch run api" "dev:api": "cd src/BlitzKit.CLI && dotnet watch run api"
}, },
+1
View File
@@ -9,6 +9,7 @@
<ItemGroup> <ItemGroup>
<ProjectReference Include="../../submodules/CUE4Parse/CUE4Parse-Conversion/CUE4Parse-Conversion.csproj" /> <ProjectReference Include="../../submodules/CUE4Parse/CUE4Parse-Conversion/CUE4Parse-Conversion.csproj" />
<ProjectReference Include="../../submodules/CUE4Parse/CUE4Parse/CUE4Parse.csproj" /> <ProjectReference Include="../../submodules/CUE4Parse/CUE4Parse/CUE4Parse.csproj" />
<ProjectReference Include="../../submodules/UAssetAPI/UAssetAPI/UAssetAPI.csproj" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
+1 -1
View File
@@ -218,7 +218,7 @@ namespace BlitzKit.CLI.Functions
async Task<Tank> MangleTank(VFS tankDir) async Task<Tank> MangleTank(VFS tankDir)
{ {
var pdaName = $"PDA_{tankDir.Name}"; var pdaName = $"PDA_{tankDir.Name}";
var pda = provider.LoadObject($"{tankDir.Path}/{pdaName}.{pdaName}"); var pda = provider.LoadPackageObject($"{tankDir.Path}/{pdaName}.{pdaName}");
var id = pda.Get<FName>("TankId").Text; var id = pda.Get<FName>("TankId").Text;
var name = GetString($"TankEntity__{id.ToLowerInvariant()}__Short_Name"); var name = GetString($"TankEntity__{id.ToLowerInvariant()}__Short_Name");
+21
View File
@@ -0,0 +1,21 @@
using BlitzKit.CLI.Models;
using UAssetAPI;
using UAssetAPI.ExportTypes;
using UAssetAPI.PropertyTypes.Objects;
using UAssetAPI.UnrealTypes;
using UAssetAPI.Unversioned;
namespace BlitzKit.CLI.Functions
{
public partial class Mangler2(string[] args)
{
readonly BlitzProvider2 provider = new();
public void Mangle()
{
var assetPath = "Blitz/Content/Tanks/USSR/R45_IS_7/PDA_R45_IS_7";
Console.WriteLine(provider.Asset(assetPath));
}
}
}
+3 -2
View File
@@ -28,11 +28,12 @@ namespace BlitzKit.CLI.Functions
DefaultFileProvider provider0 = new( DefaultFileProvider provider0 = new(
directory: new DirectoryInfo(pak0Path), directory: new DirectoryInfo(pak0Path),
searchOption: SearchOption.TopDirectoryOnly, searchOption: SearchOption.TopDirectoryOnly,
versions: new(EGame.GAME_UE5_3) versions: new(EGame.GAME_UE5_3),
pathComparer: StringComparer.OrdinalIgnoreCase
); );
provider0.Initialize(); provider0.Initialize();
provider0.Mount(); provider0.Mount();
provider0.TryFindGameFile("Blitz/Config/DefaultDlc.ini", out var defaultDlcGameFile); provider0.TryGetGameFile("Blitz/Config/DefaultDlc.ini", out var defaultDlcGameFile);
if (defaultDlcGameFile is not FPakEntry) if (defaultDlcGameFile is not FPakEntry)
throw new Exception("Failed to find DefaultDlc.ini"); throw new Exception("Failed to find DefaultDlc.ini");
+2 -1
View File
@@ -21,7 +21,8 @@ namespace BlitzKit.CLI.Models
directory: new DirectoryInfo(depot ? DEPOT_CONTAINERS_PATH : LOCAL_BUNDLED_CONTAINERS_PATH), directory: new DirectoryInfo(depot ? DEPOT_CONTAINERS_PATH : LOCAL_BUNDLED_CONTAINERS_PATH),
extraDirectories: depot ? [] : [new(LOCAL_DLC_CONTAINERS_PATH)], extraDirectories: depot ? [] : [new(LOCAL_DLC_CONTAINERS_PATH)],
searchOption: SearchOption.TopDirectoryOnly, searchOption: SearchOption.TopDirectoryOnly,
versions: new(EGame.GAME_UE5_3) versions: new(EGame.GAME_UE5_3),
pathComparer: StringComparer.OrdinalIgnoreCase
) )
{ {
RootDirectory = new() RootDirectory = new()
+92
View File
@@ -0,0 +1,92 @@
using System.Text.Json;
using Org.BouncyCastle.Tls.Crypto.Impl.BC;
using UAssetAPI;
using UAssetAPI.UnrealTypes;
using UAssetAPI.Unversioned;
namespace BlitzKit.CLI.Models
{
public class BlitzProvider2 : IDisposable
{
readonly EngineVersion Version = EngineVersion.VER_UE5_3;
readonly string BUNDLED_CONTAINERS_DIR = Path.Combine(
Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86),
"Steam",
"steamapps",
"common",
"World of Tanks Blitz Playtest",
"Blitz",
"Content",
"Paks"
);
readonly string DLC_CONTAINERS_DIR = Path.Combine(
Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData),
"Blitz",
"Saved",
"PersistentDownloadDir",
"Dlc",
"PakCache"
);
readonly Usmap Map = new("../../submodules/blitzkit-closed/blitz.usmap");
readonly Dictionary<string, (PakReader Reader, Stream Stream)> FileMap = [];
readonly List<PakReader> Readers = [];
public BlitzProvider2()
{
var containers = new List<string>(
Directory.GetFiles(BUNDLED_CONTAINERS_DIR, "*.pak", SearchOption.TopDirectoryOnly)
);
var localManifest =
JsonSerializer.Deserialize<LocalManifest>(
File.ReadAllText(Path.Combine(DLC_CONTAINERS_DIR, "LocalManifest.json"))
) ?? throw new Exception("Failed to deserialize LocalManifest.json");
containers.AddRange(
localManifest.PakFiles.Keys.Select(file => Path.Combine(DLC_CONTAINERS_DIR, file))
);
foreach (string container in containers)
{
using var stream = File.OpenRead(container);
var reader =
new PakBuilder().Reader(stream) ?? throw new Exception("Failed to create PakReader");
Readers.Add(reader);
foreach (var file in reader.Files())
{
FileMap[file] = (reader, stream);
}
}
}
public UAsset Asset(string path)
{
var assetPath = $"{path}.uasset";
var expPath = $"{path}.uexp";
var (reader, stream) = FileMap[assetPath];
byte[] assetBytes = reader.Get(stream, assetPath);
byte[] uexpBytes = reader.Get(stream, expPath);
MemoryStream assetStream = new([.. assetBytes, .. uexpBytes]);
AssetBinaryReader assetReader = new(assetStream);
return new(assetReader, Version, Map);
}
public void Dispose()
{
foreach (var reader in Readers)
{
reader.Dispose();
}
GC.SuppressFinalize(this);
}
}
}
+6 -6
View File
@@ -254,14 +254,14 @@ namespace BlitzKit.CLI.Models
int[] indices int[] indices
) )
{ {
var uvs1 = new List<Vector2>() { vert1.UV }; var uvs1 = new List<Vector2>() { (Vector2)vert1.UV };
var uvs2 = new List<Vector2>() { vert2.UV }; var uvs2 = new List<Vector2>() { (Vector2)vert2.UV };
var uvs3 = new List<Vector2>() { vert3.UV }; var uvs3 = new List<Vector2>() { (Vector2)vert3.UV };
foreach (var uv in uvs) foreach (var uv in uvs)
{ {
uvs1.Add(uv[indices[0]]); uvs1.Add((Vector2)uv[indices[0]]);
uvs2.Add(uv[indices[1]]); uvs2.Add((Vector2)uv[indices[1]]);
uvs3.Add(uv[indices[2]]); uvs3.Add((Vector2)uv[indices[2]]);
} }
return (uvs1, uvs2, uvs3); return (uvs1, uvs2, uvs3);
+15 -8
View File
@@ -16,16 +16,23 @@ namespace BlitzKit.CLI
switch (args[0]) switch (args[0])
{ {
case "unpack": // case "unpack":
{ // {
await Unpacker.Unpack(args); // await Unpacker.Unpack(args);
break; // break;
} // }
case "mangle": // case "mangle":
// {
// Mangler mangler = new(args);
// await mangler.Mangle();
// break;
// }
case "mangle2":
{ {
Mangler mangler = new(args); Mangler2 mangler2 = new(args);
await mangler.Mangle(); mangler2.Mangle();
break; break;
} }
Binary file not shown.
Submodule submodules/UAssetAPI added at c380bf3d6d.