示例#1
0
        public int GetHandleIndex(string name, ushort filetype, ushort flags, bool addnew = false)
        {
            for (var i = 0; i < imports.Count; i++)
            {
                if (imports[i].Import.className == filetype &&
                    imports[i].Import.flags == flags &&
                    (imports[i].DepotPathStr == name || (string.IsNullOrEmpty(name) && string.IsNullOrEmpty(imports[i].DepotPathStr))))
                {
                    return(i);
                }
            }

            if (addnew)
            {
                // we can leave the depotpath 0 here, it will get updated on file write
                // value is the offset in the stringtable, which gets re-written on file write
                // a better solution might be to dynamically update the string table
                var import = new CR2WImport()
                {
                    flags     = flags,
                    depotPath = 0,
                    className = filetype
                };
                imports.Add(new CR2WImportWrapper(import)
                {
                    DepotPathStr = name,
                });

                return(imports.Count - 1);
            }

            return(-1);
        }
示例#2
0
 public CR2WImportWrapper(CR2WImport import, CR2WFile cr2w)
 {
     Import = import;
     _cr2w  = cr2w;
 }