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:
1 parent
00f3a3aed2
commit
afdd3cae62
8 files changed
+54
-23
No files matched your search
@@ -785,7 +785,8 @@ namespace Vocaluxe.Base
|
|||||||
|
|
||||||
case "profilefolder":
|
case "profilefolder":
|
||||||
CSettings.CreateFolder(value);
|
CSettings.CreateFolder(value);
|
||||||
CSettings.FolderProfiles = value;
|
CSettings.FoldersProfiles.Clear();
|
||||||
|
CSettings.FoldersProfiles.Add(value);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -219,6 +219,11 @@ namespace Vocaluxe.Base
|
|||||||
{
|
{
|
||||||
return CSettings.FolderProfiles;
|
return CSettings.FolderProfiles;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public string GetDataPath()
|
||||||
|
{
|
||||||
|
return CSettings.DataPath;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class CBtheme : ITheme
|
class CBtheme : ITheme
|
||||||
|
|||||||
@@ -322,7 +322,7 @@ namespace Vocaluxe.Base
|
|||||||
{
|
{
|
||||||
CProfile profile = new CProfile
|
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))
|
if (File.Exists(profile.FileName))
|
||||||
@@ -529,7 +529,8 @@ namespace Vocaluxe.Base
|
|||||||
}
|
}
|
||||||
|
|
||||||
List<string> files = new List<string>();
|
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)
|
foreach (string file in files)
|
||||||
{
|
{
|
||||||
@@ -538,7 +539,8 @@ namespace Vocaluxe.Base
|
|||||||
|
|
||||||
CProfile profile = new CProfile
|
CProfile profile = new CProfile
|
||||||
{
|
{
|
||||||
FileName = Path.Combine(CSettings.FolderProfiles, file)
|
FileName = Path.GetFileName(file),
|
||||||
|
FilePath = Path.GetDirectoryName(file)
|
||||||
};
|
};
|
||||||
|
|
||||||
if (profile.LoadProfile())
|
if (profile.LoadProfile())
|
||||||
@@ -568,10 +570,13 @@ namespace Vocaluxe.Base
|
|||||||
}
|
}
|
||||||
|
|
||||||
List<string> files = new List<string>();
|
List<string> files = new List<string>();
|
||||||
files.AddRange(CHelper.ListFiles(CSettings.FolderProfiles, "*.png", true, true));
|
foreach (string path in CSettings.FoldersProfiles)
|
||||||
files.AddRange(CHelper.ListFiles(CSettings.FolderProfiles, "*.jpg", true, true));
|
{
|
||||||
files.AddRange(CHelper.ListFiles(CSettings.FolderProfiles, "*.jpeg", true, true));
|
files.AddRange(CHelper.ListFiles(path, "*.png", true, true));
|
||||||
files.AddRange(CHelper.ListFiles(CSettings.FolderProfiles, "*.bmp", 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)
|
foreach (string file in files)
|
||||||
{
|
{
|
||||||
@@ -610,7 +615,7 @@ namespace Vocaluxe.Base
|
|||||||
CConfig.SaveConfig();
|
CConfig.SaveConfig();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
File.Delete(_Profiles[profileID].FileName);
|
File.Delete(Path.Combine(_Profiles[profileID].FilePath, _Profiles[profileID].FileName));
|
||||||
_RemoveProfile(profileID);
|
_RemoveProfile(profileID);
|
||||||
|
|
||||||
//Check if profile is selected in game
|
//Check if profile is selected in game
|
||||||
|
|||||||
@@ -96,7 +96,16 @@ namespace Vocaluxe.Base
|
|||||||
public const string FolderThemes = "Themes";
|
public const string FolderThemes = "Themes";
|
||||||
public const string FolderThemeFonts = "Fonts";
|
public const string FolderThemeFonts = "Fonts";
|
||||||
public const string FolderScreens = "Screens";
|
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 FolderSongs = "Songs";
|
||||||
public const string FolderSounds = "Sounds";
|
public const string FolderSounds = "Sounds";
|
||||||
public const string FolderLanguages = "Languages";
|
public const string FolderLanguages = "Languages";
|
||||||
@@ -215,7 +224,8 @@ namespace Vocaluxe.Base
|
|||||||
|
|
||||||
public static void CreateFolders()
|
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)
|
foreach (string folder in folders)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -128,9 +128,9 @@ namespace Vocaluxe.Base.Server
|
|||||||
|
|
||||||
const string filename = "snapshot";
|
const string filename = "snapshot";
|
||||||
int i = 0;
|
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++;
|
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);
|
answer = CCommands.CreateCommandWithoutParams(CCommands.ResponseOK);
|
||||||
@@ -182,7 +182,7 @@ namespace Vocaluxe.Base.Server
|
|||||||
string result = String.Empty;
|
string result = String.Empty;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
string filename = Path.Combine(CSettings.FolderProfiles, "snapshot");
|
string filename = Path.Combine(CSettings.DataPath, CSettings.FolderProfiles, "snapshot");
|
||||||
int i = 0;
|
int i = 0;
|
||||||
while (File.Exists(filename + i + ".jpg"))
|
while (File.Exists(filename + i + ".jpg"))
|
||||||
i++;
|
i++;
|
||||||
|
|||||||
@@ -332,7 +332,7 @@ namespace Vocaluxe.Screens
|
|||||||
|
|
||||||
private void _OnSaveSnapshot()
|
private void _OnSaveSnapshot()
|
||||||
{
|
{
|
||||||
string filename = Path.Combine(CSettings.FolderProfiles, "snapshot");
|
string filename = Path.Combine(CSettings.DataPath, CSettings.FolderProfiles, "snapshot");
|
||||||
int i = 0;
|
int i = 0;
|
||||||
while (File.Exists(filename + i + ".png"))
|
while (File.Exists(filename + i + ".png"))
|
||||||
i++;
|
i++;
|
||||||
|
|||||||
@@ -79,6 +79,7 @@ namespace VocaluxeLib
|
|||||||
float GetMedleyMinDuration();
|
float GetMedleyMinDuration();
|
||||||
|
|
||||||
string GetFolderProfiles();
|
string GetFolderProfiles();
|
||||||
|
string GetDataPath();
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface ITheme
|
public interface ITheme
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ namespace VocaluxeLib.Profile
|
|||||||
public int ID;
|
public int ID;
|
||||||
|
|
||||||
public string PlayerName;
|
public string PlayerName;
|
||||||
|
public string FilePath;
|
||||||
public string FileName;
|
public string FileName;
|
||||||
public string AvatarFileName;
|
public string AvatarFileName;
|
||||||
|
|
||||||
@@ -69,14 +70,20 @@ namespace VocaluxeLib.Profile
|
|||||||
|
|
||||||
public bool LoadProfile()
|
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)
|
if (xmlReader == null)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@@ -99,6 +106,8 @@ namespace VocaluxeLib.Profile
|
|||||||
|
|
||||||
public void SaveProfile()
|
public void SaveProfile()
|
||||||
{
|
{
|
||||||
|
if (String.IsNullOrEmpty(FilePath))
|
||||||
|
FilePath = Path.Combine(CBase.Settings.GetDataPath(),CBase.Settings.GetFolderProfiles());
|
||||||
if (FileName == String.Empty)
|
if (FileName == String.Empty)
|
||||||
{
|
{
|
||||||
string filename = string.Empty;
|
string filename = string.Empty;
|
||||||
@@ -114,14 +123,14 @@ namespace VocaluxeLib.Profile
|
|||||||
filename = "1";
|
filename = "1";
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
while (File.Exists(Path.Combine(CBase.Settings.GetFolderProfiles(), filename + ".xml")))
|
while (File.Exists(Path.Combine(FilePath, filename + ".xml")))
|
||||||
{
|
{
|
||||||
i++;
|
i++;
|
||||||
if (!File.Exists(Path.Combine(CBase.Settings.GetFolderProfiles(), filename + i + ".xml")))
|
if (!File.Exists(Path.Combine(FilePath, filename + i + ".xml")))
|
||||||
filename += i;
|
filename += i;
|
||||||
}
|
}
|
||||||
|
|
||||||
FileName = Path.Combine(Environment.CurrentDirectory, CBase.Settings.GetFolderProfiles(), filename + ".xml");
|
FileName = filename + ".xml";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (FileName == String.Empty)
|
if (FileName == String.Empty)
|
||||||
@@ -130,7 +139,7 @@ namespace VocaluxeLib.Profile
|
|||||||
XmlWriter writer;
|
XmlWriter writer;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
writer = XmlWriter.Create(FileName, _Settings);
|
writer = XmlWriter.Create(Path.Combine(FilePath, FileName), _Settings);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in new issue
Block a user