Inheritance: MEPackage, IMEPackage
Example #1
0
        public static string ToRawText(byte[] raw, ME1Package Pcc, bool debug)
        {
            string s = "";
            pcc = Pcc;
            memory = raw;
            memsize = raw.Length;
            DebugCounter = 0;
            _debug = new List<DbgMsg>();
            List<Token> t = ReadAll(0);
            int pos = 32;
            for (int i = 0; i < t.Count; i++)
            {
                s += pos.ToString("X2") + " : " + t[i].text + "\n";
                pos += t[i].raw.Length;
            }
            if (debug)
            {
                s += "\nDebug print:\n\n";
                SortDbgMsg();
                for (int i = 0; i < _debug.Count(); i++)
                    s += _debug[i].count + " : " + _debug[i].msg;
            }
            return s;

        }
Example #2
0
        public ME1ExportEntry(ME1Package pccFile, Stream stream) : base(pccFile)
        {
            //determine header length
            long start = stream.Position;

            stream.Seek(40, SeekOrigin.Current);
            int count = stream.ReadValueS32();

            stream.Seek(4 + count * 12, SeekOrigin.Current);
            count = stream.ReadValueS32();
            stream.Seek(16, SeekOrigin.Current);
            stream.Seek(4 + count * 4, SeekOrigin.Current);
            long end = stream.Position;

            stream.Seek(start, SeekOrigin.Begin);

            //read header
            Header           = stream.ReadBytes((int)(end - start));
            headerOffset     = (uint)start;
            OriginalDataSize = DataSize;

            //read data
            stream.Seek(DataOffset, SeekOrigin.Begin);
            _data = stream.ReadBytes(DataSize);
            stream.Seek(end, SeekOrigin.Begin);
            if (ClassName.Contains("Property"))
            {
                ReadsFromConfig = Data.Length > 25 && (Data[25] & 64) != 0;
            }
            else
            {
                ReadsFromConfig = false;
            }
        }
Example #3
0
        public void InitTlkManager(ME1Package pcc, BioTlkFileSet tlkSet, TalkFiles tlks = null)
        {
            packages = new List<ME1Package>();
            tlkFileSets = new List<BioTlkFileSet>();
            selectedTlks = tlks ?? new TalkFiles();

            packages.Add(pcc);
            refreshFileBox();
            fileBox.SelectedIndex = 0;
            Application.DoEvents();
            for (int i = 0; i < tlkFileSets.Count; i++)
            {
                if (tlkFileSets[i].index == tlkSet.index)
                {
                    bioTlkSetBox.SelectedIndex = i;
                    Application.DoEvents();
                    tlkFileBox.SelectedIndex = tlkSet.selectedTLK;
                    break;
                }
            }
            TalkFile tlk = tlkSet.talkFiles[tlkSet.selectedTLK];
            if (!selectedTlks.tlkList.Contains(tlk))
            {
                selectedTlks.tlkList.Add(tlk);
            }
            foreach (TalkFile tlkFile in selectedTlks.tlkList)
            {
                selectedTlkFilesBox.Items.Add(Path.GetFileName(pcc.FileName) + " -> " + tlkFile.BioTlkSetName + tlkFile.Name); 
            }
        }
Example #4
0
 public static void Initialize()
 {
     UDKConstructorDelegate = UDKPackage.Initialize();
     ME1ConstructorDelegate = ME1Package.Initialize();
     ME2ConstructorDelegate = ME2Package.Initialize();
     ME3ConstructorDelegate = ME3Package.Initialize();
 }
Example #5
0
 public Function(byte[] raw, ME1Package Pcc)
 {
     pcc = Pcc;
     memory = raw;
     memsize = raw.Length;
     flagint = GetFlagInt();
     nativeindex = GetNatIdx();
     Deserialize();
 }
