public override int GetHashCode()
 {
     unchecked
     {
         return((PersistentId.GetHashCode() * 397) ^ (ProvisionalPathPair != null ? ProvisionalPathPair.GetHashCode() : 0));
     }
 }
Exemple #2
0
 /// <summary>
 /// Returns a hash code for this instance.
 /// </summary>
 /// <returns>A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table.</returns>
 public override int GetHashCode()
 {
     unchecked
     {
         return((PersistentId.GetHashCode() * 397) ^ TempId.GetHashCode());
     }
 }
Exemple #3
0
 public void Persists()
 {
     TestPersistentId(FileSystem, idFilePath =>
     {
         var id = PersistentId.Load(FileSystem, idFilePath);
         PersistentId.Load(FileSystem, idFilePath).Should().Be(id);
     });
 }
Exemple #4
0
 public void CreatesNewOnCorrupted()
 {
     TestPersistentId(FileSystem, idFilePath =>
     {
         var id = PersistentId.Load(FileSystem, idFilePath);
         FileSystem.WriteAllBytes(idFilePath, new byte[] {});
         var newId = PersistentId.Load(FileSystem, idFilePath);
         newId.Should().NotBe(id);
     });
 }
Exemple #5
0
 public void CreatesNonSpecialValue()
 {
     TestPersistentId(FileSystem, idFilePath =>
     {
         var id = PersistentId.Load(FileSystem, idFilePath);
         id.Should().NotBe(CacheDeterminism.None.EffectiveGuid);
         id.Should().NotBe(CacheDeterminism.Tool.EffectiveGuid);
         id.Should().NotBe(CacheDeterminism.SinglePhaseNonDeterministic.EffectiveGuid);
     });
 }
Exemple #6
0
 public void CreatesDirectoryIfMissing()
 {
     using (var testDirectory = new DisposableDirectory(FileSystem))
     {
         var missingDirectory = testDirectory.Path / "MissingDirectory";
         var id = PersistentId.Load(FileSystem, missingDirectory / "Cache.id");
         id.Should().NotBe(Guid.Empty);
         FileSystem.DirectoryExists(missingDirectory).Should().BeTrue();
     }
 }
 public bool Equals(ClientFileId other)
 {
     if (ReferenceEquals(null, other))
     {
         return(false);
     }
     if (ReferenceEquals(this, other))
     {
         return(true);
     }
     return(PersistentId.Equals(other.PersistentId) && Equals(ProvisionalPathPair, other.ProvisionalPathPair));
 }
    protected override void OnAssignSimPlayerToPlayer(PlayerInfo playerInfo, PersistentId simPlayerId)
    {
        base.OnAssignSimPlayerToPlayer(playerInfo, simPlayerId);

        // notify other players
        NetMessageSimPlayerIdAssignement message = new NetMessageSimPlayerIdAssignement();

        message.SimPlayerId = simPlayerId;
        message.PlayerId    = playerInfo.PlayerId;

        _serverSession.SendNetMessage(message, _playerConnections);
    }
Exemple #9
0
 public void CreatesNewOnNonexistent()
 {
     TestPersistentId(FileSystem, idFilePath =>
     {
         var id = PersistentId.Load(FileSystem, idFilePath);
         id.Should().NotBe(Guid.Empty);
         FileSystem.DeleteFile(idFilePath);
         var newId = PersistentId.Load(FileSystem, idFilePath);
         newId.Should().NotBe(Guid.Empty);
         newId.Should().NotBe(id);
     });
 }
Exemple #10
0
    public void AssignSimPlayerToPlayer(PlayerId playerId, PersistentId simPlayerId)
    {
        PlayerInfo playerInfo = GetPlayerInfo(playerId);

        if (playerInfo == null)
        {
            Log.Error("Trying to assign a SimPlayerId to a player that does not exist: " + playerId);
            return;
        }

        playerInfo.SimPlayerId = simPlayerId;

        OnAssignSimPlayerToPlayer(playerInfo, simPlayerId);
    }
Exemple #11
0
        /// <summary>
        /// Returns a <see cref="System.String" /> that represents this instance.
        /// </summary>
        /// <returns>A <see cref="System.String" /> that represents this instance.</returns>
        public override string ToString()
        {
            if (PersistentId != default(int))
            {
                return(PersistentId.ToString());
            }

            if (TempId != default(Guid))
            {
                return(TempId.ToString());
            }

            return(string.Empty);
        }
