2
0
Fork 0
mirror of https://github.com/KillzXGaming/Switch-Toolbox synced 2025-03-12 12:57:33 +00:00

Start to add a base for multi select tree for layout editor

This commit is contained in:
KillzXGaming 2020-02-17 19:54:50 -05:00
parent eb0ddc7864
commit 5e4ec3d131
7 changed files with 118 additions and 29 deletions
File_Format_Library
Switch_Toolbox_Library
Forms/Custom/Treeview
Texture Decoding/Gamecube
Toolbox_Library.csproj

View file

@ -1691,16 +1691,32 @@ namespace LayoutBXLYT
{
reader.SetByteOrder(true);
reader.ReadUInt32(); //magic
ushort byteOrderMark = reader.ReadUInt16();
reader.CheckByteOrderMark(byteOrderMark);
ushort HeaderSize = reader.ReadUInt16();
uint Version = reader.ReadUInt32();
uint FileSize = reader.ReadUInt32();
ushort sectionCount = reader.ReadUInt16();
reader.ReadUInt16(); //Padding
ushort sectionCount = 0;
string signature = reader.ReadString(4, Encoding.ASCII);
if (signature == "RLAN")
{
ushort byteOrderMark = reader.ReadUInt16();
reader.CheckByteOrderMark(byteOrderMark);
uint Version = reader.ReadUInt16();
uint FileSize = reader.ReadUInt32();
ushort HeaderSize = reader.ReadUInt16();
sectionCount = reader.ReadUInt16();
reader.ReadUInt16(); //Padding
reader.SeekBegin(HeaderSize);
}
else
{
ushort byteOrderMark = reader.ReadUInt16();
reader.CheckByteOrderMark(byteOrderMark);
ushort HeaderSize = reader.ReadUInt16();
uint Version = reader.ReadUInt32();
uint FileSize = reader.ReadUInt32();
sectionCount = reader.ReadUInt16();
reader.ReadUInt16(); //Padding
reader.SeekBegin(HeaderSize);
}
reader.SeekBegin(HeaderSize);
for (int i = 0; i < sectionCount; i++)
{
long pos = reader.Position;
@ -1720,12 +1736,20 @@ namespace LayoutBXLYT
for (int e = 0; e < numEntries; e++)
{
reader.SeekBegin(pos + entryOffsets[e]);
string name = reader.ReadString(28, true);
if (EntryNames.Contains(name))
return true;
if (signature == "RLAN")
{
string name = reader.ReadString(0x14, true);
if (EntryNames.Contains(name))
return true;
}
else
{
string name = reader.ReadString(28, true);
if (EntryNames.Contains(name))
return true;
}
}
}
reader.SeekBegin(pos + SectionSize);
}
}

View file

