From 7ce9a101263f31eb3e9957178e9239b736af743b Mon Sep 17 00:00:00 2001 From: Flamefire Date: Sun, 26 Oct 2014 14:03:12 +0100 Subject: [PATCH] Make config serializable --- Vocaluxe/Base/CBackgroundMusic.cs | 26 +- Vocaluxe/Base/CConfig.cs | 804 +++++++----------- Vocaluxe/Base/CCover.cs | 19 +- Vocaluxe/Base/CDraw.cs | 2 +- Vocaluxe/Base/CGame.cs | 4 +- Vocaluxe/Base/CGraphics.cs | 53 +- Vocaluxe/Base/CMain.cs | 24 +- Vocaluxe/Base/CProfiles.cs | 6 +- Vocaluxe/Base/CRecord.cs | 12 +- Vocaluxe/Base/CSongCategorizer.cs | 2 +- Vocaluxe/Base/CSongSorter.cs | 4 +- Vocaluxe/Base/CSongs.cs | 8 +- Vocaluxe/Base/CSound.cs | 2 +- Vocaluxe/Base/CVideo.cs | 2 +- Vocaluxe/Base/CWebcam.cs | 6 +- Vocaluxe/Base/Fonts/CFontStyle.cs | 2 +- Vocaluxe/Base/Fonts/CFonts.cs | 2 +- Vocaluxe/Base/Server/CVocaluxeServer.cs | 4 +- Vocaluxe/Base/ThemeSystem/CBaseTheme.cs | 2 +- Vocaluxe/Base/ThemeSystem/CPartyTheme.cs | 2 +- Vocaluxe/Base/ThemeSystem/CThemes.cs | 8 +- Vocaluxe/Lib/Draw/CDirect3D.cs | 14 +- Vocaluxe/Lib/Draw/CDrawBase.cs | 19 +- Vocaluxe/Lib/Draw/CDrawWinForm.cs | 4 +- Vocaluxe/Lib/Draw/COpenGL.cs | 13 +- Vocaluxe/Lib/Draw/CTextureProvider.cs | 2 +- .../Sound/Playback/OpenAL/COpenAlStream.cs | 4 +- .../Playback/PortAudio/CPortAudioStream.cs | 4 +- Vocaluxe/Screens/CPopupScreenPlayerControl.cs | 8 +- Vocaluxe/Screens/CScreenLoad.cs | 12 +- Vocaluxe/Screens/CScreenNames.cs | 28 +- Vocaluxe/Screens/CScreenOptionsGame.cs | 26 +- Vocaluxe/Screens/CScreenOptionsLyrics.cs | 8 +- Vocaluxe/Screens/CScreenOptionsRecord.cs | 24 +- Vocaluxe/Screens/CScreenOptionsSound.cs | 14 +- Vocaluxe/Screens/CScreenOptionsTheme.cs | 36 +- Vocaluxe/Screens/CScreenOptionsVideo.cs | 31 +- Vocaluxe/Screens/CScreenScore.cs | 6 +- Vocaluxe/Screens/CScreenSing.cs | 53 +- Vocaluxe/Screens/CScreenSong.cs | 18 +- 40 files changed, 553 insertions(+), 765 deletions(-) diff --git a/Vocaluxe/Base/CBackgroundMusic.cs b/Vocaluxe/Base/CBackgroundMusic.cs index 6a854373..806194ce 100644 --- a/Vocaluxe/Base/CBackgroundMusic.cs +++ b/Vocaluxe/Base/CBackgroundMusic.cs @@ -67,10 +67,9 @@ namespace Vocaluxe.Base { if (_PlaysPreview) return false; - else if (_BGMusicFiles.Contains(_CurrentPlaylistElement)) + if (_BGMusicFiles.Contains(_CurrentPlaylistElement)) return false; - else - return true; + return true; } } @@ -118,8 +117,7 @@ namespace Vocaluxe.Base { if (_PlaysPreview) return _PreviewPlayer.ArtistAndTitle; - else - return _BGMusicFiles.Contains(_CurrentPlaylistElement) ? Path.GetFileNameWithoutExtension(_CurrentPlaylistElement.MusicFilePath) : _SongPlayer.ArtistAndTitle; + return _BGMusicFiles.Contains(_CurrentPlaylistElement) ? Path.GetFileNameWithoutExtension(_CurrentPlaylistElement.MusicFilePath) : _SongPlayer.ArtistAndTitle; } } @@ -169,15 +167,17 @@ namespace Vocaluxe.Base _PreviewPlayer.Volume = CConfig.PreviewMusicVolume; _PreviewPlayer.RepeatSong = true; - _VideoEnabled = (CConfig.VideoBackgrounds == EOffOn.TR_CONFIG_ON && CConfig.VideosToBackground == EOffOn.TR_CONFIG_ON); - SetMusicSource(CConfig.BackgroundMusicSource); + _VideoEnabled = (CConfig.Config.Video.VideoBackgrounds == EOffOn.TR_CONFIG_ON && CConfig.Config.Video.VideosToBackground == EOffOn.TR_CONFIG_ON); + SetMusicSource(CConfig.Config.Sound.BackgroundMusicSource); _Initialized = true; } public static void Close() { - _SongPlayer.Stop(); - _PreviewPlayer.Stop(); + if (_SongPlayer != null) + _SongPlayer.Stop(); + if (_PreviewPlayer != null) + _PreviewPlayer.Stop(); _BGMusicFiles.Clear(); _NotPlayedFiles.Clear(); @@ -188,12 +188,12 @@ namespace Vocaluxe.Base public static void Play() { - if (IsPlaying || (CConfig.BackgroundMusic != EBackgroundMusicOffOn.TR_CONFIG_ON && !_PlaysPreview)) + if (IsPlaying || (CConfig.Config.Sound.BackgroundMusic != EBackgroundMusicOffOn.TR_CONFIG_ON && !_PlaysPreview)) return; if (_PlaysPreview) _PreviewPlayer.Play(); - else if (CConfig.BackgroundMusic == EBackgroundMusicOffOn.TR_CONFIG_ON) + else if (CConfig.Config.Sound.BackgroundMusic == EBackgroundMusicOffOn.TR_CONFIG_ON) { if (_SongPlayer.SongLoaded) //Resume @@ -229,7 +229,7 @@ namespace Vocaluxe.Base return; _PreviewPlayer.TogglePause(); } - else if (CConfig.BackgroundMusic == EBackgroundMusicOffOn.TR_CONFIG_ON) + else if (CConfig.Config.Sound.BackgroundMusic == EBackgroundMusicOffOn.TR_CONFIG_ON) { if (!_SongPlayer.SongLoaded) Next(); @@ -395,7 +395,7 @@ namespace Vocaluxe.Base { //Seek to #Start-Tag, if found float start = 0f; - if (_CurrentPlaylistElement.Start > 0.001 && CConfig.BackgroundMusicUseStart == EOffOn.TR_CONFIG_ON) + if (_CurrentPlaylistElement.Start > 0.001 && CConfig.Config.Sound.BackgroundMusicUseStart == EOffOn.TR_CONFIG_ON) start = _CurrentPlaylistElement.Start; _SongPlayer.Load(CBase.Songs.GetSongByID(_CurrentPlaylistElement.SongID), start, true); } diff --git a/Vocaluxe/Base/CConfig.cs b/Vocaluxe/Base/CConfig.cs index cfd423e4..796af1ff 100644 --- a/Vocaluxe/Base/CConfig.cs +++ b/Vocaluxe/Base/CConfig.cs @@ -18,12 +18,14 @@ using System; using System.Collections.Generic; using System.Collections.ObjectModel; +using System.ComponentModel; using System.IO; using System.Linq; using System.Text; using System.Text.RegularExpressions; using System.Windows.Forms; using System.Xml; +using System.Xml.Serialization; using Vocaluxe.Lib.Sound.Record; using Vocaluxe.Lib.Webcam; using VocaluxeLib; @@ -51,62 +53,143 @@ namespace Vocaluxe.Base public static string FileHighscoreDB = Path.Combine(CSettings.DataFolder, "HighscoreDB.sqlite"); private static string _FileConfig = Path.Combine(CSettings.DataFolder, "Config.xml"); - // Debug - public static EDebugLevel DebugLevel = EDebugLevel.TR_CONFIG_OFF; - public static EOffOn SaveModifiedSongs = EOffOn.TR_CONFIG_OFF; + // ReSharper disable UnassignedField.Global +#pragma warning disable 649 + public struct SConfigInfo + { + // ReSharper disable NotAccessedField.Global + public string Version; + public string Time; + public string Platform; + public string OSVersion; + public int ProcessorCount; + public int Screens; + public string PrimaryScreenResolution; + public string Directory; + // ReSharper restore NotAccessedField.Global + } - // Graphics + public struct SConfigDebug + { + [DefaultValue(EDebugLevel.TR_CONFIG_OFF)] public EDebugLevel DebugLevel; + [DefaultValue(EOffOn.TR_CONFIG_OFF)] public EOffOn SaveModifiedSongs; + } + + public struct SConfigGraphics + { #if WIN - public static ERenderer Renderer = ERenderer.TR_CONFIG_DIRECT3D; + [DefaultValue(ERenderer.TR_CONFIG_DIRECT3D)] public ERenderer Renderer; #else - public static ERenderer Renderer = ERenderer.TR_CONFIG_OPENGL; + [DefaultValue(ERenderer.TR_CONFIG_OPENGL)] public ERenderer Renderer; #endif - public static ETextureQuality TextureQuality = ETextureQuality.TR_CONFIG_TEXTURE_MEDIUM; - public static float MaxFPS = 60f; + [DefaultValue(ETextureQuality.TR_CONFIG_TEXTURE_MEDIUM)] public ETextureQuality TextureQuality; + [XmlRanged(32, 1024), DefaultValue(128)] public int CoverSize; - public static int ScreenW = 1024; - public static int ScreenH = 576; + [DefaultValue(1024)] public int ScreenW; + [DefaultValue(576)] public int ScreenH; + [DefaultValue(EGeneralAlignment.Middle)] public EGeneralAlignment ScreenAlignment; + [DefaultValue(0)] public int BorderLeft; + [DefaultValue(0)] public int BorderRight; + [DefaultValue(0)] public int BorderTop; + [DefaultValue(0)] public int BorderBottom; + [DefaultValue(EAntiAliasingModes.X0)] public EAntiAliasingModes AAMode; + [DefaultValue(60f)] public float MaxFPS; + [DefaultValue(EOffOn.TR_CONFIG_ON)] public EOffOn VSync; + [DefaultValue(EOffOn.TR_CONFIG_ON)] public EOffOn FullScreen; + [DefaultValue(0.4f)] public float FadeTime; + } - public static int BorderLeft; - public static int BorderRight; - public static int BorderTop; - public static int BorderBottom; + public struct SConfigTheme + { + [XmlElement("Name"), DefaultValue("Ambient")] public string Theme; + [DefaultValue("Blue")] public string Skin; + [XmlElement("Cover"), DefaultValue("Blue")] public string CoverTheme; + [DefaultValue(EOffOn.TR_CONFIG_ON)] public EOffOn DrawNoteLines; + [DefaultValue(EOffOn.TR_CONFIG_ON)] public EOffOn DrawToneHelper; + [DefaultValue(ETimerLook.TR_CONFIG_TIMERLOOK_EXPANDED)] public ETimerLook TimerLook; + [DefaultValue(EPlayerInfo.TR_CONFIG_PLAYERINFO_BOTH)] public EPlayerInfo PlayerInfo; + [DefaultValue(EFadePlayerInfo.TR_CONFIG_FADEPLAYERINFO_OFF)] public EFadePlayerInfo FadePlayerInfo; + [DefaultValue(ECoverLoading.TR_CONFIG_COVERLOADING_DYNAMIC)] public ECoverLoading CoverLoading; + [DefaultValue(ELyricStyle.Slide)] public ELyricStyle LyricStyle; + } - public static EGeneralAlignment ScreenAlignment = EGeneralAlignment.Middle; + public struct SConfigSound + { + [DefaultValue(EPlaybackLib.GstreamerSharp)] public EPlaybackLib PlayBackLib; + [DefaultValue(ERecordLib.PortAudio)] public ERecordLib RecordLib; + [DefaultValue(EBufferSize.B2048)] public EBufferSize AudioBufferSize; + [XmlRanged(-500, 500)] public int AudioLatency; + // ReSharper disable MemberHidesStaticFromOuterClass + [DefaultValue(EBackgroundMusicOffOn.TR_CONFIG_ON)] public EBackgroundMusicOffOn BackgroundMusic; + [XmlRanged(0, 100), DefaultValue(30)] public int BackgroundMusicVolume; + [DefaultValue(EBackgroundMusicSource.TR_CONFIG_NO_OWN_MUSIC)] public EBackgroundMusicSource BackgroundMusicSource; + [DefaultValue(EOffOn.TR_CONFIG_ON)] public EOffOn BackgroundMusicUseStart; + [XmlRanged(0, 100), DefaultValue(50)] public int PreviewMusicVolume; + [XmlRanged(0, 100), DefaultValue(80)] public int GameMusicVolume; + // ReSharper restore MemberHidesStaticFromOuterClass + } - public static EAntiAliasingModes AAMode = EAntiAliasingModes.X0; + public struct SConfigGame + { + [DefaultValue(CSettings.FallbackLanguage)] public string Language; + public string[] SongFolder; + [DefaultValue(ESongMenu.TR_CONFIG_TILE_BOARD)] public ESongMenu SongMenu; + [DefaultValue(ESongSorting.TR_CONFIG_ARTIST)] public ESongSorting SongSorting; + [DefaultValue(EOffOn.TR_CONFIG_ON)] public EOffOn IgnoreArticles; + [DefaultValue(10)] public float ScoreAnimationTime; + [DefaultValue(ETimerMode.TR_CONFIG_TIMERMODE_REMAINING)] public ETimerMode TimerMode; + [XmlAltName("NumPlayer"), DefaultValue(2)] public int NumPlayers; + [DefaultValue(EOffOn.TR_CONFIG_OFF)] public EOffOn Tabs; + [DefaultValue(ELyricsPosition.TR_CONFIG_LYRICSPOSITION_BOTTOM)] public ELyricsPosition LyricsPosition; + [DefaultValue(0.1f)] public float MinLineBreakTime; //Minimum time to show the text before it is (to be) sung (if possible) + [XmlArrayItem("Player"), XmlArray] public string[] Players; + } - public static EOffOn VSync = EOffOn.TR_CONFIG_ON; - public static EOffOn FullScreen = EOffOn.TR_CONFIG_ON; + public struct SConfigVideo + { + [DefaultValue(EVideoDecoder.FFmpeg)] public EVideoDecoder VideoDecoder; + [DefaultValue(EOffOn.TR_CONFIG_ON)] public EOffOn VideoBackgrounds; + [DefaultValue(EOffOn.TR_CONFIG_ON)] public EOffOn VideoPreview; + [DefaultValue(EOffOn.TR_CONFIG_ON)] public EOffOn VideosInSongs; + [DefaultValue(EOffOn.TR_CONFIG_OFF)] public EOffOn VideosToBackground; + [DefaultValue(EWebcamLib.OpenCV)] public EWebcamLib WebcamLib; + public SWebcamConfig? WebcamConfig; + } - public static float FadeTime = 0.4f; - public static int CoverSize = 128; + public struct SConfigRecord + { + public SMicConfig[] MicConfig; + [DefaultValue(200)] public int MicDelay; //[ms] + } - // Theme - public static string Theme = "Ambient"; - public static string Skin = "Blue"; - public static string CoverTheme = "Blue"; - public static EOffOn DrawNoteLines = EOffOn.TR_CONFIG_ON; - public static EOffOn DrawToneHelper = EOffOn.TR_CONFIG_ON; - public static ETimerLook TimerLook = ETimerLook.TR_CONFIG_TIMERLOOK_EXPANDED; - public static EPlayerInfo PlayerInfo = EPlayerInfo.TR_CONFIG_PLAYERINFO_BOTH; - public static EFadePlayerInfo FadePlayerInfo = EFadePlayerInfo.TR_CONFIG_FADEPLAYERINFO_OFF; - public static ECoverLoading CoverLoading = ECoverLoading.TR_CONFIG_COVERLOADING_DYNAMIC; - public static ELyricStyle LyricStyle = ELyricStyle.Slide; + public struct SConfigServer + { + [DefaultValue(EOffOn.TR_CONFIG_OFF)] public EOffOn ServerActive; + [DefaultValue(EOffOn.TR_CONFIG_OFF)] public EOffOn ServerEncryption; + [DefaultValue(3000)] public int ServerPort; + } +#pragma warning restore 649 + // ReSharper restore UnassignedField.Global + + public struct SConfig + { + // ReSharper disable NotAccessedField.Global + public SConfigInfo? Info; + // ReSharper restore NotAccessedField.Global + public SConfigDebug Debug; + public SConfigGraphics Graphics; + public SConfigTheme Theme; + public SConfigSound Sound; + public SConfigGame Game; + public SConfigVideo Video; + public SConfigRecord Record; + public SConfigServer Server; + } + + public static SConfig Config; public static bool LoadOldThemeFiles; - // Sound - public static EPlaybackLib PlayBackLib = EPlaybackLib.GstreamerSharp; - public static EBufferSize AudioBufferSize = EBufferSize.B2048; - public static int AudioLatency; - private static int _BackgroundMusicVolume = 30; - public static EBackgroundMusicOffOn BackgroundMusic = EBackgroundMusicOffOn.TR_CONFIG_ON; - public static EBackgroundMusicSource BackgroundMusicSource = EBackgroundMusicSource.TR_CONFIG_NO_OWN_MUSIC; - public static EOffOn BackgroundMusicUseStart = EOffOn.TR_CONFIG_ON; - private static int _PreviewMusicVolume = 50; - private static int _GameMusicVolume = 80; - //Folders public static readonly List SongFolders = new List { @@ -128,72 +211,36 @@ namespace Vocaluxe.Base Path.Combine(CSettings.DataFolder, CSettings.FolderNameProfiles) }; - // Game - 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; - public static float ScoreAnimationTime = 10; - public static ETimerMode TimerMode = ETimerMode.TR_CONFIG_TIMERMODE_REMAINING; - public static int NumPlayers = 2; - public static EOffOn Tabs = EOffOn.TR_CONFIG_OFF; - public static string Language = CSettings.FallbackLanguage; - public static ELyricsPosition LyricsPosition = ELyricsPosition.TR_CONFIG_LYRICSPOSITION_BOTTOM; - public static readonly string[] Players = new string[CSettings.MaxNumPlayer]; - - public static float MinLineBreakTime = 0.1f; //Minimum time to show the text before it is (to be) sung (if possible) - - // Video - public static EVideoDecoder VideoDecoder = EVideoDecoder.FFmpeg; - public static EOffOn VideoBackgrounds = EOffOn.TR_CONFIG_ON; - public static EOffOn VideoPreview = EOffOn.TR_CONFIG_ON; - public static EOffOn VideosInSongs = EOffOn.TR_CONFIG_ON; - public static EOffOn VideosToBackground = EOffOn.TR_CONFIG_OFF; - - // Record - 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; - - // Server - public static EOffOn ServerActive = EOffOn.TR_CONFIG_OFF; - public static EOffOn ServerEncryption = EOffOn.TR_CONFIG_OFF; - public static int ServerPort = 3000; - //public static string ServerPassword = "vocaluxe"; - //Lists to save parameters and values private static readonly List _Params = new List(); private static readonly List _Values = new List(); public static int BackgroundMusicVolume { - get { return _BackgroundMusicVolume; } + get { return Config.Sound.BackgroundMusicVolume; } set { - _BackgroundMusicVolume = value.Clamp(0, 100); + Config.Sound.BackgroundMusicVolume = value.Clamp(0, 100); SaveConfig(); } } public static int GameMusicVolume { - get { return _GameMusicVolume; } + get { return Config.Sound.GameMusicVolume; } set { - _GameMusicVolume = value.Clamp(0, 100); + Config.Sound.GameMusicVolume = value.Clamp(0, 100); SaveConfig(); } } public static int PreviewMusicVolume { - get { return _PreviewMusicVolume; } + get { return Config.Sound.PreviewMusicVolume; } set { - _PreviewMusicVolume = value.Clamp(0, 100); + Config.Sound.PreviewMusicVolume = value.Clamp(0, 100); SaveConfig(); } } @@ -214,434 +261,171 @@ namespace Vocaluxe.Base private static void _LoadConfig() { - CXMLReader xmlReader = CXMLReader.OpenFile(_FileConfig); - if (xmlReader == null) - return; + var xml = new CXmlSerializer(); + Config = xml.Deserialize(_FileConfig); - xmlReader.TryGetEnumValue("//root/Debug/DebugLevel", ref DebugLevel); - xmlReader.TryGetEnumValue("//root/Debug/SaveModifiedSongs", ref SaveModifiedSongs); - - #region Graphics - xmlReader.TryGetEnumValue("//root/Graphics/Renderer", ref Renderer); - xmlReader.TryGetEnumValue("//root/Graphics/TextureQuality", ref TextureQuality); - xmlReader.TryGetIntValueRange("//root/Graphics/CoverSize", ref CoverSize, 32, 1024); - - xmlReader.TryGetIntValue("//root/Graphics/ScreenW", ref ScreenW); - xmlReader.TryGetIntValue("//root/Graphics/ScreenH", ref ScreenH); - - xmlReader.TryGetEnumValue("//root/Graphics/ScreenAlignment", ref ScreenAlignment); - - xmlReader.TryGetIntValue("//root/Graphics/BorderLeft", ref BorderLeft); - xmlReader.TryGetIntValue("//root/Graphics/BorderRight", ref BorderRight); - xmlReader.TryGetIntValue("//root/Graphics/BorderTop", ref BorderTop); - xmlReader.TryGetIntValue("//root/Graphics/BorderBottom", ref BorderBottom); - - xmlReader.TryGetEnumValue("//root/Graphics/AAMode", ref AAMode); - xmlReader.TryGetFloatValue("//root/Graphics/MaxFPS", ref MaxFPS); - xmlReader.TryGetEnumValue("//root/Graphics/VSync", ref VSync); - xmlReader.TryGetEnumValue("//root/Graphics/FullScreen", ref FullScreen); - xmlReader.TryGetFloatValue("//root/Graphics/FadeTime", ref FadeTime); - #endregion Graphics - - #region Theme - xmlReader.GetValue("//root/Theme/Name", out Theme, Theme); - xmlReader.GetValue("//root/Theme/Skin", out Skin, Skin); - xmlReader.GetValue("//root/Theme/Cover", out CoverTheme, CoverTheme); - xmlReader.TryGetEnumValue("//root/Theme/DrawNoteLines", ref DrawNoteLines); - xmlReader.TryGetEnumValue("//root/Theme/DrawToneHelper", ref DrawToneHelper); - xmlReader.TryGetEnumValue("//root/Theme/TimerLook", ref TimerLook); - xmlReader.TryGetEnumValue("//root/Theme/PlayerInfo", ref PlayerInfo); - xmlReader.TryGetEnumValue("//root/Theme/FadePlayerInfo", ref FadePlayerInfo); - xmlReader.TryGetEnumValue("//root/Theme/CoverLoading", ref CoverLoading); - xmlReader.TryGetEnumValue("//root/Theme/LyricStyle", ref LyricStyle); - #endregion Theme - - #region Sound - xmlReader.TryGetEnumValue("//root/Sound/PlayBackLib", ref PlayBackLib); - xmlReader.TryGetEnumValue("//root/Sound/RecordLib", ref RecordLib); - xmlReader.TryGetEnumValue("//root/Sound/AudioBufferSize", ref AudioBufferSize); - - xmlReader.TryGetIntValueRange("//root/Sound/AudioLatency", ref AudioLatency, -500, 500); - - xmlReader.TryGetEnumValue("//root/Sound/BackgroundMusic", ref BackgroundMusic); - xmlReader.TryGetIntValueRange("//root/Sound/BackgroundMusicVolume", ref _BackgroundMusicVolume); - xmlReader.TryGetEnumValue("//root/Sound/BackgroundMusicSource", ref BackgroundMusicSource); - xmlReader.TryGetEnumValue("//root/Sound/BackgroundMusicUseStart", ref BackgroundMusicUseStart); - xmlReader.TryGetIntValueRange("//root/Sound/PreviewMusicVolume", ref _PreviewMusicVolume); - xmlReader.TryGetIntValueRange("//root/Sound/GameMusicVolume", ref _GameMusicVolume); - #endregion Sound - - #region Game - // Songfolder - string value = String.Empty; - int i = 1; - while (xmlReader.GetValue("//root/Game/SongFolder" + i, out value, value)) + if (Config.Game.SongFolder.Length > 0) { - if (i == 1) - SongFolders.Clear(); - SongFolders.Add(value); - value = String.Empty; - i++; + SongFolders.Clear(); + SongFolders.AddRange(Config.Game.SongFolder); } + if ((Config.Game.ScoreAnimationTime > 0 && Config.Game.ScoreAnimationTime < 1) || Config.Game.ScoreAnimationTime < 0) + Config.Game.ScoreAnimationTime = 1; - xmlReader.TryGetEnumValue("//root/Game/SongMenu", ref SongMenu); - xmlReader.TryGetEnumValue("//root/Game/SongSorting", ref SongSorting); - xmlReader.TryGetEnumValue("//root/Game/IgnoreArticles", ref IgnoreArticles); - xmlReader.TryGetFloatValue("//root/Game/ScoreAnimationTime", ref ScoreAnimationTime); - xmlReader.TryGetEnumValue("//root/Game/TimerMode", ref TimerMode); - xmlReader.TryGetIntValue("//root/Game/NumPlayer", ref NumPlayers); - xmlReader.TryGetEnumValue("//root/Game/Tabs", ref Tabs); - xmlReader.GetValue("//root/Game/Language", out Language, Language); - xmlReader.TryGetEnumValue("//root/Game/LyricsPosition", ref LyricsPosition); - xmlReader.TryGetFloatValue("//root/Game/MinLineBreakTime", ref MinLineBreakTime); + if (Config.Game.MinLineBreakTime < 0) + Config.Game.MinLineBreakTime = 0.1f; - if ((ScoreAnimationTime > 0 && ScoreAnimationTime < 1) || ScoreAnimationTime < 0) - ScoreAnimationTime = 1; + if (Config.Game.NumPlayers < 1 || Config.Game.NumPlayers > CSettings.MaxNumPlayer) + Config.Game.NumPlayers = 2; + Array.Resize(ref Config.Game.Players, CSettings.MaxNumPlayer); - if (MinLineBreakTime < 0) - MinLineBreakTime = 0.1f; - - if (NumPlayers < 1 || NumPlayers > CSettings.MaxNumPlayer) - NumPlayers = 2; - - bool langExists = CLanguage.SetLanguage(Language); + bool langExists = CLanguage.SetLanguage(Config.Game.Language); if (langExists == false) { - Language = CSettings.FallbackLanguage; - CLanguage.SetLanguage(Language); + Config.Game.Language = CSettings.FallbackLanguage; + CLanguage.SetLanguage(Config.Game.Language); } - //Read players from config - for (i = 1; i <= CSettings.MaxNumPlayer; i++) - xmlReader.GetValue("//root/Game/Players/Player" + i, out Players[i - 1], String.Empty); - #endregion Game + Config.Record.MicDelay = (int)(20 * Math.Round(Config.Record.MicDelay / 20.0)); - #region Video - xmlReader.TryGetEnumValue("//root/Video/VideoDecoder", ref VideoDecoder); - xmlReader.TryGetEnumValue("//root/Video/VideoBackgrounds", ref VideoBackgrounds); - xmlReader.TryGetEnumValue("//root/Video/VideoPreview", ref VideoPreview); - xmlReader.TryGetEnumValue("//root/Video/VideosInSongs", ref VideosInSongs); - xmlReader.TryGetEnumValue("//root/Video/VideosToBackground", ref VideosToBackground); + if (Config.Server.ServerPort < 1 || Config.Server.ServerPort > 65535) + Config.Server.ServerPort = 3000; - xmlReader.TryGetEnumValue("//root/Video/WebcamLib", ref WebcamLib); - WebcamConfig = new SWebcamConfig(); - xmlReader.GetValue("//root/Video/WebcamConfig/MonikerString", out WebcamConfig.MonikerString, String.Empty); - xmlReader.TryGetIntValue("//root/Video/WebcamConfig/Framerate", ref WebcamConfig.Framerate); - xmlReader.TryGetIntValue("//root/Video/WebcamConfig/Width", ref WebcamConfig.Width); - xmlReader.TryGetIntValue("//root/Video/WebcamConfig/Height", ref WebcamConfig.Height); - #endregion Video - - #region Record - for (int p = 1; p <= CSettings.MaxNumPlayer; p++) - { - MicConfig[p - 1] = new SMicConfig(0); - xmlReader.GetValue("//root/Record/MicConfig" + p + "/DeviceName", out MicConfig[p - 1].DeviceName, String.Empty); - xmlReader.GetValue("//root/Record/MicConfig" + p + "/DeviceDriver", out MicConfig[p - 1].DeviceDriver, String.Empty); - xmlReader.TryGetIntValue("//root/Record/MicConfig" + p + "/Channel", ref MicConfig[p - 1].Channel); - } - - xmlReader.TryGetIntValueRange("//root/Record/MicDelay", ref MicDelay, 0, 500); - MicDelay = (int)(20 * Math.Round(MicDelay / 20.0)); - #endregion Record - - #region Server - xmlReader.TryGetEnumValue("//root/Server/ServerActive", ref ServerActive); - xmlReader.TryGetEnumValue("//root/Server/ServerEncryption", ref ServerEncryption); - xmlReader.TryGetIntValue("//root/Server/ServerPort", ref ServerPort); - if (ServerPort < 1 || ServerPort > 65535) - ServerPort = 3000; - - //xmlReader.GetValue("//root/Server/ServerPassword", out ServerPassword, ServerPassword); - #endregion Server + Config.Info = new SConfigInfo + { + Version = CSettings.GetFullVersionText(), + Time = DateTime.Now.ToString(), + Platform = Environment.OSVersion.Platform.ToString(), + OSVersion = Environment.OSVersion.ToString(), + ProcessorCount = Environment.ProcessorCount, + Screens = Screen.AllScreens.Length, + PrimaryScreenResolution = Screen.PrimaryScreen.Bounds.Size.ToString(), + Directory = CSettings.ProgramFolder + }; } - public static bool SaveConfig() + private static string _GetComment(string elName) { - XmlWriter writer = null; - try + switch (elName) { - writer = XmlWriter.Create(_FileConfig, XMLSettings); - writer.WriteStartDocument(); - writer.WriteStartElement("root"); - - - writer.WriteStartElement("Info"); - - writer.WriteElementString("Version", CSettings.GetFullVersionText()); - writer.WriteElementString("Time", DateTime.Now.ToString()); - writer.WriteElementString("Platform", Environment.OSVersion.Platform.ToString()); - writer.WriteElementString("OSVersion", Environment.OSVersion.ToString()); - writer.WriteElementString("ProcessorCount", Environment.ProcessorCount.ToString()); - - writer.WriteElementString("Screens", Screen.AllScreens.Length.ToString()); - writer.WriteElementString("PrimaryScreenResolution", Screen.PrimaryScreen.Bounds.Size.ToString()); - - writer.WriteElementString("Directory", CSettings.ProgramFolder); - - writer.WriteEndElement(); - - #region Debug - writer.WriteStartElement("Debug"); - - writer.WriteComment("DebugLevel: " + CHelper.ListStrings(Enum.GetNames(typeof(EDebugLevel)))); - writer.WriteElementString("DebugLevel", Enum.GetName(typeof(EDebugLevel), DebugLevel)); - - writer.WriteComment("SaveModifiedSongs: " + CHelper.ListStrings(Enum.GetNames(typeof(EOffOn)))); - writer.WriteElementString("SaveModifiedSongs", Enum.GetName(typeof(EOffOn), SaveModifiedSongs)); - - writer.WriteEndElement(); - #endregion Debug - - #region Graphics - writer.WriteStartElement("Graphics"); - - writer.WriteComment("Renderer: " + CHelper.ListStrings(Enum.GetNames(typeof(ERenderer)))); - writer.WriteElementString("Renderer", Enum.GetName(typeof(ERenderer), Renderer)); - - writer.WriteComment("TextureQuality: " + CHelper.ListStrings(Enum.GetNames(typeof(ETextureQuality)))); - writer.WriteElementString("TextureQuality", Enum.GetName(typeof(ETextureQuality), TextureQuality)); - - writer.WriteComment("CoverSize (pixels): 32, 64, 128, 256, 512, 1024 (default: 128)"); - writer.WriteElementString("CoverSize", CoverSize.ToString()); - - writer.WriteComment("Screen width and height (pixels)"); - writer.WriteElementString("ScreenW", ScreenW.ToString()); - writer.WriteElementString("ScreenH", ScreenH.ToString()); - - writer.WriteElementString("ScreenAlignment", Enum.GetName(typeof(EGeneralAlignment), ScreenAlignment)); - - writer.WriteComment("Screen borders (pixels)"); - writer.WriteElementString("BorderLeft", BorderLeft.ToString()); - writer.WriteElementString("BorderRight", BorderRight.ToString()); - writer.WriteElementString("BorderTop", BorderTop.ToString()); - writer.WriteElementString("BorderBottom", BorderBottom.ToString()); - - writer.WriteComment("AAMode: " + CHelper.ListStrings(Enum.GetNames(typeof(EAntiAliasingModes)))); - writer.WriteElementString("AAMode", Enum.GetName(typeof(EAntiAliasingModes), AAMode)); - - writer.WriteComment("MaxFPS should be between 1..200"); - writer.WriteElementString("MaxFPS", MaxFPS.ToString("#")); - - writer.WriteComment("VSync: " + CHelper.ListStrings(Enum.GetNames(typeof(EOffOn)))); - writer.WriteElementString("VSync", Enum.GetName(typeof(EOffOn), VSync)); - - writer.WriteComment("FullScreen: " + CHelper.ListStrings(Enum.GetNames(typeof(EOffOn)))); - writer.WriteElementString("FullScreen", Enum.GetName(typeof(EOffOn), FullScreen)); - - writer.WriteComment("FadeTime should be between 0..3 Seconds"); - writer.WriteElementString("FadeTime", FadeTime.ToString("#0.00")); - - writer.WriteEndElement(); - #endregion Graphics - - #region Theme - writer.WriteStartElement("Theme"); - - writer.WriteComment("Theme name"); - writer.WriteElementString("Name", Theme); - - writer.WriteComment("Skin name"); - writer.WriteElementString("Skin", Skin); - - writer.WriteComment("Name of cover-theme"); - writer.WriteElementString("Cover", CoverTheme); - - writer.WriteComment("Draw note-lines: " + CHelper.ListStrings(Enum.GetNames(typeof(EOffOn)))); - writer.WriteElementString("DrawNoteLines", Enum.GetName(typeof(EOffOn), DrawNoteLines)); - - writer.WriteComment("Draw tone-helper: " + CHelper.ListStrings(Enum.GetNames(typeof(EOffOn)))); - writer.WriteElementString("DrawToneHelper", Enum.GetName(typeof(EOffOn), DrawToneHelper)); - - writer.WriteComment("Look of timer: " + CHelper.ListStrings(Enum.GetNames(typeof(ETimerLook)))); - writer.WriteElementString("TimerLook", Enum.GetName(typeof(ETimerLook), TimerLook)); - - writer.WriteComment("Information about players on SingScreen: " + CHelper.ListStrings(Enum.GetNames(typeof(EPlayerInfo)))); - writer.WriteElementString("PlayerInfo", Enum.GetName(typeof(EPlayerInfo), PlayerInfo)); - - writer.WriteComment("Fade player-information with lyrics and notebars: " + CHelper.ListStrings(Enum.GetNames(typeof(EFadePlayerInfo)))); - writer.WriteElementString("FadePlayerInfo", Enum.GetName(typeof(EFadePlayerInfo), FadePlayerInfo)); - - writer.WriteComment("Cover Loading: " + CHelper.ListStrings(Enum.GetNames(typeof(ECoverLoading)))); - writer.WriteElementString("CoverLoading", Enum.GetName(typeof(ECoverLoading), CoverLoading)); - - writer.WriteComment("Lyric Style: " + CHelper.ListStrings(Enum.GetNames(typeof(ELyricStyle)))); - writer.WriteElementString("LyricStyle", Enum.GetName(typeof(ELyricStyle), LyricStyle)); - - writer.WriteEndElement(); - #endregion Theme - - #region Sound - writer.WriteStartElement("Sound"); - - writer.WriteComment("PlayBackLib: " + CHelper.ListStrings(Enum.GetNames(typeof(EPlaybackLib)))); - writer.WriteElementString("PlayBackLib", Enum.GetName(typeof(EPlaybackLib), PlayBackLib)); - - writer.WriteComment("RecordLib: " + CHelper.ListStrings(Enum.GetNames(typeof(ERecordLib)))); - writer.WriteElementString("RecordLib", Enum.GetName(typeof(ERecordLib), RecordLib)); - - writer.WriteComment("AudioBufferSize: " + CHelper.ListStrings(Enum.GetNames(typeof(EBufferSize)))); - writer.WriteElementString("AudioBufferSize", Enum.GetName(typeof(EBufferSize), AudioBufferSize)); - - writer.WriteComment("AudioLatency from -500 to 500 ms"); - writer.WriteElementString("AudioLatency", AudioLatency.ToString()); - - writer.WriteComment("Background Music: " + CHelper.ListStrings(Enum.GetNames(typeof(EBackgroundMusicOffOn)))); - writer.WriteElementString("BackgroundMusic", Enum.GetName(typeof(EBackgroundMusicOffOn), BackgroundMusic)); - - writer.WriteComment("Background Music Volume from 0 to 100"); - writer.WriteElementString("BackgroundMusicVolume", BackgroundMusicVolume.ToString()); - - writer.WriteComment("Background Music Source: " + CHelper.ListStrings(Enum.GetNames(typeof(EBackgroundMusicSource)))); - writer.WriteElementString("BackgroundMusicSource", Enum.GetName(typeof(EBackgroundMusicSource), BackgroundMusicSource)); - - writer.WriteComment("Background Music use start-tag of songs: " + CHelper.ListStrings(Enum.GetNames(typeof(EOffOn)))); - writer.WriteElementString("BackgroundMusicUseStart", Enum.GetName(typeof(EOffOn), BackgroundMusicUseStart)); - - writer.WriteComment("Preview Volume from 0 to 100"); - writer.WriteElementString("PreviewMusicVolume", PreviewMusicVolume.ToString()); - - writer.WriteComment("Game Volume from 0 to 100"); - writer.WriteElementString("GameMusicVolume", GameMusicVolume.ToString()); - - writer.WriteEndElement(); - #endregion Sound - - #region Game - writer.WriteStartElement("Game"); - - writer.WriteComment("Game-Language:"); - writer.WriteElementString("Language", Language); - - // SongFolder - 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)); - - writer.WriteComment("SongSorting: " + CHelper.ListStrings(Enum.GetNames(typeof(ESongSorting)))); - writer.WriteElementString("SongSorting", Enum.GetName(typeof(ESongSorting), SongSorting)); - - writer.WriteComment("Ignore articles on song-sorting: " + CHelper.ListStrings(Enum.GetNames(typeof(EOffOn)))); - writer.WriteElementString("IgnoreArticles", Enum.GetName(typeof(EOffOn), IgnoreArticles)); - - writer.WriteComment("ScoreAnimationTime: Values >= 1 or 0 for no animation. Time is in seconds."); - writer.WriteElementString("ScoreAnimationTime", ScoreAnimationTime.ToString()); - - writer.WriteComment("TimerMode: " + CHelper.ListStrings(Enum.GetNames(typeof(ETimerMode)))); - writer.WriteElementString("TimerMode", Enum.GetName(typeof(ETimerMode), TimerMode)); - - writer.WriteComment("NumPlayer: 1.." + CSettings.MaxNumPlayer); - writer.WriteElementString("NumPlayer", NumPlayers.ToString()); - - writer.WriteComment("Order songs in tabs: " + CHelper.ListStrings(Enum.GetNames(typeof(EOffOn)))); - writer.WriteElementString("Tabs", Enum.GetName(typeof(EOffOn), Tabs)); - - writer.WriteComment("Position if lyrics on screen: " + CHelper.ListStrings(Enum.GetNames(typeof(ELyricsPosition)))); - writer.WriteElementString("LyricsPosition", Enum.GetName(typeof(ELyricsPosition), LyricsPosition)); - - writer.WriteComment("MinLineBreakTime: Value >= 0 in s. Minimum time the text is shown before it is to be sung"); - writer.WriteElementString("MinLineBreakTime", MinLineBreakTime.ToString()); - - writer.WriteComment("Default profile for players 1..." + CSettings.MaxNumPlayer + ":"); - writer.WriteStartElement("Players"); - for (int i = 1; i <= CSettings.MaxNumPlayer; i++) - writer.WriteElementString("Player" + i, Path.GetFileName(Players[i - 1])); - writer.WriteEndElement(); - - writer.WriteEndElement(); - #endregion Game - - #region Video - writer.WriteStartElement("Video"); - - writer.WriteComment("VideoDecoder: " + CHelper.ListStrings(Enum.GetNames(typeof(EVideoDecoder)))); - writer.WriteElementString("VideoDecoder", Enum.GetName(typeof(EVideoDecoder), VideoDecoder)); - - writer.WriteComment("VideoBackgrounds: " + CHelper.ListStrings(Enum.GetNames(typeof(EOffOn)))); - writer.WriteElementString("VideoBackgrounds", Enum.GetName(typeof(EOffOn), VideoBackgrounds)); - - writer.WriteComment("VideoPreview: " + CHelper.ListStrings(Enum.GetNames(typeof(EOffOn)))); - writer.WriteElementString("VideoPreview", Enum.GetName(typeof(EOffOn), VideoPreview)); - - writer.WriteComment("Show Videos while singing: " + CHelper.ListStrings(Enum.GetNames(typeof(EOffOn)))); - writer.WriteElementString("VideosInSongs", Enum.GetName(typeof(EOffOn), VideosInSongs)); - - writer.WriteComment("Show backgroundmusic videos as background: " + CHelper.ListStrings(Enum.GetNames(typeof(EOffOn)))); - writer.WriteElementString("VideosToBackground", Enum.GetName(typeof(EOffOn), VideosToBackground)); - - writer.WriteComment("WebcamLib: " + CHelper.ListStrings(Enum.GetNames(typeof(EWebcamLib)))); - writer.WriteElementString("WebcamLib", Enum.GetName(typeof(EWebcamLib), WebcamLib)); - - writer.WriteStartElement("WebcamConfig"); - - writer.WriteElementString("MonikerString", WebcamConfig.MonikerString); - writer.WriteElementString("Framerate", WebcamConfig.Framerate.ToString()); - writer.WriteElementString("Width", WebcamConfig.Width.ToString()); - writer.WriteElementString("Height", WebcamConfig.Height.ToString()); - - writer.WriteEndElement(); - - writer.WriteEndElement(); - #endregion Video - - #region Record - writer.WriteStartElement("Record"); - - for (int p = 1; p <= CSettings.MaxNumPlayer; p++) - { - if (MicConfig[p - 1].DeviceName != "" && MicConfig[p - 1].Channel > 0) - { - writer.WriteStartElement("MicConfig" + p); - - writer.WriteElementString("DeviceName", MicConfig[p - 1].DeviceName); - writer.WriteElementString("DeviceDriver", MicConfig[p - 1].DeviceDriver); - writer.WriteElementString("Channel", MicConfig[p - 1].Channel.ToString()); - - writer.WriteEndElement(); - } - } - - writer.WriteComment("Mic delay in ms. 0, 20, 40, 60 ... 500"); - writer.WriteElementString("MicDelay", MicDelay.ToString()); - - writer.WriteEndElement(); - #endregion Record - - #region Server - writer.WriteStartElement("Server"); - - writer.WriteComment("Server On/Off: " + CHelper.ListStrings(Enum.GetNames(typeof(EOffOn)))); - writer.WriteElementString("ServerActive", Enum.GetName(typeof(EOffOn), ServerActive)); - - writer.WriteComment("Server Encryption On/Off: " + CHelper.ListStrings(Enum.GetNames(typeof(EOffOn)))); - writer.WriteElementString("ServerEncryption", Enum.GetName(typeof(EOffOn), ServerEncryption)); - - writer.WriteComment("Server Port (default: 3000) [1..65535]"); - writer.WriteElementString("ServerPort", ServerPort.ToString()); - - //writer.WriteComment("Server Password (default: vocaluxe)"); - //writer.WriteElementString("ServerPassword", ServerPassword); - - writer.WriteEndElement(); - #endregion Server - - // End of File - writer.WriteEndElement(); //end of root - writer.WriteEndDocument(); - writer.Flush(); - writer.Close(); - writer = null; + case "DebugLevel": + return "DebugLevel: " + CHelper.ListStrings(Enum.GetNames(typeof(EDebugLevel))); + case "SaveModifiedSongs": + return "SaveModifiedSongs: " + CHelper.ListStrings(Enum.GetNames(typeof(EOffOn))); + case "Renderer": + return "Renderer: " + CHelper.ListStrings(Enum.GetNames(typeof(ERenderer))); + case "TextureQuality": + return "TextureQuality: " + CHelper.ListStrings(Enum.GetNames(typeof(ETextureQuality))); + case "CoverSize": + return "CoverSize (pixels): 32, 64, 128, 256, 512, 1024 (default: 128)"; + case "ScreenW": + return "Screen width and height (pixels)"; + case "BorderLeft": + return "Screen borders (pixels)"; + case "AAMode": + return "AAMode: " + CHelper.ListStrings(Enum.GetNames(typeof(EAntiAliasingModes))); + case "MaxFPS": + return "MaxFPS should be between 1..200"; + case "VSync": + return "VSync: " + CHelper.ListStrings(Enum.GetNames(typeof(EOffOn))); + case "FullScreen": + return "FullScreen: " + CHelper.ListStrings(Enum.GetNames(typeof(EOffOn))); + case "FadeTime": + return "FadeTime should be between 0..3 Seconds"; + case "Theme": + return "Theme name"; + case "Skin": + return "Skin name"; + case "Cover": + return "Name of cover-theme"; + case "DrawNoteLines": + return "Draw note-lines: " + CHelper.ListStrings(Enum.GetNames(typeof(EOffOn))); + case "DrawToneHelper": + return "Draw tone-helper: " + CHelper.ListStrings(Enum.GetNames(typeof(EOffOn))); + case "TimerLook": + return "Look of timer: " + CHelper.ListStrings(Enum.GetNames(typeof(ETimerLook))); + case "PlayerInfo": + return "Information about players on SingScreen: " + CHelper.ListStrings(Enum.GetNames(typeof(EPlayerInfo))); + case "FadePlayerInfo": + return "Fade player-information with lyrics and notebars: " + CHelper.ListStrings(Enum.GetNames(typeof(EFadePlayerInfo))); + case "CoverLoading": + return "Cover Loading: " + CHelper.ListStrings(Enum.GetNames(typeof(ECoverLoading))); + case "LyricStyle": + return "Lyric Style: " + CHelper.ListStrings(Enum.GetNames(typeof(ELyricStyle))); + case "PlayBackLib": + return "PlayBackLib: " + CHelper.ListStrings(Enum.GetNames(typeof(EPlaybackLib))); + case "RecordLib": + return "RecordLib: " + CHelper.ListStrings(Enum.GetNames(typeof(ERecordLib))); + case "AudioBufferSize": + return "AudioBufferSize: " + CHelper.ListStrings(Enum.GetNames(typeof(EBufferSize))); + case "AudioLatency": + return "AudioLatency from -500 to 500 ms"; + case "BackgroundMusic": + return "Background Music: " + CHelper.ListStrings(Enum.GetNames(typeof(EBackgroundMusicOffOn))); + case "BackgroundMusicVolume": + return "Background Music Volume from 0 to 100"; + case "BackgroundMusicSource": + return "Background Music Source: " + CHelper.ListStrings(Enum.GetNames(typeof(EBackgroundMusicSource))); + case "BackgroundMusicUseStart": + return "Background Music use start-tag of songs " + CHelper.ListStrings(Enum.GetNames(typeof(EOffOn))); + case "PreviewMusicVolume": + return "Preview Volume from 0 to 100"; + case "GameMusicVolume": + return "Game Volume from 0 to 100"; + case "Language": + return "Game-Language"; + case "SongFolder": + return "SongFolder: SongFolder1, SongFolder2, SongFolder3, ..."; + case "SongMenu": + return "SongMenu: " + CHelper.ListStrings(Enum.GetNames(typeof(ESongMenu))); + case "SongSorting": + return "SongSorting: " + CHelper.ListStrings(Enum.GetNames(typeof(ESongSorting))); + case "IgnoreArticles": + return "Ignore articles on song-sorting: " + CHelper.ListStrings(Enum.GetNames(typeof(EOffOn))); + case "ScoreAnimationTime": + return "ScoreAnimationTime: Values >= 1 or 0 for no animation. Time is in seconds."; + case "TimerMode": + return "TimerMode: " + CHelper.ListStrings(Enum.GetNames(typeof(ETimerMode))); + case "NumPlayers": + return "NumPlayers: 1.." + CSettings.MaxNumPlayer; + case "Tabs": + return "Order songs in tabs: " + CHelper.ListStrings(Enum.GetNames(typeof(EOffOn))); + case "LyricsPosition": + return "Position if lyrics on screen: " + CHelper.ListStrings(Enum.GetNames(typeof(ELyricsPosition))); + case "MinLineBreakTime": + return "MinLineBreakTime: Value >= 0 in s. Minimum time the text is shown before it is to be sung"; + case "Players": + return "Default profile for players 1..." + CSettings.MaxNumPlayer + ":"; + case "VideoDecoder": + return "VideoDecoder: " + CHelper.ListStrings(Enum.GetNames(typeof(EVideoDecoder))); + case "VideoBackgrounds": + return "VideoBackgrounds: " + CHelper.ListStrings(Enum.GetNames(typeof(EOffOn))); + case "VideoPreview": + return "VideoPreview: " + CHelper.ListStrings(Enum.GetNames(typeof(EOffOn))); + case "VideosInSongs": + return "Show Videos while singing: " + CHelper.ListStrings(Enum.GetNames(typeof(EOffOn))); + case "VideosToBackground": + return "Show backgroundmusic videos as background: " + CHelper.ListStrings(Enum.GetNames(typeof(EOffOn))); + case "WebcamLib": + return "WebcamLib: " + CHelper.ListStrings(Enum.GetNames(typeof(EWebcamLib))); + case "MicDelay": + return "Mic delay in ms. 0, 20, 40, 60 ... 500"; + case "ServerActive": + return "Server On/Off: " + CHelper.ListStrings(Enum.GetNames(typeof(EOffOn))); + case "ServerEncryption": + return "Server Encryption On/Off: " + CHelper.ListStrings(Enum.GetNames(typeof(EOffOn))); + case "ServerPort": + return "Server Port (default: 3000) [1..65535]"; + default: + return null; } - catch (Exception) - { - if (writer != null) - writer.Close(); - return false; - } - return true; + } + + public static void SaveConfig() + { + var xml = new CXmlSerializer(true, _GetComment); + xml.Serialize(_FileConfig, Config); } /// @@ -649,7 +433,7 @@ namespace Vocaluxe.Base /// public static float CalcCycleTime() { - return (1f / MaxFPS) * 1000f; + return (1f / Config.Graphics.MaxFPS) * 1000f; } /// @@ -711,14 +495,16 @@ namespace Vocaluxe.Base //Check if there is one or more channels if (device.Channels >= 2) { + if (Config.Record.MicConfig.Length < 2) + Config.Record.MicConfig = new SMicConfig[2]; //Set this device to player 1 - MicConfig[0].DeviceName = device.Name; - MicConfig[0].DeviceDriver = device.Driver; - MicConfig[0].Channel = 1; + Config.Record.MicConfig[0].DeviceName = device.Name; + Config.Record.MicConfig[0].DeviceDriver = device.Driver; + Config.Record.MicConfig[0].Channel = 1; //Set this device to player 2 - MicConfig[1].DeviceName = device.Name; - MicConfig[1].DeviceDriver = device.Driver; - MicConfig[1].Channel = 2; + Config.Record.MicConfig[1].DeviceName = device.Name; + Config.Record.MicConfig[1].DeviceDriver = device.Driver; + Config.Record.MicConfig[1].Channel = 2; return true; } @@ -734,16 +520,16 @@ namespace Vocaluxe.Base if (device.Channels >= 1) { //Set this device to player 1 - MicConfig[0].DeviceName = device.Name; - MicConfig[0].DeviceDriver = device.Driver; - MicConfig[0].Channel = 1; + Config.Record.MicConfig[0].DeviceName = device.Name; + Config.Record.MicConfig[0].DeviceDriver = device.Driver; + Config.Record.MicConfig[0].Channel = 1; if (device.Channels >= 2) { //Set this device to player 2 - MicConfig[1].DeviceName = device.Name; - MicConfig[1].DeviceDriver = device.Driver; - MicConfig[1].Channel = 2; + Config.Record.MicConfig[1].DeviceName = device.Name; + Config.Record.MicConfig[1].DeviceDriver = device.Driver; + Config.Record.MicConfig[1].Channel = 2; return true; } @@ -901,12 +687,12 @@ namespace Vocaluxe.Base for (int j = 0; j < CSettings.MaxNumPlayer; j++) { CGame.Players[j].ProfileID = -1; - if (Players[j] == "") + if (string.IsNullOrEmpty(Config.Game.Players[j])) continue; foreach (CProfile profile in profiles) { - if (Path.GetFileName(profile.FileName) == Players[j] && profile.Active == EOffOn.TR_CONFIG_ON) + if (Path.GetFileName(profile.FileName) == Config.Game.Players[j] && profile.Active == EOffOn.TR_CONFIG_ON) { //Update Game-infos with player CGame.Players[j].ProfileID = profile.ID; diff --git a/Vocaluxe/Base/CCover.cs b/Vocaluxe/Base/CCover.cs index 3c71aa57..835c0bee 100644 --- a/Vocaluxe/Base/CCover.cs +++ b/Vocaluxe/Base/CCover.cs @@ -46,7 +46,7 @@ namespace Vocaluxe.Base public static void Init() { _LoadCoverThemes(); - _LoadCovers(CConfig.CoverTheme); + _LoadCovers(CConfig.Config.Theme.CoverTheme); } public static void Close() @@ -79,7 +79,7 @@ namespace Vocaluxe.Base { for (int i = 0; i < _CoverThemes.Count; i++) { - if (_CoverThemes[i].Name == CConfig.CoverTheme) + if (_CoverThemes[i].Name == CConfig.Config.Theme.CoverTheme) return i; } return -1; @@ -137,7 +137,7 @@ namespace Vocaluxe.Base public static void ReloadCovers() { _UnloadCovers(); - _LoadCovers(CConfig.CoverTheme); + _LoadCovers(CConfig.Config.Theme.CoverTheme); } private static void _UnloadCovers() @@ -178,21 +178,18 @@ namespace Vocaluxe.Base private static void _TestNewLoad(string path) { SThemeCover themeCover; - using (var stream = new FileStream(path, FileMode.Open)) - themeCover = CXmlSerializer.Deserialize(stream); - CXmlSerializer.Serialize(path + "2", themeCover); + var xml = new CXmlSerializer(); + themeCover = xml.Deserialize(path); + xml.Serialize(path + "2", themeCover); string cover = themeCover.Info.Author; STheme theme = new STheme(); STheme theme2 = new STheme(); Stopwatch watch = new Stopwatch(); watch.Start(); for (int i = 0; i < 1; i++) - { - using (var stream = new StreamReader(Path.Combine(CBase.Themes.GetThemeScreensPath(-1), "ScreenMain.xml"))) - theme = CXmlSerializer.Deserialize(stream); - } + theme = xml.Deserialize(Path.Combine(CBase.Themes.GetThemeScreensPath(-1), "ScreenMain.xml")); watch.Stop(); - CXmlSerializer.Serialize(Path.Combine(CBase.Themes.GetThemeScreensPath(-1), "ScreenMain2.xml"),theme); + xml.Serialize(Path.Combine(CBase.Themes.GetThemeScreensPath(-1), "ScreenMain2.xml"), theme); return; Stopwatch watch2 = new Stopwatch(); watch2.Start(); diff --git a/Vocaluxe/Base/CDraw.cs b/Vocaluxe/Base/CDraw.cs index 2586ab5a..7b3b58d1 100644 --- a/Vocaluxe/Base/CDraw.cs +++ b/Vocaluxe/Base/CDraw.cs @@ -35,7 +35,7 @@ namespace Vocaluxe.Base { if (_Draw != null) return false; - switch (CConfig.Renderer) + switch (CConfig.Config.Graphics.Renderer) { case ERenderer.TR_CONFIG_SOFTWARE: _Draw = new CDrawWinForm(); diff --git a/Vocaluxe/Base/CGame.cs b/Vocaluxe/Base/CGame.cs index bcbc8477..b4d7655f 100644 --- a/Vocaluxe/Base/CGame.cs +++ b/Vocaluxe/Base/CGame.cs @@ -30,7 +30,7 @@ namespace Vocaluxe.Base static class CGame { private static ISongQueue _SongQueue; - private static int _NumPlayers = CConfig.NumPlayers; + private static int _NumPlayers = CConfig.Config.Game.NumPlayers; /// /// Last beat that has been evaluated @@ -222,7 +222,7 @@ namespace Vocaluxe.Base CurrentBeatF = b; - MidRecordedBeat = -0.5f + GetBeatFromTime(time, song.BPM, song.Gap + CConfig.MicDelay / 1000f); + MidRecordedBeat = -0.5f + GetBeatFromTime(time, song.BPM, song.Gap + CConfig.Config.Record.MicDelay / 1000f); for (int p = 0; p < _NumPlayers; p++) CRecord.AnalyzeBuffer(p); diff --git a/Vocaluxe/Base/CGraphics.cs b/Vocaluxe/Base/CGraphics.cs index 0072acfb..e0dfeda7 100644 --- a/Vocaluxe/Base/CGraphics.cs +++ b/Vocaluxe/Base/CGraphics.cs @@ -218,7 +218,7 @@ namespace Vocaluxe.Base { if (_NextScreen != EScreens.ScreenNull && _Fading == null) { - _Fading = new CFading(0f, 1f, CConfig.FadeTime); + _Fading = new CFading(0f, 1f, CConfig.Config.Graphics.FadeTime); if (_NextScreen == EScreens.ScreenPartyDummy) { @@ -343,13 +343,13 @@ namespace Vocaluxe.Base bool popupPlayerControlAllowed = _CurrentScreen != EScreens.ScreenOptionsRecord && _CurrentScreen != EScreens.ScreenSing && (_CurrentScreen != EScreens.ScreenSong || - (_CurrentScreen == EScreens.ScreenSong && !CSongs.IsInCategory && CConfig.Tabs == EOffOn.TR_CONFIG_ON)) + (_CurrentScreen == EScreens.ScreenSong && !CSongs.IsInCategory && CConfig.Config.Game.Tabs == EOffOn.TR_CONFIG_ON)) && _CurrentScreen != EScreens.ScreenCredits && !CBackgroundMusic.Disabled; bool popupVolumeControlAllowed = _CurrentScreen != EScreens.ScreenCredits && _CurrentScreen != EScreens.ScreenOptionsRecord; //Hide volume control for bg-music if bg-music is disabled if (popupVolumeControlAllowed && (_CurrentScreen != EScreens.ScreenSong || CSongs.Category == -1) - && _CurrentScreen != EScreens.ScreenSing && CConfig.BackgroundMusic == EBackgroundMusicOffOn.TR_CONFIG_OFF) + && _CurrentScreen != EScreens.ScreenSing && CConfig.Config.Sound.BackgroundMusic == EBackgroundMusicOffOn.TR_CONFIG_OFF) popupVolumeControlAllowed = false; @@ -372,43 +372,44 @@ namespace Vocaluxe.Base { case Keys.Right: if (keyEvent.ModShift) - CConfig.BorderLeft++; + CConfig.Config.Graphics.BorderLeft++; else - CConfig.BorderRight--; + CConfig.Config.Graphics.BorderRight--; break; case Keys.Left: if (keyEvent.ModShift) - CConfig.BorderLeft--; + CConfig.Config.Graphics.BorderLeft--; else - CConfig.BorderRight++; + CConfig.Config.Graphics.BorderRight++; break; case Keys.Down: if (keyEvent.ModShift) - CConfig.BorderTop++; + CConfig.Config.Graphics.BorderTop++; else - CConfig.BorderBottom--; + CConfig.Config.Graphics.BorderBottom--; break; case Keys.Up: if (keyEvent.ModShift) - CConfig.BorderTop--; + CConfig.Config.Graphics.BorderTop--; else - CConfig.BorderBottom++; + CConfig.Config.Graphics.BorderBottom++; break; case Keys.D0: case Keys.NumPad0: - CConfig.BorderLeft = CConfig.BorderRight = CConfig.BorderTop = CConfig.BorderBottom = 0; + CConfig.Config.Graphics.BorderLeft = + CConfig.Config.Graphics.BorderRight = CConfig.Config.Graphics.BorderTop = CConfig.Config.Graphics.BorderBottom = 0; break; case Keys.Add: - switch (CConfig.ScreenAlignment) + switch (CConfig.Config.Graphics.ScreenAlignment) { case EGeneralAlignment.Middle: - CConfig.ScreenAlignment = EGeneralAlignment.End; + CConfig.Config.Graphics.ScreenAlignment = EGeneralAlignment.End; break; case EGeneralAlignment.End: - CConfig.ScreenAlignment = EGeneralAlignment.Start; + CConfig.Config.Graphics.ScreenAlignment = EGeneralAlignment.Start; break; default: - CConfig.ScreenAlignment = EGeneralAlignment.Middle; + CConfig.Config.Graphics.ScreenAlignment = EGeneralAlignment.Middle; break; } break; @@ -428,13 +429,13 @@ namespace Vocaluxe.Base if (popupPlayerControlAllowed && keyEvent.Key == Keys.Tab) { - if (_CurrentPopupScreen == EPopupScreens.NoPopup && CConfig.BackgroundMusic == EBackgroundMusicOffOn.TR_CONFIG_ON) + if (_CurrentPopupScreen == EPopupScreens.NoPopup && CConfig.Config.Sound.BackgroundMusic == EBackgroundMusicOffOn.TR_CONFIG_ON) ShowPopup(EPopupScreens.PopupPlayerControl); else HidePopup(EPopupScreens.PopupPlayerControl); } - if (popupPlayerControlAllowed && CConfig.BackgroundMusic != EBackgroundMusicOffOn.TR_CONFIG_OFF) + if (popupPlayerControlAllowed && CConfig.Config.Sound.BackgroundMusic != EBackgroundMusicOffOn.TR_CONFIG_OFF) { if (keyEvent.Key == Keys.MediaNextTrack) CBackgroundMusic.Next(); @@ -499,7 +500,7 @@ namespace Vocaluxe.Base if (keyEvent.ModShift && (keyEvent.Key == Keys.F1)) CSettings.ProgramState = EProgramState.EditTheme; else if (keyEvent.ModAlt && (keyEvent.Key == Keys.Enter)) - CConfig.FullScreen = (CConfig.FullScreen == EOffOn.TR_CONFIG_ON) ? EOffOn.TR_CONFIG_OFF : EOffOn.TR_CONFIG_ON; + CConfig.Config.Graphics.FullScreen = (CConfig.Config.Graphics.FullScreen == EOffOn.TR_CONFIG_ON) ? EOffOn.TR_CONFIG_OFF : EOffOn.TR_CONFIG_ON; else if (keyEvent.ModAlt && (keyEvent.Key == Keys.P)) CDraw.MakeScreenShot(); else @@ -534,7 +535,7 @@ namespace Vocaluxe.Base bool isOverPopupPlayerControl = CHelper.IsInBounds(_PopupScreens[(int)EPopupScreens.PopupPlayerControl].ScreenArea, mouseEvent); if (popupPlayerControlAllowed && isOverPopupPlayerControl) { - if (_CurrentPopupScreen == EPopupScreens.NoPopup && CConfig.BackgroundMusic == EBackgroundMusicOffOn.TR_CONFIG_ON) + if (_CurrentPopupScreen == EPopupScreens.NoPopup && CConfig.Config.Sound.BackgroundMusic == EBackgroundMusicOffOn.TR_CONFIG_ON) ShowPopup(EPopupScreens.PopupPlayerControl); } @@ -589,7 +590,7 @@ namespace Vocaluxe.Base _Screens[(int)_CurrentScreen].NextElement(); } else if (keyEvent.ModAlt && (keyEvent.Key == Keys.Enter)) - CConfig.FullScreen = (CConfig.FullScreen == EOffOn.TR_CONFIG_ON) ? EOffOn.TR_CONFIG_OFF : EOffOn.TR_CONFIG_ON; + CConfig.Config.Graphics.FullScreen = (CConfig.Config.Graphics.FullScreen == EOffOn.TR_CONFIG_ON) ? EOffOn.TR_CONFIG_OFF : EOffOn.TR_CONFIG_ON; else if (keyEvent.ModAlt && (keyEvent.Key == Keys.P)) CDraw.MakeScreenShot(); else @@ -632,12 +633,12 @@ namespace Vocaluxe.Base private static void _DrawDebugInfos() { - if (CConfig.DebugLevel == EDebugLevel.TR_CONFIG_OFF) + if (CConfig.Config.Debug.DebugLevel == EDebugLevel.TR_CONFIG_OFF) return; List debugOutput = new List {CTime.GetFPS().ToString("FPS: 000")}; - if (CConfig.DebugLevel >= EDebugLevel.TR_CONFIG_LEVEL1) + if (CConfig.Config.Debug.DebugLevel >= EDebugLevel.TR_CONFIG_LEVEL1) { debugOutput.Add(CSound.GetStreamCount().ToString(CLanguage.Translate("TR_DEBUG_AUDIO_STREAMS") + ": 00")); debugOutput.Add(CVideo.GetNumStreams().ToString(CLanguage.Translate("TR_DEBUG_VIDEO_STREAMS") + ": 00")); @@ -645,18 +646,18 @@ namespace Vocaluxe.Base long memory = GC.GetTotalMemory(false); debugOutput.Add((memory / 1000000L).ToString(CLanguage.Translate("TR_DEBUG_MEMORY") + ": 00000 MB")); - if (CConfig.DebugLevel >= EDebugLevel.TR_CONFIG_LEVEL2) + if (CConfig.Config.Debug.DebugLevel >= EDebugLevel.TR_CONFIG_LEVEL2) { debugOutput.Add(CRecord.GetToneAbs(0).ToString(CLanguage.Translate("TR_DEBUG_TONE_ABS") + " P1: 00")); debugOutput.Add(CRecord.GetMaxVolume(0).ToString(CLanguage.Translate("TR_DEBUG_MAX_VOLUME") + " P1: 0.000")); debugOutput.Add(CRecord.GetToneAbs(1).ToString(CLanguage.Translate("TR_DEBUG_TONE_ABS") + " P2: 00")); debugOutput.Add(CRecord.GetMaxVolume(1).ToString(CLanguage.Translate("TR_DEBUG_MAX_VOLUME") + " P2: 0.000")); - if (CConfig.DebugLevel >= EDebugLevel.TR_CONFIG_LEVEL3) + if (CConfig.Config.Debug.DebugLevel >= EDebugLevel.TR_CONFIG_LEVEL3) { debugOutput.Add(CSongs.NumSongsWithCoverLoaded.ToString(CLanguage.Translate("TR_DEBUG_SONGS") + ": 00000")); - if (CConfig.DebugLevel >= EDebugLevel.TR_CONFIG_LEVEL_MAX) + if (CConfig.Config.Debug.DebugLevel >= EDebugLevel.TR_CONFIG_LEVEL_MAX) debugOutput.Add(_Cursor.X.ToString(CLanguage.Translate("TR_DEBUG_MOUSE") + " : (0000/") + _Cursor.Y.ToString("0000)")); } } diff --git a/Vocaluxe/Base/CMain.cs b/Vocaluxe/Base/CMain.cs index 2437fc6b..e23bfb9d 100644 --- a/Vocaluxe/Base/CMain.cs +++ b/Vocaluxe/Base/CMain.cs @@ -64,7 +64,7 @@ namespace Vocaluxe.Base { public EOffOn GetSaveModifiedSongs() { - return CConfig.SaveModifiedSongs; + return CConfig.Config.Debug.SaveModifiedSongs; } public void SetBackgroundMusicVolume(int newVolume) @@ -79,7 +79,7 @@ namespace Vocaluxe.Base public EBackgroundMusicOffOn GetBackgroundMusicStatus() { - return CConfig.BackgroundMusic; + return CConfig.Config.Sound.BackgroundMusic; } public int GetPreviewMusicVolume() @@ -89,37 +89,37 @@ namespace Vocaluxe.Base public ESongMenu GetSongMenuType() { - return CConfig.SongMenu; + return CConfig.Config.Game.SongMenu; } public EOffOn GetVideosToBackground() { - return CConfig.VideosToBackground; + return CConfig.Config.Video.VideosToBackground; } public EOffOn GetVideoBackgrounds() { - return CConfig.VideoBackgrounds; + return CConfig.Config.Video.VideoBackgrounds; } public EOffOn GetVideoPreview() { - return CConfig.VideoPreview; + return CConfig.Config.Video.VideoPreview; } public EOffOn GetDrawNoteLines() { - return CConfig.DrawNoteLines; + return CConfig.Config.Theme.DrawNoteLines; } public EOffOn GetDrawToneHelper() { - return CConfig.DrawToneHelper; + return CConfig.Config.Theme.DrawToneHelper; } public int GetCoverSize() { - return CConfig.CoverSize; + return CConfig.Config.Graphics.CoverSize; } public IEnumerable GetSongFolders() @@ -129,17 +129,17 @@ namespace Vocaluxe.Base public ESongSorting GetSongSorting() { - return CConfig.SongSorting; + return CConfig.Config.Game.SongSorting; } public EOffOn GetTabs() { - return CConfig.Tabs; + return CConfig.Config.Game.Tabs; } public EOffOn GetIgnoreArticles() { - return CConfig.IgnoreArticles; + return CConfig.Config.Game.IgnoreArticles; } public bool IsMicConfigured(int playerNr) diff --git a/Vocaluxe/Base/CProfiles.cs b/Vocaluxe/Base/CProfiles.cs index 8cc7d8b5..1abbda41 100644 --- a/Vocaluxe/Base/CProfiles.cs +++ b/Vocaluxe/Base/CProfiles.cs @@ -614,11 +614,11 @@ namespace Vocaluxe.Base try { //Check if profile saved in config - for (int i = 0; i < CConfig.Players.Length; i++) + for (int i = 0; i < CSettings.MaxNumPlayer; i++) { - if (CConfig.Players[i] == _Profiles[profileID].FileName) + if (CConfig.Config.Game.Players[i] == _Profiles[profileID].FileName) { - CConfig.Players[i] = string.Empty; + CConfig.Config.Game.Players[i] = string.Empty; CConfig.SaveConfig(); } } diff --git a/Vocaluxe/Base/CRecord.cs b/Vocaluxe/Base/CRecord.cs index 43c8f099..1fa22c16 100644 --- a/Vocaluxe/Base/CRecord.cs +++ b/Vocaluxe/Base/CRecord.cs @@ -31,7 +31,7 @@ namespace Vocaluxe.Base { if (_Record != null) return false; - switch (CConfig.RecordLib) + switch (CConfig.Config.Sound.RecordLib) { #if WIN case ERecordLib.DirectSound: @@ -135,12 +135,12 @@ namespace Vocaluxe.Base private static int _GetPlayerFromMicConfig(string device, string devicedriver, int channel) { - for (int p = 0; p < CSettings.MaxNumPlayer; p++) + for (int p = 0; p < CConfig.Config.Record.MicConfig.Length; p++) { - if (CConfig.MicConfig[p].Channel != 0 && - CConfig.MicConfig[p].DeviceName == device && - CConfig.MicConfig[p].DeviceDriver == devicedriver && - CConfig.MicConfig[p].Channel == channel) + if (CConfig.Config.Record.MicConfig[p].Channel != 0 && + CConfig.Config.Record.MicConfig[p].DeviceName == device && + CConfig.Config.Record.MicConfig[p].DeviceDriver == devicedriver && + CConfig.Config.Record.MicConfig[p].Channel == channel) return p + 1; } return 0; diff --git a/Vocaluxe/Base/CSongCategorizer.cs b/Vocaluxe/Base/CSongCategorizer.cs index 8f0491d5..ab7fb777 100644 --- a/Vocaluxe/Base/CSongCategorizer.cs +++ b/Vocaluxe/Base/CSongCategorizer.cs @@ -26,7 +26,7 @@ namespace Vocaluxe.Base class CSongCategorizer : CObservable { private readonly List _Categories = new List(); - private EOffOn _Tabs = CConfig.Tabs; + private EOffOn _Tabs = CConfig.Config.Game.Tabs; public CSongCategorizer() { diff --git a/Vocaluxe/Base/CSongSorter.cs b/Vocaluxe/Base/CSongSorter.cs index f521118f..8a956107 100644 --- a/Vocaluxe/Base/CSongSorter.cs +++ b/Vocaluxe/Base/CSongSorter.cs @@ -27,8 +27,8 @@ namespace Vocaluxe.Base class CSongSorter : CObservable { private CSongPointer[] _SortedSongs = new CSongPointer[0]; - private EOffOn _IgnoreArticles = CConfig.IgnoreArticles; - private ESongSorting _SongSorting = CConfig.SongSorting; + private EOffOn _IgnoreArticles = CConfig.Config.Game.IgnoreArticles; + private ESongSorting _SongSorting = CConfig.Config.Game.SongSorting; public CSongSorter() { diff --git a/Vocaluxe/Base/CSongs.cs b/Vocaluxe/Base/CSongs.cs index 2216f63b..d58f67ab 100644 --- a/Vocaluxe/Base/CSongs.cs +++ b/Vocaluxe/Base/CSongs.cs @@ -354,15 +354,15 @@ namespace Vocaluxe.Base CLog.StopBenchmark("Read TXTs"); CLog.StartBenchmark("Sort Songs"); - Sorter.SongSorting = CConfig.SongSorting; - Sorter.IgnoreArticles = CConfig.IgnoreArticles; - Categorizer.Tabs = CConfig.Tabs; + Sorter.SongSorting = CConfig.Config.Game.SongSorting; + Sorter.IgnoreArticles = CConfig.Config.Game.IgnoreArticles; + Categorizer.Tabs = CConfig.Config.Game.Tabs; Categorizer.ObjectChanged += _HandleCategoriesChanged; CLog.StopBenchmark("Sort Songs"); Category = -1; SongsLoaded = true; - switch (CConfig.CoverLoading) + switch (CConfig.Config.Theme.CoverLoading) { case ECoverLoading.TR_CONFIG_COVERLOADING_ATSTART: _LoadCovers(); diff --git a/Vocaluxe/Base/CSound.cs b/Vocaluxe/Base/CSound.cs index d20061f2..e8dba147 100644 --- a/Vocaluxe/Base/CSound.cs +++ b/Vocaluxe/Base/CSound.cs @@ -40,7 +40,7 @@ namespace Vocaluxe.Base { if (_Playback != null) return false; - switch (CConfig.PlayBackLib) + switch (CConfig.Config.Sound.PlayBackLib) { case EPlaybackLib.PortAudio: _Playback = new CPortAudioPlay(); diff --git a/Vocaluxe/Base/CVideo.cs b/Vocaluxe/Base/CVideo.cs index ddd814e8..d9400cc8 100644 --- a/Vocaluxe/Base/CVideo.cs +++ b/Vocaluxe/Base/CVideo.cs @@ -30,7 +30,7 @@ namespace Vocaluxe.Base { if (_VideoDecoder != null) return false; - switch (CConfig.VideoDecoder) + switch (CConfig.Config.Video.VideoDecoder) { case EVideoDecoder.FFmpeg: _VideoDecoder = new CVideoDecoderFFmpeg(); diff --git a/Vocaluxe/Base/CWebcam.cs b/Vocaluxe/Base/CWebcam.cs index 980c6f58..689cca3e 100644 --- a/Vocaluxe/Base/CWebcam.cs +++ b/Vocaluxe/Base/CWebcam.cs @@ -30,7 +30,7 @@ namespace Vocaluxe.Base { if (_Webcam != null) return false; - switch (CConfig.WebcamLib) + switch (CConfig.Config.Video.WebcamLib) { case EWebcamLib.AForgeNet: _Webcam = new CAForgeNet(); @@ -42,9 +42,9 @@ namespace Vocaluxe.Base } if (!_Webcam.Init()) return false; - _Webcam.Select(CConfig.WebcamConfig); + _Webcam.Select(CConfig.Config.Video.WebcamConfig.HasValue ? CConfig.Config.Video.WebcamConfig.Value : new SWebcamConfig()); - CConfig.WebcamConfig = _Webcam.GetConfig(); + CConfig.Config.Video.WebcamConfig = _Webcam.GetConfig(); CConfig.SaveConfig(); return true; } diff --git a/Vocaluxe/Base/Fonts/CFontStyle.cs b/Vocaluxe/Base/Fonts/CFontStyle.cs index 5bde6719..ba59e87b 100644 --- a/Vocaluxe/Base/Fonts/CFontStyle.cs +++ b/Vocaluxe/Base/Fonts/CFontStyle.cs @@ -42,7 +42,7 @@ namespace Vocaluxe.Base.Fonts Outline = outline; OutlineColor = outlineColor; - switch (CConfig.TextureQuality) + switch (CConfig.Config.Graphics.TextureQuality) { case ETextureQuality.TR_CONFIG_TEXTURE_LOWEST: _MaxGlyphHeight = 20f; diff --git a/Vocaluxe/Base/Fonts/CFonts.cs b/Vocaluxe/Base/Fonts/CFonts.cs index da60cf4a..446e12a8 100644 --- a/Vocaluxe/Base/Fonts/CFonts.cs +++ b/Vocaluxe/Base/Fonts/CFonts.cs @@ -236,7 +236,7 @@ namespace Vocaluxe.Base.Fonts { int index = _GetPartyFontIndex(fontName, PartyModeID); if (index < 0) - index = _GetThemeFontIndex(fontName, CConfig.Theme); + index = _GetThemeFontIndex(fontName, CConfig.Config.Theme.Theme); if (index >= 0) return index; for (int i = 0; i < _FontFamilies.Count; i++) diff --git a/Vocaluxe/Base/Server/CVocaluxeServer.cs b/Vocaluxe/Base/Server/CVocaluxeServer.cs index e0afa162..7031771e 100644 --- a/Vocaluxe/Base/Server/CVocaluxeServer.cs +++ b/Vocaluxe/Base/Server/CVocaluxeServer.cs @@ -61,7 +61,7 @@ namespace Vocaluxe.Base.Server public static void Init() { - _Server = new CServer(CConfig.ServerPort, CConfig.ServerEncryption == EOffOn.TR_CONFIG_ON); + _Server = new CServer(CConfig.Config.Server.ServerPort, CConfig.Config.Server.ServerEncryption == EOffOn.TR_CONFIG_ON); CServer.SendKeyEvent = _SendKeyEvent; CServer.GetProfileData = _GetProfileData; @@ -92,7 +92,7 @@ namespace Vocaluxe.Base.Server public static void Start() { - if (CConfig.ServerActive == EOffOn.TR_CONFIG_ON) + if (CConfig.Config.Server.ServerActive == EOffOn.TR_CONFIG_ON) { _Server.Start(); //_Discover.StartBroadcasting(); diff --git a/Vocaluxe/Base/ThemeSystem/CBaseTheme.cs b/Vocaluxe/Base/ThemeSystem/CBaseTheme.cs index de4172c1..c9f37cec 100644 --- a/Vocaluxe/Base/ThemeSystem/CBaseTheme.cs +++ b/Vocaluxe/Base/ThemeSystem/CBaseTheme.cs @@ -59,7 +59,7 @@ namespace Vocaluxe.Base.ThemeSystem protected override bool _LoadSkin() { CSkin skin; - if (!_Skins.TryGetValue(CConfig.Skin, out skin)) + if (!_Skins.TryGetValue(CConfig.Config.Theme.Skin, out skin)) skin = _Skins.Values.FirstOrDefault(); while (skin != null) { diff --git a/Vocaluxe/Base/ThemeSystem/CPartyTheme.cs b/Vocaluxe/Base/ThemeSystem/CPartyTheme.cs index b97d098c..9bc50d9c 100644 --- a/Vocaluxe/Base/ThemeSystem/CPartyTheme.cs +++ b/Vocaluxe/Base/ThemeSystem/CPartyTheme.cs @@ -49,7 +49,7 @@ namespace Vocaluxe.Base.ThemeSystem switch (fallbackNum) { case 0: - _Skins.TryGetValue(CConfig.Skin, out skin); + _Skins.TryGetValue(CConfig.Config.Theme.Skin, out skin); break; case 1: _Skins.TryGetValue(CSettings.DefaultName, out skin); diff --git a/Vocaluxe/Base/ThemeSystem/CThemes.cs b/Vocaluxe/Base/ThemeSystem/CThemes.cs index a39f2d23..665a9e32 100644 --- a/Vocaluxe/Base/ThemeSystem/CThemes.cs +++ b/Vocaluxe/Base/ThemeSystem/CThemes.cs @@ -69,7 +69,7 @@ namespace Vocaluxe.Base.ThemeSystem /// public static void Load() { - CTheme theme = _Themes.FirstOrDefault(th => th is CBaseTheme && th.Name == CConfig.Theme) ?? _Themes.FirstOrDefault(th => th is CBaseTheme); + CTheme theme = _Themes.FirstOrDefault(th => th is CBaseTheme && th.Name == CConfig.Config.Theme.Theme) ?? _Themes.FirstOrDefault(th => th is CBaseTheme); while (theme != null) { if (theme.Load()) @@ -84,8 +84,8 @@ namespace Vocaluxe.Base.ThemeSystem CLog.LogError("No themes found! Cannot continue!", true, true); else { - CConfig.Theme = theme.Name; - CConfig.Skin = theme.CurrentSkin.Name; + CConfig.Config.Theme.Theme = theme.Name; + CConfig.Config.Theme.Skin = theme.CurrentSkin.Name; int[] ids = _Themes.Select(th => th.PartyModeID).Distinct().ToArray(); foreach (int id in ids.Where(id => id >= 0)) LoadPartymodeTheme(id); @@ -95,7 +95,7 @@ namespace Vocaluxe.Base.ThemeSystem public static bool LoadPartymodeTheme(int partyModeID) { Debug.Assert(partyModeID >= 0); - CTheme theme = _Themes.FirstOrDefault(th => th.PartyModeID == partyModeID && th.Name == CConfig.Theme); + CTheme theme = _Themes.FirstOrDefault(th => th.PartyModeID == partyModeID && th.Name == CConfig.Config.Theme.Theme); if (theme != null) { if (theme.Load()) diff --git a/Vocaluxe/Lib/Draw/CDirect3D.cs b/Vocaluxe/Lib/Draw/CDirect3D.cs index 8970edcb..6289f02a 100644 --- a/Vocaluxe/Lib/Draw/CDirect3D.cs +++ b/Vocaluxe/Lib/Draw/CDirect3D.cs @@ -86,7 +86,7 @@ namespace Vocaluxe.Lib.Draw /// public CDirect3D() { - _Form = new CRenderFormHook {ClientSize = new Size(CConfig.ScreenW, CConfig.ScreenH)}; + _Form = new CRenderFormHook {ClientSize = new Size(CConfig.Config.Graphics.ScreenW, CConfig.Config.Graphics.ScreenH)}; try { @@ -113,8 +113,8 @@ namespace Vocaluxe.Lib.Draw { Windowed = true, SwapEffect = SwapEffect.Discard, - BackBufferHeight = CConfig.ScreenH, - BackBufferWidth = CConfig.ScreenW, + BackBufferHeight = CConfig.Config.Graphics.ScreenH, + BackBufferWidth = CConfig.Config.Graphics.ScreenW, BackBufferFormat = _D3D.Adapters.DefaultAdapter.CurrentDisplayMode.Format, Multisample = MultisampleType.None, MultisampleQuality = 0 @@ -125,7 +125,7 @@ namespace Vocaluxe.Lib.Draw #region Antialiasing int quality; MultisampleType msType; - switch (CConfig.AAMode) + switch (CConfig.Config.Graphics.AAMode) { case EAntiAliasingModes.X2: msType = MultisampleType.TwoSamples; @@ -159,7 +159,7 @@ namespace Vocaluxe.Lib.Draw #endregion Antialiasing //Apply the VSync configuration - _PresentParameters.PresentationInterval = CConfig.VSync == EOffOn.TR_CONFIG_ON ? PresentInterval.Default : PresentInterval.Immediate; + _PresentParameters.PresentationInterval = CConfig.Config.Graphics.VSync == EOffOn.TR_CONFIG_ON ? PresentInterval.Default : PresentInterval.Immediate; //GMA 950 graphics devices can only process vertices in software mode Capabilities caps = _D3D.GetDeviceCaps(_D3D.Adapters.DefaultAdapter.Adapter, DeviceType.Hardware); @@ -200,10 +200,10 @@ namespace Vocaluxe.Lib.Draw if (_Form.ClientSize.Width == 0 || _Form.ClientSize.Height == 0) _Form.ClientSize = _SizeBeforeMinimize; - if (_H == _Form.ClientSize.Height && _W == _Form.ClientSize.Width && CConfig.ScreenAlignment == _CurrentAlignment) + if (_H == _Form.ClientSize.Height && _W == _Form.ClientSize.Width && CConfig.Config.Graphics.ScreenAlignment == _CurrentAlignment) return; - _CurrentAlignment = CConfig.ScreenAlignment; + _CurrentAlignment = CConfig.Config.Graphics.ScreenAlignment; _H = _Form.ClientSize.Height; _W = _Form.ClientSize.Width; diff --git a/Vocaluxe/Lib/Draw/CDrawBase.cs b/Vocaluxe/Lib/Draw/CDrawBase.cs index b438b467..eb72ad6d 100644 --- a/Vocaluxe/Lib/Draw/CDrawBase.cs +++ b/Vocaluxe/Lib/Draw/CDrawBase.cs @@ -321,7 +321,7 @@ namespace Vocaluxe.Lib.Draw _Run = true; _Fullscreen = false; - if (CConfig.FullScreen == EOffOn.TR_CONFIG_ON) + if (CConfig.Config.Graphics.FullScreen == EOffOn.TR_CONFIG_ON) _EnterFullScreen(); else _DoResize(); //Resize window if aspect ratio is incorrect @@ -343,24 +343,25 @@ namespace Vocaluxe.Lib.Draw _Run = false; //Apply fullscreen mode - if ((CConfig.FullScreen == EOffOn.TR_CONFIG_ON) != _Fullscreen) + if ((CConfig.Config.Graphics.FullScreen == EOffOn.TR_CONFIG_ON) != _Fullscreen) _ToggleFullScreen(); //Apply border changes - if (_BorderLeft != CConfig.BorderLeft || _BorderRight != CConfig.BorderRight || _BorderTop != CConfig.BorderTop || _BorderBottom != CConfig.BorderBottom) + if (_BorderLeft != CConfig.Config.Graphics.BorderLeft || _BorderRight != CConfig.Config.Graphics.BorderRight || _BorderTop != CConfig.Config.Graphics.BorderTop || + _BorderBottom != CConfig.Config.Graphics.BorderBottom) { - _BorderLeft = CConfig.BorderLeft; - _BorderRight = CConfig.BorderRight; - _BorderTop = CConfig.BorderTop; - _BorderBottom = CConfig.BorderBottom; + _BorderLeft = CConfig.Config.Graphics.BorderLeft; + _BorderRight = CConfig.Config.Graphics.BorderRight; + _BorderTop = CConfig.Config.Graphics.BorderTop; + _BorderBottom = CConfig.Config.Graphics.BorderBottom; _AdjustNewBorders(); } - if (_CurrentAlignment != CConfig.ScreenAlignment) + if (_CurrentAlignment != CConfig.Config.Graphics.ScreenAlignment) _DoResize(); - if (CConfig.VSync == EOffOn.TR_CONFIG_OFF) + if (CConfig.Config.Graphics.VSync == EOffOn.TR_CONFIG_OFF) { if (CTime.IsRunning()) { diff --git a/Vocaluxe/Lib/Draw/CDrawWinForm.cs b/Vocaluxe/Lib/Draw/CDrawWinForm.cs index 7410bbf1..6a1b94a7 100644 --- a/Vocaluxe/Lib/Draw/CDrawWinForm.cs +++ b/Vocaluxe/Lib/Draw/CDrawWinForm.cs @@ -223,7 +223,7 @@ namespace Vocaluxe.Lib.Draw int delay = 0; Show(); - if (CConfig.FullScreen == EOffOn.TR_CONFIG_ON) + if (CConfig.Config.Graphics.FullScreen == EOffOn.TR_CONFIG_ON) _Maximize(this); while (_Run) @@ -237,7 +237,7 @@ namespace Vocaluxe.Lib.Draw _Run = CGraphics.UpdateGameLogic(_Keys, _Mouse); _FlipBuffer(); - if ((CConfig.FullScreen == EOffOn.TR_CONFIG_ON) != _Fullscreen) + if ((CConfig.Config.Graphics.FullScreen == EOffOn.TR_CONFIG_ON) != _Fullscreen) _ToggleFullScreen(); if (CTime.IsRunning()) diff --git a/Vocaluxe/Lib/Draw/COpenGL.cs b/Vocaluxe/Lib/Draw/COpenGL.cs index 15a2581b..261dd4f5 100644 --- a/Vocaluxe/Lib/Draw/COpenGL.cs +++ b/Vocaluxe/Lib/Draw/COpenGL.cs @@ -99,16 +99,16 @@ namespace Vocaluxe.Lib.Draw public COpenGL() { - _Form = new CFormHook {ClientSize = new Size(CConfig.ScreenW, CConfig.ScreenH)}; + _Form = new CFormHook {ClientSize = new Size(CConfig.Config.Graphics.ScreenW, CConfig.Config.Graphics.ScreenH)}; //OpenGL needs that here but D3D needs it in the constructor, so do NOT unify! //Check AA Mode - CConfig.AAMode = (EAntiAliasingModes)_CheckAntiAliasingMode((int)CConfig.AAMode); + CConfig.Config.Graphics.AAMode = (EAntiAliasingModes)_CheckAntiAliasingMode((int)CConfig.Config.Graphics.AAMode); bool ok = false; try { - var gm = new GraphicsMode(32, 24, 0, (int)CConfig.AAMode); + var gm = new GraphicsMode(32, 24, 0, (int)CConfig.Config.Graphics.AAMode); _Control = new GLControl(gm, 2, 1, GraphicsContextFlags.Default); if (_Control.GraphicsMode != null) ok = true; @@ -122,7 +122,7 @@ namespace Vocaluxe.Lib.Draw _Control = new GLControl(); _Control.MakeCurrent(); - _Control.VSync = CConfig.VSync == EOffOn.TR_CONFIG_ON; + _Control.VSync = CConfig.Config.Graphics.VSync == EOffOn.TR_CONFIG_ON; _Form.Controls.Add(_Control); _Control.ClientSize = _Form.ClientSize; @@ -212,7 +212,7 @@ namespace Vocaluxe.Lib.Draw { _H = _Control.Height; _W = _Control.Width; - _CurrentAlignment = CConfig.ScreenAlignment; + _CurrentAlignment = CConfig.Config.Graphics.ScreenAlignment; _AdjustAspect(true); _AdjustNewBorders(); @@ -276,7 +276,8 @@ namespace Vocaluxe.Lib.Draw { GL.MatrixMode(MatrixMode.Projection); GL.LoadIdentity(); - GL.Ortho(-CConfig.BorderLeft, CConfig.BorderRight + CSettings.RenderW, CConfig.BorderBottom + CSettings.RenderH, -CConfig.BorderTop, CSettings.ZNear, CSettings.ZFar); + GL.Ortho(-CConfig.Config.Graphics.BorderLeft, CConfig.Config.Graphics.BorderRight + CSettings.RenderW, CConfig.Config.Graphics.BorderBottom + CSettings.RenderH, + -CConfig.Config.Graphics.BorderTop, CSettings.ZNear, CSettings.ZFar); } public void MakeScreenShot() diff --git a/Vocaluxe/Lib/Draw/CTextureProvider.cs b/Vocaluxe/Lib/Draw/CTextureProvider.cs index 12ab6c75..e5d61f65 100644 --- a/Vocaluxe/Lib/Draw/CTextureProvider.cs +++ b/Vocaluxe/Lib/Draw/CTextureProvider.cs @@ -161,7 +161,7 @@ namespace Vocaluxe.Lib.Draw /// private static int _GetMaxTextureArea() { - switch (CConfig.TextureQuality) + switch (CConfig.Config.Graphics.TextureQuality) { case ETextureQuality.TR_CONFIG_TEXTURE_LOWEST: return 128 * 128; diff --git a/Vocaluxe/Lib/Sound/Playback/OpenAL/COpenAlStream.cs b/Vocaluxe/Lib/Sound/Playback/OpenAL/COpenAlStream.cs index 7428b494..f9b5f41d 100644 --- a/Vocaluxe/Lib/Sound/Playback/OpenAL/COpenAlStream.cs +++ b/Vocaluxe/Lib/Sound/Playback/OpenAL/COpenAlStream.cs @@ -208,7 +208,7 @@ namespace Vocaluxe.Lib.Sound.Playback.OpenAL _Timer.Reset(); _Data = new CRingBuffer(_Bufsize); _NoMoreData = false; - _SampleBuf = new byte[(int)CConfig.AudioBufferSize]; + _SampleBuf = new byte[(int)CConfig.Config.Sound.AudioBufferSize]; //From now on closing the driver and the decoder is handled by the thread ONLY! _DecoderThread = new Thread(_Execute) {Priority = ThreadPriority.Normal, Name = Path.GetFileName(_Medium)}; @@ -384,7 +384,7 @@ namespace Vocaluxe.Lib.Sound.Playback.OpenAL } } - float latency = CConfig.AudioLatency / 1000f + queuedCount * _SampleBuf.Length / _BytesPerSecond + 0.1f; + float latency = CConfig.Config.Sound.AudioLatency / 1000f + queuedCount * _SampleBuf.Length / _BytesPerSecond + 0.1f; _CurrentTime = _TimeCode - _Data.BytesNotRead / _BytesPerSecond - latency; _Timer.Restart(); } diff --git a/Vocaluxe/Lib/Sound/Playback/PortAudio/CPortAudioStream.cs b/Vocaluxe/Lib/Sound/Playback/PortAudio/CPortAudioStream.cs index ac913aaf..b03283e1 100644 --- a/Vocaluxe/Lib/Sound/Playback/PortAudio/CPortAudioStream.cs +++ b/Vocaluxe/Lib/Sound/Playback/PortAudio/CPortAudioStream.cs @@ -199,7 +199,7 @@ namespace Vocaluxe.Lib.Sound.Playback.PortAudio out _Stream, ref outputParams, format.SamplesPerSecond, - (uint)CConfig.AudioBufferSize / 2, + (uint)CConfig.Config.Sound.AudioBufferSize / 2, PortAudioSharp.PortAudio.PaStreamFlags.paNoFlag, _PaStreamCallback, IntPtr.Zero) || _Stream == IntPtr.Zero) @@ -208,7 +208,7 @@ namespace Vocaluxe.Lib.Sound.Playback.PortAudio return false; } - _Latency = CConfig.AudioLatency / 1000f + (float)PortAudioSharp.PortAudio.Pa_GetStreamInfo(_Stream).outputLatency; + _Latency = CConfig.Config.Sound.AudioLatency / 1000f + (float)PortAudioSharp.PortAudio.Pa_GetStreamInfo(_Stream).outputLatency; //From now on closing the driver and the decoder is handled by the thread ONLY! diff --git a/Vocaluxe/Screens/CPopupScreenPlayerControl.cs b/Vocaluxe/Screens/CPopupScreenPlayerControl.cs index c67156dd..801259da 100644 --- a/Vocaluxe/Screens/CPopupScreenPlayerControl.cs +++ b/Vocaluxe/Screens/CPopupScreenPlayerControl.cs @@ -58,21 +58,21 @@ namespace Vocaluxe.Screens private bool _VideoBackground { - get { return CConfig.VideosToBackground == EOffOn.TR_CONFIG_ON; } + get { return CConfig.Config.Video.VideosToBackground == EOffOn.TR_CONFIG_ON; } set { if (!value) { - if (CConfig.VideosToBackground == EOffOn.TR_CONFIG_ON) + if (CConfig.Config.Video.VideosToBackground == EOffOn.TR_CONFIG_ON) { - CConfig.VideosToBackground = EOffOn.TR_CONFIG_OFF; + CConfig.Config.Video.VideosToBackground = EOffOn.TR_CONFIG_OFF; if (!_VideoPreviewInt) CBackgroundMusic.VideoEnabled = false; } } else { - CConfig.VideosToBackground = EOffOn.TR_CONFIG_ON; + CConfig.Config.Video.VideosToBackground = EOffOn.TR_CONFIG_ON; CBackgroundMusic.VideoEnabled = true; } CConfig.SaveConfig(); diff --git a/Vocaluxe/Screens/CScreenLoad.cs b/Vocaluxe/Screens/CScreenLoad.cs index 9d785780..bc30c7cb 100644 --- a/Vocaluxe/Screens/CScreenLoad.cs +++ b/Vocaluxe/Screens/CScreenLoad.cs @@ -105,7 +105,7 @@ namespace Vocaluxe.Screens _CurrentIntroVideo = -1; _IntroOutPlayed = false; - if (CConfig.VideoBackgrounds == EOffOn.TR_CONFIG_ON) + if (CConfig.Config.Video.VideoBackgrounds == EOffOn.TR_CONFIG_ON) { for (int i = 0; i < _Intros.Length; i++) _Intros[i].Load(_IntroVideo[i]); @@ -117,7 +117,7 @@ namespace Vocaluxe.Screens { base.OnShowFinish(); - if (CConfig.VideoBackgrounds == EOffOn.TR_CONFIG_ON) + if (CConfig.Config.Video.VideoBackgrounds == EOffOn.TR_CONFIG_ON) { foreach (CVideoPlayer videoPlayer in _Intros) videoPlayer.PreLoad(); @@ -135,7 +135,7 @@ namespace Vocaluxe.Screens { _CheckStartIntroVideos(); - bool next = CConfig.CoverLoading != ECoverLoading.TR_CONFIG_COVERLOADING_ATSTART || CSongs.CoverLoaded; + bool next = CConfig.Config.Theme.CoverLoading != ECoverLoading.TR_CONFIG_COVERLOADING_ATSTART || CSongs.CoverLoaded; if ((_IntroOutPlayed || _SkipIntro) && next && CSettings.ProgramState != EProgramState.EditTheme && CSongs.SongsLoaded) CSettings.ProgramState = EProgramState.Normal; @@ -152,7 +152,7 @@ namespace Vocaluxe.Screens { CBackgroundMusic.OwnSongsAvailable = true; - if (CConfig.VideoBackgrounds == EOffOn.TR_CONFIG_ON || CConfig.VideosToBackground == EOffOn.TR_CONFIG_ON) + if (CConfig.Config.Video.VideoBackgrounds == EOffOn.TR_CONFIG_ON || CConfig.Config.Video.VideosToBackground == EOffOn.TR_CONFIG_ON) CBackgroundMusic.VideoEnabled = true; CBackgroundMusic.Play(); @@ -189,7 +189,7 @@ namespace Vocaluxe.Screens if (_IntroOutPlayed) return; - if (CConfig.VideoBackgrounds == EOffOn.TR_CONFIG_OFF) + if (CConfig.Config.Video.VideoBackgrounds == EOffOn.TR_CONFIG_OFF) { _IntroOutPlayed = true; return; @@ -200,7 +200,7 @@ namespace Vocaluxe.Screens _CurrentIntroVideo = 0; _Intros[0].Start(); } - else if (_CurrentIntroVideo == 0 && _Intros[0].IsFinished && CConfig.CoverLoading == ECoverLoading.TR_CONFIG_COVERLOADING_ATSTART) + else if (_CurrentIntroVideo == 0 && _Intros[0].IsFinished && CConfig.Config.Theme.CoverLoading == ECoverLoading.TR_CONFIG_COVERLOADING_ATSTART) { _Intros[_CurrentIntroVideo].Close(); _CurrentIntroVideo = 1; diff --git a/Vocaluxe/Screens/CScreenNames.cs b/Vocaluxe/Screens/CScreenNames.cs index 831c1b9c..c4687da5 100644 --- a/Vocaluxe/Screens/CScreenNames.cs +++ b/Vocaluxe/Screens/CScreenNames.cs @@ -125,9 +125,9 @@ namespace Vocaluxe.Screens switch (keyEvent.Key) { case Keys.Add: - if (CConfig.NumPlayers + 1 <= CSettings.MaxNumPlayer) + if (CConfig.Config.Game.NumPlayers + 1 <= CSettings.MaxNumPlayer) { - _SelectSlides[_SelectSlidePlayerNumber].Selection = CConfig.NumPlayers; + _SelectSlides[_SelectSlidePlayerNumber].Selection = CConfig.Config.Game.NumPlayers; _UpdatePlayerNumber(); //Update Tiles-List _NameSelections[_NameSelection].UpdateList(); @@ -135,9 +135,9 @@ namespace Vocaluxe.Screens break; case Keys.Subtract: - if (CConfig.NumPlayers - 1 > 0) + if (CConfig.Config.Game.NumPlayers - 1 > 0) { - _SelectSlides[_SelectSlidePlayerNumber].Selection = CConfig.NumPlayers - 2; + _SelectSlides[_SelectSlidePlayerNumber].Selection = CConfig.Config.Game.NumPlayers - 2; _UpdatePlayerNumber(); //Update Tiles-List _NameSelections[_NameSelection].UpdateList(); @@ -261,7 +261,7 @@ namespace Vocaluxe.Screens _SelectingKeyboardActive = false; _NameSelections[_NameSelection].FastSelection(false, -1); } - else if (numberPressed <= CConfig.NumPlayers) + else if (numberPressed <= CConfig.Config.Game.NumPlayers) { _SelectingFastPlayerNr = numberPressed; _NameSelections[_NameSelection].FastSelection(true, numberPressed); @@ -324,7 +324,7 @@ namespace Vocaluxe.Screens } - if (_SelectingFastPlayerNr > 0 && _SelectingFastPlayerNr <= CConfig.NumPlayers) + if (_SelectingFastPlayerNr > 0 && _SelectingFastPlayerNr <= CConfig.Config.Game.NumPlayers) { _SelectingKeyboardActive = true; _NameSelections[_NameSelection].FastSelection(true, _SelectingFastPlayerNr); @@ -488,7 +488,7 @@ namespace Vocaluxe.Screens { bool exit = true; //Remove profile-selection - for (int i = 0; i < CConfig.NumPlayers; i++) + for (int i = 0; i < CConfig.Config.Game.NumPlayers; i++) { if (CHelper.IsInBounds(_Statics[_StaticPlayer[i]].Rect, mouseEvent)) { @@ -627,12 +627,12 @@ namespace Vocaluxe.Screens _SelectSlides[_SelectSlidePlayerNumber].Clear(); for (int i = 1; i <= CSettings.MaxNumPlayer; i++) _SelectSlides[_SelectSlidePlayerNumber].AddValue(CLanguage.Translate("TR_SCREENNAMES_" + i + "PLAYER")); - _SelectSlides[_SelectSlidePlayerNumber].Selection = CConfig.NumPlayers - 1; + _SelectSlides[_SelectSlidePlayerNumber].Selection = CConfig.Config.Game.NumPlayers - 1; } private void _UpdatePlayerNumber() { - CConfig.NumPlayers = _SelectSlides[_SelectSlidePlayerNumber].Selection + 1; + CConfig.Config.Game.NumPlayers = _SelectSlides[_SelectSlidePlayerNumber].Selection + 1; CGame.NumPlayers = _SelectSlides[_SelectSlidePlayerNumber].Selection + 1; for (int i = 1; i <= CSettings.MaxNumPlayer; i++) { @@ -668,7 +668,7 @@ namespace Vocaluxe.Screens //Update Game-infos with new player CGame.Players[playerNum].ProfileID = profileId; //Update config for default players. - CConfig.Players[playerNum] = CProfiles.GetProfileFileName(profileId); + CConfig.Config.Game.Players[playerNum] = CProfiles.GetProfileFileName(profileId); CConfig.SaveConfig(); //Update texture and name _Statics[_StaticPlayerAvatar[playerNum]].Texture = CProfiles.GetAvatarTextureFromProfile(profileId); @@ -686,7 +686,7 @@ namespace Vocaluxe.Screens _NameSelections[_NameSelection].RemoveUsedProfile(CGame.Players[i].ProfileID); CGame.Players[i].ProfileID = -1; //Update config for default players. - CConfig.Players[i] = String.Empty; + CConfig.Config.Game.Players[i] = String.Empty; //Update texture and name _Statics[_StaticPlayerAvatar[i]].Texture = _OriginalPlayerAvatarTextures[i]; _Texts[_TextPlayer[i]].Text = CProfiles.GetPlayerName(-1, i + 1); @@ -700,7 +700,7 @@ namespace Vocaluxe.Screens _NameSelections[_NameSelection].RemoveUsedProfile(CGame.Players[playerNum].ProfileID); CGame.Players[playerNum].ProfileID = -1; //Update config for default players. - CConfig.Players[playerNum] = String.Empty; + CConfig.Config.Game.Players[playerNum] = String.Empty; CConfig.SaveConfig(); //Update texture and name _Statics[_StaticPlayerAvatar[playerNum]].Texture = _OriginalPlayerAvatarTextures[playerNum]; @@ -714,7 +714,7 @@ namespace Vocaluxe.Screens private void _CheckMics() { var playerWithoutMicro = new List(); - for (int player = 0; player < CConfig.NumPlayers; player++) + for (int player = 0; player < CConfig.Config.Game.NumPlayers; player++) { if (!CConfig.IsMicConfig(player + 1)) playerWithoutMicro.Add(player + 1); @@ -752,7 +752,7 @@ namespace Vocaluxe.Screens private void _CheckPlayers() { var playerWithoutProfile = new List(); - for (int player = 0; player < CConfig.NumPlayers; player++) + for (int player = 0; player < CConfig.Config.Game.NumPlayers; player++) { if (CGame.Players[player].ProfileID < 0) playerWithoutProfile.Add(player + 1); diff --git a/Vocaluxe/Screens/CScreenOptionsGame.cs b/Vocaluxe/Screens/CScreenOptionsGame.cs index 5d212d96..d25f77a8 100644 --- a/Vocaluxe/Screens/CScreenOptionsGame.cs +++ b/Vocaluxe/Screens/CScreenOptionsGame.cs @@ -55,11 +55,11 @@ namespace Vocaluxe.Screens _SelectSlides[_SelectSlideLanguage].AddValues(CLanguage.GetLanguageNames()); _SelectSlides[_SelectSlideLanguage].Selection = CLanguage.LanguageId; - _SelectSlides[_SelectSlideDebugLevel].SetValues((int)CConfig.DebugLevel); - _SelectSlides[_SelectSlideSongMenu].SetValues((int)CConfig.SongMenu); - _SelectSlides[_SelectSlideSongSorting].SetValues((int)CConfig.SongSorting); - _SelectSlides[_SelectSlideTabs].SetValues((int)CConfig.Tabs); - _SelectSlides[_SelectSlideTimerMode].SetValues((int)CConfig.TimerMode); + _SelectSlides[_SelectSlideDebugLevel].SetValues((int)CConfig.Config.Debug.DebugLevel); + _SelectSlides[_SelectSlideSongMenu].SetValues((int)CConfig.Config.Game.SongMenu); + _SelectSlides[_SelectSlideSongSorting].SetValues((int)CConfig.Config.Game.SongSorting); + _SelectSlides[_SelectSlideTabs].SetValues((int)CConfig.Config.Game.Tabs); + _SelectSlides[_SelectSlideTimerMode].SetValues((int)CConfig.Config.Game.TimerMode); } public override bool HandleInput(SKeyEvent keyEvent) @@ -134,17 +134,17 @@ namespace Vocaluxe.Screens private void _SaveConfig() { CLanguage.LanguageId = _SelectSlides[_SelectSlideLanguage].Selection; - CConfig.Language = CLanguage.GetLanguageName(CLanguage.LanguageId); - CConfig.DebugLevel = (EDebugLevel)_SelectSlides[_SelectSlideDebugLevel].Selection; - CConfig.SongMenu = (ESongMenu)_SelectSlides[_SelectSlideSongMenu].Selection; - CConfig.SongSorting = (ESongSorting)_SelectSlides[_SelectSlideSongSorting].Selection; - CConfig.Tabs = (EOffOn)_SelectSlides[_SelectSlideTabs].Selection; - CConfig.TimerMode = (ETimerMode)_SelectSlides[_SelectSlideTimerMode].Selection; + CConfig.Config.Game.Language = CLanguage.GetLanguageName(CLanguage.LanguageId); + CConfig.Config.Debug.DebugLevel = (EDebugLevel)_SelectSlides[_SelectSlideDebugLevel].Selection; + CConfig.Config.Game.SongMenu = (ESongMenu)_SelectSlides[_SelectSlideSongMenu].Selection; + CConfig.Config.Game.SongSorting = (ESongSorting)_SelectSlides[_SelectSlideSongSorting].Selection; + CConfig.Config.Game.Tabs = (EOffOn)_SelectSlides[_SelectSlideTabs].Selection; + CConfig.Config.Game.TimerMode = (ETimerMode)_SelectSlides[_SelectSlideTimerMode].Selection; CConfig.SaveConfig(); - CSongs.Sorter.SongSorting = CConfig.SongSorting; - CSongs.Categorizer.Tabs = CConfig.Tabs; + CSongs.Sorter.SongSorting = CConfig.Config.Game.SongSorting; + CSongs.Categorizer.Tabs = CConfig.Config.Game.Tabs; } } } \ No newline at end of file diff --git a/Vocaluxe/Screens/CScreenOptionsLyrics.cs b/Vocaluxe/Screens/CScreenOptionsLyrics.cs index 336e747f..5614b3b7 100644 --- a/Vocaluxe/Screens/CScreenOptionsLyrics.cs +++ b/Vocaluxe/Screens/CScreenOptionsLyrics.cs @@ -46,8 +46,8 @@ namespace Vocaluxe.Screens public override void LoadTheme(string xmlPath) { base.LoadTheme(xmlPath); - _SelectSlides[_SelectSlideLyricStyle].SetValues((int)CConfig.LyricStyle); - _SelectSlides[_SelectSlideLyricsPosition].SetValues((int)CConfig.LyricsPosition); + _SelectSlides[_SelectSlideLyricStyle].SetValues((int)CConfig.Config.Theme.LyricStyle); + _SelectSlides[_SelectSlideLyricsPosition].SetValues((int)CConfig.Config.Game.LyricsPosition); } public override bool HandleInput(SKeyEvent keyEvent) @@ -115,8 +115,8 @@ namespace Vocaluxe.Screens private void _SaveConfig() { - CConfig.LyricsPosition = (ELyricsPosition)_SelectSlides[_SelectSlideLyricsPosition].Selection; - CConfig.LyricStyle = (ELyricStyle)_SelectSlides[_SelectSlideLyricStyle].Selection; + CConfig.Config.Game.LyricsPosition = (ELyricsPosition)_SelectSlides[_SelectSlideLyricsPosition].Selection; + CConfig.Config.Theme.LyricStyle = (ELyricStyle)_SelectSlides[_SelectSlideLyricStyle].Selection; CConfig.SaveConfig(); } } diff --git a/Vocaluxe/Screens/CScreenOptionsRecord.cs b/Vocaluxe/Screens/CScreenOptionsRecord.cs index 7910d510..01a4bc24 100644 --- a/Vocaluxe/Screens/CScreenOptionsRecord.cs +++ b/Vocaluxe/Screens/CScreenOptionsRecord.cs @@ -292,7 +292,7 @@ namespace Vocaluxe.Screens _DelayTest.Reset(); - _SelectSlides[_SelectSlideDelay].Selection = CConfig.MicDelay / 20; + _SelectSlides[_SelectSlideDelay].Selection = CConfig.Config.Record.MicDelay / 20; } public override void OnShowFinish() @@ -341,7 +341,7 @@ namespace Vocaluxe.Screens private void _SaveDelayConfig() { - CConfig.MicDelay = _SelectSlides[_SelectSlideDelay].Selection * 20; + CConfig.Config.Record.MicDelay = _SelectSlides[_SelectSlideDelay].Selection * 20; CConfig.SaveConfig(); } @@ -356,22 +356,22 @@ namespace Vocaluxe.Screens if (_CheckMicConfig()) { for (int p = 0; p < CSettings.MaxNumPlayer; p++) - CConfig.MicConfig[p].Channel = 0; + CConfig.Config.Record.MicConfig[p].Channel = 0; foreach (CRecordDevice device in _Devices) { if (device.PlayerChannel1 > 0) { - CConfig.MicConfig[device.PlayerChannel1 - 1].Channel = 1; - CConfig.MicConfig[device.PlayerChannel1 - 1].DeviceName = device.Name; - CConfig.MicConfig[device.PlayerChannel1 - 1].DeviceDriver = device.Driver; + CConfig.Config.Record.MicConfig[device.PlayerChannel1 - 1].Channel = 1; + CConfig.Config.Record.MicConfig[device.PlayerChannel1 - 1].DeviceName = device.Name; + CConfig.Config.Record.MicConfig[device.PlayerChannel1 - 1].DeviceDriver = device.Driver; } if (device.PlayerChannel2 > 0) { - CConfig.MicConfig[device.PlayerChannel2 - 1].Channel = 2; - CConfig.MicConfig[device.PlayerChannel2 - 1].DeviceName = device.Name; - CConfig.MicConfig[device.PlayerChannel2 - 1].DeviceDriver = device.Driver; + CConfig.Config.Record.MicConfig[device.PlayerChannel2 - 1].Channel = 2; + CConfig.Config.Record.MicConfig[device.PlayerChannel2 - 1].DeviceName = device.Name; + CConfig.Config.Record.MicConfig[device.PlayerChannel2 - 1].DeviceDriver = device.Driver; } } CConfig.SaveConfig(); @@ -448,15 +448,15 @@ namespace Vocaluxe.Screens if (_Devices == null) return; - if (CConfig.MicConfig == null) + if (CConfig.Config.Record.MicConfig == null) return; - if (CConfig.MicConfig[0].Channel <= 0) + if (CConfig.Config.Record.MicConfig[0].Channel <= 0) return; for (int i = 0; i < _Devices.Count; i++) { - if (_Devices[i].Name == CConfig.MicConfig[0].DeviceName && _Devices[i].Driver == CConfig.MicConfig[0].DeviceDriver) + if (_Devices[i].Name == CConfig.Config.Record.MicConfig[0].DeviceName && _Devices[i].Driver == CConfig.Config.Record.MicConfig[0].DeviceDriver) { device = i; return; diff --git a/Vocaluxe/Screens/CScreenOptionsSound.cs b/Vocaluxe/Screens/CScreenOptionsSound.cs index bf7a88b3..d03537b5 100644 --- a/Vocaluxe/Screens/CScreenOptionsSound.cs +++ b/Vocaluxe/Screens/CScreenOptionsSound.cs @@ -52,12 +52,12 @@ namespace Vocaluxe.Screens public override void LoadTheme(string xmlPath) { base.LoadTheme(xmlPath); - _SelectSlides[_SelectSlideBackgroundMusic].SetValues((int)CConfig.BackgroundMusic); + _SelectSlides[_SelectSlideBackgroundMusic].SetValues((int)CConfig.Config.Sound.BackgroundMusic); _SelectSlides[_SelectSlideBackgroundMusicVolume].AddValues(new string[] {"0", "5", "10", "15", "20", "25", "30", "35", "40", "45", "50", "55", "60", "65", "70", "75", "80", "85", "90", "95", "100"}); _SelectSlides[_SelectSlideBackgroundMusicVolume].Selection = CConfig.BackgroundMusicVolume / 5; - _SelectSlides[_SelectSlideBackgroundMusicSource].SetValues((int)CConfig.BackgroundMusicSource); - _SelectSlides[_SelectSlideBackgroundMusicSource].Selection = (int)CConfig.BackgroundMusicSource; + _SelectSlides[_SelectSlideBackgroundMusicSource].SetValues((int)CConfig.Config.Sound.BackgroundMusicSource); + _SelectSlides[_SelectSlideBackgroundMusicSource].Selection = (int)CConfig.Config.Sound.BackgroundMusicSource; _SelectSlides[_SelectSlidePreviewMusicVolume].AddValues(new string[] {"0", "5", "10", "15", "20", "25", "30", "35", "40", "45", "50", "55", "60", "65", "70", "75", "80", "85", "90", "95", "100"}); _SelectSlides[_SelectSlidePreviewMusicVolume].Selection = CConfig.PreviewMusicVolume / 5; @@ -144,14 +144,14 @@ namespace Vocaluxe.Screens { CConfig.GameMusicVolume = _SelectSlides[_SelectSlideGameMusicVolume].Selection * 5; CConfig.PreviewMusicVolume = _SelectSlides[_SelectSlidePreviewMusicVolume].Selection * 5; - CConfig.BackgroundMusic = (EBackgroundMusicOffOn)_SelectSlides[_SelectSlideBackgroundMusic].Selection; - CConfig.BackgroundMusicSource = (EBackgroundMusicSource)_SelectSlides[_SelectSlideBackgroundMusicSource].Selection; + CConfig.Config.Sound.BackgroundMusic = (EBackgroundMusicOffOn)_SelectSlides[_SelectSlideBackgroundMusic].Selection; + CConfig.Config.Sound.BackgroundMusicSource = (EBackgroundMusicSource)_SelectSlides[_SelectSlideBackgroundMusicSource].Selection; CConfig.BackgroundMusicVolume = _SelectSlides[_SelectSlideBackgroundMusicVolume].Selection * 5; CConfig.SaveConfig(); - CBackgroundMusic.SetMusicSource(CConfig.BackgroundMusicSource); + CBackgroundMusic.SetMusicSource(CConfig.Config.Sound.BackgroundMusicSource); CSound.SetGlobalVolume(CConfig.BackgroundMusicVolume); - if (CConfig.BackgroundMusic == EBackgroundMusicOffOn.TR_CONFIG_ON) + if (CConfig.Config.Sound.BackgroundMusic == EBackgroundMusicOffOn.TR_CONFIG_ON) CBackgroundMusic.Play(); else CBackgroundMusic.Stop(); diff --git a/Vocaluxe/Screens/CScreenOptionsTheme.cs b/Vocaluxe/Screens/CScreenOptionsTheme.cs index 78749e29..4dbf8b69 100644 --- a/Vocaluxe/Screens/CScreenOptionsTheme.cs +++ b/Vocaluxe/Screens/CScreenOptionsTheme.cs @@ -69,11 +69,11 @@ namespace Vocaluxe.Screens _SelectSlides[_SelectSlideCover].AddValues(CCover.CoverThemes); _SelectSlides[_SelectSlideCover].Selection = CCover.GetCoverThemeIndex(); - _SelectSlides[_SelectSlideNoteLines].SetValues((int)CConfig.DrawNoteLines); - _SelectSlides[_SelectSlideToneHelper].SetValues((int)CConfig.DrawToneHelper); - _SelectSlides[_SelectSlideTimerLook].SetValues((int)CConfig.TimerLook); - _SelectSlides[_SelectSlideFadeInfo].SetValues((int)CConfig.FadePlayerInfo); - _SelectSlides[_SelectSlideCoverLoading].SetValues((int)CConfig.CoverLoading); + _SelectSlides[_SelectSlideNoteLines].SetValues((int)CConfig.Config.Theme.DrawNoteLines); + _SelectSlides[_SelectSlideToneHelper].SetValues((int)CConfig.Config.Theme.DrawToneHelper); + _SelectSlides[_SelectSlideTimerLook].SetValues((int)CConfig.Config.Theme.TimerLook); + _SelectSlides[_SelectSlideFadeInfo].SetValues((int)CConfig.Config.Theme.FadePlayerInfo); + _SelectSlides[_SelectSlideCoverLoading].SetValues((int)CConfig.Config.Theme.CoverLoading); } public override bool HandleInput(SKeyEvent keyEvent) @@ -135,18 +135,18 @@ namespace Vocaluxe.Screens _ResetSlides(); - _OldCoverTheme = CConfig.CoverTheme; + _OldCoverTheme = CConfig.Config.Theme.CoverTheme; } private void _ResetSlides() { _SelectSlides[_SelectSlideTheme].Clear(); _SelectSlides[_SelectSlideTheme].AddValues(CThemes.ThemeNames); - _SelectSlides[_SelectSlideTheme].Selection = Array.IndexOf(CThemes.ThemeNames, CConfig.Theme); + _SelectSlides[_SelectSlideTheme].Selection = Array.IndexOf(CThemes.ThemeNames, CConfig.Config.Theme.Theme); _SelectSlides[_SelectSlideSkin].Clear(); _SelectSlides[_SelectSlideSkin].AddValues(CThemes.SkinNames); - _SelectSlides[_SelectSlideSkin].Selection = Array.IndexOf(CThemes.SkinNames, CConfig.Skin); + _SelectSlides[_SelectSlideSkin].Selection = Array.IndexOf(CThemes.SkinNames, CConfig.Config.Theme.Skin); } public override bool UpdateGame() @@ -162,12 +162,12 @@ namespace Vocaluxe.Screens private void _SaveConfig() { - CConfig.CoverTheme = CCover.CoverThemes[_SelectSlides[_SelectSlideCover].Selection]; - CConfig.DrawNoteLines = (EOffOn)_SelectSlides[_SelectSlideNoteLines].Selection; - CConfig.DrawToneHelper = (EOffOn)_SelectSlides[_SelectSlideToneHelper].Selection; - CConfig.TimerLook = (ETimerLook)_SelectSlides[_SelectSlideTimerLook].Selection; - CConfig.FadePlayerInfo = (EFadePlayerInfo)_SelectSlides[_SelectSlideFadeInfo].Selection; - CConfig.CoverLoading = (ECoverLoading)_SelectSlides[_SelectSlideCoverLoading].Selection; + CConfig.Config.Theme.CoverTheme = CCover.CoverThemes[_SelectSlides[_SelectSlideCover].Selection]; + CConfig.Config.Theme.DrawNoteLines = (EOffOn)_SelectSlides[_SelectSlideNoteLines].Selection; + CConfig.Config.Theme.DrawToneHelper = (EOffOn)_SelectSlides[_SelectSlideToneHelper].Selection; + CConfig.Config.Theme.TimerLook = (ETimerLook)_SelectSlides[_SelectSlideTimerLook].Selection; + CConfig.Config.Theme.FadePlayerInfo = (EFadePlayerInfo)_SelectSlides[_SelectSlideFadeInfo].Selection; + CConfig.Config.Theme.CoverLoading = (ECoverLoading)_SelectSlides[_SelectSlideCoverLoading].Selection; CConfig.SaveConfig(); @@ -177,9 +177,9 @@ namespace Vocaluxe.Screens private void _OnChange() { - if (CConfig.Theme != _SelectSlides[_SelectSlideTheme].Value) + if (CConfig.Config.Theme.Theme != _SelectSlides[_SelectSlideTheme].Value) { - CConfig.Theme = _SelectSlides[_SelectSlideTheme].Value; + CConfig.Config.Theme.Theme = _SelectSlides[_SelectSlideTheme].Value; CThemes.Reload(); CGraphics.ReloadTheme(); @@ -188,9 +188,9 @@ namespace Vocaluxe.Screens return; } - if (CConfig.Skin != _SelectSlides[_SelectSlideSkin].Value) + if (CConfig.Config.Theme.Skin != _SelectSlides[_SelectSlideSkin].Value) { - CConfig.Skin = _SelectSlides[_SelectSlideSkin].Value; + CConfig.Config.Theme.Skin = _SelectSlides[_SelectSlideSkin].Value; CThemes.ReloadSkin(); CGraphics.ReloadSkin(); diff --git a/Vocaluxe/Screens/CScreenOptionsVideo.cs b/Vocaluxe/Screens/CScreenOptionsVideo.cs index 0ffcce49..4bfd1022 100644 --- a/Vocaluxe/Screens/CScreenOptionsVideo.cs +++ b/Vocaluxe/Screens/CScreenOptionsVideo.cs @@ -71,10 +71,10 @@ namespace Vocaluxe.Screens { base.LoadTheme(xmlPath); - _SelectSlides[_SelectSlideVideoBackgrounds].SetValues((int)CConfig.VideoBackgrounds); - _SelectSlides[_SelectSlideVideoPreview].SetValues((int)CConfig.VideoPreview); - _SelectSlides[_SelectSlideVideosInSongs].SetValues((int)CConfig.VideosInSongs); - _SelectSlides[_SelectSlideVideosToBackground].SetValues((int)CConfig.VideosToBackground); + _SelectSlides[_SelectSlideVideoBackgrounds].SetValues((int)CConfig.Config.Video.VideoBackgrounds); + _SelectSlides[_SelectSlideVideoPreview].SetValues((int)CConfig.Config.Video.VideoPreview); + _SelectSlides[_SelectSlideVideosInSongs].SetValues((int)CConfig.Config.Video.VideosInSongs); + _SelectSlides[_SelectSlideVideosToBackground].SetValues((int)CConfig.Config.Video.VideosToBackground); _Statics[_StaticWebcamOutput].Aspect = EAspect.Crop; } @@ -160,7 +160,7 @@ namespace Vocaluxe.Screens { if (CWebcam.GetFrame(ref _WebcamTexture)) _Statics[_StaticWebcamOutput].Texture = _WebcamTexture; - _SelectSlides[_SelectSlideVideosToBackground].Selection = (int)CConfig.VideosToBackground; + _SelectSlides[_SelectSlideVideosToBackground].Selection = (int)CConfig.Config.Video.VideosToBackground; return true; } @@ -216,13 +216,13 @@ namespace Vocaluxe.Screens private void _SaveConfig() { - CConfig.VideoBackgrounds = (EOffOn)_SelectSlides[_SelectSlideVideoBackgrounds].Selection; - CConfig.VideoPreview = (EOffOn)_SelectSlides[_SelectSlideVideoPreview].Selection; - CConfig.VideosInSongs = (EOffOn)_SelectSlides[_SelectSlideVideosInSongs].Selection; - CConfig.VideosToBackground = (EOffOn)_SelectSlides[_SelectSlideVideosToBackground].Selection; + CConfig.Config.Video.VideoBackgrounds = (EOffOn)_SelectSlides[_SelectSlideVideoBackgrounds].Selection; + CConfig.Config.Video.VideoPreview = (EOffOn)_SelectSlides[_SelectSlideVideoPreview].Selection; + CConfig.Config.Video.VideosInSongs = (EOffOn)_SelectSlides[_SelectSlideVideosInSongs].Selection; + CConfig.Config.Video.VideosToBackground = (EOffOn)_SelectSlides[_SelectSlideVideosToBackground].Selection; - CConfig.WebcamConfig = _Config; - CBackgroundMusic.VideoEnabled = CConfig.VideoBackgrounds == EOffOn.TR_CONFIG_ON && CConfig.VideosToBackground == EOffOn.TR_CONFIG_ON; + CConfig.Config.Video.WebcamConfig = _Config; + CBackgroundMusic.VideoEnabled = CConfig.Config.Video.VideoBackgrounds == EOffOn.TR_CONFIG_ON && CConfig.Config.Video.VideosToBackground == EOffOn.TR_CONFIG_ON; CConfig.SaveConfig(); } @@ -272,15 +272,16 @@ namespace Vocaluxe.Screens capabilities = -1; return false; } - + SWebcamConfig curConfig = CConfig.Config.Video.WebcamConfig.HasValue ? CConfig.Config.Video.WebcamConfig.Value : new SWebcamConfig(); for (int i = 0; i < devices.Length; i++) { - if (devices[i].MonikerString != CConfig.WebcamConfig.MonikerString) + if (devices[i].MonikerString != curConfig.MonikerString) continue; for (int j = 0; j < devices[i].Capabilities.Count; j++) { - if (devices[i].Capabilities[j].Framerate == CConfig.WebcamConfig.Framerate && devices[i].Capabilities[j].Width == CConfig.WebcamConfig.Width && - devices[i].Capabilities[j].Height == CConfig.WebcamConfig.Height) + if (devices[i].Capabilities[j].Framerate == curConfig.Framerate && + devices[i].Capabilities[j].Width == curConfig.Width && + devices[i].Capabilities[j].Height == curConfig.Height) { device = i; capabilities = j; diff --git a/Vocaluxe/Screens/CScreenScore.cs b/Vocaluxe/Screens/CScreenScore.cs index d4fc83c1..e82fea39 100644 --- a/Vocaluxe/Screens/CScreenScore.cs +++ b/Vocaluxe/Screens/CScreenScore.cs @@ -157,9 +157,9 @@ namespace Vocaluxe.Screens { if (_StaticPointsBarDrawnPoints[p] < players[p].Points) { - if (CConfig.ScoreAnimationTime >= 1) + if (CConfig.Config.Game.ScoreAnimationTime >= 1) { - _StaticPointsBarDrawnPoints[p] = (_Timer.ElapsedMilliseconds / 1000f) / CConfig.ScoreAnimationTime * 10000; + _StaticPointsBarDrawnPoints[p] = (_Timer.ElapsedMilliseconds / 1000f) / CConfig.Config.Game.ScoreAnimationTime * 10000; if (_StaticPointsBarDrawnPoints[p] > players[p].Points) @@ -339,7 +339,7 @@ namespace Vocaluxe.Screens _Statics[_StaticAvatar[p, CGame.NumPlayers - 1]].Texture = CProfiles.GetAvatarTextureFromProfile(players[p].ProfileID); } - if (CConfig.ScoreAnimationTime < 1) + if (CConfig.Config.Game.ScoreAnimationTime < 1) { for (int p = 0; p < CGame.NumPlayers; p++) { diff --git a/Vocaluxe/Screens/CScreenSing.cs b/Vocaluxe/Screens/CScreenSing.cs index 5c992f0f..6b3f8dcc 100644 --- a/Vocaluxe/Screens/CScreenSing.cs +++ b/Vocaluxe/Screens/CScreenSing.cs @@ -178,22 +178,22 @@ namespace Vocaluxe.Screens break; case Keys.T: - var mode = (int)CConfig.TimerMode; + var mode = (int)CConfig.Config.Game.TimerMode; mode++; if (mode > Enum.GetNames(typeof(ETimerMode)).Length - 1) mode = 0; - CConfig.TimerMode = (ETimerMode)mode; + CConfig.Config.Game.TimerMode = (ETimerMode)mode; CConfig.SaveConfig(); break; case Keys.I: - mode = (int)CConfig.PlayerInfo; + mode = (int)CConfig.Config.Theme.PlayerInfo; mode++; if (mode > Enum.GetNames(typeof(EPlayerInfo)).Length - 1) mode = 0; - CConfig.PlayerInfo = (EPlayerInfo)mode; + CConfig.Config.Theme.PlayerInfo = (EPlayerInfo)mode; CConfig.SaveConfig(); _SetVisibility(); if (CGame.GetSong() != null) @@ -259,7 +259,7 @@ namespace Vocaluxe.Screens CSong song = CGame.GetSong(); song.VideoAspect = _VideoAspect; - if (CConfig.SaveModifiedSongs == EOffOn.TR_CONFIG_ON) + if (CConfig.Config.Debug.SaveModifiedSongs == EOffOn.TR_CONFIG_ON) song.Save(); break; } @@ -344,12 +344,13 @@ namespace Vocaluxe.Screens for (int p = 0; p < CGame.NumPlayers; p++) { _SingNotes[_SingBars].PlayerNotes[p].Alpha = alpha[CGame.Players[p].VoiceNr * 2]; - if (CConfig.FadePlayerInfo == EFadePlayerInfo.TR_CONFIG_FADEPLAYERINFO_INFO || CConfig.FadePlayerInfo == EFadePlayerInfo.TR_CONFIG_FADEPLAYERINFO_ALL) + if (CConfig.Config.Theme.FadePlayerInfo == EFadePlayerInfo.TR_CONFIG_FADEPLAYERINFO_INFO || + CConfig.Config.Theme.FadePlayerInfo == EFadePlayerInfo.TR_CONFIG_FADEPLAYERINFO_ALL) { _Statics[_StaticAvatars[p, CGame.NumPlayers - 1]].Alpha = alpha[CGame.Players[p].VoiceNr * 2]; _Texts[_TextNames[p, CGame.NumPlayers - 1]].Alpha = alpha[CGame.Players[p].VoiceNr * 2]; } - if (CConfig.FadePlayerInfo == EFadePlayerInfo.TR_CONFIG_FADEPLAYERINFO_ALL) + if (CConfig.Config.Theme.FadePlayerInfo == EFadePlayerInfo.TR_CONFIG_FADEPLAYERINFO_ALL) { _Statics[_StaticScores[p, CGame.NumPlayers - 1]].Alpha = alpha[CGame.Players[p].VoiceNr * 2]; _Statics[_StaticAvatars[p, CGame.NumPlayers - 1]].Alpha = alpha[CGame.Players[p].VoiceNr * 2]; @@ -381,7 +382,7 @@ namespace Vocaluxe.Screens _Texts[_TextScores[p, CGame.NumPlayers - 1]].Text = CGame.Players[p].Points.ToString(fmtString); } - if (_CurrentVideo != null && !_FadeOut && CConfig.VideosInSongs == EOffOn.TR_CONFIG_ON) + if (_CurrentVideo != null && !_FadeOut && CConfig.Config.Video.VideosInSongs == EOffOn.TR_CONFIG_ON) CVideo.GetFrame(_CurrentVideo, _CurrentTime); if (_Webcam) @@ -411,7 +412,7 @@ namespace Vocaluxe.Screens _SingNotes[_SingBars].Init(0); foreach (CLyric lyric in _Lyrics) - lyric.LyricStyle = CConfig.LyricStyle; + lyric.LyricStyle = CConfig.Config.Theme.LyricStyle; for (int p = 0; p < CGame.NumPlayers; p++) _Statics[_StaticAvatars[p, CGame.NumPlayers - 1]].Aspect = EAspect.Crop; @@ -439,7 +440,7 @@ namespace Vocaluxe.Screens { CTextureRef background; var aspect = EAspect.Crop; - if (_CurrentVideo != null && CConfig.VideosInSongs == EOffOn.TR_CONFIG_ON && !_Webcam) + if (_CurrentVideo != null && CConfig.Config.Video.VideosInSongs == EOffOn.TR_CONFIG_ON && !_Webcam) { background = _CurrentVideo.Texture; aspect = _VideoAspect; @@ -463,7 +464,7 @@ namespace Vocaluxe.Screens base.Draw(); - switch (CConfig.TimerLook) + switch (CConfig.Config.Theme.TimerLook) { case ETimerLook.TR_CONFIG_TIMERLOOK_NORMAL: CDraw.DrawTexture(_Statics[_StaticTimeLine].Texture, _Statics[_StaticTimeLine].Rect, new SColorF(1, 1, 1, 1), _TimeLineRect); @@ -636,9 +637,9 @@ namespace Vocaluxe.Screens } else { - bool lyricsOnTop = CConfig.LyricsPosition == ELyricsPosition.TR_CONFIG_LYRICSPOSITION_TOP - || CConfig.LyricsPosition == ELyricsPosition.TR_CONFIG_LYRICSPOSITION_BOTH - || (CConfig.LyricsPosition == ELyricsPosition.TR_CONFIG_LYRICSPOSITION_DYNAMIC && _DynamicLyricsTop); + bool lyricsOnTop = CConfig.Config.Game.LyricsPosition == ELyricsPosition.TR_CONFIG_LYRICSPOSITION_TOP + || CConfig.Config.Game.LyricsPosition == ELyricsPosition.TR_CONFIG_LYRICSPOSITION_BOTH + || (CConfig.Config.Game.LyricsPosition == ELyricsPosition.TR_CONFIG_LYRICSPOSITION_DYNAMIC && _DynamicLyricsTop); _Lyrics[_LyricMainTop].Visible = lyricsOnTop; _Lyrics[_LyricSubTop].Visible = lyricsOnTop; _Statics[_StaticLyricsTop].Visible = lyricsOnTop; @@ -647,9 +648,9 @@ namespace Vocaluxe.Screens private void _SetNormalLyricsVisibility() { - bool visible = CConfig.LyricsPosition == ELyricsPosition.TR_CONFIG_LYRICSPOSITION_BOTTOM - || CConfig.LyricsPosition == ELyricsPosition.TR_CONFIG_LYRICSPOSITION_BOTH - || (CConfig.LyricsPosition == ELyricsPosition.TR_CONFIG_LYRICSPOSITION_DYNAMIC && _DynamicLyricsBottom); + bool visible = CConfig.Config.Game.LyricsPosition == ELyricsPosition.TR_CONFIG_LYRICSPOSITION_BOTTOM + || CConfig.Config.Game.LyricsPosition == ELyricsPosition.TR_CONFIG_LYRICSPOSITION_BOTH + || (CConfig.Config.Game.LyricsPosition == ELyricsPosition.TR_CONFIG_LYRICSPOSITION_DYNAMIC && _DynamicLyricsBottom); _Lyrics[_LyricMain].Visible = visible; _Lyrics[_LyricSub].Visible = visible; _Statics[_StaticLyrics].Visible = visible; @@ -694,11 +695,11 @@ namespace Vocaluxe.Screens if (firstNoteTime <= currentTime + 10f) { //First line has no predecessor or line has to be shown - if (j == 0 || firstNoteTime - CConfig.MinLineBreakTime <= currentTime) + if (j == 0 || firstNoteTime - CConfig.Config.Game.MinLineBreakTime <= currentTime) return j; float lastNoteTime = CGame.GetTimeFromBeats(lines[j - 1].LastNoteBeat, song.BPM); //No line break if last line is not fully evaluated (with 50% tolerance -> tested so notes are drawn) - if (lastNoteTime + CConfig.MicDelay / 1000f * 1.5f >= currentTime) + if (lastNoteTime + CConfig.Config.Record.MicDelay / 1000f * 1.5f >= currentTime) return j - 1; return j; } @@ -880,12 +881,12 @@ namespace Vocaluxe.Screens bool isIvisible = numplayer + 1 == CGame.NumPlayers && player <= CGame.NumPlayers; _Texts[_TextScores[player, numplayer]].Visible = isIvisible; _Texts[_TextNames[player, numplayer]].Visible = isIvisible && - (CConfig.PlayerInfo == EPlayerInfo.TR_CONFIG_PLAYERINFO_BOTH || - CConfig.PlayerInfo == EPlayerInfo.TR_CONFIG_PLAYERINFO_NAME); + (CConfig.Config.Theme.PlayerInfo == EPlayerInfo.TR_CONFIG_PLAYERINFO_BOTH || + CConfig.Config.Theme.PlayerInfo == EPlayerInfo.TR_CONFIG_PLAYERINFO_NAME); _Statics[_StaticScores[player, numplayer]].Visible = isIvisible; _Statics[_StaticAvatars[player, numplayer]].Visible = isIvisible && - (CConfig.PlayerInfo == EPlayerInfo.TR_CONFIG_PLAYERINFO_BOTH || - CConfig.PlayerInfo == EPlayerInfo.TR_CONFIG_PLAYERINFO_AVATAR); + (CConfig.Config.Theme.PlayerInfo == EPlayerInfo.TR_CONFIG_PLAYERINFO_BOTH || + CConfig.Config.Theme.PlayerInfo == EPlayerInfo.TR_CONFIG_PLAYERINFO_AVATAR); } } @@ -1233,7 +1234,7 @@ namespace Vocaluxe.Screens if (totalTime <= 0f) return; - switch (CConfig.TimerMode) + switch (CConfig.Config.Game.TimerMode) { case ETimerMode.TR_CONFIG_TIMERMODE_CURRENT: var min = (int)Math.Floor(currentTime / 60f); @@ -1255,7 +1256,7 @@ namespace Vocaluxe.Screens } - switch (CConfig.TimerLook) + switch (CConfig.Config.Theme.TimerLook) { case ETimerLook.TR_CONFIG_TIMERLOOK_NORMAL: _TimeLineRect.W = _Statics[_StaticTimeLine].Rect.W * (currentTime / totalTime); @@ -1285,7 +1286,7 @@ namespace Vocaluxe.Screens private void _PrepareTimeLine() { CStatic stat = _Statics[_StaticTimeLine]; - switch (CConfig.TimerLook) + switch (CConfig.Config.Theme.TimerLook) { case ETimerLook.TR_CONFIG_TIMERLOOK_NORMAL: _TimeLineRect = stat.Rect; diff --git a/Vocaluxe/Screens/CScreenSong.cs b/Vocaluxe/Screens/CScreenSong.cs index 2adf26e8..3111ac01 100644 --- a/Vocaluxe/Screens/CScreenSong.cs +++ b/Vocaluxe/Screens/CScreenSong.cs @@ -717,7 +717,7 @@ namespace Vocaluxe.Screens _SongMenu.OnHide(); - if (CGraphics.NextScreen != EScreens.ScreenNames || CConfig.BackgroundMusic == EBackgroundMusicOffOn.TR_CONFIG_OFF) + if (CGraphics.NextScreen != EScreens.ScreenNames || CConfig.Config.Sound.BackgroundMusic == EBackgroundMusicOffOn.TR_CONFIG_OFF) { CBackgroundMusic.Disabled = false; CSound.SetGlobalVolume(CConfig.BackgroundMusicVolume); @@ -1017,12 +1017,12 @@ namespace Vocaluxe.Screens { int start = 0; int curSelected = CSongs.IsInCategory ? _SongMenu.GetSelectedSongNr() : _SongMenu.GetSelectedCategory(); - bool firstLevel = CConfig.Tabs == EOffOn.TR_CONFIG_OFF && CSongs.IsInCategory; - bool secondSort = CConfig.Tabs == EOffOn.TR_CONFIG_ON && - (CConfig.SongSorting == ESongSorting.TR_CONFIG_ARTIST || - CConfig.SongSorting == ESongSorting.TR_CONFIG_ARTIST_LETTER || - CConfig.SongSorting == ESongSorting.TR_CONFIG_FOLDER || - CConfig.SongSorting == ESongSorting.TR_CONFIG_TITLE_LETTER); + bool firstLevel = CConfig.Config.Game.Tabs == EOffOn.TR_CONFIG_OFF && CSongs.IsInCategory; + bool secondSort = CConfig.Config.Game.Tabs == EOffOn.TR_CONFIG_ON && + (CConfig.Config.Game.SongSorting == ESongSorting.TR_CONFIG_ARTIST || + CConfig.Config.Game.SongSorting == ESongSorting.TR_CONFIG_ARTIST_LETTER || + CConfig.Config.Game.SongSorting == ESongSorting.TR_CONFIG_FOLDER || + CConfig.Config.Game.SongSorting == ESongSorting.TR_CONFIG_TITLE_LETTER); if (firstLevel && !secondSort) { //TODO: What's to do with multiple tags? @@ -1030,7 +1030,7 @@ namespace Vocaluxe.Screens ReadOnlyCollection songs = CSongs.VisibleSongs; int ct = songs.Count; int visibleID = -1; - switch (CConfig.SongSorting) + switch (CConfig.Config.Game.SongSorting) { case ESongSorting.TR_CONFIG_ARTIST: case ESongSorting.TR_CONFIG_ARTIST_LETTER: @@ -1066,7 +1066,7 @@ namespace Vocaluxe.Screens ReadOnlyCollection songs = CSongs.VisibleSongs; int ct = songs.Count; int visibleID = -1; - switch (CConfig.SongSorting) + switch (CConfig.Config.Game.SongSorting) { case ESongSorting.TR_CONFIG_FOLDER: case ESongSorting.TR_CONFIG_TITLE_LETTER: