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
@@ -290,7 +290,7 @@ namespace VocaluxeLib
|
||||
}
|
||||
#endregion Config
|
||||
|
||||
public enum EGameState
|
||||
public enum EProgramState
|
||||
{
|
||||
Start,
|
||||
Normal,
|
||||
|
||||
@@ -71,7 +71,7 @@ namespace VocaluxeLib
|
||||
float GetZFar();
|
||||
float GetZNear();
|
||||
|
||||
EGameState GetGameState();
|
||||
EProgramState GetProgramState();
|
||||
|
||||
int GetToneMin();
|
||||
int GetToneMax();
|
||||
@@ -209,6 +209,7 @@ namespace VocaluxeLib
|
||||
EGameDifficulty GetDifficulty(int profileID);
|
||||
string GetPlayerName(int profileID, int playerNum = 0);
|
||||
CTexture GetAvatar(int profileID);
|
||||
CAvatar GetAvatarByFilename(string fileName);
|
||||
bool IsProfileIDValid(int profileID);
|
||||
bool IsGuest(int profileID);
|
||||
void AddProfileChangedCallback(ProfileChangedCallback notification);
|
||||
|
||||
@@ -276,7 +276,7 @@ namespace VocaluxeLib.Menu
|
||||
|
||||
public void Draw(bool forceDraw = false)
|
||||
{
|
||||
if (!Visible && CBase.Settings.GetGameState() != EGameState.EditTheme && !forceDraw)
|
||||
if (!Visible && CBase.Settings.GetProgramState() != EProgramState.EditTheme && !forceDraw)
|
||||
return;
|
||||
|
||||
CTexture texture;
|
||||
|
||||
@@ -224,7 +224,7 @@ namespace VocaluxeLib.Menu
|
||||
#region draw
|
||||
public void Draw(float actualBeat)
|
||||
{
|
||||
if (Visible || CBase.Settings.GetGameState() == EGameState.EditTheme)
|
||||
if (Visible || CBase.Settings.GetProgramState() == EProgramState.EditTheme)
|
||||
{
|
||||
switch (LyricStyle)
|
||||
{
|
||||
|
||||
@@ -968,7 +968,7 @@ namespace VocaluxeLib.Menu
|
||||
float z = CBase.Settings.GetZFar();
|
||||
for (int i = 0; i < _Interactions.Count; i++)
|
||||
{
|
||||
if ((CBase.Settings.GetGameState() != EGameState.EditTheme) && (_Interactions[i].ThemeEditorOnly || !_IsVisible(i) || !_IsEnabled(i)))
|
||||
if ((CBase.Settings.GetProgramState() != EProgramState.EditTheme) && (_Interactions[i].ThemeEditorOnly || !_IsVisible(i) || !_IsEnabled(i)))
|
||||
continue;
|
||||
if (!_IsMouseOver(x, y, _Interactions[i]))
|
||||
continue;
|
||||
@@ -1043,7 +1043,7 @@ namespace VocaluxeLib.Menu
|
||||
private void _NextInteraction()
|
||||
{
|
||||
_UnsetSelected();
|
||||
if (CBase.Settings.GetGameState() != EGameState.EditTheme)
|
||||
if (CBase.Settings.GetProgramState() != EProgramState.EditTheme)
|
||||
{
|
||||
bool found = false;
|
||||
int start = _Selection;
|
||||
@@ -1070,7 +1070,7 @@ namespace VocaluxeLib.Menu
|
||||
private void _PrevInteraction()
|
||||
{
|
||||
_UnsetSelected();
|
||||
if (CBase.Settings.GetGameState() != EGameState.EditTheme)
|
||||
if (CBase.Settings.GetProgramState() != EProgramState.EditTheme)
|
||||
{
|
||||
bool found = false;
|
||||
int start = _Selection;
|
||||
|
||||
@@ -470,7 +470,7 @@ namespace VocaluxeLib.Menu
|
||||
float z = CBase.Settings.GetZFar();
|
||||
for (int i = 0; i < _Interactions.Count; i++)
|
||||
{
|
||||
if ((CBase.Settings.GetGameState() == EGameState.EditTheme) || (!_Interactions[i].ThemeEditorOnly && _IsVisible(i) && _IsEnabled(i)))
|
||||
if ((CBase.Settings.GetProgramState() == EProgramState.EditTheme) || (!_Interactions[i].ThemeEditorOnly && _IsVisible(i) && _IsEnabled(i)))
|
||||
{
|
||||
if (_IsMouseOver(x, y, _Interactions[i]))
|
||||
{
|
||||
@@ -553,7 +553,7 @@ namespace VocaluxeLib.Menu
|
||||
private void _NextInteraction()
|
||||
{
|
||||
_UnsetSelected();
|
||||
if (CBase.Settings.GetGameState() != EGameState.EditTheme)
|
||||
if (CBase.Settings.GetProgramState() != EProgramState.EditTheme)
|
||||
{
|
||||
bool found = false;
|
||||
int start = _Selection;
|
||||
@@ -580,7 +580,7 @@ namespace VocaluxeLib.Menu
|
||||
private void _PrevInteraction()
|
||||
{
|
||||
_UnsetSelected();
|
||||
if (CBase.Settings.GetGameState() != EGameState.EditTheme)
|
||||
if (CBase.Settings.GetProgramState() != EProgramState.EditTheme)
|
||||
{
|
||||
bool found = false;
|
||||
int start = _Selection;
|
||||
|
||||
@@ -416,7 +416,7 @@ namespace VocaluxeLib.Menu
|
||||
{
|
||||
if (_PlaylistElements.Count <= 0)
|
||||
LoadPlaylist(0);
|
||||
if (!Visible && CBase.Settings.GetGameState() != EGameState.EditTheme && !forceDraw)
|
||||
if (!Visible && CBase.Settings.GetProgramState() != EProgramState.EditTheme && !forceDraw)
|
||||
return;
|
||||
|
||||
for (int i = 0; i < _PlaylistElements.Count; i++)
|
||||
|
||||
@@ -710,7 +710,7 @@ namespace VocaluxeLib.Menu
|
||||
|
||||
public void Draw()
|
||||
{
|
||||
if (!Visible && CBase.Settings.GetGameState() != EGameState.EditTheme)
|
||||
if (!Visible && CBase.Settings.GetProgramState() != EProgramState.EditTheme)
|
||||
return;
|
||||
|
||||
CTexture texture = CBase.Theme.GetSkinTexture(_Theme.TextureName, _PartyModeID);
|
||||
@@ -733,7 +733,7 @@ namespace VocaluxeLib.Menu
|
||||
else
|
||||
CBase.Drawing.DrawTexture(texture, Rect, Color);
|
||||
|
||||
if (_Selection > 0 || CBase.Settings.GetGameState() == EGameState.EditTheme)
|
||||
if (_Selection > 0 || CBase.Settings.GetProgramState() == EProgramState.EditTheme)
|
||||
{
|
||||
if (_ArrowLeftSelected)
|
||||
CBase.Drawing.DrawTexture(selTextureArrowLeft, RectArrowLeft, SelColorArrow);
|
||||
@@ -741,7 +741,7 @@ namespace VocaluxeLib.Menu
|
||||
CBase.Drawing.DrawTexture(textureArrowLeft, RectArrowLeft, ColorArrow);
|
||||
}
|
||||
|
||||
if (_Selection < _ValueNames.Count - 1 || CBase.Settings.GetGameState() == EGameState.EditTheme)
|
||||
if (_Selection < _ValueNames.Count - 1 || CBase.Settings.GetProgramState() == EProgramState.EditTheme)
|
||||
{
|
||||
if (_ArrowRightSelected)
|
||||
CBase.Drawing.DrawTexture(selTextureArrowRight, RectArrowRight, SelColorArrow);
|
||||
|
||||
@@ -227,14 +227,14 @@ namespace VocaluxeLib.Menu
|
||||
}
|
||||
|
||||
var color = new SColorF(Color.R, Color.G, Color.B, Color.A * Alpha);
|
||||
if (Visible || forceDraw || (CBase.Settings.GetGameState() == EGameState.EditTheme))
|
||||
if (Visible || forceDraw || (CBase.Settings.GetProgramState() == EProgramState.EditTheme))
|
||||
{
|
||||
CBase.Drawing.DrawTexture(texture, rect, color, bounds);
|
||||
if (Reflection)
|
||||
CBase.Drawing.DrawTextureReflection(texture, rect, color, bounds, ReflectionSpace, ReflectionHeight);
|
||||
}
|
||||
|
||||
if (Selected && (CBase.Settings.GetGameState() == EGameState.EditTheme))
|
||||
if (Selected && (CBase.Settings.GetProgramState() == EProgramState.EditTheme))
|
||||
CBase.Drawing.DrawColor(new SColorF(1f, 1f, 1f, 0.5f), rect);
|
||||
}
|
||||
|
||||
|
||||
@@ -457,7 +457,7 @@ namespace VocaluxeLib.Menu
|
||||
|
||||
public void Draw(bool forceDraw = false)
|
||||
{
|
||||
if (!forceDraw && !Visible && CBase.Settings.GetGameState() != EGameState.EditTheme)
|
||||
if (!forceDraw && !Visible && CBase.Settings.GetProgramState() != EProgramState.EditTheme)
|
||||
return;
|
||||
|
||||
// Update Text
|
||||
@@ -474,7 +474,7 @@ namespace VocaluxeLib.Menu
|
||||
if (ReflectionHeight > 0)
|
||||
CBase.Fonts.DrawTextReflection(_Text, Rect.H, Rect.X, Rect.Y, Z, color, ReflectionSpace, ReflectionHeight);
|
||||
|
||||
if (Selected && (CBase.Settings.GetGameState() == EGameState.EditTheme))
|
||||
if (Selected && (CBase.Settings.GetProgramState() == EProgramState.EditTheme))
|
||||
CBase.Drawing.DrawColor(new SColorF(0.5f, 1f, 0.5f, 0.5f), new SRectF(Rect.X, Rect.Y, Rect.W, Rect.H, Z));
|
||||
}
|
||||
|
||||
@@ -493,7 +493,7 @@ namespace VocaluxeLib.Menu
|
||||
// TODO
|
||||
}
|
||||
|
||||
if (Selected && (CBase.Settings.GetGameState() == EGameState.EditTheme))
|
||||
if (Selected && (CBase.Settings.GetProgramState() == EProgramState.EditTheme))
|
||||
CBase.Drawing.DrawColor(new SColorF(0.5f, 1f, 0.5f, 0.5f), new SRectF(X, Y, Rect.W, Rect.H, Z));
|
||||
}
|
||||
|
||||
|
||||
@@ -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