示例#1
0
 private void openPccToolStripMenuItem_Click_1(object sender, EventArgs e)
 {
     OpenFileDialog d = new OpenFileDialog();
     d.Filter = "*.pcc|*.pcc";
     if (d.ShowDialog() == System.Windows.Forms.DialogResult.OK)
     {
         pcc = new PCCObject(d.FileName);
         CurrentView = 2;
         classes = new List<int>();
         foreach (PCCObject.ExportEntry ent in pcc.Exports)
         {
             int f = -1;
             for (int i = 0; i < classes.Count(); i++)
                 if (classes[i] == ent.ClassNameID)
                     f = i;
             if (f == -1)
                 classes.Add(ent.ClassNameID);
         }
         bool run = true;
         while (run)
         {
             run = false;
             for (int i = 0; i < classes.Count() - 1; i++)
                 if (pcc.GetName(classes[i]).CompareTo(pcc.GetName(classes[i + 1])) > 0)
                 {
                     int t = classes[i];
                     classes[i] = classes[i + 1];
                     classes[i + 1] = t;
                     run = true;
                 }
         }
         RefreshView();
     }
 }
示例#2
0
 public SAction(int idx, float x, float y, PCCObject p, GraphEditor grapheditor)
     : base(idx, x, y, p, grapheditor)
 {
     GetVarLinks();
     GetOutputLinks();
     originalX = x;
     originalY = y;
 }
示例#3
0
 public SAction(int idx, float x, float y, PCCObject p)
     : base(idx, x, y, p)
 {
     GetVarLinks();
     GetOutputLinks();
     originalX = x;
     originalY = y;
 }
 public SObj(int idx, float x, float y, PCCObject p)
     : base()
 {
     pcc = p;
     index = idx;
     comment = new SText(GetComment(index), commentColor, false);
     comment.X = 0;
     comment.Y = 0 - comment.Height;
     comment.Pickable = false;
     this.AddChild(comment);
     this.Pickable = true;
 }
示例#5
0
        private void openPccToolStripMenuItem_Click_1(object sender, EventArgs e)
        {
            OpenFileDialog d = new OpenFileDialog();

            d.Filter = "*.pcc|*.pcc";
            if (d.ShowDialog() == DialogResult.OK)
            {
                AddRecent(d.FileName);
                SaveRecentList();
                pcc = new PCCObject(d.FileName);
                loadPCC();
            }
        }
示例#6
0
        private void RecentFile_click(object sender, EventArgs e)
        {
            //just load a file
            string s = sender.ToString();

            try
            {
                pcc = new PCCObject(s);
                loadPCC();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error:\n" + ex.Message);
            }
        }
示例#7
0
 public PCCEditor()
 {
     InitializeComponent();
     LoadRecentList();
     RefreshRecent();
     if (RFiles != null && RFiles.Count != 0)
     {
         int index = RFiles.Count - 1;
         if (File.Exists(RFiles[index]))
         {
             pcc = new PCCObject(RFiles[index]);
             loadPCC();
         }
     }
 }
示例#8
0
        public TreeNode FindSequences(PCCObject pcc, int index, bool wantFullName = false, bool refSeq = false)
        {
            string objectName = "";

            if (refSeq)
            {
                List <SaltPropertyReader.Property> p = SaltPropertyReader.getPropList(pcc, pcc.Exports[index].Data);
                for (int i = 0; i < p.Count(); i++)
                {
                    if (p[i].Name == "ObjName")
                    {
                        objectName = p[i].Value.StringValue;
                        break;
                    }
                }
            }
            else
            {
                objectName = pcc.Exports[index].ObjectName;
            }
            TreeNode ret = new TreeNode("#" + index.ToString() + ": " + (wantFullName ? pcc.Exports[index].GetFullPath : objectName));

            ret.Name = index.ToString();
            Sequence seq = new Sequence(pcc, index);

            if (seq.SequenceObjects != null)
            {
                for (int i = 0; i < seq.SequenceObjects.Count(); i++)
                {
                    if (pcc.Exports[seq.SequenceObjects[i] - 1].ClassName == "Sequence" || pcc.Exports[seq.SequenceObjects[i] - 1].ClassName.StartsWith("PrefabSequence"))
                    {
                        TreeNode t = FindSequences(pcc, seq.SequenceObjects[i] - 1, wantFullName);
                        ret.Nodes.Add(t);
                    }
                    else if (pcc.Exports[seq.SequenceObjects[i] - 1].ClassName == "SequenceReference")
                    {
                        var props = SaltPropertyReader.getPropList(pcc, pcc.Exports[seq.SequenceObjects[i] - 1].Data);
                        var propSequenceReference = props.FirstOrDefault(p => p.Name.Equals("oSequenceReference"));
                        if (propSequenceReference != null)
                        {
                            TreeNode t = FindSequences(pcc, propSequenceReference.Value.IntValue - 1, wantFullName, true);
                            ret.Nodes.Add(t);
                        }
                    }
                }
            }
            return(ret);
        }
