Make CSettings contain only constant values to avoid accidental misuse. Everything changeable is in CConfig

This commit is contained in:
Flamefire committed 2014-03-19 19:54:55 +01:00
1 parent cd79704c00
commit eba5deba2b
30 files changed
+217 -243

No files matched your search

+63 -56
View File
@@ -43,6 +43,15 @@ namespace Vocaluxe.Base
ConformanceLevel = ConformanceLevel.Document ConformanceLevel = ConformanceLevel.Document
}; };
private static bool _Initialized;
// Base file and folder names (formerly from CSettings but they can be changed)
private const string _FolderProfiles = "Profiles"; //Use ProfileFolders for access
private const string _FolderSongs = "Songs"; //Use SongFolders for access
public static string FolderPlaylists = "Playlists";
public static string FileHighscoreDB = "HighscoreDB.sqlite";
private static string _FileConfig = "Config.xml";
// Debug // Debug
public static EDebugLevel DebugLevel = EDebugLevel.TR_CONFIG_OFF; public static EDebugLevel DebugLevel = EDebugLevel.TR_CONFIG_OFF;
public static EOffOn SaveModifiedSongs = EOffOn.TR_CONFIG_OFF; public static EOffOn SaveModifiedSongs = EOffOn.TR_CONFIG_OFF;
@@ -87,7 +96,6 @@ namespace Vocaluxe.Base
// Sound // Sound
public static EPlaybackLib PlayBackLib = EPlaybackLib.Gstreamer; public static EPlaybackLib PlayBackLib = EPlaybackLib.Gstreamer;
public static ERecordLib RecordLib = ERecordLib.PortAudio;
public static EBufferSize AudioBufferSize = EBufferSize.B2048; public static EBufferSize AudioBufferSize = EBufferSize.B2048;
public static int AudioLatency; public static int AudioLatency;
private static int _BackgroundMusicVolume = 30; private static int _BackgroundMusicVolume = 30;
@@ -97,8 +105,28 @@ namespace Vocaluxe.Base
public static int PreviewMusicVolume = 50; public static int PreviewMusicVolume = 50;
public static int GameMusicVolume = 80; public static int GameMusicVolume = 80;
//Folders
public static readonly List<string> SongFolders = new List<string>()
{
Path.Combine(Directory.GetCurrentDirectory(), _FolderSongs)
#if INSTALLER
,Path.Combine(CSettings.DataPath, CSettings.FolderSongs);
#endif
};
/// <summary>
/// Folders with profiles
/// First one is used for new profiles
/// </summary>
public static readonly List<string> ProfileFolders = new List<string>
{
#if INSTALLER
Path.Combine(Environment.CurrentDirectory, CSettings.FolderProfiles),
#endif
Path.Combine(CSettings.DataPath, _FolderProfiles)
};
// Game // Game
public static readonly List<string> SongFolder = new List<string>();
public static ESongMenu SongMenu = ESongMenu.TR_CONFIG_TILE_BOARD; public static ESongMenu SongMenu = ESongMenu.TR_CONFIG_TILE_BOARD;
public static ESongSorting SongSorting = ESongSorting.TR_CONFIG_ARTIST; public static ESongSorting SongSorting = ESongSorting.TR_CONFIG_ARTIST;
public static EOffOn IgnoreArticles = EOffOn.TR_CONFIG_ON; public static EOffOn IgnoreArticles = EOffOn.TR_CONFIG_ON;
@@ -120,8 +148,11 @@ namespace Vocaluxe.Base
public static EOffOn VideosToBackground = EOffOn.TR_CONFIG_OFF; public static EOffOn VideosToBackground = EOffOn.TR_CONFIG_OFF;
// Record // Record
public static SMicConfig[] MicConfig; public static ERecordLib RecordLib = ERecordLib.PortAudio;
public static int MicDelay = 300; //[ms] public static readonly SMicConfig[] MicConfig = new SMicConfig[CSettings.MaxNumPlayer];
public static int MicDelay = 200; //[ms]
// Webcam
public static EWebcamLib WebcamLib = EWebcamLib.OpenCV; public static EWebcamLib WebcamLib = EWebcamLib.OpenCV;
public static SWebcamConfig WebcamConfig; public static SWebcamConfig WebcamConfig;
@@ -135,8 +166,6 @@ namespace Vocaluxe.Base
private static readonly List<string> _Params = new List<string>(); private static readonly List<string> _Params = new List<string>();
private static readonly List<string> _Values = new List<string>(); private static readonly List<string> _Values = new List<string>();
//Variables to save old values for commandline-parameters
private static readonly List<string> _SongFolderOld = new List<string>();
public static int BackgroundMusicVolume public static int BackgroundMusicVolume
{ {
get { return _BackgroundMusicVolume; } get { return _BackgroundMusicVolume; }
@@ -154,27 +183,21 @@ namespace Vocaluxe.Base
public static void Init() public static void Init()
{ {
SongFolder.Add(Path.Combine(Directory.GetCurrentDirectory(), CSettings.FolderSongs)); if (_Initialized)
return;
#if INSTALLER
SongFolder.Add(Path.Combine(CSettings.DataPath, CSettings.FolderSongs));
#endif
foreach (string folder in SongFolder)
CSettings.CreateFolder(folder);
MicConfig = new SMicConfig[CSettings.MaxNumPlayer];
// Init config file // Init config file
if (!File.Exists(Path.Combine(CSettings.DataPath, CSettings.FileConfig))) if (!File.Exists(Path.Combine(CSettings.DataPath, _FileConfig)))
SaveConfig(); SaveConfig();
else
_LoadConfig();
_LoadConfig(); _Initialized = true;
} }
private static void _LoadConfig() private static void _LoadConfig()
{ {
CXMLReader xmlReader = CXMLReader.OpenFile(Path.Combine(CSettings.DataPath, CSettings.FileConfig)); CXMLReader xmlReader = CXMLReader.OpenFile(Path.Combine(CSettings.DataPath, _FileConfig));
if (xmlReader == null) if (xmlReader == null)
return; return;
@@ -231,15 +254,14 @@ namespace Vocaluxe.Base
#region Game #region Game
// Songfolder // Songfolder
string value = string.Empty; string value = String.Empty;
int i = 1; int i = 1;
while (xmlReader.GetValue("//root/Game/SongFolder" + i, out value, value)) while (xmlReader.GetValue("//root/Game/SongFolder" + i, out value, value))
{ {
if (i == 1) if (i == 1)
SongFolder.Clear(); SongFolders.Clear();
SongFolders.Add(value);
SongFolder.Add(value); value = String.Empty;
value = string.Empty;
i++; i++;
} }
@@ -271,7 +293,7 @@ namespace Vocaluxe.Base
//Read players from config //Read players from config
for (i = 1; i <= CSettings.MaxNumPlayer; i++) for (i = 1; i <= CSettings.MaxNumPlayer; i++)
xmlReader.GetValue("//root/Game/Players/Player" + i, out Players[i - 1], string.Empty); xmlReader.GetValue("//root/Game/Players/Player" + i, out Players[i - 1], String.Empty);
#endregion Game #endregion Game
#region Video #region Video
@@ -318,7 +340,7 @@ namespace Vocaluxe.Base
XmlWriter writer = null; XmlWriter writer = null;
try try
{ {
writer = XmlWriter.Create(Path.Combine(CSettings.DataPath, CSettings.FileConfig), XMLSettings); writer = XmlWriter.Create(Path.Combine(CSettings.DataPath, _FileConfig), XMLSettings);
writer.WriteStartDocument(); writer.WriteStartDocument();
writer.WriteStartElement("root"); writer.WriteStartElement("root");
@@ -469,21 +491,9 @@ namespace Vocaluxe.Base
writer.WriteElementString("Language", Language); writer.WriteElementString("Language", Language);
// SongFolder // SongFolder
// Check, if program was started with songfolder-parameters writer.WriteComment("SongFolder: SongFolder1, SongFolder2, SongFolder3, ...");
if (_SongFolderOld.Count > 0) for (int i = 0; i < SongFolders.Count; i++)
{ writer.WriteElementString("SongFolder" + (i + 1), SongFolders[i]);
//Write "old" song-folders to config.
writer.WriteComment("SongFolder: SongFolder1, SongFolder2, SongFolder3, ...");
for (int i = 0; i < _SongFolderOld.Count; i++)
writer.WriteElementString("SongFolder" + (i + 1), _SongFolderOld[i]);
}
else
{
//Write "normal" song-folders to config.
writer.WriteComment("SongFolder: SongFolder1, SongFolder2, SongFolder3, ...");
for (int i = 0; i < SongFolder.Count; i++)
writer.WriteElementString("SongFolder" + (i + 1), SongFolder[i]);
}
writer.WriteComment("SongMenu: " + CHelper.ListStrings(Enum.GetNames(typeof(ESongMenu)))); writer.WriteComment("SongMenu: " + CHelper.ListStrings(Enum.GetNames(typeof(ESongMenu))));
writer.WriteElementString("SongMenu", Enum.GetName(typeof(ESongMenu), SongMenu)); writer.WriteElementString("SongMenu", Enum.GetName(typeof(ESongMenu), SongMenu));
@@ -730,7 +740,7 @@ namespace Vocaluxe.Base
Regex spliterParam = new Regex(@"-{1,2}|\/", RegexOptions.IgnoreCase); Regex spliterParam = new Regex(@"-{1,2}|\/", RegexOptions.IgnoreCase);
//Complete argument string //Complete argument string
string arguments = args.Aggregate(string.Empty, (current, arg) => current + (arg + " ")); string arguments = args.Aggregate(String.Empty, (current, arg) => current + arg + " ");
args = spliterParam.Split(arguments); args = spliterParam.Split(arguments);
@@ -791,24 +801,22 @@ namespace Vocaluxe.Base
case "configfile": case "configfile":
//Check if value is valid //Check if value is valid
if (_CheckFile(value)) if (_CheckFile(value))
CSettings.FileConfig = value; _FileConfig = value;
break; break;
case "scorefile": case "scorefile":
//Check if value is valid //Check if value is valid
if (_CheckFile(value)) if (_CheckFile(value))
CSettings.FileHighscoreDB = value; FileHighscoreDB = value;
break; break;
case "playlistfolder": case "playlistfolder":
CSettings.CreateFolder(value); FolderPlaylists = value;
CSettings.FolderPlaylists = value;
break; break;
case "profilefolder": case "profilefolder":
CSettings.CreateFolder(value); ProfileFolders.Clear();
CSettings.FoldersProfiles.Clear(); ProfileFolders.Add(value);
CSettings.FoldersProfiles.Add(value);
break; break;
} }
} }
@@ -819,6 +827,7 @@ namespace Vocaluxe.Base
/// </summary> /// </summary>
public static void UseCommandLineParamsAfter() public static void UseCommandLineParamsAfter()
{ {
bool songFoldersOverwritten = false;
//Check each parameter //Check each parameter
for (int i = 0; i < _Params.Count; i++) for (int i = 0; i < _Params.Count; i++)
{ {
@@ -833,15 +842,13 @@ namespace Vocaluxe.Base
{ {
case "songfolder": case "songfolder":
case "songpath": case "songpath":
//Check if SongFolders from config.xml are saved if (!songFoldersOverwritten)
if (_SongFolderOld.Count == 0)
{ {
_SongFolderOld.Clear(); SongFolders.Clear();
_SongFolderOld.AddRange(SongFolder); songFoldersOverwritten = true;
SongFolder.Clear();
} }
//Add parameter-value to SongFolder if (!SongFolders.Contains(value))
SongFolder.Add(value); SongFolders.Add(value);
break; break;
} }
} }
+16 -19
View File
@@ -24,6 +24,7 @@ namespace Vocaluxe.Base
{ {
class CCursor class CCursor
{ {
private int _MouseMoveDiffMin = CSettings.MouseMoveDiffMinActive;
private CFading _Fading; private CFading _Fading;
private CTexture _Cursor; private CTexture _Cursor;
@@ -49,12 +50,8 @@ namespace Vocaluxe.Base
public void Draw() public void Draw()
{ {
if (_Movetimer.IsRunning && _Movetimer.ElapsedMilliseconds > CSettings.MouseMoveOffTime) if (_Movetimer.ElapsedMilliseconds > CSettings.MouseMoveOffTime)
{ Deactivate();
_Movetimer.Stop();
_Fade(0f, 0.5f);
}
if (_Fading != null) if (_Fading != null)
{ {
@@ -64,21 +61,15 @@ namespace Vocaluxe.Base
_Fading = null; _Fading = null;
} }
if (Visible && (CSettings.GameState == EGameState.EditTheme || ShowCursor)) if (Visible && (CSettings.ProgramState == EProgramState.EditTheme || ShowCursor))
CDraw.DrawTexture(_Cursor); CDraw.DrawTexture(_Cursor);
} }
public void UpdatePosition(int x, int y) public void UpdatePosition(int x, int y)
{ {
if (Math.Abs(_Cursor.Rect.X - x) > CSettings.MouseMoveDiffMin || if (Math.Abs(_Cursor.Rect.X - x) > _MouseMoveDiffMin ||
Math.Abs(_Cursor.Rect.Y - y) > CSettings.MouseMoveDiffMin) Math.Abs(_Cursor.Rect.Y - y) > _MouseMoveDiffMin)
{ Activate();
if (!IsActive)
_Fade(1f, 0.2f);
_Movetimer.Restart();
CSettings.MouseActive();
}
_Cursor.Rect.X = x; _Cursor.Rect.X = x;
_Cursor.Rect.Y = y; _Cursor.Rect.Y = y;
@@ -109,14 +100,20 @@ namespace Vocaluxe.Base
UpdatePosition(x, y); UpdatePosition(x, y);
} }
public void FadeOut() public void Deactivate()
{ {
_Movetimer.Stop(); if (!IsActive)
return;
_MouseMoveDiffMin = CSettings.MouseMoveDiffMinInactive;
_Movetimer.Reset();
_Fade(0f, 0.5f); _Fade(0f, 0.5f);
} }
public void FadeIn() public void Activate()
{ {
if (IsActive)
return;
_MouseMoveDiffMin = CSettings.MouseMoveDiffMinActive;
_Movetimer.Restart(); _Movetimer.Restart();
_Fade(1f, 0.2f); _Fade(1f, 0.2f);
} }
+1 -1
View File
@@ -60,7 +60,7 @@ namespace Vocaluxe.Base
public static bool Init() public static bool Init()
{ {
_HighscoreFilePath = Path.Combine(Environment.CurrentDirectory, CSettings.FileHighscoreDB); _HighscoreFilePath = Path.Combine(Environment.CurrentDirectory, CConfig.FileHighscoreDB);
_CoverFilePath = Path.Combine(Environment.CurrentDirectory, CSettings.FileCoverDB); _CoverFilePath = Path.Combine(Environment.CurrentDirectory, CSettings.FileCoverDB);
_CreditsRessourcesFilePath = Path.Combine(Environment.CurrentDirectory, CSettings.FileCreditsRessourcesDB); _CreditsRessourcesFilePath = Path.Combine(Environment.CurrentDirectory, CSettings.FileCreditsRessourcesDB);
+8 -12
View File
@@ -178,7 +178,7 @@ namespace Vocaluxe.Base
if (CConfig.CoverLoading == ECoverLoading.TR_CONFIG_COVERLOADING_DYNAMIC && _CurrentScreen != EScreens.ScreenSing) if (CConfig.CoverLoading == ECoverLoading.TR_CONFIG_COVERLOADING_DYNAMIC && _CurrentScreen != EScreens.ScreenSing)
CSongs.LoadCover(); CSongs.LoadCover();
if (CSettings.GameState != EGameState.EditTheme) if (CSettings.ProgramState != EProgramState.EditTheme)
{ {
run &= _HandleInputs(keys, mouse); run &= _HandleInputs(keys, mouse);
run &= _Update(); run &= _Update();
@@ -344,8 +344,7 @@ namespace Vocaluxe.Base
if (keyEvent.Key == Keys.Left || keyEvent.Key == Keys.Right || keyEvent.Key == Keys.Up || keyEvent.Key == Keys.Down || keyEvent.Key == Keys.NumPad0 || if (keyEvent.Key == Keys.Left || keyEvent.Key == Keys.Right || keyEvent.Key == Keys.Up || keyEvent.Key == Keys.Down || keyEvent.Key == Keys.NumPad0 ||
keyEvent.Key == Keys.D0) keyEvent.Key == Keys.D0)
{ {
CSettings.MouseInactive(); _Cursor.Deactivate();
_Cursor.FadeOut();
if (keyEvent.ModAlt && keyEvent.ModCtrl && keyEvent.ModShift) if (keyEvent.ModAlt && keyEvent.ModCtrl && keyEvent.ModShift)
{ {
@@ -454,9 +453,9 @@ namespace Vocaluxe.Base
} }
if (keyEvent.ModShift && (keyEvent.Key == Keys.F1)) if (keyEvent.ModShift && (keyEvent.Key == Keys.F1))
CSettings.GameState = EGameState.EditTheme; CSettings.ProgramState = EProgramState.EditTheme;
else if (keyEvent.ModAlt && (keyEvent.Key == Keys.Enter)) else if (keyEvent.ModAlt && (keyEvent.Key == Keys.Enter))
CSettings.IsFullScreen = !CSettings.IsFullScreen; CConfig.FullScreen = (CConfig.FullScreen == EOffOn.TR_CONFIG_ON) ? EOffOn.TR_CONFIG_OFF : EOffOn.TR_CONFIG_ON;
else if (keyEvent.ModAlt && (keyEvent.Key == Keys.P)) else if (keyEvent.ModAlt && (keyEvent.Key == Keys.P))
CDraw.MakeScreenShot(); CDraw.MakeScreenShot();
else else
@@ -484,10 +483,7 @@ namespace Vocaluxe.Base
mouseEvent = inputMouseEvent; mouseEvent = inputMouseEvent;
if (mouseEvent.Wheel != 0) if (mouseEvent.Wheel != 0)
{ _Cursor.Activate();
CSettings.MouseActive();
_Cursor.FadeIn();
}
_UpdateMousePosition(mouseEvent.X, mouseEvent.Y); _UpdateMousePosition(mouseEvent.X, mouseEvent.Y);
@@ -550,11 +546,11 @@ namespace Vocaluxe.Base
{ {
if (keyEvent.ModShift && (keyEvent.Key == Keys.F1)) if (keyEvent.ModShift && (keyEvent.Key == Keys.F1))
{ {
CSettings.GameState = EGameState.Normal; CSettings.ProgramState = EProgramState.Normal;
_Screens[(int)_CurrentScreen].NextInteraction(); _Screens[(int)_CurrentScreen].NextInteraction();
} }
else if (keyEvent.ModAlt && (keyEvent.Key == Keys.Enter)) else if (keyEvent.ModAlt && (keyEvent.Key == Keys.Enter))
CSettings.IsFullScreen = !CSettings.IsFullScreen; CConfig.FullScreen = (CConfig.FullScreen == EOffOn.TR_CONFIG_ON) ? EOffOn.TR_CONFIG_OFF : EOffOn.TR_CONFIG_ON;
else if (keyEvent.ModAlt && (keyEvent.Key == Keys.P)) else if (keyEvent.ModAlt && (keyEvent.Key == Keys.P))
CDraw.MakeScreenShot(); CDraw.MakeScreenShot();
else else
@@ -588,7 +584,7 @@ namespace Vocaluxe.Base
} }
if (_VolumePopupTimer.IsRunning) if (_VolumePopupTimer.IsRunning)
_Cursor.FadeIn(); _Cursor.Activate();
if (_CurrentPopupScreen != EPopupScreens.NoPopup) if (_CurrentPopupScreen != EPopupScreens.NoPopup)
_PopupScreens[(int)_CurrentPopupScreen].UpdateGame(); _PopupScreens[(int)_CurrentPopupScreen].UpdateGame();
+9 -4
View File
@@ -118,7 +118,7 @@ namespace Vocaluxe.Base
public IEnumerable<string> GetSongFolders() public IEnumerable<string> GetSongFolders()
{ {
return CConfig.SongFolder; return CConfig.SongFolders;
} }
public ESongSorting GetSongSorting() public ESongSorting GetSongSorting()
@@ -179,9 +179,9 @@ namespace Vocaluxe.Base
return CSettings.ZNear; return CSettings.ZNear;
} }
public EGameState GetGameState() public EProgramState GetProgramState()
{ {
return CSettings.GameState; return CSettings.ProgramState;
} }
public int GetToneMin() public int GetToneMin()
@@ -226,7 +226,7 @@ namespace Vocaluxe.Base
public string GetFolderProfiles() public string GetFolderProfiles()
{ {
return CSettings.FolderProfiles; return CConfig.ProfileFolders[0];
} }
public string GetDataPath() public string GetDataPath()
@@ -601,6 +601,11 @@ namespace Vocaluxe.Base
return CProfiles.GetAvatarTextureFromProfile(profileID); return CProfiles.GetAvatarTextureFromProfile(profileID);
} }
public CAvatar GetAvatarByFilename(string fileName)
{
return CProfiles.GetAvatarByFilename(fileName);
}
public bool IsProfileIDValid(int profileID) public bool IsProfileIDValid(int profileID)
{ {
return CProfiles.IsProfileIDValid(profileID); return CProfiles.IsProfileIDValid(profileID);
+2 -2
View File
@@ -58,7 +58,7 @@ namespace Vocaluxe.Base
private static void _ConvertUSDXPlaylists() private static void _ConvertUSDXPlaylists()
{ {
var files = new List<string>(); var files = new List<string>();
files.AddRange(CHelper.ListFiles(Path.Combine(CSettings.DataPath, CSettings.FolderPlaylists), "*.upl", true, true)); files.AddRange(CHelper.ListFiles(Path.Combine(CSettings.DataPath, CConfig.FolderPlaylists), "*.upl", true, true));
foreach (string file in files) foreach (string file in files)
{ {
@@ -73,7 +73,7 @@ namespace Vocaluxe.Base
_Playlists = new List<CPlaylistFile>(); _Playlists = new List<CPlaylistFile>();
var files = new List<string>(); var files = new List<string>();
files.AddRange(CHelper.ListFiles(Path.Combine(CSettings.DataPath, CSettings.FolderPlaylists), "*.xml", true, true)); files.AddRange(CHelper.ListFiles(Path.Combine(CSettings.DataPath, CConfig.FolderPlaylists), "*.xml", true, true));
foreach (string file in files) foreach (string file in files)
{ {
+25 -20
View File
@@ -17,6 +17,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
using System.IO; using System.IO;
using VocaluxeLib; using VocaluxeLib;
using VocaluxeLib.Draw; using VocaluxeLib.Draw;
@@ -111,13 +112,21 @@ namespace Vocaluxe.Base
break; break;
case EAction.AddProfile: case EAction.AddProfile:
if (change.Profile == null) CProfile newProf = change.Profile;
if (newProf == null)
break; break;
change.Profile.ID = _ProfileIDs.Dequeue(); newProf.ID = _ProfileIDs.Dequeue();
change.Profile.Avatar = _GetAvatar(change.Profile.AvatarFileName); if (newProf.Avatar == null)
change.Profile.SaveProfile(); newProf.Avatar = _Avatars.Values.First();
_Profiles.Add(change.Profile.ID, change.Profile); else if (newProf.Avatar.ID < 0)
{
newProf.Avatar.ID = _AvatarIDs.Dequeue();
_Avatars.Add(newProf.Avatar.ID, newProf.Avatar);
_AvatarsChanged = true;
}
newProf.SaveProfile();
_Profiles.Add(newProf.ID, newProf);
_ProfilesChanged = true; _ProfilesChanged = true;
break; break;
@@ -318,7 +327,7 @@ namespace Vocaluxe.Base
{ {
var profile = new CProfile var profile = new CProfile
{ {
FileName = fileName != "" ? Path.Combine(CSettings.DataPath, CSettings.FolderProfiles, fileName) : String.Empty FileName = fileName != "" ? Path.Combine(CConfig.ProfileFolders[0], fileName) : String.Empty
}; };
if (File.Exists(profile.FileName)) if (File.Exists(profile.FileName))
@@ -332,8 +341,8 @@ namespace Vocaluxe.Base
public static int NewAvatar(string fileName) public static int NewAvatar(string fileName)
{ {
var avatar = new CAvatar(-1); CAvatar avatar = CAvatar.GetAvatar(fileName);
if (!avatar.LoadFromFile(fileName)) if (avatar == null)
return -1; return -1;
avatar.ID = _AvatarIDs.Dequeue(); avatar.ID = _AvatarIDs.Dequeue();
@@ -474,7 +483,7 @@ namespace Vocaluxe.Base
public static int GetAvatarID(int profileID) public static int GetAvatarID(int profileID)
{ {
if (!IsProfileIDValid(profileID)) if (!IsProfileIDValid(profileID) || _Profiles[profileID].Avatar == null)
return -1; return -1;
return _Profiles[profileID].Avatar.ID; return _Profiles[profileID].Avatar.ID;
@@ -505,7 +514,7 @@ namespace Vocaluxe.Base
public static CTexture GetAvatarTextureFromProfile(int profileID) public static CTexture GetAvatarTextureFromProfile(int profileID)
{ {
if (!IsProfileIDValid(profileID)) if (!IsProfileIDValid(profileID) || _Profiles[profileID].Avatar == null)
return null; return null;
return _Profiles[profileID].Avatar.Texture; return _Profiles[profileID].Avatar.Texture;
@@ -525,10 +534,7 @@ namespace Vocaluxe.Base
foreach (int id in ids) foreach (int id in ids)
{ {
if (_Profiles[id].LoadProfile()) if (_Profiles[id].LoadProfile())
{
_Profiles[id].Avatar = _GetAvatar(_Profiles[id].AvatarFileName);
knownFiles.Add(Path.GetFileName(_Profiles[id].FileName)); knownFiles.Add(Path.GetFileName(_Profiles[id].FileName));
}
else else
_Profiles.Remove(id); _Profiles.Remove(id);
} }
@@ -536,7 +542,7 @@ namespace Vocaluxe.Base
var files = new List<string>(); var files = new List<string>();
foreach (string path in CSettings.FoldersProfiles) foreach (string path in CConfig.ProfileFolders)
files.AddRange(CHelper.ListFiles(path, "*.xml", true, true)); files.AddRange(CHelper.ListFiles(path, "*.xml", true, true));
foreach (string file in files) foreach (string file in files)
@@ -552,7 +558,6 @@ namespace Vocaluxe.Base
if (profile.LoadProfile()) if (profile.LoadProfile())
{ {
profile.Avatar = _GetAvatar(profile.AvatarFileName);
profile.ID = _ProfileIDs.Dequeue(); profile.ID = _ProfileIDs.Dequeue();
_Profiles.Add(profile.ID, profile); _Profiles.Add(profile.ID, profile);
} }
@@ -577,7 +582,7 @@ namespace Vocaluxe.Base
} }
var files = new List<string>(); var files = new List<string>();
foreach (string path in CSettings.FoldersProfiles) foreach (string path in CConfig.ProfileFolders)
files.AddRange(CHelper.ListImageFiles(path, true, true)); files.AddRange(CHelper.ListImageFiles(path, true, true));
foreach (string file in files) foreach (string file in files)
@@ -585,8 +590,8 @@ namespace Vocaluxe.Base
if (knownFiles.Contains(Path.GetFileName(file))) if (knownFiles.Contains(Path.GetFileName(file)))
continue; continue;
var avatar = new CAvatar(-1); CAvatar avatar = CAvatar.GetAvatar(file);
if (avatar.LoadFromFile(file)) if (avatar != null)
{ {
avatar.ID = _AvatarIDs.Dequeue(); avatar.ID = _AvatarIDs.Dequeue();
_Avatars.Add(avatar.ID, avatar); _Avatars.Add(avatar.ID, avatar);
@@ -650,7 +655,7 @@ namespace Vocaluxe.Base
return String.CompareOrdinal(a.PlayerName, b.PlayerName); return String.CompareOrdinal(a.PlayerName, b.PlayerName);
} }
private static CAvatar _GetAvatar(string fileName) public static CAvatar GetAvatarByFilename(string fileName)
{ {
string name = Path.GetFileName(fileName); string name = Path.GetFileName(fileName);
@@ -659,7 +664,7 @@ namespace Vocaluxe.Base
if (Path.GetFileName(_Avatars[id].FileName) == name) if (Path.GetFileName(_Avatars[id].FileName) == name)
return _Avatars[id]; return _Avatars[id];
} }
return new CAvatar(-1); return null;
} }
#endregion private methods #endregion private methods
} }
+21 -38
View File
@@ -33,6 +33,10 @@ namespace Vocaluxe.Base
// ReSharper restore UnusedMember.Global // ReSharper restore UnusedMember.Global
} }
/// <summary>
/// This class contains settings for the program
/// These are not editable, everything that can be changed by the user is in CConfig
/// </summary>
static class CSettings static class CSettings
{ {
#if ARCH_X86 #if ARCH_X86
@@ -43,7 +47,9 @@ namespace Vocaluxe.Base
private const String _Arch = "x64"; private const String _Arch = "x64";
#endif #endif
public static EGameState GameState = EGameState.Start; //TODO: This should not be here as it can change
//State of the program
public static EProgramState ProgramState = EProgramState.Start;
//Adjusting of programName and version now in the assembly config. //Adjusting of programName and version now in the assembly config.
//I'd use the major and minor for Main releases, build number for every public release and revision for every bugfix version without any features //I'd use the major and minor for Main releases, build number for every public release and revision for every bugfix version without any features
@@ -63,23 +69,20 @@ namespace Vocaluxe.Base
public const int ZNear = -100; public const int ZNear = -100;
public const int ZFar = 100; public const int ZFar = 100;
public static bool IsFullScreen;
public const int VertexBufferElements = 10000; public const int VertexBufferElements = 10000;
#if INSTALLER #if INSTALLER
public static string DataPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "Vocaluxe"); public static readonly string DataPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "Vocaluxe");
#else #else
public static string DataPath = Environment.CurrentDirectory; public static readonly string DataPath = Environment.CurrentDirectory;
#endif #endif
public const string Icon = "Vocaluxe.ico"; public const string Icon = "Vocaluxe.ico";
public const string Logo = "Logo.png"; public const string Logo = "Logo.png";
public const string FallbackLanguage = "English"; public const string FallbackLanguage = "English";
public static string FileConfig = "Config.xml";
public const string FileFonts = "Fonts.xml"; public const string FileFonts = "Fonts.xml";
public const string FileOldHighscoreDB = "Ultrastar.db"; public const string FileOldHighscoreDB = "Ultrastar.db";
public static string FileHighscoreDB = "HighscoreDB.sqlite";
public const string FileCoverDB = "CoverDB.sqlite"; public const string FileCoverDB = "CoverDB.sqlite";
public const string FileCreditsRessourcesDB = "CreditsRessourcesDB.sqlite"; public const string FileCreditsRessourcesDB = "CreditsRessourcesDB.sqlite";
public const string FilePerformanceLog = "Performance.log"; public const string FilePerformanceLog = "Performance.log";
@@ -96,21 +99,11 @@ 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 const string FolderProfiles = "Profiles";
public static List<string> FoldersProfiles = new List<string>
{
#if INSTALLER
Path.Combine(Environment.CurrentDirectory, FolderProfiles),
#endif
Path.Combine(DataPath, FolderProfiles)
};
public const string FolderPhotos = "Photos"; public const string FolderPhotos = "Photos";
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";
public const string FolderScreenshots = "Screenshots"; public const string FolderScreenshots = "Screenshots";
public const string FolderBackgroundMusic = "BackgroundMusic"; public const string FolderBackgroundMusic = "BackgroundMusic";
public static string FolderPlaylists = "Playlists";
public const string FolderPartyModes = "PartyModes"; public const string FolderPartyModes = "PartyModes";
public const string FolderPartyModeCode = "Code"; public const string FolderPartyModeCode = "Code";
@@ -128,8 +121,10 @@ namespace Vocaluxe.Base
public const int ToneMax = 89; public const int ToneMax = 89;
public const int NumNoteLines = 11; public const int NumNoteLines = 11;
public static int MouseMoveDiffMin = 2;
public const int MouseMoveOffTime = 3000; //in ms public const int MouseMoveOffTime = 3000; //in ms
public const int MouseMoveDiffMinActive = 3;
public const int MouseMoveDiffMinInactive = 15;
public const int MaxNumPlayer = 6; public const int MaxNumPlayer = 6;
public const int MaxScore = 10000; public const int MaxScore = 10000;
@@ -212,37 +207,25 @@ namespace Vocaluxe.Base
return RenderW / (float)RenderH; return RenderW / (float)RenderH;
} }
public static void MouseInactive()
{
MouseMoveDiffMin = 15;
}
public static void MouseActive()
{
MouseMoveDiffMin = 3;
}
public static void CreateFolders() public static void CreateFolders()
{ {
var folders = new List<string> var folders = new List<string>
{ {
FolderCover, Path.Combine(Environment.CurrentDirectory, FolderCover),
FolderFonts, Path.Combine(Environment.CurrentDirectory, FolderFonts),
Path.Combine(DataPath, FolderScreenshots), Path.Combine(DataPath, FolderScreenshots),
FolderBackgroundMusic, Path.Combine(Environment.CurrentDirectory, FolderBackgroundMusic),
FolderSounds, Path.Combine(Environment.CurrentDirectory, FolderSounds),
Path.Combine(DataPath, FolderPlaylists) Path.Combine(DataPath, CConfig.FolderPlaylists)
}; };
folders.AddRange(FoldersProfiles); folders.AddRange(CConfig.ProfileFolders);
folders.AddRange(CConfig.SongFolders);
foreach (string folder in folders) foreach (string folder in folders)
{ _CreateFolder(folder);
string path = Path.Combine(Environment.CurrentDirectory, folder);
CreateFolder(path);
}
} }
public static void CreateFolder(string path) private static void _CreateFolder(string path)
{ {
if (!Directory.Exists(path)) if (!Directory.Exists(path))
Directory.CreateDirectory(path); Directory.CreateDirectory(path);
+1 -1
View File
@@ -338,7 +338,7 @@ namespace Vocaluxe.Base
CLog.StartBenchmark("List Songs"); CLog.StartBenchmark("List Songs");
var files = new List<string>(); var files = new List<string>();
foreach (string p in CConfig.SongFolder) foreach (string p in CConfig.SongFolders)
{ {
string path = p; string path = p;
files.AddRange(CHelper.ListFiles(path, "*.txt", true, true)); files.AddRange(CHelper.ListFiles(path, "*.txt", true, true));
+3 -4
View File
@@ -207,7 +207,6 @@ namespace Vocaluxe.Base.Server
ID = existingProfile.ID, ID = existingProfile.ID,
FileName = existingProfile.FileName, FileName = existingProfile.FileName,
Active = existingProfile.Active, Active = existingProfile.Active,
AvatarFileName = existingProfile.AvatarFileName,
Avatar = existingProfile.Avatar, Avatar = existingProfile.Avatar,
Difficulty = existingProfile.Difficulty, Difficulty = existingProfile.Difficulty,
UserRole = existingProfile.UserRole, UserRole = existingProfile.UserRole,
@@ -317,10 +316,10 @@ namespace Vocaluxe.Base.Server
{ {
try try
{ {
string filename = _SaveImage(avatarData, "snapshot", CSettings.FolderProfiles); string filename = _SaveImage(avatarData, "snapshot", CConfig.ProfileFolders[0]);
var avatar = new CAvatar(-1); var avatar = CAvatar.GetAvatar(filename);
if (avatar.LoadFromFile(filename)) if (avatar!=null)
{ {
CProfiles.AddAvatar(avatar); CProfiles.AddAvatar(avatar);
return avatar; return avatar;
+2 -10
View File
@@ -311,7 +311,6 @@ namespace Vocaluxe.Lib.Draw
FormBorderStyle = FormBorderStyle.None; FormBorderStyle = FormBorderStyle.None;
CenterToScreen(); CenterToScreen();
_Fullscreen = true; _Fullscreen = true;
CConfig.FullScreen = EOffOn.TR_CONFIG_ON;
if (WindowState == FormWindowState.Maximized) if (WindowState == FormWindowState.Maximized)
{ {
@@ -321,8 +320,7 @@ namespace Vocaluxe.Lib.Draw
} }
else else
_DoResize(); _DoResize();
;
CConfig.SaveConfig();
} }
/// <summary> /// <summary>
@@ -334,9 +332,6 @@ namespace Vocaluxe.Lib.Draw
FormBorderStyle = FormBorderStyle.Sizable; FormBorderStyle = FormBorderStyle.Sizable;
CenterToScreen(); CenterToScreen();
_Fullscreen = false; _Fullscreen = false;
CConfig.FullScreen = EOffOn.TR_CONFIG_OFF;
CConfig.SaveConfig();
} }
#endregion resize #endregion resize
@@ -486,10 +481,7 @@ namespace Vocaluxe.Lib.Draw
Show(); Show();
if (CConfig.FullScreen == EOffOn.TR_CONFIG_ON) if (CConfig.FullScreen == EOffOn.TR_CONFIG_ON)
{
CSettings.IsFullScreen = true;
_EnterFullScreen(); _EnterFullScreen();
}
//Resize window if aspect ratio is incorrect //Resize window if aspect ratio is incorrect
if (Math.Abs(_W / (float)_H - CSettings.GetRenderAspect()) > 0.01) if (Math.Abs(_W / (float)_H - CSettings.GetRenderAspect()) > 0.01)
@@ -530,7 +522,7 @@ namespace Vocaluxe.Lib.Draw
} }
} }
//Apply fullscreen mode //Apply fullscreen mode
if (CSettings.IsFullScreen != _Fullscreen) if ((CConfig.FullScreen == EOffOn.TR_CONFIG_ON) != _Fullscreen)
{ {
if (!_Fullscreen) if (!_Fullscreen)
_EnterFullScreen(); _EnterFullScreen();
+1 -10
View File
@@ -127,9 +127,6 @@ namespace Vocaluxe.Lib.Draw
targetForm.Bounds = Screen.PrimaryScreen.Bounds; targetForm.Bounds = Screen.PrimaryScreen.Bounds;
targetForm.TopMost = true; targetForm.TopMost = true;
_Fullscreen = true; _Fullscreen = true;
CConfig.FullScreen = EOffOn.TR_CONFIG_ON;
CConfig.SaveConfig();
} }
} }
@@ -146,9 +143,6 @@ namespace Vocaluxe.Lib.Draw
targetForm.TopMost = _TopMost; targetForm.TopMost = _TopMost;
targetForm.Bounds = _Bounds; targetForm.Bounds = _Bounds;
_Fullscreen = false; _Fullscreen = false;
CConfig.FullScreen = EOffOn.TR_CONFIG_OFF;
CConfig.SaveConfig();
} }
#endregion FullScreenStuff #endregion FullScreenStuff
@@ -232,10 +226,7 @@ namespace Vocaluxe.Lib.Draw
Show(); Show();
if (CConfig.FullScreen == EOffOn.TR_CONFIG_ON) if (CConfig.FullScreen == EOffOn.TR_CONFIG_ON)
{
CSettings.IsFullScreen = true;
_Maximize(this); _Maximize(this);
}
while (_Run) while (_Run)
{ {
@@ -247,7 +238,7 @@ namespace Vocaluxe.Lib.Draw
_Run = CGraphics.UpdateGameLogic(_Keys, _Mouse); _Run = CGraphics.UpdateGameLogic(_Keys, _Mouse);
_FlipBuffer(); _FlipBuffer();
if ((CSettings.IsFullScreen && !_Fullscreen) || (!CSettings.IsFullScreen && _Fullscreen)) if ((CConfig.FullScreen == EOffOn.TR_CONFIG_ON) != _Fullscreen)
_ToggleFullScreen(); _ToggleFullScreen();
if (CTime.IsRunning()) if (CTime.IsRunning())
+1 -10
View File
@@ -235,7 +235,6 @@ namespace Vocaluxe.Lib.Draw
private void _EnterFullScreen() private void _EnterFullScreen()
{ {
_Fullscreen = true; _Fullscreen = true;
CConfig.FullScreen = EOffOn.TR_CONFIG_ON;
_Restore.Location = Location; _Restore.Location = Location;
_Restore.Width = Width; _Restore.Width = Width;
@@ -261,19 +260,14 @@ namespace Vocaluxe.Lib.Draw
} }
else else
_DoResize(); _DoResize();
CConfig.SaveConfig();
} }
private void _LeaveFullScreen() private void _LeaveFullScreen()
{ {
_Fullscreen = false; _Fullscreen = false;
CConfig.FullScreen = EOffOn.TR_CONFIG_OFF;
FormBorderStyle = FormBorderStyle.Sizable; FormBorderStyle = FormBorderStyle.Sizable;
DesktopBounds = new Rectangle(_Restore.Location, new Size(_Restore.Width, _Restore.Height)); DesktopBounds = new Rectangle(_Restore.Location, new Size(_Restore.Width, _Restore.Height));
CConfig.SaveConfig();
} }
#endregion Helpers #endregion Helpers
@@ -433,10 +427,7 @@ namespace Vocaluxe.Lib.Draw
Show(); Show();
if (CConfig.FullScreen == EOffOn.TR_CONFIG_ON) if (CConfig.FullScreen == EOffOn.TR_CONFIG_ON)
{
CSettings.IsFullScreen = true;
_EnterFullScreen(); _EnterFullScreen();
}
while (_Run) while (_Run)
{ {
@@ -448,7 +439,7 @@ namespace Vocaluxe.Lib.Draw
_Control.SwapBuffers(); _Control.SwapBuffers();
if (CSettings.IsFullScreen != _Fullscreen) if ((CConfig.FullScreen == EOffOn.TR_CONFIG_ON) != _Fullscreen)
_ToggleFullScreen(); _ToggleFullScreen();
_CheckQueue(); _CheckQueue();
+3 -3
View File
@@ -63,14 +63,14 @@ namespace Vocaluxe.Lib.Playlist
filename = "1"; filename = "1";
int i = 0; int i = 0;
while (File.Exists(Path.Combine(CSettings.DataPath, CSettings.FolderPlaylists, filename + ".xml"))) while (File.Exists(Path.Combine(CSettings.DataPath, CConfig.FolderPlaylists, filename + ".xml")))
{ {
i++; i++;
if (!File.Exists(Path.Combine(CSettings.DataPath, CSettings.FolderPlaylists, filename + i + ".xml"))) if (!File.Exists(Path.Combine(CSettings.DataPath, CConfig.FolderPlaylists, filename + i + ".xml")))
filename += i; filename += i;
} }
PlaylistFile = Path.Combine(CSettings.DataPath, CSettings.FolderPlaylists, filename + ".xml"); PlaylistFile = Path.Combine(CSettings.DataPath, CConfig.FolderPlaylists, filename + ".xml");
} }
XmlWriter writer; XmlWriter writer;
+7 -1
View File
@@ -25,6 +25,7 @@ namespace Vocaluxe.Lib.Sound.Record
public CBuffer() public CBuffer()
{ {
MinVolume = 0.02f;
ToneWeigth = new float[NumHalfTones]; ToneWeigth = new float[NumHalfTones];
for (int i = 0; i < ToneWeigth.Length; i++) for (int i = 0; i < ToneWeigth.Length; i++)
ToneWeigth[i] = 0.99f; ToneWeigth[i] = 0.99f;
@@ -54,6 +55,11 @@ namespace Vocaluxe.Lib.Sound.Record
public float[] ToneWeigth { get; private set; } public float[] ToneWeigth { get; private set; }
/// <summary>
/// Minimum volume for a tone to be valid
/// </summary>
public float MinVolume { get; set; }
public void Reset() public void Reset()
{ {
lock (_Stream) lock (_Stream)
@@ -109,7 +115,7 @@ namespace Vocaluxe.Lib.Sound.Record
// find maximum volume // find maximum volume
_FindMaxVolume(); _FindMaxVolume();
if (MaxVolume >= 0.02) if (MaxVolume >= MinVolume)
_AnalyzeByAutocorrelation(); _AnalyzeByAutocorrelation();
else else
ToneValid = false; ToneValid = false;
+3 -1
View File
@@ -87,7 +87,6 @@ namespace Vocaluxe
CProgrammHelper.Init(); CProgrammHelper.Init();
CMain.Init(); CMain.Init();
CSettings.CreateFolders();
Application.DoEvents(); Application.DoEvents();
// Init Language // Init Language
@@ -105,6 +104,9 @@ namespace Vocaluxe
CConfig.UseCommandLineParamsAfter(); CConfig.UseCommandLineParamsAfter();
CLog.StopBenchmark("Init Config"); CLog.StopBenchmark("Init Config");
// Create folders
CSettings.CreateFolders();
Application.DoEvents(); Application.DoEvents();
_SplashScreen = new CSplashScreen(); _SplashScreen = new CSplashScreen();
Application.DoEvents(); Application.DoEvents();
+3 -3
View File
@@ -137,10 +137,10 @@ namespace Vocaluxe.Screens
bool next = CConfig.CoverLoading != ECoverLoading.TR_CONFIG_COVERLOADING_ATSTART || CSongs.CoverLoaded; bool next = CConfig.CoverLoading != ECoverLoading.TR_CONFIG_COVERLOADING_ATSTART || CSongs.CoverLoaded;
if ((_IntroOutPlayed || _SkipIntro) && next && CSettings.GameState != EGameState.EditTheme && CSongs.SongsLoaded) if ((_IntroOutPlayed || _SkipIntro) && next && CSettings.ProgramState != EProgramState.EditTheme && CSongs.SongsLoaded)
CSettings.GameState = EGameState.Normal; CSettings.ProgramState = EProgramState.Normal;
if (CSettings.GameState == EGameState.Normal) if (CSettings.ProgramState == EProgramState.Normal)
CGraphics.FadeTo(EScreens.ScreenMain); CGraphics.FadeTo(EScreens.ScreenMain);
_Texts[_TextStatus].Text = _Texts[_TextStatus].Text =
+1 -1
View File
@@ -330,7 +330,7 @@ namespace Vocaluxe.Screens
private void _OnSaveSnapshot() private void _OnSaveSnapshot()
{ {
string filename = Path.Combine(CSettings.DataPath, CSettings.FolderProfiles, "snapshot"); string filename = Path.Combine(CSettings.DataPath, CConfig.ProfileFolders[0], "snapshot");
int i = 0; int i = 0;
while (File.Exists(filename + i + ".png")) while (File.Exists(filename + i + ".png"))
i++; i++;
+1 -1
View File
@@ -290,7 +290,7 @@ namespace VocaluxeLib
} }
#endregion Config #endregion Config
public enum EGameState public enum EProgramState
{ {
Start, Start,
Normal, Normal,
+2 -1
View File
@@ -71,7 +71,7 @@ namespace VocaluxeLib
float GetZFar(); float GetZFar();
float GetZNear(); float GetZNear();
EGameState GetGameState(); EProgramState GetProgramState();
int GetToneMin(); int GetToneMin();
int GetToneMax(); int GetToneMax();
@@ -209,6 +209,7 @@ namespace VocaluxeLib
EGameDifficulty GetDifficulty(int profileID); EGameDifficulty GetDifficulty(int profileID);
string GetPlayerName(int profileID, int playerNum = 0); string GetPlayerName(int profileID, int playerNum = 0);
CTexture GetAvatar(int profileID); CTexture GetAvatar(int profileID);
CAvatar GetAvatarByFilename(string fileName);
bool IsProfileIDValid(int profileID); bool IsProfileIDValid(int profileID);
bool IsGuest(int profileID); bool IsGuest(int profileID);
void AddProfileChangedCallback(ProfileChangedCallback notification); void AddProfileChangedCallback(ProfileChangedCallback notification);
+1 -1
View File
@@ -276,7 +276,7 @@ namespace VocaluxeLib.Menu
public void Draw(bool forceDraw = false) public void Draw(bool forceDraw = false)
{ {
if (!Visible && CBase.Settings.GetGameState() != EGameState.EditTheme && !forceDraw) if (!Visible && CBase.Settings.GetProgramState() != EProgramState.EditTheme && !forceDraw)
return; return;
CTexture texture; CTexture texture;
+1 -1
View File
@@ -224,7 +224,7 @@ namespace VocaluxeLib.Menu
#region draw #region draw
public void Draw(float actualBeat) public void Draw(float actualBeat)
{ {
if (Visible || CBase.Settings.GetGameState() == EGameState.EditTheme) if (Visible || CBase.Settings.GetProgramState() == EProgramState.EditTheme)
{ {
switch (LyricStyle) switch (LyricStyle)
{ {
+3 -3
View File
@@ -968,7 +968,7 @@ namespace VocaluxeLib.Menu
float z = CBase.Settings.GetZFar(); float z = CBase.Settings.GetZFar();
for (int i = 0; i < _Interactions.Count; i++) 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; continue;
if (!_IsMouseOver(x, y, _Interactions[i])) if (!_IsMouseOver(x, y, _Interactions[i]))
continue; continue;
@@ -1043,7 +1043,7 @@ namespace VocaluxeLib.Menu
private void _NextInteraction() private void _NextInteraction()
{ {
_UnsetSelected(); _UnsetSelected();
if (CBase.Settings.GetGameState() != EGameState.EditTheme) if (CBase.Settings.GetProgramState() != EProgramState.EditTheme)
{ {
bool found = false; bool found = false;
int start = _Selection; int start = _Selection;
@@ -1070,7 +1070,7 @@ namespace VocaluxeLib.Menu
private void _PrevInteraction() private void _PrevInteraction()
{ {
_UnsetSelected(); _UnsetSelected();
if (CBase.Settings.GetGameState() != EGameState.EditTheme) if (CBase.Settings.GetProgramState() != EProgramState.EditTheme)
{ {
bool found = false; bool found = false;
int start = _Selection; int start = _Selection;
+3 -3
View File
@@ -470,7 +470,7 @@ namespace VocaluxeLib.Menu
float z = CBase.Settings.GetZFar(); float z = CBase.Settings.GetZFar();
for (int i = 0; i < _Interactions.Count; i++) 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])) if (_IsMouseOver(x, y, _Interactions[i]))
{ {
@@ -553,7 +553,7 @@ namespace VocaluxeLib.Menu
private void _NextInteraction() private void _NextInteraction()
{ {
_UnsetSelected(); _UnsetSelected();
if (CBase.Settings.GetGameState() != EGameState.EditTheme) if (CBase.Settings.GetProgramState() != EProgramState.EditTheme)
{ {
bool found = false; bool found = false;
int start = _Selection; int start = _Selection;
@@ -580,7 +580,7 @@ namespace VocaluxeLib.Menu
private void _PrevInteraction() private void _PrevInteraction()
{ {
_UnsetSelected(); _UnsetSelected();
if (CBase.Settings.GetGameState() != EGameState.EditTheme) if (CBase.Settings.GetProgramState() != EProgramState.EditTheme)
{ {
bool found = false; bool found = false;
int start = _Selection; int start = _Selection;
+1 -1
View File
@@ -416,7 +416,7 @@ namespace VocaluxeLib.Menu
{ {
if (_PlaylistElements.Count <= 0) if (_PlaylistElements.Count <= 0)
LoadPlaylist(0); LoadPlaylist(0);
if (!Visible && CBase.Settings.GetGameState() != EGameState.EditTheme && !forceDraw) if (!Visible && CBase.Settings.GetProgramState() != EProgramState.EditTheme && !forceDraw)
return; return;
for (int i = 0; i < _PlaylistElements.Count; i++) for (int i = 0; i < _PlaylistElements.Count; i++)
+3 -3
View File
@@ -710,7 +710,7 @@ namespace VocaluxeLib.Menu
public void Draw() public void Draw()
{ {
if (!Visible && CBase.Settings.GetGameState() != EGameState.EditTheme) if (!Visible && CBase.Settings.GetProgramState() != EProgramState.EditTheme)
return; return;
CTexture texture = CBase.Theme.GetSkinTexture(_Theme.TextureName, _PartyModeID); CTexture texture = CBase.Theme.GetSkinTexture(_Theme.TextureName, _PartyModeID);
@@ -733,7 +733,7 @@ namespace VocaluxeLib.Menu
else else
CBase.Drawing.DrawTexture(texture, Rect, Color); CBase.Drawing.DrawTexture(texture, Rect, Color);
if (_Selection > 0 || CBase.Settings.GetGameState() == EGameState.EditTheme) if (_Selection > 0 || CBase.Settings.GetProgramState() == EProgramState.EditTheme)
{ {
if (_ArrowLeftSelected) if (_ArrowLeftSelected)
CBase.Drawing.DrawTexture(selTextureArrowLeft, RectArrowLeft, SelColorArrow); CBase.Drawing.DrawTexture(selTextureArrowLeft, RectArrowLeft, SelColorArrow);
@@ -741,7 +741,7 @@ namespace VocaluxeLib.Menu
CBase.Drawing.DrawTexture(textureArrowLeft, RectArrowLeft, ColorArrow); 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) if (_ArrowRightSelected)
CBase.Drawing.DrawTexture(selTextureArrowRight, RectArrowRight, SelColorArrow); CBase.Drawing.DrawTexture(selTextureArrowRight, RectArrowRight, SelColorArrow);
+2 -2
View File
@@ -227,14 +227,14 @@ namespace VocaluxeLib.Menu
} }
var color = new SColorF(Color.R, Color.G, Color.B, Color.A * Alpha); 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); CBase.Drawing.DrawTexture(texture, rect, color, bounds);
if (Reflection) if (Reflection)
CBase.Drawing.DrawTextureReflection(texture, rect, color, bounds, ReflectionSpace, ReflectionHeight); 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); CBase.Drawing.DrawColor(new SColorF(1f, 1f, 1f, 0.5f), rect);
} }
+3 -3
View File
@@ -457,7 +457,7 @@ namespace VocaluxeLib.Menu
public void Draw(bool forceDraw = false) public void Draw(bool forceDraw = false)
{ {
if (!forceDraw && !Visible && CBase.Settings.GetGameState() != EGameState.EditTheme) if (!forceDraw && !Visible && CBase.Settings.GetProgramState() != EProgramState.EditTheme)
return; return;
// Update Text // Update Text
@@ -474,7 +474,7 @@ namespace VocaluxeLib.Menu
if (ReflectionHeight > 0) if (ReflectionHeight > 0)
CBase.Fonts.DrawTextReflection(_Text, Rect.H, Rect.X, Rect.Y, Z, color, ReflectionSpace, ReflectionHeight); 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)); 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 // 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)); CBase.Drawing.DrawColor(new SColorF(0.5f, 1f, 0.5f, 0.5f), new SRectF(X, Y, Rect.W, Rect.H, Z));
} }
+23 -13
View File
@@ -22,36 +22,46 @@ namespace VocaluxeLib.Profile
public class CAvatar public class CAvatar
{ {
public int ID; public int ID;
public string FileName = ""; private string _FileName = "";
public CTexture Texture; 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; ID = id;
} }
public bool LoadFromFile(string fileName) public bool LoadFromFile(string fileName)
{ {
FileName = fileName; _FileName = fileName;
return Reload(); return Reload();
} }
public bool Reload() public bool Reload()
{ {
CBase.Drawing.RemoveTexture(ref Texture); Unload();
Texture = CBase.Drawing.AddTexture(FileName); _Texture = CBase.Drawing.AddTexture(_FileName);
return Texture != null; return _Texture != null;
} }
public void Unload() public void Unload()
{ {
CBase.Drawing.RemoveTexture(ref Texture); CBase.Drawing.RemoveTexture(ref _Texture);
}
public string GetFileName()
{
return FileName;
} }
} }
} }
+4 -15
View File
@@ -38,22 +38,12 @@ namespace VocaluxeLib.Profile
public string PlayerName; public string PlayerName;
public string FilePath; public string FilePath;
public string FileName; public string FileName;
public string AvatarFileName;
public byte[] PasswordHash; public byte[] PasswordHash;
public byte[] PasswordSalt; public byte[] PasswordSalt;
public EGameDifficulty Difficulty; public EGameDifficulty Difficulty;
private CAvatar _Avatar; public CAvatar Avatar { get; set; }
public CAvatar Avatar
{
get { return _Avatar; }
set
{
_Avatar = value;
AvatarFileName = _Avatar.FileName;
}
}
public EUserRole UserRole; public EUserRole UserRole;
public EOffOn Active; public EOffOn Active;
@@ -62,11 +52,9 @@ namespace VocaluxeLib.Profile
{ {
PlayerName = String.Empty; PlayerName = String.Empty;
Difficulty = EGameDifficulty.TR_CONFIG_EASY; Difficulty = EGameDifficulty.TR_CONFIG_EASY;
Avatar = new CAvatar(-1);
UserRole = EUserRole.TR_USERROLE_NORMAL; UserRole = EUserRole.TR_USERROLE_NORMAL;
Active = EOffOn.TR_CONFIG_ON; Active = EOffOn.TR_CONFIG_ON;
AvatarFileName = String.Empty;
FileName = String.Empty; FileName = String.Empty;
} }
@@ -95,9 +83,10 @@ namespace VocaluxeLib.Profile
if (xmlReader.GetValue("//root/Info/PlayerName", out value, value)) if (xmlReader.GetValue("//root/Info/PlayerName", out value, value))
{ {
PlayerName = value; PlayerName = value;
string avatarFileName;
xmlReader.TryGetEnumValue("//root/Info/Difficulty", ref Difficulty); 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/UserRole", ref UserRole);
xmlReader.TryGetEnumValue("//root/Info/Active", ref Active); xmlReader.TryGetEnumValue("//root/Info/Active", ref Active);
string passwordHash; string passwordHash;