コード例 #1
0
        private string DecompileHsdtScripts()
        {
            using (IReader reader = _streamManager.OpenRead())
            {
                ScriptTable scripts = _scriptFile.LoadScripts(reader);
                if (scripts is null)
                {
                    return("");
                }

                OpcodeLookup opcodes   = _buildInfo.ScriptInfo;
                var          generator = new BlamScriptGenerator(scripts, opcodes, _buildInfo, _endian);
                return(generator.Decompile(_scriptFile.Name, App.AssemblyStorage.AssemblySettings.ShowScriptInfo));
            }
        }
コード例 #2
0
ファイル: MetaReader.cs プロジェクト: widdop4ever/Assembly
 /// <summary>
 ///     Opens the file for reading and sets _reader to the stream. Must be done before any I/O operations are performed.
 /// </summary>
 /// <returns>false if the file was already open.</returns>
 private bool OpenReader()
 {
     if (_reader == null)
     {
         _reader = _streamManager.OpenRead();
         return(true);
     }
     return(false);
 }
コード例 #3
0
        public SoundEditor(EngineDescription buildInfo, string cacheLocation, TagEntry tag, ICacheFile cache, IStreamManager streamManager)
        {
            InitializeComponent();

            _buildInfo     = buildInfo;
            _cacheLocation = cacheLocation;
            _tag           = tag;
            _cache         = cache;
            _streamManager = streamManager;

            var viewModel = new ViewModel();

            DataContext       = viewModel;
            viewModel.TagName = _tag.TagFileName;
            viewModel.Sound   = _sound;

            if (!_cache.ResourceMetaLoader.SupportsSounds)
            {
                IsEnabled = false;
                MetroMessageBox.Show("Unsupported", "Assembly doesn't support sounds on this build of Halo yet.");
                return;
            }

            using (var reader = _streamManager.OpenRead())
            {
                _soundResourceGestalt = _cache.LoadSoundResourceGestaltData(reader);
                _sound = _cache.ResourceMetaLoader.LoadSoundMeta(_tag.RawTag, reader);
                var resourceTable = _cache.Resources.LoadResourceTable(reader);
                _soundResource = resourceTable.Resources.First(r => r.Index == _sound.ResourceIndex);
                _resourcePages = new []
                {
                    _soundResource.Location.PrimaryPage,
                    _soundResource.Location.SecondaryPage,
                    _soundResource.Location.TertiaryPage,
                };

                viewModel.ResourcePages =
                    new ObservableCollection <ResourcePage>(_resourcePages.ToList());
            }

            var playback = _soundResourceGestalt.SoundPlaybacks[_sound.PlaybackIndex];

            var soundPermutations = new ISoundPermutation[playback.EncodedPermutationCount];

            for (var i = 0; i < playback.EncodedPermutationCount; i++)
            {
                var permutation = _soundResourceGestalt.SoundPermutations[i + playback.FirstPermutationIndex];
                soundPermutations[i] = permutation;
                viewModel.Permutations.Add(new ViewModel.ViewPermutation
                {
                    Name             = _cache.StringIDs.GetString(permutation.SoundName),
                    Index            = i,
                    SoundPermutation = permutation
                });
            }
        }
コード例 #4
0
        public ViewValueAs(ICacheFile cacheFile, IStreamManager streamManager, IList<MetaField> fields, uint cacheOffset)
        {
            InitializeComponent();

            DwmDropShadow.DropShadowToWindow(this);

            _stream = streamManager.OpenRead();
            _reader = new MetaReader(streamManager, cacheOffset, cacheFile);
            _fields = fields;
            _cacheOffset = _cacheOffsetOriginal = cacheOffset;

            // Set Textbox
            txtOffset.Text = "0x" + _cacheOffset.ToString("X");
            btnRefresh_Click(null, null);

            // Load Plugin Path
            _examplePath = string.Format("{0}\\Examples\\ThirdGenExample.xml", VariousFunctions.GetApplicationLocation() + @"Plugins");

            // Load Meta
            RefreshMeta();
        }
