Exemplo n.º 1
0
        // Load Languages
        private void LoadLanguages(MapInfo.GameIdentifier gameIdent)
        {
            if (gameIdent == MapInfo.GameIdentifier.Halo4)
            {
                // TODO: Add the new Halo 4 Languages
            }

            cbLanguages.DataContext = _languages;
        }
Exemplo n.º 2
0
        public void LoadMapInfo()
        {
            try
            {
                // Just a lazy way to validate the BLF file
                _blf = new PureBLF(_blfLocation);
                if (_blf.BLFChunks[1].ChunkMagic != "levl")
                    throw new Exception("The selected Map Info BLF is not a valid Map Info BLF file.");
                _blf.Close();

                _mapInfo = new MapInfo(_blfLocation);

                Dispatcher.Invoke(new Action(delegate
                {
                    // Add BLF Info
                    paneBLFInfo.Children.Insert(0, new Components.MapHeaderEntry("BLF Length:", "0x" + _mapInfo.Stream.Length.ToString("X8")));
                    paneBLFInfo.Children.Insert(1, new Components.MapHeaderEntry("BLF Chunks:", _blf.BLFChunks.Count.ToString()));

                    // Load Languages
                    LoadLanguages(_mapInfo.MapInformation.Game);

                    // Add Map Info
                    switch (_mapInfo.MapInformation.Game)
                    {
                        case MapInfo.GameIdentifier.Halo3:
                            txtGameName.Text = "Halo 3";
                            break;
                        case MapInfo.GameIdentifier.Halo3ODST:
                            txtGameName.Text = "Halo 3: ODST";
                            break;
                        case MapInfo.GameIdentifier.HaloReach:
                            txtGameName.Text = "Halo Reach";
                            break;
                        case MapInfo.GameIdentifier.Halo4:
                            txtGameName.Text = "Halo 4";
                            break;
                    }
                    txtMapID.Text = _mapInfo.MapInformation.MapID.ToString();
                    lblBLFNameFooter.Text = lblBLFname.Text = txtMapInternalName.Text = _mapInfo.MapInformation.InternalName;
                    txtMapPhysicalName.Text = _mapInfo.MapInformation.PhysicalName;

                    // Update UI
                    _startEditing = true;
                    cbLanguages.SelectedIndex = 0;

                    if (Settings.startpageHideOnLaunch)
                        Settings.homeWindow.ExternalTabClose(Windows.Home.TabGenre.StartPage);

                    RecentFiles.AddNewEntry(new FileInfo(_blfLocation).Name, _blfLocation, "Map Info", Settings.RecentFileType.MapInfo);
                }));
            }
            catch (Exception ex)
            {
                Dispatcher.Invoke(new Action(delegate
                {
                    MetroMessageBox.Show("Unable to open MapInfo", ex.Message.ToString());
                    Settings.homeWindow.ExternalTabClose((TabItem)this.Parent);
                }));
            }
        }