@ -65,6 +65,8 @@ namespace LayoutBXLYT
private void SearchActiveAnimations(BasePane pane)
{
Console.WriteLine($"SearchActiveAnimations {pane.Name} {pane.LayoutFile == null}");
if (pane.LayoutFile == null) return;
var animations = GetAnimations();
@ -72,12 +74,14 @@ namespace LayoutBXLYT
string matName = material != null ? material.Name : "";
var archive = pane.LayoutFile.FileInfo.IFileInfo.ArchiveParent;
if (archive != null)
{
foreach (var file in archive.Files)
{
if (Utils.GetExtension(file.FileName) == ".bflan" &&
!animations.Any(x => x.FileName == file.FileName))
string ext = Utils.GetExtension(file.FileName);
bool isBxlan = ext == ".bflan" || ext == ".bclan" || ext == ".brlan";
if (isBxlan && !animations.Any(x => x.FileName == file.FileName))
{
if (BxlanHeader.ContainsEntry(file.FileData, new string[2] { pane.Name, matName }))
animationCB.Items.Add(new AnimationComboboxItem(file.FileName) { Tag = file });
@ -87,8 +91,7 @@ namespace LayoutBXLYT
for (int i = 0; i < animations?.Count; i++)
{
if (animations[i].ContainsEntry(pane.Name) || animations[i].ContainsEntry(matName))
{
if (animations[i].ContainsEntry(pane.Name) || animations[i].ContainsEntry(matName)) {
animationCB.Items.Add(new AnimationComboboxItem(animations[i].FileName) { Tag = animations[i] });
}
}

View file

@ -28,7 +28,7 @@
/// </summary>
private void InitializeComponent()
{
this.treeView1 = new System.Windows.Forms.TreeView();
this.treeView1 = new Toolbox.Library.Forms.MultiselectTreeView();
this.SuspendLayout();
//
// treeView1
@ -64,6 +64,6 @@
#endregion
private System.Windows.Forms.TreeView treeView1;
private Toolbox.Library.Forms.MultiselectTreeView treeView1;
}
}

View file

@ -158,6 +158,16 @@ namespace LayoutBXLYT
isLoaded = false;
}
public List<BasePane> GetSelectedPanes()
{
List<BasePane> nodes = new List<BasePane>();
foreach (var node in treeView1.SelectedNodes) {
if (node.Tag != null && node.Tag is BasePane)
nodes.Add((BasePane)node.Tag);
}
return nodes;
}
private void LoadTextures(List<string> textures)
{
ActiveLayout.TextureFolder = new TreeNode("Textures");
@ -357,7 +367,8 @@ namespace LayoutBXLYT
private void TogglePane(object sender, EventArgs e)
{
TogglePane(treeView1.SelectedNode);
foreach (TreeNode node in treeView1.SelectedNodes)
TogglePane(node);
}
private void TogglePane(TreeNode node)
@ -373,14 +384,15 @@ namespace LayoutBXLYT
private void treeView1_KeyDown(object sender, KeyEventArgs e)
{
var node = treeView1.SelectedNode;
if (node == null || node.Tag == null)
return;
foreach (var node in treeView1.SelectedNodes) {
if (node == null || node.Tag == null)
continue;
if (e.KeyCode == Keys.H && e.Control)
{
if (node.Tag is BasePane)
TogglePane(node);
if (e.KeyCode == Keys.H)
{
if (node.Tag is BasePane)
TogglePane(node);
}
}
}
@ -391,7 +403,8 @@ namespace LayoutBXLYT
if (e.Button == MouseButtons.Right)
{
treeView1.SelectedNode = e.Node;
if (treeView1.SelectedNodes.Count == 0)
treeView1.SelectedNode = e.Node;
if (e.Node.Tag is BasePane)
{

View file

@ -0,0 +1,41 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Windows.Forms;
using Toolbox.Library;
namespace Toolbox.Library.Forms
{
public class MultiselectTreeView : TreeView
{
#region Public Properties
private List<TreeNode> m_SelectedNodes = null;
public List<TreeNode> SelectedNodes
{
get
{
return new List<TreeNode>() { SelectedNode };
}
set
{
//ClearSelectedNodes();
if (value != null)
{
foreach (TreeNode node in value)
{
//ToggleNode(node, true);
}
}
}
}
#endregion
public MultiselectTreeView()
{
m_SelectedNodes = new List<TreeNode>();
base.SelectedNode = null;
}
}
}

View file

@ -232,13 +232,18 @@ namespace Toolbox.Library
public static int GetDataSizeWithMips(uint format, uint Width, uint Height, uint MipCount)
{
if (MipCount == 0)
MipCount = 1;
int size = 0;
for (int m = 0; m < MipCount; m++)
{
uint width = (uint)Math.Max(1, Width >> m);
uint height = (uint)Math.Max(1, Height >> m);
size =+ Decode_Gamecube.GetDataSize(format, width, height);
size += Decode_Gamecube.GetDataSize(format, width, height);
System.Console.WriteLine($"size {m} {width} {height} {size}");
}
return size;

View file

@ -314,6 +314,9 @@
<Compile Include="Forms\Custom\STRadioButton.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="Forms\Custom\Treeview\MultiselectTreeView.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="Forms\Custom\Treeview\TreeviewDragSorter.cs">
<SubType>Component</SubType>
</Compile>