private void btnOutputFolder_Click(object sender, RoutedEventArgs e) { var fbd = new FolderBrowserDialog(); if (Directory.Exists(txtOutputFolder.Text)) { fbd.SelectedPath = txtOutputFolder.Text; } else { fbd.SelectedPath = VariousFunctions.GetApplicationLocation() + "\\plugins\\"; } if (fbd.ShowDialog() == DialogResult.OK) { txtOutputFolder.Text = fbd.SelectedPath; } }
public void LoadNewTagEntry(TagEntry tag) { _tag = tag; // Load Plugin Path string className = VariousFunctions.SterilizeTagClassName(CharConstant.ToString(_tag.RawTag.Class.Magic)).Trim(); _pluginPath = string.Format("{0}\\{1}\\{2}.xml", VariousFunctions.GetApplicationLocation() + @"Plugins", _buildInfo.Settings.GetSetting <string>("plugins"), className); // Set Option boxes cbShowInvisibles.IsChecked = App.AssemblyStorage.AssemblySettings.PluginsShowInvisibles; cbShowComments.IsChecked = App.AssemblyStorage.AssemblySettings.PluginsShowComments; cbShowEnumIndex.IsChecked = App.AssemblyStorage.AssemblySettings.PluginsShowEnumIndex; cbShowInformation.IsChecked = App.AssemblyStorage.AssemblySettings.PluginsShowInformation; // Load Meta RefreshEditor(MetaReader.LoadType.File); }
public PluginEditor(EngineDescription buildInfo, TagEntry tag, MetaContainer parent, MetaEditor sibling) { InitializeComponent(); txtPlugin.TextArea.TextEntered += PluginTextEntered; _parent = parent; _sibling = sibling; LoadSyntaxHighlighting(); LoadCodeCompletion(); App.AssemblyStorage.AssemblySettings.PropertyChanged += Settings_SettingsChanged; string className = VariousFunctions.SterilizeTagClassName(CharConstant.ToString(tag.RawTag.Class.Magic)).Trim(); _pluginPath = string.Format("{0}\\{1}\\{2}.xml", VariousFunctions.GetApplicationLocation() + @"Plugins", buildInfo.Settings.GetSetting <string>("plugins"), className.Trim()); LoadPlugin(); }
public MetaEditor(EngineDescription buildInfo, TagEntry tag, MetaContainer parentContainer, TagHierarchy tags, ICacheFile cache, IStreamManager streamManager, IRTEProvider rteProvider, Trie stringIDTrie) { InitializeComponent(); _parentMetaContainer = parentContainer; _tag = tag; _tags = tags; _buildInfo = buildInfo; _cache = cache; _fileManager = streamManager; _rteProvider = rteProvider; _searchTimer = new Timer(SearchTimer); _stringIdTrie = stringIDTrie; // Load Plugin Path string className = VariousFunctions.SterilizeTagClassName(CharConstant.ToString(tag.RawTag.Class.Magic)).Trim(); _pluginPath = string.Format("{0}\\{1}\\{2}.xml", VariousFunctions.GetApplicationLocation() + @"Plugins", _buildInfo.Settings.GetSetting <string>("plugins"), className); if (_buildInfo.Settings.PathExists("fallbackPlugins")) { _fallbackPluginPath = string.Format("{0}\\{1}\\{2}.xml", VariousFunctions.GetApplicationLocation() + @"Plugins", _buildInfo.Settings.GetSetting <string>("fallbackPlugins"), className); } // Set Option boxes cbShowInvisibles.IsChecked = App.AssemblyStorage.AssemblySettings.PluginsShowInvisibles; cbShowComments.IsChecked = App.AssemblyStorage.AssemblySettings.PluginsShowComments; cbShowInformation.IsChecked = App.AssemblyStorage.AssemblySettings.PluginsShowInformation; cbEnumPrefix.SelectedIndex = (int)App.AssemblyStorage.AssemblySettings.PluginsEnumPrefix; // Load Meta RefreshEditor(MetaReader.LoadType.File); // Set init finished hasInitFinished = true; }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { // Create a new SpriteBatch, which can be used to draw textures. spriteBatch = new SpriteBatch(GraphicsDevice); gameAssets = new List <GameModel>(); foreach (var tag in _sandbox.SandboxMapMetaData.Tags) { var tagPath = string.Format("{0}\\Content\\{1}\\Assets\\{2}.xnb", VariousFunctions.GetApplicationLocation(), Usermaps.Games.Halo3.GameId, tag.TagPath); var pipelineTagPath = string.Format("{0}\\Assets\\{1}", Usermaps.Games.Halo3.GameId, tag.TagPath); if (File.Exists(tagPath)) { gameAssets.Add(new GameModel { Model = Content.Load <Model>(pipelineTagPath), Tag = tag }); } } _aspectRatio = graphics.GraphicsDevice.Viewport.AspectRatio; }
private void btnInputFolder_Click(object sender, RoutedEventArgs e) { var fbd = new FolderBrowserDialog { SelectedPath = Directory.Exists(txtInputFolder.Text) ? txtInputFolder.Text : VariousFunctions.GetApplicationLocation() }; if (fbd.ShowDialog() != DialogResult.OK) { return; } GeneratorMaps.Clear(); txtInputFolder.Text = fbd.SelectedPath; var di = new DirectoryInfo(txtInputFolder.Text); FileInfo[] fis = di.GetFiles("*.map"); foreach ( FileInfo fi in fis.Where( fi => !fi.Name.ToLower().StartsWith("campaign") && !fi.Name.ToLower().StartsWith("shared") && !fi.Name.ToLower().StartsWith("single_player_shared"))) { GeneratorMaps.Add(new MapEntry { IsSelected = true, LocalMapPath = fi.FullName, MapName = fi.Name }); } }
private void btnInputFolder_Click(object sender, RoutedEventArgs e) { var fbd = new FolderBrowserDialog { SelectedPath = Directory.Exists(txtInputFolder.Text) ? txtInputFolder.Text : VariousFunctions.GetApplicationLocation() }; if (fbd.ShowDialog() != DialogResult.OK) { return; } SelectedPlugins.Clear(); txtInputFolder.Text = fbd.SelectedPath; var di = new DirectoryInfo(txtInputFolder.Text); FileInfo[] fis = di.GetFiles(); foreach ( FileInfo fi in fis.Where( fi => (fi.Name.EndsWith(".asc") || fi.Name.EndsWith(".alt") || fi.Name.EndsWith(".ent") || fi.Name.EndsWith(".xml")) && Path.GetFileNameWithoutExtension(fi.Name).Length == 4)) { SelectedPlugins.Add(new PluginEntry { IsSelected = true, LocalMapPath = fi.FullName, PluginClassMagic = fi.Name.Remove(fi.Name.Length - 3) }); } }
public void RefreshEditor(MetaReader.LoadType type) { // Load Plugin Path string groupName = VariousFunctions.SterilizeTagGroupName(CharConstant.ToString(_tag.RawTag.Group.Magic)).Trim(); _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)) { UpdateMetaButtons(false); StatusUpdater.Update("Plugin doesn't exist. It can't be loaded for this tag."); return; } // Store the current search selection so it can be restored int searchSelectedItem = comboSearchResults.SelectedIndex; // Set the stream manager and base offset to use based upon the LoadType IStreamManager streamManager = null; long baseOffset = 0; switch (type) { case MetaReader.LoadType.File: streamManager = _fileManager; baseOffset = (uint)_tag.RawTag.MetaLocation.AsOffset(); break; case MetaReader.LoadType.Memory: if (_rteProvider == null) { goto default; } if (_rteProvider.GetMetaStream(_cache) == null) { ShowConnectionError(); return; } streamManager = new RTEStreamManager(_rteProvider, _cache); baseOffset = _tag.RawTag.MetaLocation.AsPointer(); break; default: MetroMessageBox.Show("Not Supported", "That feature is not supported for this game."); return; } // Load Plugin File using (XmlReader xml = XmlReader.Create(_pluginPath)) { _pluginVisitor = new ThirdGenPluginVisitor(_tags, _stringIdTrie, _cache.MetaArea, App.AssemblyStorage.AssemblySettings.PluginsShowInvisibles); AssemblyPluginLoader.LoadPlugin(xml, _pluginVisitor); } _changeTracker = new FieldChangeTracker(); _fileChanges = new FieldChangeSet(); _memoryChanges = new FieldChangeSet(); var metaReader = new MetaReader(streamManager, baseOffset, _cache, _buildInfo, type, _fileChanges); _flattener = new TagBlockFlattener(metaReader, _changeTracker, _fileChanges); _flattener.Flatten(_pluginVisitor.Values); metaReader.ReadFields(_pluginVisitor.Values); panelMetaComponents.ItemsSource = _pluginVisitor.Values; // Start monitoring fields for changes _changeTracker.RegisterChangeSet(_fileChanges); _changeTracker.RegisterChangeSet(_memoryChanges); _changeTracker.Attach(_pluginVisitor.Values); // Update Meta Toolbar UpdateMetaButtons(true); // Refresh search if needed if (searchSelectedItem != -1) { SearchTimer(null); if (searchSelectedItem <= (comboSearchResults.Items.Count - 1)) { comboSearchResults.SelectedIndex = searchSelectedItem; } } }
public void LoadGames() { string applicationFormatsPath = VariousFunctions.GetApplicationLocation() + "Formats\\"; // Load XContainer if (!File.Exists(applicationFormatsPath + "SupportedGames.xml")) { return; } XDocument gameInfo = XDocument.Load(applicationFormatsPath + "SupportedGames.xml"); XContainer supportedGames = gameInfo.Element("games"); // Find the first game IList <XElement> games = supportedGames.Elements("game").ToList(); if (games == null) { return; } // Loop though games, getting their info foreach (XElement game in games) { XAttribute nameAttrib = game.Attribute("name"); XAttribute safeNameAttrib = game.Attribute("safeName"); XAttribute diffucultyShieldAttrib = game.Attribute("diffucultyShield"); XAttribute titleIDAttrib = game.Attribute("titleID"); XAttribute subPackageNameAttrib = game.Attribute("subPackageName"); XAttribute hasGameStateAttrib = game.Attribute("hasGameState"); XAttribute stfsStartsWithAttrib = game.Attribute("stfsStartsWith"); XAttribute securityTypeAttrib = game.Attribute("securityType"); XAttribute securitySaltAttrib = game.Attribute("securitySalt"); XAttribute filenameAttrib = game.Attribute("filename"); // Check compulsary fields if (nameAttrib != null && safeNameAttrib != null && diffucultyShieldAttrib != null && titleIDAttrib != null && subPackageNameAttrib != null && hasGameStateAttrib != null && stfsStartsWithAttrib != null && securityTypeAttrib != null && filenameAttrib != null) { SupportedGame supportedGame = new SupportedGame(); supportedGame.Name = nameAttrib.Value; supportedGame.SafeName = safeNameAttrib.Value; supportedGame.TitleID = long.Parse(titleIDAttrib.Value.Replace("0x", ""), System.Globalization.NumberStyles.HexNumber); supportedGame.SubPackageName = subPackageNameAttrib.Value; supportedGame.HasGamestate = Convert.ToBoolean(hasGameStateAttrib.Value); supportedGame.STFSStartsWith = stfsStartsWithAttrib.Value; supportedGame.SecurityType = securityTypeAttrib.Value.ToLower() == "SHA1" ? SecurityType.SHA1 : SecurityType.CRC32; if (securitySaltAttrib != null) { supportedGame.SecuritySalt = VariousFunctions.StringToByteArray(securitySaltAttrib.Value.Replace("0x", "").Replace(" ", "").Replace(",", "")); } supportedGame.FileName = filenameAttrib.Value; LoadGameLayout(applicationFormatsPath + supportedGame.FileName, supportedGame); _games.Add(supportedGame); } } }
private string ConvertToAudioFile(ICollection <byte> data, string path = null) { string towav = Path.Combine(VariousFunctions.GetApplicationLocation(), "helpers", "towav.exe"); if (!File.Exists(towav)) { MetroMessageBox.Show("Cannot Convert Sound", "Sounds cannot be converted because towav.exe is not present. Copy it to the \\helpers folder inside your Assembly installation."); return(null); } var tempFile = Path.GetTempFileName(); byte[] footer; var codec = _soundResourceTable.Codecs[_sound.CodecIndex]; switch ((SoundEncoding)codec.Encoding) { case SoundEncoding.Mono: footer = _monoFooter; break; case SoundEncoding.Stereo: footer = _stereoFooter; break; default: throw new NotImplementedException(); } switch ((SoundCompression)codec.Compression) { case SoundCompression.XMA2: using (var fileStream = new FileStream(tempFile, FileMode.OpenOrCreate)) { using (var writer = new EndianWriter(fileStream, Endian.BigEndian)) { // Generate an XMA header // ADAPTED FROM wwisexmabank - I DO NOT TAKE ANY CREDIT WHATSOEVER FOR THE FOLLOWING CODE. // See http://hcs64.com/vgm_ripping.html for more information // 'riff' chunk writer.WriteInt32(0x52494646); // 'RIFF' writer.Endianness = Endian.LittleEndian; writer.WriteInt32(data.Count + 0x34); writer.Endianness = Endian.BigEndian; writer.WriteInt32(0x57415645); // 'data' chunk writer.Endianness = Endian.BigEndian; writer.WriteInt32(0x64617461); // 'data' writer.Endianness = Endian.LittleEndian; writer.WriteInt32(data.Count); writer.WriteBlock(data.ToArray()); // footer writer.WriteBlock(footer); // size writer.SeekTo(0x04); writer.WriteInt32((Int32)writer.Length - 0x08); } } VariousFunctions.RunProgramSilently(towav, string.Format("\"{0}\"", Path.GetFileName(tempFile)), Path.GetDirectoryName(tempFile)); if (File.Exists(tempFile)) { File.Delete(tempFile); } tempFile = Path.ChangeExtension(tempFile, "wav"); if (path != null) { File.Move(tempFile, path); } return(path ?? tempFile); default: throw new NotImplementedException(); } }
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 } } } }