Exemplo n.º 3
0
        private void DoWork(BackgroundWorker worker, IEnumerable<MetaItem> items)
        {
            var rootFolder = Path.GetDirectoryName(Application.StartupPath);
            var metaOutput = new MetaContent()
                                 {
                                     GeneratedTimestamp = ConvertToTimestamp(DateTime.Now),
                                     Type = "cache_meta_content"
                                 };

            foreach(var item in items)
            {
                var gameEntry = new MetaContent.GameEntry { Targets = item.Targets };

                var gameTarget = item.Targets.Split('|')[0];
                var files = Directory.GetFiles(item.MapInfoPath, "*.mapinfo");
                foreach (var file in files)
                {
                    var fi = new FileInfo(file);
                    var continueProcessing = true;
                    foreach (var block in blfBlockList.Where(block => fi.Name.StartsWith(block)))
                        continueProcessing = false;

                    if (!continueProcessing) continue;

                    var mapInfo = new MapInfo(file);
                    var metaEntry = new MetaContent.GameEntry.MetaDataEntry
                                        {
                                            English_Name = mapInfo.MapInformation.MapNames[0],
                                            English_Desc = mapInfo.MapInformation.MapDescriptions[0],
                                            InternalName = mapInfo.MapInformation.InternalName,
                                            PhysicalName = mapInfo.MapInformation.PhysicalName,
                                            MapId = mapInfo.MapInformation.MapID
                                        };

                    var extraSuffix = "";
                    if (gameTarget.StartsWith("Halo4"))
                        extraSuffix = "_card";

                    var blfFile1 = new PureBLF(string.Format("{0}\\{1}{2}.blf", item.BlfPath, mapInfo.MapInformation.PhysicalName, extraSuffix));
                    var blfFile = new List<byte>(blfFile1.BLFChunks[1].ChunkData);
                    blfFile1.Close();
                    blfFile.RemoveRange(0, 0x08);

                    var blfFileSmall1 =
                        new PureBLF(string.Format("{0}\\{1}_sm.blf", item.BlfPath, mapInfo.MapInformation.PhysicalName));
                    var blfFileSmall = new List<byte>(blfFileSmall1.BLFChunks[1].ChunkData);
                    blfFileSmall1.Close();
                    blfFileSmall.RemoveRange(0, 0x08);

                    if (!Directory.Exists(string.Format("{0}\\{1}\\maps\\", rootFolder, gameTarget)))
                        Directory.CreateDirectory(string.Format("{0}\\{1}\\maps\\", rootFolder, gameTarget));

                    File.WriteAllBytes(
                        string.Format("{0}\\{1}\\maps\\{2}.jpg", rootFolder, gameTarget, mapInfo.MapInformation.PhysicalName),
                        blfFile.ToArray<byte>());
                    File.WriteAllBytes(
                        string.Format("{0}\\{1}\\maps\\{2}_small.jpg", rootFolder, gameTarget, mapInfo.MapInformation.PhysicalName),
                        blfFileSmall.ToArray<byte>());
                    metaEntry.ImageMetaData = new MetaContent.GameEntry.MetaDataEntry.ImageMetaDataEntry
                                                  {
                                                      Large =
                                                          string.Format("{0}/maps/{1}.jpg", gameTarget, mapInfo.MapInformation.PhysicalName),
                                                      Small =
                                                          string.Format("{0}/maps/{1}_small.jpg", gameTarget,
                                                                        mapInfo.MapInformation.PhysicalName)
                                                  };
                    gameEntry.MetaData.Add(metaEntry);
                }
                metaOutput.Games.Add(gameEntry);
            }

            File.WriteAllText(string.Format("{0}/content.aidf", rootFolder), JsonConvert.SerializeObject(metaOutput));
        }
