diff --git a/Vocaluxe/Base/CSettings.cs b/Vocaluxe/Base/CSettings.cs index e75835b1..d5331c4a 100644 --- a/Vocaluxe/Base/CSettings.cs +++ b/Vocaluxe/Base/CSettings.cs @@ -112,7 +112,7 @@ namespace Vocaluxe.Base public const float LyricHelperMinTime = 0.2f; public const float DefaultMedleyFadeInTime = 8f; - public const float DefaultMedleyFadeOutTIme = 2f; + public const float DefaultMedleyFadeOutTime = 2f; public const int MedleyMinSeriesLength = 3; public const float MedleyMinDuration = 40f; diff --git a/Vocaluxe/GameModes/CGameMode.cs b/Vocaluxe/GameModes/CGameMode.cs index 821178e4..80e19118 100644 --- a/Vocaluxe/GameModes/CGameMode.cs +++ b/Vocaluxe/GameModes/CGameMode.cs @@ -85,14 +85,14 @@ namespace Vocaluxe.GameModes { protected bool _Initialized = false; protected EGameMode _GameMode; - protected List _SongIDs; + protected List _Songs; protected int _ActualSong; protected CPoints _Points; #region Implementation public virtual void Init() { - _SongIDs = new List(); + _Songs = new List(); Reset(); } @@ -105,12 +105,9 @@ namespace Vocaluxe.GameModes { if (CSongs.VisibleSongs.Length > VisibleIndex) { - //int ID = CSongs.VisibleSongs[VisibleIndex].ID; - //if (!_SongIDs.Exists(delegate(int i) { return (i == ID); })) - //{ - _SongIDs.Add(CSongs.VisibleSongs[VisibleIndex].ID); - return true; - //} + _Songs.Add(new CSong(CSongs.VisibleSongs[VisibleIndex])); + SongManipulation(_Songs.Count - 1); + return true; } return false; } @@ -119,12 +116,9 @@ namespace Vocaluxe.GameModes { if (CSongs.AllSongs.Length > AbsoluteIndex) { - //int ID = CSongs.AllSongs[AbsoluteIndex].ID; - //if (!_SongIDs.Exists(delegate(int i) { return (i == ID); })) - //{ - _SongIDs.Add(CSongs.AllSongs[AbsoluteIndex].ID); + _Songs.Add(CSongs.AllSongs[AbsoluteIndex]); + SongManipulation(_Songs.Count - 1); return true; - //} } return false; } @@ -133,7 +127,24 @@ namespace Vocaluxe.GameModes { if (CSongs.VisibleSongs.Length > VisibleIndex) { - return _SongIDs.Remove(CSongs.VisibleSongs[VisibleIndex].ID); + int ID = CSongs.VisibleSongs[VisibleIndex].ID; + int index = -1; + + for (int i = 0; i < _Songs.Count; i++) + { + if (_Songs[i].ID == ID) + { + index = i; + break; + } + } + + if (index > -1) + { + _Songs.RemoveAt(index); + return true; + } + return false; } return false; } @@ -142,14 +153,31 @@ namespace Vocaluxe.GameModes { if (CSongs.AllSongs.Length > AbsoluteIndex) { - return _SongIDs.Remove(CSongs.AllSongs[AbsoluteIndex].ID); + int ID = CSongs.AllSongs[AbsoluteIndex].ID; + int index = -1; + + for (int i = 0; i < _Songs.Count; i++) + { + if (_Songs[i].ID == ID) + { + index = i; + break; + } + } + + if (index > -1) + { + _Songs.RemoveAt(index); + return true; + } + return false; } return false; } public virtual void ClearSongs() { - _SongIDs.Clear(); + _Songs.Clear(); } public virtual void Reset() @@ -159,16 +187,16 @@ namespace Vocaluxe.GameModes public virtual void Start(SPlayer[] Player) { - _Points = new CPoints(_SongIDs.Count, Player); + _Points = new CPoints(_Songs.Count, Player); } public virtual void NextRound(SPlayer[] Player) { - if (_ActualSong < _SongIDs.Count && _SongIDs.Count > 0) + if (_ActualSong < _Songs.Count && _Songs.Count > 0) { if (_ActualSong > -1) { - _Points.SetPoints(_ActualSong, _SongIDs[_ActualSong], Player, _GameMode == EGameMode.Medley, _GameMode == EGameMode.Duet); + _Points.SetPoints(_ActualSong, _Songs[_ActualSong].ID, Player, _GameMode == EGameMode.Medley, _GameMode == EGameMode.Duet); } _ActualSong++; } @@ -176,7 +204,7 @@ namespace Vocaluxe.GameModes public virtual bool IsFinished() { - return (_ActualSong == _SongIDs.Count || _SongIDs.Count == 0); + return (_ActualSong == _Songs.Count || _Songs.Count == 0); } public virtual int GetActualRoundNr() @@ -186,22 +214,22 @@ namespace Vocaluxe.GameModes public virtual CSong GetSong() { - if (_ActualSong >= 0 && _ActualSong < _SongIDs.Count) + if (_ActualSong >= 0 && _ActualSong < _Songs.Count) { - return CSongs.GetSong(_SongIDs[_ActualSong]); + return _Songs[_ActualSong]; } return null; } public virtual int GetNumSongs() { - return _SongIDs.Count; + return _Songs.Count; } public virtual CSong GetSong(int Num) { - if (Num - 1 < _SongIDs.Count) - return CSongs.GetSong(_SongIDs[Num - 1]); + if (Num - 1 < _Songs.Count) + return _Songs[Num - 1]; return null; } @@ -211,5 +239,9 @@ namespace Vocaluxe.GameModes return _Points; } #endregion Implementation + + protected virtual void SongManipulation(int SongIndex) + { + } } } diff --git a/Vocaluxe/GameModes/CGameModeMedley.cs b/Vocaluxe/GameModes/CGameModeMedley.cs index 03daef3f..7b22f145 100644 --- a/Vocaluxe/GameModes/CGameModeMedley.cs +++ b/Vocaluxe/GameModes/CGameModeMedley.cs @@ -2,6 +2,9 @@ using System.Collections.Generic; using System.Text; +using Vocaluxe.Base; +using Vocaluxe.Lib.Song; + namespace Vocaluxe.GameModes { class CGameModeMedley : CGameMode @@ -13,5 +16,20 @@ namespace Vocaluxe.GameModes _GameMode = EGameMode.Medley; _Initialized = true; } + + protected override void SongManipulation(int SongIndex) + { + CSong song = _Songs[SongIndex]; + + // set medley mode timings + song.Start = CGame.GetTimeFromBeats(song.Medley.StartBeat, song.BPM) - song.Medley.FadeInTime + song.Gap; + if (song.Start < 0f) + song.Start = 0f; + + song.Finish = CGame.GetTimeFromBeats(song.Medley.EndBeat, song.BPM) + song.Medley.FadeOutTime + song.Gap; + + // set lines to medley mode + song.Notes.SetMedley(song.Medley.StartBeat, song.Medley.EndBeat); + } } } diff --git a/Vocaluxe/Lib/Song/CNotes.cs b/Vocaluxe/Lib/Song/CNotes.cs index 0396c8da..2b3045c0 100644 --- a/Vocaluxe/Lib/Song/CNotes.cs +++ b/Vocaluxe/Lib/Song/CNotes.cs @@ -15,6 +15,18 @@ namespace Vocaluxe.Lib.Song get { return _Lines.ToArray(); } } + public CNotes() + { + } + + public CNotes(CNotes notes) + { + foreach (CLines lines in notes._Lines) + { + _Lines.Add(new CLines(lines)); + } + } + public CLines GetLines(int Index) { while (Index >= _Lines.Count) @@ -54,6 +66,13 @@ namespace Vocaluxe.Lib.Song _Lines.Clear(); } + public void SetMedley(int StartBeat, int EndBeat) + { + foreach (CLines lines in _Lines) + { + lines.SetMedley(StartBeat, EndBeat); + } + } } public enum ENoteType @@ -85,6 +104,17 @@ namespace Vocaluxe.Lib.Song _Perfect = false; } + public CNote(CNote note) + { + _StartBeat = note._StartBeat; + _Duration = note._Duration; + _Tone = note._Tone; + _NoteType = note._NoteType; + _Text = note._Text; + _Hit = note._Hit; + _Perfect = note._Perfect; + } + public CNote(int StartBeat, int Duration, int Tone, string Text) : this() { @@ -245,16 +275,26 @@ namespace Vocaluxe.Lib.Song private int _EndBeat; private bool _PerfectLine; // for drawing perfect line effect - private List _Notes; + private List _Notes = new List(); #region Constructors public CLine() { - _Notes = new List(); StartBeat = int.MinValue; EndBeat = int.MaxValue; _PerfectLine = false; } + + public CLine(CLine line) + { + foreach (CNote note in line._Notes) + { + _Notes.Add(new CNote(note)); + } + _StartBeat = line._StartBeat; + _EndBeat = line._EndBeat; + _PerfectLine = line._PerfectLine; + } #endregion Constructors #region Properties @@ -475,16 +515,32 @@ namespace Vocaluxe.Lib.Song { _Notes.Clear(); } + + public void SetMedley(int StartBeat, int EndBeat) + { + foreach (CNote note in _Notes) + { + if (note.StartBeat < StartBeat || note.EndBeat > EndBeat) + note.NoteType = ENoteType.Freestyle; + } + } #endregion Methods } public class CLines { - private List _Lines; + private List _Lines = new List(); public CLines() { - _Lines = new List(); + } + + public CLines(CLines lines) + { + foreach (CLine line in lines._Lines) + { + _Lines.Add(new CLine(line)); + } } public CLine[] Line @@ -648,6 +704,13 @@ namespace Vocaluxe.Lib.Song } } + public void SetMedley(int StartBeat, int EndBeat) + { + foreach (CLine line in _Lines) + { + line.SetMedley(StartBeat, EndBeat); + } + } #endregion Methods } } diff --git a/Vocaluxe/Lib/Song/CSong.cs b/Vocaluxe/Lib/Song/CSong.cs index 3a728747..d9998e61 100644 --- a/Vocaluxe/Lib/Song/CSong.cs +++ b/Vocaluxe/Lib/Song/CSong.cs @@ -53,7 +53,7 @@ namespace Vocaluxe.Lib.Song private STexture _CoverTextureSmall = new STexture(-1); private STexture _CoverTextureBig = new STexture(-1); - private SMedley Medley = new SMedley(0); + public SMedley Medley = new SMedley(0); public bool CalculateMedley = true; public float PreviewStart = 0f; @@ -74,9 +74,7 @@ namespace Vocaluxe.Lib.Song { get { return _CoverLoaded; } } - public bool CoverBigLoaded = false; - public bool BackgroundLoaded = false; public STexture CoverTextureSmall { @@ -111,8 +109,6 @@ namespace Vocaluxe.Lib.Song set { _CoverTextureBig = value; } } - public CBackground Background = new CBackground(); - public string Title = String.Empty; public string Artist = String.Empty; @@ -143,6 +139,83 @@ namespace Vocaluxe.Lib.Song // Notes public CNotes Notes = new CNotes(); + public CSong() + { + } + + public CSong(CSong song) + { + this._CoverTextureSmall = song._CoverTextureSmall; + this._CoverTextureBig = song._CoverTextureBig; + + this.Medley = new SMedley(); + this.Medley.Source = song.Medley.Source; + this.Medley.StartBeat = song.Medley.StartBeat; + this.Medley.EndBeat = song.Medley.EndBeat; + this.Medley.FadeInTime = song.Medley.FadeInTime; + this.Medley.FadeOutTime = song.Medley.FadeOutTime; + + this.CalculateMedley = song.CalculateMedley; + this.PreviewStart = song.PreviewStart; + + this.Encoding = song.Encoding; + this.Folder = song.Folder; + this.FolderName = song.FolderName; + this.FileName = song.FileName; + + this.MP3FileName = song.MP3FileName; + this.CoverFileName = song.CoverFileName; + this.BackgroundFileName = song.BackgroundFileName; + this.VideoFileName = song.VideoFileName; + + this.VideoAspect = song.VideoAspect; + this._CoverLoaded = song._CoverLoaded; + this.CoverBigLoaded = song.CoverBigLoaded; + + this.Artist = song.Artist; + this.Title = song.Title; + + this.Start = song.Start; + this.Finish = song.Finish; + + this.BPM = song.BPM; + this.Gap = song.Gap; + this.VideoGap = song.VideoGap; + + this.Comment = new List(); + foreach (string value in song.Comment) + { + this.Comment.Add(value); + } + + this.ID = song.ID; + this.Visible = song.Visible; + this.CatIndex = song.CatIndex; + this.Selected = song.Selected; + + this.Edition = new List(); + foreach (string value in song.Edition) + { + this.Edition.Add(value); + } + + this.Genre = new List(); + foreach (string value in song.Genre) + { + this.Genre.Add(value); + } + + this.Year = song.Year; + + this.Language = new List(); + foreach (string value in song.Language) + { + this.Language.Add(value); + } + + this.Notes = new CNotes(song.Notes); + } + public string GetMP3() { return Path.Combine(Folder, MP3FileName); @@ -418,7 +491,7 @@ namespace Vocaluxe.Lib.Song { this.Medley.Source = EMedleySource.Tag; this.Medley.FadeInTime = CSettings.DefaultMedleyFadeInTime; - this.Medley.FadeOutTime = CSettings.DefaultMedleyFadeOutTIme; + this.Medley.FadeOutTime = CSettings.DefaultMedleyFadeOutTime; } #endregion check medley tags @@ -644,6 +717,12 @@ namespace Vocaluxe.Lib.Song private void FindRefrain() { + if (this.IsDuet) + { + this.Medley.Source = EMedleySource.None; + return; + } + if (this.Medley.Source == EMedleySource.Tag) return; @@ -735,7 +814,7 @@ namespace Vocaluxe.Lib.Song { this.Medley.Source = EMedleySource.Calculated; this.Medley.FadeInTime = CSettings.DefaultMedleyFadeInTime; - this.Medley.FadeOutTime = CSettings.DefaultMedleyFadeOutTIme; + this.Medley.FadeOutTime = CSettings.DefaultMedleyFadeOutTime; } } diff --git a/Vocaluxe/Screens/CScreenSong.cs b/Vocaluxe/Screens/CScreenSong.cs index abc609de..356edf80 100644 --- a/Vocaluxe/Screens/CScreenSong.cs +++ b/Vocaluxe/Screens/CScreenSong.cs @@ -8,6 +8,7 @@ using System.Windows.Forms; using Vocaluxe.Base; using Vocaluxe.Lib.Draw; +using Vocaluxe.Lib.Song; using Vocaluxe.Menu; using Vocaluxe.Menu.SongMenu; @@ -133,6 +134,11 @@ namespace Vocaluxe.Screens SongMenus[htSongMenus(SongMenu)].SetSelectedSong(CSongs.GetRandomSong()); } break; + + case Keys.S: + if (CSongs.NumVisibleSongs > 0) + StartMedleySong(SongMenus[htSongMenus(SongMenu)].GetSelectedSong()); + break; } } @@ -234,6 +240,23 @@ namespace Vocaluxe.Screens } } + private void StartMedleySong(int SongNr) + { + if ((CSongs.Category >= 0) && (SongNr >= 0)) + { + if (CSongs.VisibleSongs[SongNr].Medley.Source != EMedleySource.None) + CGame.SetGameMode(GameModes.EGameMode.Medley); + else + return; + + CGame.Reset(); + CGame.ClearSongs(); + CGame.AddVisibleSong(SongNr); + + CGraphics.FadeTo(EScreens.ScreenNames); + } + } + private void StartRandomAllSongs() { CGame.Reset();