Fix for inconsistent song Menu
Multiple refactoring due to ambiguous meanings
This commit is contained in:
1 parent
155718456c
commit
3b82d5c13c
8 files changed
+180
-144
No files matched your search
@@ -248,7 +248,7 @@ namespace VocaluxeLib.PartyModes.TicTacToe
|
||||
|
||||
public override void DataFromScreen(string screenName, Object data)
|
||||
{
|
||||
SDataFromScreen dataFrom = new SDataFromScreen();
|
||||
var dataFrom = new SDataFromScreen();
|
||||
switch (screenName)
|
||||
{
|
||||
case "PartyScreenTicTacToeConfig":
|
||||
@@ -492,7 +492,7 @@ namespace VocaluxeLib.PartyModes.TicTacToe
|
||||
|
||||
public override void SongSelected(int songID)
|
||||
{
|
||||
EGameMode gm = EGameMode.TR_GAMEMODE_NORMAL;
|
||||
var gm = EGameMode.TR_GAMEMODE_NORMAL;
|
||||
|
||||
switch (_GameData.GameMode)
|
||||
{
|
||||
@@ -525,7 +525,7 @@ namespace VocaluxeLib.PartyModes.TicTacToe
|
||||
_GameData.Rounds = new List<CRound>();
|
||||
for (int i = 0; i < _GameData.NumFields; i++)
|
||||
{
|
||||
CRound r = new CRound();
|
||||
var r = new CRound();
|
||||
_GameData.Rounds.Add(r);
|
||||
}
|
||||
}
|
||||
@@ -540,11 +540,11 @@ namespace VocaluxeLib.PartyModes.TicTacToe
|
||||
_GameData.PlayerTeam2 = new List<int>();
|
||||
|
||||
//Prepare Player-IDs
|
||||
List<int> ids1 = new List<int>();
|
||||
List<int> ids2 = new List<int>();
|
||||
var ids1 = new List<int>();
|
||||
var ids2 = new List<int>();
|
||||
//Add IDs to team-list
|
||||
while (_GameData.PlayerTeam1.Count < _GameData.NumFields + _GameData.NumJokerRetry[0] &&
|
||||
_GameData.PlayerTeam2.Count < _GameData.NumFields + _GameData.NumJokerRetry[1] )
|
||||
_GameData.PlayerTeam2.Count < _GameData.NumFields + _GameData.NumJokerRetry[1])
|
||||
{
|
||||
if (ids1.Count == 0)
|
||||
{
|
||||
@@ -579,7 +579,7 @@ namespace VocaluxeLib.PartyModes.TicTacToe
|
||||
case 1:
|
||||
{
|
||||
//Prepare Player-IDs
|
||||
List<int> ids = new List<int>();
|
||||
var ids = new List<int>();
|
||||
//Add IDs to team-list
|
||||
while (_GameData.PlayerTeam1.Count < _GameData.NumFields + _GameData.NumJokerRetry[0] && ids.Count == 0)
|
||||
{
|
||||
@@ -602,7 +602,7 @@ namespace VocaluxeLib.PartyModes.TicTacToe
|
||||
case 2:
|
||||
{
|
||||
//Prepare Player-IDs
|
||||
List<int> ids = new List<int>();
|
||||
var ids = new List<int>();
|
||||
//Add IDs to team-list
|
||||
while (_GameData.PlayerTeam2.Count < _GameData.NumFields + _GameData.NumJokerRetry[1] && ids.Count == 0)
|
||||
{
|
||||
@@ -627,7 +627,7 @@ namespace VocaluxeLib.PartyModes.TicTacToe
|
||||
|
||||
private void _PrepareSongList()
|
||||
{
|
||||
EGameMode gm = EGameMode.TR_GAMEMODE_NORMAL;
|
||||
var gm = EGameMode.TR_GAMEMODE_NORMAL;
|
||||
|
||||
switch (_GameData.GameMode)
|
||||
{
|
||||
@@ -646,7 +646,7 @@ namespace VocaluxeLib.PartyModes.TicTacToe
|
||||
|
||||
while (_GameData.Songs.Count < (_GameData.NumFields + _GameData.NumJokerRandom[0] + _GameData.NumJokerRandom[1]))
|
||||
{
|
||||
List<int> songs = new List<int>();
|
||||
var songs = new List<int>();
|
||||
switch (_GameData.SongSource)
|
||||
{
|
||||
case ESongSource.TR_PLAYLIST:
|
||||
@@ -678,7 +678,7 @@ namespace VocaluxeLib.PartyModes.TicTacToe
|
||||
|
||||
case ESongSource.TR_CATEGORY:
|
||||
CBase.Songs.SetCategory(_GameData.CategoryID);
|
||||
for (int i = 0; i < CBase.Songs.NumSongsInCategory(_GameData.CategoryID); i++)
|
||||
for (int i = 0; i < CBase.Songs.GetNumSongsVisible(); i++)
|
||||
{
|
||||
// ReSharper disable LoopCanBeConvertedToQuery
|
||||
foreach (EGameMode mode in CBase.Songs.GetVisibleSong(i).AvailableGameModes)
|
||||
|
||||
@@ -22,6 +22,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Windows.Forms;
|
||||
using VocaluxeLib.Menu;
|
||||
using VocaluxeLib.Songs;
|
||||
|
||||
namespace VocaluxeLib.PartyModes.TicTacToe
|
||||
{
|
||||
@@ -61,7 +62,7 @@ namespace VocaluxeLib.PartyModes.TicTacToe
|
||||
_ThemeButtons = new string[] {_ButtonNext, _ButtonBack};
|
||||
|
||||
_Data = new SDataFromScreen();
|
||||
SFromScreenConfig config = new SFromScreenConfig
|
||||
var config = new SFromScreenConfig
|
||||
{
|
||||
PlaylistID = 0,
|
||||
NumFields = 9,
|
||||
@@ -78,7 +79,7 @@ namespace VocaluxeLib.PartyModes.TicTacToe
|
||||
{
|
||||
try
|
||||
{
|
||||
SDataToScreenConfig config = (SDataToScreenConfig)receivedData;
|
||||
var config = (SDataToScreenConfig)receivedData;
|
||||
_Data.ScreenConfig.NumFields = config.NumFields;
|
||||
_Data.ScreenConfig.NumPlayerTeam1 = config.NumPlayerTeam1;
|
||||
_Data.ScreenConfig.NumPlayerTeam2 = config.NumPlayerTeam2;
|
||||
@@ -209,13 +210,13 @@ namespace VocaluxeLib.PartyModes.TicTacToe
|
||||
_SelectSlides[_SelectSlidePlaylist].Selection = _Data.ScreenConfig.PlaylistID;
|
||||
_SelectSlides[_SelectSlidePlaylist].Visible = _Data.ScreenConfig.SongSource == ESongSource.TR_PLAYLIST;
|
||||
|
||||
string[] categories = new string[CBase.Songs.GetNumCategories()];
|
||||
var categories = new string[CBase.Songs.GetNumCategories()];
|
||||
for (int i = 0; i < CBase.Songs.GetNumCategories(); i++)
|
||||
categories[i] = CBase.Songs.GetCategory(i).Name;
|
||||
_SelectSlides[_SelectSlideCategory].Clear();
|
||||
for (int i = 0; i < categories.Length; i++)
|
||||
{
|
||||
string value = categories[i] + " (" + CBase.Songs.NumSongsInCategory(i) + " " + CBase.Language.Translate("TR_SONGS", _PartyModeID) + ")";
|
||||
string value = categories[i] + " (" + CBase.Songs.GetNumSongsNotSungInCategory(i) + " " + CBase.Language.Translate("TR_SONGS", _PartyModeID) + ")";
|
||||
_SelectSlides[_SelectSlideCategory].AddValue(value);
|
||||
}
|
||||
_SelectSlides[_SelectSlideCategory].Selection = _Data.ScreenConfig.CategoryID;
|
||||
@@ -242,7 +243,7 @@ namespace VocaluxeLib.PartyModes.TicTacToe
|
||||
_Data.ScreenConfig.CategoryID = _SelectSlides[_SelectSlideCategory].Selection;
|
||||
_Data.ScreenConfig.GameMode = (EPartyGameMode)_SelectSlides[_SelectSlideGameMode].Selection;
|
||||
|
||||
EGameMode gm = EGameMode.TR_GAMEMODE_NORMAL;
|
||||
var gm = EGameMode.TR_GAMEMODE_NORMAL;
|
||||
|
||||
switch (_Data.ScreenConfig.GameMode)
|
||||
{
|
||||
@@ -282,25 +283,22 @@ namespace VocaluxeLib.PartyModes.TicTacToe
|
||||
}
|
||||
if (_Data.ScreenConfig.SongSource == ESongSource.TR_CATEGORY)
|
||||
{
|
||||
if (CBase.Songs.GetNumCategories() > 0)
|
||||
{
|
||||
if (CBase.Songs.NumSongsInCategory(_Data.ScreenConfig.CategoryID) > 0)
|
||||
{
|
||||
CBase.Songs.SetCategory(_Data.ScreenConfig.CategoryID);
|
||||
_ConfigOk = false;
|
||||
for (int i = 0; i < CBase.Songs.NumSongsInCategory(_Data.ScreenConfig.CategoryID); i++)
|
||||
{
|
||||
_ConfigOk = CBase.Songs.GetVisibleSong(i).AvailableGameModes.Any(mode => mode == gm);
|
||||
if (_ConfigOk)
|
||||
break;
|
||||
}
|
||||
CBase.Songs.SetCategory(-1);
|
||||
}
|
||||
else
|
||||
_ConfigOk = false;
|
||||
}
|
||||
else
|
||||
if (CBase.Songs.GetNumCategories() == 0)
|
||||
_ConfigOk = false;
|
||||
else if (CBase.Songs.GetNumSongsNotSungInCategory(_Data.ScreenConfig.CategoryID) <= 0)
|
||||
_ConfigOk = false;
|
||||
else
|
||||
{
|
||||
CBase.Songs.SetCategory(_Data.ScreenConfig.CategoryID);
|
||||
_ConfigOk = false;
|
||||
foreach (CSong song in CBase.Songs.GetVisibleSongs())
|
||||
{
|
||||
_ConfigOk = song.AvailableGameModes.Any(mode => mode == gm);
|
||||
if (_ConfigOk)
|
||||
break;
|
||||
}
|
||||
CBase.Songs.SetCategory(-1);
|
||||
}
|
||||
}
|
||||
if (_Data.ScreenConfig.SongSource == ESongSource.TR_ALLSONGS)
|
||||
{
|
||||
|
||||
@@ -598,9 +598,14 @@ namespace Vocaluxe.Base
|
||||
return CSongs.NumCategories;
|
||||
}
|
||||
|
||||
public int NumSongsInCategory(int categoryIndex)
|
||||
public int GetNumSongsInCategory(int categoryIndex)
|
||||
{
|
||||
return CSongs.NumSongsInCategory(categoryIndex);
|
||||
return CSongs.GetNumSongsInCategory(categoryIndex);
|
||||
}
|
||||
|
||||
public int GetNumSongsNotSungInCategory(int categoryIndex)
|
||||
{
|
||||
return CSongs.GetNumSongsNotSungInCategory(categoryIndex);
|
||||
}
|
||||
|
||||
public bool IsInCategory()
|
||||
@@ -655,10 +660,7 @@ namespace Vocaluxe.Base
|
||||
|
||||
public CCategory GetCategory(int index)
|
||||
{
|
||||
if (index >= CSongs.NumCategories)
|
||||
return null;
|
||||
|
||||
return new CCategory(CSongs.Categories[index]);
|
||||
return CSongs.GetCategoryByIndex(index);
|
||||
}
|
||||
|
||||
public void AddPartySongSung(int songID)
|
||||
|
||||
+35
-8
@@ -66,7 +66,7 @@ namespace Vocaluxe.Base
|
||||
|
||||
public static int NumSongsVisible
|
||||
{
|
||||
get { return _CatIndex < 0 ? 0 : Categories[_CatIndex].Songs.Count(sp => !sp.IsSung); }
|
||||
get { return VisibleSongs.Count; }
|
||||
}
|
||||
|
||||
public static int NumCategories
|
||||
@@ -104,9 +104,19 @@ namespace Vocaluxe.Base
|
||||
/// </summary>
|
||||
/// <param name="catIndex">Category index</param>
|
||||
/// <returns></returns>
|
||||
public static int NumSongsInCategory(int catIndex)
|
||||
public static int GetNumSongsInCategory(int catIndex)
|
||||
{
|
||||
return _IsCatIndexValid(catIndex) ? Categories[catIndex].Songs.Count(sp => !sp.IsSung) : 0;
|
||||
return _IsCatIndexValid(catIndex) ? Categories[catIndex].Songs.Count : 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the number of song that are not sung in the category specified with CatIndex
|
||||
/// </summary>
|
||||
/// <param name="catIndex">Category index</param>
|
||||
/// <returns>Number of visible songs in that category</returns>
|
||||
public static int GetNumSongsNotSungInCategory(int catIndex)
|
||||
{
|
||||
return _IsCatIndexValid(catIndex) ? Categories[catIndex].GetNumSongsNotSung() : 0;
|
||||
}
|
||||
|
||||
public static void NextCategory()
|
||||
@@ -159,9 +169,8 @@ namespace Vocaluxe.Base
|
||||
foreach (CSongPointer song in category.Songs.Where(song => song.SongID == songID))
|
||||
{
|
||||
song.IsSung = true;
|
||||
int catIndex = _GetCategoryNumber(category);
|
||||
if (NumSongsInCategory(catIndex) == 0)
|
||||
ResetPartySongSung(catIndex);
|
||||
if (category.GetNumSongsNotSung() == 0)
|
||||
ResetPartySongSung(_GetCategoryNumber(category));
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -251,7 +260,7 @@ namespace Vocaluxe.Base
|
||||
{
|
||||
get
|
||||
{
|
||||
List<CSong> songs = new List<CSong>();
|
||||
var songs = new List<CSong>();
|
||||
if (_IsCatIndexValid(_CatIndex))
|
||||
{
|
||||
// ReSharper disable LoopCanBeConvertedToQuery
|
||||
@@ -271,6 +280,24 @@ namespace Vocaluxe.Base
|
||||
get { return Categorizer.Categories.AsReadOnly(); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets category with given index or null for invalid index
|
||||
/// </summary>
|
||||
/// <param name="index"></param>
|
||||
/// <returns>category with given index or null for invalid index</returns>
|
||||
public static CCategory GetCategoryByIndex(int index)
|
||||
{
|
||||
if (!_IsCatIndexValid(index))
|
||||
return null;
|
||||
|
||||
return Categorizer.Categories[index];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets visible song with given index or null for invalid index or song not visible
|
||||
/// </summary>
|
||||
/// <param name="index"></param>
|
||||
/// <returns>visible song with given index or null for invalid index or song not visible</returns>
|
||||
public static CSong GetVisibleSongByIndex(int index)
|
||||
{
|
||||
if (index < 0)
|
||||
@@ -298,7 +325,7 @@ namespace Vocaluxe.Base
|
||||
_Songs.Clear();
|
||||
|
||||
CLog.StartBenchmark(2, "List Songs");
|
||||
List<string> files = new List<string>();
|
||||
var files = new List<string>();
|
||||
foreach (string p in CConfig.SongFolder)
|
||||
{
|
||||
string path = p;
|
||||
|
||||
@@ -206,7 +206,8 @@ namespace VocaluxeLib
|
||||
int GetNumSongs();
|
||||
int GetNumSongsVisible();
|
||||
int GetNumCategories();
|
||||
int NumSongsInCategory(int categoryIndex);
|
||||
int GetNumSongsInCategory(int categoryIndex);
|
||||
int GetNumSongsNotSungInCategory(int categoryIndex);
|
||||
bool IsInCategory();
|
||||
|
||||
int GetCurrentCategoryIndex();
|
||||
|
||||
@@ -130,7 +130,6 @@ namespace VocaluxeLib.Menu.SongMenu
|
||||
{
|
||||
if ((_SelectedInternal != _SelectedPending) && (_Timer.ElapsedMilliseconds >= _PendingTime))
|
||||
{
|
||||
_Timer.Stop();
|
||||
_Timer.Reset();
|
||||
_SelectedInternal = _SelectedPending;
|
||||
}
|
||||
@@ -140,7 +139,6 @@ namespace VocaluxeLib.Menu.SongMenu
|
||||
{
|
||||
if (value == -1)
|
||||
{
|
||||
_Timer.Stop();
|
||||
_Timer.Reset();
|
||||
|
||||
_SelectedInternal = -1;
|
||||
@@ -148,26 +146,28 @@ namespace VocaluxeLib.Menu.SongMenu
|
||||
return;
|
||||
}
|
||||
|
||||
if ((value != _SelectedInternal) && (value != _SelectedPending))
|
||||
if (value == _SelectedPending)
|
||||
{
|
||||
_Timer.Reset();
|
||||
_Timer.Start();
|
||||
|
||||
_SelectedPending = value;
|
||||
if (_Timer.ElapsedMilliseconds >= _PendingTime || _SelectedInternal == -1)
|
||||
{
|
||||
_Timer.Reset();
|
||||
_SelectedInternal = _SelectedPending;
|
||||
}
|
||||
}
|
||||
|
||||
if ((value == _SelectedPending) && ((_Timer.ElapsedMilliseconds >= _PendingTime) || (_SelectedInternal == -1)))
|
||||
else
|
||||
{
|
||||
_Timer.Stop();
|
||||
_Timer.Reset();
|
||||
_SelectedInternal = _SelectedPending;
|
||||
if (value != _SelectedInternal)
|
||||
{
|
||||
_Timer.Reset();
|
||||
_Timer.Start();
|
||||
}
|
||||
_SelectedPending = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void _SetSelectedNow()
|
||||
{
|
||||
_Timer.Stop();
|
||||
_Timer.Reset();
|
||||
_SelectedInternal = _SelectedPending;
|
||||
}
|
||||
@@ -518,7 +518,10 @@ namespace VocaluxeLib.Menu.SongMenu
|
||||
_Active = active;
|
||||
}
|
||||
|
||||
public virtual bool IsMouseOverActualSelection(SMouseEvent mEvent) { return false; }
|
||||
public virtual bool IsMouseOverActualSelection(SMouseEvent mEvent)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public virtual int GetSelectedSong()
|
||||
{
|
||||
|
||||
@@ -92,9 +92,9 @@ namespace VocaluxeLib.Menu.SongMenu
|
||||
{
|
||||
for (int j = 0; j < _NumW; j++)
|
||||
{
|
||||
SRectF rect = new SRectF(_Theme.SongMenuTileBoard.TileRect.X + j * (_TileW + _SpaceW),
|
||||
_Theme.SongMenuTileBoard.TileRect.Y + i * (_TileH + _SpaceH), _TileW, _TileH, _Rect.Z);
|
||||
CStatic tile = new CStatic(_PartyModeID, _CoverTexture, Color, rect);
|
||||
var rect = new SRectF(_Theme.SongMenuTileBoard.TileRect.X + j * (_TileW + _SpaceW),
|
||||
_Theme.SongMenuTileBoard.TileRect.Y + i * (_TileH + _SpaceH), _TileW, _TileH, _Rect.Z);
|
||||
var tile = new CStatic(_PartyModeID, _CoverTexture, Color, rect);
|
||||
_Tiles.Add(tile);
|
||||
}
|
||||
}
|
||||
@@ -129,6 +129,73 @@ namespace VocaluxeLib.Menu.SongMenu
|
||||
}
|
||||
}
|
||||
|
||||
private void _UpdatePreview()
|
||||
{
|
||||
//First hide everything so we just have to set what we actually want
|
||||
_CoverBig.Texture = _CoverBigTexture;
|
||||
_Artist.Text = String.Empty;
|
||||
_Title.Text = String.Empty;
|
||||
_SongLength.Text = String.Empty;
|
||||
_DuetIcon.Visible = false;
|
||||
_VideoIcon.Visible = false;
|
||||
_MedleyCalcIcon.Visible = false;
|
||||
_MedleyTagIcon.Visible = false;
|
||||
|
||||
//Check if nothing is selected (for preview)
|
||||
if (_PreviewSelected < 0)
|
||||
return;
|
||||
|
||||
if (CBase.Songs.IsInCategory())
|
||||
{
|
||||
CSong song = CBase.Songs.GetVisibleSong(_PreviewSelected);
|
||||
//Check if we have a valid song (song still visible, index >=0 etc is checked by framework)
|
||||
if (song == null)
|
||||
{
|
||||
//Display at least the category
|
||||
CCategory category = CBase.Songs.GetCategory(CBase.Songs.GetCurrentCategoryIndex());
|
||||
//Check if we have a valid category
|
||||
if (category == null)
|
||||
return;
|
||||
_CoverBig.Texture = category.CoverTextureBig;
|
||||
_Artist.Text = category.Name;
|
||||
return;
|
||||
}
|
||||
_CoverBig.Texture = song.CoverTextureBig;
|
||||
_Artist.Text = song.Artist;
|
||||
_Title.Text = song.Title;
|
||||
_DuetIcon.Visible = song.IsDuet;
|
||||
_VideoIcon.Visible = song.VideoFileName != "";
|
||||
_MedleyCalcIcon.Visible = song.Medley.Source == EMedleySource.Calculated;
|
||||
_MedleyTagIcon.Visible = song.Medley.Source == EMedleySource.Tag;
|
||||
|
||||
float time = CBase.Sound.GetLength(_SongStream);
|
||||
if (Math.Abs(song.Finish) > 0.001)
|
||||
time = song.Finish;
|
||||
|
||||
time -= song.Start;
|
||||
var min = (int)Math.Floor(time / 60f);
|
||||
var sec = (int)(time - min * 60f);
|
||||
_SongLength.Text = min.ToString("00") + ":" + sec.ToString("00");
|
||||
}
|
||||
else
|
||||
{
|
||||
CCategory category = CBase.Songs.GetCategory(_PreviewSelected);
|
||||
//Check if we have a valid category
|
||||
if (category == null)
|
||||
return;
|
||||
_CoverBig.Texture = category.CoverTextureBig;
|
||||
_Artist.Text = category.Name;
|
||||
|
||||
int num = category.GetNumSongsNotSung();
|
||||
// ReSharper disable ConvertIfStatementToConditionalTernaryExpression
|
||||
if (num != 1)
|
||||
// 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());
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnShow()
|
||||
{
|
||||
if (CBase.Songs.GetTabs() == EOffOn.TR_CONFIG_OFF && CBase.Songs.GetNumCategories() > 0 && !CBase.Songs.IsInCategory())
|
||||
@@ -141,33 +208,16 @@ namespace VocaluxeLib.Menu.SongMenu
|
||||
SetSelectedSong(_ActSong);
|
||||
_AfterCategoryChange();
|
||||
|
||||
int actcat = _PreviewSelected;
|
||||
if ((CBase.Songs.GetNumCategories() > 0) && (actcat < 0))
|
||||
if (_PreviewSelected < 0)
|
||||
{
|
||||
_CoverBig.Texture = CBase.Songs.GetCategory(0).CoverTextureBig;
|
||||
_Artist.Text = CBase.Songs.GetCategory(0).Name;
|
||||
_Title.Text = String.Empty;
|
||||
_SongLength.Text = String.Empty;
|
||||
_PreviewSelected = 0;
|
||||
_Locked = 0;
|
||||
_DuetIcon.Visible = false;
|
||||
_VideoIcon.Visible = false;
|
||||
_MedleyCalcIcon.Visible = false;
|
||||
_MedleyTagIcon.Visible = false;
|
||||
}
|
||||
|
||||
if (CBase.Songs.GetNumSongsVisible() == 0 && CBase.Songs.GetSearchFilter() != "")
|
||||
{
|
||||
_CoverBig.Texture = _CoverBigTexture;
|
||||
_Artist.Text = String.Empty;
|
||||
_Title.Text = String.Empty;
|
||||
_SongLength.Text = String.Empty;
|
||||
_PreviewSelected = -1;
|
||||
_Locked = -1;
|
||||
_DuetIcon.Visible = false;
|
||||
_VideoIcon.Visible = false;
|
||||
_MedleyCalcIcon.Visible = false;
|
||||
_MedleyTagIcon.Visible = false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -394,63 +444,12 @@ namespace VocaluxeLib.Menu.SongMenu
|
||||
tile.Draw(1.2f, tile.Rect.Z - 0.1f, EAspect.Crop);
|
||||
else
|
||||
{
|
||||
// ReSharper disable ConvertIfStatementToConditionalTernaryExpression
|
||||
if (tile.Texture != _CoverTexture)
|
||||
// ReSharper restore ConvertIfStatementToConditionalTernaryExpression
|
||||
tile.Draw(1f, tile.Rect.Z, EAspect.Crop);
|
||||
else
|
||||
tile.Draw(1f, tile.Rect.Z, EAspect.Stretch);
|
||||
EAspect aspect = (tile.Texture != _CoverTexture) ? EAspect.Crop : EAspect.Stretch;
|
||||
tile.Draw(1f, tile.Rect.Z, aspect);
|
||||
}
|
||||
}
|
||||
|
||||
if (CBase.Songs.IsInCategory())
|
||||
{
|
||||
int actsong = _PreviewSelected;
|
||||
if ((CBase.Songs.GetNumSongsVisible() > actsong) && (actsong >= 0))
|
||||
{
|
||||
CSong song = CBase.Songs.GetVisibleSong(actsong);
|
||||
|
||||
_CoverBig.Texture = song.CoverTextureBig;
|
||||
_Artist.Text = song.Artist;
|
||||
_Title.Text = song.Title;
|
||||
_DuetIcon.Visible = song.IsDuet;
|
||||
_VideoIcon.Visible = song.VideoFileName != "";
|
||||
_MedleyCalcIcon.Visible = song.Medley.Source == EMedleySource.Calculated;
|
||||
_MedleyTagIcon.Visible = song.Medley.Source == EMedleySource.Tag;
|
||||
|
||||
float time = CBase.Sound.GetLength(_SongStream);
|
||||
if (Math.Abs(song.Finish) > 0.001)
|
||||
time = song.Finish;
|
||||
|
||||
time -= song.Start;
|
||||
int min = (int)Math.Floor(time / 60f);
|
||||
int sec = (int)(time - min * 60f);
|
||||
_SongLength.Text = min.ToString("00") + ":" + sec.ToString("00");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
int actcat = _PreviewSelected;
|
||||
if ((CBase.Songs.GetNumCategories() > actcat) && (actcat >= 0))
|
||||
{
|
||||
_CoverBig.Texture = CBase.Songs.GetCategory(actcat).CoverTextureBig;
|
||||
_Artist.Text = CBase.Songs.GetCategory(actcat).Name;
|
||||
|
||||
int num = CBase.Songs.NumSongsInCategory(actcat);
|
||||
// ReSharper disable ConvertIfStatementToConditionalTernaryExpression
|
||||
if (num != 1)
|
||||
// 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());
|
||||
|
||||
_SongLength.Text = String.Empty;
|
||||
_DuetIcon.Visible = false;
|
||||
_VideoIcon.Visible = false;
|
||||
_MedleyCalcIcon.Visible = false;
|
||||
_MedleyTagIcon.Visible = false;
|
||||
}
|
||||
}
|
||||
_UpdatePreview();
|
||||
|
||||
_TextBG.Draw();
|
||||
|
||||
@@ -458,11 +457,11 @@ namespace VocaluxeLib.Menu.SongMenu
|
||||
{
|
||||
if (_Vidtex.Color.A < 1)
|
||||
_CoverBig.Draw(1f, EAspect.Crop);
|
||||
RectangleF bounds = new RectangleF(_CoverBig.Rect.X, _CoverBig.Rect.Y, _CoverBig.Rect.W, _CoverBig.Rect.H);
|
||||
var bounds = new RectangleF(_CoverBig.Rect.X, _CoverBig.Rect.Y, _CoverBig.Rect.W, _CoverBig.Rect.H);
|
||||
RectangleF rect;
|
||||
CHelper.SetRect(bounds, out rect, _Vidtex.OrigAspect, EAspect.Crop);
|
||||
SRectF vidRect = new SRectF(rect.X, rect.Y, rect.Width, rect.Height, _CoverBig.Rect.Z);
|
||||
SRectF vidRectBounds = new SRectF(bounds.X, bounds.Y, bounds.Width, bounds.Height, 0f);
|
||||
var vidRect = new SRectF(rect.X, rect.Y, rect.Width, rect.Height, _CoverBig.Rect.Z);
|
||||
var vidRectBounds = new SRectF(bounds.X, bounds.Y, bounds.Width, bounds.Height, 0f);
|
||||
|
||||
CBase.Drawing.DrawTexture(_Vidtex, vidRect, _Vidtex.Color, vidRectBounds);
|
||||
CBase.Drawing.DrawTextureReflection(_Vidtex, vidRect, _Vidtex.Color, vidRectBounds, _CoverBig.ReflectionSpace, _CoverBig.ReflectionHeight);
|
||||
@@ -490,7 +489,7 @@ namespace VocaluxeLib.Menu.SongMenu
|
||||
CStatic selCov = GetSelectedSongCover();
|
||||
if (selCov.Texture == null)
|
||||
return false;
|
||||
SRectF rect = new SRectF(selCov.Rect.X - selCov.Rect.W*0.2f, selCov.Rect.Y - selCov.Rect.H*0.2f, selCov.Rect.W*1.2f, selCov.Rect.H*1.2f, selCov.Rect.Z);
|
||||
var rect = new SRectF(selCov.Rect.X - selCov.Rect.W * 0.2f, selCov.Rect.Y - selCov.Rect.H * 0.2f, selCov.Rect.W * 1.2f, selCov.Rect.H * 1.2f, selCov.Rect.Z);
|
||||
return CHelper.IsInBounds(rect, mEvent);
|
||||
}
|
||||
|
||||
@@ -679,8 +678,8 @@ namespace VocaluxeLib.Menu.SongMenu
|
||||
{
|
||||
for (int j = 0; j < _NumW; j++)
|
||||
{
|
||||
SRectF rect = new SRectF(_Rect.X + j * (_TileW + _SpaceW), _Rect.Y + i * (_TileH + _SpaceH), _TileW, _TileH, _Rect.Z);
|
||||
CStatic tile = new CStatic(_PartyModeID, _CoverTexture, Color, rect);
|
||||
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);
|
||||
_Tiles.Add(tile);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
|
||||
using System.Collections.Generic;
|
||||
using VocaluxeLib.Draw;
|
||||
using System.Linq;
|
||||
|
||||
namespace VocaluxeLib.Songs
|
||||
{
|
||||
@@ -52,6 +53,11 @@ namespace VocaluxeLib.Songs
|
||||
}
|
||||
}
|
||||
|
||||
public int GetNumSongsNotSung()
|
||||
{
|
||||
return Songs.Count(sp => !sp.IsSung);
|
||||
}
|
||||
|
||||
public CCategory(string name, CTexture coverSmall, CTexture coverBig)
|
||||
{
|
||||
Name = name;
|
||||
|
||||
Reference in new issue
Block a user