Exemplo n.º 4
0
        private void UpdateMapInfo()
        {
            var errorStrings = new List<string>();

            //Reopen as new file
            _mapInfoNew = new MapInfo(_blfLocation, App.AssemblyStorage.AssemblySettings.DefaultMapInfoDatabase);
            if (IsTextBoxValid(txtMapID))
                errorStrings.Add("Map ID");
            if (IsTextBoxValid(txtZoneIndex))
                errorStrings.Add("Insertion Point " + cbInsertIndex.SelectedIndex + " Zone Index");
            errorStrings.AddRange(from textBox in _maxTeamTextBoxes where IsTextBoxValid(textBox) select _mapInfo.Engine.MaxTeamCollection.GetLayout((int)textBox.Tag).Name + " Max Teams");

            if (errorStrings.Count != 0)
            {
                Close();
                MetroMessageBox.Show("MapInfo Not Saved", errorStrings.Aggregate("The data given for the following is either not a valid number or too large.\n", (current, error) => current + ("\n" + error)));
                return;
            }

            // Update MapID
            if (!Equals(txtMapID.BorderBrush, FindResource("ExtryzeAccentBrush")))
                _mapInfo.MapInformation.MapID = Int32.Parse(txtMapID.Text);

            // Check if MapID was invalid, if so tell user.
            if (Equals(txtMapID.BorderBrush, FindResource("ExtryzeAccentBrush")))
            {
                Close();
                MetroMessageBox.Show("MapID Not Saved", "The MapID was not saved into the MapInfo. Change the MapID to a valid number, then save again.");
                return;
            }
            // Update Internal Name
            _mapInfo.MapInformation.InternalName = txtMapInternalName.Text;

            // Update Physical Name
            _mapInfo.MapInformation.PhysicalName = txtMapPhysicalName.Text;

            // Update Current Map Name/Descrption Language Selection
            _mapInfo.MapInformation.MapNames[cbLanguages.SelectedIndex] = txtMapName.Text;
            _mapInfo.MapInformation.MapDescriptions[cbLanguages.SelectedIndex] = txtMapDesc.Text;

            // Update Flags
            _mapInfo.MapInformation.Flags = LevelFlags.None;
            if (cbType.SelectedIndex == 0)
                _mapInfo.MapInformation.Flags |= LevelFlags.IsMainMenu;
            if (cbType.SelectedIndex == 1)
                _mapInfo.MapInformation.Flags |= LevelFlags.IsMultiplayer;
            if (cbType.SelectedIndex == 2)
                _mapInfo.MapInformation.Flags |= LevelFlags.IsCampaign;
            if (cbType.SelectedIndex == 4)
                _mapInfo.MapInformation.Flags |= LevelFlags.IsFirefight;
            if (cbType.SelectedIndex == 3)
                _mapInfo.MapInformation.Flags |= LevelFlags.IsCinematic;
            if (cbVisible.IsChecked == true)
                _mapInfo.MapInformation.Flags |= LevelFlags.Visible;
            if (cbGeneratesFilm.IsChecked == true)
                _mapInfo.MapInformation.Flags |= LevelFlags.GeneratesFilm;
            if (cbDLC.IsChecked == true)
                _mapInfo.MapInformation.Flags |= LevelFlags.IsDLC;
            if (cbForgeOnly.IsChecked == true)
                _mapInfo.MapInformation.Flags |= LevelFlags.IsForgeOnly;

            // Update Max Teams
            if (_mapInfo.Engine.MaxTeamCollection != null)
                UpdateMaxTeams();

            // Update MP Objects
            if (_mapInfo.Engine.MultiplayerObjectCollection != null)
                UpdateMultiplayerObjects();

            // Update Default Author
            if (_mapInfo.Engine.UsesDefaultAuthor)
                _mapInfo.MapInformation.DefaultAuthor = txtDefaultAuthor.Text;

            // Update Insertion Points
            UpdateInsertionPoints();

            // Copy changes to new file
            _mapInfoNew.MapInformation = _mapInfo.MapInformation;

            // Write all changes to file
            _mapInfoNew.UpdateMapInfo();
            Close();
            MetroMessageBox.Show("Save Successful", "Your MapInfo has been saved.");
            App.AssemblyStorage.AssemblySettings.HomeWindow.ExternalTabClose(_tab);
        }