Example #6
0
        public static ME1Package OpenME1Package(string pathToFile, WPFBase wpfWindow = null, WinFormsBase winForm = null)
        {
            IMEPackage pck = OpenMEPackage(pathToFile, wpfWindow, winForm);
            ME1Package pcc = pck as ME1Package;

            if (pcc == null)
            {
                pck.Release(wpfWindow, winForm);
                throw new FormatException("Not an ME1 package file.");
            }
            return(pcc);
        }
 public TreeNode ToTree(int MyIndex, ITalkFile talk, ME1Package pcc)
 {
     string s = "";
     if (Text.Length != 0)
         s = Text.Substring(0, Text.Length - 1);
     TreeNode res = new TreeNode(MyIndex + " : " + s + "  " + talk.findDataById(refText));
     TreeNode t = new TreeNode("Reply List");
     for (int i = 0; i < ReplyList.Count; i++)
     {
         EntryListReplyListStruct e = ReplyList[i];
         string par = e.Paraphrase;
         if (par.Length != 0 && par[par.Length - 1] == '\0')
             par = par.Substring(0, par.Length - 1);
         t.Nodes.Add(i + " : " 
                       + par
                       + " " 
                       + e.refParaphrase 
                       + " " 
                       + talk.findDataById(e.refParaphrase) 
                       + " " 
                       + e.Index
                       + " " 
                       + pcc.getNameEntry(e.CategoryValue));
     }
     res.Nodes.Add(t);
     TreeNode t2 = new TreeNode("Speaker List");
     for (int i = 0; i < SpeakerList.Count; i++)
         t2.Nodes.Add(i + " : " + SpeakerList[i]);
     res.Nodes.Add(t2);
     res.Nodes.Add("SpeakerIndex : " + SpeakerIndex);
     res.Nodes.Add("ListenerIndex : " + ListenerIndex);
     res.Nodes.Add("ConditionalFunc : " + ConditionalFunc);
     res.Nodes.Add("ConditionalParam : " + ConditionalParam);
     res.Nodes.Add("StateTransition : " + StateTransition);
     res.Nodes.Add("StateTransitionParam : " + StateTransitionParam);
     res.Nodes.Add("ExportID : " + ExportID);
     res.Nodes.Add("ScriptIndex : " + ScriptIndex);
     res.Nodes.Add("CameraIntimacy : " + CameraIntimacy);
     res.Nodes.Add("Skippable : " + Skippable);
     res.Nodes.Add("FireConditional : " + FireConditional);
     res.Nodes.Add("Ambient : " + Ambient);
     res.Nodes.Add("NonTextline : " + NonTextline);
     res.Nodes.Add("IgnoreBodyGestures : " + IgnoreBodyGestures);
     res.Nodes.Add("Text : " + Text);
     res.Nodes.Add("refText : " + refText + " " + talk.findDataById(refText, true));
     res.Nodes.Add("GUIStyle : " + pcc.getNameEntry(GUIStyleValue));
     return res;
 }