示例#9
0
        private void openPccToolStripMenuItem_Click_1(object sender, EventArgs e)
        {
            OpenFileDialog d = new OpenFileDialog();

            d.Filter = "*.pcc|*.pcc";
            if (d.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                pcc         = new PCCObject(d.FileName);
                CurrentView = 2;
                classes     = new List <int>();
                foreach (PCCObject.ExportEntry ent in pcc.Exports)
                {
                    int f = -1;
                    for (int i = 0; i < classes.Count(); i++)
                    {
                        if (classes[i] == ent.ClassNameID)
                        {
                            f = i;
                        }
                    }
                    if (f == -1)
                    {
                        classes.Add(ent.ClassNameID);
                    }
                }
                bool run = true;
                while (run)
                {
                    run = false;
                    for (int i = 0; i < classes.Count() - 1; i++)
                    {
                        if (pcc.GetName(classes[i]).CompareTo(pcc.GetName(classes[i + 1])) > 0)
                        {
                            int t = classes[i];
                            classes[i]     = classes[i + 1];
                            classes[i + 1] = t;
                            run            = true;
                        }
                    }
                }
                RefreshView();
            }
        }
示例#10
0
        private void loadToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (autoSaveViewToolStripMenuItem.Checked)
            {
                saveView();
            }
            OpenFileDialog d = new OpenFileDialog();

            d.Filter = "PCC Files(*.pcc)|*.pcc";
            if (d.ShowDialog() == DialogResult.OK)
            {
                pcc         = new PCCObject(d.FileName);
                CurrentFile = d.FileName;
                toolStripStatusLabel1.Text = CurrentFile.Substring(CurrentFile.LastIndexOf(@"\") + 1);
                LoadSequences();
                graphEditor.nodeLayer.RemoveAllChildren();
                graphEditor.edgeLayer.RemoveAllChildren();
                if (CurrentObjects != null)
                {
                    CurrentObjects.Clear();
                }
            }
        }
示例#11
0
 private void loadToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (autoSaveViewToolStripMenuItem.Checked)
         saveView();
     OpenFileDialog d = new OpenFileDialog();
     d.Filter = "PCC Files(*.pcc)|*.pcc";
     if (d.ShowDialog() == System.Windows.Forms.DialogResult.OK)
     {
         pcc = new PCCObject(d.FileName);
         CurrentFile = d.FileName;
         toolStripStatusLabel1.Text = CurrentFile.Substring(CurrentFile.LastIndexOf(@"\") + 1);
         LoadSequences();
         graphEditor.nodeLayer.RemoveAllChildren();
         graphEditor.edgeLayer.RemoveAllChildren();
         if(CurrentObjects != null)
             CurrentObjects.Clear();
     }
 }
示例#12
0
 public TreeNode FindSequences(PCCObject pcc, int index, bool wantFullName = false, bool refSeq = false)
 {
     string objectName = "";
     if (refSeq)
     {
         List<SaltPropertyReader.Property> p = SaltPropertyReader.getPropList(pcc, pcc.Exports[index].Data);
         for (int i = 0; i < p.Count(); i++)
             if (p[i].Name == "ObjName")
             {
                 objectName = p[i].Value.StringValue;
                 break;
             }
     }
     else
     {
         objectName = pcc.Exports[index].ObjectName;
     }
     TreeNode ret = new TreeNode("#" + index.ToString() + ": " + (wantFullName ? pcc.Exports[index].GetFullPath : objectName));
     ret.Name = index.ToString();
     Sequence seq = new Sequence(pcc, index);
     if (seq.SequenceObjects != null)
         for (int i = 0; i < seq.SequenceObjects.Count(); i++)
             if (pcc.Exports[seq.SequenceObjects[i] - 1].ClassName == "Sequence" || pcc.Exports[seq.SequenceObjects[i] - 1].ClassName.StartsWith("PrefabSequence"))
             {
                 TreeNode t = FindSequences(pcc, seq.SequenceObjects[i] - 1, wantFullName);
                 ret.Nodes.Add(t);
             }
             else if (pcc.Exports[seq.SequenceObjects[i] - 1].ClassName == "SequenceReference")
             {
                 var props = SaltPropertyReader.getPropList(pcc, pcc.Exports[seq.SequenceObjects[i] - 1].Data);
                 var propSequenceReference = props.FirstOrDefault(p => p.Name.Equals("oSequenceReference"));
                 if (propSequenceReference != null)
                 {
                     TreeNode t = FindSequences(pcc, propSequenceReference.Value.IntValue - 1, wantFullName, true);
                     ret.Nodes.Add(t);
                 }
             }
     return ret;
 }
示例#13
0
        public byte[] ToArray(int pccExportDataOffset, PCCObject pcc)
        {
            MemoryStream buffer = new MemoryStream();
            buffer.Write(headerData, 0, headerData.Length);

            if (properties.ContainsKey("LODGroup"))
            {
                properties["LODGroup"].Value.StringValue = "TEXTUREGROUP_LightAndShadowMap";
                properties["LODGroup"].Value.String2 = pcc.Names[0];
            }
            else
            {
                buffer.WriteValueS64(pcc.AddName("LODGroup"));
                buffer.WriteValueS64(pcc.AddName("ByteProperty"));
                buffer.WriteValueS64(8);
                buffer.WriteValueS64(pcc.AddName("TEXTUREGROUP_LightAndShadowMap"));
            }

            foreach (KeyValuePair<string, SaltPropertyReader.Property> kvp in properties)
            {
                SaltPropertyReader.Property prop = kvp.Value;

                if (prop.Name == "UnpackMin")
                {
                    for (int j = 0; j < UnpackNum; j++)
                    {
                        buffer.WriteValueS64(pcc.AddName(prop.Name));
                        buffer.WriteValueS64(pcc.AddName(prop.TypeVal.ToString()));
                        buffer.WriteValueS32(prop.Size);
                        buffer.WriteValueS32(j);
                        buffer.WriteValueF32(prop.Value.FloatValue, Endian.Little);
                    }
                    continue;
                }

                buffer.WriteValueS64(pcc.AddName(prop.Name));
                if (prop.Name == "None")
                {
                    for (int j = 0; j < 12; j++)
                        buffer.WriteByte(0);
                }
                else
                {
                    buffer.WriteValueS64(pcc.AddName(prop.TypeVal.ToString()));
                    buffer.WriteValueS64(prop.Size);

                    switch (prop.TypeVal)
                    {
                        case SaltPropertyReader.Type.IntProperty:
                            buffer.WriteValueS32(prop.Value.IntValue);
                            break;
                        case SaltPropertyReader.Type.BoolProperty:
                            buffer.WriteValueS32(prop.Value.IntValue);
                            break;
                        case SaltPropertyReader.Type.NameProperty:
                            buffer.WriteValueS64(pcc.AddName(prop.Value.StringValue));
                            break;
                        case SaltPropertyReader.Type.StrProperty:
                            buffer.WriteValueS32(prop.Value.StringValue.Length + 1);
                            foreach (char c in prop.Value.StringValue)
                                buffer.WriteByte((byte)c);
                            buffer.WriteByte(0);
                            break;
                        case SaltPropertyReader.Type.StructProperty:
                            buffer.WriteValueS64(pcc.AddName(prop.Value.StringValue));
                            foreach (SaltPropertyReader.PropertyValue value in prop.Value.Array)
                                buffer.WriteValueS32(value.IntValue);
                            break;
                        case SaltPropertyReader.Type.ByteProperty:
                            buffer.WriteValueS32(pcc.AddName(prop.Value.StringValue));
                            buffer.WriteValueS32(pcc.AddName(prop.Value.String2));
                            break;
                        case SaltPropertyReader.Type.FloatProperty:
                            buffer.WriteValueF32(prop.Value.FloatValue, Endian.Little);
                            break;
                        default:
                            throw new FormatException("unknown property");
                    }
                }
            }

            buffer.WriteValueS32((int)buffer.Position + pccExportDataOffset);

            //Remove empty textures
            List<ImageInfo> tempList = new List<ImageInfo>();
            foreach (ImageInfo imgInfo in imgList)
            {
                if (imgInfo.storageType != storage.empty)
                    tempList.Add(imgInfo);
            }
            imgList = tempList;
            numMipMaps = (uint)imgList.Count;

            buffer.WriteValueU32(numMipMaps);
            foreach (ImageInfo imgInfo in imgList)
            {
                buffer.WriteValueS32((int)imgInfo.storageType);
                buffer.WriteValueS32(imgInfo.uncSize);
                buffer.WriteValueS32(imgInfo.cprSize);
                if (imgInfo.storageType == storage.pccSto)
                {
                    buffer.WriteValueS32((int)(buffer.Position + pccExportDataOffset));
                    buffer.Write(imageData, imgInfo.offset, imgInfo.uncSize);
                }
                else
                    buffer.WriteValueS32(imgInfo.offset);
                if (imgInfo.imgSize.width < 4)
                    buffer.WriteValueU32(4);
                else
                    buffer.WriteValueU32(imgInfo.imgSize.width);
                if (imgInfo.imgSize.height < 4)
                    buffer.WriteValueU32(4);
                else
                    buffer.WriteValueU32(imgInfo.imgSize.height);
            }
            buffer.WriteBytes(footerData);
            return buffer.ToArray();
        }
示例#14
0
        public Texture2D(PCCObject pcc, int pccExpID, String pathBioGame)
        {
            PCCObject.ExportEntry exp = pcc.Exports[pccExpID]; ;
            if (String.Compare(exp.ClassName, className) != 0 && String.Compare(exp.ClassName, class2) != 0 && String.Compare(exp.ClassName, class3) != 0)
            {
                throw new FormatException("Export is not a texture");
            }
            Class = exp.ClassName;
            exportOffset = exp.DataOffset;
            FullPackage = exp.PackageFullName;
            texName = exp.ObjectName;
            pccFileName = pcc.pccFileName;
            allPccs = new List<string>();
            allPccs.Add(pcc.pccFileName);
            properties = new Dictionary<string, SaltPropertyReader.Property>();
            byte[] rawData = (byte[])exp.Data.Clone();
            Compression = "No Compression";
            int propertiesOffset = SaltPropertyReader.detectStart(pcc, rawData);
            headerData = new byte[propertiesOffset];
            Buffer.BlockCopy(rawData, 0, headerData, 0, propertiesOffset);
            pccOffset = (uint)exp.DataOffset;
            UnpackNum = 0;
            List<SaltPropertyReader.Property> tempProperties = SaltPropertyReader.getPropList(pcc, rawData);
            for (int i = 0; i < tempProperties.Count; i++)
            {
                SaltPropertyReader.Property property = tempProperties[i];
                if (property.Name == "UnpackMin")
                    UnpackNum++;

                if (!properties.ContainsKey(property.Name))
                    properties.Add(property.Name, property);

                switch (property.Name)
                {
                    case "Format": texFormat = property.Value.StringValue; break;
                    case "TextureFileCacheName": arcName = property.Value.StringValue; break;
                    case "LODGroup": LODGroup = property.Value.StringValue; break;
                    case "CompressionSettings": Compression = property.Value.StringValue; break;
                    case "None": dataOffset = (uint)(property.offsetval + property.Size); break;
                }
            }
            // if "None" property isn't found throws an exception
            if (dataOffset == 0)
                throw new Exception("\"None\" property not found");

            if (!String.IsNullOrEmpty(arcName))
                FullArcPath = GetTexArchive(pathBioGame);

            imageData = new byte[rawData.Length - dataOffset];
            Buffer.BlockCopy(rawData, (int)dataOffset, imageData, 0, (int)(rawData.Length - dataOffset));

            //DebugOutput.PrintLn("ImageData size = " + imageData.Length);
            pccExpIdx = pccExpID;

            MemoryStream dataStream = new MemoryStream(imageData);
            imgList = new List<ImageInfo>();
            dataStream.ReadValueU32(); //Current position in pcc
            numMipMaps = dataStream.ReadValueU32();
            uint count = numMipMaps;
            ArcDataSize = 0;
            //DebugOutput.PrintLn(numMipMaps + " derp");
            while (dataStream.Position < dataStream.Length && count > 0)
            {
                ImageInfo imgInfo = new ImageInfo();
                imgInfo.storageType = (storage)dataStream.ReadValueS32();
                imgInfo.uncSize = dataStream.ReadValueS32();
                imgInfo.cprSize = dataStream.ReadValueS32();
                imgInfo.offset = dataStream.ReadValueS32();
                if (imgInfo.storageType == storage.pccSto)
                {
                    imgInfo.offset = (int)dataStream.Position;
                    dataStream.Seek(imgInfo.uncSize, SeekOrigin.Current);
                }
                else if (imgInfo.storageType == storage.arcCpr || imgInfo.storageType == storage.arcUnc)
                {
                    ArcDataSize += imgInfo.uncSize;
                }

                imgInfo.imgSize = new ImageSize(dataStream.ReadValueU32(), dataStream.ReadValueU32());
                if (imgList.Exists(img => img.imgSize == imgInfo.imgSize))
                {
                    uint width = imgInfo.imgSize.width;
                    uint height = imgInfo.imgSize.height;
                    if (width == 4 && imgList.Exists(img => img.imgSize.width == width))
                        width = imgList.Last().imgSize.width / 2;
                    if (width == 0)
                        width = 1;
                    if (height == 4 && imgList.Exists(img => img.imgSize.height == height))
                        height = imgList.Last().imgSize.height / 2;
                    if (height == 0)
                        height = 1;
                    imgInfo.imgSize = new ImageSize(width, height);
                    if (imgList.Exists(img => img.imgSize == imgInfo.imgSize))
                        throw new Exception("Duplicate image size found");
                }
                imgList.Add(imgInfo);
                count--;
                //DebugOutput.PrintLn("ImgInfo no: " + count + ", Storage Type = " + imgInfo.storageType + ", offset = " + imgInfo.offset);
            }
            // Grab the rest for the footer
            footerData = new byte[dataStream.Length - dataStream.Position];
            footerData = dataStream.ReadBytes(footerData.Length);
        }
示例#15
0
 public SBox(int idx, float x, float y, PCCObject p)
     : base(idx, x, y, p)
 {
 }
示例#16
0
 public SBox(int idx, float x, float y, PCCObject p, GraphEditor grapheditor)
     : base(idx, x, y, p, grapheditor)
 {
 }
示例#17
0
 public SVar(int idx, float x, float y, PCCObject p, GraphEditor grapheditor)
     : base(idx, x, y, p, grapheditor)
 {
     string s = pcc.Exports[index].ObjectName;
     s = s.Replace("BioSeqVar_", "");
     s = s.Replace("SFXSeqVar_", "");
     s = s.Replace("SeqVar_", "");
     type = getType(s);
     float w = 60;
     float h = 60;
     shape = PPath.CreateEllipse(0, 0, w, h);
     outlinePen = new Pen(getColor(type));
     shape.Pen = outlinePen;
     shape.Brush = nodeBrush;
     shape.Pickable = false;
     this.AddChild(shape);
     this.Bounds = new RectangleF(0, 0, w, h);
     val = new SText(GetValue());
     val.Pickable = false;
     val.TextAlignment = StringAlignment.Center;
     val.X = w / 2 - val.Width / 2;
     val.Y = h / 2 - val.Height / 2;
     this.AddChild(val);
     List<SaltPropertyReader.Property> props = SaltPropertyReader.getPropList(pcc, pcc.Exports[index].Data);
     foreach (SaltPropertyReader.Property prop in props)
     {
         if (prop.Name == "VarName" || prop.Name == "varName")
         {
             SText VarName = new SText(prop.Value.StringValue, Color.Red, false);
             VarName.Pickable = false;
             VarName.TextAlignment = StringAlignment.Center;
             VarName.X = w / 2 - VarName.Width / 2;
             VarName.Y = h;
             this.AddChild(VarName);
             break;
         }
     }
     this.TranslateBy(x, y);
     this.MouseEnter += new PInputEventHandler(OnMouseEnter);
     this.MouseLeave += new PInputEventHandler(OnMouseLeave);
 }
示例#18
0
 public void ChangeTexFormat(string newFormat, PCCObject pcc)
 {
     SaltPropertyReader.Property prop = properties["Format"];
     Int64 formatID = (Int64)pcc.AddName(newFormat);
     byte[] buff = BitConverter.GetBytes(formatID);
     Buffer.BlockCopy(buff, 0, prop.raw, 24, sizeof(Int64));
     prop.Value.StringValue = pcc.Names[(int)formatID];
     properties["Format"] = prop;
     texFormat = properties["Format"].Value.StringValue;
 }
示例#19
0
        public void CopyImgList(Texture2D inTex, PCCObject pcc)
        {
            numMipMaps = inTex.numMipMaps;

            if (properties.ContainsKey("NeverStream") && properties["NeverStream"].Value.IntValue == 1)
            {
                imageData = null;
                GC.Collect();
                // store images as pccSto format
                imgList = new List<ImageInfo>();
                MemoryStream tempData = new MemoryStream();

                for (int i = 0; i < inTex.imgList.Count; i++)
                {
                    ImageInfo newImg = new ImageInfo();
                    ImageInfo replaceImg = inTex.imgList[i];
                    newImg.storageType = storage.pccSto;
                    newImg.uncSize = replaceImg.uncSize;
                    newImg.cprSize = replaceImg.uncSize;
                    newImg.imgSize = replaceImg.imgSize;
                    newImg.offset = (int)(tempData.Position);
                    if (replaceImg.storageType == storage.arcCpr)
                    {
                        string archivePath = inTex.FullArcPath;
                        if (!File.Exists(archivePath))
                            throw new FileNotFoundException("Texture archive not found in " + archivePath);

                        using (FileStream archiveStream = File.OpenRead(archivePath))
                        {
                            archiveStream.Seek(replaceImg.offset, SeekOrigin.Begin);
                            SaltLZOHelper lzohelp = new SaltLZOHelper();
                            tempData.WriteBytes(lzohelp.DecompressTex(archiveStream, replaceImg.offset, replaceImg.uncSize, replaceImg.cprSize));
                        }
                    }
                    else if (replaceImg.storageType == storage.pccSto)
                    {
                        byte[] buffer = new byte[newImg.cprSize];
                        Buffer.BlockCopy(inTex.imageData, replaceImg.offset, buffer, 0, buffer.Length);
                        tempData.WriteBytes(buffer);
                    }
                    else
                        throw new NotImplementedException("Copying from non package stored texture no available");
                    imgList.Add(newImg);
                }

                for (int i = 0; i < imgList.Count; i++)
                {
                    ImageInfo tempinfo = imgList[i];
                    if (inTex.imgList[i].storageType == storage.empty)
                        tempinfo.storageType = storage.empty;
                    imgList[i] = tempinfo;
                }

                imageData = tempData.ToArray();
                tempData.Close();
                tempData = null;
                GC.Collect();
            }
            else
            {
                imageData = inTex.imageData;
                imgList = inTex.imgList;
            }

            // add properties "TextureFileCacheName" and "TFCFileGuid" if they are missing,
            if (!properties.ContainsKey("TextureFileCacheName") && inTex.properties.ContainsKey("TextureFileCacheName"))
            {
                SaltPropertyReader.Property none = properties["None"];
                properties.Remove("None");

                SaltPropertyReader.Property property = new SaltPropertyReader.Property();
                property.TypeVal = SaltPropertyReader.Type.NameProperty;
                property.Name = "TextureFileCacheName";
                property.Size = 8;
                SaltPropertyReader.PropertyValue value = new SaltPropertyReader.PropertyValue();
                value.StringValue = "Textures";
                property.Value = value;
                properties.Add("TextureFileCacheName", property);
                arcName = value.StringValue;

                if (!properties.ContainsKey("TFCFileGuid"))
                {
                    SaltPropertyReader.Property guidprop = new SaltPropertyReader.Property();
                    guidprop.TypeVal = SaltPropertyReader.Type.StructProperty;
                    guidprop.Name = "TFCFileGuid";
                    guidprop.Size = 16;
                    SaltPropertyReader.PropertyValue guid = new SaltPropertyReader.PropertyValue();
                    guid.len = guidprop.Size;
                    guid.StringValue = "Guid";
                    guid.IntValue = pcc.AddName(guid.StringValue);
                    guid.Array = new List<SaltPropertyReader.PropertyValue>();
                    for (int i = 0; i < 4; i++)
                        guid.Array.Add(new SaltPropertyReader.PropertyValue());
                    guidprop.Value = guid;
                    properties.Add("TFCFileGuid", guidprop);
                }

                properties.Add("None", none);
            }

            // copy specific properties from inTex
            for (int i = 0; i < inTex.properties.Count; i++)
            {
                SaltPropertyReader.Property prop = inTex.properties.ElementAt(i).Value;
                switch (prop.Name)
                {
                    case "TextureFileCacheName":
                        arcName = prop.Value.StringValue;
                        properties["TextureFileCacheName"].Value.StringValue = arcName;
                        break;
                    case "TFCFileGuid":
                        SaltPropertyReader.Property GUIDProp = properties["TFCFileGuid"];
                        for (int l = 0; l < 4; l++)
                        {
                            SaltPropertyReader.PropertyValue tempVal = GUIDProp.Value.Array[l];
                            tempVal.IntValue = prop.Value.Array[l].IntValue;
                            GUIDProp.Value.Array[l] = tempVal;
                        }
                        break;
                    case "MipTailBaseIdx":
                        properties["MipTailBaseIdx"].Value.IntValue = prop.Value.IntValue;
                        break;
                    case "SizeX":
                        properties["SizeX"].Value.IntValue = prop.Value.IntValue;
                        break;
                    case "SizeY":
                        properties["SizeY"].Value.IntValue = prop.Value.IntValue;
                        break;
                }
            }
        }
示例#20
0
        public void ChangeCompression(string newComp, PCCObject pcc)
        {
            if (!properties.ContainsKey("CompressionSettings"))
            {
                throw new KeyNotFoundException("Texture doesn't have a compression property");
            }
            SaltPropertyReader.Property prop = properties["CompressionSettings"];
            Int64 comp = (Int64)pcc.AddName(newComp);
            byte[] buff = BitConverter.GetBytes(comp);
            Buffer.BlockCopy(buff, 0, prop.raw, 24, sizeof(Int64));
            prop.Value.StringValue = pcc.Names[(int)comp];
            properties["CompressionSettings"] = prop;
            Compression = properties["CompressionSettings"].Value.StringValue;

        }
示例#21
0
        public MemoryTributary DecompressPCC(Stream raw, PCCObject pcc)
        {
            raw.Seek(pcc.header.Length, SeekOrigin.Begin);
            int pos = 4;
            pcc.NumChunks = raw.ReadValueS32();
            List<Chunk> Chunks = new List<Chunk>();

            //DebugOutput.PrintLn("Reading chunk headers...");
            for (int i = 0; i < pcc.NumChunks; i++)
            {
                Chunk c = new Chunk();
                c.uncompressedOffset = raw.ReadValueS32();
                c.uncompressedSize = raw.ReadValueS32();
                c.compressedOffset = raw.ReadValueS32();
                c.compressedSize = raw.ReadValueS32();
                c.Compressed = new byte[c.compressedSize];
                c.Uncompressed = new byte[c.uncompressedSize];
                //DebugOutput.PrintLn("Chunk " + i + ", compressed size = " + c.compressedSize + ", uncompressed size = " + c.uncompressedSize);
                //DebugOutput.PrintLn("Compressed offset = " + c.compressedOffset + ", uncompressed offset = " + c.uncompressedOffset);
                Chunks.Add(c);
            }

            //DebugOutput.PrintLn("\tRead Chunks...");
            int count = 0;
            for (int i = 0; i < Chunks.Count; i++)
            {
                Chunk c = Chunks[i];
                raw.Seek(c.compressedOffset, SeekOrigin.Begin);
                c.Compressed = raw.ReadBytes(c.compressedSize);

                ChunkHeader h = new ChunkHeader();
                h.magic = BitConverter.ToInt32(c.Compressed, 0);
                if (h.magic != -1641380927)
                    throw new FormatException("Chunk magic number incorrect");
                h.blocksize = BitConverter.ToInt32(c.Compressed, 4);
                h.compressedsize = BitConverter.ToInt32(c.Compressed, 8);
                h.uncompressedsize = BitConverter.ToInt32(c.Compressed, 12);
                //DebugOutput.PrintLn("Chunkheader read: Magic = " + h.magic + ", Blocksize = " + h.blocksize + ", Compressed Size = " + h.compressedsize + ", Uncompressed size = " + h.uncompressedsize);
                pos = 16;
                int blockCount = (h.uncompressedsize % h.blocksize == 0)
                    ?
                    h.uncompressedsize / h.blocksize
                    :
                    h.uncompressedsize / h.blocksize + 1;
                List<Block> BlockList = new List<Block>();
                //DebugOutput.PrintLn("\t\t" + count + " Read Blockheaders...");
                for (int j = 0; j < blockCount; j++)
                {
                    Block b = new Block();
                    b.compressedsize = BitConverter.ToInt32(c.Compressed, pos);
                    b.uncompressedsize = BitConverter.ToInt32(c.Compressed, pos + 4);
                    //DebugOutput.PrintLn("Block " + j + ", compressed size = " + b.compressedsize + ", uncompressed size = " + b.uncompressedsize);
                    pos += 8;
                    BlockList.Add(b);
                }
                int outpos = 0;
                //DebugOutput.PrintLn("\t\t" + count + " Read and decompress Blocks...");
                foreach (Block b in BlockList)
                {
                    byte[] datain = new byte[b.compressedsize];
                    byte[] dataout = new byte[b.uncompressedsize];
                    for (int j = 0; j < b.compressedsize; j++)
                        datain[j] = c.Compressed[pos + j];
                    pos += b.compressedsize;

                    try
                    {
                        LZO1X.Decompress(datain, dataout);
                    }
                    catch
                    {
                        throw new Exception("LZO decompression failed!");
                    }
                    for (int j = 0; j < b.uncompressedsize; j++)
                        c.Uncompressed[outpos + j] = dataout[j];
                    outpos += b.uncompressedsize;
                }
                c.header = h;
                c.blocks = BlockList;
                count++;
                Chunks[i] = c;
            }

            MemoryTributary result = new MemoryTributary();
            foreach (Chunk c in Chunks)
            {
                result.Seek(c.uncompressedOffset, SeekOrigin.Begin);
                result.WriteBytes(c.Uncompressed);
            }
            
            return result;
        }
示例#22
0
 public SEvent(int idx, float x, float y, PCCObject p, GraphEditor grapheditor)
     : base(idx, x, y, p, grapheditor)
 {
     outlinePen = new Pen(Color.FromArgb(214, 30, 28));
     string s = pcc.Exports[index].ObjectName;
     s = s.Replace("BioSeqEvt_", "");
     s = s.Replace("SFXSeqEvt_", "");
     s = s.Replace("SeqEvt_", "");
     s = s.Replace("SeqEvent_", "");
     float starty = 0;
     float w = 15;
     float midW = 0;
     varLinkBox = new PPath();
     GetVarLinks();
     for (int i = 0; i < Varlinks.Count; i++)
     {
         string d = "";
         foreach (int l in Varlinks[i].Links)
             d = d + "#" + l + ",";
         d = d.Remove(d.Length - 1);
         SText t2 = new SText( d + "\n" + Varlinks[i].Desc);
         t2.X = w;
         t2.Y = 0;
         w += t2.Width + 20;
         t2.Pickable = false;
         Varlinks[i].node.TranslateBy(t2.X + t2.Width / 2, t2.Y + t2.Height);
         t2.AddChild(Varlinks[i].node);
         varLinkBox.AddChild(t2);
     }
     if(Varlinks.Count != 0)
         varLinkBox.AddRectangle(0, 0, w, varLinkBox[0].Height);
     varLinkBox.Pickable = false;
     varLinkBox.Pen = outlinePen;
     varLinkBox.Brush = nodeBrush;
     GetOutputLinks();
     outLinkBox = new PPath();
     for (int i = 0; i < Outlinks.Count(); i++)
     {
         SText t2 = new SText(Outlinks[i].Desc);
         if(t2.Width + 10 > midW) midW = t2.Width + 10;
         //t2.TextAlignment = StringAlignment.Far;
         //t2.ConstrainWidthToTextWidth = false;
         t2.X = 0 - t2.Width;
         t2.Y = starty + 3;
         starty += t2.Height + 6;
         t2.Pickable = false;
         Outlinks[i].node.TranslateBy(0, t2.Y + t2.Height / 2);
         t2.AddChild(Outlinks[i].node);
         outLinkBox.AddChild(t2);
     }
     outLinkBox.AddPolygon(new PointF[] { new PointF(0, 0), new PointF(0, starty), new PointF(-0.5f*midW, starty+30), new PointF(0 - midW, starty), new PointF(0 - midW, 0), new PointF(midW/-2, -30) });
     outLinkBox.Pickable = false;
     outLinkBox.Pen = outlinePen;
     outLinkBox.Brush = nodeBrush;
     List<SaltPropertyReader.Property> props = SaltPropertyReader.getPropList(pcc, pcc.Exports[index].Data);
     foreach (SaltPropertyReader.Property prop in props)
     {
         if (prop.Name.Contains("EventName") || prop.Name == "sScriptName")
             s += "\n\"" + prop.Value.IntValue + "\"";
         else if (prop.Name == "InputLabel" || prop.Name == "sEvent")
             s += "\n\"" + prop.Value.StringValue + "\"";
     }
     float tW = GetTitleBox(s, w);
     if (tW > w)
     {
         if (midW > tW)
         {
             w = midW;
             titleBox.Width = w;
         }
         else
         {
             w = tW;
         }
         varLinkBox.Width = w;
     }
     float h = titleBox.Height + 1;
     outLinkBox.TranslateBy(titleBox.Width/2 + midW/2, h + 30);
     h += outLinkBox.Height + 1;
     varLinkBox.TranslateBy(0, h);
     h += varLinkBox.Height;
     this.bounds = new RectangleF(0, 0, w, h);
     this.AddChild(titleBox);
     this.AddChild(varLinkBox);
     this.AddChild(outLinkBox);
     this.TranslateBy(x, y);
 }