Make CSettings contain only constant values to avoid accidental misuse. Everything changeable is in CConfig
This commit is contained in:
1 parent
cd79704c00
commit
eba5deba2b
30 files changed
+217
-243
No files matched your search
@@ -22,36 +22,46 @@ namespace VocaluxeLib.Profile
|
||||
public class CAvatar
|
||||
{
|
||||
public int ID;
|
||||
public string FileName = "";
|
||||
public CTexture Texture;
|
||||
private string _FileName = "";
|
||||
private CTexture _Texture;
|
||||
|
||||
public CAvatar(int id)
|
||||
public CTexture Texture
|
||||
{
|
||||
get { return _Texture; }
|
||||
}
|
||||
public string FileName
|
||||
{
|
||||
get { return _FileName; }
|
||||
}
|
||||
|
||||
public static CAvatar GetAvatar(string fileName)
|
||||
{
|
||||
CTexture texture = CBase.Drawing.AddTexture(fileName);
|
||||
return texture == null ? null : new CAvatar(texture, fileName);
|
||||
}
|
||||
|
||||
private CAvatar(CTexture texture, string fileName, int id = -1)
|
||||
{
|
||||
ID = id;
|
||||
}
|
||||
|
||||
public bool LoadFromFile(string fileName)
|
||||
{
|
||||
FileName = fileName;
|
||||
_FileName = fileName;
|
||||
return Reload();
|
||||
}
|
||||
|
||||
public bool Reload()
|
||||
{
|
||||
CBase.Drawing.RemoveTexture(ref Texture);
|
||||
Texture = CBase.Drawing.AddTexture(FileName);
|
||||
Unload();
|
||||
_Texture = CBase.Drawing.AddTexture(_FileName);
|
||||
|
||||
return Texture != null;
|
||||
return _Texture != null;
|
||||
}
|
||||
|
||||
public void Unload()
|
||||
{
|
||||
CBase.Drawing.RemoveTexture(ref Texture);
|
||||
}
|
||||
|
||||
public string GetFileName()
|
||||
{
|
||||
return FileName;
|
||||
CBase.Drawing.RemoveTexture(ref _Texture);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -38,22 +38,12 @@ namespace VocaluxeLib.Profile
|
||||
public string PlayerName;
|
||||
public string FilePath;
|
||||
public string FileName;
|
||||
public string AvatarFileName;
|
||||
public byte[] PasswordHash;
|
||||
public byte[] PasswordSalt;
|
||||
|
||||
public EGameDifficulty Difficulty;
|
||||
|
||||
private CAvatar _Avatar;
|
||||
public CAvatar Avatar
|
||||
{
|
||||
get { return _Avatar; }
|
||||
set
|
||||
{
|
||||
_Avatar = value;
|
||||
AvatarFileName = _Avatar.FileName;
|
||||
}
|
||||
}
|
||||
public CAvatar Avatar { get; set; }
|
||||
|
||||
public EUserRole UserRole;
|
||||
public EOffOn Active;
|
||||
@@ -62,11 +52,9 @@ namespace VocaluxeLib.Profile
|
||||
{
|
||||
PlayerName = String.Empty;
|
||||
Difficulty = EGameDifficulty.TR_CONFIG_EASY;
|
||||
Avatar = new CAvatar(-1);
|
||||
UserRole = EUserRole.TR_USERROLE_NORMAL;
|
||||
Active = EOffOn.TR_CONFIG_ON;
|
||||
|
||||
AvatarFileName = String.Empty;
|
||||
FileName = String.Empty;
|
||||
}
|
||||
|
||||
@@ -95,9 +83,10 @@ namespace VocaluxeLib.Profile
|
||||
if (xmlReader.GetValue("//root/Info/PlayerName", out value, value))
|
||||
{
|
||||
PlayerName = value;
|
||||
|
||||
string avatarFileName;
|
||||
xmlReader.TryGetEnumValue("//root/Info/Difficulty", ref Difficulty);
|
||||
xmlReader.GetValue("//root/Info/Avatar", out AvatarFileName, String.Empty);
|
||||
xmlReader.GetValue("//root/Info/Avatar", out avatarFileName, String.Empty);
|
||||
Avatar = CBase.Profiles.GetAvatarByFilename(avatarFileName);
|
||||
xmlReader.TryGetEnumValue("//root/Info/UserRole", ref UserRole);
|
||||
xmlReader.TryGetEnumValue("//root/Info/Active", ref Active);
|
||||
string passwordHash;
|
||||
|
||||
Reference in new issue
Block a user