Exemplo n.º 5
0
        public void LoadMapInfo()
        {
            try
            {
                // Just a lazy way to validate the BLF file
                _blf = new PureBLF(_blfLocation);
                if (_blf.BLFChunks[1].ChunkMagic != "levl")
                    throw new Exception("The selected Map Info BLF is not a valid Map Info BLF file.");
                _blf.Close();

                _mapInfo = new MapInfo(_blfLocation, App.AssemblyStorage.AssemblySettings.DefaultMapInfoDatabase);

                Dispatcher.Invoke(new Action(delegate
                {

                    // Add BLF Info
                    paneBLFInfo.Children.Insert(0, new MapHeaderEntry("MapInfo Version:", _mapInfo.Engine.Version.ToString(CultureInfo.InvariantCulture)));
                    paneBLFInfo.Children.Insert(1, new MapHeaderEntry("BLF Length:", "0x" + _mapInfo.Stream.Length.ToString("X")));
                    paneBLFInfo.Children.Insert(2, new MapHeaderEntry("BLF Chunks:", _blf.BLFChunks.Count.ToString(CultureInfo.InvariantCulture)));

                    // Hide unused elements
                    if (_mapInfo.Engine.MaxTeamCollection == null)
                        tiMaxTeams.Visibility = Visibility.Collapsed;
                    if (_mapInfo.Engine.MultiplayerObjectCollection == null)
                        tiMPObjects.Visibility = Visibility.Collapsed;
                    if (!_mapInfo.Engine.UsesDefaultAuthor)
                    {
                        lblDefaultAuthor.Visibility = Visibility.Collapsed;
                        txtDefaultAuthor.Visibility = Visibility.Collapsed;
                    }

                    // Load Languages
                    LoadLanguages();

                    // Load Map Info
                    txtGameName.Text = _mapInfo.Engine.Name;
                    txtMapID.Text = _mapInfo.MapInformation.MapID.ToString(CultureInfo.InvariantCulture);
                    txtMapInternalName.Text = _mapInfo.MapInformation.InternalName;
                    txtMapPhysicalName.Text = _mapInfo.MapInformation.PhysicalName;

                    // Load Default Author & change margin if necessary
                    txtDefaultAuthor.Text = _mapInfo.MapInformation.DefaultAuthor;
                    if (_mapInfo.Engine.UsesDefaultAuthor && _mapInfo.Engine.Version <= 8)
                            lblDefaultAuthor.Margin = new Thickness(0, 37, 0, 3);

                    // Set up the Type combo box
                    // TODO: Add flags to formats?
                    cbType_Cine.Visibility = cbType_FF.Visibility = _mapInfo.Engine.Version < 5 ? Visibility.Collapsed : Visibility.Visible;
                    cbType_Cine.IsEnabled = cbType_FF.IsEnabled = _mapInfo.Engine.Version >= 5;
                    cbType_FF.Content = _mapInfo.Engine.Version < 8 ? "Firefight" : "Spartan Ops";
                    if (_mapInfo.MapInformation.Flags.HasFlag(LevelFlags.IsMainMenu))
                        cbType.SelectedIndex = 0;
                    if (_mapInfo.MapInformation.Flags.HasFlag(LevelFlags.IsMultiplayer))
                        cbType.SelectedIndex = 1;
                    if (_mapInfo.MapInformation.Flags.HasFlag(LevelFlags.IsCampaign))
                        cbType.SelectedIndex = 2;
                    if (_mapInfo.MapInformation.Flags.HasFlag(LevelFlags.IsCinematic))
                        cbType.SelectedIndex = 3;
                    if (_mapInfo.MapInformation.Flags.HasFlag(LevelFlags.IsFirefight))
                        cbType.SelectedIndex = 4;

                    // Set up the Checkboxes
                    cbForgeOnly.Visibility  = _mapInfo.Engine.Version < 9 ? Visibility.Collapsed : Visibility.Visible;
                    cbVisible.IsChecked = _mapInfo.MapInformation.Flags.HasFlag(LevelFlags.Visible);
                    cbGeneratesFilm.IsChecked = _mapInfo.MapInformation.Flags.HasFlag(LevelFlags.GeneratesFilm);
                    cbDLC.IsChecked = _mapInfo.MapInformation.Flags.HasFlag(LevelFlags.IsDLC);
                    cbForgeOnly.IsChecked = _mapInfo.MapInformation.Flags.HasFlag(LevelFlags.IsForgeOnly);

                    // Load Max Teams
                    if (_mapInfo.Engine.MaxTeamCollection != null)
                        LoadMaxTeams();

                    // Load MP Objects
                    if (_mapInfo.Engine.MultiplayerObjectCollection != null)
                        LoadMultiplayerObjects();

                    // Load Insertion Points
                    LoadInsertionPoints();

                    // Update UI
                    _startEditing = true;
                    cbLanguages.SelectedIndex = 0;
                    cbInsertIndex.SelectedIndex = 0;
                    cbInsertLanguages.SelectedIndex = 0;

                    if (App.AssemblyStorage.AssemblySettings.StartpageHideOnLaunch)
                        App.AssemblyStorage.AssemblySettings.HomeWindow.ExternalTabClose(Home.TabGenre.StartPage);

                    RecentFiles.AddNewEntry(new FileInfo(_blfLocation).Name, _blfLocation, "Map Info", Settings.RecentFileType.MapInfo);
                    Close();
                }));
            }
            catch (Exception ex)
            {
                Dispatcher.Invoke(new Action(delegate
                {
                    MetroMessageBox.Show("Unable to open MapInfo", ex.Message);
                    App.AssemblyStorage.AssemblySettings.HomeWindow.ExternalTabClose(_tab);
                    Close();
                }));
            }
        }
