public void LoadResourceEntry(ResourceEntry resourceEntry, string description, Endian endian)
        {
            var resource = new ResourceFormats.ScriptResource();

            using (var data = new MemoryStream(resourceEntry.Data, false))
            {
                resource.Deserialize(resourceEntry.Version, data, endian);
            }

            _ResourceEntry = resourceEntry;
            _Endian        = endian;
            _Description   = description;
            _Resource      = resource;

            // ReSharper disable LocalizableElement
            Text += ": " + resource.Path;
            // ReSharper restore LocalizableElement
            _ScriptComboBox.Items.Clear();
            foreach (var script in resource.Scripts)
            {
                _ScriptComboBox.Items.Add(script);
            }
            if (_ScriptComboBox.Items.Count > 0)
            {
                _ScriptComboBox.SelectedIndex = 0;
            }
        }
 public void LoadResourceEntry(ResourceEntry resourceEntry, string description, Endian endian)
 {
     _ResourceEntry = resourceEntry;
     _Endian        = endian;
     _Description   = description;
     UpdatePreview();
 }
Exemple #3
0
        public static IResourceViewer Create(string name, FileFormats.Archive.ResourceEntry resourceEntry)
        {
            if (Properties.Settings.Default.ArchiveViewer_HexMode)
            {
                return(_RawViewer != null ? _RawViewer : _RawViewer = new RawViewer());
            }

            switch (name)
            {
            // case "Generic":
            // case "hkAnimation":
            // case "Flash":

            case "MemFile":
            {
                int    hash = System.BitConverter.ToInt32(resourceEntry.Data, 0);  // Hash
                int    size = System.BitConverter.ToInt32(resourceEntry.Data, 4);
                string file = System.Text.Encoding.ASCII.GetString(resourceEntry.Data, 8, size);
                int    unk  = System.BitConverter.ToInt32(resourceEntry.Data, 8 + size);
                int    type = System.BitConverter.ToInt32(resourceEntry.Data, 12 + size);

                if (type == 16)
                {
                    return(_BnkViewer != null ? _BnkViewer : _BnkViewer = new BnkViewer());
                }

                return(_MemFileViewer != null ? _MemFileViewer : _MemFileViewer = new MemFileViewer());
            }

            case "Script":
            {
                return(_ScriptViewer != null ? _ScriptViewer : _ScriptViewer = new ScriptViewer());
            }

            case "Texture":
            {
                return(_TextureViewer != null ? _TextureViewer : _TextureViewer = new TextureViewer());
            }

            case "XML":
            {
                return(_XmlViewer != null ? _XmlViewer : _XmlViewer = new XmlViewer());
            }

            case "Flash":
            {
                return(_FlashViewer != null ? _FlashViewer : _FlashViewer = new FlashViewer());
            }
            }

            return(_RawViewer != null ? _RawViewer : _RawViewer = new RawViewer());
        }
        public void LoadResourceEntry(ResourceEntry resourceEntry, string description, Endian endian)
        {
            var resource = new ResourceFormats.FlashResource();

            using (var data = new MemoryStream(resourceEntry.Data, false))
            {
                resource.Deserialize(resourceEntry.Version, data, endian);
            }

            _ResourceEntry = resourceEntry;
            _Endian        = endian;
            _Description   = description;
            _Resource      = resource;

            _HexBox.ByteProvider = new DynamicByteProvider(resource.Data);
        }
        public void LoadResourceEntry(ResourceEntry resourceEntry, string description, Endian endian)
        {
            _SaveButton.Enabled         = true;
            _LoadFromFileButton.Enabled = true;
            _SaveToFileButton.Enabled   = true;

#if (DEBUG == FALSE)
            try
            {
#endif

#if DEBUG
            using (var file = File.Create("input_xml.bin"))
            {
                file.WriteBytes(resourceEntry.Data);
            }
            hash_input = FileFormats.Hashing.FNV64.Hash(resourceEntry.Data, 0, resourceEntry.Data.Length);
#endif
            var resource = new ResourceFormats.XmlResource();
            using (var data = new MemoryStream(resourceEntry.Data, false))
            {
                resource.Deserialize(resourceEntry.Version, data, endian);
            }

            _ResourceEntry = resourceEntry;
            _Endian        = endian;
            _Description   = description;
            _Resource      = resource;

            _Scintilla.Text = resource.Content;
            _Scintilla.EmptyUndoBuffer();

#if (DEBUG == FALSE)
        }

        catch
        {
            _SaveButton.Enabled         = false;
            _LoadFromFileButton.Enabled = false;
            _SaveToFileButton.Enabled   = false;
            _Scintilla.Text             = "";
        }
#endif
        }
        public void LoadResourceEntry(ResourceEntry resourceEntry, string description, Endian endian)
        {
            var tables = new ResourceFormats.TableResource();

            using (var data = new MemoryStream(resourceEntry.Data, false))
            {
                tables.Deserialize(resourceEntry.Version, data, endian);
            }

            _TableComboBox.Items.Clear();
            foreach (var table in tables.Tables)
            {
                _TableComboBox.Items.Add(table);
            }
            if (_TableComboBox.Items.Count > 0)
            {
                _TableComboBox.SelectedIndex = 0;
            }
        }
