Ejemplo n.º 1
0
        public string ParamListToString()
        {
            Uarray arr = (Uarray)((UClass)Parser.type.Members[4]).Members[0];

            UType[]       GenericMono = arr.Value;
            StringBuilder sb          = new StringBuilder();

            for (int i = 0; i < GenericMono.Length; i++)
            {
                UClass vectorList = (UClass)GenericMono[i].Members[0];
                arr = (Uarray)vectorList.Members[0];
                UType[] Strings = arr.Value;
                for (int j = 0; j < Strings.Length; j++)
                {
                    sb.Append("<");
                    int    wordStart = sb.Length;
                    string word      = ((UClass)Strings[j]).GetString();
                    sb.Append(word);
                    sb.Replace("\\", "\\\\", wordStart, sb.Length - wordStart);
                    sb.Replace("<", "\\<", wordStart, sb.Length - wordStart);
                    sb.Replace(">", "\\>", wordStart, sb.Length - wordStart);
                    sb.Append(">");
                }
                sb.Append("\r\n");
            }
            return(sb.ToString());
        }
Ejemplo n.º 2
0
 void CustomDispose()
 {
     try
     {
         Gui.Scripting.Variables.Remove(EditorVar);
         if (Uarray.CanPasteBelow())
         {
             bool anyMBeditor = false;
             foreach (object obj in Gui.Scripting.Variables.Values)
             {
                 if (obj is MonoBehaviourEditor)
                 {
                     anyMBeditor = true;
                     break;
                 }
             }
             if (!anyMBeditor)
             {
                 Uarray.Copy(null, -1);
             }
         }
         Editor = null;
     }
     catch (Exception ex)
     {
         Utility.ReportException(ex);
     }
 }
Ejemplo n.º 3
0
        public Uarray(Uarray a)
        {
            Name = a.Name;

            for (int i = 0; i < a.Members.Count; i++)
            {
                Type            t    = a.Members[i].GetType();
                ConstructorInfo info = t.GetConstructor(new Type[] { t });
                Members.Add((UType)info.Invoke(new object[] { a.Members[i] }));
            }
        }
Ejemplo n.º 4
0
        public void Export(string path)
        {
            DirectoryInfo dirInfo = new DirectoryInfo(path);

            if (!dirInfo.Exists)
            {
                dirInfo.Create();
            }

            if (Parser.type.Members.Count > 4 && Parser.type.Members[4] is UClass &&
                ((UClass)Parser.type.Members[4]).ClassName == "Param" &&
                ((UClass)Parser.type.Members[4]).Name == "list")
            {
                Uarray  arr         = (Uarray)((UClass)Parser.type.Members[4]).Members[0];
                UType[] GenericMono = arr.Value;
                using (BinaryWriter writer = new BinaryWriter(File.OpenWrite(path + "\\" + m_Name + "." + UnityClassID.MonoBehaviour), System.Text.Encoding.UTF8))
                {
                    for (int i = 0; i < GenericMono.Length; i++)
                    {
                        UClass vectorList = (UClass)GenericMono[i].Members[0];
                        arr = (Uarray)vectorList.Members[0];
                        UType[] Strings = arr.Value;
                        for (int j = 0; j < Strings.Length; j++)
                        {
                            string word = ((UClass)Strings[j]).GetString();
                            for (int k = 0; k < word.Length; k++)
                            {
                                if (word[k] == '<' || word[k] == '>' || word[k] == '\\')
                                {
                                    word = word.Substring(0, k) + "\\" + word.Substring(k);
                                }
                            }
                            writer.Write(System.Text.Encoding.UTF8.GetBytes("<" + word + ">"));
                        }
                        writer.Write(System.Text.Encoding.UTF8.GetBytes("\r\n"));
                    }
                    writer.BaseStream.SetLength(writer.BaseStream.Position);
                }
            }
            else
            {
                string name = m_GameObject.instance != null ? m_GameObject.instance.m_Name : m_Name;
                using (FileStream stream = File.OpenWrite(path + "\\" + name + "." + UnityClassID.MonoBehaviour))
                {
                    Parser.type.WriteTo(stream);
                    stream.SetLength(stream.Position);
                }
            }
        }