Example #8
0
 public BioTlkFileSet(ME1Package _pcc)
 {
     pcc = _pcc;
     index = -1;
     IReadOnlyList<IExportEntry> Exports = pcc.Exports;
     for (int i = 0; i < Exports.Count; i++)
     {
         if (Exports[i].ClassName == "BioTlkFileSet")
         {
             index = i;
         }
     }
     if (index != -1)
     {
         loadData(index);
     }
     else
     {
         talkFiles = new List<TalkFile>();
     }
 }
        private static PropertyInfo getProperty(ME1Package pcc, IExportEntry entry)
        {
            PropertyInfo p = new PropertyInfo();
            switch (entry.ClassName)
            {
                case "IntProperty":
                    p.type = PropertyType.IntProperty;
                    break;
                case "StringRefProperty":
                    p.type = PropertyType.StringRefProperty;
                    break;
                case "FloatProperty":
                    p.type = PropertyType.FloatProperty;
                    break;
                case "BoolProperty":
                    p.type = PropertyType.BoolProperty;
                    break;
                case "StrProperty":
                    p.type = PropertyType.StrProperty;
                    break;
                case "NameProperty":
                    p.type = PropertyType.NameProperty;
                    break;
                case "DelegateProperty":
                    p.type = PropertyType.DelegateProperty;
                    break;
                case "ObjectProperty":
                    p.type = PropertyType.ObjectProperty;
                    p.reference = pcc.getObjectName(BitConverter.ToInt32(entry.Data, entry.Data.Length - 4));
                    break;
                case "StructProperty":
                    p.type = PropertyType.StructProperty;
                    p.reference = pcc.getObjectName(BitConverter.ToInt32(entry.Data, entry.Data.Length - 4));
                    break;
                case "BioMask4Property":
                case "ByteProperty":
                    p.type = PropertyType.ByteProperty;
                    p.reference = pcc.getObjectName(BitConverter.ToInt32(entry.Data, entry.Data.Length - 4));
                    break;
                case "ArrayProperty":
                    p.type = PropertyType.ArrayProperty;
                    PropertyInfo arrayTypeProp = getProperty(pcc, pcc.Exports[BitConverter.ToInt32(entry.Data, 44) - 1]);
                    if (arrayTypeProp != null)
                    {
                        switch (arrayTypeProp.type)
                        {
                            case PropertyType.ObjectProperty:
                            case PropertyType.StructProperty:
                            case PropertyType.ArrayProperty:
                                p.reference = arrayTypeProp.reference;
                                break;
                            case PropertyType.ByteProperty:
                                if (arrayTypeProp.reference == "")
                                    p.reference = arrayTypeProp.type.ToString();
                                else
                                    p.reference = arrayTypeProp.reference;
                                break;
                            case PropertyType.IntProperty:
                            case PropertyType.FloatProperty:
                            case PropertyType.NameProperty:
                            case PropertyType.BoolProperty:
                            case PropertyType.StrProperty:
                            case PropertyType.StringRefProperty:
                            case PropertyType.DelegateProperty:
                                p.reference = arrayTypeProp.type.ToString();
                                break;
                            case PropertyType.None:
                            case PropertyType.Unknown:
                            default:
                                System.Diagnostics.Debugger.Break();
                                p = null;
                                break;
                        }
                    }
                    else
                    {
                        p = null;
                    }
                    break;
                case "ClassProperty":
                case "InterfaceProperty":
                case "ComponentProperty":
                default:
                    p = null;
                    break;
            }

            return p;
        } 
 private static ClassInfo generateClassInfo(int index, ME1Package pcc)
 {
     ClassInfo info = new ClassInfo();
     IReadOnlyList<IExportEntry> Exports = pcc.Exports;
     info.baseClass = Exports[index].ClassParent;
     foreach (IExportEntry entry in Exports)
     {
         if (entry.idxLink - 1 == index && entry.ClassName != "ScriptStruct" && entry.ClassName != "Enum"
             && entry.ClassName != "Function" && entry.ClassName != "Const" && entry.ClassName != "State")
         {
             //Skip if property is transient (only used during execution, will never be in game files)
             if ((BitConverter.ToUInt64(entry.Data, 24) & 0x0000000000002000) == 0 && !info.properties.ContainsKey(entry.ObjectName))
             {
                 PropertyInfo p = getProperty(pcc, entry);
                 if (p != null)
                 {
                     info.properties.Add(entry.ObjectName, p);
                 }
             }
         }
     }
     return info;
 }
 public TreeNode ToTree(int MyIndex, ITalkFile talk, ME1Package pcc)
 {
     string s = "";
     if (Text.Length != 0)
         s = Text.Substring(0, Text.Length - 1);
     TreeNode res = new TreeNode(MyIndex + " : " + s + "  " + talk.findDataById(refText));
     TreeNode t = new TreeNode("Entry List");
     for (int i = 0; i < EntryList.Count; i++)
         t.Nodes.Add(i + " : " + EntryList[i]);
     res.Nodes.Add(t);
     res.Nodes.Add("Listener Index : " + ListenerIndex);
     res.Nodes.Add("Unskippable : " + Unskippable);
     res.Nodes.Add("ReplyType : " + pcc.getNameEntry(ReplyTypeValue));
     res.Nodes.Add("Text : " + Text);
     res.Nodes.Add("refText : " + refText + " " + talk.findDataById(refText, true));
     res.Nodes.Add("ConditionalFunc : " + ConditionalFunc);
     res.Nodes.Add("ConditionalParam : " + ConditionalParam);
     res.Nodes.Add("StateTransition : " + StateTransition);
     res.Nodes.Add("StateTransitionParam : " + StateTransitionParam);
     res.Nodes.Add("ExportID : " + ExportID);
     res.Nodes.Add("ScriptIndex : " + ScriptIndex);
     res.Nodes.Add("CameraIntimacy : " + CameraIntimacy);
     res.Nodes.Add("FireConditional : " + FireConditional);
     res.Nodes.Add("Ambient : " + Ambient);
     res.Nodes.Add("NonTextline : " + NonTextLine);
     res.Nodes.Add("IgnoreBodyGestures : " + IgnoreBodyGestures);
     res.Nodes.Add("GUIStyle : " + pcc.getNameEntry(GUIStyleValue));
     return res;
 }
