Beispiel #1
0
        private Song UpdateSongFromFileData(Song song)
        {
            string title = song.DefaultName;
            if (song.InfoPacIndex.HasValue) {
                title = mumMsbn._strings[song.InfoPacIndex.Value];
            }

            byte? volume = song.DefaultVolume;
            if (gctCsv != null && gctCsv.Settings.ContainsKey(song.ID)) {
                volume = gctCsv.Settings[song.ID];
            }

            return new Song(title, song.Filename, song.ID, volume, song.InfoPacIndex);
        }
Beispiel #2
0
        private void ImportSong(FileInfo file)
        {
            var match = filenameRegex.Match(file.Name);
            if (!match.Success) {
                Warn("Skipped file due to incorrect filename format: " + file.FullName);
                return;
            }
            if (file.Length == 0) {
                Log("Skipped empty file: " + file.FullName);
                return;
            }

            string filename = match.Groups[1].Value;
            byte fileVolume = byte.Parse(match.Groups[2].Value);
            string title = match.Groups[3].Value;

            Song defSong = songEditor.GetDefaultSong(filename);
            Song curSong = songEditor.ReadSong(filename);
            if (defSong == null) {
                Log("Skipped unknown song: " + file.FullName);
                return;
            }

            if (importedSongs.ContainsKey(filename)) {
                string first = importedSongs[filename];
                Warn("Song file '" + filename + "' has already been imported from '"
                    + first + "'. Skipping subsequent file: " + file.Name);
                return;
            }
            importedSongs.Add(filename, file.Name);

            if (FileOperations.SantizeFilename(curSong.DefaultName) == title) {
                title = curSong.DefaultName;
            }

            if (fileVolume > 127) {
                Warn("Volume decreased to maximum of 127 for file: " + file.FullName);
                fileVolume = 127;
            }

            byte? volume = fileVolume;
            if (fileVolume == 0) {
                Log("Ignoring 0 volume for: " + file.FullName);
                volume = null;
            } else if (defSong.DefaultVolume.HasValue
                && defSong.DefaultVolume.Value == fileVolume) {
                volume = null;
            }
            Song song = new Song(title, filename, defSong.ID, volume, defSong.InfoPacIndex);
            songEditor.WriteSong(song);

            File.Copy(file.FullName, new SongInfo(song.Filename).File.FullName, true);
        }
Beispiel #3
0
 public void WriteSong(Song song)
 {
     if (song.InfoPacIndex.HasValue) {
         if (mumMsbn != null) {
             mumMsbn._strings[song.InfoPacIndex.Value] = song.DefaultName;
             mumMsbn.SignalPropertyChange();
         }
         if (infoMsbn != null) {
             infoMsbn._strings[song.InfoPacIndex.Value] = song.DefaultName;
             infoMsbn.SignalPropertyChange();
         }
         if (trngMsbn != null) {
             trngMsbn._strings[song.InfoPacIndex.Value] = song.DefaultName;
             trngMsbn.SignalPropertyChange();
         }
     }
     if (gctCsv != null) {
         if (song.DefaultVolume.HasValue) {
             gctCsv.Settings[song.ID] = song.DefaultVolume.Value;
         } else if (gctCsv.Settings.ContainsKey(song.ID)) {
             gctCsv.Settings.Remove(song.ID);
         }
     }
 }
 public bool TryGetSong(byte key, out Song value)
 {
     return SongsByStage.TryGetValue(key, out value);
 }