Merge branch 'develop' of github.com:Flamefire/Vocaluxe into sound-player
Conflicts: PartyModes/PartyModeTicTacToe/CPartyScreenTicTacToeMain.cs VocaluxeLib/Menu/SongMenu/CSongMenuFramework.cs
This commit is contained in:
commit
bd41de6dbe
53 files changed
+1150
-1273
No files matched your search
@@ -118,7 +118,7 @@ namespace Vocaluxe.Base
|
||||
if (_Initialized)
|
||||
return;
|
||||
|
||||
List<string> soundFiles = CHelper.ListSoundFiles(CSettings.FolderBackgroundMusic, true, true);
|
||||
List<string> soundFiles = CHelper.ListSoundFiles(CSettings.FolderNameBackgroundMusic, true, true);
|
||||
|
||||
foreach (string path in soundFiles)
|
||||
_BGMusicFiles.Add(new CPlaylistElement(path));
|
||||
|
||||
+13
-17
@@ -46,11 +46,9 @@ namespace Vocaluxe.Base
|
||||
private static bool _Initialized;
|
||||
|
||||
// Base file and folder names (formerly from CSettings but they can be changed)
|
||||
private const string _FolderProfiles = "Profiles"; //Use ProfileFolders for access
|
||||
private const string _FolderSongs = "Songs"; //Use SongFolders for access
|
||||
public static string FolderPlaylists = "Playlists";
|
||||
public static string FileHighscoreDB = "HighscoreDB.sqlite";
|
||||
private static string _FileConfig = "Config.xml";
|
||||
public static string FolderPlaylists = Path.Combine(CSettings.DataFolder, "Playlists");
|
||||
public static string FileHighscoreDB = Path.Combine(CSettings.DataFolder, "HighscoreDB.sqlite");
|
||||
private static string _FileConfig = Path.Combine(CSettings.DataFolder, "Config.xml");
|
||||
|
||||
// Debug
|
||||
public static EDebugLevel DebugLevel = EDebugLevel.TR_CONFIG_OFF;
|
||||
@@ -108,10 +106,10 @@ namespace Vocaluxe.Base
|
||||
//Folders
|
||||
public static readonly List<string> SongFolders = new List<string>
|
||||
{
|
||||
Path.Combine(Directory.GetCurrentDirectory(), _FolderSongs)
|
||||
Path.Combine(CSettings.ProgramFolder, CSettings.FolderNameSongs)
|
||||
|
||||
#if INSTALLER
|
||||
,Path.Combine(CSettings.DataPath, CSettings.FolderSongs);
|
||||
,Path.Combine(CSettings.DataFolder, CSettings.FolderNameSongs);
|
||||
#endif
|
||||
};
|
||||
/// <summary>
|
||||
@@ -121,9 +119,9 @@ namespace Vocaluxe.Base
|
||||
public static readonly List<string> ProfileFolders = new List<string>
|
||||
{
|
||||
#if INSTALLER
|
||||
Path.Combine(Environment.CurrentDirectory, CSettings.FolderProfiles),
|
||||
Path.Combine(Environment.CurrentDirectory, CSettings.FolderNameProfiles),
|
||||
#endif
|
||||
Path.Combine(CSettings.DataPath, _FolderProfiles)
|
||||
Path.Combine(CSettings.DataFolder, CSettings.FolderNameProfiles)
|
||||
};
|
||||
|
||||
// Game
|
||||
@@ -202,7 +200,7 @@ namespace Vocaluxe.Base
|
||||
return;
|
||||
|
||||
// Init config file
|
||||
if (!File.Exists(Path.Combine(CSettings.DataPath, _FileConfig)))
|
||||
if (!File.Exists(_FileConfig))
|
||||
SaveConfig();
|
||||
else
|
||||
_LoadConfig();
|
||||
@@ -212,7 +210,7 @@ namespace Vocaluxe.Base
|
||||
|
||||
private static void _LoadConfig()
|
||||
{
|
||||
CXMLReader xmlReader = CXMLReader.OpenFile(Path.Combine(CSettings.DataPath, _FileConfig));
|
||||
CXMLReader xmlReader = CXMLReader.OpenFile(_FileConfig);
|
||||
if (xmlReader == null)
|
||||
return;
|
||||
|
||||
@@ -357,7 +355,7 @@ namespace Vocaluxe.Base
|
||||
XmlWriter writer = null;
|
||||
try
|
||||
{
|
||||
writer = XmlWriter.Create(Path.Combine(CSettings.DataPath, _FileConfig), XMLSettings);
|
||||
writer = XmlWriter.Create(_FileConfig, XMLSettings);
|
||||
writer.WriteStartDocument();
|
||||
writer.WriteStartElement("root");
|
||||
|
||||
@@ -373,7 +371,7 @@ namespace Vocaluxe.Base
|
||||
writer.WriteElementString("Screens", Screen.AllScreens.Length.ToString());
|
||||
writer.WriteElementString("PrimaryScreenResolution", Screen.PrimaryScreen.Bounds.Size.ToString());
|
||||
|
||||
writer.WriteElementString("Directory", Environment.CurrentDirectory);
|
||||
writer.WriteElementString("Directory", CSettings.ProgramFolder);
|
||||
|
||||
writer.WriteEndElement();
|
||||
|
||||
@@ -806,10 +804,8 @@ namespace Vocaluxe.Base
|
||||
//Check each parameter
|
||||
for (int i = 0; i < _Params.Count; i++)
|
||||
{
|
||||
//Switch parameter as lower case
|
||||
string param = _Params[i];
|
||||
|
||||
param = param.ToLower();
|
||||
//Switch parameter to lower case
|
||||
string param = _Params[i].ToLower();
|
||||
|
||||
string value = _Values[i];
|
||||
|
||||
|
||||
@@ -143,7 +143,7 @@ namespace Vocaluxe.Base
|
||||
{
|
||||
_CoverThemes.Clear();
|
||||
|
||||
const string path = CSettings.FolderCover;
|
||||
string path = Path.Combine(CSettings.ProgramFolder, CSettings.FolderNameCover);
|
||||
List<string> files = CHelper.ListFiles(path, "*.xml");
|
||||
|
||||
foreach (string file in files)
|
||||
@@ -179,10 +179,10 @@ namespace Vocaluxe.Base
|
||||
|
||||
var ignoreList = new List<string>();
|
||||
|
||||
string coverPath = Path.Combine(CSettings.FolderCover, coverTheme.Folder);
|
||||
string coverPath = Path.Combine(CSettings.ProgramFolder, CSettings.FolderNameCover, coverTheme.Folder);
|
||||
List<string> files = CHelper.ListImageFiles(coverPath, true, true);
|
||||
|
||||
CXMLReader xmlReader = CXMLReader.OpenFile(Path.Combine(CSettings.FolderCover, coverTheme.File));
|
||||
CXMLReader xmlReader = CXMLReader.OpenFile(Path.Combine(CSettings.ProgramFolder, CSettings.FolderNameCover, coverTheme.File));
|
||||
lock (_Covers)
|
||||
{
|
||||
if (xmlReader != null)
|
||||
@@ -195,7 +195,7 @@ namespace Vocaluxe.Base
|
||||
string filePath;
|
||||
xmlReader.GetValue("//root/Cover/" + coverName + "/Name", out name, String.Empty);
|
||||
xmlReader.GetValue("//root/Cover/" + coverName + "/Path", out filePath, String.Empty);
|
||||
string coverFilePath = Path.Combine(CSettings.FolderCover, Path.Combine(coverTheme.Folder, filePath));
|
||||
string coverFilePath = Path.Combine(CSettings.ProgramFolder, CSettings.FolderNameCover, coverTheme.Folder, filePath);
|
||||
if (!File.Exists(coverFilePath))
|
||||
continue;
|
||||
|
||||
|
||||
@@ -32,9 +32,9 @@ namespace Vocaluxe.Base
|
||||
|
||||
public static bool Init()
|
||||
{
|
||||
_HighscoreDB = new CHighscoreDB(Path.Combine(Environment.CurrentDirectory, CConfig.FileHighscoreDB));
|
||||
_CoverDB = new CCoverDB(Path.Combine(Environment.CurrentDirectory, CSettings.FileCoverDB));
|
||||
_ResourceDB = new CResourceDB(Path.Combine(Environment.CurrentDirectory, CSettings.FileCreditsRessourcesDB));
|
||||
_HighscoreDB = new CHighscoreDB(CConfig.FileHighscoreDB);
|
||||
_CoverDB = new CCoverDB(Path.Combine(CSettings.DataFolder, CSettings.FileNameCoverDB));
|
||||
_ResourceDB = new CResourceDB(Path.Combine(CSettings.ProgramFolder, CSettings.FileNameCreditsRessourcesDB));
|
||||
|
||||
if (!_HighscoreDB.Init())
|
||||
{
|
||||
|
||||
@@ -74,7 +74,7 @@ namespace Vocaluxe.Base
|
||||
_Languages = new List<SLanguage>();
|
||||
|
||||
var files = new List<string>();
|
||||
files.AddRange(CHelper.ListFiles(CSettings.FolderLanguages, "*.xml", true, true));
|
||||
files.AddRange(CHelper.ListFiles(CSettings.FolderNameLanguages, "*.xml", true, true));
|
||||
|
||||
foreach (string file in files)
|
||||
_LoadLanguageFile(file);
|
||||
@@ -214,7 +214,7 @@ namespace Vocaluxe.Base
|
||||
|
||||
private static void _LoadLanguageFile(string fileName)
|
||||
{
|
||||
var lang = new SLanguage {LanguageFilePath = Path.Combine(CSettings.FolderLanguages, fileName)};
|
||||
var lang = new SLanguage {LanguageFilePath = Path.Combine(CSettings.ProgramFolder, CSettings.FolderNameLanguages, fileName)};
|
||||
|
||||
CXMLReader xmlReader = CXMLReader.OpenFile(lang.LanguageFilePath);
|
||||
if (xmlReader == null)
|
||||
|
||||
@@ -42,7 +42,7 @@ namespace Vocaluxe.Base
|
||||
{
|
||||
if (_LogFile != null)
|
||||
return;
|
||||
_LogFile = new StreamWriter(Path.Combine(CSettings.DataPath, _LogFileName), false, Encoding.UTF8);
|
||||
_LogFile = new StreamWriter(Path.Combine(CSettings.DataFolder, _LogFileName), false, Encoding.UTF8);
|
||||
|
||||
_LogFile.WriteLine(_LogName + " " + CSettings.GetFullVersionText() + " " + DateTime.Now);
|
||||
_LogFile.WriteLine("----------------------------------------");
|
||||
@@ -117,11 +117,11 @@ namespace Vocaluxe.Base
|
||||
|
||||
public static void Init()
|
||||
{
|
||||
_ErrorLog = new CErrorLogFile(CSettings.FileErrorLog, "Error-Log");
|
||||
_PerformanceLog = new CLogFile(CSettings.FilePerformanceLog, "Performance-Log");
|
||||
_BenchmarkLog = new CLogFile(CSettings.FileBenchmarkLog, "Benchmark-Log");
|
||||
_DebugLog = new CLogFile(CSettings.FileDebugLog, "Debug-Log");
|
||||
_SongInfoLog = new CLogFile(CSettings.FileSongInfoLog, "Song-Information-Log");
|
||||
_ErrorLog = new CErrorLogFile(CSettings.FileNameErrorLog, "Error-Log");
|
||||
_PerformanceLog = new CLogFile(CSettings.FileNamePerformanceLog, "Performance-Log");
|
||||
_BenchmarkLog = new CLogFile(CSettings.FileNameBenchmarkLog, "Benchmark-Log");
|
||||
_DebugLog = new CLogFile(CSettings.FileNameDebugLog, "Debug-Log");
|
||||
_SongInfoLog = new CLogFile(CSettings.FileNameSongInfoLog, "Song-Information-Log");
|
||||
|
||||
_BenchmarkTimer = new Stopwatch[_MaxBenchmarks];
|
||||
for (int i = 0; i < _BenchmarkTimer.Length; i++)
|
||||
|
||||
+45
-30
@@ -231,7 +231,7 @@ namespace Vocaluxe.Base
|
||||
|
||||
public string GetDataPath()
|
||||
{
|
||||
return CSettings.DataPath;
|
||||
return CSettings.DataFolder;
|
||||
}
|
||||
|
||||
public float GetSlideShowImageTime()
|
||||
@@ -340,7 +340,7 @@ namespace Vocaluxe.Base
|
||||
return CBackgroundMusic.VideoEnabled;
|
||||
}
|
||||
|
||||
public void SetStatus(bool disabled)
|
||||
public void SetDisabled(bool disabled)
|
||||
{
|
||||
CBackgroundMusic.Disabled = disabled;
|
||||
}
|
||||
@@ -582,6 +582,16 @@ namespace Vocaluxe.Base
|
||||
{
|
||||
return CGame.GetNumSongs();
|
||||
}
|
||||
|
||||
public CSong GetSong()
|
||||
{
|
||||
return CGame.GetSong();
|
||||
}
|
||||
|
||||
public CSong GetSong(int round)
|
||||
{
|
||||
return CGame.GetSong(round);
|
||||
}
|
||||
}
|
||||
|
||||
class CBprofiles : IProfiles
|
||||
@@ -870,29 +880,34 @@ namespace Vocaluxe.Base
|
||||
|
||||
class CBplaylist : IPlaylist
|
||||
{
|
||||
public void SetPlaylistName(int playlistID, string name)
|
||||
public void SetName(int playlistID, string name)
|
||||
{
|
||||
CPlaylists.SetPlaylistName(playlistID, name);
|
||||
CPlaylists.SetName(playlistID, name);
|
||||
}
|
||||
|
||||
public List<string> GetPlaylistNames()
|
||||
public List<string> GetNames()
|
||||
{
|
||||
return CPlaylists.PlaylistNames;
|
||||
return CPlaylists.Names;
|
||||
}
|
||||
|
||||
public string GetPlaylistName(int playlistID)
|
||||
public bool Exists(int playlistID)
|
||||
{
|
||||
return CPlaylists.GetPlaylistName(playlistID);
|
||||
return CPlaylists.Get(playlistID) != null;
|
||||
}
|
||||
|
||||
public void DeletePlaylist(int playlistID)
|
||||
public string GetName(int playlistID)
|
||||
{
|
||||
CPlaylists.DeletePlaylist(playlistID);
|
||||
return CPlaylists.GetName(playlistID);
|
||||
}
|
||||
|
||||
public void SavePlaylist(int playlistID)
|
||||
public void Delete(int playlistID)
|
||||
{
|
||||
CPlaylists.SavePlaylist(playlistID);
|
||||
CPlaylists.Delete(playlistID);
|
||||
}
|
||||
|
||||
public void Save(int playlistID)
|
||||
{
|
||||
CPlaylists.Save(playlistID);
|
||||
}
|
||||
|
||||
public int GetNumPlaylists()
|
||||
@@ -900,49 +915,49 @@ namespace Vocaluxe.Base
|
||||
return CPlaylists.NumPlaylists;
|
||||
}
|
||||
|
||||
public void AddPlaylistSong(int playlistID, int songID)
|
||||
public void AddSong(int playlistID, int songID)
|
||||
{
|
||||
CPlaylists.AddPlaylistSong(playlistID, songID);
|
||||
CPlaylists.AddSong(playlistID, songID);
|
||||
}
|
||||
|
||||
public void AddPlaylistSong(int playlistID, int songID, EGameMode gameMode)
|
||||
public void AddSong(int playlistID, int songID, EGameMode gameMode)
|
||||
{
|
||||
CPlaylists.AddPlaylistSong(playlistID, songID, gameMode);
|
||||
CPlaylists.AddSong(playlistID, songID, gameMode);
|
||||
}
|
||||
|
||||
public void InsertPlaylistSong(int playlistID, int positionIndex, int songID, EGameMode gameMode)
|
||||
public void InsertSong(int playlistID, int positionIndex, int songID, EGameMode gameMode)
|
||||
{
|
||||
CPlaylists.InsertPlaylistSong(playlistID, positionIndex, songID, gameMode);
|
||||
CPlaylists.InsertSong(playlistID, positionIndex, songID, gameMode);
|
||||
}
|
||||
|
||||
public void MovePlaylistSong(int playlistID, int sourceIndex, int destIndex)
|
||||
public void MoveSong(int playlistID, int sourceIndex, int destIndex)
|
||||
{
|
||||
CPlaylists.MovePlaylistSong(playlistID, sourceIndex, destIndex);
|
||||
CPlaylists.MoveSong(playlistID, sourceIndex, destIndex);
|
||||
}
|
||||
|
||||
public void MovePlaylistSongDown(int playlistID, int songIndex)
|
||||
public void MoveSongDown(int playlistID, int songIndex)
|
||||
{
|
||||
CPlaylists.MovePlaylistSongDown(playlistID, songIndex);
|
||||
CPlaylists.MovePSongDown(playlistID, songIndex);
|
||||
}
|
||||
|
||||
public void MovePlaylistSongUp(int playlistID, int songIndex)
|
||||
public void MoveSongUp(int playlistID, int songIndex)
|
||||
{
|
||||
CPlaylists.MovePlaylistSongUp(playlistID, songIndex);
|
||||
CPlaylists.MoveSongUp(playlistID, songIndex);
|
||||
}
|
||||
|
||||
public void DeletePlaylistSong(int playlistID, int songIndex)
|
||||
public void DeleteSong(int playlistID, int songIndex)
|
||||
{
|
||||
CPlaylists.DeletePlaylistSong(playlistID, songIndex);
|
||||
CPlaylists.DeleteSong(playlistID, songIndex);
|
||||
}
|
||||
|
||||
public int GetPlaylistSongCount(int playlistID)
|
||||
public int GetSongCount(int playlistID)
|
||||
{
|
||||
return CPlaylists.GetPlaylistSongCount(playlistID);
|
||||
return CPlaylists.GetSongCount(playlistID);
|
||||
}
|
||||
|
||||
public CPlaylistSong GetPlaylistSong(int playlistID, int songIndex)
|
||||
public CPlaylistSong GetSong(int playlistID, int songIndex)
|
||||
{
|
||||
return CPlaylists.GetPlaylistSong(playlistID, songIndex);
|
||||
return CPlaylists.GetSong(playlistID, songIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -218,7 +218,7 @@ namespace Vocaluxe.Base
|
||||
private static void _LoadPartyModes()
|
||||
{
|
||||
var files = new List<string>();
|
||||
files.AddRange(CHelper.ListFiles(CSettings.FolderPartyModes, "*.xml", false, true));
|
||||
files.AddRange(CHelper.ListFiles(CSettings.FolderNamePartyModes, "*.xml", false, true));
|
||||
|
||||
foreach (string file in files)
|
||||
{
|
||||
@@ -269,7 +269,8 @@ namespace Vocaluxe.Base
|
||||
return pm;
|
||||
}
|
||||
|
||||
string pathToCode = Path.Combine(Path.Combine(CSettings.FolderPartyModes, pm.Folder), CSettings.FolderPartyModeCode);
|
||||
string pathToPm = Path.Combine(CSettings.ProgramFolder, CSettings.FolderNamePartyModes, pm.Folder);
|
||||
string pathToCode = Path.Combine(pathToPm, CSettings.FolderNamePartyModeCode);
|
||||
|
||||
var filesToCompile = new List<string>();
|
||||
filesToCompile.AddRange(CHelper.ListFiles(pathToCode, "*.cs", false, true));
|
||||
@@ -278,7 +279,7 @@ namespace Vocaluxe.Base
|
||||
if (output == null)
|
||||
return pm;
|
||||
|
||||
if (!CLanguage.LoadPartyLanguageFiles(pm.PartyModeID, Path.Combine(Path.Combine(CSettings.FolderPartyModes, pm.Folder), CSettings.FolderPartyModeLanguages)))
|
||||
if (!CLanguage.LoadPartyLanguageFiles(pm.PartyModeID, Path.Combine(pathToPm, CSettings.FolderNamePartyModeLanguages)))
|
||||
{
|
||||
CLog.LogError("Error loading language files for PartyMode: " + file);
|
||||
return pm;
|
||||
@@ -301,9 +302,9 @@ namespace Vocaluxe.Base
|
||||
return pm;
|
||||
}
|
||||
pm.PartyMode.Initialize();
|
||||
pm.PartyMode.SetFolder(Path.Combine(Directory.GetCurrentDirectory(), Path.Combine(CSettings.FolderPartyModes, pm.Folder)));
|
||||
pm.PartyMode.SetFolder(pathToPm);
|
||||
|
||||
if (!CTheme.AddTheme(Path.Combine(pm.PartyMode.GetFolder(), "Theme.xml"), pm.PartyModeID))
|
||||
if (!CTheme.AddTheme(Path.Combine(pathToPm, "Theme.xml"), pm.PartyModeID))
|
||||
return pm;
|
||||
|
||||
int themeIndex = CTheme.GetThemeIndex(pm.PartyModeID);
|
||||
@@ -318,7 +319,7 @@ namespace Vocaluxe.Base
|
||||
|
||||
foreach (string screenfile in pm.ScreenFiles)
|
||||
{
|
||||
string xmlPath = Path.Combine(Path.Combine(CSettings.FolderPartyModes, pm.Folder), CSettings.FolderPartyModeScreens);
|
||||
string xmlPath = Path.Combine(pathToPm, CSettings.FolderNamePartyModeScreens);
|
||||
CMenuParty screen = _GetPartyScreenInstance(output, screenfile, pm.Folder);
|
||||
|
||||
if (screen != null)
|
||||
|
||||
+86
-99
@@ -31,15 +31,16 @@ namespace Vocaluxe.Base
|
||||
static class CPlaylists
|
||||
{
|
||||
private static List<CPlaylistFile> _Playlists;
|
||||
private static int _NextID;
|
||||
|
||||
public static CPlaylistFile[] Playlists
|
||||
public static IEnumerable<CPlaylistFile> Playlists
|
||||
{
|
||||
get { return _Playlists.ToArray(); }
|
||||
get { return _Playlists.AsReadOnly(); }
|
||||
}
|
||||
|
||||
public static List<string> PlaylistNames
|
||||
public static List<string> Names
|
||||
{
|
||||
get { return _Playlists.Select(t => t.PlaylistName).ToList(); }
|
||||
get { return _Playlists.Select(t => t.Name).ToList(); }
|
||||
}
|
||||
|
||||
public static int NumPlaylists
|
||||
@@ -49,176 +50,169 @@ namespace Vocaluxe.Base
|
||||
|
||||
public static void Init()
|
||||
{
|
||||
LoadPlaylists();
|
||||
Load();
|
||||
_ConvertUSDXPlaylists();
|
||||
|
||||
_SortPlaylistsByName();
|
||||
_SortByName();
|
||||
}
|
||||
|
||||
private static void _ConvertUSDXPlaylists()
|
||||
{
|
||||
var files = new List<string>();
|
||||
files.AddRange(CHelper.ListFiles(Path.Combine(CSettings.DataPath, CConfig.FolderPlaylists), "*.upl", true, true));
|
||||
files.AddRange(CHelper.ListFiles(Path.Combine(CSettings.DataFolder, CConfig.FolderPlaylists), "*.upl", true, true));
|
||||
|
||||
foreach (string file in files)
|
||||
{
|
||||
CPlaylistFile playlist = _ConvertUSDXPlaylist(file);
|
||||
playlist.SavePlaylist();
|
||||
playlist.Save();
|
||||
_Playlists.Add(playlist);
|
||||
}
|
||||
}
|
||||
|
||||
public static void LoadPlaylists()
|
||||
public static void Load()
|
||||
{
|
||||
_Playlists = new List<CPlaylistFile>();
|
||||
|
||||
var files = new List<string>();
|
||||
files.AddRange(CHelper.ListFiles(Path.Combine(CSettings.DataPath, CConfig.FolderPlaylists), "*.xml", true, true));
|
||||
files.AddRange(CHelper.ListFiles(Path.Combine(CSettings.DataFolder, CConfig.FolderPlaylists), "*.xml", true, true));
|
||||
|
||||
foreach (string file in files)
|
||||
{
|
||||
CPlaylistFile playlist = new CPlaylistFile(file, files.IndexOf(file));
|
||||
CPlaylistFile playlist = new CPlaylistFile(files.IndexOf(file), file);
|
||||
_Playlists.Add(playlist);
|
||||
}
|
||||
}
|
||||
|
||||
public static string GetPlaylistName(int playlistID)
|
||||
public static CPlaylistFile Get(int playlistID)
|
||||
{
|
||||
if (playlistID >= _Playlists.Count || playlistID < 0)
|
||||
return "Error: Can't find Playlist";
|
||||
|
||||
return _Playlists[playlistID].PlaylistName;
|
||||
return _Playlists.FirstOrDefault(pl => pl.Id == playlistID);
|
||||
}
|
||||
|
||||
public static void SetPlaylistName(int playlistID, string name)
|
||||
public static string GetName(int playlistID)
|
||||
{
|
||||
if (playlistID >= _Playlists.Count || playlistID < 0)
|
||||
return;
|
||||
|
||||
_Playlists[playlistID].PlaylistName = name;
|
||||
CPlaylistFile pl = Get(playlistID);
|
||||
return pl == null ? "Error: Can't find Playlist" : pl.Name;
|
||||
}
|
||||
|
||||
public static void DeletePlaylist(int playlistID)
|
||||
public static void SetName(int playlistID, string name)
|
||||
{
|
||||
if (playlistID < 0 || playlistID >= _Playlists.Count)
|
||||
CPlaylistFile pl = Get(playlistID);
|
||||
|
||||
if (pl != null)
|
||||
pl.Name = name;
|
||||
}
|
||||
|
||||
public static void Delete(int playlistID)
|
||||
{
|
||||
CPlaylistFile pl = Get(playlistID);
|
||||
if (pl == null)
|
||||
return;
|
||||
if (_Playlists[playlistID].PlaylistFile != "")
|
||||
if (pl.File != "" && File.Exists(pl.File))
|
||||
{
|
||||
try
|
||||
{
|
||||
File.Delete(_Playlists[playlistID].PlaylistFile);
|
||||
File.Delete(pl.File);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
CLog.LogError("Can't delete Playlist File " + _Playlists[playlistID].PlaylistFile + ".xml");
|
||||
CLog.LogError("Can't delete Playlist File " + _Playlists[playlistID].File + ".xml");
|
||||
}
|
||||
}
|
||||
_Playlists.RemoveAt(playlistID);
|
||||
_Playlists.Remove(pl);
|
||||
}
|
||||
|
||||
public static void SavePlaylist(int playlistID)
|
||||
public static void Save(int playlistID)
|
||||
{
|
||||
if (playlistID < 0 || playlistID >= _Playlists.Count)
|
||||
return;
|
||||
_Playlists[playlistID].SavePlaylist();
|
||||
CPlaylistFile pl = Get(playlistID);
|
||||
if (pl != null)
|
||||
pl.Save();
|
||||
}
|
||||
|
||||
public static int NewPlaylist()
|
||||
public static int NewPlaylist(string name = "New Playlist")
|
||||
{
|
||||
CPlaylistFile pl = new CPlaylistFile {PlaylistName = "New Playlist", Id = _Playlists.Count};
|
||||
CPlaylistFile pl = new CPlaylistFile(_NextID++) {Name = name};
|
||||
_Playlists.Add(pl);
|
||||
return _Playlists.Count - 1;
|
||||
return pl.Id;
|
||||
}
|
||||
|
||||
public static void AddPlaylistSong(int playlistID, int songID)
|
||||
public static void AddSong(int playlistID, int songID)
|
||||
{
|
||||
if (playlistID >= _Playlists.Count || playlistID < 0)
|
||||
return;
|
||||
|
||||
_Playlists[playlistID].AddSong(songID);
|
||||
CPlaylistFile pl = Get(playlistID);
|
||||
if (pl != null)
|
||||
pl.AddSong(songID);
|
||||
}
|
||||
|
||||
public static void AddPlaylistSong(int playlistID, int songID, EGameMode gameMode)
|
||||
public static void AddSong(int playlistID, int songID, EGameMode gameMode)
|
||||
{
|
||||
if (playlistID >= _Playlists.Count || playlistID < 0)
|
||||
return;
|
||||
|
||||
_Playlists[playlistID].AddSong(songID, gameMode);
|
||||
CPlaylistFile pl = Get(playlistID);
|
||||
if (pl != null)
|
||||
pl.AddSong(songID, gameMode);
|
||||
}
|
||||
|
||||
public static void InsertPlaylistSong(int playlistID, int positionIndex, int songID, EGameMode gameMode)
|
||||
public static void InsertSong(int playlistID, int positionIndex, int songID, EGameMode gameMode)
|
||||
{
|
||||
if (playlistID >= _Playlists.Count || playlistID < 0)
|
||||
return;
|
||||
|
||||
_Playlists[playlistID].SongInsert(positionIndex, songID, gameMode);
|
||||
CPlaylistFile pl = Get(playlistID);
|
||||
if (pl != null)
|
||||
pl.InsertSong(positionIndex, songID, gameMode);
|
||||
}
|
||||
|
||||
public static void MovePlaylistSong(int playlistID, int sourceIndex, int destIndex)
|
||||
public static void MoveSong(int playlistID, int sourceIndex, int destIndex)
|
||||
{
|
||||
if (playlistID >= _Playlists.Count || playlistID < 0)
|
||||
return;
|
||||
|
||||
_Playlists[playlistID].SongMove(sourceIndex, destIndex);
|
||||
CPlaylistFile pl = Get(playlistID);
|
||||
if (pl != null)
|
||||
pl.MoveSong(sourceIndex, destIndex);
|
||||
}
|
||||
|
||||
public static void MovePlaylistSongDown(int playlistID, int songIndex)
|
||||
public static void MovePSongDown(int playlistID, int songIndex)
|
||||
{
|
||||
if (playlistID >= _Playlists.Count || playlistID < 0)
|
||||
return;
|
||||
|
||||
_Playlists[playlistID].SongDown(songIndex);
|
||||
CPlaylistFile pl = Get(playlistID);
|
||||
if (pl != null)
|
||||
pl.MoveSongDown(songIndex);
|
||||
}
|
||||
|
||||
public static void MovePlaylistSongUp(int playlistID, int songIndex)
|
||||
public static void MoveSongUp(int playlistID, int songIndex)
|
||||
{
|
||||
if (playlistID >= _Playlists.Count || playlistID < 0)
|
||||
return;
|
||||
|
||||
_Playlists[playlistID].SongUp(songIndex);
|
||||
CPlaylistFile pl = Get(playlistID);
|
||||
if (pl != null)
|
||||
pl.MoveSongUp(songIndex);
|
||||
}
|
||||
|
||||
public static void DeletePlaylistSong(int playlistID, int songIndex)
|
||||
public static void DeleteSong(int playlistID, int songIndex)
|
||||
{
|
||||
if (playlistID >= _Playlists.Count || playlistID < 0)
|
||||
return;
|
||||
|
||||
_Playlists[playlistID].DeleteSong(songIndex);
|
||||
CPlaylistFile pl = Get(playlistID);
|
||||
if (pl != null)
|
||||
pl.DeleteSong(songIndex);
|
||||
}
|
||||
|
||||
public static int GetPlaylistSongCount(int playlistID)
|
||||
public static int GetSongCount(int playlistID)
|
||||
{
|
||||
if (playlistID >= _Playlists.Count || playlistID < 0)
|
||||
return 0;
|
||||
|
||||
return _Playlists[playlistID].Songs.Count;
|
||||
CPlaylistFile pl = Get(playlistID);
|
||||
return pl != null ? pl.Songs.Count : -1;
|
||||
}
|
||||
|
||||
public static CPlaylistSong GetPlaylistSong(int playlistID, int songIndex)
|
||||
public static CPlaylistSong GetSong(int playlistID, int songIndex)
|
||||
{
|
||||
if (playlistID >= _Playlists.Count || playlistID < 0)
|
||||
CPlaylistFile pl = Get(playlistID);
|
||||
if (pl == null || songIndex >= pl.Songs.Count)
|
||||
return null;
|
||||
|
||||
if (songIndex >= _Playlists[playlistID].Songs.Count)
|
||||
return null;
|
||||
|
||||
return _Playlists[playlistID].Songs[songIndex];
|
||||
return pl.Songs[songIndex];
|
||||
}
|
||||
|
||||
#region private methods
|
||||
private static void _SortPlaylistsByName()
|
||||
private static void _SortByName()
|
||||
{
|
||||
_Playlists.Sort(_CompareByPlaylistName);
|
||||
_Playlists.Sort(_CompareByName);
|
||||
}
|
||||
|
||||
private static int _CompareByPlaylistName(CPlaylistFile a, CPlaylistFile b)
|
||||
private static int _CompareByName(CPlaylistFile a, CPlaylistFile b)
|
||||
{
|
||||
return String.CompareOrdinal(a.PlaylistName, b.PlaylistName);
|
||||
return String.CompareOrdinal(a.Name, b.Name);
|
||||
}
|
||||
|
||||
private static CPlaylistFile _ConvertUSDXPlaylist(string file)
|
||||
{
|
||||
var pl = new CPlaylistFile();
|
||||
var pl = new CPlaylistFile(_NextID++);
|
||||
ReadOnlyCollection<CSong> allSongs = CSongs.AllSongs;
|
||||
|
||||
if (!File.Exists(file))
|
||||
@@ -234,30 +228,23 @@ namespace Vocaluxe.Base
|
||||
int pos = line.IndexOf(":", StringComparison.Ordinal);
|
||||
if (pos <= 0)
|
||||
continue;
|
||||
//Name or comment
|
||||
if (line[0] == '#')
|
||||
{
|
||||
//Name or comment
|
||||
string identifier = line.Substring(1, pos - 1).Trim();
|
||||
string value = line.Substring(pos + 1, line.Length - pos - 1).Trim();
|
||||
if (identifier.ToUpper() == "NAME")
|
||||
pl.PlaylistName = value;
|
||||
pl.Name = value;
|
||||
}
|
||||
//Song
|
||||
else
|
||||
{
|
||||
//Song
|
||||
string artist = line.Substring(0, pos - 1).Trim();
|
||||
string title = line.Substring(pos + 1, line.Length - pos - 1).Trim();
|
||||
bool found = false;
|
||||
foreach (CSong song in allSongs)
|
||||
{
|
||||
if (song.Artist == artist && song.Title == title)
|
||||
{
|
||||
pl.AddSong(song.ID);
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!found)
|
||||
CSong plSong = allSongs.FirstOrDefault(song => song.Artist == artist && song.Title == title);
|
||||
if (plSong != null)
|
||||
pl.AddSong(plSong.ID);
|
||||
else
|
||||
CLog.LogError("Can't find song '" + title + "' from '" + artist + "' in playlist file: " + file);
|
||||
}
|
||||
}
|
||||
|
||||
+42
-36
@@ -71,45 +71,51 @@ namespace Vocaluxe.Base
|
||||
|
||||
public const int VertexBufferElements = 10000;
|
||||
|
||||
public static readonly string ProgramFolder = AppDomain.CurrentDomain.BaseDirectory;
|
||||
|
||||
#if INSTALLER
|
||||
public static readonly string DataPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "Vocaluxe");
|
||||
public static readonly string DataFolder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "Vocaluxe");
|
||||
#else
|
||||
public static readonly string DataPath = Environment.CurrentDirectory;
|
||||
public static readonly string DataFolder = ProgramFolder;
|
||||
#endif
|
||||
|
||||
public const string Icon = "Vocaluxe.ico";
|
||||
public const string Logo = "Logo.png";
|
||||
public const string FallbackLanguage = "English";
|
||||
public const string FileFonts = "Fonts.xml";
|
||||
|
||||
public const string FileOldHighscoreDB = "Ultrastar.db";
|
||||
public const string FileCoverDB = "CoverDB.sqlite";
|
||||
public const string FileCreditsRessourcesDB = "CreditsRessourcesDB.sqlite";
|
||||
public const string FilePerformanceLog = "Performance.log";
|
||||
public const string FileErrorLog = "Error.log";
|
||||
public const string FileBenchmarkLog = "Benchmark.log";
|
||||
public const string FileDebugLog = "Debug.log";
|
||||
public const string FileSongInfoLog = "SongInformation.log";
|
||||
public const string FileNameIcon = "Vocaluxe.ico";
|
||||
public const string FileNameLogo = "Logo.png";
|
||||
public const string FileNameFonts = "Fonts.xml";
|
||||
|
||||
public const string SoundT440 = "440Hz.mp3";
|
||||
public const string FileNameOldHighscoreDB = "Ultrastar.db";
|
||||
public const string FileNameCoverDB = "CoverDB.sqlite";
|
||||
public const string FileNameCreditsRessourcesDB = "CreditsRessourcesDB.sqlite";
|
||||
|
||||
public const string FolderCover = "Cover";
|
||||
public const string FolderGraphics = "Graphics";
|
||||
public const string FolderFonts = "Fonts";
|
||||
public const string FolderThemes = "Themes";
|
||||
public const string FolderThemeFonts = "Fonts";
|
||||
public const string FolderScreens = "Screens";
|
||||
public const string FolderPhotos = "Photos";
|
||||
public const string FolderSounds = "Sounds";
|
||||
public const string FolderLanguages = "Languages";
|
||||
public const string FolderScreenshots = "Screenshots";
|
||||
public const string FolderBackgroundMusic = "BackgroundMusic";
|
||||
public const string FileNamePerformanceLog = "Performance.log";
|
||||
public const string FileNameErrorLog = "Error.log";
|
||||
public const string FileNameBenchmarkLog = "Benchmark.log";
|
||||
public const string FileNameDebugLog = "Debug.log";
|
||||
public const string FileNameSongInfoLog = "SongInformation.log";
|
||||
|
||||
public const string FolderPartyModes = "PartyModes";
|
||||
public const string FolderPartyModeCode = "Code";
|
||||
public const string FolderPartyModeScreens = "Screens";
|
||||
public const string FolderPartyModeLanguages = "Languages";
|
||||
public const string FolderPartyModeFonts = "Fonts";
|
||||
public const string FileNameSoundT440 = "440Hz.mp3";
|
||||
|
||||
public const string FolderNameSongs = "Songs";
|
||||
public const string FolderNameProfiles = "Profiles";
|
||||
public const string FolderNameCover = "Cover";
|
||||
public const string FolderNameGraphics = "Graphics";
|
||||
public const string FolderNameFonts = "Fonts";
|
||||
public const string FolderNameThemes = "Themes";
|
||||
public const string FolderNameThemeFonts = "Fonts";
|
||||
public const string FolderNameScreens = "Screens";
|
||||
public const string FolderNamePhotos = "Photos";
|
||||
public const string FolderNameSounds = "Sounds";
|
||||
public const string FolderNameLanguages = "Languages";
|
||||
public const string FolderNameScreenshots = "Screenshots";
|
||||
public const string FolderNameBackgroundMusic = "BackgroundMusic";
|
||||
|
||||
public const string FolderNamePartyModes = "PartyModes";
|
||||
public const string FolderNamePartyModeCode = "Code";
|
||||
public const string FolderNamePartyModeScreens = "Screens";
|
||||
public const string FolderNamePartyModeLanguages = "Languages";
|
||||
public const string FolderNamePartyModeFonts = "Fonts";
|
||||
|
||||
public const string LinkAndroidApp = "https://build.phonegap.com/apps/639714/download/android/?qr_key=uY98ymvTr6K144RyTdhs";
|
||||
public const string LinkSymbianApp = "https://build.phonegap.com/apps/639714/download/symbian/?qr_key=uY98ymvTr6K144RyTdhs";
|
||||
@@ -213,12 +219,12 @@ namespace Vocaluxe.Base
|
||||
{
|
||||
var folders = new List<string>
|
||||
{
|
||||
Path.Combine(Environment.CurrentDirectory, FolderCover),
|
||||
Path.Combine(Environment.CurrentDirectory, FolderFonts),
|
||||
Path.Combine(DataPath, FolderScreenshots),
|
||||
Path.Combine(Environment.CurrentDirectory, FolderBackgroundMusic),
|
||||
Path.Combine(Environment.CurrentDirectory, FolderSounds),
|
||||
Path.Combine(DataPath, CConfig.FolderPlaylists)
|
||||
Path.Combine(ProgramFolder, FolderNameCover),
|
||||
Path.Combine(ProgramFolder, FolderNameFonts),
|
||||
Path.Combine(DataFolder, FolderNameScreenshots),
|
||||
Path.Combine(ProgramFolder, FolderNameBackgroundMusic),
|
||||
Path.Combine(ProgramFolder, FolderNameSounds),
|
||||
Path.Combine(DataFolder, CConfig.FolderPlaylists)
|
||||
};
|
||||
folders.AddRange(CConfig.ProfileFolders);
|
||||
folders.AddRange(CConfig.SongFolders);
|
||||
|
||||
@@ -85,7 +85,7 @@ namespace Vocaluxe.Base
|
||||
}
|
||||
|
||||
#region Stream Handling
|
||||
public static int Load(string media, bool loop=false, bool prescan=false)
|
||||
public static int Load(string media, bool loop = false, bool prescan = false)
|
||||
{
|
||||
return _Playback.Load(media, loop, prescan);
|
||||
}
|
||||
@@ -176,11 +176,11 @@ namespace Vocaluxe.Base
|
||||
#region Sounds
|
||||
public static int PlaySound(ESounds sound, bool fade = true)
|
||||
{
|
||||
string file = Path.Combine(Environment.CurrentDirectory, CSettings.FolderSounds);
|
||||
string file = Path.Combine(CSettings.ProgramFolder, CSettings.FolderNameSounds);
|
||||
switch (sound)
|
||||
{
|
||||
case ESounds.T440:
|
||||
file = Path.Combine(file, CSettings.SoundT440);
|
||||
file = Path.Combine(file, CSettings.FileNameSoundT440);
|
||||
break;
|
||||
default:
|
||||
return -1;
|
||||
|
||||
@@ -266,13 +266,13 @@ namespace Vocaluxe.Base
|
||||
{
|
||||
CFonts.LoadThemeFonts(
|
||||
_Themes[themeIndex].Name,
|
||||
Path.Combine(Path.Combine(_Themes[themeIndex].Path, _Themes[themeIndex].SkinFolder), CSettings.FolderThemeFonts),
|
||||
Path.Combine(Path.Combine(_Themes[themeIndex].Path, _Themes[themeIndex].SkinFolder), CSettings.FolderNameThemeFonts),
|
||||
xmlReader);
|
||||
}
|
||||
else
|
||||
{
|
||||
CFonts.LoadPartyModeFonts(_Themes[themeIndex].PartyModeID,
|
||||
Path.Combine(_Themes[themeIndex].Path, CSettings.FolderPartyModeFonts),
|
||||
Path.Combine(_Themes[themeIndex].Path, CSettings.FolderNamePartyModeFonts),
|
||||
xmlReader);
|
||||
}
|
||||
return true;
|
||||
@@ -385,11 +385,11 @@ namespace Vocaluxe.Base
|
||||
{
|
||||
_Themes.Clear();
|
||||
|
||||
string path = Path.Combine(Directory.GetCurrentDirectory(), CSettings.FolderThemes);
|
||||
List<string> files = CHelper.ListFiles(path, "*.xml");
|
||||
string path = Path.Combine(CSettings.ProgramFolder, CSettings.FolderNameThemes);
|
||||
List<string> files = CHelper.ListFiles(path, "*.xml", false, true);
|
||||
|
||||
foreach (string file in files)
|
||||
AddTheme(Path.Combine(path, file), -1);
|
||||
AddTheme(file, -1);
|
||||
}
|
||||
|
||||
public static bool AddTheme(string filePath, int partyModeID)
|
||||
@@ -546,7 +546,7 @@ namespace Vocaluxe.Base
|
||||
if (themeIndex != -1)
|
||||
{
|
||||
path = Path.Combine(_Themes[themeIndex].Path, _Themes[themeIndex].SkinFolder);
|
||||
path = Path.Combine(path, CSettings.FolderScreens);
|
||||
path = Path.Combine(path, CSettings.FolderNameScreens);
|
||||
}
|
||||
else
|
||||
CLog.LogError("Can't find current Theme");
|
||||
|
||||
@@ -341,11 +341,11 @@ namespace Vocaluxe.Base.Fonts
|
||||
/// <returns></returns>
|
||||
private static void _LoadFontList()
|
||||
{
|
||||
CXMLReader xmlReader = CXMLReader.OpenFile(Path.Combine(CSettings.FolderFonts, CSettings.FileFonts));
|
||||
CXMLReader xmlReader = CXMLReader.OpenFile(Path.Combine(CSettings.ProgramFolder, CSettings.FolderNameFonts, CSettings.FileNameFonts));
|
||||
if (xmlReader == null)
|
||||
return;
|
||||
|
||||
_LoadFontFiles(xmlReader, Path.Combine(Directory.GetCurrentDirectory(), CSettings.FolderFonts));
|
||||
_LoadFontFiles(xmlReader, Path.Combine(CSettings.ProgramFolder, CSettings.FolderNameFonts));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -342,7 +342,7 @@ namespace Vocaluxe.Base.Server
|
||||
return false;
|
||||
|
||||
string name = DateTime.Now.ToString("yyyy-MM-dd_HH-mm-ss");
|
||||
string filePath = _SaveImage(photoData.Photo, name, CSettings.FolderPhotos);
|
||||
string filePath = _SaveImage(photoData.Photo, name, CSettings.FolderNamePhotos);
|
||||
if (!string.IsNullOrEmpty(filePath))
|
||||
{
|
||||
_PhotosOfThisRound.Add(filePath);
|
||||
@@ -461,20 +461,20 @@ namespace Vocaluxe.Base.Server
|
||||
|
||||
private static SPlaylistInfo _GetPlaylist(int playlistId)
|
||||
{
|
||||
if (CPlaylists.Playlists.Length <= playlistId || playlistId < 0)
|
||||
if (CPlaylists.Get(playlistId) == null)
|
||||
throw new ArgumentException("invalid playlistId");
|
||||
return _GetPlaylistInfo(CPlaylists.Playlists[playlistId]);
|
||||
return _GetPlaylistInfo(CPlaylists.Get(playlistId));
|
||||
}
|
||||
|
||||
private static void _AddSongToPlaylist(int songId, int playlistId, bool allowDuplicates)
|
||||
{
|
||||
if (CPlaylists.Playlists.Length <= playlistId || playlistId < 0)
|
||||
if (CPlaylists.Get(playlistId) == null)
|
||||
throw new ArgumentException("invalid playlistId");
|
||||
|
||||
if (allowDuplicates || !_PlaylistContainsSong(songId, playlistId))
|
||||
{
|
||||
CPlaylists.AddPlaylistSong(playlistId, songId);
|
||||
CPlaylists.SavePlaylist(playlistId);
|
||||
CPlaylists.AddSong(playlistId, songId);
|
||||
CPlaylists.Save(playlistId);
|
||||
}
|
||||
else
|
||||
throw new ArgumentException("song exists in this playlist");
|
||||
@@ -482,45 +482,49 @@ namespace Vocaluxe.Base.Server
|
||||
|
||||
private static void _RemoveSongFromPlaylist(int position, int playlistId, int songId)
|
||||
{
|
||||
if (CPlaylists.Playlists.Length <= playlistId || playlistId < 0)
|
||||
CPlaylistFile pl = CPlaylists.Get(playlistId);
|
||||
if (pl == null)
|
||||
throw new ArgumentException("invalid playlistId");
|
||||
if (!_PlaylistContainsSong(songId, playlistId))
|
||||
throw new ArgumentException("invalid songId");
|
||||
if (position < 0 || CPlaylists.Playlists[playlistId].Songs.Count <= position
|
||||
|| CPlaylists.Playlists[playlistId].Songs[position].SongID != songId)
|
||||
if (position < 0 || pl.Songs.Count <= position
|
||||
|| pl.Songs[position].SongID != songId)
|
||||
throw new ArgumentException("invalid position");
|
||||
CPlaylists.Playlists[playlistId].DeleteSong(position);
|
||||
CPlaylists.SavePlaylist(playlistId);
|
||||
pl.DeleteSong(position);
|
||||
pl.Save();
|
||||
}
|
||||
|
||||
private static void _MoveSongInPlaylist(int newPosition, int playlistId, int songId)
|
||||
{
|
||||
if (CPlaylists.Playlists.Length <= playlistId || playlistId < 0)
|
||||
CPlaylistFile pl = CPlaylists.Get(playlistId);
|
||||
if (pl == null)
|
||||
throw new ArgumentException("invalid playlistId");
|
||||
if (!_PlaylistContainsSong(songId, playlistId))
|
||||
throw new ArgumentException("invalid songId");
|
||||
|
||||
if (CPlaylists.Playlists[playlistId].Songs.Count < newPosition)
|
||||
if (pl.Songs.Count < newPosition)
|
||||
throw new ArgumentException("invalid newPosition");
|
||||
|
||||
int oldPosition = CPlaylists.Playlists[playlistId].Songs.FindIndex(s => s.SongID == songId);
|
||||
CPlaylists.MovePlaylistSong(playlistId, oldPosition, newPosition);
|
||||
CPlaylists.SavePlaylist(playlistId);
|
||||
int oldPosition = pl.Songs.FindIndex(s => s.SongID == songId);
|
||||
pl.MoveSong(oldPosition, newPosition);
|
||||
pl.Save();
|
||||
}
|
||||
|
||||
private static bool _PlaylistContainsSong(int songId, int playlistId)
|
||||
{
|
||||
if (CPlaylists.Playlists.Length <= playlistId || playlistId < 0)
|
||||
CPlaylistFile pl = CPlaylists.Get(playlistId);
|
||||
if (pl == null)
|
||||
throw new ArgumentException("invalid playlistId");
|
||||
return CPlaylists.Playlists[playlistId].Songs.Any(s => s.SongID == songId);
|
||||
return pl.Songs.Any(s => s.SongID == songId);
|
||||
}
|
||||
|
||||
private static SPlaylistSongInfo[] _GetPlaylistSongs(int playlistId)
|
||||
{
|
||||
if (CPlaylists.Playlists.Length <= playlistId || playlistId < 0)
|
||||
CPlaylistFile pl = CPlaylists.Get(playlistId);
|
||||
if (pl == null)
|
||||
throw new ArgumentException("invalid playlistId");
|
||||
|
||||
return _GetPlaylistSongInfos(CPlaylists.Playlists[playlistId]);
|
||||
return _GetPlaylistSongInfos(pl);
|
||||
}
|
||||
|
||||
private static SPlaylistSongInfo _GetPlaylistSongInfo(CPlaylistSong playlistSong, int playlistId, int playlistPos)
|
||||
@@ -549,7 +553,7 @@ namespace Vocaluxe.Base.Server
|
||||
return new SPlaylistInfo
|
||||
{
|
||||
PlaylistId = playlist.Id,
|
||||
PlaylistName = playlist.PlaylistName,
|
||||
PlaylistName = playlist.Name,
|
||||
SongCount = playlist.Songs.Count,
|
||||
LastChanged = DateTime.Now.ToLongDateString()
|
||||
};
|
||||
@@ -557,16 +561,15 @@ namespace Vocaluxe.Base.Server
|
||||
|
||||
private static void _RemovePlaylist(int playlistId)
|
||||
{
|
||||
if (CPlaylists.Playlists.Length <= playlistId || playlistId < 0)
|
||||
if (CPlaylists.Get(playlistId) == null)
|
||||
throw new ArgumentException("invalid playlistId");
|
||||
CPlaylists.DeletePlaylist(playlistId);
|
||||
CPlaylists.Delete(playlistId);
|
||||
}
|
||||
|
||||
private static int _AddPlaylist(string playlistName)
|
||||
{
|
||||
int newPlaylistId = CPlaylists.NewPlaylist();
|
||||
CPlaylists.Playlists[newPlaylistId].PlaylistName = playlistName;
|
||||
CPlaylists.SavePlaylist(newPlaylistId);
|
||||
int newPlaylistId = CPlaylists.NewPlaylist(playlistName);
|
||||
CPlaylists.Save(newPlaylistId);
|
||||
|
||||
return newPlaylistId;
|
||||
}
|
||||
@@ -682,19 +685,10 @@ namespace Vocaluxe.Base.Server
|
||||
if (!Directory.Exists(folder))
|
||||
Directory.CreateDirectory(folder);
|
||||
|
||||
string filename = Path.Combine(folder, name);
|
||||
if (File.Exists(filename + "." + extension))
|
||||
{
|
||||
int i = 0;
|
||||
while (File.Exists(filename + "_" + i + "." + extension))
|
||||
i++;
|
||||
filename = filename + "_" + i + "." + extension;
|
||||
}
|
||||
else
|
||||
filename = filename + "." + extension;
|
||||
string file = CHelper.GetUniqueFileName(folder, name + "." + extension);
|
||||
|
||||
avatarImage.Save(filename);
|
||||
return filename;
|
||||
avatarImage.Save(file);
|
||||
return file;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -29,7 +29,7 @@ namespace Vocaluxe
|
||||
|
||||
public CSplashScreen()
|
||||
{
|
||||
string path = Path.Combine(Environment.CurrentDirectory, Path.Combine(CSettings.FolderGraphics, CSettings.Logo));
|
||||
string path = Path.Combine(CSettings.ProgramFolder, CSettings.FolderNameGraphics, CSettings.FileNameLogo);
|
||||
if (File.Exists(path))
|
||||
{
|
||||
try
|
||||
@@ -45,7 +45,7 @@ namespace Vocaluxe
|
||||
else
|
||||
CLog.LogError("Can't find " + path);
|
||||
|
||||
path = Path.Combine(Environment.CurrentDirectory, CSettings.Icon);
|
||||
path = Path.Combine(CSettings.ProgramFolder, CSettings.FileNameIcon);
|
||||
if (File.Exists(path))
|
||||
{
|
||||
try
|
||||
|
||||
@@ -47,7 +47,7 @@ namespace Vocaluxe.Lib.Database
|
||||
|
||||
public override bool Init()
|
||||
{
|
||||
string oldDBFilePath = Path.Combine(Environment.CurrentDirectory, CSettings.FileOldHighscoreDB);
|
||||
string oldDBFilePath = Path.Combine(CSettings.DataFolder, CSettings.FileNameOldHighscoreDB);
|
||||
if (File.Exists(oldDBFilePath))
|
||||
{
|
||||
if (File.Exists(_FilePath))
|
||||
|
||||
@@ -119,7 +119,7 @@ namespace Vocaluxe.Lib.Database
|
||||
{
|
||||
foreach (string file in _FilesV1)
|
||||
{
|
||||
string filePath = Path.Combine(Environment.CurrentDirectory, file);
|
||||
string filePath = Path.Combine(CSettings.ProgramFolder, file);
|
||||
if (!_AddImageToCreditsDB(filePath, transaction))
|
||||
{
|
||||
transaction.Rollback();
|
||||
|
||||
@@ -84,7 +84,7 @@ namespace Vocaluxe.Lib.Draw
|
||||
/// </summary>
|
||||
public CDirect3D()
|
||||
{
|
||||
Icon = new Icon(Path.Combine(Environment.CurrentDirectory, CSettings.Icon));
|
||||
Icon = new Icon(Path.Combine(CSettings.ProgramFolder, CSettings.FileNameIcon));
|
||||
|
||||
//Fill Queue with 100000 IDs
|
||||
for (int i = 0; i < _MaxID; i++)
|
||||
@@ -320,7 +320,6 @@ namespace Vocaluxe.Lib.Draw
|
||||
}
|
||||
else
|
||||
_DoResize();
|
||||
;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -731,18 +730,13 @@ namespace Vocaluxe.Lib.Draw
|
||||
/// </summary>
|
||||
public void MakeScreenShot()
|
||||
{
|
||||
const string file = "Screenshot_";
|
||||
string path = Path.Combine(CSettings.DataPath, CSettings.FolderScreenshots);
|
||||
|
||||
int i = 0;
|
||||
while (File.Exists(Path.Combine(path, file + i.ToString("00000") + ".bmp")))
|
||||
i++;
|
||||
string file = CHelper.GetUniqueFileName(Path.Combine(CSettings.DataFolder, CSettings.FolderNameScreenshots), "Screenshot.bmp");
|
||||
|
||||
//create a surface of the frame
|
||||
using (Surface surface = _Device.GetBackBuffer(0, 0))
|
||||
{
|
||||
var screen = new Bitmap(Surface.ToStream(surface, ImageFileFormat.Bmp));
|
||||
screen.Save(Path.Combine(path, file + i.ToString("00000") + ".bmp"), ImageFormat.Bmp);
|
||||
screen.Save(file, ImageFormat.Bmp);
|
||||
screen.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ namespace Vocaluxe.Lib.Draw
|
||||
|
||||
public CDrawWinForm()
|
||||
{
|
||||
Icon = new Icon(Path.Combine(Environment.CurrentDirectory, CSettings.Icon));
|
||||
Icon = new Icon(Path.Combine(CSettings.ProgramFolder, CSettings.FileNameIcon));
|
||||
|
||||
_Keys = new CKeys();
|
||||
_Mouse = new CMouse();
|
||||
@@ -304,14 +304,9 @@ namespace Vocaluxe.Lib.Draw
|
||||
|
||||
public void MakeScreenShot()
|
||||
{
|
||||
const string file = "Screenshot_";
|
||||
string path = Path.Combine(CSettings.DataPath, CSettings.FolderScreenshots);
|
||||
string file = CHelper.GetUniqueFileName(Path.Combine(CSettings.DataFolder, CSettings.FolderNameScreenshots), "Screenshot.bmp");
|
||||
|
||||
int i = 0;
|
||||
while (File.Exists(Path.Combine(path, file + i.ToString("00000") + ".png")))
|
||||
i++;
|
||||
|
||||
_Backbuffer.Save(Path.Combine(path, file + i.ToString("00000") + ".png"), ImageFormat.Png);
|
||||
_Backbuffer.Save(file, ImageFormat.Png);
|
||||
}
|
||||
|
||||
public void DrawLine(int a, int r, int g, int b, int w, int x1, int y1, int x2, int y2)
|
||||
|
||||
@@ -111,7 +111,7 @@ namespace Vocaluxe.Lib.Draw
|
||||
|
||||
public COpenGL()
|
||||
{
|
||||
Icon = new Icon(Path.Combine(Environment.CurrentDirectory, CSettings.Icon));
|
||||
Icon = new Icon(Path.Combine(CSettings.ProgramFolder, CSettings.FileNameIcon));
|
||||
|
||||
for (int i = 1; i < _MaxID; i++)
|
||||
_IDs.Enqueue(i);
|
||||
@@ -534,12 +534,7 @@ namespace Vocaluxe.Lib.Draw
|
||||
|
||||
public void MakeScreenShot()
|
||||
{
|
||||
const string file = "Screenshot_";
|
||||
string path = Path.Combine(CSettings.DataPath, CSettings.FolderScreenshots);
|
||||
|
||||
int i = 0;
|
||||
while (File.Exists(Path.Combine(path, file + i.ToString("00000") + ".bmp")))
|
||||
i++;
|
||||
string file = CHelper.GetUniqueFileName(Path.Combine(CSettings.DataFolder, CSettings.FolderNameScreenshots), "Screenshot.bmp");
|
||||
|
||||
int width = GetScreenWidth();
|
||||
int height = GetScreenHeight();
|
||||
@@ -552,7 +547,7 @@ namespace Vocaluxe.Lib.Draw
|
||||
screen.UnlockBits(bmpData);
|
||||
|
||||
screen.RotateFlip(RotateFlipType.RotateNoneFlipY);
|
||||
screen.Save(Path.Combine(path, file + i.ToString("00000") + ".bmp"), ImageFormat.Bmp);
|
||||
screen.Save(file, ImageFormat.Bmp);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Xml;
|
||||
using Vocaluxe.Base;
|
||||
using VocaluxeLib;
|
||||
@@ -28,31 +29,26 @@ namespace Vocaluxe.Lib.Playlist
|
||||
{
|
||||
public class CPlaylistFile
|
||||
{
|
||||
public string PlaylistName;
|
||||
public string PlaylistFile;
|
||||
public int Id = -1;
|
||||
public string Name = "";
|
||||
public string File;
|
||||
public readonly int Id = -1;
|
||||
public List<CPlaylistSong> Songs = new List<CPlaylistSong>();
|
||||
|
||||
public CPlaylistFile()
|
||||
{
|
||||
PlaylistName = string.Empty;
|
||||
PlaylistFile = string.Empty;
|
||||
}
|
||||
|
||||
public CPlaylistFile(string file, int id)
|
||||
public CPlaylistFile(int id, string file = "")
|
||||
{
|
||||
Id = id;
|
||||
PlaylistFile = file;
|
||||
_LoadPlaylist();
|
||||
File = file;
|
||||
if (File != "")
|
||||
_Load();
|
||||
}
|
||||
|
||||
public void SavePlaylist()
|
||||
public void Save()
|
||||
{
|
||||
if (PlaylistFile == "")
|
||||
if (File == "")
|
||||
{
|
||||
string filename = string.Empty;
|
||||
// ReSharper disable LoopCanBeConvertedToQuery
|
||||
foreach (char chr in PlaylistName)
|
||||
foreach (char chr in Name)
|
||||
// ReSharper restore LoopCanBeConvertedToQuery
|
||||
{
|
||||
if (char.IsLetter(chr))
|
||||
@@ -62,25 +58,17 @@ namespace Vocaluxe.Lib.Playlist
|
||||
if (filename == "")
|
||||
filename = "1";
|
||||
|
||||
int i = 0;
|
||||
while (File.Exists(Path.Combine(CSettings.DataPath, CConfig.FolderPlaylists, filename + ".xml")))
|
||||
{
|
||||
i++;
|
||||
if (!File.Exists(Path.Combine(CSettings.DataPath, CConfig.FolderPlaylists, filename + i + ".xml")))
|
||||
filename += i;
|
||||
}
|
||||
|
||||
PlaylistFile = Path.Combine(CSettings.DataPath, CConfig.FolderPlaylists, filename + ".xml");
|
||||
File = CHelper.GetUniqueFileName(Path.Combine(CSettings.DataFolder, CConfig.FolderPlaylists), filename + ".xml");
|
||||
}
|
||||
|
||||
XmlWriter writer;
|
||||
try
|
||||
{
|
||||
writer = XmlWriter.Create(PlaylistFile, CConfig.XMLSettings);
|
||||
writer = XmlWriter.Create(File, CConfig.XMLSettings);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
CLog.LogError("Error creating/opening Playlist File " + PlaylistFile + ": " + e.Message);
|
||||
CLog.LogError("Error creating/opening Playlist File " + File + ": " + e.Message);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -90,7 +78,7 @@ namespace Vocaluxe.Lib.Playlist
|
||||
writer.WriteStartElement("root");
|
||||
|
||||
writer.WriteStartElement("Info");
|
||||
writer.WriteElementString("PlaylistName", PlaylistName);
|
||||
writer.WriteElementString("PlaylistName", Name);
|
||||
writer.WriteEndElement();
|
||||
|
||||
writer.WriteStartElement("Songs");
|
||||
@@ -121,51 +109,42 @@ namespace Vocaluxe.Lib.Playlist
|
||||
}
|
||||
}
|
||||
|
||||
private void _LoadPlaylist()
|
||||
private void _Load()
|
||||
{
|
||||
CXMLReader xmlReader = CXMLReader.OpenFile(PlaylistFile);
|
||||
CXMLReader xmlReader = CXMLReader.OpenFile(File);
|
||||
if (xmlReader == null)
|
||||
return;
|
||||
|
||||
string value = String.Empty;
|
||||
if (xmlReader.GetValue("//root/Info/PlaylistName", out value, value))
|
||||
string value;
|
||||
if (xmlReader.GetValue("//root/Info/PlaylistName", out value, ""))
|
||||
{
|
||||
PlaylistName = value;
|
||||
Name = value;
|
||||
|
||||
Songs = new List<CPlaylistSong>();
|
||||
|
||||
List<string> songs = xmlReader.GetValues("Songs");
|
||||
var gm = EGameMode.TR_GAMEMODE_NORMAL;
|
||||
|
||||
foreach (string song in songs)
|
||||
foreach (string songEntry in songs)
|
||||
{
|
||||
string artist;
|
||||
string title;
|
||||
xmlReader.GetValue("//root/Songs/" + song + "/Artist", out artist, String.Empty);
|
||||
xmlReader.GetValue("//root/Songs/" + song + "/Title", out title, String.Empty);
|
||||
xmlReader.TryGetEnumValue("//root/Songs/" + song + "/GameMode", ref gm);
|
||||
xmlReader.GetValue("//root/Songs/" + songEntry + "/Artist", out artist, String.Empty);
|
||||
xmlReader.GetValue("//root/Songs/" + songEntry + "/Title", out title, String.Empty);
|
||||
EGameMode gm = EGameMode.TR_GAMEMODE_NORMAL;
|
||||
xmlReader.TryGetEnumValue("//root/Songs/" + songEntry + "/GameMode", ref gm);
|
||||
|
||||
var playlistSong = new CPlaylistSong {SongID = -1};
|
||||
|
||||
foreach (CSong curSong in CSongs.AllSongs)
|
||||
CSong plSong = CSongs.AllSongs.FirstOrDefault(song => song.Artist == artist && song.Title == title);
|
||||
if (plSong != null)
|
||||
{
|
||||
if (curSong.Artist != artist || curSong.Title != title)
|
||||
continue;
|
||||
playlistSong.SongID = curSong.ID;
|
||||
break;
|
||||
}
|
||||
|
||||
if (playlistSong.SongID != -1)
|
||||
{
|
||||
playlistSong.GameMode = gm;
|
||||
var playlistSong = new CPlaylistSong(plSong.ID, gm);
|
||||
Songs.Add(playlistSong);
|
||||
}
|
||||
else
|
||||
CLog.LogError("Can't find song '" + title + "' from '" + artist + "' in playlist file: " + PlaylistFile);
|
||||
CLog.LogError("Can't find song '" + title + "' from '" + artist + "' in playlist file: " + File);
|
||||
}
|
||||
}
|
||||
else
|
||||
CLog.LogError("Can't find PlaylistName in Playlist File: " + PlaylistFile);
|
||||
CLog.LogError("Can't find PlaylistName in Playlist File: " + File);
|
||||
}
|
||||
|
||||
public void AddSong(int songID)
|
||||
@@ -181,7 +160,7 @@ namespace Vocaluxe.Lib.Playlist
|
||||
|
||||
public void AddSong(int songID, EGameMode gm)
|
||||
{
|
||||
var song = new CPlaylistSong {SongID = songID, GameMode = gm};
|
||||
var song = new CPlaylistSong(songID, gm);
|
||||
|
||||
Songs.Add(song);
|
||||
}
|
||||
@@ -191,31 +170,31 @@ namespace Vocaluxe.Lib.Playlist
|
||||
Songs.RemoveAt(songNr);
|
||||
}
|
||||
|
||||
public void SongUp(int songNr)
|
||||
public void MoveSongUp(int songNr)
|
||||
{
|
||||
if (songNr < Songs.Count - 1 && songNr > 0)
|
||||
if (songNr < Songs.Count && songNr > 0)
|
||||
Songs.Reverse(songNr - 1, 2);
|
||||
}
|
||||
|
||||
public void SongDown(int songNr)
|
||||
public void MoveSongDown(int songNr)
|
||||
{
|
||||
if (songNr < Songs.Count - 1 && songNr >= 0)
|
||||
Songs.Reverse(songNr, 2);
|
||||
}
|
||||
|
||||
public void SongMove(int sourceNr, int destNr)
|
||||
public void MoveSong(int sourceNr, int destNr)
|
||||
{
|
||||
if (sourceNr < 0 || destNr < 0 || sourceNr == destNr || sourceNr > Songs.Count - 1 || destNr > Songs.Count - 1)
|
||||
if (sourceNr < 0 || destNr < 0 || sourceNr == destNr || sourceNr >= Songs.Count || destNr >= Songs.Count)
|
||||
return;
|
||||
|
||||
var ps = new CPlaylistSong(Songs[sourceNr]);
|
||||
CPlaylistSong song = Songs[sourceNr];
|
||||
Songs.RemoveAt(sourceNr);
|
||||
Songs.Insert(destNr, ps);
|
||||
Songs.Insert(destNr, song);
|
||||
}
|
||||
|
||||
public void SongInsert(int destNr, int songID, EGameMode gm)
|
||||
public void InsertSong(int destNr, int songID, EGameMode gm)
|
||||
{
|
||||
if (destNr < 0 || destNr > Songs.Count - 1)
|
||||
if (destNr < 0 || destNr >= Songs.Count)
|
||||
return;
|
||||
|
||||
CPlaylistSong ps = new CPlaylistSong(songID, gm);
|
||||
|
||||
@@ -142,10 +142,7 @@ namespace Vocaluxe.Lib.Sound.Playback
|
||||
{
|
||||
int index = _GetStreamIndex(streamID);
|
||||
if (index >= 0)
|
||||
{
|
||||
_Streams[index].Close();
|
||||
_Streams.RemoveAt(index);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+12
-13
@@ -301,6 +301,7 @@ namespace Vocaluxe
|
||||
if (args.Name.IndexOf(".resources", StringComparison.Ordinal) >= 0)
|
||||
return null;
|
||||
|
||||
Assembly assembly = null;
|
||||
string[] arr = args.Name.Split(new char[] {','});
|
||||
if (arr.Length > 0)
|
||||
{
|
||||
@@ -311,27 +312,25 @@ namespace Vocaluxe
|
||||
#if ARCH_X64
|
||||
string path = "x64";
|
||||
#endif
|
||||
path = Path.Combine(path, arr[0] + ".dll");
|
||||
path = Path.Combine(CSettings.ProgramFolder, path, arr[0] + ".dll");
|
||||
try
|
||||
{
|
||||
Assembly assembly;
|
||||
assembly = Assembly.LoadFrom(path);
|
||||
}
|
||||
catch (FileLoadException e1)
|
||||
{
|
||||
//possibly loading from network, this would work always but better use the normal LoadFrom for more specific errors
|
||||
try
|
||||
{
|
||||
assembly = Assembly.LoadFrom(path);
|
||||
}
|
||||
catch (FileLoadException)
|
||||
{
|
||||
//possibly loading from network, this would work always but better use the normal LoadFrom for more specific errors
|
||||
assembly = Assembly.Load(File.ReadAllBytes(path));
|
||||
}
|
||||
return assembly;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
CLog.LogError("Cannot load assembly " + args.Name + " from " + path + ": " + e);
|
||||
catch (Exception e)
|
||||
{
|
||||
CLog.LogError("Cannot load assembly " + args.Name + " from " + path + ": " + e + "\r\nOuter Error: " + e1);
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
return assembly;
|
||||
}
|
||||
|
||||
private static readonly Mutex _Mutex = new Mutex(false, Application.ProductName + "-SingleInstanceMutex");
|
||||
|
||||
@@ -345,13 +345,8 @@ namespace Vocaluxe.Screens
|
||||
|
||||
private void _OnSaveSnapshot()
|
||||
{
|
||||
string filename = Path.Combine(CSettings.DataPath, CConfig.ProfileFolders[0], "snapshot");
|
||||
int i = 0;
|
||||
while (File.Exists(filename + i + ".png"))
|
||||
i++;
|
||||
|
||||
filename = filename + i + ".png";
|
||||
_Snapshot.Save(filename, ImageFormat.Png);
|
||||
string file = CHelper.GetUniqueFileName(Path.Combine(CSettings.DataFolder, CConfig.ProfileFolders[0]), "snapshot.png");
|
||||
_Snapshot.Save(file, ImageFormat.Png);
|
||||
|
||||
_Snapshot = null;
|
||||
CDraw.RemoveTexture(ref _WebcamTexture);
|
||||
@@ -361,7 +356,7 @@ namespace Vocaluxe.Screens
|
||||
_Buttons[_ButtonTakeSnapshot].Visible = false;
|
||||
_Buttons[_ButtonWebcam].Visible = CWebcam.IsDeviceAvailable();
|
||||
|
||||
int id = CProfiles.NewAvatar(filename);
|
||||
int id = CProfiles.NewAvatar(file);
|
||||
CProfiles.SetAvatar(_SelectSlides[_SelectSlideProfiles].ValueIndex, id);
|
||||
_LoadAvatars(false);
|
||||
}
|
||||
|
||||
@@ -433,7 +433,6 @@ namespace Vocaluxe.Screens
|
||||
_UpdateAvatars();
|
||||
_UpdateNames();
|
||||
|
||||
CBackgroundMusic.Disabled = true;
|
||||
_CloseSong();
|
||||
CSound.SetGlobalVolume(CConfig.GameMusicVolume);
|
||||
}
|
||||
@@ -441,6 +440,7 @@ namespace Vocaluxe.Screens
|
||||
public override void OnShowFinish()
|
||||
{
|
||||
base.OnShowFinish();
|
||||
CBackgroundMusic.Disabled = true;
|
||||
|
||||
CGame.Start();
|
||||
_LoadNextSong();
|
||||
|
||||
+149
-136
@@ -23,6 +23,7 @@ using System.Windows.Forms;
|
||||
using Vocaluxe.Base;
|
||||
using VocaluxeLib;
|
||||
using VocaluxeLib.Menu;
|
||||
using VocaluxeLib.Menu.SongMenu;
|
||||
using VocaluxeLib.PartyModes;
|
||||
using VocaluxeLib.Songs;
|
||||
|
||||
@@ -70,15 +71,15 @@ namespace Vocaluxe.Screens
|
||||
|
||||
private const string _StaticSearchBar = "StaticSearchBar";
|
||||
private const string _StaticOptionsBG = "StaticOptionsBG";
|
||||
private const string _SongMenu = "SongMenu";
|
||||
private const string _Playlist = "Playlist";
|
||||
private const string _SongMenuName = "SongMenu";
|
||||
private const string _PlaylistName = "Playlist";
|
||||
|
||||
private string _SearchText = String.Empty;
|
||||
private bool _SearchActive;
|
||||
|
||||
private readonly List<string> _ButtonsJoker = new List<string>();
|
||||
private readonly List<string> _TextsPlayer = new List<string>();
|
||||
private bool _SongOptionsActive;
|
||||
private ESongOptionsView _CurSongOptionsView;
|
||||
private bool _PlaylistActive;
|
||||
private readonly List<EGameMode> _AvailableGameModes;
|
||||
private SScreenSongOptions _Sso;
|
||||
@@ -91,6 +92,9 @@ namespace Vocaluxe.Screens
|
||||
private int _SelectedSongID;
|
||||
private int _SelectedCategoryIndex;
|
||||
|
||||
private CSongMenu _SongMenu;
|
||||
private CPlaylist _Playlist;
|
||||
|
||||
public CScreenSong()
|
||||
{
|
||||
_AvailableGameModes = new List<EGameMode>();
|
||||
@@ -133,19 +137,20 @@ namespace Vocaluxe.Screens
|
||||
_ThemeTexts = tlist.ToArray();
|
||||
_ThemeButtons = blist.ToArray();
|
||||
_ThemeSelectSlides = new string[] {_SelectSlideOptionsMode, _SelectSlideOptionsPlaylistAdd, _SelectSlideOptionsPlaylistOpen, _SelectSlideOptionsNumMedleySongs};
|
||||
_ThemeSongMenus = new string[] {_SongMenu};
|
||||
_ThemePlaylists = new string[] {_Playlist};
|
||||
_ThemeSongMenus = new string[] {_SongMenuName};
|
||||
_ThemePlaylists = new string[] {_PlaylistName};
|
||||
}
|
||||
|
||||
public override void LoadTheme(string xmlPath)
|
||||
{
|
||||
base.LoadTheme(xmlPath);
|
||||
_SongMenu = _SongMenus[_SongMenuName];
|
||||
_Playlist = _Playlists[_PlaylistName];
|
||||
_ToggleSongOptions(ESongOptionsView.None);
|
||||
_Playlists[_Playlist].Visible = false;
|
||||
|
||||
_DragAndDropCover = GetNewStatic();
|
||||
|
||||
_Playlists[_Playlist].Init();
|
||||
_Playlist.Init();
|
||||
_Playlist.Visible = false;
|
||||
|
||||
_AvailableGameModes.Clear();
|
||||
}
|
||||
@@ -158,11 +163,11 @@ namespace Vocaluxe.Screens
|
||||
|
||||
if (_PlaylistActive)
|
||||
{
|
||||
_Playlists[_Playlist].HandleInput(keyEvent);
|
||||
_Playlist.HandleInput(keyEvent);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!_SongOptionsActive)
|
||||
if (_CurSongOptionsView == ESongOptionsView.None)
|
||||
{
|
||||
if (keyEvent.KeyPressed && !Char.IsControl(keyEvent.Unicode) && keyEvent.Mod != EModifier.Ctrl)
|
||||
{
|
||||
@@ -176,8 +181,8 @@ namespace Vocaluxe.Screens
|
||||
}
|
||||
else
|
||||
{
|
||||
_SongMenus[_SongMenu].HandleInput(ref keyEvent, _Sso);
|
||||
_UpdatePartyModeOptions();
|
||||
if (_SongMenu.HandleInput(ref keyEvent, _Sso))
|
||||
keyEvent.Handled = true;
|
||||
|
||||
if (keyEvent.Handled)
|
||||
return true;
|
||||
@@ -210,32 +215,31 @@ namespace Vocaluxe.Screens
|
||||
}
|
||||
}
|
||||
if (_Buttons[_ButtonStart].Selected)
|
||||
_HandlePartySongSelection(_SongMenus[_SongMenu].GetSelectedSong());
|
||||
_HandlePartySongSelection(_SongMenu.GetPreviewSongNr());
|
||||
}
|
||||
if (CSongs.NumSongsVisible > 0 && !_Sso.Selection.PartyMode)
|
||||
{
|
||||
if (_SongMenus[_SongMenu].GetSelectedSong() != -1 && !_SongOptionsActive)
|
||||
{
|
||||
if (!_Sso.Selection.PartyMode)
|
||||
_ToggleSongOptions(ESongOptionsView.Song);
|
||||
}
|
||||
if (_SongMenu.GetPreviewSongNr() != -1)
|
||||
_ToggleSongOptions(ESongOptionsView.Song);
|
||||
}
|
||||
break;
|
||||
|
||||
case Keys.Tab:
|
||||
if (_Playlists[_Playlist].Visible)
|
||||
if (_Playlist.Visible)
|
||||
{
|
||||
_PlaylistActive = !_PlaylistActive;
|
||||
_Playlists[_Playlist].Selected = _PlaylistActive;
|
||||
_SongMenus[_SongMenu].SetActive(!_PlaylistActive);
|
||||
_Playlist.Selected = _PlaylistActive;
|
||||
_SongMenu.Active = !_PlaylistActive;
|
||||
}
|
||||
break;
|
||||
|
||||
case Keys.Back:
|
||||
if (_SearchActive && _SearchText != "")
|
||||
_ApplyNewSearchFilter(_SearchText.Remove(_SearchText.Length - 1));
|
||||
|
||||
if ((CSongs.Category < 0 || _Sso.Sorting.Tabs == EOffOn.TR_CONFIG_OFF) && !_Sso.Selection.PartyMode && !_SearchActive)
|
||||
if (_SearchActive)
|
||||
{
|
||||
if (_SearchText != "")
|
||||
_ApplyNewSearchFilter(_SearchText.Remove(_SearchText.Length - 1));
|
||||
}
|
||||
else if ((!CSongs.IsInCategory || _Sso.Sorting.Tabs == EOffOn.TR_CONFIG_OFF) && !_Sso.Selection.PartyMode)
|
||||
CGraphics.FadeTo(EScreens.ScreenMain);
|
||||
|
||||
break;
|
||||
@@ -276,7 +280,12 @@ namespace Vocaluxe.Screens
|
||||
|
||||
case Keys.S:
|
||||
if (keyEvent.Mod == EModifier.Ctrl && CSongs.NumSongsVisible > 0 && !_Sso.Selection.PartyMode)
|
||||
_StartMedleySong(_SongMenus[_SongMenu].GetSelectedSong());
|
||||
_StartMedleySong(_SongMenu.GetPreviewSongNr());
|
||||
break;
|
||||
|
||||
case Keys.F:
|
||||
if (keyEvent.Mod == EModifier.Ctrl)
|
||||
_SearchActive = true;
|
||||
break;
|
||||
|
||||
case Keys.D1:
|
||||
@@ -322,7 +331,7 @@ namespace Vocaluxe.Screens
|
||||
else if (_Buttons[_ButtonOptionsSing].Selected)
|
||||
{
|
||||
_ToggleSongOptions(ESongOptionsView.None);
|
||||
_StartSong(_SongMenus[_SongMenu].GetSelectedSong());
|
||||
_StartSong(_SongMenu.GetPreviewSongNr());
|
||||
}
|
||||
else if (_Buttons[_ButtonOptionsPlaylist].Selected)
|
||||
{
|
||||
@@ -332,9 +341,9 @@ namespace Vocaluxe.Screens
|
||||
else if (_Buttons[_ButtonOptionsRandom].Selected)
|
||||
{
|
||||
if (CSongs.IsInCategory)
|
||||
_SongMenus[_SongMenu].SetSelectedSong(CSongs.GetRandomSong());
|
||||
_SongMenu.SetSelectedSong(CSongs.GetRandomSong());
|
||||
else
|
||||
_SongMenus[_SongMenu].SetSelectedCategory(CSongs.GetRandomCategory());
|
||||
_SongMenu.SetSelectedCategory(CSongs.GetRandomCategory());
|
||||
}
|
||||
else if (_Buttons[_ButtonOptionsSingAll].Selected)
|
||||
_StartRandomAllSongs();
|
||||
@@ -397,31 +406,31 @@ namespace Vocaluxe.Screens
|
||||
_OldMousePosX = mouseEvent.X;
|
||||
_OldMousePosY = mouseEvent.Y;
|
||||
|
||||
if (_Playlists[_Playlist].Visible && _Playlists[_Playlist].IsMouseOver(mouseEvent))
|
||||
if (_Playlist.Visible && _Playlist.IsMouseOver(mouseEvent))
|
||||
{
|
||||
_PlaylistActive = true;
|
||||
_Playlists[_Playlist].Selected = _PlaylistActive;
|
||||
_SongMenus[_SongMenu].SetActive(!_PlaylistActive);
|
||||
_Playlist.Selected = _PlaylistActive;
|
||||
_SongMenu.Active = !_PlaylistActive;
|
||||
_ToggleSongOptions(ESongOptionsView.None);
|
||||
}
|
||||
else if (CHelper.IsInBounds(_SongMenus[_SongMenu].Rect, mouseEvent.X, mouseEvent.Y))
|
||||
else if (CHelper.IsInBounds(_SongMenu.Rect, mouseEvent.X, mouseEvent.Y))
|
||||
{
|
||||
_PlaylistActive = false;
|
||||
_Playlists[_Playlist].Selected = _PlaylistActive;
|
||||
_SongMenus[_SongMenu].SetActive(!_PlaylistActive);
|
||||
_Playlist.Selected = _PlaylistActive;
|
||||
_SongMenu.Active = !_PlaylistActive;
|
||||
}
|
||||
|
||||
|
||||
if (_Playlists[_Playlist].Visible && _PlaylistActive)
|
||||
if (_Playlist.Visible && _PlaylistActive)
|
||||
{
|
||||
if (_Playlists[_Playlist].HandleMouse(mouseEvent))
|
||||
if (_Playlist.HandleMouse(mouseEvent))
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
if (mouseEvent.RB)
|
||||
{
|
||||
if (_SongOptionsActive)
|
||||
if (_CurSongOptionsView != ESongOptionsView.None)
|
||||
{
|
||||
_ToggleSongOptions(ESongOptionsView.None);
|
||||
return true;
|
||||
@@ -447,19 +456,23 @@ namespace Vocaluxe.Screens
|
||||
|
||||
if (mouseEvent.LD && !_Sso.Selection.PartyMode)
|
||||
{
|
||||
if (CSongs.NumSongsVisible > 0 && _SongMenus[_SongMenu].GetActualSelection() != -1 && _SongMenus[_SongMenu].IsMouseOverActualSelection(mouseEvent))
|
||||
if (CSongs.NumSongsVisible > 0 && _SongMenu.GetPreviewSongNr() != -1 && _SongMenu.IsMouseOverSelectedSong(mouseEvent))
|
||||
{
|
||||
_ToggleSongOptions(ESongOptionsView.None);
|
||||
_StartVisibleSong(_SongMenus[_SongMenu].GetActualSelection());
|
||||
_StartVisibleSong(_SongMenu.GetPreviewSongNr());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
_SongMenus[_SongMenu].HandleMouse(ref mouseEvent, _Sso);
|
||||
_UpdatePartyModeOptions();
|
||||
if (_SongMenu.HandleMouse(ref mouseEvent, _Sso))
|
||||
mouseEvent.Handled = true;
|
||||
|
||||
if (mouseEvent.Handled)
|
||||
{
|
||||
if (_CurSongOptionsView != ESongOptionsView.None)
|
||||
_ToggleSongOptions(ESongOptionsView.None);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (mouseEvent.LB)
|
||||
{
|
||||
@@ -478,7 +491,7 @@ namespace Vocaluxe.Screens
|
||||
if (_Buttons[_ButtonOptionsSing].Selected)
|
||||
{
|
||||
_ToggleSongOptions(ESongOptionsView.None);
|
||||
_StartSong(_SongMenus[_SongMenu].GetSelectedSong());
|
||||
_StartSong(_SongMenu.GetPreviewSongNr());
|
||||
return true;
|
||||
}
|
||||
if (_Buttons[_ButtonOptionsPlaylist].Selected)
|
||||
@@ -491,7 +504,7 @@ namespace Vocaluxe.Screens
|
||||
{
|
||||
if (CSongs.IsInCategory)
|
||||
{
|
||||
_SongMenus[_SongMenu].SetSelectedSong(CSongs.GetRandomSong());
|
||||
_SongMenu.SetSelectedSong(CSongs.GetRandomSong());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -499,7 +512,7 @@ namespace Vocaluxe.Screens
|
||||
{
|
||||
if (!CSongs.IsInCategory)
|
||||
{
|
||||
_SongMenus[_SongMenu].SetSelectedCategory(CSongs.GetRandomCategory());
|
||||
_SongMenu.SetSelectedCategory(CSongs.GetRandomCategory());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -545,7 +558,7 @@ namespace Vocaluxe.Screens
|
||||
{
|
||||
if (_Buttons[_ButtonStart].Selected)
|
||||
{
|
||||
_HandlePartySongSelection(_SongMenus[_SongMenu].GetSelectedSong());
|
||||
_HandlePartySongSelection(_SongMenu.GetPreviewSongNr());
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -563,25 +576,20 @@ namespace Vocaluxe.Screens
|
||||
}
|
||||
}
|
||||
|
||||
if (CSongs.NumSongsVisible > 0 && _SongMenus[_SongMenu].GetActualSelection() != -1 && !_Sso.Selection.PartyMode)
|
||||
if (_SongMenu.GetPreviewSongNr() != -1 && !_Sso.Selection.PartyMode && _SongMenu.IsMouseOverSelectedSong(mouseEvent))
|
||||
{
|
||||
if (_SongMenus[_SongMenu].GetSelectedSong() != -1 && !_SongOptionsActive)
|
||||
{
|
||||
_ToggleSongOptions(ESongOptionsView.Song);
|
||||
return true;
|
||||
}
|
||||
_ToggleSongOptions(ESongOptionsView.None);
|
||||
_ToggleSongOptions(ESongOptionsView.Song);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (mouseEvent.LBH)
|
||||
{
|
||||
if (!_DragAndDropActive && _Playlists[_Playlist].Visible && CSongs.NumSongsVisible > 0 && _SongMenus[_SongMenu].GetActualSelection() != -1)
|
||||
if (!_DragAndDropActive && _Playlist.Visible && CSongs.NumSongsVisible > 0 && _SongMenu.GetSelectedSongNr() != -1)
|
||||
{
|
||||
_DragAndDropCover = _SongMenus[_SongMenu].GetSelectedSongCover();
|
||||
_DragAndDropCover = _SongMenu.GetSelectedSongCover();
|
||||
_DragAndDropCover.Rect.Z = CSettings.ZNear;
|
||||
_Playlists[_Playlist].DragAndDropSongID = CSongs.VisibleSongs[_SongMenus[_SongMenu].GetActualSelection()].ID;
|
||||
_Playlist.DragAndDropSongID = CSongs.VisibleSongs[_SongMenu.GetSelectedSongNr()].ID;
|
||||
_DragAndDropActive = true;
|
||||
return true;
|
||||
}
|
||||
@@ -591,7 +599,7 @@ namespace Vocaluxe.Screens
|
||||
if (!mouseEvent.LBH && _DragAndDropActive)
|
||||
{
|
||||
_DragAndDropActive = false;
|
||||
_Playlists[_Playlist].DragAndDropSongID = -1;
|
||||
_Playlist.DragAndDropSongID = -1;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -608,7 +616,7 @@ namespace Vocaluxe.Screens
|
||||
else if (_Sso.Selection.CategoryChangeAllowed)
|
||||
{
|
||||
_ToggleSongOptions(ESongOptionsView.None);
|
||||
_SongMenus[_SongMenu].EnterCurrentCategory();
|
||||
_SongMenu.EnterSelectedCategory();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -625,7 +633,7 @@ namespace Vocaluxe.Screens
|
||||
_SearchText = _Sso.Sorting.SearchString;
|
||||
|
||||
CGame.Reset();
|
||||
_SongMenus[_SongMenu].OnShow();
|
||||
_SongMenu.OnShow();
|
||||
|
||||
if (_Sso.Selection.PartyMode)
|
||||
_PlaylistActive = false;
|
||||
@@ -633,14 +641,14 @@ namespace Vocaluxe.Screens
|
||||
if (_Sso.Selection.PartyMode)
|
||||
_ToggleSongOptions(ESongOptionsView.None);
|
||||
|
||||
_SongMenus[_SongMenu].SetActive(!_PlaylistActive);
|
||||
_SongMenus[_SongMenu].SetSmallView(_Playlists[_Playlist].Visible);
|
||||
_SongMenu.Active = !_PlaylistActive;
|
||||
_SongMenu.SmallView = _Playlist.Visible;
|
||||
|
||||
if (_Playlists[_Playlist].ActivePlaylistID != -1)
|
||||
_Playlists[_Playlist].LoadPlaylist(_Playlists[_Playlist].ActivePlaylistID);
|
||||
if (_Playlist.ActivePlaylistID != -1)
|
||||
_Playlist.LoadPlaylist(_Playlist.ActivePlaylistID);
|
||||
|
||||
_DragAndDropActive = false;
|
||||
_Playlists[_Playlist].DragAndDropSongID = -1;
|
||||
_Playlist.DragAndDropSongID = -1;
|
||||
|
||||
UpdateGame();
|
||||
if (CSongs.IsInCategory)
|
||||
@@ -649,23 +657,30 @@ namespace Vocaluxe.Screens
|
||||
|
||||
public override bool UpdateGame()
|
||||
{
|
||||
if (_SongMenus[_SongMenu].IsSmallView())
|
||||
CheckPlaylist();
|
||||
if (_PlaylistActive)
|
||||
_CheckPlaylist();
|
||||
|
||||
_Texts[_TextCategory].Text = CSongs.GetCurrentCategoryName();
|
||||
|
||||
if (CSongs.Category > -1 || CConfig.Tabs == EOffOn.TR_CONFIG_OFF)
|
||||
if (CSongs.IsInCategory || CConfig.Tabs == EOffOn.TR_CONFIG_OFF)
|
||||
CBackgroundMusic.Disabled = true;
|
||||
else
|
||||
CBackgroundMusic.Disabled = false;
|
||||
|
||||
int song = _SongMenus[_SongMenu].GetActualSelection();
|
||||
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;
|
||||
else if (!CSongs.IsInCategory && song >= 0 && song < CSongs.Categories.Count)
|
||||
_Texts[_TextSelection].Text = CSongs.Categories[song].Name;
|
||||
string selectionText = "";
|
||||
if (CSongs.IsInCategory)
|
||||
{
|
||||
int song = _SongMenu.GetSelectedSongNr();
|
||||
if (song >= 0 && song < CSongs.VisibleSongs.Count)
|
||||
selectionText = CSongs.VisibleSongs[song].Artist + " - " + CSongs.VisibleSongs[song].Title;
|
||||
}
|
||||
else
|
||||
_Texts[_TextSelection].Text = String.Empty;
|
||||
{
|
||||
int cat = _SongMenu.GetSelectedCategory();
|
||||
if (!CSongs.IsInCategory && cat >= 0 && cat < CSongs.Categories.Count)
|
||||
_Texts[_TextSelection].Text = CSongs.Categories[cat].Name;
|
||||
}
|
||||
_Texts[_TextSelection].Text = selectionText;
|
||||
|
||||
_Texts[_TextSearchBar].Text = _SearchText;
|
||||
if (_SearchActive)
|
||||
@@ -703,12 +718,12 @@ namespace Vocaluxe.Screens
|
||||
base.OnClose();
|
||||
CBackgroundMusic.Disabled = false;
|
||||
CSound.SetGlobalVolume(CConfig.BackgroundMusicVolume);
|
||||
_SongMenus[_SongMenu].OnHide();
|
||||
_SongMenu.OnHide();
|
||||
}
|
||||
|
||||
private void _HandlePartySongSelection(int songNr)
|
||||
{
|
||||
if ((CSongs.Category >= 0) && (songNr >= 0))
|
||||
if (CSongs.IsInCategory && (songNr >= 0))
|
||||
{
|
||||
CSong song = CSongs.VisibleSongs[songNr];
|
||||
if (song != null)
|
||||
@@ -730,12 +745,12 @@ namespace Vocaluxe.Screens
|
||||
_SelectNextRandomSong();
|
||||
|
||||
if (_Sso.Selection.SongIndex != -1)
|
||||
_SongMenus[_SongMenu].SetSelectedSong(_Sso.Selection.SongIndex);
|
||||
_SongMenu.SetSelectedSong(_Sso.Selection.SongIndex);
|
||||
}
|
||||
|
||||
if (_SelectedSongID != _SongMenus[_SongMenu].GetSelectedSong() && CSongs.Category > -1)
|
||||
if (_SelectedSongID != _SongMenu.GetPreviewSongNr() && CSongs.IsInCategory)
|
||||
{
|
||||
_SelectedSongID = _SongMenus[_SongMenu].GetSelectedSong();
|
||||
_SelectedSongID = _SongMenu.GetPreviewSongNr();
|
||||
CParty.OnSongChange(_SelectedSongID, ref _Sso);
|
||||
}
|
||||
|
||||
@@ -752,14 +767,13 @@ namespace Vocaluxe.Screens
|
||||
_ToggleSongOptions(ESongOptionsView.None);
|
||||
}
|
||||
|
||||
_SongMenus[_SongMenu].Update(_Sso);
|
||||
_SongMenu.Update(_Sso);
|
||||
|
||||
if (_Sso.Selection.RandomOnly && _Sso.Selection.NumJokers != null)
|
||||
{
|
||||
_Buttons[_ButtonStart].Visible = true;
|
||||
|
||||
if (!_SongMenus[_SongMenu].IsSmallView())
|
||||
_SongMenus[_SongMenu].SetSmallView(true);
|
||||
_SongMenu.SmallView = true;
|
||||
|
||||
for (int i = 0; i < CSettings.MaxNumPlayer; i++)
|
||||
{
|
||||
@@ -791,8 +805,8 @@ namespace Vocaluxe.Screens
|
||||
}
|
||||
else
|
||||
{
|
||||
if (_Sso.Selection.PartyMode && _SongMenus[_SongMenu].IsSmallView())
|
||||
_SongMenus[_SongMenu].SetSmallView(false);
|
||||
if (_Sso.Selection.PartyMode)
|
||||
_SongMenu.SmallView = false;
|
||||
|
||||
for (int i = 0; i < CSettings.MaxNumPlayer; i++)
|
||||
{
|
||||
@@ -806,7 +820,7 @@ namespace Vocaluxe.Screens
|
||||
|
||||
private void _StartSong(int songNr)
|
||||
{
|
||||
if ((CSongs.Category >= 0) && (songNr >= 0))
|
||||
if (CSongs.IsInCategory && (songNr >= 0))
|
||||
{
|
||||
EGameMode gm;
|
||||
if (_AvailableGameModes.Count >= _SelectSlides[_SelectSlideOptionsMode].Selection)
|
||||
@@ -824,7 +838,7 @@ namespace Vocaluxe.Screens
|
||||
|
||||
private void _StartVisibleSong(int songNr)
|
||||
{
|
||||
if (CSongs.Category >= 0 && songNr >= 0 && CSongs.NumSongsVisible > songNr)
|
||||
if (CSongs.IsInCategory && songNr >= 0 && CSongs.NumSongsVisible > songNr)
|
||||
{
|
||||
EGameMode gm = CSongs.VisibleSongs[songNr].IsDuet ? EGameMode.TR_GAMEMODE_DUET : EGameMode.TR_GAMEMODE_NORMAL;
|
||||
|
||||
@@ -838,7 +852,7 @@ namespace Vocaluxe.Screens
|
||||
|
||||
private void _StartMedleySong(int songNr)
|
||||
{
|
||||
if ((CSongs.Category >= 0) && (songNr >= 0))
|
||||
if (CSongs.IsInCategory && (songNr >= 0))
|
||||
{
|
||||
if (!CSongs.VisibleSongs[songNr].IsGameModeAvailable(EGameMode.TR_GAMEMODE_MEDLEY))
|
||||
return;
|
||||
@@ -964,7 +978,7 @@ namespace Vocaluxe.Screens
|
||||
if (CSongs.IsInCategory)
|
||||
{
|
||||
_ToggleSongOptions(ESongOptionsView.None);
|
||||
_SongMenus[_SongMenu].SetSelectedSong(CSongs.GetRandomSong());
|
||||
_SongMenu.SetSelectedSong(CSongs.GetRandomSong());
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -975,7 +989,7 @@ namespace Vocaluxe.Screens
|
||||
if (!CSongs.IsInCategory)
|
||||
{
|
||||
_ToggleSongOptions(ESongOptionsView.None);
|
||||
_SongMenus[_SongMenu].SetSelectedCategory(CSongs.GetRandomCategory());
|
||||
_SongMenu.SetSelectedCategory(CSongs.GetRandomCategory());
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -999,7 +1013,7 @@ namespace Vocaluxe.Screens
|
||||
private void _JumpTo(char letter)
|
||||
{
|
||||
int start = 0;
|
||||
int curSelected = _SongMenus[_SongMenu].GetActualSelection();
|
||||
int curSelected = CSongs.IsInCategory ? _SongMenu.GetSelectedSongNr() : _SongMenu.GetSelectedCategory();
|
||||
bool firstLevel = CConfig.Tabs == EOffOn.TR_CONFIG_OFF && CSongs.IsInCategory;
|
||||
bool secondSort = CConfig.Tabs == EOffOn.TR_CONFIG_ON &&
|
||||
(CConfig.SongSorting == ESongSorting.TR_CONFIG_ARTIST ||
|
||||
@@ -1042,7 +1056,7 @@ namespace Vocaluxe.Screens
|
||||
break;
|
||||
}
|
||||
if (visibleID > -1)
|
||||
_SongMenus[_SongMenu].SetSelectedSong(visibleID);
|
||||
_SongMenu.SetSelectedSong(visibleID);
|
||||
}
|
||||
else if (secondSort && CSongs.IsInCategory)
|
||||
{
|
||||
@@ -1066,7 +1080,7 @@ namespace Vocaluxe.Screens
|
||||
break;
|
||||
}
|
||||
if (visibleID > -1)
|
||||
_SongMenus[_SongMenu].SetSelectedSong(visibleID);
|
||||
_SongMenu.SetSelectedSong(visibleID);
|
||||
}
|
||||
else if (!CSongs.IsInCategory)
|
||||
{
|
||||
@@ -1076,7 +1090,7 @@ namespace Vocaluxe.Screens
|
||||
start = curSelected + 1;
|
||||
int visibleID = _FindIndex(categories, start, element => element.Name.StartsWith(letter.ToString(), StringComparison.OrdinalIgnoreCase));
|
||||
if (visibleID > -1)
|
||||
_SongMenus[_SongMenu].SetSelectedCategory(visibleID);
|
||||
_SongMenu.SetSelectedCategory(visibleID);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1088,9 +1102,9 @@ namespace Vocaluxe.Screens
|
||||
bool refresh = false;
|
||||
_SearchText = newFilterString;
|
||||
|
||||
int songIndex = _SongMenus[_SongMenu].GetSelectedSong();
|
||||
int songIndex = _SongMenu.GetSelectedSongNr();
|
||||
int songID = -1;
|
||||
if (songIndex != -1 && CSongs.NumSongsVisible > 0 && CSongs.NumSongsVisible > songIndex)
|
||||
if (songIndex != -1)
|
||||
songID = CSongs.VisibleSongs[songIndex].ID;
|
||||
|
||||
if (newFilterString == "" && _Sso.Sorting.Tabs == EOffOn.TR_CONFIG_ON)
|
||||
@@ -1107,13 +1121,13 @@ namespace Vocaluxe.Screens
|
||||
|
||||
CSongs.Sort(_Sso.Sorting.SongSorting, _Sso.Sorting.Tabs, _Sso.Sorting.IgnoreArticles, newFilterString, _Sso.Sorting.DuetOptions);
|
||||
|
||||
if (songID == -1 || CSongs.NumSongsVisible == 0 || CSongs.NumSongsVisible <= songIndex || CSongs.GetVisibleSongByIndex(songIndex).ID != songID)
|
||||
if (songID == -1 || CSongs.NumSongsVisible <= songIndex || CSongs.GetVisibleSongByIndex(songIndex).ID != songID)
|
||||
refresh = true;
|
||||
|
||||
if (refresh)
|
||||
_SongMenus[_SongMenu].OnHide();
|
||||
_SongMenu.OnHide();
|
||||
|
||||
_SongMenus[_SongMenu].OnShow();
|
||||
_SongMenu.OnShow();
|
||||
}
|
||||
|
||||
private void _ToggleSongOptions(ESongOptionsView view)
|
||||
@@ -1137,13 +1151,13 @@ namespace Vocaluxe.Screens
|
||||
_Buttons[_ButtonOpenOptions].Visible = true;
|
||||
|
||||
if (view == ESongOptionsView.None)
|
||||
_SongOptionsActive = false;
|
||||
_CurSongOptionsView = view;
|
||||
else if (CSongs.IsInCategory)
|
||||
_SongOptionsActive = CSongs.VisibleSongs.Count > 0;
|
||||
_CurSongOptionsView = CSongs.VisibleSongs.Count > 0 ? view : ESongOptionsView.None;
|
||||
else
|
||||
_SongOptionsActive = CSongs.Categories.Count > 0;
|
||||
_CurSongOptionsView = CSongs.Categories.Count > 0 ? view : ESongOptionsView.None;
|
||||
|
||||
if (!_SongOptionsActive)
|
||||
if (_CurSongOptionsView == ESongOptionsView.None)
|
||||
return;
|
||||
|
||||
//Has to be done here otherwhise changed playlist names will not appear until OnShow is called!
|
||||
@@ -1163,7 +1177,7 @@ namespace Vocaluxe.Screens
|
||||
|
||||
private void _CheckAndAddGameMode(EGameMode gameMode)
|
||||
{
|
||||
if (CSongs.VisibleSongs[_SongMenus[_SongMenu].GetSelectedSong()].IsGameModeAvailable(gameMode))
|
||||
if (CSongs.VisibleSongs[_SongMenu.GetPreviewSongNr()].IsGameModeAvailable(gameMode))
|
||||
{
|
||||
_SelectSlides[_SelectSlideOptionsMode].AddValue(Enum.GetName(typeof(EGameMode), gameMode));
|
||||
_AvailableGameModes.Add(gameMode);
|
||||
@@ -1243,31 +1257,30 @@ namespace Vocaluxe.Screens
|
||||
}
|
||||
|
||||
#region Playlist Actions
|
||||
public void CheckPlaylist()
|
||||
private void _CheckPlaylist()
|
||||
{
|
||||
if (_Playlists[_Playlist].ActivePlaylistID == -1 && _PlaylistActive)
|
||||
if (_Playlist.ActivePlaylistID == -1 && _PlaylistActive)
|
||||
_ClosePlaylist();
|
||||
}
|
||||
|
||||
private void _OpenPlaylist(int playlistID)
|
||||
{
|
||||
if (CPlaylists.Playlists.Length > playlistID && playlistID >= 0)
|
||||
if (_Playlist.LoadPlaylist(playlistID))
|
||||
{
|
||||
_Playlists[_Playlist].LoadPlaylist(playlistID);
|
||||
_SongMenus[_SongMenu].SetSmallView(true);
|
||||
_Playlists[_Playlist].Visible = true;
|
||||
_SongMenu.SmallView = true;
|
||||
_Playlist.Visible = true;
|
||||
}
|
||||
}
|
||||
|
||||
private void _ClosePlaylist()
|
||||
{
|
||||
if (_Playlists[_Playlist].Visible || _PlaylistActive)
|
||||
if (_Playlist.Visible || _PlaylistActive)
|
||||
{
|
||||
_SongMenus[_SongMenu].SetSmallView(false);
|
||||
_SongMenu.SmallView = false;
|
||||
_PlaylistActive = false;
|
||||
_Playlists[_Playlist].Selected = _PlaylistActive;
|
||||
_SongMenus[_SongMenu].SetActive(!_PlaylistActive);
|
||||
_Playlists[_Playlist].ClosePlaylist();
|
||||
_Playlist.Selected = _PlaylistActive;
|
||||
_SongMenu.Active = !_PlaylistActive;
|
||||
_Playlist.ClosePlaylist();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1275,22 +1288,22 @@ namespace Vocaluxe.Screens
|
||||
{
|
||||
_SelectSlides[_SelectSlideOptionsPlaylistAdd].Clear();
|
||||
_SelectSlides[_SelectSlideOptionsPlaylistAdd].AddValue("TR_SCREENSONG_NEWPLAYLIST");
|
||||
_SelectSlides[_SelectSlideOptionsPlaylistAdd].AddValues(CPlaylists.PlaylistNames);
|
||||
_SelectSlides[_SelectSlideOptionsPlaylistAdd].AddValues(CPlaylists.Names);
|
||||
_SelectSlides[_SelectSlideOptionsPlaylistOpen].Clear();
|
||||
_SelectSlides[_SelectSlideOptionsPlaylistOpen].AddValues(CPlaylists.PlaylistNames);
|
||||
_SelectSlides[_SelectSlideOptionsPlaylistOpen].AddValues(CPlaylists.Names);
|
||||
}
|
||||
|
||||
private void _OpenAndAddPlaylistAction()
|
||||
{
|
||||
//Open an existing playlist and add song
|
||||
if (_Playlists[_Playlist].ActivePlaylistID != (_SelectSlides[_SelectSlideOptionsPlaylistAdd].Selection - 1) &&
|
||||
if (_Playlist.ActivePlaylistID != (_SelectSlides[_SelectSlideOptionsPlaylistAdd].Selection - 1) &&
|
||||
(_SelectSlides[_SelectSlideOptionsPlaylistAdd].Selection - 1) != -1)
|
||||
{
|
||||
//Open an existing playlist and add song
|
||||
//Check selected game-mode
|
||||
EGameMode gm;
|
||||
if (_AvailableGameModes.Count >= _SelectSlides[_SelectSlideOptionsMode].Selection)
|
||||
gm = _AvailableGameModes[_SelectSlides[_SelectSlideOptionsMode].Selection];
|
||||
else if (CSongs.VisibleSongs[_SongMenus[_SongMenu].GetSelectedSong()].IsDuet)
|
||||
else if (CSongs.VisibleSongs[_SongMenu.GetPreviewSongNr()].IsDuet)
|
||||
gm = EGameMode.TR_GAMEMODE_DUET;
|
||||
else
|
||||
gm = EGameMode.TR_GAMEMODE_NORMAL;
|
||||
@@ -1298,63 +1311,63 @@ namespace Vocaluxe.Screens
|
||||
//Check if Playlist really exists
|
||||
if (_SelectSlides[_SelectSlideOptionsPlaylistAdd].Selection - 1 >= 0)
|
||||
{
|
||||
_Playlists[_Playlist].ActivePlaylistID = _SelectSlides[_SelectSlideOptionsPlaylistAdd].Selection - 1;
|
||||
_Playlist.ActivePlaylistID = _SelectSlides[_SelectSlideOptionsPlaylistAdd].Selection - 1;
|
||||
|
||||
//Add song to playlist
|
||||
CPlaylists.Playlists[_Playlists[_Playlist].ActivePlaylistID].AddSong(CSongs.VisibleSongs[_SongMenus[_SongMenu].GetSelectedSong()].ID, gm);
|
||||
CPlaylists.AddSong(_Playlist.ActivePlaylistID, CSongs.VisibleSongs[_SongMenu.GetPreviewSongNr()].ID, gm);
|
||||
|
||||
//Open playlist
|
||||
_OpenPlaylist(_Playlists[_Playlist].ActivePlaylistID);
|
||||
_OpenPlaylist(_Playlist.ActivePlaylistID);
|
||||
|
||||
_Playlists[_Playlist].ScrollToBottom();
|
||||
_Playlist.ScrollToBottom();
|
||||
}
|
||||
}
|
||||
//Create a new playlist and add song
|
||||
else if ((_SelectSlides[_SelectSlideOptionsPlaylistAdd].Selection - 1) == -1)
|
||||
{
|
||||
//Create a new playlist and add song
|
||||
//Check selected game-mode
|
||||
EGameMode gm;
|
||||
if (_AvailableGameModes.Count >= _SelectSlides[_SelectSlideOptionsMode].Selection)
|
||||
gm = _AvailableGameModes[_SelectSlides[_SelectSlideOptionsMode].Selection];
|
||||
else if (CSongs.VisibleSongs[_SongMenus[_SongMenu].GetSelectedSong()].IsDuet)
|
||||
else if (CSongs.VisibleSongs[_SongMenu.GetPreviewSongNr()].IsDuet)
|
||||
gm = EGameMode.TR_GAMEMODE_DUET;
|
||||
else
|
||||
gm = EGameMode.TR_GAMEMODE_NORMAL;
|
||||
|
||||
//Create new playlist
|
||||
_Playlists[_Playlist].ActivePlaylistID = CPlaylists.NewPlaylist();
|
||||
_Playlist.ActivePlaylistID = CPlaylists.NewPlaylist();
|
||||
|
||||
//Add song to playlist
|
||||
CPlaylists.Playlists[_Playlists[_Playlist].ActivePlaylistID].AddSong(CSongs.VisibleSongs[_SongMenus[_SongMenu].GetSelectedSong()].ID, gm);
|
||||
CPlaylists.AddSong(_Playlist.ActivePlaylistID, CSongs.VisibleSongs[_SongMenu.GetPreviewSongNr()].ID, gm);
|
||||
|
||||
//Open playlist
|
||||
_OpenPlaylist(_Playlists[_Playlist].ActivePlaylistID);
|
||||
_OpenPlaylist(_Playlist.ActivePlaylistID);
|
||||
|
||||
//Add new playlist to select-slide
|
||||
_SelectSlides[_SelectSlideOptionsPlaylistAdd].AddValue(CPlaylists.Playlists[_Playlists[_Playlist].ActivePlaylistID].PlaylistName);
|
||||
_SelectSlides[_SelectSlideOptionsPlaylistOpen].AddValue(CPlaylists.Playlists[_Playlists[_Playlist].ActivePlaylistID].PlaylistName);
|
||||
_SelectSlides[_SelectSlideOptionsPlaylistAdd].AddValue(CPlaylists.GetName(_Playlist.ActivePlaylistID));
|
||||
_SelectSlides[_SelectSlideOptionsPlaylistOpen].AddValue(CPlaylists.GetName(_Playlist.ActivePlaylistID));
|
||||
}
|
||||
//Add song to loaded playlist
|
||||
else
|
||||
{
|
||||
//Add song to loaded playlist
|
||||
//Check selected game-mode
|
||||
EGameMode gm;
|
||||
if (_AvailableGameModes.Count >= _SelectSlides[_SelectSlideOptionsMode].Selection)
|
||||
gm = _AvailableGameModes[_SelectSlides[_SelectSlideOptionsMode].Selection];
|
||||
else if (CSongs.VisibleSongs[_SongMenus[_SongMenu].GetSelectedSong()].IsDuet)
|
||||
else if (CSongs.VisibleSongs[_SongMenu.GetPreviewSongNr()].IsDuet)
|
||||
gm = EGameMode.TR_GAMEMODE_DUET;
|
||||
else
|
||||
gm = EGameMode.TR_GAMEMODE_NORMAL;
|
||||
CPlaylists.Playlists[_Playlists[_Playlist].ActivePlaylistID].AddSong(CSongs.VisibleSongs[_SongMenus[_SongMenu].GetSelectedSong()].ID, gm);
|
||||
_Playlists[_Playlist].UpdatePlaylist();
|
||||
_Playlists[_Playlist].ScrollToBottom();
|
||||
CPlaylists.AddSong(_Playlist.ActivePlaylistID, CSongs.VisibleSongs[_SongMenu.GetPreviewSongNr()].ID, gm);
|
||||
_Playlist.UpdatePlaylist();
|
||||
_Playlist.ScrollToBottom();
|
||||
}
|
||||
}
|
||||
|
||||
private void _SetSelectSlidePlaylistToCurrentPlaylist()
|
||||
{
|
||||
if (_Playlists[_Playlist].ActivePlaylistID > -1)
|
||||
_SelectSlides[_SelectSlideOptionsPlaylistAdd].Selection = _Playlists[_Playlist].ActivePlaylistID + 1;
|
||||
if (_Playlist.ActivePlaylistID > -1)
|
||||
_SelectSlides[_SelectSlideOptionsPlaylistAdd].Selection = _Playlist.ActivePlaylistID + 1;
|
||||
else
|
||||
_SelectSlides[_SelectSlideOptionsPlaylistAdd].Selection = 0;
|
||||
}
|
||||
|
||||
@@ -41,6 +41,7 @@ namespace Vocaluxe.SongQueue
|
||||
private List<SSongQueueEntry> _SongQueue;
|
||||
private int _CurrentRound;
|
||||
private CPoints _Points;
|
||||
private CSong _CurrentSong;
|
||||
|
||||
#region Implementation
|
||||
public void Init()
|
||||
@@ -124,6 +125,7 @@ namespace Vocaluxe.SongQueue
|
||||
_SongQueue[_CurrentRound].GameMode);
|
||||
}
|
||||
_CurrentRound++;
|
||||
_CurrentSong = IsFinished() ? null : CGameModes.Get(GetCurrentGameMode()).GetSong(_SongQueue[_CurrentRound].SongID);
|
||||
}
|
||||
|
||||
public bool IsFinished()
|
||||
@@ -155,7 +157,7 @@ namespace Vocaluxe.SongQueue
|
||||
/// <returns>Song of current round or null if there is none/game finished</returns>
|
||||
public CSong GetSong()
|
||||
{
|
||||
return GetSong(_CurrentRound);
|
||||
return _CurrentSong;
|
||||
}
|
||||
|
||||
public int GetNumSongs()
|
||||
@@ -170,6 +172,8 @@ namespace Vocaluxe.SongQueue
|
||||
/// <returns>Current song or null if out of bounds</returns>
|
||||
public CSong GetSong(int round)
|
||||
{
|
||||
if (round == _CurrentRound)
|
||||
return _CurrentSong;
|
||||
if (round < _SongQueue.Count && round >= 0)
|
||||
return CSongs.GetSong(_SongQueue[round].SongID);
|
||||
|
||||
|
||||
Reference in new issue
Block a user