Exemple #12
0
        public async Task <String> doMkzipAsync(String bucket, String existKey, String newFileName, String[] urls, string pipeline)
        {
            if (bucket == null || string.IsNullOrEmpty(existKey) || string.IsNullOrEmpty(newFileName) || urls.Length < 0 || pipeline == null)
            {
                throw new Exception("params error");
            }
            String entryURI  = bucket + ":" + newFileName;
            String urlString = "";

            for (int i = 0; i < urls.Length; i++)
            {
                String urlEntry = "/url/" + Qiniu.Util.Base64URLSafe.ToBase64URLSafe(urls[i]);
                urlString += urlEntry;
            }

            String fop = System.Net.WebUtility.UrlEncode("mkzip/1" + urlString + "|saveas/" + Qiniu.Util.Base64URLSafe.ToBase64URLSafe(entryURI));

            string body = string.Format("bucket={0}&key={1}&fops={2}&pipeline={3}", bucket, existKey, fop, pipeline);

            System.Text.Encoding curEncoding = System.Text.Encoding.UTF8;

            QiniuAuthClient authClient = new QiniuAuthClient();

            var content = new StringContent(body);

            // StringContent 的 ContentType 默认是 text/plain
            content.Headers.ContentType = new MediaTypeHeaderValue("application/x-www-form-urlencoded");

            CallRet ret = await authClient.CallWithBinaryAsync(Config.API_HOST + "/pfop/", content);

            if (ret.OK)
            {
                try
                {
                    PersistentId pid = JsonConvert.DeserializeObject <PersistentId>(ret.Response);
                    return(pid.persistentId);
                }
                catch (Exception e)
                {
                    throw e;
                }
            }
            else
            {
                throw new Exception(ret.Response);
            }
        }
Exemple #13
0
    public static PlayerInfo GetPlayerFromSimPlayer(PersistentId simPlayerId)
    {
        if (PlayerRepertoireSystem.Instance == null)
        {
            return(null);
        }

        foreach (PlayerInfo player in PlayerRepertoireSystem.Instance.Players)
        {
            if (player.SimPlayerId == simPlayerId)
            {
                return(player);
            }
        }

        return(null);
    }
    public static Entity FindPlayerEntity(ISimWorldReadAccessor readAccessor, PersistentId simPlayerId)
    {
        Entity result = Entity.Null;

        readAccessor.Entities
        .WithAll <PlayerTag>()
        .ForEach((Entity controller, ref PersistentId id) =>
        {
            if (id.Value == simPlayerId.Value)
            {
                result = controller;
                return;
            }
        });

        return(result);
    }
Exemple #15
0
        /// <summary>
        /// 多文件压缩存储为用户提供了批量文件的压缩存储功能
        /// POST /pfop/ HTTP/1.1
        /// Host: api.qiniu.com
        /// Content-Type: application/x-www-form-urlencoded
        /// Authorization: <AccessToken>
        /// bucket = <bucket>
        /// mkzip/<mode>
        /// /url/<Base64EncodedURL>
        /// /alias/<Base64EncodedAlias>
        /// /url/<Base64EncodedURL>
        /// ...
        /// </summary>
        public String doMkzip(String bucket, String existKey, String newFileName, String[] urls, string pipeline)
        {
            if (bucket == null || string.IsNullOrEmpty(existKey) || string.IsNullOrEmpty(newFileName) || urls.Length < 0 || pipeline == null)
            {
                throw new Exception("params error");
            }
            String entryURI  = bucket + ":" + newFileName;
            String urlString = "";

            for (int i = 0; i < urls.Length; i++)
            {
                String urlEntry = "/url/" + Qiniu.Util.Base64URLSafe.ToBase64URLSafe(urls[i]);
                urlString += urlEntry;
            }
            String fop = WWW.EscapeURL("mkzip/1" + urlString + "|saveas/" + Qiniu.Util.Base64URLSafe.ToBase64URLSafe(entryURI));

            string body = string.Format("bucket={0}&key={1}&fops={2}&pipeline={3}", bucket, existKey, fop, pipeline);

            System.Text.Encoding curEncoding = System.Text.Encoding.UTF8;

            QiniuAuthClient authClient = new QiniuAuthClient();
            CallRet         ret        = authClient.CallWithBinary(Config.API_HOST + "/pfop/", "application/x-www-form-urlencoded", StreamEx.ToStream(body), body.Length);

            if (ret.OK)
            {
                try
                {
                    PersistentId pid = JsonConvert.DeserializeObject <PersistentId>(ret.Response);
                    return(pid.persistentId);
                }
                catch (Exception e)
                {
                    throw e;
                }
            }
            else
            {
                throw new Exception(ret.Response);
            }
        }
