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
+63
-56
@@ -43,6 +43,15 @@ namespace Vocaluxe.Base
|
||||
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
|
||||
public static EDebugLevel DebugLevel = EDebugLevel.TR_CONFIG_OFF;
|
||||
public static EOffOn SaveModifiedSongs = EOffOn.TR_CONFIG_OFF;
|
||||
@@ -87,7 +96,6 @@ namespace Vocaluxe.Base
|
||||
|
||||
// Sound
|
||||
public static EPlaybackLib PlayBackLib = EPlaybackLib.Gstreamer;
|
||||
public static ERecordLib RecordLib = ERecordLib.PortAudio;
|
||||
public static EBufferSize AudioBufferSize = EBufferSize.B2048;
|
||||
public static int AudioLatency;
|
||||
private static int _BackgroundMusicVolume = 30;
|
||||
@@ -97,8 +105,28 @@ namespace Vocaluxe.Base
|
||||
public static int PreviewMusicVolume = 50;
|
||||
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
|
||||
public static readonly List<string> SongFolder = new List<string>();
|
||||
public static ESongMenu SongMenu = ESongMenu.TR_CONFIG_TILE_BOARD;
|
||||
public static ESongSorting SongSorting = ESongSorting.TR_CONFIG_ARTIST;
|
||||
public static EOffOn IgnoreArticles = EOffOn.TR_CONFIG_ON;
|
||||
@@ -120,8 +148,11 @@ namespace Vocaluxe.Base
|
||||
public static EOffOn VideosToBackground = EOffOn.TR_CONFIG_OFF;
|
||||
|
||||
// Record
|
||||
public static SMicConfig[] MicConfig;
|
||||
public static int MicDelay = 300; //[ms]
|
||||
public static ERecordLib RecordLib = ERecordLib.PortAudio;
|
||||
public static readonly SMicConfig[] MicConfig = new SMicConfig[CSettings.MaxNumPlayer];
|
||||
public static int MicDelay = 200; //[ms]
|
||||
|
||||
// Webcam
|
||||
public static EWebcamLib WebcamLib = EWebcamLib.OpenCV;
|
||||
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> _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
|
||||
{
|
||||
get { return _BackgroundMusicVolume; }
|
||||
@@ -154,27 +183,21 @@ namespace Vocaluxe.Base
|
||||
|
||||
public static void Init()
|
||||
{
|
||||
SongFolder.Add(Path.Combine(Directory.GetCurrentDirectory(), CSettings.FolderSongs));
|
||||
|
||||
#if INSTALLER
|
||||
SongFolder.Add(Path.Combine(CSettings.DataPath, CSettings.FolderSongs));
|
||||
#endif
|
||||
|
||||
foreach (string folder in SongFolder)
|
||||
CSettings.CreateFolder(folder);
|
||||
|
||||
MicConfig = new SMicConfig[CSettings.MaxNumPlayer];
|
||||
if (_Initialized)
|
||||
return;
|
||||
|
||||
// Init config file
|
||||
if (!File.Exists(Path.Combine(CSettings.DataPath, CSettings.FileConfig)))
|
||||
if (!File.Exists(Path.Combine(CSettings.DataPath, _FileConfig)))
|
||||
SaveConfig();
|
||||
else
|
||||
_LoadConfig();
|
||||
|
||||
_LoadConfig();
|
||||
_Initialized = true;
|
||||
}
|
||||
|
||||
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)
|
||||
return;
|
||||
|
||||
@@ -231,15 +254,14 @@ namespace Vocaluxe.Base
|
||||
|
||||
#region Game
|
||||
// Songfolder
|
||||
string value = string.Empty;
|
||||
string value = String.Empty;
|
||||
int i = 1;
|
||||
while (xmlReader.GetValue("//root/Game/SongFolder" + i, out value, value))
|
||||
{
|
||||
if (i == 1)
|
||||
SongFolder.Clear();
|
||||
|
||||
SongFolder.Add(value);
|
||||
value = string.Empty;
|
||||
SongFolders.Clear();
|
||||
SongFolders.Add(value);
|
||||
value = String.Empty;
|
||||
i++;
|
||||
}
|
||||
|
||||
@@ -271,7 +293,7 @@ namespace Vocaluxe.Base
|
||||
|
||||
//Read players from config
|
||||
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
|
||||
|
||||
#region Video
|
||||
@@ -318,7 +340,7 @@ namespace Vocaluxe.Base
|
||||
XmlWriter writer = null;
|
||||
try
|
||||
{
|
||||
writer = XmlWriter.Create(Path.Combine(CSettings.DataPath, CSettings.FileConfig), XMLSettings);
|
||||
writer = XmlWriter.Create(Path.Combine(CSettings.DataPath, _FileConfig), XMLSettings);
|
||||
writer.WriteStartDocument();
|
||||
writer.WriteStartElement("root");
|
||||
|
||||
@@ -469,21 +491,9 @@ namespace Vocaluxe.Base
|
||||
writer.WriteElementString("Language", Language);
|
||||
|
||||
// SongFolder
|
||||
// Check, if program was started with songfolder-parameters
|
||||
if (_SongFolderOld.Count > 0)
|
||||
{
|
||||
//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("SongFolder: SongFolder1, SongFolder2, SongFolder3, ...");
|
||||
for (int i = 0; i < SongFolders.Count; i++)
|
||||
writer.WriteElementString("SongFolder" + (i + 1), SongFolders[i]);
|
||||
|
||||
writer.WriteComment("SongMenu: " + CHelper.ListStrings(Enum.GetNames(typeof(ESongMenu))));
|
||||
writer.WriteElementString("SongMenu", Enum.GetName(typeof(ESongMenu), SongMenu));
|
||||
@@ -730,7 +740,7 @@ namespace Vocaluxe.Base
|
||||
Regex spliterParam = new Regex(@"-{1,2}|\/", RegexOptions.IgnoreCase);
|
||||
|
||||
//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);
|
||||
|
||||
@@ -791,24 +801,22 @@ namespace Vocaluxe.Base
|
||||
case "configfile":
|
||||
//Check if value is valid
|
||||
if (_CheckFile(value))
|
||||
CSettings.FileConfig = value;
|
||||
_FileConfig = value;
|
||||
break;
|
||||
|
||||
case "scorefile":
|
||||
//Check if value is valid
|
||||
if (_CheckFile(value))
|
||||
CSettings.FileHighscoreDB = value;
|
||||
FileHighscoreDB = value;
|
||||
break;
|
||||
|
||||
case "playlistfolder":
|
||||
CSettings.CreateFolder(value);
|
||||
CSettings.FolderPlaylists = value;
|
||||
FolderPlaylists = value;
|
||||
break;
|
||||
|
||||
case "profilefolder":
|
||||
CSettings.CreateFolder(value);
|
||||
CSettings.FoldersProfiles.Clear();
|
||||
CSettings.FoldersProfiles.Add(value);
|
||||
ProfileFolders.Clear();
|
||||
ProfileFolders.Add(value);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -819,6 +827,7 @@ namespace Vocaluxe.Base
|
||||
/// </summary>
|
||||
public static void UseCommandLineParamsAfter()
|
||||
{
|
||||
bool songFoldersOverwritten = false;
|
||||
//Check each parameter
|
||||
for (int i = 0; i < _Params.Count; i++)
|
||||
{
|
||||
@@ -833,15 +842,13 @@ namespace Vocaluxe.Base
|
||||
{
|
||||
case "songfolder":
|
||||
case "songpath":
|
||||
//Check if SongFolders from config.xml are saved
|
||||
if (_SongFolderOld.Count == 0)
|
||||
if (!songFoldersOverwritten)
|
||||
{
|
||||
_SongFolderOld.Clear();
|
||||
_SongFolderOld.AddRange(SongFolder);
|
||||
SongFolder.Clear();
|
||||
SongFolders.Clear();
|
||||
songFoldersOverwritten = true;
|
||||
}
|
||||
//Add parameter-value to SongFolder
|
||||
SongFolder.Add(value);
|
||||
if (!SongFolders.Contains(value))
|
||||
SongFolders.Add(value);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
+16
-19
@@ -24,6 +24,7 @@ namespace Vocaluxe.Base
|
||||
{
|
||||
class CCursor
|
||||
{
|
||||
private int _MouseMoveDiffMin = CSettings.MouseMoveDiffMinActive;
|
||||
private CFading _Fading;
|
||||
private CTexture _Cursor;
|
||||
|
||||
@@ -49,12 +50,8 @@ namespace Vocaluxe.Base
|
||||
|
||||
public void Draw()
|
||||
{
|
||||
if (_Movetimer.IsRunning && _Movetimer.ElapsedMilliseconds > CSettings.MouseMoveOffTime)
|
||||
{
|
||||
_Movetimer.Stop();
|
||||
_Fade(0f, 0.5f);
|
||||
}
|
||||
|
||||
if (_Movetimer.ElapsedMilliseconds > CSettings.MouseMoveOffTime)
|
||||
Deactivate();
|
||||
|
||||
if (_Fading != null)
|
||||
{
|
||||
@@ -64,21 +61,15 @@ namespace Vocaluxe.Base
|
||||
_Fading = null;
|
||||
}
|
||||
|
||||
if (Visible && (CSettings.GameState == EGameState.EditTheme || ShowCursor))
|
||||
if (Visible && (CSettings.ProgramState == EProgramState.EditTheme || ShowCursor))
|
||||
CDraw.DrawTexture(_Cursor);
|
||||
}
|
||||
|
||||
public void UpdatePosition(int x, int y)
|
||||
{
|
||||
if (Math.Abs(_Cursor.Rect.X - x) > CSettings.MouseMoveDiffMin ||
|
||||
Math.Abs(_Cursor.Rect.Y - y) > CSettings.MouseMoveDiffMin)
|
||||
{
|
||||
if (!IsActive)
|
||||
_Fade(1f, 0.2f);
|
||||
|
||||
_Movetimer.Restart();
|
||||
CSettings.MouseActive();
|
||||
}
|
||||
if (Math.Abs(_Cursor.Rect.X - x) > _MouseMoveDiffMin ||
|
||||
Math.Abs(_Cursor.Rect.Y - y) > _MouseMoveDiffMin)
|
||||
Activate();
|
||||
|
||||
_Cursor.Rect.X = x;
|
||||
_Cursor.Rect.Y = y;
|
||||
@@ -109,14 +100,20 @@ namespace Vocaluxe.Base
|
||||
UpdatePosition(x, y);
|
||||
}
|
||||
|
||||
public void FadeOut()
|
||||
public void Deactivate()
|
||||
{
|
||||
_Movetimer.Stop();
|
||||
if (!IsActive)
|
||||
return;
|
||||
_MouseMoveDiffMin = CSettings.MouseMoveDiffMinInactive;
|
||||
_Movetimer.Reset();
|
||||
_Fade(0f, 0.5f);
|
||||
}
|
||||
|
||||
public void FadeIn()
|
||||
public void Activate()
|
||||
{
|
||||
if (IsActive)
|
||||
return;
|
||||
_MouseMoveDiffMin = CSettings.MouseMoveDiffMinActive;
|
||||
_Movetimer.Restart();
|
||||
_Fade(1f, 0.2f);
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@ namespace Vocaluxe.Base
|
||||
|
||||
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);
|
||||
_CreditsRessourcesFilePath = Path.Combine(Environment.CurrentDirectory, CSettings.FileCreditsRessourcesDB);
|
||||
|
||||
|
||||
@@ -178,7 +178,7 @@ namespace Vocaluxe.Base
|
||||
if (CConfig.CoverLoading == ECoverLoading.TR_CONFIG_COVERLOADING_DYNAMIC && _CurrentScreen != EScreens.ScreenSing)
|
||||
CSongs.LoadCover();
|
||||
|
||||
if (CSettings.GameState != EGameState.EditTheme)
|
||||
if (CSettings.ProgramState != EProgramState.EditTheme)
|
||||
{
|
||||
run &= _HandleInputs(keys, mouse);
|
||||
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 ||
|
||||
keyEvent.Key == Keys.D0)
|
||||
{
|
||||
CSettings.MouseInactive();
|
||||
_Cursor.FadeOut();
|
||||
_Cursor.Deactivate();
|
||||
|
||||
if (keyEvent.ModAlt && keyEvent.ModCtrl && keyEvent.ModShift)
|
||||
{
|
||||
@@ -454,9 +453,9 @@ namespace Vocaluxe.Base
|
||||
}
|
||||
|
||||
if (keyEvent.ModShift && (keyEvent.Key == Keys.F1))
|
||||
CSettings.GameState = EGameState.EditTheme;
|
||||
CSettings.ProgramState = EProgramState.EditTheme;
|
||||
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))
|
||||
CDraw.MakeScreenShot();
|
||||
else
|
||||
@@ -484,10 +483,7 @@ namespace Vocaluxe.Base
|
||||
mouseEvent = inputMouseEvent;
|
||||
|
||||
if (mouseEvent.Wheel != 0)
|
||||
{
|
||||
CSettings.MouseActive();
|
||||
_Cursor.FadeIn();
|
||||
}
|
||||
_Cursor.Activate();
|
||||
|
||||
_UpdateMousePosition(mouseEvent.X, mouseEvent.Y);
|
||||
|
||||
@@ -550,11 +546,11 @@ namespace Vocaluxe.Base
|
||||
{
|
||||
if (keyEvent.ModShift && (keyEvent.Key == Keys.F1))
|
||||
{
|
||||
CSettings.GameState = EGameState.Normal;
|
||||
CSettings.ProgramState = EProgramState.Normal;
|
||||
_Screens[(int)_CurrentScreen].NextInteraction();
|
||||
}
|
||||
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))
|
||||
CDraw.MakeScreenShot();
|
||||
else
|
||||
@@ -588,7 +584,7 @@ namespace Vocaluxe.Base
|
||||
}
|
||||
|
||||
if (_VolumePopupTimer.IsRunning)
|
||||
_Cursor.FadeIn();
|
||||
_Cursor.Activate();
|
||||
|
||||
if (_CurrentPopupScreen != EPopupScreens.NoPopup)
|
||||
_PopupScreens[(int)_CurrentPopupScreen].UpdateGame();
|
||||
|
||||
@@ -118,7 +118,7 @@ namespace Vocaluxe.Base
|
||||
|
||||
public IEnumerable<string> GetSongFolders()
|
||||
{
|
||||
return CConfig.SongFolder;
|
||||
return CConfig.SongFolders;
|
||||
}
|
||||
|
||||
public ESongSorting GetSongSorting()
|
||||
@@ -179,9 +179,9 @@ namespace Vocaluxe.Base
|
||||
return CSettings.ZNear;
|
||||
}
|
||||
|
||||
public EGameState GetGameState()
|
||||
public EProgramState GetProgramState()
|
||||
{
|
||||
return CSettings.GameState;
|
||||
return CSettings.ProgramState;
|
||||
}
|
||||
|
||||
public int GetToneMin()
|
||||
@@ -226,7 +226,7 @@ namespace Vocaluxe.Base
|
||||
|
||||
public string GetFolderProfiles()
|
||||
{
|
||||
return CSettings.FolderProfiles;
|
||||
return CConfig.ProfileFolders[0];
|
||||
}
|
||||
|
||||
public string GetDataPath()
|
||||
@@ -601,6 +601,11 @@ namespace Vocaluxe.Base
|
||||
return CProfiles.GetAvatarTextureFromProfile(profileID);
|
||||
}
|
||||
|
||||
public CAvatar GetAvatarByFilename(string fileName)
|
||||
{
|
||||
return CProfiles.GetAvatarByFilename(fileName);
|
||||
}
|
||||
|
||||
public bool IsProfileIDValid(int profileID)
|
||||
{
|
||||
return CProfiles.IsProfileIDValid(profileID);
|
||||
|
||||
@@ -58,7 +58,7 @@ namespace Vocaluxe.Base
|
||||
private static void _ConvertUSDXPlaylists()
|
||||
{
|
||||
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)
|
||||
{
|
||||
@@ -73,7 +73,7 @@ namespace Vocaluxe.Base
|
||||
_Playlists = new List<CPlaylistFile>();
|
||||
|
||||
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)
|
||||
{
|
||||
|
||||
+25
-20
@@ -17,6 +17,7 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.IO;
|
||||
using VocaluxeLib;
|
||||
using VocaluxeLib.Draw;
|
||||
@@ -111,13 +112,21 @@ namespace Vocaluxe.Base
|
||||
break;
|
||||
|
||||
case EAction.AddProfile:
|
||||
if (change.Profile == null)
|
||||
CProfile newProf = change.Profile;
|
||||
if (newProf == null)
|
||||
break;
|
||||
|
||||
change.Profile.ID = _ProfileIDs.Dequeue();
|
||||
change.Profile.Avatar = _GetAvatar(change.Profile.AvatarFileName);
|
||||
change.Profile.SaveProfile();
|
||||
_Profiles.Add(change.Profile.ID, change.Profile);
|
||||
newProf.ID = _ProfileIDs.Dequeue();
|
||||
if (newProf.Avatar == null)
|
||||
newProf.Avatar = _Avatars.Values.First();
|
||||
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;
|
||||
break;
|
||||
@@ -318,7 +327,7 @@ namespace Vocaluxe.Base
|
||||
{
|
||||
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))
|
||||
@@ -332,8 +341,8 @@ namespace Vocaluxe.Base
|
||||
|
||||
public static int NewAvatar(string fileName)
|
||||
{
|
||||
var avatar = new CAvatar(-1);
|
||||
if (!avatar.LoadFromFile(fileName))
|
||||
CAvatar avatar = CAvatar.GetAvatar(fileName);
|
||||
if (avatar == null)
|
||||
return -1;
|
||||
|
||||
avatar.ID = _AvatarIDs.Dequeue();
|
||||
@@ -474,7 +483,7 @@ namespace Vocaluxe.Base
|
||||
|
||||
public static int GetAvatarID(int profileID)
|
||||
{
|
||||
if (!IsProfileIDValid(profileID))
|
||||
if (!IsProfileIDValid(profileID) || _Profiles[profileID].Avatar == null)
|
||||
return -1;
|
||||
|
||||
return _Profiles[profileID].Avatar.ID;
|
||||
@@ -505,7 +514,7 @@ namespace Vocaluxe.Base
|
||||
|
||||
public static CTexture GetAvatarTextureFromProfile(int profileID)
|
||||
{
|
||||
if (!IsProfileIDValid(profileID))
|
||||
if (!IsProfileIDValid(profileID) || _Profiles[profileID].Avatar == null)
|
||||
return null;
|
||||
|
||||
return _Profiles[profileID].Avatar.Texture;
|
||||
@@ -525,10 +534,7 @@ namespace Vocaluxe.Base
|
||||
foreach (int id in ids)
|
||||
{
|
||||
if (_Profiles[id].LoadProfile())
|
||||
{
|
||||
_Profiles[id].Avatar = _GetAvatar(_Profiles[id].AvatarFileName);
|
||||
knownFiles.Add(Path.GetFileName(_Profiles[id].FileName));
|
||||
}
|
||||
else
|
||||
_Profiles.Remove(id);
|
||||
}
|
||||
@@ -536,7 +542,7 @@ namespace Vocaluxe.Base
|
||||
|
||||
|
||||
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));
|
||||
|
||||
foreach (string file in files)
|
||||
@@ -552,7 +558,6 @@ namespace Vocaluxe.Base
|
||||
|
||||
if (profile.LoadProfile())
|
||||
{
|
||||
profile.Avatar = _GetAvatar(profile.AvatarFileName);
|
||||
profile.ID = _ProfileIDs.Dequeue();
|
||||
_Profiles.Add(profile.ID, profile);
|
||||
}
|
||||
@@ -577,7 +582,7 @@ namespace Vocaluxe.Base
|
||||
}
|
||||
|
||||
var files = new List<string>();
|
||||
foreach (string path in CSettings.FoldersProfiles)
|
||||
foreach (string path in CConfig.ProfileFolders)
|
||||
files.AddRange(CHelper.ListImageFiles(path, true, true));
|
||||
|
||||
foreach (string file in files)
|
||||
@@ -585,8 +590,8 @@ namespace Vocaluxe.Base
|
||||
if (knownFiles.Contains(Path.GetFileName(file)))
|
||||
continue;
|
||||
|
||||
var avatar = new CAvatar(-1);
|
||||
if (avatar.LoadFromFile(file))
|
||||
CAvatar avatar = CAvatar.GetAvatar(file);
|
||||
if (avatar != null)
|
||||
{
|
||||
avatar.ID = _AvatarIDs.Dequeue();
|
||||
_Avatars.Add(avatar.ID, avatar);
|
||||
@@ -650,7 +655,7 @@ namespace Vocaluxe.Base
|
||||
return String.CompareOrdinal(a.PlayerName, b.PlayerName);
|
||||
}
|
||||
|
||||
private static CAvatar _GetAvatar(string fileName)
|
||||
public static CAvatar GetAvatarByFilename(string fileName)
|
||||
{
|
||||
string name = Path.GetFileName(fileName);
|
||||
|
||||
@@ -659,7 +664,7 @@ namespace Vocaluxe.Base
|
||||
if (Path.GetFileName(_Avatars[id].FileName) == name)
|
||||
return _Avatars[id];
|
||||
}
|
||||
return new CAvatar(-1);
|
||||
return null;
|
||||
}
|
||||
#endregion private methods
|
||||
}
|
||||
|
||||
+21
-38
@@ -33,6 +33,10 @@ namespace Vocaluxe.Base
|
||||
// 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
|
||||
{
|
||||
#if ARCH_X86
|
||||
@@ -43,7 +47,9 @@ namespace Vocaluxe.Base
|
||||
private const String _Arch = "x64";
|
||||
#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.
|
||||
//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 ZFar = 100;
|
||||
|
||||
public static bool IsFullScreen;
|
||||
public const int VertexBufferElements = 10000;
|
||||
|
||||
#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
|
||||
public static string DataPath = Environment.CurrentDirectory;
|
||||
public static readonly string DataPath = Environment.CurrentDirectory;
|
||||
#endif
|
||||
|
||||
public const string Icon = "Vocaluxe.ico";
|
||||
public const string Logo = "Logo.png";
|
||||
public const string FallbackLanguage = "English";
|
||||
public static string FileConfig = "Config.xml";
|
||||
public const string FileFonts = "Fonts.xml";
|
||||
|
||||
public const string FileOldHighscoreDB = "Ultrastar.db";
|
||||
public static string FileHighscoreDB = "HighscoreDB.sqlite";
|
||||
public const string FileCoverDB = "CoverDB.sqlite";
|
||||
public const string FileCreditsRessourcesDB = "CreditsRessourcesDB.sqlite";
|
||||
public const string FilePerformanceLog = "Performance.log";
|
||||
@@ -96,21 +99,11 @@ namespace Vocaluxe.Base
|
||||
public const string FolderThemes = "Themes";
|
||||
public const string FolderThemeFonts = "Fonts";
|
||||
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 FolderSongs = "Songs";
|
||||
public const string FolderSounds = "Sounds";
|
||||
public const string FolderLanguages = "Languages";
|
||||
public const string FolderScreenshots = "Screenshots";
|
||||
public const string FolderBackgroundMusic = "BackgroundMusic";
|
||||
public static string FolderPlaylists = "Playlists";
|
||||
|
||||
public const string FolderPartyModes = "PartyModes";
|
||||
public const string FolderPartyModeCode = "Code";
|
||||
@@ -128,8 +121,10 @@ namespace Vocaluxe.Base
|
||||
public const int ToneMax = 89;
|
||||
|
||||
public const int NumNoteLines = 11;
|
||||
public static int MouseMoveDiffMin = 2;
|
||||
|
||||
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 MaxScore = 10000;
|
||||
@@ -212,37 +207,25 @@ namespace Vocaluxe.Base
|
||||
return RenderW / (float)RenderH;
|
||||
}
|
||||
|
||||
public static void MouseInactive()
|
||||
{
|
||||
MouseMoveDiffMin = 15;
|
||||
}
|
||||
|
||||
public static void MouseActive()
|
||||
{
|
||||
MouseMoveDiffMin = 3;
|
||||
}
|
||||
|
||||
public static void CreateFolders()
|
||||
{
|
||||
var folders = new List<string>
|
||||
{
|
||||
FolderCover,
|
||||
FolderFonts,
|
||||
Path.Combine(Environment.CurrentDirectory, FolderCover),
|
||||
Path.Combine(Environment.CurrentDirectory, FolderFonts),
|
||||
Path.Combine(DataPath, FolderScreenshots),
|
||||
FolderBackgroundMusic,
|
||||
FolderSounds,
|
||||
Path.Combine(DataPath, FolderPlaylists)
|
||||
Path.Combine(Environment.CurrentDirectory, FolderBackgroundMusic),
|
||||
Path.Combine(Environment.CurrentDirectory, FolderSounds),
|
||||
Path.Combine(DataPath, CConfig.FolderPlaylists)
|
||||
};
|
||||
folders.AddRange(FoldersProfiles);
|
||||
folders.AddRange(CConfig.ProfileFolders);
|
||||
folders.AddRange(CConfig.SongFolders);
|
||||
|
||||
foreach (string folder in folders)
|
||||
{
|
||||
string path = Path.Combine(Environment.CurrentDirectory, folder);
|
||||
CreateFolder(path);
|
||||
}
|
||||
_CreateFolder(folder);
|
||||
}
|
||||
|
||||
public static void CreateFolder(string path)
|
||||
private static void _CreateFolder(string path)
|
||||
{
|
||||
if (!Directory.Exists(path))
|
||||
Directory.CreateDirectory(path);
|
||||
|
||||
@@ -338,7 +338,7 @@ namespace Vocaluxe.Base
|
||||
|
||||
CLog.StartBenchmark("List Songs");
|
||||
var files = new List<string>();
|
||||
foreach (string p in CConfig.SongFolder)
|
||||
foreach (string p in CConfig.SongFolders)
|
||||
{
|
||||
string path = p;
|
||||
files.AddRange(CHelper.ListFiles(path, "*.txt", true, true));
|
||||
|
||||
@@ -207,7 +207,6 @@ namespace Vocaluxe.Base.Server
|
||||
ID = existingProfile.ID,
|
||||
FileName = existingProfile.FileName,
|
||||
Active = existingProfile.Active,
|
||||
AvatarFileName = existingProfile.AvatarFileName,
|
||||
Avatar = existingProfile.Avatar,
|
||||
Difficulty = existingProfile.Difficulty,
|
||||
UserRole = existingProfile.UserRole,
|
||||
@@ -317,10 +316,10 @@ namespace Vocaluxe.Base.Server
|
||||
{
|
||||
try
|
||||
{
|
||||
string filename = _SaveImage(avatarData, "snapshot", CSettings.FolderProfiles);
|
||||
string filename = _SaveImage(avatarData, "snapshot", CConfig.ProfileFolders[0]);
|
||||
|
||||
var avatar = new CAvatar(-1);
|
||||
if (avatar.LoadFromFile(filename))
|
||||
var avatar = CAvatar.GetAvatar(filename);
|
||||
if (avatar!=null)
|
||||
{
|
||||
CProfiles.AddAvatar(avatar);
|
||||
return avatar;
|
||||
|
||||
@@ -311,7 +311,6 @@ namespace Vocaluxe.Lib.Draw
|
||||
FormBorderStyle = FormBorderStyle.None;
|
||||
CenterToScreen();
|
||||
_Fullscreen = true;
|
||||
CConfig.FullScreen = EOffOn.TR_CONFIG_ON;
|
||||
|
||||
if (WindowState == FormWindowState.Maximized)
|
||||
{
|
||||
@@ -321,8 +320,7 @@ namespace Vocaluxe.Lib.Draw
|
||||
}
|
||||
else
|
||||
_DoResize();
|
||||
|
||||
CConfig.SaveConfig();
|
||||
;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -334,9 +332,6 @@ namespace Vocaluxe.Lib.Draw
|
||||
FormBorderStyle = FormBorderStyle.Sizable;
|
||||
CenterToScreen();
|
||||
_Fullscreen = false;
|
||||
CConfig.FullScreen = EOffOn.TR_CONFIG_OFF;
|
||||
|
||||
CConfig.SaveConfig();
|
||||
}
|
||||
#endregion resize
|
||||
|
||||
@@ -486,10 +481,7 @@ namespace Vocaluxe.Lib.Draw
|
||||
Show();
|
||||
|
||||
if (CConfig.FullScreen == EOffOn.TR_CONFIG_ON)
|
||||
{
|
||||
CSettings.IsFullScreen = true;
|
||||
_EnterFullScreen();
|
||||
}
|
||||
|
||||
//Resize window if aspect ratio is incorrect
|
||||
if (Math.Abs(_W / (float)_H - CSettings.GetRenderAspect()) > 0.01)
|
||||
@@ -530,7 +522,7 @@ namespace Vocaluxe.Lib.Draw
|
||||
}
|
||||
}
|
||||
//Apply fullscreen mode
|
||||
if (CSettings.IsFullScreen != _Fullscreen)
|
||||
if ((CConfig.FullScreen == EOffOn.TR_CONFIG_ON) != _Fullscreen)
|
||||
{
|
||||
if (!_Fullscreen)
|
||||
_EnterFullScreen();
|
||||
|
||||
@@ -127,9 +127,6 @@ namespace Vocaluxe.Lib.Draw
|
||||
targetForm.Bounds = Screen.PrimaryScreen.Bounds;
|
||||
targetForm.TopMost = true;
|
||||
_Fullscreen = true;
|
||||
|
||||
CConfig.FullScreen = EOffOn.TR_CONFIG_ON;
|
||||
CConfig.SaveConfig();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -146,9 +143,6 @@ namespace Vocaluxe.Lib.Draw
|
||||
targetForm.TopMost = _TopMost;
|
||||
targetForm.Bounds = _Bounds;
|
||||
_Fullscreen = false;
|
||||
|
||||
CConfig.FullScreen = EOffOn.TR_CONFIG_OFF;
|
||||
CConfig.SaveConfig();
|
||||
}
|
||||
#endregion FullScreenStuff
|
||||
|
||||
@@ -232,10 +226,7 @@ namespace Vocaluxe.Lib.Draw
|
||||
Show();
|
||||
|
||||
if (CConfig.FullScreen == EOffOn.TR_CONFIG_ON)
|
||||
{
|
||||
CSettings.IsFullScreen = true;
|
||||
_Maximize(this);
|
||||
}
|
||||
|
||||
while (_Run)
|
||||
{
|
||||
@@ -247,7 +238,7 @@ namespace Vocaluxe.Lib.Draw
|
||||
_Run = CGraphics.UpdateGameLogic(_Keys, _Mouse);
|
||||
_FlipBuffer();
|
||||
|
||||
if ((CSettings.IsFullScreen && !_Fullscreen) || (!CSettings.IsFullScreen && _Fullscreen))
|
||||
if ((CConfig.FullScreen == EOffOn.TR_CONFIG_ON) != _Fullscreen)
|
||||
_ToggleFullScreen();
|
||||
|
||||
if (CTime.IsRunning())
|
||||
|
||||
@@ -235,7 +235,6 @@ namespace Vocaluxe.Lib.Draw
|
||||
private void _EnterFullScreen()
|
||||
{
|
||||
_Fullscreen = true;
|
||||
CConfig.FullScreen = EOffOn.TR_CONFIG_ON;
|
||||
|
||||
_Restore.Location = Location;
|
||||
_Restore.Width = Width;
|
||||
@@ -261,19 +260,14 @@ namespace Vocaluxe.Lib.Draw
|
||||
}
|
||||
else
|
||||
_DoResize();
|
||||
|
||||
CConfig.SaveConfig();
|
||||
}
|
||||
|
||||
private void _LeaveFullScreen()
|
||||
{
|
||||
_Fullscreen = false;
|
||||
CConfig.FullScreen = EOffOn.TR_CONFIG_OFF;
|
||||
|
||||
FormBorderStyle = FormBorderStyle.Sizable;
|
||||
DesktopBounds = new Rectangle(_Restore.Location, new Size(_Restore.Width, _Restore.Height));
|
||||
|
||||
CConfig.SaveConfig();
|
||||
}
|
||||
#endregion Helpers
|
||||
|
||||
@@ -433,10 +427,7 @@ namespace Vocaluxe.Lib.Draw
|
||||
Show();
|
||||
|
||||
if (CConfig.FullScreen == EOffOn.TR_CONFIG_ON)
|
||||
{
|
||||
CSettings.IsFullScreen = true;
|
||||
_EnterFullScreen();
|
||||
}
|
||||
|
||||
while (_Run)
|
||||
{
|
||||
@@ -448,7 +439,7 @@ namespace Vocaluxe.Lib.Draw
|
||||
|
||||
_Control.SwapBuffers();
|
||||
|
||||
if (CSettings.IsFullScreen != _Fullscreen)
|
||||
if ((CConfig.FullScreen == EOffOn.TR_CONFIG_ON) != _Fullscreen)
|
||||
_ToggleFullScreen();
|
||||
|
||||
_CheckQueue();
|
||||
|
||||
@@ -63,14 +63,14 @@ namespace Vocaluxe.Lib.Playlist
|
||||
filename = "1";
|
||||
|
||||
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++;
|
||||
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;
|
||||
}
|
||||
|
||||
PlaylistFile = Path.Combine(CSettings.DataPath, CSettings.FolderPlaylists, filename + ".xml");
|
||||
PlaylistFile = Path.Combine(CSettings.DataPath, CConfig.FolderPlaylists, filename + ".xml");
|
||||
}
|
||||
|
||||
XmlWriter writer;
|
||||
|
||||
@@ -25,6 +25,7 @@ namespace Vocaluxe.Lib.Sound.Record
|
||||
|
||||
public CBuffer()
|
||||
{
|
||||
MinVolume = 0.02f;
|
||||
ToneWeigth = new float[NumHalfTones];
|
||||
for (int i = 0; i < ToneWeigth.Length; i++)
|
||||
ToneWeigth[i] = 0.99f;
|
||||
@@ -54,6 +55,11 @@ namespace Vocaluxe.Lib.Sound.Record
|
||||
|
||||
public float[] ToneWeigth { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Minimum volume for a tone to be valid
|
||||
/// </summary>
|
||||
public float MinVolume { get; set; }
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
lock (_Stream)
|
||||
@@ -109,7 +115,7 @@ namespace Vocaluxe.Lib.Sound.Record
|
||||
// find maximum volume
|
||||
_FindMaxVolume();
|
||||
|
||||
if (MaxVolume >= 0.02)
|
||||
if (MaxVolume >= MinVolume)
|
||||
_AnalyzeByAutocorrelation();
|
||||
else
|
||||
ToneValid = false;
|
||||
|
||||
+3
-1
@@ -87,7 +87,6 @@ namespace Vocaluxe
|
||||
CProgrammHelper.Init();
|
||||
|
||||
CMain.Init();
|
||||
CSettings.CreateFolders();
|
||||
Application.DoEvents();
|
||||
|
||||
// Init Language
|
||||
@@ -105,6 +104,9 @@ namespace Vocaluxe
|
||||
CConfig.UseCommandLineParamsAfter();
|
||||
CLog.StopBenchmark("Init Config");
|
||||
|
||||
// Create folders
|
||||
CSettings.CreateFolders();
|
||||
|
||||
Application.DoEvents();
|
||||
_SplashScreen = new CSplashScreen();
|
||||
Application.DoEvents();
|
||||
|
||||
@@ -137,10 +137,10 @@ namespace Vocaluxe.Screens
|
||||
|
||||
bool next = CConfig.CoverLoading != ECoverLoading.TR_CONFIG_COVERLOADING_ATSTART || CSongs.CoverLoaded;
|
||||
|
||||
if ((_IntroOutPlayed || _SkipIntro) && next && CSettings.GameState != EGameState.EditTheme && CSongs.SongsLoaded)
|
||||
CSettings.GameState = EGameState.Normal;
|
||||
if ((_IntroOutPlayed || _SkipIntro) && next && CSettings.ProgramState != EProgramState.EditTheme && CSongs.SongsLoaded)
|
||||
CSettings.ProgramState = EProgramState.Normal;
|
||||
|
||||
if (CSettings.GameState == EGameState.Normal)
|
||||
if (CSettings.ProgramState == EProgramState.Normal)
|
||||
CGraphics.FadeTo(EScreens.ScreenMain);
|
||||
|
||||
_Texts[_TextStatus].Text =
|
||||
|
||||
@@ -330,7 +330,7 @@ namespace Vocaluxe.Screens
|
||||
|
||||
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;
|
||||
while (File.Exists(filename + i + ".png"))
|
||||
i++;
|
||||
|
||||
@@ -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