Code move and delay made configurable
Moved code to CSongMenuFramework and made autoplay-delay configurable in config.xml as suggested in code review.
This commit is contained in:
1 parent
dad5f5ec11
commit
2fbb600272
6 files changed
+49
-70
No files matched your search
@@ -172,6 +172,7 @@ namespace Vocaluxe.Base
|
|||||||
[XmlAltName("NumPlayer"), DefaultValue(2)] public int NumPlayers;
|
[XmlAltName("NumPlayer"), DefaultValue(2)] public int NumPlayers;
|
||||||
[DefaultValue(EOffOn.TR_CONFIG_OFF)] public EOffOn Tabs;
|
[DefaultValue(EOffOn.TR_CONFIG_OFF)] public EOffOn Tabs;
|
||||||
[DefaultValue(EOffOn.TR_CONFIG_OFF)] public EOffOn AutoplayPreviews;
|
[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(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)
|
[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;
|
[XmlArrayItem("Player"), XmlArray] public string[] Players;
|
||||||
@@ -524,6 +525,8 @@ namespace Vocaluxe.Base
|
|||||||
return "Order songs in tabs: " + CHelper.ListStrings(Enum.GetNames(typeof(EOffOn)));
|
return "Order songs in tabs: " + CHelper.ListStrings(Enum.GetNames(typeof(EOffOn)));
|
||||||
case "AutoplayPreviews":
|
case "AutoplayPreviews":
|
||||||
return "Automatically play song preview when selected: " + CHelper.ListStrings(Enum.GetNames(typeof(EOffOn)));
|
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":
|
case "LyricsPosition":
|
||||||
return "Position if lyrics on screen: " + CHelper.ListStrings(Enum.GetNames(typeof(ELyricsPosition)));
|
return "Position if lyrics on screen: " + CHelper.ListStrings(Enum.GetNames(typeof(ELyricsPosition)));
|
||||||
case "MinLineBreakTime":
|
case "MinLineBreakTime":
|
||||||
|
|||||||
@@ -146,6 +146,11 @@ namespace Vocaluxe.Base
|
|||||||
return CConfig.Config.Game.AutoplayPreviews;
|
return CConfig.Config.Game.AutoplayPreviews;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int GetAutoplayPreviewDelay()
|
||||||
|
{
|
||||||
|
return CConfig.Config.Game.AutoplayPreviewDelay;
|
||||||
|
}
|
||||||
|
|
||||||
public EOffOn GetIgnoreArticles()
|
public EOffOn GetIgnoreArticles()
|
||||||
{
|
{
|
||||||
return CConfig.Config.Game.IgnoreArticles;
|
return CConfig.Config.Game.IgnoreArticles;
|
||||||
|
|||||||
@@ -57,6 +57,7 @@ namespace VocaluxeLib
|
|||||||
ESongSorting GetSongSorting();
|
ESongSorting GetSongSorting();
|
||||||
EOffOn GetTabs();
|
EOffOn GetTabs();
|
||||||
EOffOn GetAutoplayPreviews();
|
EOffOn GetAutoplayPreviews();
|
||||||
|
int GetAutoplayPreviewDelay();
|
||||||
EOffOn GetIgnoreArticles();
|
EOffOn GetIgnoreArticles();
|
||||||
|
|
||||||
bool IsMicConfigured(int playerNr);
|
bool IsMicConfigured(int playerNr);
|
||||||
|
|||||||
@@ -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;
|
private SColorF _ColorInternal;
|
||||||
protected SColorF _Color
|
protected SColorF _Color
|
||||||
{
|
{
|
||||||
@@ -204,6 +207,7 @@ namespace VocaluxeLib.Menu.SongMenu
|
|||||||
public virtual void Init()
|
public virtual void Init()
|
||||||
{
|
{
|
||||||
_ResetPreview(false);
|
_ResetPreview(false);
|
||||||
|
_InitializeAutoplayTimer();
|
||||||
_Initialized = true;
|
_Initialized = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -358,6 +362,42 @@ namespace VocaluxeLib.Menu.SongMenu
|
|||||||
_PreviewNrInternal = -1;
|
_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
|
#region ThemeEdit
|
||||||
public void MoveElement(int stepX, int stepY)
|
public void MoveElement(int stepX, int stepY)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -64,9 +64,6 @@ namespace VocaluxeLib.Menu.SongMenu
|
|||||||
|
|
||||||
private readonly List<IMenuElement> _SubElements = new List<IMenuElement>();
|
private readonly List<IMenuElement> _SubElements = new List<IMenuElement>();
|
||||||
|
|
||||||
private int _AutoplayDelay = 500;
|
|
||||||
private System.Timers.Timer _AutoplayTimer = new System.Timers.Timer();
|
|
||||||
|
|
||||||
public override float SelectedTileZoomFactor
|
public override float SelectedTileZoomFactor
|
||||||
{
|
{
|
||||||
get { return 1.2f; }
|
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()
|
private void _UpdateListIfRequired()
|
||||||
{
|
{
|
||||||
int curElements = CBase.Songs.IsInCategory() ? CBase.Songs.GetNumSongsVisible() : CBase.Songs.GetNumCategories();
|
int curElements = CBase.Songs.IsInCategory() ? CBase.Songs.GetNumSongsVisible() : CBase.Songs.GetNumCategories();
|
||||||
|
|||||||
@@ -60,9 +60,6 @@ namespace VocaluxeLib.Menu.SongMenu
|
|||||||
|
|
||||||
private readonly List<IMenuElement> _SubElements = new List<IMenuElement>();
|
private readonly List<IMenuElement> _SubElements = new List<IMenuElement>();
|
||||||
|
|
||||||
private int _AutoplayDelay = 500;
|
|
||||||
private System.Timers.Timer _AutoplayTimer = new System.Timers.Timer();
|
|
||||||
|
|
||||||
public override float SelectedTileZoomFactor
|
public override float SelectedTileZoomFactor
|
||||||
{
|
{
|
||||||
get { return 1.2f; }
|
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()
|
private void _UpdateListIfRequired()
|
||||||
{
|
{
|
||||||
int curElements = CBase.Songs.IsInCategory() ? CBase.Songs.GetNumSongsVisible() : CBase.Songs.GetNumCategories();
|
int curElements = CBase.Songs.IsInCategory() ? CBase.Songs.GetNumSongsVisible() : CBase.Songs.GetNumCategories();
|
||||||
|
|||||||
Reference in new issue
Block a user