예제 #1
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);
        }
예제 #2
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);
        }