New Project Window

This commit is contained in:
dexyfex
2018-03-04 00:03:08 +11:00
Unverified
parent 0c558e746c
commit c093aa4736
136 changed files with 29501 additions and 20 deletions
@@ -12,7 +12,9 @@ namespace CodeWalker.GameFiles
public class YtypFile : PackedFile
{
public RpfFileEntry FileEntry { get; set; }
public RpfFileEntry RpfFileEntry { get; set; }
public string FilePath { get; set; }
public string Name { get; set; }
public Meta Meta { get; set; }
public PsoFile Pso { get; set; }
@@ -32,16 +34,21 @@ namespace CodeWalker.GameFiles
public CCompositeEntityType[] CompositeEntityTypes { get; set; }
//fields used by the editor:
public bool HasChanged { get; set; } = false;
public List<string> SaveWarnings = null;
public override string ToString()
{
return (FileEntry != null) ? FileEntry.Name : string.Empty;
return (RpfFileEntry != null) ? RpfFileEntry.Name : string.Empty;
}
public void Load(byte[] data, RpfFileEntry entry)
{
FileEntry = entry;
Name = entry.Name;
RpfFileEntry = entry;
RpfResourceFileEntry resentry = entry as RpfResourceFileEntry;
if (resentry == null)
{
@@ -219,6 +226,61 @@ namespace CodeWalker.GameFiles
}
public void Load(byte[] data) //REFACTOR THIS WITH YMAP!!
{
//direct load from a raw, compressed ymap file (openIV-compatible format)
RpfResourceFileEntry resentry = new RpfResourceFileEntry();
//hopefully this format has an RSC7 header...
uint rsc7 = BitConverter.ToUInt32(data, 0);
if (rsc7 == 0x37435352) //RSC7 header present!
{
int version = BitConverter.ToInt32(data, 4);
resentry.SystemFlags = BitConverter.ToUInt32(data, 8);
resentry.GraphicsFlags = BitConverter.ToUInt32(data, 12);
if (data.Length > 16)
{
int newlen = data.Length - 16; //trim the header from the data passed to the next step.
byte[] newdata = new byte[newlen];
Buffer.BlockCopy(data, 16, newdata, 0, newlen);
data = newdata;
}
else
{
data = null; //shouldn't happen... empty..
}
}
else
{
//direct load from file without the rpf header..
//assume it's in resource meta format
resentry.SystemFlags = RpfResourceFileEntry.GetFlagsFromSize(data.Length, 0);
resentry.GraphicsFlags = RpfResourceFileEntry.GetFlagsFromSize(0, 2); //graphics type 2 for ymap
}
var oldresentry = RpfFileEntry as RpfResourceFileEntry;
if (oldresentry != null) //update the existing entry with the new one
{
oldresentry.SystemFlags = resentry.SystemFlags;
oldresentry.GraphicsFlags = resentry.GraphicsFlags;
resentry.Name = oldresentry.Name;
resentry.NameHash = oldresentry.NameHash;
resentry.NameLower = oldresentry.NameLower;
resentry.ShortNameHash = oldresentry.ShortNameHash;
}
else
{
RpfFileEntry = resentry; //just stick it in there for later...
}
data = ResourceBuilder.Decompress(data);
Load(data, resentry);
//Loaded = true;
}
}
+1 -1
View File
@@ -232,7 +232,7 @@ namespace CodeWalker.GameFiles
var dlclistxml = RpfMan.GetFileXml(dlclistpath);
DlcPaths.Clear();
if (dlclistxml == null)
if ((dlclistxml == null) || (dlclistxml.DocumentElement == null))
{
ErrorLog("InitDlcList: Couldn't load " + dlclistpath + ".");
}
@@ -77,7 +77,7 @@ namespace CodeWalker.GameFiles
}
public static string GetXml(YtypFile ytyp, out string filename)
{
var fn = (ytyp?.FileEntry?.Name) ?? "";
var fn = (ytyp?.RpfFileEntry?.Name) ?? "";
if (ytyp.Meta != null) { filename = fn + ".xml"; return GetXml(ytyp.Meta); }
else if (ytyp.Pso != null) { filename = fn + ".pso.xml"; return PsoXml.GetXml(ytyp.Pso); }
else if (ytyp.Rbf != null) { filename = fn + ".rbf.xml"; return RbfXml.GetXml(ytyp.Rbf); }