Merge branch 'release-0.3' into develop

Conflicts:
	VocaluxeLib/Menu/SongMenu/CSongMenuFramework.cs
This commit is contained in:
Flamefire committed 2013-10-19 02:12:29 +02:00
commit dbcd79af79
5 files changed
+65 -101

No files matched your search

+1 -1
View File
@@ -658,7 +658,7 @@ namespace Vocaluxe.Screens
CBackgroundMusic.Disabled = false; CBackgroundMusic.Disabled = false;
int song = _SongMenus[_SongMenu].GetActualSelection(); int song = _SongMenus[_SongMenu].GetActualSelection();
if ((CSongs.Category >= 0 || CConfig.Tabs == EOffOn.TR_CONFIG_OFF) && song >= 0 && song < CSongs.VisibleSongs.Count) if ((CSongs.IsInCategory || CConfig.Tabs == EOffOn.TR_CONFIG_OFF) && song >= 0 && song < CSongs.VisibleSongs.Count)
_Texts[_TextSelection].Text = CSongs.VisibleSongs[song].Artist + " - " + CSongs.VisibleSongs[song].Title; _Texts[_TextSelection].Text = CSongs.VisibleSongs[song].Artist + " - " + CSongs.VisibleSongs[song].Title;
else if (!CSongs.IsInCategory && song >= 0 && song < CSongs.Categories.Count) else if (!CSongs.IsInCategory && song >= 0 && song < CSongs.Categories.Count)
_Texts[_TextSelection].Text = CSongs.Categories[song].Name; _Texts[_TextSelection].Text = CSongs.Categories[song].Name;
+1 -6
View File
@@ -47,7 +47,7 @@ namespace VocaluxeLib.Menu.SongMenu
public SRectF Rect public SRectF Rect
{ {
get { return _SongMenu.GetRect(); } get { return _SongMenu.Rect; }
} }
#region ISongMenu #region ISongMenu
@@ -156,11 +156,6 @@ namespace VocaluxeLib.Menu.SongMenu
_SongMenu.SetVisible(visible); _SongMenu.SetVisible(visible);
} }
public SRectF GetRect()
{
return _SongMenu.GetRect();
}
public bool IsSmallView() public bool IsSmallView()
{ {
return _SongMenu.IsSmallView(); return _SongMenu.IsSmallView();
+48 -72
View File
@@ -101,52 +101,38 @@ namespace VocaluxeLib.Menu.SongMenu
private readonly Stopwatch _VideoFadeTimer = new Stopwatch(); private readonly Stopwatch _VideoFadeTimer = new Stopwatch();
private readonly List<int> _Streams = new List<int>(); private readonly List<int> _Streams = new List<int>();
private int _ActSongId = -1;
private int _Actsongstream = -1;
protected CTexture _Vidtex; protected CTexture _Vidtex;
protected bool _Initialized; protected bool _Initialized;
protected int _LastKnownNumSongs; protected int _LastKnownNumSongs;
protected int _LastKnownCategory = -1; protected int _LastKnownCategory = -1;
protected SRectF _Rect;
protected SColorF _Color; protected SColorF _Color;
protected bool _Active; protected bool _Active;
protected float _MaxVolume = 100f; protected float _MaxVolume = 100f;
protected virtual int _PreviewId { get; set; } //the real selected song for singing
protected int _Locked { get; set; }
private int _LockedInternal = -1; private int _PreviewIdInternal = -1;
protected int _Locked protected virtual int _PreviewId
{ {
//the real selected song for singing get { return _PreviewIdInternal; }
get { return _LockedInternal; } set
set { _LockedInternal = value; } {
//Do this first, otherwhise song will restart
_PlaySong(value);
_PreviewIdInternal = value;
}
} }
protected int _SongStream protected int _PreviewSongStream { get; private set; }
{
get { return _Actsongstream; }
}
protected int _Video { get; private set; } protected int _PreviewVideoStream { get; private set; }
protected int _ActSong public SRectF Rect { get; protected set; }
{
get { return _ActSongId; }
}
public SRectF Rect
{
get { return _Rect; }
}
public SRectF GetRect()
{
return _Rect;
}
public SColorF Color public SColorF Color
{ {
@@ -155,7 +141,7 @@ namespace VocaluxeLib.Menu.SongMenu
public virtual int GetActualSelection() public virtual int GetActualSelection()
{ {
return _ActSongId; return -1;
} }
private bool _Selected; private bool _Selected;
@@ -185,7 +171,9 @@ namespace VocaluxeLib.Menu.SongMenu
protected CSongMenuFramework(int partyModeID) protected CSongMenuFramework(int partyModeID)
{ {
_PartyModeID = partyModeID; _PartyModeID = partyModeID;
_Video = -1; _PreviewVideoStream = -1;
_PreviewSongStream = -1;
_Locked = -1;
_Theme = new SThemeSongMenu _Theme = new SThemeSongMenu
{ {
SongMenuTileBoard = SongMenuTileBoard =
@@ -374,7 +362,7 @@ namespace VocaluxeLib.Menu.SongMenu
public void UpdateRect(SRectF rect) public void UpdateRect(SRectF rect)
{ {
_Rect = rect; Rect = rect;
Init(); Init();
} }
@@ -383,23 +371,20 @@ namespace VocaluxeLib.Menu.SongMenu
if (!_Initialized) if (!_Initialized)
return; return;
if (_ActSongId != _PreviewId) if (_Streams.Count <= 0 || _PreviewVideoStream == -1)
_SelectSong(_PreviewId);
if (_Streams.Count <= 0 || _Video == -1)
return; return;
if (CBase.Video.IsFinished(_Video) || CBase.Sound.IsFinished(_Actsongstream)) if (CBase.Video.IsFinished(_PreviewVideoStream) || CBase.Sound.IsFinished(_PreviewSongStream))
{ {
CBase.Video.Close(_Video); CBase.Video.Close(_PreviewVideoStream);
_Video = -1; _PreviewVideoStream = -1;
return; return;
} }
float time = CBase.Sound.GetPosition(_Actsongstream); float time = CBase.Sound.GetPosition(_PreviewSongStream);
float vtime; float vtime;
if (CBase.Video.GetFrame(_Video, ref _Vidtex, time, out vtime)) if (CBase.Video.GetFrame(_PreviewVideoStream, ref _Vidtex, time, out vtime))
{ {
if (_Vidtex != null) if (_Vidtex != null)
{ {
@@ -416,7 +401,7 @@ namespace VocaluxeLib.Menu.SongMenu
public virtual void OnShow() public virtual void OnShow()
{ {
_Actsongstream = -1; _PreviewSongStream = -1;
_Vidtex = null; _Vidtex = null;
ApplyVolume(CBase.Config.GetPreviewMusicVolume()); ApplyVolume(CBase.Config.GetPreviewMusicVolume());
} }
@@ -435,7 +420,7 @@ namespace VocaluxeLib.Menu.SongMenu
if (!_Initialized || !_Visible) if (!_Initialized || !_Visible)
return; return;
if (_Video != -1) if (_PreviewVideoStream != -1)
CBase.Drawing.DrawTexture(_Vidtex, new SRectF(0, 0, 1280, 720, 0)); CBase.Drawing.DrawTexture(_Vidtex, new SRectF(0, 0, 1280, 720, 0));
} }
@@ -538,53 +523,44 @@ namespace VocaluxeLib.Menu.SongMenu
CBase.Songs.SetCategory(-1); CBase.Songs.SetCategory(-1);
} }
public void ApplyVolume() private void _PlaySong(int nr)
{ {
CBase.Sound.SetStreamVolume(_Actsongstream, CBase.Config.GetPreviewMusicVolume()); if (CBase.Songs.IsInCategory() && (_PreviewId != nr || _Streams.Count == 0))
}
protected void _SelectSong(int nr)
{
if (CBase.Songs.IsInCategory() && (CBase.Songs.GetNumSongsVisible() > 0) && (nr >= 0) && ((_ActSongId != nr) || (_Streams.Count == 0)))
{ {
_Streams.ForEach(soundStream => CBase.Sound.FadeAndStop(soundStream, 0f, 1f)); _Reset();
_Streams.Clear();
CBase.Video.Close(_Video); CSong song = CBase.Songs.GetVisibleSong(nr);
_Video = -1; if (song == null)
return;
CBase.Drawing.RemoveTexture(ref _Vidtex); int stream = CBase.Sound.Load(Path.Combine(song.Folder, song.MP3FileName), true);
_ActSongId = nr;
if (_ActSongId >= CBase.Songs.GetNumSongsVisible())
_ActSongId = 0;
CSong actSong = CBase.Songs.GetVisibleSong(_ActSongId);
int stream = CBase.Sound.Load(Path.Combine(actSong.Folder, actSong.MP3FileName), true);
CBase.Sound.SetStreamVolumeMax(stream, _MaxVolume); CBase.Sound.SetStreamVolumeMax(stream, _MaxVolume);
CBase.Sound.SetStreamVolume(stream, 0f); CBase.Sound.SetStreamVolume(stream, 0f);
float startposition = actSong.Preview.StartTime; float startposition = song.Preview.StartTime;
float length = CBase.Sound.GetLength(stream);
if (actSong.Preview.Source == EDataSource.None) if (song.Preview.Source == EDataSource.None)
startposition = CBase.Sound.GetLength(stream) / 4f; startposition = length / 4f;
else if (startposition > length - 5f)
startposition = Math.Max(0f, Math.Min(length / 4f, length - 5f));
if (startposition >= 0.5f) if (startposition >= 0.5f)
startposition -= 0.5f; startposition -= 0.5f;
CBase.Sound.SetPosition(stream, startposition); CBase.Sound.SetPosition(stream, startposition);
CBase.Sound.Play(stream); CBase.Sound.Play(stream);
CBase.Sound.SetStreamVolumeMax(stream, CBase.Config.GetPreviewMusicVolume());
CBase.Sound.Fade(stream, 100f, 3f); CBase.Sound.Fade(stream, 100f, 3f);
_Streams.Add(stream); _Streams.Add(stream);
_Actsongstream = stream; _PreviewSongStream = stream;
if (actSong.VideoFileName != "" && CBase.Config.GetVideoPreview() == EOffOn.TR_CONFIG_ON) if (song.VideoFileName != "" && CBase.Config.GetVideoPreview() == EOffOn.TR_CONFIG_ON)
{ {
_Video = CBase.Video.Load(Path.Combine(actSong.Folder, actSong.VideoFileName)); _PreviewVideoStream = CBase.Video.Load(Path.Combine(song.Folder, song.VideoFileName));
if (_Video == -1) if (_PreviewVideoStream == -1)
return; return;
CBase.Video.Skip(_Video, startposition, actSong.VideoGap); CBase.Video.Skip(_PreviewVideoStream, startposition, song.VideoGap);
_VideoFadeTimer.Stop(); _VideoFadeTimer.Stop();
_VideoFadeTimer.Reset(); _VideoFadeTimer.Reset();
_VideoFadeTimer.Start(); _VideoFadeTimer.Start();
@@ -598,8 +574,8 @@ namespace VocaluxeLib.Menu.SongMenu
CBase.Sound.FadeAndStop(stream, 0f, 0.75f); CBase.Sound.FadeAndStop(stream, 0f, 0.75f);
_Streams.Clear(); _Streams.Clear();
CBase.Video.Close(_Video); CBase.Video.Close(_PreviewVideoStream);
_Video = -1; _PreviewVideoStream = -1;
CBase.Drawing.RemoveTexture(ref _Vidtex); CBase.Drawing.RemoveTexture(ref _Vidtex);
} }
+14 -21
View File
@@ -79,7 +79,7 @@ namespace VocaluxeLib.Menu.SongMenu
{ {
base.Init(); base.Init();
_Rect = _Theme.SongMenuTileBoard.TileRect; Rect = _Theme.SongMenuTileBoard.TileRect;
_NumW = _Theme.SongMenuTileBoard.NumW; _NumW = _Theme.SongMenuTileBoard.NumW;
_NumH = _Theme.SongMenuTileBoard.NumH; _NumH = _Theme.SongMenuTileBoard.NumH;
@@ -98,7 +98,7 @@ namespace VocaluxeLib.Menu.SongMenu
for (int j = 0; j < _NumW; j++) for (int j = 0; j < _NumW; j++)
{ {
var rect = new SRectF(_Theme.SongMenuTileBoard.TileRect.X + j * (_TileW + _SpaceW), var rect = new SRectF(_Theme.SongMenuTileBoard.TileRect.X + j * (_TileW + _SpaceW),
_Theme.SongMenuTileBoard.TileRect.Y + i * (_TileH + _SpaceH), _TileW, _TileH, _Rect.Z); _Theme.SongMenuTileBoard.TileRect.Y + i * (_TileH + _SpaceH), _TileW, _TileH, Rect.Z);
var tile = new CStatic(_PartyModeID, _CoverTexture, Color, rect); var tile = new CStatic(_PartyModeID, _CoverTexture, Color, rect);
_Tiles.Add(tile); _Tiles.Add(tile);
} }
@@ -173,7 +173,7 @@ namespace VocaluxeLib.Menu.SongMenu
_MedleyCalcIcon.Visible = song.Medley.Source == EDataSource.Calculated; _MedleyCalcIcon.Visible = song.Medley.Source == EDataSource.Calculated;
_MedleyTagIcon.Visible = song.Medley.Source == EDataSource.Tag; _MedleyTagIcon.Visible = song.Medley.Source == EDataSource.Tag;
float time = CBase.Sound.GetLength(_SongStream); float time = CBase.Sound.GetLength(_PreviewSongStream);
if (Math.Abs(song.Finish) > 0.001) if (Math.Abs(song.Finish) > 0.001)
time = song.Finish; time = song.Finish;
@@ -192,12 +192,8 @@ namespace VocaluxeLib.Menu.SongMenu
_Artist.Text = category.Name; _Artist.Text = category.Name;
int num = category.GetNumSongsNotSung(); int num = category.GetNumSongsNotSung();
// ReSharper disable ConvertIfStatementToConditionalTernaryExpression String songOrSongs = (num == 1) ? "TR_SCREENSONG_NUMSONG" : "TR_SCREENSONG_NUMSONGS";
if (num != 1) _Title.Text = CBase.Language.Translate(songOrSongs).Replace("%v", num.ToString());
// ReSharper restore ConvertIfStatementToConditionalTernaryExpression
_Title.Text = CBase.Language.Translate("TR_SCREENSONG_NUMSONGS").Replace("%v", num.ToString());
else
_Title.Text = CBase.Language.Translate("TR_SCREENSONG_NUMSONG").Replace("%v", num.ToString());
} }
} }
@@ -210,7 +206,7 @@ namespace VocaluxeLib.Menu.SongMenu
_PreviewId = -1; _PreviewId = -1;
_UpdateList(0, true); _UpdateList(0, true);
//AfterCategoryChange(); //AfterCategoryChange();
SetSelectedSong(_ActSong); SetSelectedSong(_PreviewId);
_AfterCategoryChange(); _AfterCategoryChange();
if (_PreviewId < 0) if (_PreviewId < 0)
@@ -374,7 +370,7 @@ namespace VocaluxeLib.Menu.SongMenu
bool sel = false; bool sel = false;
int lastselection = _ActualSelection; int lastselection = _ActualSelection;
if (!songOptions.Selection.RandomOnly || !CBase.Songs.IsInCategory() && songOptions.Selection.CategoryChangeAllowed) if (!songOptions.Selection.RandomOnly || (!CBase.Songs.IsInCategory() && songOptions.Selection.CategoryChangeAllowed))
{ {
foreach (CStatic tile in _Tiles) foreach (CStatic tile in _Tiles)
{ {
@@ -455,7 +451,7 @@ namespace VocaluxeLib.Menu.SongMenu
_TextBG.Draw(); _TextBG.Draw();
if (_Vidtex != null && _Video != -1) if (_Vidtex != null && _PreviewVideoStream != -1)
{ {
if (_Vidtex.Color.A < 1) if (_Vidtex.Color.A < 1)
_CoverBig.Draw(1f, EAspect.Crop); _CoverBig.Draw(1f, EAspect.Crop);
@@ -595,9 +591,6 @@ namespace VocaluxeLib.Menu.SongMenu
private void _AfterCategoryChange() private void _AfterCategoryChange()
{ {
_SelectSong(_PreviewId);
_UpdatePreview();
foreach (CStatic tile in _Tiles) foreach (CStatic tile in _Tiles)
tile.Selected = false; tile.Selected = false;
@@ -658,17 +651,17 @@ namespace VocaluxeLib.Menu.SongMenu
{ {
_NumH = _Theme.SongMenuTileBoard.NumHsmall; _NumH = _Theme.SongMenuTileBoard.NumHsmall;
_NumW = _Theme.SongMenuTileBoard.NumWsmall; _NumW = _Theme.SongMenuTileBoard.NumWsmall;
_Rect = _Theme.SongMenuTileBoard.TileRectSmall; Rect = _Theme.SongMenuTileBoard.TileRectSmall;
} }
else else
{ {
_NumH = _Theme.SongMenuTileBoard.NumH; _NumH = _Theme.SongMenuTileBoard.NumH;
_NumW = _Theme.SongMenuTileBoard.NumW; _NumW = _Theme.SongMenuTileBoard.NumW;
_Rect = _Theme.SongMenuTileBoard.TileRect; Rect = _Theme.SongMenuTileBoard.TileRect;
} }
_TileW = (int)((_Rect.W - _SpaceW * (_NumW - 1)) / _NumW); _TileW = (int)((Rect.W - _SpaceW * (_NumW - 1)) / _NumW);
_TileH = (int)((_Rect.H - _SpaceH * (_NumH - 1)) / _NumH); _TileH = (int)((Rect.H - _SpaceH * (_NumH - 1)) / _NumH);
_CoverTexture = CBase.Theme.GetSkinTexture(_Theme.CoverBackgroundName, _PartyModeID); _CoverTexture = CBase.Theme.GetSkinTexture(_Theme.CoverBackgroundName, _PartyModeID);
_CoverBigTexture = CBase.Theme.GetSkinTexture(_Theme.CoverBigBackgroundName, _PartyModeID); _CoverBigTexture = CBase.Theme.GetSkinTexture(_Theme.CoverBigBackgroundName, _PartyModeID);
@@ -678,13 +671,13 @@ namespace VocaluxeLib.Menu.SongMenu
{ {
for (int j = 0; j < _NumW; j++) for (int j = 0; j < _NumW; j++)
{ {
var rect = new SRectF(_Rect.X + j * (_TileW + _SpaceW), _Rect.Y + i * (_TileH + _SpaceH), _TileW, _TileH, _Rect.Z); var rect = new SRectF(Rect.X + j * (_TileW + _SpaceW), Rect.Y + i * (_TileH + _SpaceH), _TileW, _TileH, Rect.Z);
var tile = new CStatic(_PartyModeID, _CoverTexture, Color, rect); var tile = new CStatic(_PartyModeID, _CoverTexture, Color, rect);
_Tiles.Add(tile); _Tiles.Add(tile);
} }
} }
_ScrollRect = new SRectF(0, 0, CBase.Settings.GetRenderW(), CBase.Settings.GetRenderH(), _Rect.Z); _ScrollRect = new SRectF(0, 0, CBase.Settings.GetRenderW(), CBase.Settings.GetRenderH(), Rect.Z);
_UpdateList(true); _UpdateList(true);
} }
+1 -1
View File
@@ -55,6 +55,6 @@ namespace VocaluxeLib.Menu.SongMenu
bool IsSmallView(); bool IsSmallView();
void SetSmallView(bool smallView); void SetSmallView(bool smallView);
SRectF GetRect(); SRectF Rect { get; }
} }
} }