diff --git a/Vocaluxe/Base/CCover.cs b/Vocaluxe/Base/CCover.cs index 5b52371b..26eb6866 100644 --- a/Vocaluxe/Base/CCover.cs +++ b/Vocaluxe/Base/CCover.cs @@ -18,9 +18,6 @@ using System; using System.Collections.Generic; using System.IO; -using System.Linq; -using System.Text; -using System.Xml; using VocaluxeLib; using VocaluxeLib.Draw; @@ -35,7 +32,6 @@ namespace Vocaluxe.Base static class CCover { - private static readonly XmlWriterSettings _Settings = new XmlWriterSettings(); private static readonly Dictionary _Covers = new Dictionary(); private static readonly List _CoverThemes = new List(); @@ -43,14 +39,16 @@ namespace Vocaluxe.Base public static void Init() { - _Settings.Indent = true; - _Settings.Encoding = Encoding.UTF8; - _Settings.ConformanceLevel = ConformanceLevel.Document; - _LoadCoverThemes(); _LoadCover(CConfig.CoverTheme); } + public static void Close() + { + _UnloadCovers(); + _CoverThemes.Clear(); + } + /// /// Returns an array of CoverThemes-Names /// @@ -106,18 +104,23 @@ namespace Vocaluxe.Base /// /// Reloads cover to use a new cover-theme /// - public static void ReloadCover() + public static void ReloadCovers() + { + _UnloadCovers(); + _LoadCover(CConfig.CoverTheme); + } + + private static void _UnloadCovers() { lock (_Covers) { - foreach (string key in _Covers.Keys.ToList()) + foreach (string key in _Covers.Keys) { CTexture texture = _Covers[key]; CDraw.RemoveTexture(ref texture); } _Covers.Clear(); } - _LoadCover(CConfig.CoverTheme); } /// diff --git a/Vocaluxe/Base/CDraw.cs b/Vocaluxe/Base/CDraw.cs index f43d8542..f109645b 100644 --- a/Vocaluxe/Base/CDraw.cs +++ b/Vocaluxe/Base/CDraw.cs @@ -28,7 +28,7 @@ namespace Vocaluxe.Base { private static IDraw _Draw; - public static bool InitDraw() + public static bool Init() { if (_Draw != null) return false; diff --git a/Vocaluxe/Base/CGraphics.cs b/Vocaluxe/Base/CGraphics.cs index a4b5adcb..837cd713 100644 --- a/Vocaluxe/Base/CGraphics.cs +++ b/Vocaluxe/Base/CGraphics.cs @@ -106,6 +106,13 @@ namespace Vocaluxe.Base CLog.StopBenchmark("Load Theme"); } + public static void Close() + { + if (_CurrentPopupScreen != EPopupScreens.NoPopup) + _PopupScreens[(int)_CurrentPopupScreen].OnClose(); + _Screens[(int)_CurrentScreen].OnClose(); + } + public static void LoadTheme() { _Cursor.LoadTextures(); diff --git a/Vocaluxe/Base/CLanguage.cs b/Vocaluxe/Base/CLanguage.cs index 2cf54d9d..343aabc0 100644 --- a/Vocaluxe/Base/CLanguage.cs +++ b/Vocaluxe/Base/CLanguage.cs @@ -19,8 +19,6 @@ using System; using System.Collections.Generic; using System.IO; using System.Linq; -using System.Text; -using System.Xml; using VocaluxeLib; namespace Vocaluxe.Base @@ -42,7 +40,6 @@ namespace Vocaluxe.Base static class CLanguage { - private static readonly XmlWriterSettings _Settings = new XmlWriterSettings(); private static List _Languages; private static int _CurrentLanguage; private static int _FallbackLanguage; @@ -75,9 +72,6 @@ namespace Vocaluxe.Base public static void Init() { _Languages = new List(); - _Settings.Indent = true; - _Settings.Encoding = Encoding.UTF8; - _Settings.ConformanceLevel = ConformanceLevel.Document; var files = new List(); files.AddRange(CHelper.ListFiles(CSettings.FolderLanguages, "*.xml", true, true)); diff --git a/Vocaluxe/Base/Fonts/CFonts.cs b/Vocaluxe/Base/Fonts/CFonts.cs index 1c904e98..2c838aac 100644 --- a/Vocaluxe/Base/Fonts/CFonts.cs +++ b/Vocaluxe/Base/Fonts/CFonts.cs @@ -19,7 +19,6 @@ using System.Collections.Generic; using System.Drawing; using System.IO; using System.Linq; -using System.Text; using System.Xml; using VocaluxeLib; using VocaluxeLib.Menu; @@ -28,8 +27,6 @@ namespace Vocaluxe.Base.Fonts { static class CFonts { - private static readonly XmlWriterSettings _Settings = new XmlWriterSettings(); - private static readonly List _Fonts = new List(); private static int _CurrentFont; private static float _Height = 1f; @@ -58,10 +55,6 @@ namespace Vocaluxe.Base.Fonts public static void Init() { - _Settings.Indent = true; - _Settings.Encoding = Encoding.UTF8; - _Settings.ConformanceLevel = ConformanceLevel.Document; - _CurrentFont = 0; PartyModeID = -1; _BuildFonts(); diff --git a/Vocaluxe/Program.cs b/Vocaluxe/Program.cs index 5ee3826e..b7e0d20c 100644 --- a/Vocaluxe/Program.cs +++ b/Vocaluxe/Program.cs @@ -107,26 +107,17 @@ namespace Vocaluxe // Create folders CSettings.CreateFolders(); - Application.DoEvents(); _SplashScreen = new CSplashScreen(); Application.DoEvents(); // Init Draw CLog.StartBenchmark("Init Draw"); - if (!CDraw.InitDraw()) + if (!CDraw.Init()) throw new CLoadingException("drawing"); CLog.StopBenchmark("Init Draw"); Application.DoEvents(); - // Init Database - CLog.StartBenchmark("Init Database"); - if (!CDataBase.Init()) - throw new CLoadingException("database"); - CLog.StopBenchmark("Init Database"); - - Application.DoEvents(); - // Init Playback CLog.StartBenchmark("Init Playback"); if (!CSound.Init()) @@ -143,6 +134,22 @@ namespace Vocaluxe Application.DoEvents(); + // Init VideoDecoder + CLog.StartBenchmark("Init Videodecoder"); + if (!CVideo.Init()) + throw new CLoadingException("video"); + CLog.StopBenchmark("Init Videodecoder"); + + Application.DoEvents(); + + // Init Database + CLog.StartBenchmark("Init Database"); + if (!CDataBase.Init()) + throw new CLoadingException("database"); + CLog.StopBenchmark("Init Database"); + + Application.DoEvents(); + //Init Webcam CLog.StartBenchmark("Init Webcam"); if (!CWebcam.Init()) @@ -172,14 +179,6 @@ namespace Vocaluxe Application.DoEvents(); - // Init VideoDecoder - CLog.StartBenchmark("Init Videodecoder"); - if (!CVideo.Init()) - throw new CLoadingException("video"); - CLog.StopBenchmark("Init Videodecoder"); - - Application.DoEvents(); - // Load Cover CLog.StartBenchmark("Init Cover"); CCover.Init(); @@ -257,19 +256,22 @@ namespace Vocaluxe private static void _CloseProgram() { - // Unloading + // Unloading in reverse order try { - CVocaluxeServer.Close(); CController.Close(); + CVocaluxeServer.Close(); + CGraphics.Close(); + CCover.Close(); + CBackgroundMusic.Close(); + CWebcam.Close(); + CDataBase.Close(); + CVideo.Close(); CRecord.Close(); CSound.Close(); - CVideo.Close(); CDraw.Unload(); - CDataBase.Close(); - CWebcam.Close(); GC.Collect(); // Do a GC run here before we close logs to have finalizers run - CLog.CloseAll(); + CLog.CloseAll(); // Do this last, so we get all log entries! } catch (Exception) {} Environment.Exit(Environment.ExitCode); diff --git a/Vocaluxe/Screens/CScreenOptionsTheme.cs b/Vocaluxe/Screens/CScreenOptionsTheme.cs index 5bcbe620..a58226a8 100644 --- a/Vocaluxe/Screens/CScreenOptionsTheme.cs +++ b/Vocaluxe/Screens/CScreenOptionsTheme.cs @@ -179,7 +179,7 @@ namespace Vocaluxe.Screens CConfig.SaveConfig(); if (_OldCoverTheme != _SelectSlides[_SelectSlideCover].Selection) - CCover.ReloadCover(); + CCover.ReloadCovers(); if (_OldTheme != _SelectSlides[_SelectSlideTheme].Selection) { diff --git a/VocaluxeLib/Menu/SongMenu/CSongMenuTileBoard.cs b/VocaluxeLib/Menu/SongMenu/CSongMenuTileBoard.cs index 46781018..e15be31d 100644 --- a/VocaluxeLib/Menu/SongMenu/CSongMenuTileBoard.cs +++ b/VocaluxeLib/Menu/SongMenu/CSongMenuTileBoard.cs @@ -67,11 +67,11 @@ namespace VocaluxeLib.Menu.SongMenu { set { - _PlaySong(value); - _PreviewIdInternal = value; + if (value == base._PreviewId) + return; + base._PreviewId = value; _UpdatePreview(); } - get { return _PreviewIdInternal; } } public override int GetActualSelection() @@ -373,8 +373,7 @@ namespace VocaluxeLib.Menu.SongMenu if (!keyEvent.Handled) { _ActualSelection = _Locked; - if (_PreviewId != _Locked) - _PreviewId = _Locked; + _PreviewId = _Locked; for (int i = 0; i < _Tiles.Count; i++) _Tiles[i].Selected = _Locked == i + _Offset;