Exemple #7
0
        public void LoadResourceEntry(ResourceEntry resourceEntry, string description, Endian endian)
        {
            var resource = new ResourceFormats.MemFileResource();

            using (var data = new MemoryStream(resourceEntry.Data, false))
            {
                resource.Deserialize(resourceEntry.Version, data, endian);
            }

            _ResourceEntry = resourceEntry;
            _Endian        = endian;
            _Description   = description;
            _Resource      = resource;

            //
            textLog.Clear();
            _LastPlaySound = 0;
            _LastWemPath   = "";

            _HeaderGeneral = null;
            _DIDXSection   = null;
            if (_DIDXData != null)
            {
                _DIDXData.Close();
                _DIDXData = null;
            }
            _Section.Clear();

            var input = new MemoryStream(resource.Data, false);

            if (input.ReadValueU32() != 0x44484b42)
            {
                Console.WriteLine("Invalid .bnk file");
                return;
            }

            uint headerSize = input.ReadValueU32();

            _HeaderGeneral = input.ReadBytes(headerSize);

#if DEBUG
            string hex = BitConverter.ToString(_HeaderGeneral).Replace("-", "");
            Console.WriteLine("header=" + hex);
#endif

            while (input.Position != input.Length)
            {
                uint section = input.ReadValueU32();
                if (section == 0x58444944) // DIDX
                {
                    _DIDXSection = ReadDIDXSection(input);
                }
                else if (section == 0x41544144) // DATA
                {
                    uint SectionSize = input.ReadValueU32();;
                    _DIDXData = new FileStream(_PathCache, FileMode.Create, FileAccess.ReadWrite, FileShare.ReadWrite);
                    _DIDXData.WriteFromStream(input, SectionSize);
                    _DIDXData.Seek(0L, SeekOrigin.Begin);
                    Console.WriteLine("section='{0}' {1}", "DATA", SectionSize);
                }
                else if (section == 0x43524948) // HIRC
                {
#if _DEBUG
                    var posBegin = input.Position;
#endif

                    uint SectionSize = input.ReadValueU32();
                    _Section.Add(section, input.ReadBytes(SectionSize));
                    Console.WriteLine("section='{0}' {1}", "HIRC", SectionSize);
#if _DEBUG
                    var posEnd = input.Position;
                    input.Seek(posBegin, SeekOrigin.Begin);
                    var pHIRCSection = ReadHIRCSection(input);
                    input.Seek(posEnd, SeekOrigin.Begin);
#endif
                }
                else
                {
                    uint   SectionSize = input.ReadValueU32();
                    byte[] buffer      = input.ReadBytes(SectionSize);
                    _Section.Add(section, buffer);
                    string name = Encoding.ASCII.GetString(BitConverter.GetBytes(section));
                    Console.WriteLine("section='{0}' {1}", name, SectionSize);
                }
            }

            BuildEntryTree();

            input.Close();
        }