Exemplo n.º 6
0
        // Update MapInfo file
        private void btnUpdate_Click(object sender, RoutedEventArgs e)
        {
            _mapInfo = new MapInfo(_blfLocation);
            // Update MapID
            if (!Equals(txtMapID.BorderBrush, FindResource("ExtryzeAccentBrush")))
                _mapInfo.MapInformation.MapID = Int32.Parse(txtMapID.Text);

            // Check if MapID was invalid, if so tell user.
            if (Equals(txtMapID.BorderBrush, FindResource("ExtryzeAccentBrush")))
            {
                MetroMessageBox.Show("MapID Not Saved",
                    "The MapID was not saved into the MapInfo. Change the MapID to a valid number, then save again.");
                return;
            }
            // Update Internal Name
            _mapInfo.MapInformation.InternalName = txtMapInternalName.Text;

            // Update Physical Name
            _mapInfo.MapInformation.PhysicalName = txtMapPhysicalName.Text;

            // Update Current Map Name/Descrption Language Selection
            _mapInfo.MapInformation.MapNames[cbLanguages.SelectedIndex] = txtMapName.Text;
            _mapInfo.MapInformation.MapDescriptions[cbLanguages.SelectedIndex] = txtMapDesc.Text;

            // Update Flags
            _mapInfo.MapInformation.Flags = LevelFlags.None;
            if (cbType.SelectedIndex == 0)
                _mapInfo.MapInformation.Flags |= LevelFlags.IsMainMenu;
            if (cbType.SelectedIndex == 1)
                _mapInfo.MapInformation.Flags |= LevelFlags.IsMultiplayer;
            if (cbType.SelectedIndex == 2)
                _mapInfo.MapInformation.Flags |= LevelFlags.IsCampaign;
            if (cbType.SelectedIndex == 4)
                _mapInfo.MapInformation.Flags |= LevelFlags.IsFirefight;
            if (cbType.SelectedIndex == 3)
                _mapInfo.MapInformation.Flags |= LevelFlags.IsCinematic;
            if (cbVisible.IsChecked == true)
                _mapInfo.MapInformation.Flags |= LevelFlags.Visible;
            if (cbGeneratesFilm.IsChecked == true)
                _mapInfo.MapInformation.Flags |= LevelFlags.GeneratesFilm;
            if (cbDLC.IsChecked == true)
                _mapInfo.MapInformation.Flags |= LevelFlags.IsDLC;
            if (cbForgeOnly.IsChecked == true)
                _mapInfo.MapInformation.Flags |= LevelFlags.IsForgeOnly;

            // Write all changes to file
            _mapInfo.UpdateMapInfo();
            Close();
            MetroMessageBox.Show("Save Successful", "Your MapInfo has been saved.");
            App.AssemblyStorage.AssemblySettings.HomeWindow.ExternalTabClose(_tab);
        }
