mirror of
https://mirror.ghproxy.com/https://github.com/dexyfex/CodeWalker
synced 2026-05-15 09:14:54 +08:00
Convert cache_y.dat files to XML
This commit is contained in:
+41
-2
@@ -189,21 +189,42 @@ namespace CodeWalker
|
||||
InitFileType(".awc", "Audio Wave Container", 22, FileTypeAction.ViewAwc);
|
||||
InitFileType(".rel", "Audio Data (REL)", 23, FileTypeAction.ViewRel);
|
||||
|
||||
InitSubFileType(".dat", "cache_y.dat", "Cache File", 6, FileTypeAction.ViewCacheDat);
|
||||
}
|
||||
private void InitFileType(string ext, string name, int imgidx, FileTypeAction defaultAction = FileTypeAction.ViewHex)
|
||||
{
|
||||
var ft = new FileTypeInfo(ext, name, imgidx, defaultAction);
|
||||
FileTypes[ext] = ft;
|
||||
}
|
||||
private void InitSubFileType(string ext, string subext, string name, int imgidx, FileTypeAction defaultAction = FileTypeAction.ViewHex)
|
||||
{
|
||||
FileTypeInfo pti = null;
|
||||
if (FileTypes.TryGetValue(ext, out pti))
|
||||
{
|
||||
var ft = new FileTypeInfo(subext, name, imgidx, defaultAction);
|
||||
pti.AddSubType(ft);
|
||||
}
|
||||
}
|
||||
public FileTypeInfo GetFileType(string fn)
|
||||
{
|
||||
var fi = new FileInfo(fn);
|
||||
var ext = fi.Extension.ToLower();
|
||||
var ext = fi.Extension.ToLowerInvariant();
|
||||
if (!string.IsNullOrEmpty(ext))
|
||||
{
|
||||
FileTypeInfo ft;
|
||||
if (FileTypes.TryGetValue(ext, out ft))
|
||||
{
|
||||
if (ft.SubTypes != null)
|
||||
{
|
||||
var fnl = fn.ToLowerInvariant();
|
||||
foreach (var sft in ft.SubTypes)
|
||||
{
|
||||
if (fnl.EndsWith(sft.Extension))
|
||||
{
|
||||
return sft;
|
||||
}
|
||||
}
|
||||
}
|
||||
return ft;
|
||||
}
|
||||
else
|
||||
@@ -1062,6 +1083,7 @@ namespace CodeWalker
|
||||
case FileTypeAction.ViewYwr:
|
||||
case FileTypeAction.ViewYvr:
|
||||
case FileTypeAction.ViewYcd:
|
||||
case FileTypeAction.ViewCacheDat:
|
||||
return true;
|
||||
case FileTypeAction.ViewHex:
|
||||
default:
|
||||
@@ -1168,6 +1190,9 @@ namespace CodeWalker
|
||||
case FileTypeAction.ViewYcd:
|
||||
ViewYcd(name, path, data, item.File);
|
||||
break;
|
||||
case FileTypeAction.ViewCacheDat:
|
||||
ViewCacheDat(name, path, data, item.File);
|
||||
break;
|
||||
case FileTypeAction.ViewHex:
|
||||
default:
|
||||
ViewHex(name, path, data);
|
||||
@@ -1367,7 +1392,13 @@ namespace CodeWalker
|
||||
f.Show();
|
||||
f.LoadYcd(ycd);
|
||||
}
|
||||
|
||||
private void ViewCacheDat(string name, string path, byte[] data, RpfFileEntry e)
|
||||
{
|
||||
var cachedat = RpfFile.GetFile<CacheDatFile>(e, data);
|
||||
MetaForm f = new MetaForm();
|
||||
f.Show();
|
||||
f.LoadMeta(cachedat);
|
||||
}
|
||||
|
||||
|
||||
private void ShowTreeContextMenu(TreeNode n, Point p)
|
||||
@@ -2740,6 +2771,7 @@ namespace CodeWalker
|
||||
public string Extension { get; set; }
|
||||
public int ImageIndex { get; set; }
|
||||
public FileTypeAction DefaultAction { get; set; }
|
||||
public List<FileTypeInfo> SubTypes { get; set; }
|
||||
|
||||
public FileTypeInfo(string extension, string name, int imageindex, FileTypeAction defaultAction)
|
||||
{
|
||||
@@ -2748,6 +2780,12 @@ namespace CodeWalker
|
||||
ImageIndex = imageindex;
|
||||
DefaultAction = defaultAction;
|
||||
}
|
||||
|
||||
public void AddSubType(FileTypeInfo t)
|
||||
{
|
||||
if (SubTypes == null) SubTypes = new List<FileTypeInfo>();
|
||||
SubTypes.Add(t);
|
||||
}
|
||||
}
|
||||
|
||||
public enum FileTypeAction
|
||||
@@ -2770,6 +2808,7 @@ namespace CodeWalker
|
||||
ViewYwr = 15,
|
||||
ViewYvr = 16,
|
||||
ViewYcd = 17,
|
||||
ViewCacheDat = 18,
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user