1
0
mirror of synced 2024-09-24 03:28:21 +02:00

A few fixes and additions.

Adjust drag and drop support a bit from archives so it doesn't have any issues.
Added BRLYT viewing (very basic)
Fix U8 not adding all the directories. Hopefully any U8 will work correctly now
This commit is contained in:
KillzXGaming 2019-08-31 17:24:05 -04:00
parent ca1b62e45e
commit bb7d9d88b1
19 changed files with 1390 additions and 52 deletions

View File

@ -121,19 +121,24 @@ namespace FirstPlugin
for (int i = 0; i < dirs.Length; i++)
dirs[i] = new DirectoryEntry();
DirectoryEntry currentDir = dirs[0];
DirectoryEntry currentDir = dirs[1];
nodes.Add(currentDir);
//Skip root so start index at 1
int dirIndex = 1;
for (int i = 0; i < TotalNodeCount; i++)
{
var node = entries[i];
Console.WriteLine($"node " + node.Name + " " + node.nodeType);
if (node.Name == string.Empty)
continue;
if (node.nodeType == NodeEntry.NodeType.Directory)
{
DirectoryEntry dir = new DirectoryEntry();
dir.Name = node.Name;
dir.nodeEntry = node;
dirs[node.Setting1].AddNode(dir);
currentDir = dir;
dirs[i].Name = node.Name;
dirs[i].nodeEntry = node;
dirs[node.Setting1].AddNode(dirs[i]);
currentDir = dirs[i];
}
else
{
@ -147,8 +152,6 @@ namespace FirstPlugin
entry.FileData = reader.ReadBytes((int)entry.nodeEntry.Setting2);
}
}
nodes.Add(currentDir);
}
}

File diff suppressed because it is too large Load Diff

View File

@ -71,6 +71,8 @@ namespace FirstPlugin
uint unk2Table = reader.ReadUInt32();
uint textureInfoTable = reader.ReadUInt32();
bool UseExternalBinary = true;
List<TextureEntry> entries = new List<TextureEntry>();
for (int i = 0; i < numTextures; i++)
{
@ -80,6 +82,9 @@ namespace FirstPlugin
reader.SeekBegin(dataOffsetTable + (i * 4));
tex.DataOffset = reader.ReadUInt32();
if (i == 0 && tex.DataOffset != 0)
UseExternalBinary = false;
//Get data size
reader.SeekBegin(dataSizeTable + (i * 4));
tex.DataSize = reader.ReadUInt32();
@ -91,6 +96,8 @@ namespace FirstPlugin
Nodes.Add(new TextureWrapper(tex) { Text = $"Texture {i}" });
}
if (UseExternalBinary)
{
string fileData = FilePath.Replace("wta", "wtp");
if (System.IO.File.Exists(fileData))
{
@ -104,6 +111,15 @@ namespace FirstPlugin
}
}
}
else
{
for (int i = 0; i < numTextures; i++)
{
reader.SeekBegin(entries[i].DataOffset);
entries[i].ImageData = reader.ReadBytes((int)entries[i].DataSize);
}
}
}
}
[StructLayout(LayoutKind.Sequential, Pack = 1)]
@ -221,6 +237,8 @@ namespace FirstPlugin
public override byte[] GetImageData(int ArrayLevel = 0, int MipLevel = 0)
{
Console.WriteLine($" Texture.ImageData " + Texture.ImageData.Length);
return TegraX1Swizzle.GetImageData(this, Texture.ImageData, ArrayLevel, MipLevel, 1);
}

View File

@ -297,6 +297,7 @@
<Compile Include="FileFormats\Layout\CAFE\FLYT.cs" />
<Compile Include="FileFormats\Layout\PaneTreeWrapper.cs" />
<Compile Include="FileFormats\Layout\Common.cs" />
<Compile Include="FileFormats\Layout\Rev\BRLYT.cs" />
<Compile Include="FileFormats\Message\MSBP.cs" />
<Compile Include="FileFormats\CrashBandicoot\IGZ_TEX.cs" />
<Compile Include="FileFormats\MOD.cs" />