Ejemplo n.º 5
0
        public static void Delete(Uarray arr, int pos)
        {
            int len = arr.Value != null ? arr.Value.Length : 0;

            if (len == 0)
            {
                return;
            }
            len--;
            UType[] newValue = new UType[len];
            for (int i = 0; i < len; i++)
            {
                newValue[i] = arr.Value[i < pos ? i : i + 1];
            }
            arr.Value = newValue;
        }
Ejemplo n.º 6
0
        public static void InsertBelow(Uarray arr, int pos)
        {
            pos++;
            int len = arr.Value != null ? arr.Value.Length : 0;

            UType[] newValue = new UType[len + 1];
            for (int i = 0; i < len; i++)
            {
                newValue[i < pos ? i : i + 1] = arr.Value[i];
            }
            Type            t    = arr.Members[1].GetType();
            ConstructorInfo info = t.GetConstructor(new Type[] { t });

            newValue[pos] = (UType)info.Invoke(new object[] { arr.Members[1] });
            arr.Value     = newValue;
        }
Ejemplo n.º 7
0
        public void ReplaceMonoBehaviour(string path)
        {
            MonoBehaviour m = MonoBehaviour.Import(path, Parser.Cabinet);

            if (m == null)
            {
                return;
            }

            for (int i = 0; i < Parser.Cabinet.Components.Count; i++)
            {
                Component asset = Parser.Cabinet.Components[i];
                if (asset.classID1 == m.classID1)
                {
                    MonoBehaviour mono = null;
                    string        name;
                    if (asset is NotLoaded)
                    {
                        name = ((NotLoaded)asset).Name;
                        if (name != m.m_Name)
                        {
                            continue;
                        }
                        mono = Parser.Cabinet.LoadComponent(asset.pathID);
                    }
                    else
                    {
                        mono = (MonoBehaviour)asset;
                        name = mono.m_GameObject.instance != null ? mono.m_GameObject.instance.m_Name : mono.m_Name;
                        if (name != m.m_Name)
                        {
                            continue;
                        }
                    }
                    if (mono.Parser.type.Members.Count > 4 && mono.Parser.type.Members[4] is UClass &&
                        ((UClass)mono.Parser.type.Members[4]).ClassName == "Param" &&
                        ((UClass)mono.Parser.type.Members[4]).Name == "list")
                    {
                        Uarray monoArr = (Uarray)((UClass)mono.Parser.type.Members[4]).Members[0];
                        Uarray mArr    = (Uarray)((UClass)m.Parser.type.Members[4]).Members[0];
                        monoArr.Value = mArr.Value;
                        Changed       = true;
                    }
                    return;
                }
            }
        }
Ejemplo n.º 8
0
        public string GetString()
        {
            if (ClassName != "string")
            {
                return(null);
            }

            Uarray arr = (Uarray)Members[0];

            UType[] Chars = arr.Value;
            byte[]  str   = new byte[Chars.Length];
            for (int i = 0; i < Chars.Length; i++)
            {
                str[i] = ((Uchar)Chars[i]).Value;
            }
            return(UTF8Encoding.UTF8.GetString(str));
        }
Ejemplo n.º 9
0
 public static void PasteBelow(Uarray arr, int pos)
 {
     if (CanPasteBelow())
     {
         InsertBelow(arr, pos);
         try
         {
             int sourcePosition = CopySourceArray == arr && CopySourcePosition > pos
                                         ? CopySourcePosition + 1 : CopySourcePosition;
             CopySourceArray.Value[sourcePosition].CopyTo(arr.Value[pos + 1]);
         }
         catch (Exception e)
         {
             Delete(arr, pos);
             throw e;
         }
     }
 }
