Profiles could be in different folders now, vocaluxe loads profiles from main-folder and user-folder, new profiles will be saved in user-folder.

This commit is contained in:
flokuep authored and Stephan Sundermann committed 2013-08-31 13:42:31 +02:00
1 parent 00f3a3aed2
commit afdd3cae62
8 files changed
+54 -23

No files matched your search

+2 -1
View File
@@ -785,7 +785,8 @@ namespace Vocaluxe.Base
case "profilefolder":
CSettings.CreateFolder(value);
CSettings.FolderProfiles = value;
CSettings.FoldersProfiles.Clear();
CSettings.FoldersProfiles.Add(value);
break;
}
}
+5
View File
@@ -219,6 +219,11 @@ namespace Vocaluxe.Base
{
return CSettings.FolderProfiles;
}
public string GetDataPath()
{
return CSettings.DataPath;
}
}
class CBtheme : ITheme
+13 -8
View File
@@ -322,7 +322,7 @@ namespace Vocaluxe.Base
{
CProfile profile = new CProfile
{
FileName = fileName != "" ? Path.Combine(CSettings.FolderProfiles, fileName) : String.Empty
FileName = fileName != "" ? Path.Combine(CSettings.DataPath, CSettings.FolderProfiles, fileName) : String.Empty
};
if (File.Exists(profile.FileName))
@@ -529,7 +529,8 @@ namespace Vocaluxe.Base
}
List<string> files = new List<string>();
files.AddRange(CHelper.ListFiles(CSettings.FolderProfiles, "*.xml", true, true));
foreach(string path in CSettings.FoldersProfiles)
files.AddRange(CHelper.ListFiles(path, "*.xml", true, true));
foreach (string file in files)
{
@@ -538,7 +539,8 @@ namespace Vocaluxe.Base
CProfile profile = new CProfile
{
FileName = Path.Combine(CSettings.FolderProfiles, file)
FileName = Path.GetFileName(file),
FilePath = Path.GetDirectoryName(file)
};
if (profile.LoadProfile())
@@ -568,10 +570,13 @@ namespace Vocaluxe.Base
}
List<string> files = new List<string>();
files.AddRange(CHelper.ListFiles(CSettings.FolderProfiles, "*.png", true, true));
files.AddRange(CHelper.ListFiles(CSettings.FolderProfiles, "*.jpg", true, true));
files.AddRange(CHelper.ListFiles(CSettings.FolderProfiles, "*.jpeg", true, true));
files.AddRange(CHelper.ListFiles(CSettings.FolderProfiles, "*.bmp", true, true));
foreach (string path in CSettings.FoldersProfiles)
{
files.AddRange(CHelper.ListFiles(path, "*.png", true, true));
files.AddRange(CHelper.ListFiles(path, "*.jpg", true, true));
files.AddRange(CHelper.ListFiles(path, "*.jpeg", true, true));
files.AddRange(CHelper.ListFiles(path, "*.bmp", true, true));
}
foreach (string file in files)
{
@@ -610,7 +615,7 @@ namespace Vocaluxe.Base
CConfig.SaveConfig();
}
}
File.Delete(_Profiles[profileID].FileName);
File.Delete(Path.Combine(_Profiles[profileID].FilePath, _Profiles[profileID].FileName));
_RemoveProfile(profileID);
//Check if profile is selected in game
+12 -2
View File
@@ -96,7 +96,16 @@ namespace Vocaluxe.Base
public const string FolderThemes = "Themes";
public const string FolderThemeFonts = "Fonts";
public const string FolderScreens = "Screens";
public static string FolderProfiles = "Profiles";
public const string FolderProfiles = "Profiles";
public static List<string> FoldersProfiles = new List<string>()
{
#if PORTABLE
Path.Combine(DataPath, FolderProfiles)
#else
Path.Combine(Environment.CurrentDirectory, FolderProfiles),
Path.Combine(DataPath, FolderProfiles)
#endif
};
public const string FolderSongs = "Songs";
public const string FolderSounds = "Sounds";
public const string FolderLanguages = "Languages";
@@ -215,7 +224,8 @@ namespace Vocaluxe.Base
public static void CreateFolders()
{
List<string> folders = new List<string> {FolderCover, FolderFonts, FolderProfiles, Path.Combine(DataPath,FolderScreenshots), FolderBackgroundMusic, FolderSounds, Path.Combine(DataPath,FolderPlaylists)};
List<string> folders = new List<string> {FolderCover, FolderFonts, Path.Combine(DataPath,FolderScreenshots), FolderBackgroundMusic, FolderSounds, Path.Combine(DataPath,FolderPlaylists)};
folders.AddRange(FoldersProfiles);
foreach (string folder in folders)
{
+3 -3
View File
@@ -128,9 +128,9 @@ namespace Vocaluxe.Base.Server
const string filename = "snapshot";
int i = 0;
while (File.Exists(Path.Combine(CSettings.FolderProfiles, filename + i + ".png")))
while (File.Exists(Path.Combine(CSettings.DataPath, CSettings.FolderProfiles, filename + i + ".png")))
i++;
bmp.Save(Path.Combine(CSettings.FolderProfiles, filename + i + ".png"), ImageFormat.Png);
bmp.Save(Path.Combine(CSettings.DataPath, CSettings.FolderProfiles, filename + i + ".png"), ImageFormat.Png);
}
answer = CCommands.CreateCommandWithoutParams(CCommands.ResponseOK);
@@ -182,7 +182,7 @@ namespace Vocaluxe.Base.Server
string result = String.Empty;
try
{
string filename = Path.Combine(CSettings.FolderProfiles, "snapshot");
string filename = Path.Combine(CSettings.DataPath, CSettings.FolderProfiles, "snapshot");
int i = 0;
while (File.Exists(filename + i + ".jpg"))
i++;
+1 -1
View File
@@ -332,7 +332,7 @@ namespace Vocaluxe.Screens
private void _OnSaveSnapshot()
{
string filename = Path.Combine(CSettings.FolderProfiles, "snapshot");
string filename = Path.Combine(CSettings.DataPath, CSettings.FolderProfiles, "snapshot");
int i = 0;
while (File.Exists(filename + i + ".png"))
i++;
+1
View File
@@ -79,6 +79,7 @@ namespace VocaluxeLib
float GetMedleyMinDuration();
string GetFolderProfiles();
string GetDataPath();
}
public interface ITheme
+17 -8
View File
@@ -36,6 +36,7 @@ namespace VocaluxeLib.Profile
public int ID;
public string PlayerName;
public string FilePath;
public string FileName;
public string AvatarFileName;
@@ -69,14 +70,20 @@ namespace VocaluxeLib.Profile
public bool LoadProfile()
{
return LoadProfile(FileName);
return LoadProfile(FilePath, FileName);
}
public bool LoadProfile(string fileName)
public bool LoadProfile(string file)
{
FileName = fileName;
FileName = Path.GetFileName(file);
FilePath = Path.GetDirectoryName(file);
CXMLReader xmlReader = CXMLReader.OpenFile(FileName);
return LoadProfile(FilePath, FileName);
}
public bool LoadProfile(string pathName, string fileName)
{
CXMLReader xmlReader = CXMLReader.OpenFile(Path.Combine(FilePath, FileName));
if (xmlReader == null)
return false;
@@ -99,6 +106,8 @@ namespace VocaluxeLib.Profile
public void SaveProfile()
{
if (String.IsNullOrEmpty(FilePath))
FilePath = Path.Combine(CBase.Settings.GetDataPath(),CBase.Settings.GetFolderProfiles());
if (FileName == String.Empty)
{
string filename = string.Empty;
@@ -114,14 +123,14 @@ namespace VocaluxeLib.Profile
filename = "1";
int i = 0;
while (File.Exists(Path.Combine(CBase.Settings.GetFolderProfiles(), filename + ".xml")))
while (File.Exists(Path.Combine(FilePath, filename + ".xml")))
{
i++;
if (!File.Exists(Path.Combine(CBase.Settings.GetFolderProfiles(), filename + i + ".xml")))
if (!File.Exists(Path.Combine(FilePath, filename + i + ".xml")))
filename += i;
}
FileName = Path.Combine(Environment.CurrentDirectory, CBase.Settings.GetFolderProfiles(), filename + ".xml");
FileName = filename + ".xml";
}
if (FileName == String.Empty)
@@ -130,7 +139,7 @@ namespace VocaluxeLib.Profile
XmlWriter writer;
try
{
writer = XmlWriter.Create(FileName, _Settings);
writer = XmlWriter.Create(Path.Combine(FilePath, FileName), _Settings);
}
catch (Exception e)
{