コード例 #5
0
ファイル: SoundEditor.xaml.cs プロジェクト: Akarias/Assembly
        public SoundEditor(EngineDescription buildInfo, string cacheLocation, TagEntry tag, ICacheFile cache, IStreamManager streamManager)
        {
            InitializeComponent();

            /*
             * This was been fixed up to support the changes that came from sound injection, but has not really been tested
             * but it still isn't great/complete and was mainly only done so I didn't leave in a control where most of its code has been commented out and broken
             * not to mention this is all moot with MCC using external proprietary files for sounds
             * if i had to complete it, id probably add extra methods to SoundResourceTable and SoundGestalt to grab pitch ranges on demand instead of loading in everything every time
             *      -Zedd
             */

            _buildInfo     = buildInfo;
            _cacheLocation = cacheLocation;
            _tag           = tag;
            _cache         = cache;
            _streamManager = streamManager;

            var viewModel = new ViewModel();

            DataContext       = viewModel;
            viewModel.TagName = _tag.TagFileName;
            viewModel.Sound   = _sound;

            if (!_cache.ResourceMetaLoader.SupportsSounds)
            {
                IsEnabled = false;
                MetroMessageBox.Show("Unsupported", "Assembly doesn't support sounds on this build of Halo yet.");
                return;
            }

            using (var reader = _streamManager.OpenRead())
            {
                // load gestalt
                if (_cache.SoundGestalt != null)
                {
                    _soundResourceTable = _cache.SoundGestalt.LoadSoundResourceTable(reader);
                }

                _sound = _cache.ResourceMetaLoader.LoadSoundMeta(_tag.RawTag, reader);
                var resourceTable = _cache.Resources.LoadResourceTable(reader);
                _soundResource = resourceTable.Resources.First(r => r.Index == _sound.ResourceIndex);
                _resourcePages = new []
                {
                    _soundResource.Location.PrimaryPage,
                    _soundResource.Location.SecondaryPage,
                    _soundResource.Location.TertiaryPage,
                };

                viewModel.ResourcePages =
                    new ObservableCollection <ResourcePage>(_resourcePages.ToList());
            }

            for (int i = 0; i < _sound.PitchRangeCount; i++)
            {
                var pitchrange = _soundResourceTable.PitchRanges[_sound.FirstPitchRangeIndex + i];

                foreach (var permutation in pitchrange.Permutations)
                {
                    viewModel.Permutations.Add(new ViewModel.ViewPermutation
                    {
                        Name             = _cache.StringIDs.GetString(permutation.Name),
                        Index            = i,
                        SoundPermutation = permutation
                    });
                }
            }
        }
