Rename File/Folder name variables to distinguish them from real (full) paths

Make sure full path is used everywhere (if I didn't miss anything)
This commit is contained in:
Flamefire committed 2014-08-08 17:27:36 +02:00
1 parent 7b95942653
commit 03b9ea8e49
27 files changed
+165 -188

No files matched your search

+1 -1
View File
@@ -185,7 +185,7 @@ namespace ServerLib
ProcessStartInfo info = new ProcessStartInfo ProcessStartInfo info = new ProcessStartInfo
{ {
FileName = "VocaluxeServerConfig.exe", FileName = "VocaluxeServerConfig.exe",
WorkingDirectory = Environment.CurrentDirectory, WorkingDirectory = AppDomain.CurrentDomain.BaseDirectory,
Arguments = port + " " + (_Encrypted ? "true" : "false") + (reserve ? " reserve" : ""), Arguments = port + " " + (_Encrypted ? "true" : "false") + (reserve ? " reserve" : ""),
UseShellExecute = true, UseShellExecute = true,
CreateNoWindow = true, CreateNoWindow = true,
+1 -1
View File
@@ -135,7 +135,7 @@ namespace Vocaluxe.Base
if (_Initialized) if (_Initialized)
return; return;
List<string> soundFiles = CHelper.ListSoundFiles(CSettings.FolderBackgroundMusic, true, true); List<string> soundFiles = CHelper.ListSoundFiles(CSettings.FolderNameBackgroundMusic, true, true);
foreach (string path in soundFiles) foreach (string path in soundFiles)
_BGMusicFiles.Add(new CPlaylistElement(path)); _BGMusicFiles.Add(new CPlaylistElement(path));
+13 -17
View File
@@ -46,11 +46,9 @@ namespace Vocaluxe.Base
private static bool _Initialized; private static bool _Initialized;
// Base file and folder names (formerly from CSettings but they can be changed) // Base file and folder names (formerly from CSettings but they can be changed)
private const string _FolderProfiles = "Profiles"; //Use ProfileFolders for access public static string FolderPlaylists = Path.Combine(CSettings.DataFolder, "Playlists");
private const string _FolderSongs = "Songs"; //Use SongFolders for access public static string FileHighscoreDB = Path.Combine(CSettings.DataFolder, "HighscoreDB.sqlite");
public static string FolderPlaylists = "Playlists"; private static string _FileConfig = Path.Combine(CSettings.DataFolder, "Config.xml");
public static string FileHighscoreDB = "HighscoreDB.sqlite";
private static string _FileConfig = "Config.xml";
// Debug // Debug
public static EDebugLevel DebugLevel = EDebugLevel.TR_CONFIG_OFF; public static EDebugLevel DebugLevel = EDebugLevel.TR_CONFIG_OFF;
@@ -108,10 +106,10 @@ namespace Vocaluxe.Base
//Folders //Folders
public static readonly List<string> SongFolders = new List<string> public static readonly List<string> SongFolders = new List<string>
{ {
Path.Combine(Directory.GetCurrentDirectory(), _FolderSongs) Path.Combine(CSettings.ProgramFolder, CSettings.FolderNameSongs)
#if INSTALLER #if INSTALLER
,Path.Combine(CSettings.DataPath, CSettings.FolderSongs); ,Path.Combine(CSettings.DataFolder, CSettings.FolderNameSongs);
#endif #endif
}; };
/// <summary> /// <summary>
@@ -121,9 +119,9 @@ namespace Vocaluxe.Base
public static readonly List<string> ProfileFolders = new List<string> public static readonly List<string> ProfileFolders = new List<string>
{ {
#if INSTALLER #if INSTALLER
Path.Combine(Environment.CurrentDirectory, CSettings.FolderProfiles), Path.Combine(Environment.CurrentDirectory, CSettings.FolderNameProfiles),
#endif #endif
Path.Combine(CSettings.DataPath, _FolderProfiles) Path.Combine(CSettings.DataFolder, CSettings.FolderNameProfiles)
}; };
// Game // Game
@@ -202,7 +200,7 @@ namespace Vocaluxe.Base
return; return;
// Init config file // Init config file
if (!File.Exists(Path.Combine(CSettings.DataPath, _FileConfig))) if (!File.Exists(_FileConfig))
SaveConfig(); SaveConfig();
else else
_LoadConfig(); _LoadConfig();
@@ -212,7 +210,7 @@ namespace Vocaluxe.Base
private static void _LoadConfig() private static void _LoadConfig()
{ {
CXMLReader xmlReader = CXMLReader.OpenFile(Path.Combine(CSettings.DataPath, _FileConfig)); CXMLReader xmlReader = CXMLReader.OpenFile(_FileConfig);
if (xmlReader == null) if (xmlReader == null)
return; return;
@@ -357,7 +355,7 @@ namespace Vocaluxe.Base
XmlWriter writer = null; XmlWriter writer = null;
try try
{ {
writer = XmlWriter.Create(Path.Combine(CSettings.DataPath, _FileConfig), XMLSettings); writer = XmlWriter.Create(_FileConfig, XMLSettings);
writer.WriteStartDocument(); writer.WriteStartDocument();
writer.WriteStartElement("root"); writer.WriteStartElement("root");
@@ -373,7 +371,7 @@ namespace Vocaluxe.Base
writer.WriteElementString("Screens", Screen.AllScreens.Length.ToString()); writer.WriteElementString("Screens", Screen.AllScreens.Length.ToString());
writer.WriteElementString("PrimaryScreenResolution", Screen.PrimaryScreen.Bounds.Size.ToString()); writer.WriteElementString("PrimaryScreenResolution", Screen.PrimaryScreen.Bounds.Size.ToString());
writer.WriteElementString("Directory", Environment.CurrentDirectory); writer.WriteElementString("Directory", CSettings.ProgramFolder);
writer.WriteEndElement(); writer.WriteEndElement();
@@ -806,10 +804,8 @@ namespace Vocaluxe.Base
//Check each parameter //Check each parameter
for (int i = 0; i < _Params.Count; i++) for (int i = 0; i < _Params.Count; i++)
{ {
//Switch parameter as lower case //Switch parameter to lower case
string param = _Params[i]; string param = _Params[i].ToLower();
param = param.ToLower();
string value = _Values[i]; string value = _Values[i];
+4 -4
View File
@@ -143,7 +143,7 @@ namespace Vocaluxe.Base
{ {
_CoverThemes.Clear(); _CoverThemes.Clear();
const string path = CSettings.FolderCover; string path = Path.Combine(CSettings.ProgramFolder, CSettings.FolderNameCover);
List<string> files = CHelper.ListFiles(path, "*.xml"); List<string> files = CHelper.ListFiles(path, "*.xml");
foreach (string file in files) foreach (string file in files)
@@ -179,10 +179,10 @@ namespace Vocaluxe.Base
var ignoreList = new List<string>(); 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); 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) lock (_Covers)
{ {
if (xmlReader != null) if (xmlReader != null)
@@ -195,7 +195,7 @@ namespace Vocaluxe.Base
string filePath; string filePath;
xmlReader.GetValue("//root/Cover/" + coverName + "/Name", out name, String.Empty); xmlReader.GetValue("//root/Cover/" + coverName + "/Name", out name, String.Empty);
xmlReader.GetValue("//root/Cover/" + coverName + "/Path", out filePath, 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)) if (!File.Exists(coverFilePath))
continue; continue;
+3 -3
View File
@@ -32,9 +32,9 @@ namespace Vocaluxe.Base
public static bool Init() public static bool Init()
{ {
_HighscoreDB = new CHighscoreDB(Path.Combine(Environment.CurrentDirectory, CConfig.FileHighscoreDB)); _HighscoreDB = new CHighscoreDB(CConfig.FileHighscoreDB);
_CoverDB = new CCoverDB(Path.Combine(Environment.CurrentDirectory, CSettings.FileCoverDB)); _CoverDB = new CCoverDB(Path.Combine(CSettings.DataFolder, CSettings.FileNameCoverDB));
_ResourceDB = new CResourceDB(Path.Combine(Environment.CurrentDirectory, CSettings.FileCreditsRessourcesDB)); _ResourceDB = new CResourceDB(Path.Combine(CSettings.ProgramFolder, CSettings.FileNameCreditsRessourcesDB));
if (!_HighscoreDB.Init()) if (!_HighscoreDB.Init())
{ {
+2 -2
View File
@@ -74,7 +74,7 @@ namespace Vocaluxe.Base
_Languages = new List<SLanguage>(); _Languages = new List<SLanguage>();
var files = new List<string>(); 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) foreach (string file in files)
_LoadLanguageFile(file); _LoadLanguageFile(file);
@@ -214,7 +214,7 @@ namespace Vocaluxe.Base
private static void _LoadLanguageFile(string fileName) 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); CXMLReader xmlReader = CXMLReader.OpenFile(lang.LanguageFilePath);
if (xmlReader == null) if (xmlReader == null)
+6 -6
View File
@@ -42,7 +42,7 @@ namespace Vocaluxe.Base
{ {
if (_LogFile != null) if (_LogFile != null)
return; 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(_LogName + " " + CSettings.GetFullVersionText() + " " + DateTime.Now);
_LogFile.WriteLine("----------------------------------------"); _LogFile.WriteLine("----------------------------------------");
@@ -117,11 +117,11 @@ namespace Vocaluxe.Base
public static void Init() public static void Init()
{ {
_ErrorLog = new CErrorLogFile(CSettings.FileErrorLog, "Error-Log"); _ErrorLog = new CErrorLogFile(CSettings.FileNameErrorLog, "Error-Log");
_PerformanceLog = new CLogFile(CSettings.FilePerformanceLog, "Performance-Log"); _PerformanceLog = new CLogFile(CSettings.FileNamePerformanceLog, "Performance-Log");
_BenchmarkLog = new CLogFile(CSettings.FileBenchmarkLog, "Benchmark-Log"); _BenchmarkLog = new CLogFile(CSettings.FileNameBenchmarkLog, "Benchmark-Log");
_DebugLog = new CLogFile(CSettings.FileDebugLog, "Debug-Log"); _DebugLog = new CLogFile(CSettings.FileNameDebugLog, "Debug-Log");
_SongInfoLog = new CLogFile(CSettings.FileSongInfoLog, "Song-Information-Log"); _SongInfoLog = new CLogFile(CSettings.FileNameSongInfoLog, "Song-Information-Log");
_BenchmarkTimer = new Stopwatch[_MaxBenchmarks]; _BenchmarkTimer = new Stopwatch[_MaxBenchmarks];
for (int i = 0; i < _BenchmarkTimer.Length; i++) for (int i = 0; i < _BenchmarkTimer.Length; i++)
+1 -1
View File
@@ -231,7 +231,7 @@ namespace Vocaluxe.Base
public string GetDataPath() public string GetDataPath()
{ {
return CSettings.DataPath; return CSettings.DataFolder;
} }
public float GetSlideShowImageTime() public float GetSlideShowImageTime()
+7 -6
View File
@@ -218,7 +218,7 @@ namespace Vocaluxe.Base
private static void _LoadPartyModes() private static void _LoadPartyModes()
{ {
var files = new List<string>(); 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) foreach (string file in files)
{ {
@@ -269,7 +269,8 @@ namespace Vocaluxe.Base
return pm; 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>(); var filesToCompile = new List<string>();
filesToCompile.AddRange(CHelper.ListFiles(pathToCode, "*.cs", false, true)); filesToCompile.AddRange(CHelper.ListFiles(pathToCode, "*.cs", false, true));
@@ -278,7 +279,7 @@ namespace Vocaluxe.Base
if (output == null) if (output == null)
return pm; 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); CLog.LogError("Error loading language files for PartyMode: " + file);
return pm; return pm;
@@ -301,9 +302,9 @@ namespace Vocaluxe.Base
return pm; return pm;
} }
pm.PartyMode.Initialize(); 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; return pm;
int themeIndex = CTheme.GetThemeIndex(pm.PartyModeID); int themeIndex = CTheme.GetThemeIndex(pm.PartyModeID);
@@ -318,7 +319,7 @@ namespace Vocaluxe.Base
foreach (string screenfile in pm.ScreenFiles) 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); CMenuParty screen = _GetPartyScreenInstance(output, screenfile, pm.Folder);
if (screen != null) if (screen != null)
+11 -11
View File
@@ -39,7 +39,7 @@ namespace Vocaluxe.Base
public static List<string> PlaylistNames public static List<string> PlaylistNames
{ {
get { return _Playlists.Select(t => t.PlaylistName).ToList(); } get { return _Playlists.Select(t => t.Name).ToList(); }
} }
public static int NumPlaylists public static int NumPlaylists
@@ -58,7 +58,7 @@ namespace Vocaluxe.Base
private static void _ConvertUSDXPlaylists() private static void _ConvertUSDXPlaylists()
{ {
var files = new List<string>(); 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) foreach (string file in files)
{ {
@@ -73,7 +73,7 @@ namespace Vocaluxe.Base
_Playlists = new List<CPlaylistFile>(); _Playlists = new List<CPlaylistFile>();
var files = new List<string>(); 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) foreach (string file in files)
{ {
@@ -87,7 +87,7 @@ namespace Vocaluxe.Base
if (playlistID >= _Playlists.Count || playlistID < 0) if (playlistID >= _Playlists.Count || playlistID < 0)
return "Error: Can't find Playlist"; return "Error: Can't find Playlist";
return _Playlists[playlistID].PlaylistName; return _Playlists[playlistID].Name;
} }
public static void SetPlaylistName(int playlistID, string name) public static void SetPlaylistName(int playlistID, string name)
@@ -95,22 +95,22 @@ namespace Vocaluxe.Base
if (playlistID >= _Playlists.Count || playlistID < 0) if (playlistID >= _Playlists.Count || playlistID < 0)
return; return;
_Playlists[playlistID].PlaylistName = name; _Playlists[playlistID].Name = name;
} }
public static void DeletePlaylist(int playlistID) public static void DeletePlaylist(int playlistID)
{ {
if (playlistID < 0 || playlistID >= _Playlists.Count) if (playlistID < 0 || playlistID >= _Playlists.Count)
return; return;
if (_Playlists[playlistID].PlaylistFile != "") if (_Playlists[playlistID].File != "")
{ {
try try
{ {
File.Delete(_Playlists[playlistID].PlaylistFile); File.Delete(_Playlists[playlistID].File);
} }
catch (Exception) 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.RemoveAt(playlistID);
@@ -125,7 +125,7 @@ namespace Vocaluxe.Base
public static int NewPlaylist() public static int NewPlaylist()
{ {
CPlaylistFile pl = new CPlaylistFile {PlaylistName = "New Playlist", Id = _Playlists.Count}; CPlaylistFile pl = new CPlaylistFile {Name = "New Playlist", Id = _Playlists.Count};
_Playlists.Add(pl); _Playlists.Add(pl);
return _Playlists.Count - 1; return _Playlists.Count - 1;
} }
@@ -213,7 +213,7 @@ namespace Vocaluxe.Base
private static int _CompareByPlaylistName(CPlaylistFile a, CPlaylistFile b) private static int _CompareByPlaylistName(CPlaylistFile a, CPlaylistFile b)
{ {
return String.CompareOrdinal(a.PlaylistName, b.PlaylistName); return String.CompareOrdinal(a.Name, b.Name);
} }
private static CPlaylistFile _ConvertUSDXPlaylist(string file) private static CPlaylistFile _ConvertUSDXPlaylist(string file)
@@ -240,7 +240,7 @@ namespace Vocaluxe.Base
string identifier = line.Substring(1, pos - 1).Trim(); string identifier = line.Substring(1, pos - 1).Trim();
string value = line.Substring(pos + 1, line.Length - pos - 1).Trim(); string value = line.Substring(pos + 1, line.Length - pos - 1).Trim();
if (identifier.ToUpper() == "NAME") if (identifier.ToUpper() == "NAME")
pl.PlaylistName = value; pl.Name = value;
} }
//Song //Song
else else
+40 -36
View File
@@ -74,44 +74,48 @@ namespace Vocaluxe.Base
public static readonly string ProgramFolder = AppDomain.CurrentDomain.BaseDirectory; public static readonly string ProgramFolder = AppDomain.CurrentDomain.BaseDirectory;
#if INSTALLER #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 #else
public static readonly string DataPath = ProgramFolder; public static readonly string DataFolder = ProgramFolder;
#endif #endif
public const string Icon = "Vocaluxe.ico";
public const string Logo = "Logo.png";
public const string FallbackLanguage = "English"; public const string FallbackLanguage = "English";
public const string FileFonts = "Fonts.xml";
public const string FileOldHighscoreDB = "Ultrastar.db"; public const string FileNameIcon = "Vocaluxe.ico";
public const string FileCoverDB = "CoverDB.sqlite"; public const string FileNameLogo = "Logo.png";
public const string FileCreditsRessourcesDB = "CreditsRessourcesDB.sqlite"; public const string FileNameFonts = "Fonts.xml";
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 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 FileNamePerformanceLog = "Performance.log";
public const string FolderGraphics = "Graphics"; public const string FileNameErrorLog = "Error.log";
public const string FolderFonts = "Fonts"; public const string FileNameBenchmarkLog = "Benchmark.log";
public const string FolderThemes = "Themes"; public const string FileNameDebugLog = "Debug.log";
public const string FolderThemeFonts = "Fonts"; public const string FileNameSongInfoLog = "SongInformation.log";
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 FolderPartyModes = "PartyModes"; public const string FileNameSoundT440 = "440Hz.mp3";
public const string FolderPartyModeCode = "Code";
public const string FolderPartyModeScreens = "Screens"; public const string FolderNameSongs = "Songs";
public const string FolderPartyModeLanguages = "Languages"; public const string FolderNameProfiles = "Profiles";
public const string FolderPartyModeFonts = "Fonts"; 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 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"; public const string LinkSymbianApp = "https://build.phonegap.com/apps/639714/download/symbian/?qr_key=uY98ymvTr6K144RyTdhs";
@@ -213,12 +217,12 @@ namespace Vocaluxe.Base
{ {
var folders = new List<string> var folders = new List<string>
{ {
Path.Combine(Environment.CurrentDirectory, FolderCover), Path.Combine(ProgramFolder, FolderNameCover),
Path.Combine(Environment.CurrentDirectory, FolderFonts), Path.Combine(ProgramFolder, FolderNameFonts),
Path.Combine(DataPath, FolderScreenshots), Path.Combine(DataFolder, FolderNameScreenshots),
Path.Combine(Environment.CurrentDirectory, FolderBackgroundMusic), Path.Combine(ProgramFolder, FolderNameBackgroundMusic),
Path.Combine(Environment.CurrentDirectory, FolderSounds), Path.Combine(ProgramFolder, FolderNameSounds),
Path.Combine(DataPath, CConfig.FolderPlaylists) Path.Combine(DataFolder, CConfig.FolderPlaylists)
}; };
folders.AddRange(CConfig.ProfileFolders); folders.AddRange(CConfig.ProfileFolders);
folders.AddRange(CConfig.SongFolders); folders.AddRange(CConfig.SongFolders);
+3 -3
View File
@@ -85,7 +85,7 @@ namespace Vocaluxe.Base
} }
#region Stream Handling #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); return _Playback.Load(media, loop, prescan);
} }
@@ -176,11 +176,11 @@ namespace Vocaluxe.Base
#region Sounds #region Sounds
public static int PlaySound(ESounds sound, bool fade = true) 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) switch (sound)
{ {
case ESounds.T440: case ESounds.T440:
file = Path.Combine(file, CSettings.SoundT440); file = Path.Combine(file, CSettings.FileNameSoundT440);
break; break;
default: default:
return -1; return -1;
+6 -6
View File
@@ -266,13 +266,13 @@ namespace Vocaluxe.Base
{ {
CFonts.LoadThemeFonts( CFonts.LoadThemeFonts(
_Themes[themeIndex].Name, _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); xmlReader);
} }
else else
{ {
CFonts.LoadPartyModeFonts(_Themes[themeIndex].PartyModeID, CFonts.LoadPartyModeFonts(_Themes[themeIndex].PartyModeID,
Path.Combine(_Themes[themeIndex].Path, CSettings.FolderPartyModeFonts), Path.Combine(_Themes[themeIndex].Path, CSettings.FolderNamePartyModeFonts),
xmlReader); xmlReader);
} }
return true; return true;
@@ -385,11 +385,11 @@ namespace Vocaluxe.Base
{ {
_Themes.Clear(); _Themes.Clear();
string path = Path.Combine(Directory.GetCurrentDirectory(), CSettings.FolderThemes); string path = Path.Combine(CSettings.ProgramFolder, CSettings.FolderNameThemes);
List<string> files = CHelper.ListFiles(path, "*.xml"); List<string> files = CHelper.ListFiles(path, "*.xml", false, true);
foreach (string file in files) foreach (string file in files)
AddTheme(Path.Combine(path, file), -1); AddTheme(file, -1);
} }
public static bool AddTheme(string filePath, int partyModeID) public static bool AddTheme(string filePath, int partyModeID)
@@ -546,7 +546,7 @@ namespace Vocaluxe.Base
if (themeIndex != -1) if (themeIndex != -1)
{ {
path = Path.Combine(_Themes[themeIndex].Path, _Themes[themeIndex].SkinFolder); path = Path.Combine(_Themes[themeIndex].Path, _Themes[themeIndex].SkinFolder);
path = Path.Combine(path, CSettings.FolderScreens); path = Path.Combine(path, CSettings.FolderNameScreens);
} }
else else
CLog.LogError("Can't find current Theme"); CLog.LogError("Can't find current Theme");
+2 -2
View File
@@ -341,11 +341,11 @@ namespace Vocaluxe.Base.Fonts
/// <returns></returns> /// <returns></returns>
private static void _LoadFontList() 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) if (xmlReader == null)
return; return;
_LoadFontFiles(xmlReader, Path.Combine(Directory.GetCurrentDirectory(), CSettings.FolderFonts)); _LoadFontFiles(xmlReader, Path.Combine(CSettings.ProgramFolder, CSettings.FolderNameFonts));
} }
/// <summary> /// <summary>
+6 -15
View File
@@ -342,7 +342,7 @@ namespace Vocaluxe.Base.Server
return false; return false;
string name = DateTime.Now.ToString("yyyy-MM-dd_HH-mm-ss"); 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)) if (!string.IsNullOrEmpty(filePath))
{ {
_PhotosOfThisRound.Add(filePath); _PhotosOfThisRound.Add(filePath);
@@ -549,7 +549,7 @@ namespace Vocaluxe.Base.Server
return new SPlaylistInfo return new SPlaylistInfo
{ {
PlaylistId = playlist.Id, PlaylistId = playlist.Id,
PlaylistName = playlist.PlaylistName, PlaylistName = playlist.Name,
SongCount = playlist.Songs.Count, SongCount = playlist.Songs.Count,
LastChanged = DateTime.Now.ToLongDateString() LastChanged = DateTime.Now.ToLongDateString()
}; };
@@ -565,7 +565,7 @@ namespace Vocaluxe.Base.Server
private static int _AddPlaylist(string playlistName) private static int _AddPlaylist(string playlistName)
{ {
int newPlaylistId = CPlaylists.NewPlaylist(); int newPlaylistId = CPlaylists.NewPlaylist();
CPlaylists.Playlists[newPlaylistId].PlaylistName = playlistName; CPlaylists.Playlists[newPlaylistId].Name = playlistName;
CPlaylists.SavePlaylist(newPlaylistId); CPlaylists.SavePlaylist(newPlaylistId);
return newPlaylistId; return newPlaylistId;
@@ -682,19 +682,10 @@ namespace Vocaluxe.Base.Server
if (!Directory.Exists(folder)) if (!Directory.Exists(folder))
Directory.CreateDirectory(folder); Directory.CreateDirectory(folder);
string filename = Path.Combine(folder, name); string file = CHelper.GetUniqueFileName(folder, name + "." + extension);
if (File.Exists(filename + "." + extension))
{
int i = 0;
while (File.Exists(filename + "_" + i + "." + extension))
i++;
filename = filename + "_" + i + "." + extension;
}
else
filename = filename + "." + extension;
avatarImage.Save(filename); avatarImage.Save(file);
return filename; return file;
} }
} }
} }
+2 -2
View File
@@ -29,7 +29,7 @@ namespace Vocaluxe
public CSplashScreen() 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)) if (File.Exists(path))
{ {
try try
@@ -45,7 +45,7 @@ namespace Vocaluxe
else else
CLog.LogError("Can't find " + path); CLog.LogError("Can't find " + path);
path = Path.Combine(Environment.CurrentDirectory, CSettings.Icon); path = Path.Combine(CSettings.ProgramFolder, CSettings.FileNameIcon);
if (File.Exists(path)) if (File.Exists(path))
{ {
try try
+1 -1
View File
@@ -47,7 +47,7 @@ namespace Vocaluxe.Lib.Database
public override bool Init() 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(oldDBFilePath))
{ {
if (File.Exists(_FilePath)) if (File.Exists(_FilePath))
+1 -1
View File
@@ -119,7 +119,7 @@ namespace Vocaluxe.Lib.Database
{ {
foreach (string file in _FilesV1) foreach (string file in _FilesV1)
{ {
string filePath = Path.Combine(Environment.CurrentDirectory, file); string filePath = Path.Combine(CSettings.ProgramFolder, file);
if (!_AddImageToCreditsDB(filePath, transaction)) if (!_AddImageToCreditsDB(filePath, transaction))
{ {
transaction.Rollback(); transaction.Rollback();
+3 -8
View File
@@ -84,7 +84,7 @@ namespace Vocaluxe.Lib.Draw
/// </summary> /// </summary>
public CDirect3D() 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 //Fill Queue with 100000 IDs
for (int i = 0; i < _MaxID; i++) for (int i = 0; i < _MaxID; i++)
@@ -730,18 +730,13 @@ namespace Vocaluxe.Lib.Draw
/// </summary> /// </summary>
public void MakeScreenShot() public void MakeScreenShot()
{ {
const string file = "Screenshot_"; string file = CHelper.GetUniqueFileName(Path.Combine(CSettings.DataFolder, CSettings.FolderNameScreenshots), "Screenshot.bmp");
string path = Path.Combine(CSettings.DataPath, CSettings.FolderScreenshots);
int i = 0;
while (File.Exists(Path.Combine(path, file + i.ToString("00000") + ".bmp")))
i++;
//create a surface of the frame //create a surface of the frame
using (Surface surface = _Device.GetBackBuffer(0, 0)) using (Surface surface = _Device.GetBackBuffer(0, 0))
{ {
var screen = new Bitmap(Surface.ToStream(surface, ImageFileFormat.Bmp)); 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(); screen.Dispose();
} }
} }
+3 -8
View File
@@ -51,7 +51,7 @@ namespace Vocaluxe.Lib.Draw
public CDrawWinForm() public CDrawWinForm()
{ {
Icon = new Icon(Path.Combine(Environment.CurrentDirectory, CSettings.Icon)); Icon = new Icon(Path.Combine(CSettings.ProgramFolder, CSettings.FileNameIcon));
_Keys = new CKeys(); _Keys = new CKeys();
_Mouse = new CMouse(); _Mouse = new CMouse();
@@ -304,14 +304,9 @@ namespace Vocaluxe.Lib.Draw
public void MakeScreenShot() public void MakeScreenShot()
{ {
const string file = "Screenshot_"; string file = CHelper.GetUniqueFileName(Path.Combine(CSettings.DataFolder, CSettings.FolderNameScreenshots), "Screenshot.bmp");
string path = Path.Combine(CSettings.DataPath, CSettings.FolderScreenshots);
int i = 0; _Backbuffer.Save(file, ImageFormat.Png);
while (File.Exists(Path.Combine(path, file + i.ToString("00000") + ".png")))
i++;
_Backbuffer.Save(Path.Combine(path, file + i.ToString("00000") + ".png"), ImageFormat.Png);
} }
public void DrawLine(int a, int r, int g, int b, int w, int x1, int y1, int x2, int y2) public void DrawLine(int a, int r, int g, int b, int w, int x1, int y1, int x2, int y2)
+3 -8
View File
@@ -111,7 +111,7 @@ namespace Vocaluxe.Lib.Draw
public COpenGL() 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++) for (int i = 1; i < _MaxID; i++)
_IDs.Enqueue(i); _IDs.Enqueue(i);
@@ -534,12 +534,7 @@ namespace Vocaluxe.Lib.Draw
public void MakeScreenShot() public void MakeScreenShot()
{ {
const string file = "Screenshot_"; string file = CHelper.GetUniqueFileName(Path.Combine(CSettings.DataFolder, CSettings.FolderNameScreenshots), "Screenshot.bmp");
string path = Path.Combine(CSettings.DataPath, CSettings.FolderScreenshots);
int i = 0;
while (File.Exists(Path.Combine(path, file + i.ToString("00000") + ".bmp")))
i++;
int width = GetScreenWidth(); int width = GetScreenWidth();
int height = GetScreenHeight(); int height = GetScreenHeight();
@@ -552,7 +547,7 @@ namespace Vocaluxe.Lib.Draw
screen.UnlockBits(bmpData); screen.UnlockBits(bmpData);
screen.RotateFlip(RotateFlipType.RotateNoneFlipY); screen.RotateFlip(RotateFlipType.RotateNoneFlipY);
screen.Save(Path.Combine(path, file + i.ToString("00000") + ".bmp"), ImageFormat.Bmp); screen.Save(file, ImageFormat.Bmp);
} }
} }
+15 -23
View File
@@ -28,31 +28,31 @@ namespace Vocaluxe.Lib.Playlist
{ {
public class CPlaylistFile public class CPlaylistFile
{ {
public string PlaylistName; public string Name;
public string PlaylistFile; public string File;
public int Id = -1; public int Id = -1;
public List<CPlaylistSong> Songs = new List<CPlaylistSong>(); public List<CPlaylistSong> Songs = new List<CPlaylistSong>();
public CPlaylistFile() public CPlaylistFile()
{ {
PlaylistName = string.Empty; Name = string.Empty;
PlaylistFile = string.Empty; File = string.Empty;
} }
public CPlaylistFile(string file, int id) public CPlaylistFile(string file, int id)
{ {
Id = id; Id = id;
PlaylistFile = file; File = file;
_LoadPlaylist(); _LoadPlaylist();
} }
public void SavePlaylist() public void SavePlaylist()
{ {
if (PlaylistFile == "") if (File == "")
{ {
string filename = string.Empty; string filename = string.Empty;
// ReSharper disable LoopCanBeConvertedToQuery // ReSharper disable LoopCanBeConvertedToQuery
foreach (char chr in PlaylistName) foreach (char chr in Name)
// ReSharper restore LoopCanBeConvertedToQuery // ReSharper restore LoopCanBeConvertedToQuery
{ {
if (char.IsLetter(chr)) if (char.IsLetter(chr))
@@ -62,25 +62,17 @@ namespace Vocaluxe.Lib.Playlist
if (filename == "") if (filename == "")
filename = "1"; filename = "1";
int i = 0; File = CHelper.GetUniqueFileName(Path.Combine(CSettings.DataFolder, CConfig.FolderPlaylists), filename + ".xml");
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");
} }
XmlWriter writer; XmlWriter writer;
try try
{ {
writer = XmlWriter.Create(PlaylistFile, CConfig.XMLSettings); writer = XmlWriter.Create(File, CConfig.XMLSettings);
} }
catch (Exception e) catch (Exception e)
{ {
CLog.LogError("Error creating/opening Playlist File " + PlaylistFile + ": " + e.Message); CLog.LogError("Error creating/opening Playlist File " + File + ": " + e.Message);
return; return;
} }
@@ -90,7 +82,7 @@ namespace Vocaluxe.Lib.Playlist
writer.WriteStartElement("root"); writer.WriteStartElement("root");
writer.WriteStartElement("Info"); writer.WriteStartElement("Info");
writer.WriteElementString("PlaylistName", PlaylistName); writer.WriteElementString("PlaylistName", Name);
writer.WriteEndElement(); writer.WriteEndElement();
writer.WriteStartElement("Songs"); writer.WriteStartElement("Songs");
@@ -123,14 +115,14 @@ namespace Vocaluxe.Lib.Playlist
private void _LoadPlaylist() private void _LoadPlaylist()
{ {
CXMLReader xmlReader = CXMLReader.OpenFile(PlaylistFile); CXMLReader xmlReader = CXMLReader.OpenFile(File);
if (xmlReader == null) if (xmlReader == null)
return; return;
string value = String.Empty; string value = String.Empty;
if (xmlReader.GetValue("//root/Info/PlaylistName", out value, value)) if (xmlReader.GetValue("//root/Info/PlaylistName", out value, value))
{ {
PlaylistName = value; Name = value;
Songs = new List<CPlaylistSong>(); Songs = new List<CPlaylistSong>();
@@ -161,11 +153,11 @@ namespace Vocaluxe.Lib.Playlist
Songs.Add(playlistSong); Songs.Add(playlistSong);
} }
else 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 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) public void AddSong(int songID)
+3 -8
View File
@@ -345,13 +345,8 @@ namespace Vocaluxe.Screens
private void _OnSaveSnapshot() private void _OnSaveSnapshot()
{ {
string filename = Path.Combine(CSettings.DataPath, CConfig.ProfileFolders[0], "snapshot"); string file = CHelper.GetUniqueFileName(Path.Combine(CSettings.DataFolder, CConfig.ProfileFolders[0]), "snapshot.png");
int i = 0; _Snapshot.Save(file, ImageFormat.Png);
while (File.Exists(filename + i + ".png"))
i++;
filename = filename + i + ".png";
_Snapshot.Save(filename, ImageFormat.Png);
_Snapshot = null; _Snapshot = null;
CDraw.RemoveTexture(ref _WebcamTexture); CDraw.RemoveTexture(ref _WebcamTexture);
@@ -361,7 +356,7 @@ namespace Vocaluxe.Screens
_Buttons[_ButtonTakeSnapshot].Visible = false; _Buttons[_ButtonTakeSnapshot].Visible = false;
_Buttons[_ButtonWebcam].Visible = CWebcam.IsDeviceAvailable(); _Buttons[_ButtonWebcam].Visible = CWebcam.IsDeviceAvailable();
int id = CProfiles.NewAvatar(filename); int id = CProfiles.NewAvatar(file);
CProfiles.SetAvatar(_SelectSlides[_SelectSlideProfiles].ValueIndex, id); CProfiles.SetAvatar(_SelectSlides[_SelectSlideProfiles].ValueIndex, id);
_LoadAvatars(false); _LoadAvatars(false);
} }
+2 -2
View File
@@ -1345,8 +1345,8 @@ namespace Vocaluxe.Screens
_OpenPlaylist(_Playlist.ActivePlaylistID); _OpenPlaylist(_Playlist.ActivePlaylistID);
//Add new playlist to select-slide //Add new playlist to select-slide
_SelectSlides[_SelectSlideOptionsPlaylistAdd].AddValue(CPlaylists.Playlists[_Playlist.ActivePlaylistID].PlaylistName); _SelectSlides[_SelectSlideOptionsPlaylistAdd].AddValue(CPlaylists.Playlists[_Playlist.ActivePlaylistID].Name);
_SelectSlides[_SelectSlideOptionsPlaylistOpen].AddValue(CPlaylists.Playlists[_Playlist.ActivePlaylistID].PlaylistName); _SelectSlides[_SelectSlideOptionsPlaylistOpen].AddValue(CPlaylists.Playlists[_Playlist.ActivePlaylistID].Name);
} }
//Add song to loaded playlist //Add song to loaded playlist
else else
+24
View File
@@ -273,6 +273,30 @@ namespace VocaluxeLib
{ {
return (bounds.X <= x) && (bounds.X + bounds.W >= x) && (bounds.Y <= y) && (bounds.Y + bounds.H >= y); return (bounds.X <= x) && (bounds.X + bounds.W >= x) && (bounds.Y <= y) && (bounds.Y + bounds.H >= y);
} }
/// <summary>
/// Returns a filename that is unique in that path
/// </summary>
/// <param name="path">Path in which the file should be stored</param>
/// <param name="filename">filename (including extension)</param>
/// <returns></returns>
public static string GetUniqueFileName(string path, string filename, bool withPath = true)
{
string ext = Path.GetExtension(filename);
filename = Path.GetFileNameWithoutExtension(filename);
if (filename == null)
filename = "1";
if (File.Exists(Path.Combine(path, filename + ext)))
{
int i = 1;
while (File.Exists(Path.Combine(path, filename + "_" + i + ext)))
i++;
filename += "_" + i;
}
if (withPath)
filename = Path.Combine(path, filename);
return filename + ext;
}
} }
static class CEncoding static class CEncoding
+1 -12
View File
@@ -120,20 +120,9 @@ namespace VocaluxeLib.Profile
if (filename == "") if (filename == "")
filename = "1"; filename = "1";
int i = 0; FileName = CHelper.GetUniqueFileName(FilePath, filename + ".xml", false);
while (File.Exists(Path.Combine(FilePath, filename + ".xml")))
{
i++;
if (!File.Exists(Path.Combine(FilePath, filename + i + ".xml")))
filename += i;
}
FileName = filename + ".xml";
} }
if (FileName == String.Empty)
return;
XmlWriter writer; XmlWriter writer;
try try
{ {
+1 -1
View File
@@ -55,7 +55,7 @@ namespace WebserverInitalConfig
ProcessStartInfo proc = new ProcessStartInfo ProcessStartInfo proc = new ProcessStartInfo
{ {
UseShellExecute = true, UseShellExecute = true,
WorkingDirectory = Environment.CurrentDirectory, WorkingDirectory = AppDomain.CurrentDomain.BaseDirectory,
FileName = Process.GetCurrentProcess().MainModule.FileName, FileName = Process.GetCurrentProcess().MainModule.FileName,
Arguments = args[0] + " " + args[1], Arguments = args[0] + " " + args[1],
Verb = "runas", Verb = "runas",