Example #12
0
 public ME1ExportEntry(ME1Package file) : base(file)
 {
 }
 public ME1BioConversation(ME1Package Pcc, int Index)
 {
     pcc = Pcc;
     MyIndex = Index;
     Memory = pcc.Exports[Index].Data;
     ReadData();
 }
Example #14
0
 public ME1ExportEntry(ME1Package pccFile, byte[] headerData, uint exportOffset) :
     base(pccFile, headerData, exportOffset)
 {
 }
        public void replaceTlkwithFile(ME1Package pcc, int Index)
        {
            /* converts Huffmann Tree to binary form */
            byte[] treeBuffer = ConvertHuffmanTreeToBuffer();

            List<EncodedString> encodedStrings = new List<EncodedString>();
            int i = 0;
            foreach (var entry in _inputData)
            {
                if (entry.Flags == 0)
                {
                    if (entry.StringID > 0)
                        entry.index = -1;
                    else
                        entry.index = 0;
                }
                else
                {
                    entry.index = i;
                    i++;
                    List<BitArray> binaryData = new List<BitArray>();
                    int binaryLength = 0;
                    /* for every character in a string, put it's binary code into data array */
                    foreach (char c in entry.data)
                    {
                        binaryData.Add(_huffmanCodes[c]);
                        binaryLength += _huffmanCodes[c].Count;
                    }
                    byte[] buffer = BitArrayListToByteArray(binaryData, binaryLength);
                    encodedStrings.Add(new EncodedString(entry.data.Length, buffer.Length, buffer));
                }
            }

            /* get properties from object we're replacing*/
            byte[] properties = pcc.Exports[Index].Data.Take(40).ToArray();

            MemoryStream m = new MemoryStream();

            /* writing properties */
            m.Write(properties, 0, 40);
            m.Seek(0x1C, SeekOrigin.Begin);
            m.Write(BitConverter.GetBytes(_inputData.Count), 0, 4);
            m.Seek(0, SeekOrigin.End);

            /* writing entries */
            m.Write(BitConverter.GetBytes(_inputData.Count), 0, 4);
            foreach (TLKEntry entry in _inputData)
            {
                m.Write(BitConverter.GetBytes(entry.StringID), 0, 4);
                m.Write(BitConverter.GetBytes(entry.Flags), 0, 4);
                m.Write(BitConverter.GetBytes(entry.index), 0, 4);
            }

            /* writing HuffmanTree */
            m.Write(treeBuffer, 0, treeBuffer.Length);

            /* writing data */
            m.Write(BitConverter.GetBytes(encodedStrings.Count), 0, 4);
            foreach (EncodedString enc in encodedStrings)
            {
                m.Write(BitConverter.GetBytes(enc.stringLength), 0, 4);
                m.Write(BitConverter.GetBytes(enc.encodedLength), 0, 4);
                m.Write(enc.binaryData, 0, enc.encodedLength);
            }

            byte[] buff = m.ToArray();
            pcc.Exports[Index].Data = buff;
            pcc.save(pcc.FileName); 
        }
Example #16
0
 public BioTlkFileSet(ME1Package _pcc, int _index)
 {
     pcc = _pcc;
     index = _index;
     loadData();
 }
 private static void generateEnumValues(int index, ME1Package pcc)
 {
     string enumName = pcc.Exports[index].ObjectName;
     if (!Enums.ContainsKey(enumName))
     {
         List<string> values = new List<string>();
         byte[] buff = pcc.Exports[index].Data;
         int count = BitConverter.ToInt32(buff, 20);
         for (int i = 0; i < count; i++)
         {
             values.Add(pcc.Names[BitConverter.ToInt32(buff, 24 + i * 8)]);
         }
         Enums.Add(enumName, values);
     }
 }