コード例 #6
0
ファイル: HaloMap.xaml.cs プロジェクト: YxCREATURExY/Assembly
        public void InitalizeMap()
        {
            _mapManager = new FileStreamManager(_cacheLocation);
            using (Stream fileStream = _mapManager.OpenRead())
            {
                EndianReader reader = new EndianReader(fileStream, Endian.BigEndian);
                Dispatcher.Invoke(new Action(delegate { StatusUpdater.Update("Opened File"); }));

                _version = new ThirdGenVersionInfo(reader);
                _supportedBuilds = XDocument.Load(VariousFunctions.GetApplicationLocation() + @"Formats\SupportedBuilds.xml");
                _layoutLoader = new BuildInfoLoader(_supportedBuilds, VariousFunctions.GetApplicationLocation() + @"Formats\");
                _buildInfo = _layoutLoader.LoadBuild(_version.BuildString);

                Dispatcher.Invoke(new Action(delegate { StatusUpdater.Update("Loaded Build Definitions"); }));

                if (_buildInfo == null)
                {
                    Dispatcher.Invoke(new Action(delegate
                        {
                            if (!_0xabad1dea.IWff.Heman(reader))
                            {
                                StatusUpdater.Update("Not a supported cache build");
                                MetroMessageBox.Show("Unable to open cache file", "Unsupported blam engine build \"" + _version.BuildString + "\". Why not add support in the 'Formats' folder?");
                            }
                            else
                            {
                                StatusUpdater.Update("HEYYEYAAEYAAAEYAEYAA");
                            }

                            Settings.homeWindow.ExternalTabClose((TabItem)this.Parent);
                        }));
                    return;
                }
                Dispatcher.Invoke(new Action(delegate
                {
                    if (Settings.startpageHideOnLaunch)
                        Settings.homeWindow.ExternalTabClose(Windows.Home.TabGenre.StartPage);
                }));

                // Load the cache file
                _cacheFile = new ThirdGenCacheFile(reader, _buildInfo, _version.BuildString);
                Dispatcher.Invoke(new Action(delegate { StatusUpdater.Update("Loaded Cache File"); }));

                // Add to Recents
                Dispatcher.Invoke(new Action(delegate
                {
                    RecentFiles.AddNewEntry(System.IO.Path.GetFileName(_cacheLocation), _cacheLocation, _buildInfo.ShortName, Settings.RecentFileType.Cache);
                    StatusUpdater.Update("Added To Recents");
                }));

                LoadHeader();
                LoadTags();
                LoadLocales();
                LoadScripts();
            }
        }
コード例 #7
0
        public void ProcessTag(ITag bitmapTag)
        {
            // I don't feel like writing structure definitions, poaching extraction code
            // #TODO: Wrap all of this up under a neat function for other uses
            bitmapTagData = null;
            processedPages.Clear();

            string groupName  = VariousFunctions.SterilizeTagGroupName(CharConstant.ToString(bitmapTag.Group.Magic)).Trim();
            string pluginPath = string.Format("{0}\\{1}\\{2}.xml", VariousFunctions.GetApplicationLocation() + @"Plugins", _buildInfo.Settings.GetSetting <string>("plugins"), groupName);

            if (!File.Exists(pluginPath) && _buildInfo.Settings.PathExists("fallbackPlugins"))
            {
                pluginPath = string.Format("{0}\\{1}\\{2}.xml", VariousFunctions.GetApplicationLocation() + @"Plugins", _buildInfo.Settings.GetSetting <string>("fallbackPlugins"), groupName);
            }

            if (pluginPath == null || !File.Exists(pluginPath))
            {
                StatusUpdater.Update("Plugin doesn't exist for 'bitmap', yet somehow you managed to get to the bitmap tab...");
                return;
            }

            using (IReader reader = _streamManager.OpenRead())
            {
                bitmapTagData = new DataBlockBuilder(reader, bitmapTag, _cache, _buildInfo);
                using (XmlReader pluginReader = XmlReader.Create(pluginPath))
                {
                    AssemblyPluginLoader.LoadPlugin(pluginReader, bitmapTagData);
                }
            }

            bool multiResouceMagic = false;             // debugging 8k textures spread across space and time

            // Resource check
            if (bitmapTagData.ReferencedResources.Count == 0)
            {
                StatusUpdater.Update("Unable to find any resources in the current tag to get bitmap data from!");
                return;
            }
            else
            {
                if (bitmapTagData.ReferencedResources.Count > 1)
                {
                    multiResouceMagic = true;
                }
                if (_cache.Resources != null)                 // mandrill compiled debugging cache
                {
                    using (IReader reader = _streamManager.OpenRead())
                    {
                        resourceTable = _cache.Resources.LoadResourceTable(reader);
                    }
                }
                else
                {
                    StatusUpdater.Update("Unable to find any resources in the cache file at all! Failed to display bitmap.");
                    return;
                }
            }

            // Grab all the raw pages required
            foreach (DatumIndex resourceDatum in bitmapTagData.ReferencedResources)
            {
                Resource currentResource = resourceTable.Resources[resourceDatum.Index];
                if (currentResource.Location == null)
                {
                    StatusUpdater.Update("A bitmap resource had a null location, bad doo doo! Fix yo compiler nerd.");
                    return;
                }

                foreach (ResourcePage currentPage in currentResource.Location.PagesToArray())
                {
                    if (currentPage == null)
                    {
                        continue;
                    }

                    using (FileStream fileStream = File.OpenRead(_cacheLocation))
                    {
                        ThirdGenCacheFile resourceFile   = (ThirdGenCacheFile)_cache;
                        Stream            resourceStream = fileStream;

                        if (currentPage.FilePath != null)                         // Mandrill compiles everything into a single cache
                        {
                            ResourceCacheInfo resourceCacheInfo = App.AssemblyStorage.AssemblySettings.HalomapResourceCachePaths.FirstOrDefault(r => r.EngineName == _buildInfo.Name);
                            string            resourceCachePath = (resourceCacheInfo != null && resourceCacheInfo.ResourceCachePath != "") ? resourceCacheInfo.ResourceCachePath : Path.GetDirectoryName(_cacheLocation);
                            resourceCachePath = Path.Combine(resourceCachePath ?? "", Path.GetFileName(currentPage.FilePath));

                            if (!File.Exists(resourceCachePath))
                            {
                                StatusUpdater.Update("Bitmap exists outside of the local cache, was unable to find this cache: " + Path.GetFileName(resourceCachePath));
                                return;
                            }

                            resourceStream = File.OpenRead(resourceCachePath);
                            resourceFile   = new ThirdGenCacheFile(new EndianReader(resourceStream, _cache.Endianness), _buildInfo, Path.GetFileName(_cacheLocation), _cache.BuildString);
                        }

                        byte[] pageData;
                        ResourcePageExtractor pageExtractor = new ResourcePageExtractor(resourceFile);
                        using (MemoryStream pageStream = new MemoryStream())
                        {
                            pageExtractor.ExtractPage(currentPage, resourceStream, pageStream);
                            pageData = new byte[pageStream.Length];
                            Buffer.BlockCopy(pageStream.GetBuffer(), 0, pageData, 0, (int)pageStream.Length);
                        }

                        processedPages.Add(pageData);                         // Store the page for use
                    }
                }
            }
        }