View File

@ -292,6 +292,8 @@ namespace LayoutBXLYT
LoadBxlyt(((BFLYT)file).header, file.FileName);
else if (file is BCLYT)
LoadBxlyt(((BCLYT)file).header, file.FileName);
else if (file is BRLYT)
LoadBxlyt(((BRLYT)file).header, file.FileName);
else if (file is IArchiveFile)
{
var layouts = SearchLayoutFiles((IArchiveFile)file);
@ -307,6 +309,8 @@ namespace LayoutBXLYT
LoadBxlyt(((BFLYT)layout).header, file.FileName);
if (layout is BCLYT)
LoadBxlyt(((BCLYT)layout).header, file.FileName);
if (layout is BRLYT)
LoadBxlyt(((BRLYT)layout).header, file.FileName);
}
}
}
@ -316,6 +320,8 @@ namespace LayoutBXLYT
LoadBxlyt(((BFLYT)layouts[0]).header, file.FileName);
if (layouts[0] is BCLYT)
LoadBxlyt(((BCLYT)layouts[0]).header, file.FileName);
if (layouts[0] is BRLYT)
LoadBxlyt(((BRLYT)layouts[0]).header, file.FileName);
}
}
else if (file is BFLAN)
@ -335,7 +341,7 @@ namespace LayoutBXLYT
foreach (var file in archiveFile.Files)
{
var fileFormat = STFileLoader.OpenFileFormat(file.FileName,
new Type[] { typeof(BFLYT), typeof(BCLYT), typeof(SARC) }, file.FileData);
new Type[] { typeof(BFLYT), typeof(BCLYT), typeof(BRLYT), typeof(SARC) }, file.FileData);
if (fileFormat is BFLYT)
{
@ -405,6 +411,7 @@ namespace LayoutBXLYT
if (ActiveLayout.FileInfo is BFLYT)
{
TextConverter = new LayoutTextDocked();
TextConverter.Text = "Text Converter";
TextConverter.LoadLayout((BFLYT)ActiveLayout.FileInfo);
TextConverter.Show(dockPanel1, DockState.DockLeft);
}

View File

@ -62,11 +62,14 @@ namespace LayoutBXLYT
string imageKey = "";
if (pane is BFLYT.WND1) imageKey = "WindowPane";
else if (pane is BFLYT.PIC1) imageKey = "PicturePane";
else if (pane is BFLYT.BND1) imageKey = "BoundryPane";
else if (pane is BCLYT.WND1) imageKey = "WindowPane";
else if (pane is BCLYT.BND1) imageKey = "BoundryPane";
else if (pane is BRLYT.WND1) imageKey = "WindowPane";
else if (pane is BFLYT.PIC1) imageKey = "PicturePane";
else if (pane is BCLYT.PIC1) imageKey = "PicturePane";
else if (pane is BRLYT.PIC1) imageKey = "PicturePane";
else if (pane is BFLYT.BND1) imageKey = "BoundryPane";
else if (pane is BCLYT.BND1) imageKey = "BoundryPane";
else if (pane is BRLYT.BND1) imageKey = "BoundryPane";
else imageKey = "NullPane";
paneNode.ImageKey = imageKey;

View File

@ -124,11 +124,15 @@ namespace LayoutBXLYT
if (pane is BFLYT.PIC1)
DrawPicturePane((BFLYT.PIC1)pane);
else if (pane is BCLYT.PIC1)
DrawDefaultPane((BCLYT.PIC1)pane);
DrawPicturePane((BCLYT.PIC1)pane);
else if (pane is BRLYT.PIC1)
DrawPicturePane((BRLYT.PIC1)pane);
else if (pane is BFLYT.PAN1)
DrawDefaultPane((BFLYT.PAN1)pane);
else if (pane is BCLYT.PAN1)
DrawDefaultPane((BCLYT.PAN1)pane);
else if (pane is BRLYT.PAN1)
DrawDefaultPane((BRLYT.PAN1)pane);
}
else
isRoot = false;
@ -199,7 +203,6 @@ namespace LayoutBXLYT
DrawRectangle(pane.CreateRectangle(), TexCoords, Colors);
}
int texId = 1;
private void DrawPicturePane(BCLYT.PIC1 pane)
{
Vector2[] TexCoords = new Vector2[] {
@ -239,6 +242,46 @@ namespace LayoutBXLYT
GL.BindTexture(TextureTarget.Texture2D, 0);
}
private void DrawPicturePane(BRLYT.PIC1 pane)
{
Vector2[] TexCoords = new Vector2[] {
new Vector2(1,1),
new Vector2(0,1),
new Vector2(0,0),
new Vector2(1,0)
};
Color[] Colors = new Color[] {
pane.ColorTopLeft.Color,
pane.ColorTopRight.Color,
pane.ColorBottomRight.Color,
pane.ColorBottomLeft.Color,
};
if (pane.TexCoords.Length > 0)
{
var mat = pane.GetMaterial();
string textureMap0 = "";
if (mat.TextureMaps.Count > 0)
textureMap0 = mat.GetTexture(0);
// if (Textures.ContainsKey(textureMap0))
// BindGLTexture(mat.TextureMaps[0], Textures[textureMap0]);
GL.BindTexture(TextureTarget.Texture2D, RenderTools.uvTestPattern.RenderableTex.TexID);
TexCoords = new Vector2[] {
pane.TexCoords[0].TopLeft.ToTKVector2(),
pane.TexCoords[0].TopRight.ToTKVector2(),
pane.TexCoords[0].BottomRight.ToTKVector2(),
pane.TexCoords[0].BottomLeft.ToTKVector2(),
};
}
DrawRectangle(pane.CreateRectangle(), TexCoords, Colors, false);
GL.BindTexture(TextureTarget.Texture2D, 0);
}
private void DrawPicturePane(BFLYT.PIC1 pane)
{
Vector2[] TexCoords = new Vector2[] {

View File

@ -368,6 +368,7 @@ namespace FirstPlugin
Formats.Add(typeof(G1T));
Formats.Add(typeof(LayoutBXLYT.BFLYT));
Formats.Add(typeof(LayoutBXLYT.BCLYT));
Formats.Add(typeof(LayoutBXLYT.BRLYT));
Formats.Add(typeof(ZSI));
Formats.Add(typeof(IGZ_TEX));
Formats.Add(typeof(MOD));

View File

@ -124,8 +124,8 @@ namespace Ryujinx.Graphics.Gal.Texture
throw new ASTCDecoderException("Invalid block mode");
}
Console.WriteLine($"BlockWidth {BlockWidth} {BlockHeight} BlockHeight");
Console.WriteLine($"TexelParams {TexelParams.Width} X {TexelParams.Height}");
// Console.WriteLine($"BlockWidth {BlockWidth} {BlockHeight} BlockHeight");
// Console.WriteLine($"TexelParams {TexelParams.Width} X {TexelParams.Height}");
if (TexelParams.VoidExtentLDR)
{

View File

@ -599,6 +599,8 @@ namespace Toolbox.Library.Forms
private void treeViewCustom1_DragEnter(object sender, DragEventArgs e)
{
if (!Runtime.EnableDragDrop) return;
if (e.Data.GetDataPresent(DataFormats.FileDrop))
e.Effect = DragDropEffects.All;
else
@ -615,14 +617,32 @@ namespace Toolbox.Library.Forms
if (node is ArchiveFileWrapper)
{
treeViewCustom1.DoDragDrop("dummy", DragDropEffects.Copy);
}
else if (node is ArchiveFolderNodeWrapper || node is ArchiveRootNodeWrapper)
{
treeViewCustom1.DoDragDrop("dummy", DragDropEffects.Copy);
}
}
private void DropFileOutsideApplication(TreeNode node)
{
if (node is ArchiveFileWrapper)
{
Runtime.EnableDragDrop = false;
string fullPath = Write2TempAndGetFullPath(((ArchiveFileWrapper)node).ArchiveFileInfo);
DataObject dragObj = new DataObject();
dragObj.SetFileDropList(new System.Collections.Specialized.StringCollection() { fullPath });
treeViewCustom1.DoDragDrop(dragObj, DragDropEffects.Copy);
Runtime.EnableDragDrop = true;
}
else if (node is ArchiveFolderNodeWrapper || node is ArchiveRootNodeWrapper)
{
Runtime.EnableDragDrop = false;
string[] fullPaths = Write2TempAndGetFullPath(node);
DataObject dragObj = new DataObject();
@ -630,6 +650,8 @@ namespace Toolbox.Library.Forms
collection.AddRange(fullPaths);
dragObj.SetFileDropList(collection);
treeViewCustom1.DoDragDrop(dragObj, DragDropEffects.Copy);
Runtime.EnableDragDrop = true;
}
}
@ -669,6 +691,18 @@ namespace Toolbox.Library.Forms
}
private void treeViewCustom1_DragDrop(object sender, DragEventArgs e)
{
if (!Runtime.EnableDragDrop) return;
Console.WriteLine("test");
if (e.Effect == DragDropEffects.Copy)
{
Console.WriteLine("drop");
DropFileOutsideApplication(treeViewCustom1.SelectedNode);
}
else if (e.Effect == DragDropEffects.All)
{
Point pt = treeViewCustom1.PointToClient(new Point(e.X, e.Y));
var node = treeViewCustom1.GetNodeAt(pt.X, pt.Y);
@ -705,6 +739,7 @@ namespace Toolbox.Library.Forms
Cursor.Current = Cursors.Default;
}
}
}
private ArchiveRootNodeWrapper GetActiveArchive()
{

View File

@ -123,6 +123,9 @@
<metadata name="objectEditorMenu.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<metadata name="objectEditorMenu.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<metadata name="treeNodeContextMenu.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>166, 17</value>
</metadata>

View File

@ -0,0 +1,75 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Drawing;
namespace Toolbox.Library
{
//Class that contains colors and useful color related methods
public class STColor16
{
public ushort R { get; set; }
public ushort G { get; set; }
public ushort B { get; set; }
public ushort A { get; set; }
public Color Color
{
get
{
return Color.FromArgb(A, R, G, B);
}
set
{
var color = value;
R = color.R;
G = color.G;
B = color.B;
A = color.A;
}
}
public static STColor16 FromShorts(ushort[] color)
{
STColor16 col = new STColor16();
col.R = color[0];
col.G = color[1];
col.B = color[2];
col.A = color[3];
return col;
}
public STColor16()
{
R = 255;
G = 255;
B = 255;
A = 255;
}
public STColor16(ushort r, ushort g, ushort b, ushort a)
{
R = r;
G = g;
B = b;
A = a;
}
public override string ToString()
{
return String.Format("R:{0} G:{1} B:{2} A:{3}", R, G, B, A);
}
public string ToHexString()
{
return String.Format("R:{0:X2} G:{1:X2} B:{2:X2} A:{3:X2}", R, G, B, A);
}
public static STColor8 White
{
get { return new STColor8(255, 255, 255, 255); }
}
}
}

View File

@ -296,6 +296,20 @@ namespace Toolbox.Library.IO
return STColor8.FromBytes(ReadBytes(4));
}
public STColor16[] ReadColor16sRGBA(int count)
{
STColor16[] colors = new STColor16[count];
for (int i = 0; i < count; i++)
colors[i] = STColor16.FromShorts(ReadUInt16s(4));
return colors;
}
public STColor16 ReadColor16RGBA()
{
return STColor16.FromShorts(ReadUInt16s(4));
}
public STColor[] ReadColorsRGBA(int count)
{
STColor[] colors = new STColor[count];

View File

@ -18,6 +18,8 @@ namespace Toolbox.Library
//Disable loading 3k and higher texture res to prevent slowdown and memory issues
public static bool DisableLoadingGLHighResTextures = true;
public static bool EnableDragDrop = true;
public static bool UseSingleInstance = true;
public static bool UseDirectXTexDecoder = true;
public static bool DEVELOPER_DEBUG_MODE = false;

View File

@ -68,7 +68,7 @@ namespace Toolbox.Library
return MipMapSizes;
}
public static byte[] GetImageData(STGenericTexture texture, byte[] ImageData, int ArrayLevel, int MipLevel, int target = 1)
public static byte[] GetImageData(STGenericTexture texture, byte[] ImageData, int ArrayLevel, int MipLevel, int target = 1, bool LinearTileMode = false)
{
uint bpp = STGenericTexture.GetBytesPerPixel(texture.Format);
uint blkWidth = STGenericTexture.GetBlockWidth(texture.Format);
@ -81,6 +81,8 @@ namespace Toolbox.Library
uint Pitch = 0;
uint DataAlignment = 512;
uint TileMode = 0;
if (LinearTileMode)
TileMode = 1;
int linesPerBlockHeight = (1 << (int)BlockHeightLog2) * 8;
@ -100,6 +102,8 @@ namespace Toolbox.Library
uint size = TegraX1Swizzle.DIV_ROUND_UP(width, blkWidth) * TegraX1Swizzle.DIV_ROUND_UP(height, blkHeight) * bpp;
Console.WriteLine($"size " + size);
if (TegraX1Swizzle.pow2_round_up(TegraX1Swizzle.DIV_ROUND_UP(height, blkWidth)) < linesPerBlockHeight)
blockHeightShift += 1;
@ -122,7 +126,6 @@ namespace Toolbox.Library
Pitch = TegraX1Swizzle.round_up(width__ * bpp, 64);
SurfaceSize += Pitch * TegraX1Swizzle.round_up(height__, Math.Max(1, blockHeight >> blockHeightShift) * 8);
Console.WriteLine($"{width} {height} {blkWidth} {blkHeight} {target} {bpp} {TileMode} {(int)Math.Max(0, BlockHeightLog2 - blockHeightShift)} {data_.Length}");
byte[] result = TegraX1Swizzle.deswizzle(width, height, depth, blkWidth, blkHeight, blkDepth, target, bpp, TileMode, (int)Math.Max(0, BlockHeightLog2 - blockHeightShift), data_);
//Create a copy and use that to remove uneeded data
byte[] result_ = new byte[size];

View File

@ -300,14 +300,15 @@
<Compile Include="Interfaces\ModelData\IMeshContainer.cs" />
<Compile Include="Interfaces\Textures\ITextureContainer.cs" />
<Compile Include="Interfaces\Forms\IUpdateForm.cs" />
<Compile Include="IO\Colors\STColor16.cs" />
<Compile Include="IO\Extensions\ColorExtensions.cs" />
<Compile Include="IO\Extensions\StreamExport.cs" />
<Compile Include="IO\Extensions\UintExtension.cs" />
<Compile Include="IO\FileStreamStorage.cs" />
<Compile Include="IO\HSVPixel.cs" />
<Compile Include="IO\IOComoon.cs" />
<Compile Include="IO\STColor.cs" />
<Compile Include="IO\STColor8.cs" />
<Compile Include="IO\Colors\STColor.cs" />
<Compile Include="IO\Colors\STColor8.cs" />
<Compile Include="IO\SubStream.cs" />
<Compile Include="Rendering\GenericModelRenderer\GenericModelRenderer.cs" />
<Compile Include="Rendering\GenericModelRenderer\GenericRenderedObject.cs" />

View File

@ -980,6 +980,8 @@ namespace Toolbox
private void MainForm_DragEnter(object sender, DragEventArgs e)
{
if (!Runtime.EnableDragDrop) return;
if (e.Data.GetDataPresent(DataFormats.FileDrop))
e.Effect = DragDropEffects.All;
else
@ -991,6 +993,8 @@ namespace Toolbox
private void MainForm_DragDrop(object sender, DragEventArgs e)
{
if (!Runtime.EnableDragDrop) return;
Cursor.Current = Cursors.WaitCursor;
string[] files = (string[])e.Data.GetData(DataFormats.FileDrop);