Exemple #16
0
        private void addArrangementButton_Click(object sender, EventArgs e)
        {
            //Validations
            var xmlfilepath = XmlFilePath.Text;

            if (!File.Exists(xmlfilepath))
            {
                XmlFilePath.Focus();
                return;
            }

            if (currentGameVersion == GameVersion.RS2014)
            {
                if (!routeMaskLeadRadio.Checked && !routeMaskRhythmRadio.Checked && !routeMaskBassRadio.Checked && (ArrangementType)arrangementTypeCombo.SelectedItem != ArrangementType.Vocal)
                {
                    if (MessageBox.Show("You not selected a Gameplay Path, this arrangement you show only in song list.", DLCPackageCreator.MESSAGEBOX_CAPTION, MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == System.Windows.Forms.DialogResult.Cancel)
                    {
                        gbGameplayPath.Focus();
                        return;
                    }
                }
            }

            //Song XML File
            arrangement.SongXml.File = xmlfilepath;

            //Arrangment Information
            arrangement.Name            = (ArrangementName)arrangementNameCombo.SelectedItem;
            arrangement.ArrangementType = (ArrangementType)arrangementTypeCombo.SelectedItem;

            // Tuning
            arrangement.Tuning      = tuningComboBox.SelectedItem.ToString();
            arrangement.TuningPitch = 440;
            var value = frequencyTB.Text;

            if (!String.IsNullOrEmpty(value))
            {
                double freq = 440;
                Double.TryParse(value, out freq);
                arrangement.TuningPitch = freq;
            }

            arrangement.ScrollSpeed = scrollSpeedTrackBar.Value;
            arrangement.PluckedType = Picked.Checked ? PluckedType.Picked : PluckedType.NotPicked;
            arrangement.BonusArr    = BonusCheckBox.Checked;

            //ToneSelector
            arrangement.ToneBase = toneBaseCombo.SelectedItem.ToString();
            arrangement.ToneA    = (toneBCombo.SelectedItem != null) ? toneBaseCombo.SelectedItem.ToString() : ""; //Only need if have more than one tone
            arrangement.ToneB    = (toneBCombo.SelectedItem != null) ? toneBCombo.SelectedItem.ToString() : "";
            arrangement.ToneC    = (toneCCombo.SelectedItem != null) ? toneCCombo.SelectedItem.ToString() : "";
            arrangement.ToneD    = (toneDCombo.SelectedItem != null) ? toneDCombo.SelectedItem.ToString() : "";

            //Gameplay Path
            arrangement.RouteMask = RouteMask;

            // DLC IDs
            Guid guid;

            if (Guid.TryParse(PersistentId.Text, out guid) == false)
            {
                PersistentId.Focus();
            }
            else
            {
                arrangement.Id = guid;
            }

            int masterId;

            if (int.TryParse(MasterId.Text, out masterId) == false)
            {
                MasterId.Focus();
            }
            else
            {
                arrangement.MasterId = masterId;
            }

            DialogResult = DialogResult.OK;
            Close();
        }
Exemple #17
0
 protected virtual void OnAssignSimPlayerToPlayer(PlayerInfo playerInfo, PersistentId simPlayerId)
 {
 }
Exemple #18
0
        public bool LoadArrangementData(string xmlfilepath)
        {
            //Song XML File
            Arrangement.SongXml.File = xmlfilepath;

            // SONG INFO
            if (!ReferenceEquals(xmlSong, null))
            {
                if (String.IsNullOrEmpty(parentControl.SongTitle))
                {
                    parentControl.SongTitle = xmlSong.Title ?? String.Empty;
                }
                if (String.IsNullOrEmpty(parentControl.SongTitleSort))
                {
                    parentControl.SongTitleSort = xmlSong.SongNameSort.GetValidSortName() ?? parentControl.SongTitle.GetValidSortName();
                }
                if (String.IsNullOrEmpty(parentControl.AverageTempo))
                {
                    parentControl.AverageTempo = Math.Round(xmlSong.AverageTempo).ToString() ?? String.Empty;
                }
                if (String.IsNullOrEmpty(parentControl.Artist))
                {
                    parentControl.Artist = xmlSong.ArtistName ?? String.Empty;
                }
                if (String.IsNullOrEmpty(parentControl.ArtistSort))
                {
                    parentControl.ArtistSort = xmlSong.ArtistNameSort.GetValidSortName() ?? parentControl.Artist.GetValidSortName();
                }
                if (String.IsNullOrEmpty(parentControl.Album))
                {
                    parentControl.Album = xmlSong.AlbumName ?? String.Empty;
                }
                if (String.IsNullOrEmpty(parentControl.AlbumYear))
                {
                    parentControl.AlbumYear = xmlSong.AlbumYear ?? String.Empty;
                }
                if (String.IsNullOrEmpty(parentControl.DLCName))
                {
                    parentControl.DLCName = parentControl.Artist.Acronym() + parentControl.SongTitleSort;
                }
            }

            //Arrangment Information
            Arrangement.Name            = (ArrangementName)arrangementNameCombo.SelectedItem;
            Arrangement.ArrangementType = (ArrangementType)arrangementTypeCombo.SelectedItem;
            Arrangement.ScrollSpeed     = scrollSpeedTrackBar.Value;
            Arrangement.PluckedType     = Picked.Checked ? PluckedType.Picked : PluckedType.NotPicked;
            Arrangement.BonusArr        = BonusCheckBox.Checked;
            Arrangement.Metronome       = MetronomeCb.Checked ? Metronome.Generate : Metronome.None;

            // Tuning
            TuningDefinition tuning = (TuningDefinition)tuningComboBox.SelectedItem;

            Arrangement.Tuning        = tuning.UIName;
            Arrangement.TuningStrings = tuning.Tuning;

            // TODO: Add capo selection to arrangement form
            if (!ReferenceEquals(xmlSong, null))
            {
                Arrangement.CapoFret = xmlSong.Capo;
            }
            UpdateCentOffset();

            //ToneSelector
            Arrangement.ToneBase = toneBaseCombo.SelectedItem.ToString();
            Arrangement.ToneA    = (toneACombo.SelectedItem != null) ? toneACombo.SelectedItem.ToString() : ""; //Only need if have more than one tone
            Arrangement.ToneB    = (toneBCombo.SelectedItem != null) ? toneBCombo.SelectedItem.ToString() : "";
            Arrangement.ToneC    = (toneCCombo.SelectedItem != null) ? toneCCombo.SelectedItem.ToString() : "";
            Arrangement.ToneD    = (toneDCombo.SelectedItem != null) ? toneDCombo.SelectedItem.ToString() : "";

            //Gameplay Path
            Arrangement.RouteMask = RouteMask;

            //Xml data cleanup
            xmlSong = null;

            // DLC IDs
            Guid guid;

            if (Guid.TryParse(PersistentId.Text, out guid) == false)
            {
                PersistentId.Focus();
            }
            else
            {
                Arrangement.Id = guid;
            }

            int masterId;

            if (int.TryParse(MasterId.Text, out masterId) == false)
            {
                MasterId.Focus();
            }
            else
            {
                Arrangement.MasterId = masterId;
            }

            return(true);
        }
Exemple #19
0
        public bool LoadArrangementData(string xmlfilepath)
        {
            //Song XML File
            Arrangement.SongXml.File = xmlfilepath;

            // SONG INFO
            // TODO: get song info from json or hsan file (would be better than from xml)
            if (!ReferenceEquals(xmlSong, null))
            {
                var defaultAuthor = ConfigRepository.Instance()["general_defaultauthor"].Trim();

                if (String.IsNullOrEmpty(parentControl.SongTitle))
                {
                    parentControl.SongTitle = xmlSong.Title ?? String.Empty;
                }
                if (String.IsNullOrEmpty(parentControl.SongTitleSort))
                {
                    parentControl.SongTitleSort = xmlSong.SongNameSort.GetValidSortableName() ?? parentControl.SongTitle.GetValidSortableName();
                }
                if (String.IsNullOrEmpty(parentControl.AverageTempo))
                {
                    parentControl.AverageTempo = Math.Round(xmlSong.AverageTempo).ToString() ?? String.Empty;
                }
                if (String.IsNullOrEmpty(parentControl.Artist))
                {
                    parentControl.Artist = xmlSong.ArtistName ?? String.Empty;
                }
                if (String.IsNullOrEmpty(parentControl.ArtistSort))
                {
                    parentControl.ArtistSort = xmlSong.ArtistNameSort.GetValidSortableName() ?? parentControl.Artist.GetValidSortableName();
                }
                if (String.IsNullOrEmpty(parentControl.Album))
                {
                    parentControl.Album = xmlSong.AlbumName ?? String.Empty;
                }
                if (String.IsNullOrEmpty(parentControl.AlbumYear))
                {
                    parentControl.AlbumYear = xmlSong.AlbumYear ?? String.Empty;
                }
                // using first three letters of defaultAuthor to make DLCKey unique
                if (String.IsNullOrEmpty(parentControl.DLCKey))
                {
                    parentControl.DLCKey = String.Format("{0}{1}{2}",
                                                         defaultAuthor.Substring(0, Math.Min(3, defaultAuthor.Length)), parentControl.Artist.GetValidAcronym(), parentControl.SongTitle).GetValidKey(parentControl.SongTitle);
                }

                if (String.IsNullOrEmpty(parentControl.AlbumSort))
                {
                    // use default author for AlbumSort or generate
                    var useDefaultAuthor = ConfigRepository.Instance().GetBoolean("creator_usedefaultauthor");
                    if (useDefaultAuthor) // && currentGameVersion == GameVersion.RS2014)
                    {
                        parentControl.AlbumSort = defaultAuthor.GetValidSortableName();
                    }
                    else
                    {
                        parentControl.AlbumSort = xmlSong.AlbumNameSort.GetValidSortableName() ?? parentControl.Album.GetValidSortableName();
                    }
                }
            }

            //Arrangment Information
            Arrangement.Name            = (ArrangementName)arrangementNameCombo.SelectedItem;
            Arrangement.ArrangementType = (ArrangementType)arrangementTypeCombo.SelectedItem;
            Arrangement.ScrollSpeed     = scrollSpeedTrackBar.Value;
            Arrangement.PluckedType     = Picked.Checked ? PluckedType.Picked : PluckedType.NotPicked;
            Arrangement.BonusArr        = BonusCheckBox.Checked;
            Arrangement.Metronome       = MetronomeCb.Checked ? Metronome.Generate : Metronome.None;

            // Tuning
            TuningDefinition tuning = (TuningDefinition)tuningComboBox.SelectedItem;

            Arrangement.Tuning        = tuning.UIName;
            Arrangement.TuningStrings = tuning.Tuning;

            // TODO: Add capo selection to arrangement form
            if (!ReferenceEquals(xmlSong, null))
            {
                Arrangement.CapoFret = xmlSong.Capo;
            }
            UpdateCentOffset();

            //ToneSelector //TODO: add parsing tones events
            Arrangement.ToneBase = toneBaseCombo.SelectedItem.ToString();
            Arrangement.ToneA    = (toneACombo.SelectedItem != null) ? toneACombo.SelectedItem.ToString() : ""; //Only need if have more than one tone
            Arrangement.ToneB    = (toneBCombo.SelectedItem != null) ? toneBCombo.SelectedItem.ToString() : "";
            Arrangement.ToneC    = (toneCCombo.SelectedItem != null) ? toneCCombo.SelectedItem.ToString() : "";
            Arrangement.ToneD    = (toneDCombo.SelectedItem != null) ? toneDCombo.SelectedItem.ToString() : "";

            //Gameplay Path
            Arrangement.RouteMask = RouteMask;

            //Xml data cleanup
            xmlSong = null;

            // DLC IDs
            Guid guid;

            if (Guid.TryParse(PersistentId.Text, out guid) == false)
            {
                PersistentId.Focus();
            }
            else
            {
                Arrangement.Id = guid;
            }

            int masterId;

            if (int.TryParse(MasterId.Text, out masterId) == false)
            {
                MasterId.Focus();
            }
            else
            {
                Arrangement.MasterId = masterId;
            }

            return(true);
        }
    protected override void OnUpdate()
    {
        if (PlayerRepertoireSystem.Instance == null)
        {
            return;
        }

        // wait for level to be loaded before trying to spawn pawns, kinda hack ...
        if (!SimWorldAccessor.HasSingleton <GridInfo>())
        {
            return;
        }

        _simTick.Set(SimWorldAccessor.ExpectedNewTickId);

        if (!_simTick.ClearDirty()) // makes sure we wait for sim update before sending new request
        {
            return;
        }

        // When we submit an input in the simulation, we have no guarantee that it will be processed in the next frame
        // This 'cooldown' mechanism ensures we don't ask for too many player creations
        if (_dontAskForPlayerCreateCooldownMap.Count > 0)
        {
            foreach (KeyValuePair <PlayerInfo, double> playerInCooldown in _dontAskForPlayerCreateCooldownMap)
            {
                if (playerInCooldown.Value < Time.ElapsedTime)
                {
                    _dontAskForPlayerCreateCooldownMap.Remove(playerInCooldown.Key);
                    break;
                }
            }
        }

        foreach (PlayerInfo playerInfo in PlayerRepertoireSystem.Instance.Players)
        {
            if (playerInfo.SimPlayerId == PersistentId.Invalid && AllowCreatePlayers)
            {
                Entity unassignedSimPlayer = GetUnassignedSimPlayer();

                if (unassignedSimPlayer == Entity.Null)
                {
                    // ask the simulation to create a new player

                    // When we submit an input in the simulation, we have no guarantee that it will be processed in the next frame
                    // This 'cooldown' mechanism ensures we don't ask for too many player creations
                    if (!_dontAskForPlayerCreateCooldownMap.ContainsKey(playerInfo))
                    {
                        SimWorldAccessor.SubmitInput(new SimInputPlayerCreate()
                        {
                            PlayerName = playerInfo.PlayerName
                        });
                        _dontAskForPlayerCreateCooldownMap.Add(playerInfo, Time.ElapsedTime + 1);
                    }
                }
                else
                {
                    // assign the sim player to the player
                    PersistentId simPlayerId = SimWorldAccessor.GetComponent <PersistentId>(unassignedSimPlayer);

                    PlayerRepertoireMaster.Instance.AssignSimPlayerToPlayer(playerInfo.PlayerId, simPlayerId);
                }
            }
        }

        // Update Active Player State
        SimWorldAccessor.Entities
        .WithAll <PlayerTag>()
        .ForEach((Entity playerEntity, ref PersistentId playerID, ref Active isActive) =>
        {
            PlayerInfo playerInfo = PlayerHelpers.GetPlayerFromSimPlayer(playerID);
            if (playerInfo != null && !isActive.Value)     // player connected in game but not active in simulation
            {
                SimWorldAccessor.SubmitInput(new SimInputSetPlayerActive()
                {
                    IsActive = true, PlayerID = playerID
                });
            }
            else if (playerInfo == null && isActive.Value)     // player disconnected but active in simulation
            {
                SimWorldAccessor.SubmitInput(new SimInputSetPlayerActive()
                {
                    IsActive = false, PlayerID = playerID
                });
            }
        });
    }
        private void OkButton_Click(object sender, EventArgs e)
        {
            //Validations
            var xmlfilepath = XmlFilePath.Text;

            if (!File.Exists(xmlfilepath))
            {
                if (MessageBox.Show("Xml Arrangement file path is not valid.", DLCPackageCreator.MESSAGEBOX_CAPTION, MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.Cancel)
                {
                    XmlFilePath.Focus();
                    return;
                }
            }

            if (currentGameVersion != GameVersion.RS2012)
            {
                if (!routeMaskLeadRadio.Checked && !routeMaskRhythmRadio.Checked && !routeMaskBassRadio.Checked && (ArrangementType)arrangementTypeCombo.SelectedItem != ArrangementType.Vocal)
                {
                    if (MessageBox.Show("You did not select a Gameplay Path for this arrangement.", DLCPackageCreator.MESSAGEBOX_CAPTION, MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == System.Windows.Forms.DialogResult.Cancel)
                    {
                        gbGameplayPath.Focus();
                        return;
                    }
                }
            }

            //Song XML File
            Arrangement.SongXml.File = xmlfilepath;

            // SONG INFO
            if (!ReferenceEquals(xmlSong, null))
            {
                if (String.IsNullOrEmpty(parentControl.SongTitle))
                {
                    parentControl.SongTitle = xmlSong.Title ?? String.Empty;
                }
                if (String.IsNullOrEmpty(parentControl.SongTitleSort))
                {
                    parentControl.SongTitleSort = xmlSong.SongNameSort.GetValidSortName() ?? parentControl.SongTitle.GetValidSortName();
                }
                if (String.IsNullOrEmpty(parentControl.AverageTempo))
                {
                    parentControl.AverageTempo = Math.Round(xmlSong.AverageTempo).ToString() ?? String.Empty;
                }
                if (String.IsNullOrEmpty(parentControl.Artist))
                {
                    parentControl.Artist = xmlSong.ArtistName ?? String.Empty;
                }
                if (String.IsNullOrEmpty(parentControl.ArtistSort))
                {
                    parentControl.ArtistSort = xmlSong.ArtistNameSort.GetValidSortName() ?? parentControl.Artist.GetValidSortName();
                }
                if (String.IsNullOrEmpty(parentControl.Album))
                {
                    parentControl.Album = xmlSong.AlbumName ?? String.Empty;
                }
                if (String.IsNullOrEmpty(parentControl.AlbumYear))
                {
                    parentControl.AlbumYear = xmlSong.AlbumYear ?? String.Empty;
                }
                if (String.IsNullOrEmpty(parentControl.DLCName))
                {
                    parentControl.DLCName = parentControl.Artist.Acronym() + parentControl.SongTitleSort;
                }
            }

            //Arrangment Information
            Arrangement.Name            = (ArrangementName)arrangementNameCombo.SelectedItem;
            Arrangement.ArrangementType = (ArrangementType)arrangementTypeCombo.SelectedItem;
            Arrangement.ScrollSpeed     = scrollSpeedTrackBar.Value;
            Arrangement.PluckedType     = Picked.Checked ? PluckedType.Picked : PluckedType.NotPicked;
            Arrangement.BonusArr        = BonusCheckBox.Checked;
            Arrangement.Metronome       = MetronomeCb.Checked ? Metronome.Generate : Metronome.None;

            // Tuning
            TuningDefinition tuning = (TuningDefinition)tuningComboBox.SelectedItem;

            Arrangement.Tuning        = tuning.UIName;
            Arrangement.TuningStrings = tuning.Tuning;

            // TODO: Add capo selection to arrangement form
            if (!ReferenceEquals(xmlSong, null))
            {
                Arrangement.CapoFret = xmlSong.Capo;
            }
            UpdateCentOffset();

            //ToneSelector
            Arrangement.ToneBase = toneBaseCombo.SelectedItem.ToString();
            Arrangement.ToneA    = (toneACombo.SelectedItem != null) ? toneACombo.SelectedItem.ToString() : ""; //Only need if have more than one tone
            Arrangement.ToneB    = (toneBCombo.SelectedItem != null) ? toneBCombo.SelectedItem.ToString() : "";
            Arrangement.ToneC    = (toneCCombo.SelectedItem != null) ? toneCCombo.SelectedItem.ToString() : "";
            Arrangement.ToneD    = (toneDCombo.SelectedItem != null) ? toneDCombo.SelectedItem.ToString() : "";

            //Gameplay Path
            Arrangement.RouteMask = RouteMask;

            //Xml data cleanup
            xmlSong = null;

            // DLC IDs
            Guid guid;

            if (Guid.TryParse(PersistentId.Text, out guid) == false)
            {
                PersistentId.Focus();
            }
            else
            {
                Arrangement.Id = guid;
            }

            int masterId;

            if (int.TryParse(MasterId.Text, out masterId) == false)
            {
                MasterId.Focus();
            }
            else
            {
                Arrangement.MasterId = masterId;
            }

            DialogResult = DialogResult.OK;
            Close();
        }