Ejemplo n.º 10
0
        UType GetMember(AssetCabinet.TypeDefinitionString member)
        {
            switch (member.type)
            {
            case "char":
                return(new Uchar(member.identifier));

            case "bool":
            case "UInt8":
                return(new Uint8(member.identifier));

            case "int":
                return(new Uint32(member.identifier));

            case "unsigned int":
                return(new Uuint32(member.identifier));

            case "float":
                return(new Ufloat(member.identifier));
            }

            UType cls;

            if (member.type.StartsWith("PPtr<") && member.type.EndsWith(">"))
            {
                cls = new UPPtr(file, member.identifier);
            }
            else if (member.type == "Array")
            {
                cls = new Uarray();
            }
            else
            {
                cls = new UClass(member.type, member.identifier);
            }
            for (int i = 0; i < member.children.Length; i++)
            {
                AssetCabinet.TypeDefinitionString memberDef = member.children[i];
                UType submember = GetMember(memberDef);
                cls.Members.Add(submember);
            }
            return(cls);
        }
Ejemplo n.º 11
0
        private void buttonArrayElementPasteBelow_Click(object sender, EventArgs e)
        {
            try
            {
                if (treeViewAdditionalMembers.SelectedNode == null)
                {
                    ReselectEditedNode();
                }

                int line = int.Parse(treeViewAdditionalMembers.SelectedNode.Name);
                if ((bool)Gui.Scripting.RunScript(EditorVar + ".ArrayPasteBelow(line=" + line + ")"))
                {
                    Changed = Changed;

                    int linesToInsert;
                    if (treeViewAdditionalMembers.SelectedNode.Tag is Uarray)
                    {
                        Uarray arr = (Uarray)treeViewAdditionalMembers.SelectedNode.Tag;
                        linesToInsert = FormLoadedByTypeDefinition.CountMembers(arr.Members) - 1;
                    }
                    else
                    {
                        linesToInsert = FormLoadedByTypeDefinition.CountNodes(treeViewAdditionalMembers.SelectedNode);
                    }
                    AddChange(new Tuple <int, string, int>(-4, treeViewAdditionalMembers.SelectedNode.Name, linesToInsert));
                    LoadAdditionalMembers(line, linesToInsert);
                    FormLoadedByTypeDefinition.EnsureVisibleEditedNodes(treeViewAdditionalMembers.Nodes[0]);
                    if (treeViewAdditionalMembers.SelectedNode == null)
                    {
                        TreeNode[] nodes = treeViewAdditionalMembers.Nodes.Find(line.ToString(), true);
                        if (nodes.Length > 0)
                        {
                            treeViewAdditionalMembers.SelectedNode = nodes[0];
                            treeViewAdditionalMembers.SelectedNode.EnsureVisible();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Utility.ReportException(ex);
            }
        }
Ejemplo n.º 12
0
        private void buttonArrayElementDelete_Click(object sender, EventArgs e)
        {
            try
            {
                if (treeViewMembers.SelectedNode == null)
                {
                    ReselectEditedNode();
                }

                int line = int.Parse(treeViewMembers.SelectedNode.Name);
                if ((bool)Gui.Scripting.RunScript(EditorVar + ".ArrayDelete(line=" + line + ")"))
                {
                    Changed = Changed;

                    int linesToDelete;
                    if (treeViewMembers.SelectedNode.Tag is Uarray)
                    {
                        Uarray arr = (Uarray)treeViewMembers.SelectedNode.Tag;
                        linesToDelete = CountMembers(arr.Members) - 1;
                    }
                    else
                    {
                        linesToDelete = CountNodes(treeViewMembers.SelectedNode);
                    }
                    AddChange(new Tuple <int, string, int>(-2, treeViewMembers.SelectedNode.Name, linesToDelete));
                    LoadMembers(line + linesToDelete, -linesToDelete);
                    EnsureVisibleEditedNodes(treeViewMembers.Nodes[0]);
                    if (treeViewMembers.SelectedNode == null)
                    {
                        TreeNode[] nodes = treeViewMembers.Nodes.Find(line.ToString(), true);
                        if (nodes.Length > 0)
                        {
                            treeViewMembers.SelectedNode = nodes[0];
                            treeViewMembers.SelectedNode.EnsureVisible();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Utility.ReportException(ex);
            }
        }
Ejemplo n.º 13
0
 public bool ArrayPasteBelow(int line)
 {
     if (Uarray.CanPasteBelow())
     {
         int currentLine = 0;
         for (int i = 4; i < Parser.Parser.type.Members.Count; i++)
         {
             if (LoadedByTypeDefinitionEditor.ArrayOperation(Parser.Parser.type.Members[i], ref currentLine, line, Uarray.PasteBelow))
             {
                 Changed = true;
                 return(true);
             }
         }
     }
     else
     {
         Report.ReportLog("Warning! Nothing had been copied for pasting.");
     }
     return(false);
 }
Ejemplo n.º 14
0
 public static void UpdatePointersUType(UType t)
 {
     if (t is UPPtr)
     {
         UPPtr p = (UPPtr)t;
         p.Value.Refresh();
     }
     else if (t is Uarray)
     {
         Uarray a = (Uarray)t;
         for (int i = 0; i < a.Value.Length; i++)
         {
             UpdatePointersUType(a.Value[i]);
         }
     }
     else if (t is UClass)
     {
         UpdatePointersUClass((UClass)t);
     }
 }
Ejemplo n.º 15
0
 public static MonoBehaviour Import(string filePath, AssetCabinet file)
 {
     foreach (var typeDef in file.Types)
     {
         if (typeDef.definitions.type == UnityClassID.MonoBehaviour.ToString() &&
             typeDef.definitions.children.Length > 4)
         {
             var member = typeDef.definitions.children[4];
             if (member.type == "Param" && member.identifier == "list")
             {
                 MonoBehaviour m = new MonoBehaviour(null, 0, (UnityClassID)typeDef.typeId, UnityClassID.MonoBehaviour);
                 m.Parser = new TypeParser(file, typeDef);
                 m.m_Name = Path.GetFileNameWithoutExtension(filePath);
                 Uarray      ParamListArr = (Uarray)m.Parser.type.Members[4].Members[0];
                 List <Line> lines        = LoadLines(filePath);
                 ParamListArr.Value = new UType[lines.Count];
                 Type            genericMonoType    = ParamListArr.Members[1].GetType();
                 ConstructorInfo genericMonoCtrInfo = genericMonoType.GetConstructor(new Type[] { genericMonoType });
                 for (int i = 0; i < lines.Count; i++)
                 {
                     ParamListArr.Value[i] = (UType)genericMonoCtrInfo.Invoke(new object[] { ParamListArr.Members[1] });
                     UClass   GenericMonoData = (UClass)ParamListArr.Value[i];
                     Uarray   vectorListArr   = (Uarray)GenericMonoData.Members[0].Members[0];
                     UClass[] Strings         = new UClass[lines[i].m_Words.Count];
                     vectorListArr.Value = Strings;
                     Type            stringType    = vectorListArr.Members[1].GetType();
                     ConstructorInfo stringCtrInfo = genericMonoType.GetConstructor(new Type[] { stringType });
                     for (int j = 0; j < lines[i].m_Words.Count; j++)
                     {
                         Strings[j] = (UClass)stringCtrInfo.Invoke(new object[] { vectorListArr.Members[1] });
                         Strings[j].SetString(lines[i].m_Words[j]);
                     }
                 }
                 return(m);
             }
         }
     }
     Report.ReportLog("Warning! No definition of required type found!");
     return(null);
 }
Ejemplo n.º 16
0
        UType GetMember(AssetCabinet.TypeDefinitionString member)
        {
            switch (member.type)
            {
            case "char":
                return new Uchar(member.identifier);
            case "bool":
            case "UInt8":
                return new Uint8(member.identifier);
            case "int":
                return new Uint32(member.identifier);
            case "unsigned int":
                return new Uuint32(member.identifier);
            case "float":
                return new Ufloat(member.identifier);
            }

            UType cls;
            if (member.type.StartsWith("PPtr<") && member.type.EndsWith(">"))
            {
                cls = new UPPtr(file, member.identifier);
            }
            else if (member.type == "Array")
            {
                cls = new Uarray();
            }
            else
            {
                cls = new UClass(member.type, member.identifier);
            }
            for (int i = 0; i < member.children.Length; i++)
            {
                AssetCabinet.TypeDefinitionString memberDef = member.children[i];
                UType submember = GetMember(memberDef);
                cls.Members.Add(submember);
            }
            return cls;
        }
Ejemplo n.º 17
0
 public static void MovePointersUType(UType t, Component old, Component replacement, AssetCabinet destFile)
 {
     if (t is UPPtr)
     {
         UPPtr p = (UPPtr)t;
         if (p.Value.asset == old || p.Value.asset is NotLoaded && ((NotLoaded)p.Value.asset).replacement == old)
         {
             p.Value = new PPtr <Object>(replacement, destFile);
         }
     }
     else if (t is Uarray)
     {
         Uarray a = (Uarray)t;
         for (int i = 0; i < a.Value.Length; i++)
         {
             MovePointersUType(a.Value[i], old, replacement, destFile);
         }
     }
     else if (t is UClass)
     {
         MovePointersUClass((UClass)t, old, replacement, destFile);
     }
 }
Ejemplo n.º 18
0
        public void SetString(string str)
        {
            if (ClassName != "string")
            {
                return;
            }

            Uarray arr = (Uarray)Members[0];

            byte[]  bytes = UTF8Encoding.UTF8.GetBytes(str);
            UType[] Chars;
            if (arr.Value == null || bytes.Length != arr.Value.Length)
            {
                Chars = new UType[bytes.Length];
                if (arr.Value != null)
                {
                    for (int i = 0; i < Math.Min(bytes.Length, arr.Value.Length); i++)
                    {
                        Chars[i] = arr.Value[i];
                    }
                }
                arr.Value = Chars;
            }
            else
            {
                Chars = arr.Value;
            }
            for (int i = 0; i < bytes.Length; i++)
            {
                if (Chars[i] == null)
                {
                    Chars[i] = new Uchar();
                }
                ((Uchar)Chars[i]).Value = bytes[i];
            }
        }
Ejemplo n.º 19
0
        public static void StringToParamList(MonoBehaviour m, List <Line> lines)
        {
            Uarray ParamListArr = (Uarray)m.Parser.type.Members[4].Members[0];

            ParamListArr.Value = new UType[lines.Count];
            Type            genericMonoType    = ParamListArr.Members[1].GetType();
            ConstructorInfo genericMonoCtrInfo = genericMonoType.GetConstructor(new Type[] { genericMonoType });

            for (int i = 0; i < lines.Count; i++)
            {
                ParamListArr.Value[i] = (UType)genericMonoCtrInfo.Invoke(new object[] { ParamListArr.Members[1] });
                UClass   GenericMonoData = (UClass)ParamListArr.Value[i];
                Uarray   vectorListArr   = (Uarray)GenericMonoData.Members[0].Members[0];
                UClass[] Strings         = new UClass[lines[i].m_Words.Count];
                vectorListArr.Value = Strings;
                Type            stringType    = vectorListArr.Members[1].GetType();
                ConstructorInfo stringCtrInfo = genericMonoType.GetConstructor(new Type[] { stringType });
                for (int j = 0; j < lines[i].m_Words.Count; j++)
                {
                    Strings[j] = (UClass)stringCtrInfo.Invoke(new object[] { vectorListArr.Members[1] });
                    Strings[j].SetString(lines[i].m_Words[j]);
                }
            }
        }
Ejemplo n.º 20
0
        public Uarray(Uarray a)
        {
            Name = a.Name;

            for (int i = 0; i < a.Members.Count; i++)
            {
                Type t = a.Members[i].GetType();
                ConstructorInfo info = t.GetConstructor(new Type[] { t });
                Members.Add((UType)info.Invoke(new object[] { a.Members[i] }));
            }
        }
Ejemplo n.º 21
0
        public static bool ArrayOperation(UType utype, ref int currentLine, int actionLine, Uarray.action func)
        {
            if (utype is UClass)
            {
                switch (((UClass)utype).ClassName)
                {
                case "string":
                case "Vector2f":
                case "Vector3f":
                case "Vector4f":
                case "Quaternionf":
                    break;

                default:
                    if (((UClass)utype).ClassName == "ColorRGBA" && ((UClass)utype).Members.Count == 4)
                    {
                        break;
                    }
                    currentLine++;
                    for (int i = 0; i < ((UClass)utype).Members.Count; i++)
                    {
                        if (ArrayOperation(((UClass)utype).Members[i], ref currentLine, actionLine, func))
                        {
                            return(true);
                        }
                    }
                    currentLine--;
                    break;
                }
            }
            else if (utype is UPPtr)
            {
            }
            else if (utype is Uarray)
            {
                if (currentLine == actionLine)
                {
                    Uarray arr = (Uarray)utype;
                    if (func == Uarray.Delete && (arr.Value == null || arr.Value.Length == 0))
                    {
                        currentLine = -1;
                        return(true);
                    }
                    func((Uarray)utype, -1);
                    return(true);
                }
                currentLine++;
                for (int i = 0; i < ((Uarray)utype).Value.Length; i++)
                {
                    if (currentLine == actionLine)
                    {
                        func((Uarray)utype, i);
                        return(true);
                    }
                    if (ArrayOperation(((Uarray)utype).Value[i], ref currentLine, actionLine, func))
                    {
                        return(true);
                    }
                }
                currentLine--;
            }
            else if (utype is Ufloat || utype is Udouble ||
                     utype is Uint8 ||
                     utype is Uint16 || utype is Uuint16 ||
                     utype is Uint32 || utype is Uuint32 ||
                     utype is Uint64 || utype is Uuint64)
            {
            }
            else
            {
                Report.ReportLog(currentLine + " " + utype.Name + " " + utype.GetType() + " unhandled");
            }
            currentLine++;
            return(false);
        }
Ejemplo n.º 22
0
 public static void Copy(Uarray arr, int pos)
 {
     CopySourceArray    = arr;
     CopySourcePosition = pos;
 }
Ejemplo n.º 23
0
        void LoadContents()
        {
            dataGridViewContents.Visible = false;
            dataGridViewContents.Rows.Clear();
            dataGridViewContents.Columns.Clear();

            TextAsset textAsset = Gui.Scripting.Variables[ParserVar] as TextAsset;

            if (textAsset != null)
            {
                if (textAsset.m_ScriptBuffer != null && textAsset.m_Script == null)
                {
                    using (BinaryReader reader = new BinaryReader(new MemoryStream(textAsset.m_ScriptBuffer)))
                    {
                        if (textAsset.file.VersionNumber < AssetCabinet.VERSION_5_6_2)
                        {
                            StringBuilder decoded   = new StringBuilder(512 * 1024);
                            int           numTracks = reader.ReadInt32();
                            if (numTracks < textAsset.m_ScriptBuffer.Length)
                            {
                                TextAssetMode = TextAssetContents.HONEYSELECT;

                                for (int i = 0; i < numTracks; i++)
                                {
                                    decoded.Append(reader.ReadShortName());

                                    int numKeyframes = reader.ReadInt32();
                                    for (int j = 0; j < numKeyframes; j++)
                                    {
                                        int     id   = reader.ReadInt32();
                                        float[] fArr = reader.ReadSingleArray(9);
                                        decoded.Append('\t').Append(id.ToString());
                                        for (int k = 0; k < fArr.Length; k++)
                                        {
                                            decoded.Append('\t').Append(fArr[k].ToFloatString());
                                        }
                                    }
                                    decoded.Append("\r\n");
                                }
                                checkBoxJoin.CheckedChanged -= checkBoxJoin_CheckedChanged;
                                checkBoxJoin.Checked         = true;
                                checkBoxJoin.CheckedChanged += checkBoxJoin_CheckedChanged;
                            }
                            textAsset.m_Script = decoded.ToString();
                        }
                        else
                        {
                            int numRecords = reader.ReadInt32();
                            if (numRecords < textAsset.m_ScriptBuffer.Length)
                            {
                                TextAssetMode      = TextAssetContents.KOIKATSU_POSES;
                                textAsset.m_Script = KoikatsuPosesTextAsset.ToString(reader);

                                editTextBoxJoinedContent.ReadOnly = true;
                                dataGridViewContents.ReadOnly     = true;
                                checkBoxJoin.CheckedChanged      -= checkBoxJoin_CheckedChanged;
                                checkBoxJoin.Checked         = true;
                                checkBoxJoin.CheckedChanged += checkBoxJoin_CheckedChanged;
                            }
                            else
                            {
                                TextAssetMode      = TextAssetContents.KIOKATSU_LIST;
                                kList              = new KoikatsuListTextAsset(reader);
                                textAsset.m_Script = kList.ToString();

                                Text += " [" + kList.GetCategory() + "]";
                            }
                        }
                        if (reader.BaseStream.Position != textAsset.m_ScriptBuffer.Length)
                        {
                            Report.ReportLog("Warning! Read only x" + reader.BaseStream.Position.ToString("X") + " of x" + textAsset.m_ScriptBuffer.Length.ToString("X") + " bytes");
                        }
                    }
                }
                if (!checkBoxJoin.Checked)
                {
                    string[] lines      = textAsset.m_Script.Split(new char[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries);
                    int      numColumns = 1;
                    for (int i = 0; i < lines.Length; i++)
                    {
                        string[] words = lines[i].Split('\t');
                        if (numColumns < words.Length)
                        {
                            numColumns = words.Length;
                        }
                    }
                    for (int i = 0; i < numColumns; i++)
                    {
                        DataGridViewColumn col = new DataGridViewTextBoxColumn();
                        col.AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;
                        col.FillWeight   = 100;
                        col.HeaderText   = i.ToString();
                        col.MinimumWidth = 10;
                        col.Name         = "dataGridViewTextBoxColumn" + i;
                        col.SortMode     = DataGridViewColumnSortMode.NotSortable;
                        if (i == 0)
                        {
                            col.Frozen = true;
                        }
                        dataGridViewContents.Columns.Add(col);
                    }
                    int numLines = lines.Length;
                    if (numLines > 0)
                    {
                        if (lines[numLines - 1].Length == 0)
                        {
                            numLines--;
                        }
                    }
                    for (int i = 0; i < numLines; i++)
                    {
                        string[]        words = lines[i].Split('\t');
                        DataGridViewRow row   = new DataGridViewRow();
                        row.CreateCells(dataGridViewContents, words);
                        dataGridViewContents.Rows.Add(row);
                    }
                    if (TextAssetMode == TextAssetContents.KIOKATSU_LIST)
                    {
                        dataGridViewContents.Rows[0].ReadOnly = true;
                        dataGridViewContents.Rows[0].DefaultCellStyle.BackColor = Color.LightSkyBlue;
                        dataGridViewContents.Rows[0].Cells[0].Selected          = false;
                    }

                    dataGridViewContents.BringToFront();
                }
                else
                {
                    string s = textAsset.m_Script;
                    if (s.IndexOf('\r') == -1)
                    {
                        s = s.Replace("\n", "\r\n");
                    }
                    editTextBoxJoinedContent.Text = s;
                    editTextBoxJoinedContent.BringToFront();
                }
            }
            else
            {
                MonoBehaviour textMB = Gui.Scripting.Variables[ParserVar] as MonoBehaviour;
                if (textMB != null && textMB.Parser.type.Members.Count > 4 && textMB.Parser.type.Members[4] is UClass &&
                    ((UClass)textMB.Parser.type.Members[4]).ClassName == "Param" &&
                    ((UClass)textMB.Parser.type.Members[4]).Name == "list")
                {
                    Uarray  arr         = (Uarray)((UClass)textMB.Parser.type.Members[4]).Members[0];
                    UType[] GenericMono = arr.Value;
                    int     numColumns  = 1;
                    for (int i = 0; i < GenericMono.Length; i++)
                    {
                        UClass vectorList = (UClass)GenericMono[i].Members[0];
                        arr = (Uarray)vectorList.Members[0];
                        UType[] Strings = arr.Value;
                        if (numColumns < Strings.Length)
                        {
                            numColumns = Strings.Length;
                        }
                    }
                    for (int i = 0; i < numColumns; i++)
                    {
                        DataGridViewColumn col = new DataGridViewTextBoxColumn();
                        col.AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;
                        col.FillWeight   = 100;
                        col.HeaderText   = i.ToString();
                        col.MinimumWidth = 10;
                        col.Name         = "dataGridViewTextBoxColumn" + i;
                        col.SortMode     = DataGridViewColumnSortMode.NotSortable;
                        if (i == 0)
                        {
                            col.Frozen = true;
                        }
                        dataGridViewContents.Columns.Add(col);
                    }
                    for (int i = 0; i < GenericMono.Length; i++)
                    {
                        DataGridViewRow row        = new DataGridViewRow();
                        UClass          vectorList = (UClass)GenericMono[i].Members[0];
                        arr = (Uarray)vectorList.Members[0];
                        UType[]  Strings = arr.Value;
                        string[] words   = new string[Strings.Length];
                        for (int j = 0; j < Strings.Length; j++)
                        {
                            words[j] = ((UClass)Strings[j]).GetString();
                        }
                        row.CreateCells(dataGridViewContents, words);
                        for (int j = words.Length; j < numColumns; j++)
                        {
                            row.Cells[j].Style.BackColor = Color.Red;
                            row.Cells[j].ReadOnly        = true;
                        }
                        dataGridViewContents.Rows.Add(row);
                    }
                }
            }
            dataGridViewContents.Visible = true;
        }
Ejemplo n.º 24
0
        UType GetMember(AssetCabinet.TypeDefinitionString member)
        {
            switch (member.type)
            {
            case "char":
                return(new Uchar(member.identifier, member.align()));

            case "bool":
            case "SInt8":
            case "UInt8":
                return(new Uint8(member.identifier, member.align()));

            case "SInt16":
                return(new Uint16(member.identifier, member.align()));

            case "UInt16":
                return(new Uuint16(member.identifier, member.align()));

            case "int":
                return(new Uint32(member.identifier, member.align()));

            case "unsigned int":
                return(new Uuint32(member.identifier, member.align()));

            case "int64":
                return(new Uint64(member.identifier, member.align()));

            case "UInt64":
                return(new Uuint64(member.identifier, member.align()));

            case "float":
                return(new Ufloat(member.identifier, member.align()));

            case "double":
                return(new Udouble(member.identifier, member.align()));
            }

            UType cls;

            if (member.type.StartsWith("PPtr<") && member.type.EndsWith(">"))
            {
                cls = new UPPtr(file, member.identifier, member.type, member.align());
            }
            else if (member.type == "Array")
            {
                cls = new Uarray(member.align());
            }
            else
            {
                if (member.type == "StreamedResource")
                {
                    cls = new UStreamedResource(member.type, member.identifier, member.align(), file);
                }
                else
                {
                    cls = new UClass(member.type, member.identifier, member.align());
                }
                if (member.children.Length == 0)
                {
                    Report.ReportLog("Warning! " + member.identifier + " has no members!");
                }
            }
            for (int i = 0; i < member.children.Length; i++)
            {
                AssetCabinet.TypeDefinitionString memberDef = member.children[i];
                UType submember = GetMember(memberDef);
                cls.Members.Add(submember);
            }
            return(cls);
        }