diff --git a/Vocaluxe/Base/CConfig.cs b/Vocaluxe/Base/CConfig.cs index d90c6395..d80e0024 100644 --- a/Vocaluxe/Base/CConfig.cs +++ b/Vocaluxe/Base/CConfig.cs @@ -172,6 +172,7 @@ namespace Vocaluxe.Base [XmlAltName("NumPlayer"), DefaultValue(2)] public int NumPlayers; [DefaultValue(EOffOn.TR_CONFIG_OFF)] public EOffOn Tabs; [DefaultValue(EOffOn.TR_CONFIG_OFF)] public EOffOn AutoplayPreviews; + [XmlAltName("AutoplayPreviewDelay"), DefaultValue(500)] public int AutoplayPreviewDelay; [DefaultValue(ELyricsPosition.TR_CONFIG_LYRICSPOSITION_BOTTOM)] public ELyricsPosition LyricsPosition; [DefaultValue(0.1f)] public float MinLineBreakTime; //Minimum time to show the text before it is (to be) sung (if possible) [XmlArrayItem("Player"), XmlArray] public string[] Players; @@ -524,6 +525,8 @@ namespace Vocaluxe.Base return "Order songs in tabs: " + CHelper.ListStrings(Enum.GetNames(typeof(EOffOn))); case "AutoplayPreviews": return "Automatically play song preview when selected: " + CHelper.ListStrings(Enum.GetNames(typeof(EOffOn))); + case "AutoplayPreviewDelay": + return "Delay before playback of autoplay previews is started in milliseconds"; case "LyricsPosition": return "Position if lyrics on screen: " + CHelper.ListStrings(Enum.GetNames(typeof(ELyricsPosition))); case "MinLineBreakTime": diff --git a/Vocaluxe/Base/CMain.cs b/Vocaluxe/Base/CMain.cs index 9d33cb37..41f79bb2 100644 --- a/Vocaluxe/Base/CMain.cs +++ b/Vocaluxe/Base/CMain.cs @@ -146,6 +146,11 @@ namespace Vocaluxe.Base return CConfig.Config.Game.AutoplayPreviews; } + public int GetAutoplayPreviewDelay() + { + return CConfig.Config.Game.AutoplayPreviewDelay; + } + public EOffOn GetIgnoreArticles() { return CConfig.Config.Game.IgnoreArticles; diff --git a/VocaluxeLib/IBasic.cs b/VocaluxeLib/IBasic.cs index 6d2706dd..8eb73b2b 100644 --- a/VocaluxeLib/IBasic.cs +++ b/VocaluxeLib/IBasic.cs @@ -57,6 +57,7 @@ namespace VocaluxeLib ESongSorting GetSongSorting(); EOffOn GetTabs(); EOffOn GetAutoplayPreviews(); + int GetAutoplayPreviewDelay(); EOffOn GetIgnoreArticles(); bool IsMicConfigured(int playerNr); diff --git a/VocaluxeLib/Menu/SongMenu/CSongMenuFramework.cs b/VocaluxeLib/Menu/SongMenu/CSongMenuFramework.cs index d4328025..ecd41bb8 100644 --- a/VocaluxeLib/Menu/SongMenu/CSongMenuFramework.cs +++ b/VocaluxeLib/Menu/SongMenu/CSongMenuFramework.cs @@ -158,6 +158,9 @@ namespace VocaluxeLib.Menu.SongMenu } } + protected int _AutoplayDelayinMs = CBase.Config.GetAutoplayPreviewDelay(); + protected System.Timers.Timer _AutoplayTimer = new System.Timers.Timer(); + private SColorF _ColorInternal; protected SColorF _Color { @@ -204,6 +207,7 @@ namespace VocaluxeLib.Menu.SongMenu public virtual void Init() { _ResetPreview(false); + _InitializeAutoplayTimer(); _Initialized = true; } @@ -358,6 +362,42 @@ namespace VocaluxeLib.Menu.SongMenu _PreviewNrInternal = -1; } + protected void _PreviewSelectedSong() + { + _PreviewNr = _SelectionNr; + } + + protected void _InitializeAutoplayTimer() + { + _AutoplayTimer.Interval = _AutoplayDelayinMs; + _AutoplayTimer.AutoReset = false; + _AutoplayTimer.Elapsed += (object sender, System.Timers.ElapsedEventArgs e) => + { + _PreviewSelectedSong(); + }; + } + + protected void _AutoplayPreviewIfEnabled() + { + if (CBase.Config.GetAutoplayPreviews() == EOffOn.TR_CONFIG_ON) + { + _PlayPreviewAfterDelay(); + } + } + + protected void _PlayPreviewAfterDelay() + { + if (!_AutoplayTimer.Enabled) + { + _AutoplayTimer.Start(); + } + else + { + _AutoplayTimer.Stop(); + _AutoplayTimer.Start(); + } + } + #region ThemeEdit public void MoveElement(int stepX, int stepY) { diff --git a/VocaluxeLib/Menu/SongMenu/CSongMenuList.cs b/VocaluxeLib/Menu/SongMenu/CSongMenuList.cs index fc0befc5..2c85058a 100644 --- a/VocaluxeLib/Menu/SongMenu/CSongMenuList.cs +++ b/VocaluxeLib/Menu/SongMenu/CSongMenuList.cs @@ -64,9 +64,6 @@ namespace VocaluxeLib.Menu.SongMenu private readonly List _SubElements = new List(); - private int _AutoplayDelay = 500; - private System.Timers.Timer _AutoplayTimer = new System.Timers.Timer(); - public override float SelectedTileZoomFactor { get { return 1.2f; } @@ -581,38 +578,6 @@ namespace VocaluxeLib.Menu.SongMenu } } - private void _PreviewSelectedSong() - { - _PreviewNr = _SelectionNr; - } - - private void _AutoplayPreviewIfEnabled() - { - if (CBase.Config.GetAutoplayPreviews() == EOffOn.TR_CONFIG_ON) - { - _PlayPreviewAfterDelay(_AutoplayDelay); - } - } - - private void _PlayPreviewAfterDelay(double delay) - { - if (!_AutoplayTimer.Enabled) - { - _AutoplayTimer = new System.Timers.Timer(delay); - _AutoplayTimer.AutoReset = false; - _AutoplayTimer.Elapsed += (object sender, System.Timers.ElapsedEventArgs e) => - { - _PreviewSelectedSong(); - }; - _AutoplayTimer.Start(); - } - else - { - _AutoplayTimer.Stop(); - _AutoplayTimer.Start(); - } - } - private void _UpdateListIfRequired() { int curElements = CBase.Songs.IsInCategory() ? CBase.Songs.GetNumSongsVisible() : CBase.Songs.GetNumCategories(); diff --git a/VocaluxeLib/Menu/SongMenu/CSongMenuTileBoard.cs b/VocaluxeLib/Menu/SongMenu/CSongMenuTileBoard.cs index 7d7bb0fe..18bcad8f 100644 --- a/VocaluxeLib/Menu/SongMenu/CSongMenuTileBoard.cs +++ b/VocaluxeLib/Menu/SongMenu/CSongMenuTileBoard.cs @@ -60,9 +60,6 @@ namespace VocaluxeLib.Menu.SongMenu private readonly List _SubElements = new List(); - private int _AutoplayDelay = 500; - private System.Timers.Timer _AutoplayTimer = new System.Timers.Timer(); - public override float SelectedTileZoomFactor { get { return 1.2f; } @@ -544,38 +541,6 @@ namespace VocaluxeLib.Menu.SongMenu } } - private void _PreviewSelectedSong() - { - _PreviewNr = _SelectionNr; - } - - private void _AutoplayPreviewIfEnabled() - { - if (CBase.Config.GetAutoplayPreviews() == EOffOn.TR_CONFIG_ON) - { - _PlayPreviewAfterDelay(_AutoplayDelay); - } - } - - private void _PlayPreviewAfterDelay(double delay) - { - if (!_AutoplayTimer.Enabled) - { - _AutoplayTimer = new System.Timers.Timer(delay); - _AutoplayTimer.AutoReset = false; - _AutoplayTimer.Elapsed += (object sender, System.Timers.ElapsedEventArgs e) => - { - _PreviewSelectedSong(); - }; - _AutoplayTimer.Start(); - } - else - { - _AutoplayTimer.Stop(); - _AutoplayTimer.Start(); - } - } - private void _UpdateListIfRequired() { int curElements = CBase.Songs.IsInCategory() ? CBase.Songs.GetNumSongsVisible() : CBase.Songs.GetNumCategories();