Merge branch 'release-0.3' into develop
Conflicts: Vocaluxe/Base/CConfig.cs Vocaluxe/Lib/Playlist/CPlaylistFile.cs Vocaluxe/Screens/CScreenSong.cs VocaluxeLib/CHelper.cs VocaluxeLib/Menu/CMenu.cs VocaluxeLib/Menu/SongMenu/CSongMenuFramework.cs VocaluxeLib/Menu/SongMenu/CSongMenuTileBoard.cs
This commit is contained in:
commit
73e4a9fa74
15 files changed
+240
-272
No files matched your search
@@ -675,7 +675,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)
|
||||
|
||||
@@ -20,6 +20,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Windows.Forms;
|
||||
using VocaluxeLib.Menu;
|
||||
using VocaluxeLib.Songs;
|
||||
|
||||
namespace VocaluxeLib.PartyModes.TicTacToe
|
||||
{
|
||||
@@ -59,7 +60,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,
|
||||
@@ -76,7 +77,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;
|
||||
@@ -207,13 +208,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;
|
||||
@@ -240,7 +241,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)
|
||||
{
|
||||
@@ -280,25 +281,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)
|
||||
{
|
||||
|
||||
@@ -33,7 +33,15 @@ namespace Vocaluxe.Base
|
||||
{
|
||||
static class CConfig
|
||||
{
|
||||
private static readonly XmlWriterSettings _Settings = new XmlWriterSettings();
|
||||
/// <summary>
|
||||
/// Uniform settings for writing XML files. ALWAYS use this!
|
||||
/// </summary>
|
||||
public static readonly XmlWriterSettings XMLSettings = new XmlWriterSettings
|
||||
{
|
||||
Indent = true,
|
||||
Encoding = Encoding.UTF8,
|
||||
ConformanceLevel = ConformanceLevel.Document
|
||||
};
|
||||
|
||||
// Debug
|
||||
public static EDebugLevel DebugLevel = EDebugLevel.TR_CONFIG_OFF;
|
||||
@@ -141,10 +149,6 @@ namespace Vocaluxe.Base
|
||||
|
||||
public static void Init()
|
||||
{
|
||||
_Settings.Indent = true;
|
||||
_Settings.Encoding = Encoding.UTF8;
|
||||
_Settings.ConformanceLevel = ConformanceLevel.Document;
|
||||
|
||||
SongFolder.Add(Path.Combine(Directory.GetCurrentDirectory(), CSettings.FolderSongs));
|
||||
|
||||
#if INSTALLER
|
||||
@@ -304,7 +308,7 @@ namespace Vocaluxe.Base
|
||||
XmlWriter writer = null;
|
||||
try
|
||||
{
|
||||
writer = XmlWriter.Create(Path.Combine(CSettings.DataPath, CSettings.FileConfig), _Settings);
|
||||
writer = XmlWriter.Create(Path.Combine(CSettings.DataPath, CSettings.FileConfig), XMLSettings);
|
||||
writer.WriteStartDocument();
|
||||
writer.WriteStartElement("root");
|
||||
|
||||
|
||||
+14
-6
@@ -19,6 +19,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Drawing;
|
||||
using System.Xml;
|
||||
using Vocaluxe.Base.Fonts;
|
||||
using VocaluxeLib;
|
||||
using VocaluxeLib.Game;
|
||||
@@ -144,6 +145,11 @@ namespace Vocaluxe.Base
|
||||
{
|
||||
return CConfig.GetMaxNumMics();
|
||||
}
|
||||
|
||||
public XmlWriterSettings GetXMLSettings()
|
||||
{
|
||||
return CConfig.XMLSettings;
|
||||
}
|
||||
}
|
||||
|
||||
class CBsettings : ISettings
|
||||
@@ -606,9 +612,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()
|
||||
@@ -663,10 +674,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)
|
||||
|
||||
+33
-6
@@ -64,7 +64,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
|
||||
@@ -102,9 +102,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()
|
||||
@@ -157,9 +167,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;
|
||||
}
|
||||
}
|
||||
@@ -269,6 +278,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)
|
||||
|
||||
@@ -105,7 +105,6 @@ namespace Vocaluxe.Base
|
||||
private const int _SkinSystemVersion = 3;
|
||||
|
||||
#region Vars
|
||||
private static readonly XmlWriterSettings _Settings = new XmlWriterSettings();
|
||||
private static readonly List<STheme> _Themes = new List<STheme>();
|
||||
public static string[] ThemeNames
|
||||
{
|
||||
@@ -146,10 +145,6 @@ namespace Vocaluxe.Base
|
||||
#region Theme and Skin loading and writing
|
||||
public static void InitTheme()
|
||||
{
|
||||
_Settings.Indent = true;
|
||||
_Settings.Encoding = Encoding.UTF8;
|
||||
_Settings.ConformanceLevel = ConformanceLevel.Document;
|
||||
|
||||
_ListThemes();
|
||||
ListSkins();
|
||||
|
||||
@@ -289,7 +284,7 @@ namespace Vocaluxe.Base
|
||||
private static void _SaveTheme(int themeIndex)
|
||||
{
|
||||
#region ThemeMainFile
|
||||
using (XmlWriter writer = XmlWriter.Create(Path.Combine(_Themes[themeIndex].Path, _Themes[themeIndex].FileName), _Settings))
|
||||
using (XmlWriter writer = XmlWriter.Create(Path.Combine(_Themes[themeIndex].Path, _Themes[themeIndex].FileName), CConfig.XMLSettings))
|
||||
{
|
||||
writer.WriteStartDocument();
|
||||
writer.WriteStartElement("root");
|
||||
@@ -331,7 +326,7 @@ namespace Vocaluxe.Base
|
||||
{
|
||||
for (int skinIndex = 0; skinIndex < _Skins.Count; skinIndex++)
|
||||
{
|
||||
using (XmlWriter writer = XmlWriter.Create(Path.Combine(_Skins[skinIndex].Path, _Skins[skinIndex].FileName), _Settings))
|
||||
using (XmlWriter writer = XmlWriter.Create(Path.Combine(_Skins[skinIndex].Path, _Skins[skinIndex].FileName), CConfig.XMLSettings))
|
||||
{
|
||||
writer.WriteStartDocument();
|
||||
writer.WriteStartElement("root");
|
||||
|
||||
@@ -29,33 +29,22 @@ namespace Vocaluxe.Lib.Playlist
|
||||
{
|
||||
public class CPlaylistFile
|
||||
{
|
||||
private static readonly XmlWriterSettings _Settings = new XmlWriterSettings();
|
||||
|
||||
public string PlaylistName;
|
||||
public string PlaylistFile;
|
||||
public List<CPlaylistSong> Songs = new List<CPlaylistSong>();
|
||||
|
||||
public CPlaylistFile()
|
||||
{
|
||||
_Init();
|
||||
PlaylistName = string.Empty;
|
||||
PlaylistFile = string.Empty;
|
||||
}
|
||||
|
||||
public CPlaylistFile(string file)
|
||||
{
|
||||
_Init();
|
||||
PlaylistFile = file;
|
||||
_LoadPlaylist();
|
||||
}
|
||||
|
||||
private void _Init()
|
||||
{
|
||||
_Settings.Indent = true;
|
||||
_Settings.Encoding = Encoding.UTF8;
|
||||
_Settings.ConformanceLevel = ConformanceLevel.Document;
|
||||
}
|
||||
|
||||
public void SavePlaylist()
|
||||
{
|
||||
if (PlaylistFile == "")
|
||||
@@ -86,7 +75,7 @@ namespace Vocaluxe.Lib.Playlist
|
||||
XmlWriter writer;
|
||||
try
|
||||
{
|
||||
writer = XmlWriter.Create(PlaylistFile, _Settings);
|
||||
writer = XmlWriter.Create(PlaylistFile, CConfig.XMLSettings);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
||||
@@ -1011,7 +1011,10 @@ namespace Vocaluxe.Screens
|
||||
if (firstLevel && !secondSort)
|
||||
{
|
||||
//TODO: What's to do with multiple tags?
|
||||
//Flamefire: What? We only sorted by one tag, sorting by multiple tags (e.g. Album) will be by e.g. the first entry. That can be used here too as otherwhise it will confuse users because it jumps randomly
|
||||
|
||||
//How can we get current letter? I think we have to save it - Or is there a better method?
|
||||
//"Current letter"? The letter that was typed last? Doesn't matter as we are starting the search on current selected song
|
||||
ReadOnlyCollection<CSong> songs = CSongs.VisibleSongs;
|
||||
int ct = songs.Count;
|
||||
int visibleID = -1;
|
||||
@@ -1025,6 +1028,7 @@ namespace Vocaluxe.Screens
|
||||
break;
|
||||
|
||||
//TODO: Does this make sense? Maybe we should deactivate this for years? You could only jump between 1 and 2
|
||||
//Keep it for consistency. Decades are reasonable though.
|
||||
case ESongSorting.TR_CONFIG_YEAR:
|
||||
case ESongSorting.TR_CONFIG_DECADE:
|
||||
if (curSelected >= 0 && curSelected < ct - 1 && songs[curSelected].Year.StartsWith(letter.ToString(), StringComparison.OrdinalIgnoreCase))
|
||||
@@ -1139,27 +1143,29 @@ namespace Vocaluxe.Screens
|
||||
_Statics[_StaticOptionsBG].Visible = false;
|
||||
_Buttons[_ButtonOpenOptions].Visible = true;
|
||||
|
||||
if (CSongs.VisibleSongs.Count > 0)
|
||||
{
|
||||
_SongOptionsActive = view != ESongOptionsView.None;
|
||||
if (view == ESongOptionsView.None)
|
||||
_SongOptionsActive = false;
|
||||
else if (CSongs.IsInCategory)
|
||||
_SongOptionsActive = CSongs.VisibleSongs.Count > 0;
|
||||
else
|
||||
_SongOptionsActive = CSongs.Categories.Count > 0;
|
||||
|
||||
if (_SongOptionsActive)
|
||||
{
|
||||
//Has to be done here otherwhise changed playlist names will not appear until OnShow is called!
|
||||
_UpdatePlaylistNames();
|
||||
if (!_SongOptionsActive)
|
||||
return;
|
||||
|
||||
_Texts[_TextOptionsTitle].Visible = true;
|
||||
_Buttons[_ButtonOptionsClose].Visible = true;
|
||||
_Statics[_StaticOptionsBG].Visible = true;
|
||||
_Buttons[_ButtonOpenOptions].Visible = false;
|
||||
if (view == ESongOptionsView.Song)
|
||||
_ShowSongOptionsSong();
|
||||
else if (view == ESongOptionsView.General)
|
||||
_ShowSongOptionsGeneral();
|
||||
else if (view == ESongOptionsView.Medley)
|
||||
_ShowSongOptionsMedley();
|
||||
}
|
||||
}
|
||||
//Has to be done here otherwhise changed playlist names will not appear until OnShow is called!
|
||||
_UpdatePlaylistNames();
|
||||
|
||||
_Texts[_TextOptionsTitle].Visible = true;
|
||||
_Buttons[_ButtonOptionsClose].Visible = true;
|
||||
_Statics[_StaticOptionsBG].Visible = true;
|
||||
_Buttons[_ButtonOpenOptions].Visible = false;
|
||||
if (view == ESongOptionsView.Song)
|
||||
_ShowSongOptionsSong();
|
||||
else if (view == ESongOptionsView.General)
|
||||
_ShowSongOptionsGeneral();
|
||||
else if (view == ESongOptionsView.Medley)
|
||||
_ShowSongOptionsMedley();
|
||||
}
|
||||
|
||||
private void _CheckAndAddGameMode(EGameMode gameMode)
|
||||
|
||||
@@ -140,6 +140,8 @@ namespace VocaluxeLib
|
||||
{
|
||||
var files = new List<string>();
|
||||
var dir = new DirectoryInfo(path);
|
||||
if (!dir.Exists)
|
||||
return files;
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
@@ -19,6 +19,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Drawing;
|
||||
using System.Xml;
|
||||
using VocaluxeLib.Draw;
|
||||
using VocaluxeLib.Game;
|
||||
using VocaluxeLib.Menu;
|
||||
@@ -54,6 +55,11 @@ namespace VocaluxeLib
|
||||
|
||||
bool IsMicConfigured(int playerNr);
|
||||
int GetMaxNumMics();
|
||||
|
||||
/// <summary>
|
||||
/// Get the uniform settings for writing XML files. ALWAYS use this!
|
||||
/// </summary>
|
||||
XmlWriterSettings GetXMLSettings();
|
||||
}
|
||||
|
||||
public interface ISettings
|
||||
@@ -207,7 +213,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();
|
||||
|
||||
@@ -196,10 +196,9 @@ namespace VocaluxeLib.Menu
|
||||
if (_ThemePath == "")
|
||||
return;
|
||||
|
||||
var settings = new XmlWriterSettings {Indent = true, Encoding = Encoding.UTF8, ConformanceLevel = ConformanceLevel.Document};
|
||||
|
||||
string file = Path.Combine(_ThemePath, ThemeName + ".xml");
|
||||
using (XmlWriter writer = XmlWriter.Create(file, settings))
|
||||
using (XmlWriter writer = XmlWriter.Create(file, CBase.Config.GetXMLSettings()))
|
||||
{
|
||||
writer.WriteStartDocument();
|
||||
writer.WriteStartElement("root");
|
||||
|
||||
@@ -99,7 +99,6 @@ namespace VocaluxeLib.Menu.SongMenu
|
||||
protected SThemeSongMenu _Theme;
|
||||
private bool _ThemeLoaded;
|
||||
|
||||
private readonly Stopwatch _Timer = new Stopwatch();
|
||||
private readonly Stopwatch _VideoFadeTimer = new Stopwatch();
|
||||
private readonly List<int> _Streams = new List<int>();
|
||||
private int _ActSongId = -1;
|
||||
@@ -113,64 +112,13 @@ namespace VocaluxeLib.Menu.SongMenu
|
||||
protected SRectF _Rect;
|
||||
protected SColorF _Color;
|
||||
|
||||
private int _SelectedInternal = -1;
|
||||
private int _SelectedPending = -1;
|
||||
protected long _PendingTime = 500L;
|
||||
|
||||
private int _LockedInternal = -1;
|
||||
protected bool _Active;
|
||||
|
||||
protected float _MaxVolume = 100f;
|
||||
|
||||
protected int _PreviewSelected
|
||||
{
|
||||
//for preview only
|
||||
get
|
||||
{
|
||||
if ((_SelectedInternal != _SelectedPending) && (_Timer.ElapsedMilliseconds >= _PendingTime))
|
||||
{
|
||||
_Timer.Stop();
|
||||
_Timer.Reset();
|
||||
_SelectedInternal = _SelectedPending;
|
||||
}
|
||||
return _SelectedInternal;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value == -1)
|
||||
{
|
||||
_Timer.Stop();
|
||||
_Timer.Reset();
|
||||
|
||||
_SelectedInternal = -1;
|
||||
_SelectedPending = -1;
|
||||
return;
|
||||
}
|
||||
|
||||
if ((value != _SelectedInternal) && (value != _SelectedPending))
|
||||
{
|
||||
_Timer.Reset();
|
||||
_Timer.Start();
|
||||
|
||||
_SelectedPending = value;
|
||||
}
|
||||
|
||||
if ((value == _SelectedPending) && ((_Timer.ElapsedMilliseconds >= _PendingTime) || (_SelectedInternal == -1)))
|
||||
{
|
||||
_Timer.Stop();
|
||||
_Timer.Reset();
|
||||
_SelectedInternal = _SelectedPending;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void _SetSelectedNow()
|
||||
{
|
||||
_Timer.Stop();
|
||||
_Timer.Reset();
|
||||
_SelectedInternal = _SelectedPending;
|
||||
}
|
||||
protected virtual int _PreviewId { get; set; }
|
||||
|
||||
private int _LockedInternal = -1;
|
||||
protected int _Locked
|
||||
{
|
||||
//the real selected song for singing
|
||||
@@ -435,8 +383,8 @@ namespace VocaluxeLib.Menu.SongMenu
|
||||
if (!_Initialized)
|
||||
return;
|
||||
|
||||
if (_ActSongId != _PreviewSelected)
|
||||
_SelectSong(_PreviewSelected);
|
||||
if (_ActSongId != _PreviewId)
|
||||
_SelectSong(_PreviewId);
|
||||
|
||||
if (_Streams.Count <= 0 || _Video == -1)
|
||||
return;
|
||||
@@ -475,18 +423,7 @@ namespace VocaluxeLib.Menu.SongMenu
|
||||
|
||||
public virtual void OnHide()
|
||||
{
|
||||
foreach (int stream in _Streams)
|
||||
CBase.Sound.FadeAndStop(stream, 0f, 0.75f);
|
||||
_Streams.Clear();
|
||||
|
||||
CBase.Video.Close(_Video);
|
||||
_Video = -1;
|
||||
|
||||
CBase.Drawing.RemoveTexture(ref _Vidtex);
|
||||
|
||||
_Timer.Stop();
|
||||
_Timer.Reset();
|
||||
_SelectedInternal = _SelectedPending;
|
||||
_Reset();
|
||||
}
|
||||
|
||||
public virtual void HandleInput(ref SKeyEvent keyEvent, SScreenSongOptions songOptions) {}
|
||||
@@ -571,9 +508,9 @@ namespace VocaluxeLib.Menu.SongMenu
|
||||
{
|
||||
if (!_Initialized)
|
||||
return false;
|
||||
if (CBase.Songs.IsInCategory() || _PreviewSelected < 0 || _PreviewSelected >= CBase.Songs.GetNumCategories())
|
||||
if (CBase.Songs.IsInCategory() || _PreviewId < 0 || _PreviewId >= CBase.Songs.GetNumCategories())
|
||||
return false;
|
||||
_EnterCategory(_PreviewSelected);
|
||||
_EnterCategory(_PreviewId);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -665,10 +602,6 @@ namespace VocaluxeLib.Menu.SongMenu
|
||||
_Video = -1;
|
||||
|
||||
CBase.Drawing.RemoveTexture(ref _Vidtex);
|
||||
|
||||
_Timer.Stop();
|
||||
_Timer.Reset();
|
||||
_SelectedInternal = _SelectedPending;
|
||||
}
|
||||
|
||||
#region ThemeEdit
|
||||
|
||||
@@ -61,6 +61,15 @@ namespace VocaluxeLib.Menu.SongMenu
|
||||
public CSongMenuTileBoard(int partyModeID)
|
||||
: base(partyModeID) {}
|
||||
|
||||
protected override int _PreviewId
|
||||
{
|
||||
set
|
||||
{
|
||||
base._PreviewId = value;
|
||||
_UpdatePreview();
|
||||
}
|
||||
}
|
||||
|
||||
public override int GetActualSelection()
|
||||
{
|
||||
return _ActualSelection;
|
||||
@@ -77,8 +86,6 @@ namespace VocaluxeLib.Menu.SongMenu
|
||||
_SpaceW = _Theme.SongMenuTileBoard.SpaceW;
|
||||
_SpaceH = _Theme.SongMenuTileBoard.SpaceH;
|
||||
|
||||
_PendingTime = 100L;
|
||||
|
||||
_TileW = (int)((_Theme.SongMenuTileBoard.TileRect.W - _SpaceW * (_NumW - 1)) / _NumW);
|
||||
_TileH = (int)((_Theme.SongMenuTileBoard.TileRect.H - _SpaceH * (_NumH - 1)) / _NumH);
|
||||
|
||||
@@ -99,9 +106,6 @@ namespace VocaluxeLib.Menu.SongMenu
|
||||
|
||||
_ScrollRect = new SRectF(0, 0, CBase.Settings.GetRenderW(), CBase.Settings.GetRenderH(), _Theme.SongMenuTileBoard.TileRect.Z);
|
||||
|
||||
_PreviewSelected = -1;
|
||||
_Offset = 0;
|
||||
|
||||
_CoverBig = _Theme.SongMenuTileBoard.StaticCoverBig;
|
||||
_TextBG = _Theme.SongMenuTileBoard.StaticTextBG;
|
||||
_DuetIcon = _Theme.SongMenuTileBoard.StaticDuetIcon;
|
||||
@@ -112,6 +116,9 @@ namespace VocaluxeLib.Menu.SongMenu
|
||||
_Artist = _Theme.SongMenuTileBoard.TextArtist;
|
||||
_Title = _Theme.SongMenuTileBoard.TextTitle;
|
||||
_SongLength = _Theme.SongMenuTileBoard.TextSongLength;
|
||||
|
||||
_PreviewId = -1;
|
||||
_Offset = 0;
|
||||
}
|
||||
|
||||
public override void Update(SScreenSongOptions songOptions)
|
||||
@@ -120,52 +127,102 @@ namespace VocaluxeLib.Menu.SongMenu
|
||||
|
||||
if (songOptions.Selection.RandomOnly)
|
||||
{
|
||||
_Locked = _PreviewSelected;
|
||||
_ActualSelection = _PreviewSelected;
|
||||
_Locked = _PreviewId;
|
||||
_ActualSelection = _PreviewId;
|
||||
for (int i = 0; i < _Tiles.Count; i++)
|
||||
_Tiles[i].Selected = _Locked == i + _Offset;
|
||||
}
|
||||
}
|
||||
|
||||
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 (_PreviewId < 0)
|
||||
return;
|
||||
|
||||
if (CBase.Songs.IsInCategory())
|
||||
{
|
||||
CSong song = CBase.Songs.GetVisibleSong(_PreviewId);
|
||||
//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 == EDataSource.Calculated;
|
||||
_MedleyTagIcon.Visible = song.Medley.Source == EDataSource.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(_PreviewId);
|
||||
//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())
|
||||
_EnterCategory(0);
|
||||
_ActualSelection = -1;
|
||||
_Locked = -1;
|
||||
_PreviewSelected = -1;
|
||||
_PreviewId = -1;
|
||||
_UpdateList(0, true);
|
||||
//AfterCategoryChange();
|
||||
SetSelectedSong(_ActSong);
|
||||
_AfterCategoryChange();
|
||||
|
||||
int actcat = _PreviewSelected;
|
||||
if ((CBase.Songs.GetNumCategories() > 0) && (actcat < 0))
|
||||
if (_PreviewId < 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;
|
||||
_PreviewId = 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;
|
||||
_PreviewId = -1;
|
||||
_Locked = -1;
|
||||
_DuetIcon.Visible = false;
|
||||
_VideoIcon.Visible = false;
|
||||
_MedleyCalcIcon.Visible = false;
|
||||
_MedleyTagIcon.Visible = false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -185,14 +242,13 @@ namespace VocaluxeLib.Menu.SongMenu
|
||||
if ((_Locked == -1 || !sel) &&
|
||||
(keyEvent.Key != Keys.Escape && keyEvent.Key != Keys.Back && keyEvent.Key != Keys.PageUp && keyEvent.Key != Keys.PageDown))
|
||||
{
|
||||
if (_PreviewSelected > -1)
|
||||
_Locked = _PreviewSelected;
|
||||
if (_PreviewId > -1)
|
||||
_Locked = _PreviewId;
|
||||
else
|
||||
{
|
||||
_Locked = 0;
|
||||
_ActualSelection = 0;
|
||||
_PreviewSelected = 0;
|
||||
_SetSelectedNow();
|
||||
_PreviewId = 0;
|
||||
_UpdateList(0, true);
|
||||
}
|
||||
}
|
||||
@@ -203,10 +259,10 @@ namespace VocaluxeLib.Menu.SongMenu
|
||||
case Keys.Enter:
|
||||
if (!CBase.Songs.IsInCategory())
|
||||
{
|
||||
_EnterCategory(_PreviewSelected);
|
||||
_EnterCategory(_PreviewId);
|
||||
keyEvent.Handled = true;
|
||||
}
|
||||
else if (_ActualSelection > -1 && _PreviewSelected >= 0)
|
||||
else if (_ActualSelection > -1 && _PreviewId >= 0)
|
||||
_Locked = _ActualSelection;
|
||||
break;
|
||||
|
||||
@@ -301,7 +357,7 @@ namespace VocaluxeLib.Menu.SongMenu
|
||||
|
||||
if (!keyEvent.Handled)
|
||||
{
|
||||
_PreviewSelected = _Locked;
|
||||
_PreviewId = _Locked;
|
||||
_ActualSelection = _Locked;
|
||||
|
||||
for (int i = 0; i < _Tiles.Count; i++)
|
||||
@@ -326,11 +382,11 @@ namespace VocaluxeLib.Menu.SongMenu
|
||||
{
|
||||
if (mouseEvent.LB || !CBase.Songs.IsInCategory())
|
||||
{
|
||||
if (_PreviewSelected == i + _Offset)
|
||||
_Locked = _PreviewSelected;
|
||||
if (_PreviewId == i + _Offset)
|
||||
_Locked = _PreviewId;
|
||||
else
|
||||
{
|
||||
_PreviewSelected = i + _Offset;
|
||||
_PreviewId = i + _Offset;
|
||||
_Locked = -1;
|
||||
}
|
||||
}
|
||||
@@ -361,10 +417,10 @@ namespace VocaluxeLib.Menu.SongMenu
|
||||
}
|
||||
if (mouseEvent.RB && CBase.Songs.GetTabs() == EOffOn.TR_CONFIG_OFF && !songOptions.Selection.PartyMode)
|
||||
CBase.Graphics.FadeTo(EScreens.ScreenMain);
|
||||
else if (_PreviewSelected != -1 && mouseEvent.LB && CBase.Songs.GetCurrentCategoryIndex() != -1 && !songOptions.Selection.PartyMode)
|
||||
else if (_PreviewId != -1 && mouseEvent.LB && CBase.Songs.GetCurrentCategoryIndex() != -1 && !songOptions.Selection.PartyMode)
|
||||
{
|
||||
if (CHelper.IsInBounds(_CoverBig.Rect, mouseEvent) || CHelper.IsInBounds(_TextBG.Rect, mouseEvent))
|
||||
_Locked = _PreviewSelected;
|
||||
_Locked = _PreviewId;
|
||||
}
|
||||
else if (mouseEvent.LB && (!CBase.Songs.IsInCategory()))
|
||||
{
|
||||
@@ -372,7 +428,7 @@ namespace VocaluxeLib.Menu.SongMenu
|
||||
{
|
||||
if (tile.Texture != _CoverTexture && CHelper.IsInBounds(tile.Rect, mouseEvent))
|
||||
{
|
||||
_EnterCategory(_PreviewSelected);
|
||||
_EnterCategory(_PreviewId);
|
||||
mouseEvent.Handled = true;
|
||||
return;
|
||||
}
|
||||
@@ -392,61 +448,8 @@ 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);
|
||||
}
|
||||
}
|
||||
|
||||
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 == EDataSource.Calculated;
|
||||
_MedleyTagIcon.Visible = song.Medley.Source == EDataSource.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
|
||||
{
|
||||
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;
|
||||
EAspect aspect = (tile.Texture != _CoverTexture) ? EAspect.Crop : EAspect.Stretch;
|
||||
tile.Draw(1f, tile.Rect.Z, aspect);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -508,14 +511,13 @@ namespace VocaluxeLib.Menu.SongMenu
|
||||
|
||||
if (_Locked == -1 || !sel)
|
||||
{
|
||||
if (_PreviewSelected > -1)
|
||||
_Locked = _PreviewSelected;
|
||||
if (_PreviewId > -1)
|
||||
_Locked = _PreviewId;
|
||||
else
|
||||
{
|
||||
_Locked = 0;
|
||||
_ActualSelection = 0;
|
||||
_PreviewSelected = 0;
|
||||
_SetSelectedNow();
|
||||
_PreviewId = 0;
|
||||
_UpdateList(0, true);
|
||||
}
|
||||
}
|
||||
@@ -523,13 +525,12 @@ namespace VocaluxeLib.Menu.SongMenu
|
||||
foreach (CStatic tile in _Tiles)
|
||||
tile.Selected = false;
|
||||
|
||||
_PreviewSelected = itemNr;
|
||||
_SetSelectedNow();
|
||||
_PreviewId = itemNr;
|
||||
_Locked = itemNr;
|
||||
|
||||
_UpdateList(true);
|
||||
|
||||
_PreviewSelected = _Locked;
|
||||
_PreviewId = _Locked;
|
||||
_ActualSelection = _Locked;
|
||||
|
||||
if (_Locked - _Offset >= 0)
|
||||
@@ -556,7 +557,7 @@ namespace VocaluxeLib.Menu.SongMenu
|
||||
{
|
||||
base._EnterCategory(cat);
|
||||
|
||||
_PreviewSelected = 0;
|
||||
_PreviewId = 0;
|
||||
_Locked = -1;
|
||||
_ActualSelection = 0;
|
||||
_AfterCategoryChange();
|
||||
@@ -567,7 +568,7 @@ namespace VocaluxeLib.Menu.SongMenu
|
||||
{
|
||||
base._ShowCategories();
|
||||
|
||||
_PreviewSelected = 0;
|
||||
_PreviewId = 0;
|
||||
_Locked = -1;
|
||||
_ActualSelection = 0;
|
||||
_AfterCategoryChange();
|
||||
@@ -594,8 +595,8 @@ namespace VocaluxeLib.Menu.SongMenu
|
||||
|
||||
private void _AfterCategoryChange()
|
||||
{
|
||||
_SetSelectedNow();
|
||||
_SelectSong(_PreviewSelected);
|
||||
_SelectSong(_PreviewId);
|
||||
_UpdatePreview();
|
||||
|
||||
foreach (CStatic tile in _Tiles)
|
||||
tile.Selected = false;
|
||||
|
||||
@@ -24,13 +24,6 @@ namespace VocaluxeLib.Profile
|
||||
{
|
||||
public class CProfile
|
||||
{
|
||||
private static readonly XmlWriterSettings _Settings = new XmlWriterSettings
|
||||
{
|
||||
Indent = true,
|
||||
Encoding = Encoding.UTF8,
|
||||
ConformanceLevel = ConformanceLevel.Document
|
||||
};
|
||||
|
||||
public int ID;
|
||||
|
||||
public string PlayerName;
|
||||
@@ -137,7 +130,7 @@ namespace VocaluxeLib.Profile
|
||||
XmlWriter writer;
|
||||
try
|
||||
{
|
||||
writer = XmlWriter.Create(Path.Combine(FilePath, FileName), _Settings);
|
||||
writer = XmlWriter.Create(Path.Combine(FilePath, FileName), CBase.Config.GetXMLSettings());
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
|
||||
using System.Collections.Generic;
|
||||
using VocaluxeLib.Draw;
|
||||
using System.Linq;
|
||||
|
||||
namespace VocaluxeLib.Songs
|
||||
{
|
||||
@@ -50,6 +51,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