reconstructed CProfiles (preparing for async profile adding)
This commit is contained in:
1 parent
967e2eb4b1
commit
19339c6888
11 files changed
+353
-225
No files matched your search
@@ -9,28 +9,23 @@ namespace VocaluxeLib.Profile
|
||||
{
|
||||
public class CAvatar
|
||||
{
|
||||
private int _ID;
|
||||
|
||||
public int ID
|
||||
{
|
||||
get { return _ID; }
|
||||
}
|
||||
|
||||
public int ID;
|
||||
public string FileName;
|
||||
public STexture Texture;
|
||||
|
||||
public CAvatar(int ID)
|
||||
{
|
||||
_ID = ID;
|
||||
this.ID = ID;
|
||||
FileName = String.Empty;
|
||||
Texture = new STexture(-1);
|
||||
}
|
||||
|
||||
public void LoadFromFile(string NewFileName)
|
||||
public bool LoadFromFile(string NewFileName)
|
||||
{
|
||||
FileName = NewFileName;
|
||||
CBase.Drawing.RemoveTexture(ref Texture);
|
||||
Texture = CBase.Drawing.AddTexture(FileName);
|
||||
return (Texture.Index != -1);
|
||||
}
|
||||
|
||||
public void Reload()
|
||||
@@ -38,5 +33,10 @@ namespace VocaluxeLib.Profile
|
||||
CBase.Drawing.RemoveTexture(ref Texture);
|
||||
Texture = CBase.Drawing.AddTexture(FileName);
|
||||
}
|
||||
|
||||
public void Unload()
|
||||
{
|
||||
CBase.Drawing.RemoveTexture(ref Texture);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -16,20 +16,14 @@ namespace VocaluxeLib.Profile
|
||||
ConformanceLevel = ConformanceLevel.Document
|
||||
};
|
||||
|
||||
private int _ID;
|
||||
private int _AvatarID;
|
||||
|
||||
public int ID
|
||||
{
|
||||
get { return _ID; }
|
||||
}
|
||||
|
||||
public int ID;
|
||||
|
||||
public string PlayerName;
|
||||
public string FileName;
|
||||
public string AvatarFileName;
|
||||
|
||||
public EGameDifficulty Difficulty;
|
||||
public CAvatar Avatar; //should be removed! use avatar id
|
||||
public CAvatar Avatar;
|
||||
|
||||
public EOffOn GuestProfile;
|
||||
public EOffOn Active;
|
||||
@@ -78,6 +72,29 @@ namespace VocaluxeLib.Profile
|
||||
|
||||
public void SaveProfile()
|
||||
{
|
||||
if (FileName == String.Empty)
|
||||
{
|
||||
string filename = string.Empty;
|
||||
foreach (char chr in PlayerName)
|
||||
{
|
||||
if (char.IsLetter(chr))
|
||||
filename += chr.ToString();
|
||||
}
|
||||
|
||||
if (filename == "")
|
||||
filename = "1";
|
||||
|
||||
int i = 0;
|
||||
while (File.Exists(Path.Combine(CBase.Settings.GetFolderProfiles(), filename + ".xml")))
|
||||
{
|
||||
i++;
|
||||
if (!File.Exists(Path.Combine(CBase.Settings.GetFolderProfiles(), filename + i + ".xml")))
|
||||
filename += i;
|
||||
}
|
||||
|
||||
FileName = Path.Combine(Environment.CurrentDirectory, CBase.Settings.GetFolderProfiles(), filename + ".xml");
|
||||
}
|
||||
|
||||
if (FileName == String.Empty)
|
||||
return;
|
||||
|
||||
@@ -99,7 +116,7 @@ namespace VocaluxeLib.Profile
|
||||
writer.WriteStartElement("Info");
|
||||
writer.WriteElementString("PlayerName", PlayerName);
|
||||
writer.WriteElementString("Difficulty", Enum.GetName(typeof(EGameDifficulty), Difficulty));
|
||||
writer.WriteElementString("Avatar", Avatar.FileName);
|
||||
writer.WriteElementString("Avatar", Path.GetFileName(Avatar.FileName));
|
||||
writer.WriteElementString("GuestProfile", Enum.GetName(typeof(EOffOn), GuestProfile));
|
||||
writer.WriteElementString("Active", Enum.GetName(typeof(EOffOn), Active));
|
||||
writer.WriteEndElement();
|
||||
|
||||
Reference in new issue
Block a user