Exemplo n.º 7
0
        public void LoadMapInfo()
        {
            try
            {
                // Just a lazy way to validate the BLF file
                _blf = new PureBLF(_blfLocation);
                if (_blf.BLFChunks[1].ChunkMagic != "levl")
                    throw new Exception("The selected Map Info BLF is not a valid Map Info BLF file.");
                _blf.Close();

                _mapInfo = new MapInfo(_blfLocation);

                Dispatcher.Invoke(new Action(delegate
                {
                    // Add BLF Info
                    paneBLFInfo.Children.Insert(0, new MapHeaderEntry("BLF Length:", "0x" + _mapInfo.Stream.Length.ToString("X8")));
                    paneBLFInfo.Children.Insert(1,
                        new MapHeaderEntry("BLF Chunks:", _blf.BLFChunks.Count.ToString(CultureInfo.InvariantCulture)));

                    // Load Languages
                    LoadLanguages();

                    // Add Map Info
                    switch (_mapInfo.MapInformation.Game)
                    {
                        case MapInfo.GameIdentifier.Halo3:
                            txtGameName.Text = "Halo 3";
                            break;
                        case MapInfo.GameIdentifier.Halo3ODST:
                            txtGameName.Text = "Halo 3: ODST";
                            break;
                        case MapInfo.GameIdentifier.HaloReach:
                            txtGameName.Text = "Halo Reach";
                            break;
                        case MapInfo.GameIdentifier.HaloReachBetas:
                            txtGameName.Text = "Halo Reach Pre/Beta";
                            break;
                        case MapInfo.GameIdentifier.Halo4:
                            txtGameName.Text = "Halo 4";
                            break;
                    }
                    txtMapID.Text = _mapInfo.MapInformation.MapID.ToString(CultureInfo.InvariantCulture);
                    lblBLFNameFooter.Text = lblBLFname.Text = txtMapInternalName.Text = _mapInfo.MapInformation.InternalName;
                    txtMapPhysicalName.Text = _mapInfo.MapInformation.PhysicalName;

                    // Set up the Type combo box
                    switch (_mapInfo.MapInformation.Game)
                    {
                        case MapInfo.GameIdentifier.Halo3:
                        case MapInfo.GameIdentifier.Halo3ODST:
                            cbType_Cine.Visibility = System.Windows.Visibility.Collapsed;
                            cbType_Cine.IsEnabled = false;
                            cbType_FF.Visibility = System.Windows.Visibility.Collapsed;
                            cbType_FF.IsEnabled = false;
                            break;
                        case MapInfo.GameIdentifier.HaloReach:
                        case MapInfo.GameIdentifier.HaloReachBetas:
                            cbType_Cine.Visibility = System.Windows.Visibility.Visible;
                            cbType_Cine.IsEnabled = true;
                            cbType_FF.Visibility = System.Windows.Visibility.Visible;
                            cbType_FF.IsEnabled = true;
                            cbType_FF.Content = "Firefight";
                            break;
                        case MapInfo.GameIdentifier.Halo4:
                            cbType_Cine.Visibility = System.Windows.Visibility.Visible;
                            cbType_Cine.IsEnabled = true;
                            cbType_FF.Visibility = System.Windows.Visibility.Visible;
                            cbType_FF.IsEnabled = true;
                            cbType_FF.Content = "Spartan Ops";
                            break;
                    }
                    if (_mapInfo.MapInformation.Flags.HasFlag(LevelFlags.IsMainMenu))
                        cbType.SelectedIndex = 0;
                    if (_mapInfo.MapInformation.Flags.HasFlag(LevelFlags.IsMultiplayer))
                        cbType.SelectedIndex = 1;
                    if (_mapInfo.MapInformation.Flags.HasFlag(LevelFlags.IsCampaign))
                        cbType.SelectedIndex = 2;
                    if (_mapInfo.MapInformation.Flags.HasFlag(LevelFlags.IsCinematic))
                        cbType.SelectedIndex = 3;
                    if (_mapInfo.MapInformation.Flags.HasFlag(LevelFlags.IsFirefight))
                        cbType.SelectedIndex = 4;

                    // Set up the Checkboxes
                    switch (_mapInfo.MapInformation.Game)
                    {
                        case MapInfo.GameIdentifier.Halo4:
                            cbDLC.Margin = new Thickness(112, 0, 0, 0);
                            cbForgeOnly.Visibility = System.Windows.Visibility.Visible;
                            break;
                        default:
                            cbDLC.Margin = new Thickness(150, 0, 0, 0);
                            cbForgeOnly.Visibility = System.Windows.Visibility.Collapsed;
                            break;
                    }
                    if (_mapInfo.MapInformation.Flags.HasFlag(LevelFlags.Visible))
                        cbVisible.IsChecked = true;
                    if (_mapInfo.MapInformation.Flags.HasFlag(LevelFlags.GeneratesFilm))
                        cbGeneratesFilm.IsChecked = true;
                    if (_mapInfo.MapInformation.Flags.HasFlag(LevelFlags.IsDLC))
                        cbDLC.IsChecked = true;
                    if (_mapInfo.MapInformation.Flags.HasFlag(LevelFlags.IsForgeOnly))
                        cbForgeOnly.IsChecked = true;

                    // Update UI
                    _startEditing = true;
                    cbLanguages.SelectedIndex = 0;

                    if (App.AssemblyStorage.AssemblySettings.StartpageHideOnLaunch)
                        App.AssemblyStorage.AssemblySettings.HomeWindow.ExternalTabClose(Home.TabGenre.StartPage);

                    RecentFiles.AddNewEntry(new FileInfo(_blfLocation).Name, _blfLocation, "Map Info", Settings.RecentFileType.MapInfo);
                    Close();
                }));
            }
            catch (Exception ex)
            {
                Dispatcher.Invoke(new Action(delegate
                {
                    MetroMessageBox.Show("Unable to open MapInfo", ex.Message);
                    App.AssemblyStorage.AssemblySettings.HomeWindow.ExternalTabClose(_tab);
                    Close();
                }));
            }
        }