mirror of
https://mirror.ghproxy.com/https://github.com/dexyfex/CodeWalker
synced 2024-11-30 02:42:54 +08:00
Added ResourceAnalyzer
This commit is contained in:
parent
9aa228c1da
commit
d3bc78ddb4
@ -106,6 +106,7 @@ namespace CodeWalker.GameFiles
|
||||
|
||||
public YftFile Yft { get; set; }
|
||||
|
||||
//public ResourceAnalyzer Analyzer { get; set; }
|
||||
|
||||
public override void Read(ResourceDataReader reader, params object[] parameters)
|
||||
{
|
||||
@ -196,6 +197,7 @@ namespace CodeWalker.GameFiles
|
||||
|
||||
AssignChildrenShaders();
|
||||
|
||||
//Analyzer = new ResourceAnalyzer(reader);
|
||||
|
||||
|
||||
////just testing!!
|
||||
@ -303,8 +305,6 @@ namespace CodeWalker.GameFiles
|
||||
// default:
|
||||
// break;//no hit
|
||||
//}
|
||||
|
||||
|
||||
}
|
||||
public override void Write(ResourceDataWriter writer, params object[] parameters)
|
||||
{
|
||||
|
58
CodeWalker.Core/GameFiles/Resources/ResourceAnalyzer.cs
Normal file
58
CodeWalker.Core/GameFiles/Resources/ResourceAnalyzer.cs
Normal file
@ -0,0 +1,58 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Text;
|
||||
|
||||
namespace CodeWalker.GameFiles
|
||||
{
|
||||
[TypeConverter(typeof(ExpandableObjectConverter))]
|
||||
public class ResourceAnalyzer
|
||||
{
|
||||
|
||||
public ResourceAnalyzerItem[] Blocks { get; set; }
|
||||
|
||||
[TypeConverter(typeof(ExpandableObjectConverter))]
|
||||
public class ResourceAnalyzerItem
|
||||
{
|
||||
public long Position { get; set; }
|
||||
public long Length { get; set; }
|
||||
public long Offset { get { return Position & 0xFFFFFFF; } }
|
||||
public ResourceSystemBlock SystemBlock { get; set; }
|
||||
public ResourceGraphicsBlock GraphicsBlock { get; set; }
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
var type = "";
|
||||
if (SystemBlock != null)
|
||||
{
|
||||
type = SystemBlock.GetType().Name;
|
||||
}
|
||||
if (GraphicsBlock != null)
|
||||
{
|
||||
type = GraphicsBlock.GetType().Name;
|
||||
}
|
||||
return Offset.ToString() + " - " + Length.ToString() + " - " + type;
|
||||
}
|
||||
}
|
||||
|
||||
public ResourceAnalyzer(ResourceDataReader reader)
|
||||
{
|
||||
var dlist = new List<ResourceAnalyzerItem>();
|
||||
var dict = reader.blockPool;
|
||||
foreach (var kvp in dict)
|
||||
{
|
||||
var item = new ResourceAnalyzerItem();
|
||||
item.Position = kvp.Key;
|
||||
item.Length = kvp.Value.BlockLength;
|
||||
item.SystemBlock = kvp.Value as ResourceSystemBlock;
|
||||
item.GraphicsBlock = kvp.Value as ResourceGraphicsBlock;
|
||||
dlist.Add(item);
|
||||
}
|
||||
|
||||
dlist.Sort((a, b) => a.Position.CompareTo(b.Position));
|
||||
|
||||
Blocks = dlist.ToArray();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user