Beispiel #1
0
        public TreeNode BuildTree()
        {
            var treeView = new TreeNode($"{_stringTable.Id:X8}");

            var language = new TreeNode($"Language: {_stringTable.Language}");

            var unknown = new TreeNode($"Unknown: {_stringTable.Unknown}");

            var stringTableData = new TreeNode($"String Tables:");

            for (var i = 0; i < _stringTable.StringTableData.Count; i++)
            {
                var tree = new StringTableData(_stringTable.StringTableData[i]).BuildTree();
                var node = new TreeNode($"{tree[0].Name}");
                tree.RemoveAt(0);
                node.Items.AddRange(tree);

                stringTableData.Items.Add(node);
            }
            treeView.Items.AddRange(new List <TreeNode>()
            {
                language, unknown, stringTableData
            });
            return(treeView);
        }
Beispiel #2
0
            /// <summary>
            /// Exports the specified StringTable XAsset.
            /// </summary>
            /// <param name="xasset"></param>
            /// <param name="instance"></param>
            /// <returns>Status of the export operation.</returns>
            public override JekyllStatus Export(GameXAsset xasset, JekyllInstance instance)
            {
                StringTableXAsset header = instance.Reader.ReadStruct <StringTableXAsset>(xasset.HeaderAddress);

                if (xasset.Name != instance.Reader.ReadNullTerminatedString(header.Name))
                {
                    return(JekyllStatus.MemoryChanged);
                }

                string path = Path.Combine(instance.ExportPath, xasset.Name);

                Directory.CreateDirectory(Path.GetDirectoryName(path));

                StringBuilder stringTable = new StringBuilder();

                for (int x = 0; x < header.RowCount; x++)
                {
                    for (int y = 0; y < header.ColumnCount; y++)
                    {
                        StringTableData data = instance.Reader.ReadStruct <StringTableData>(header.Strings);
                        string          cell = instance.Reader.ReadNullTerminatedString(data.Value);

                        stringTable.Append($"{cell},");

                        header.Strings += Marshal.SizeOf <StringTableData>();
                    }

                    stringTable.AppendLine();
                }

                File.WriteAllText(path, stringTable.ToString());

                Console.WriteLine($"Exported {xasset.Type} {xasset.Name}");

                return(JekyllStatus.Success);
            }