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;
|
||||
[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":
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -57,6 +57,7 @@ namespace VocaluxeLib
|
||||
ESongSorting GetSongSorting();
|
||||
EOffOn GetTabs();
|
||||
EOffOn GetAutoplayPreviews();
|
||||
int GetAutoplayPreviewDelay();
|
||||
EOffOn GetIgnoreArticles();
|
||||
|
||||
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;
|
||||
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)
|
||||
{
|
||||
|
||||
@@ -64,9 +64,6 @@ namespace VocaluxeLib.Menu.SongMenu
|
||||
|
||||
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
|
||||
{
|
||||
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();
|
||||
|
||||
@@ -60,9 +60,6 @@ namespace VocaluxeLib.Menu.SongMenu
|
||||
|
||||
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
|
||||
{
|
||||
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();
|
||||
|
||||
Reference in new issue
Block a user