private static void _CloseProgram() { // Unloading in reverse order try { CController.Close(); CVocaluxeServer.Close(); CGraphics.Close(); CThemes.Close(); CCover.Close(); CFonts.Close(); CBackgroundMusic.Close(); CWebcam.Close(); CDataBase.Close(); CVideo.Close(); CRecord.Close(); CSound.Close(); CDraw.Close(); } catch (Exception e) { CLog.LogError("Error during shutdown!", false, false, e); } GC.Collect(); // Do a GC run here before we close logs to have finalizers run try { CLog.Close(); // Do this last, so we get all log entries! } catch (Exception) {} Environment.Exit(Environment.ExitCode); }
public void Load(string videoName) { _VideoStream = CThemes.GetSkinVideo(videoName, -1, false); if (_VideoStream == null) { return; } _Loaded = true; CVideo.Pause(_VideoStream); }
public void LoadSkin() { SThemeCursor theme = CThemes.GetCursorTheme(); _Cursor = CDraw.CopyTexture(CThemes.GetSkinTexture(theme.SkinName, -1)); theme.Color.Get(-1, out _Cursor.Color); _Cursor.Rect.W = theme.W; _Cursor.Rect.H = theme.H; _Cursor.Rect.Z = CSettings.ZNear; }
public static void ReloadTheme() { _Cursor.ReloadSkin(); foreach (IMenu screen in _Screens) { screen.ReloadTheme(CThemes.GetThemeScreensPath(screen.PartyModeID)); } foreach (IMenu popup in _PopupScreens) { popup.ReloadTheme(CThemes.GetThemeScreensPath(popup.PartyModeID)); } CParty.ReloadTheme(); }
public static void LoadTheme() { _Cursor.LoadSkin(); for (int i = 0; i < _Screens.Count; i++) { CLog.StartBenchmark("Load Theme " + Enum.GetNames(typeof(EScreen))[i]); _Screens[i].Init(); _Screens[i].LoadTheme(CThemes.GetThemeScreensPath(_Screens[i].PartyModeID)); CLog.StopBenchmark("Load Theme " + Enum.GetNames(typeof(EScreen))[i]); } foreach (IMenu popup in _PopupScreens) { popup.Init(); popup.LoadTheme(CThemes.GetThemeScreensPath(popup.PartyModeID)); } }
private void _OnChange() { if (CConfig.Config.Theme.Theme != _SelectSlides[_SelectSlideTheme].SelectedValue) { CConfig.Config.Theme.Theme = _SelectSlides[_SelectSlideTheme].SelectedValue; CThemes.Reload(); CGraphics.ReloadTheme(); _ResetSlides(); _ResumeBG(); return; } if (CConfig.Config.Theme.Skin != _SelectSlides[_SelectSlideSkin].SelectedValue) { CConfig.Config.Theme.Skin = _SelectSlides[_SelectSlideSkin].SelectedValue; CThemes.ReloadSkin(); CGraphics.ReloadSkin(); _ResetSlides(); _ResumeBG(); } }
private static bool _LoadPartyMode(string filePath, out SPartyMode pm) { CXmlDeserializer deser = new CXmlDeserializer(); try { pm = deser.Deserialize <SPartyMode>(filePath); if (pm.PartyModeSystemVersion != _PartyModeSystemVersion) { throw new Exception("Wrong PartyModeSystemVersion " + pm.PartyModeSystemVersion + " expected: " + _PartyModeSystemVersion); } if (pm.ScreenFiles.Count == 0) { throw new Exception("No ScreenFiles found"); } } catch (Exception e) { pm = new SPartyMode(); CLog.LogError("Error loading PartyMode file " + filePath + ": " + e.Message); return(false); } string pathToPm = Path.Combine(CSettings.ProgramFolder, CSettings.FolderNamePartyModes, pm.Info.Folder); string pathToCode = Path.Combine(pathToPm, CSettings.FolderNamePartyModeCode); var filesToCompile = new List <string>(); filesToCompile.AddRange(CHelper.ListFiles(pathToCode, "*.cs", false, true)); Assembly output = _CompileFiles(filesToCompile.ToArray()); if (output == null) { return(false); } object instance = output.CreateInstance(typeof(IPartyMode).Namespace + "." + pm.Info.Folder + "." + pm.Info.PartyModeFile, false, BindingFlags.Public | BindingFlags.Instance, null, new object[] { _NextID++ }, null, null); if (instance == null) { CLog.LogError("Error creating Instance of PartyMode file: " + filePath); return(false); } try { pm.PartyMode = (IPartyMode)instance; } catch (Exception e) { CLog.LogError("Error casting PartyMode file: " + filePath + "; " + e.Message); return(false); } if (!CLanguage.LoadPartyLanguageFiles(pm.PartyMode.ID, Path.Combine(pathToPm, CSettings.FolderNamePartyModeLanguages))) { CLog.LogError("Error loading language files for PartyMode: " + filePath); return(false); } if (!CThemes.ReadThemesFromFolder(Path.Combine(pathToPm, CSettings.FolderNameThemes), pm.PartyMode.ID)) { return(false); } if (!CThemes.LoadPartymodeTheme(pm.PartyMode.ID)) { return(false); } foreach (string screenfile in pm.ScreenFiles) { CMenuParty screen = _GetPartyScreenInstance(output, screenfile, pm.Info.Folder); if (screen != null) { screen.AssignPartyMode(pm.PartyMode); pm.PartyMode.AddScreen(screen, screenfile); } else { return(false); } } pm.PartyMode.LoadTheme(); pm.Info.ExtInfo = pm.PartyMode; return(true); }
public void Reload() { CThemes.Reload(); }
public SColorF GetPlayerColor(int playerNr) { return(CThemes.GetPlayerColor(playerNr)); }
public bool GetColor(string colorName, int partyModeID, out SColorF color) { return(CThemes.GetColor(colorName, partyModeID, out color)); }
public CVideoStream GetSkinVideo(string videoName, int partyModeID, bool loop) { return(CThemes.GetSkinVideo(videoName, partyModeID, loop)); }
public CTextureRef GetSkinTexture(string textureName, int partyModeID) { return(CThemes.GetSkinTexture(textureName, partyModeID)); }
public string GetThemeScreensPath(int partyModeID) { return(CThemes.GetThemeScreensPath(partyModeID)); }
private static void _Run(string[] args) { Application.DoEvents(); try { // Create data folder Directory.CreateDirectory(CSettings.DataFolder); // Init Log CLog.Init(); if (!CProgrammHelper.CheckRequirements()) { return; } CProgrammHelper.Init(); CLog.StartBenchmark("Init Program"); CMain.Init(); Application.DoEvents(); // Init Language CLog.StartBenchmark("Init Language"); if (!CLanguage.Init()) { throw new CLoadingException("Language"); } CLog.StopBenchmark("Init Language"); Application.DoEvents(); // load config CLog.StartBenchmark("Init Config"); CConfig.LoadCommandLineParams(args); CConfig.UseCommandLineParamsBefore(); CConfig.Init(); CConfig.UseCommandLineParamsAfter(); CLog.StopBenchmark("Init Config"); // Create folders CSettings.CreateFolders(); _SplashScreen = new CSplashScreen(); Application.DoEvents(); // Init Draw CLog.StartBenchmark("Init Draw"); if (!CDraw.Init()) { throw new CLoadingException("drawing"); } CLog.StopBenchmark("Init Draw"); Application.DoEvents(); // Init Playback CLog.StartBenchmark("Init Playback"); if (!CSound.Init()) { throw new CLoadingException("playback"); } CLog.StopBenchmark("Init Playback"); Application.DoEvents(); // Init Record CLog.StartBenchmark("Init Record"); if (!CRecord.Init()) { throw new CLoadingException("record"); } CLog.StopBenchmark("Init Record"); 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()) { throw new CLoadingException("webcam"); } CLog.StopBenchmark("Init Webcam"); Application.DoEvents(); // Init Background Music CLog.StartBenchmark("Init Background Music"); CBackgroundMusic.Init(); CLog.StopBenchmark("Init Background Music"); Application.DoEvents(); // Init Profiles CLog.StartBenchmark("Init Profiles"); CProfiles.Init(); CLog.StopBenchmark("Init Profiles"); Application.DoEvents(); // Init Fonts CLog.StartBenchmark("Init Fonts"); if (!CFonts.Init()) { throw new CLoadingException("fonts"); } CLog.StopBenchmark("Init Fonts"); Application.DoEvents(); // Theme System CLog.StartBenchmark("Init Theme"); if (!CThemes.Init()) { throw new CLoadingException("theme"); } CLog.StopBenchmark("Init Theme"); CLog.StartBenchmark("Load Theme"); CThemes.Load(); CLog.StopBenchmark("Load Theme"); Application.DoEvents(); // Load Cover CLog.StartBenchmark("Init Cover"); if (!CCover.Init()) { throw new CLoadingException("covertheme"); } CLog.StopBenchmark("Init Cover"); Application.DoEvents(); // Init Screens CLog.StartBenchmark("Init Screens"); CGraphics.Init(); CLog.StopBenchmark("Init Screens"); Application.DoEvents(); // Init Server CLog.StartBenchmark("Init Server"); CVocaluxeServer.Init(); CLog.StopBenchmark("Init Server"); Application.DoEvents(); // Init Input CLog.StartBenchmark("Init Input"); CController.Init(); CController.Connect(); CLog.StopBenchmark("Init Input"); Application.DoEvents(); // Init Game; CLog.StartBenchmark("Init Game"); CGame.Init(); CProfiles.Update(); CConfig.UsePlayers(); CLog.StopBenchmark("Init Game"); Application.DoEvents(); // Init Party Modes; CLog.StartBenchmark("Init Party Modes"); if (!CParty.Init()) { throw new CLoadingException("Party Modes"); } CLog.StopBenchmark("Init Party Modes"); Application.DoEvents(); //Only reasonable point to call GC.Collect() because initialization may cause lots of garbage //Rely on GC doing its job afterwards and call Dispose methods where appropriate GC.Collect(); CLog.StopBenchmark("Init Program"); } catch (Exception e) { MessageBox.Show("Error on start up: " + e.Message); CLog.LogError("Error on start up: " + e); if (_SplashScreen != null) { _SplashScreen.Close(); } _CloseProgram(); return; } Application.DoEvents(); // Start Main Loop if (_SplashScreen != null) { _SplashScreen.Close(); } CDraw.MainLoop(); }
private static void _Run(string[] args) { Application.DoEvents(); try { // Create data folder Directory.CreateDirectory(CSettings.DataFolder); // Init Log CLog.Init(CSettings.FolderNameLogs, CSettings.FileNameMainLog, CSettings.FileNameSongLog, CSettings.FileNameCrashMarker, CSettings.GetFullVersionText(), CReporter.ShowReporterFunc, ELogLevel.Information); if (!CProgrammHelper.CheckRequirements()) { return; } CProgrammHelper.Init(); using (CBenchmark.Time("Init Program")) { CMain.Init(); Application.DoEvents(); // Init Language using (CBenchmark.Time("Init Language")) { if (!CLanguage.Init()) { throw new CLoadingException("Language"); } } Application.DoEvents(); // load config using (CBenchmark.Time("Init Config")) { CConfig.LoadCommandLineParams(args); CConfig.UseCommandLineParamsBefore(); CConfig.Init(); CConfig.UseCommandLineParamsAfter(); } // Create folders CSettings.CreateFolders(); _SplashScreen = new CSplashScreen(); Application.DoEvents(); // Init Draw using (CBenchmark.Time("Init Draw")) { if (!CDraw.Init()) { throw new CLoadingException("drawing"); } } Application.DoEvents(); // Init Playback using (CBenchmark.Time("Init Playback")) { if (!CSound.Init()) { throw new CLoadingException("playback"); } } Application.DoEvents(); // Init Record using (CBenchmark.Time("Init Record")) { if (!CRecord.Init()) { throw new CLoadingException("record"); } } Application.DoEvents(); // Init VideoDecoder using (CBenchmark.Time("Init Videodecoder")) { if (!CVideo.Init()) { throw new CLoadingException("video"); } } Application.DoEvents(); // Init Database using (CBenchmark.Time("Init Database")) { if (!CDataBase.Init()) { throw new CLoadingException("database"); } } Application.DoEvents(); //Init Webcam using (CBenchmark.Time("Init Webcam")) { if (!CWebcam.Init()) { throw new CLoadingException("webcam"); } } Application.DoEvents(); // Init Background Music using (CBenchmark.Time("Init Background Music")) { CBackgroundMusic.Init(); } Application.DoEvents(); // Init Profiles using (CBenchmark.Time("Init Profiles")) { CProfiles.Init(); } Application.DoEvents(); // Init Fonts using (CBenchmark.Time("Init Fonts")) { if (!CFonts.Init()) { throw new CLoadingException("fonts"); } } Application.DoEvents(); // Theme System using (CBenchmark.Time("Init Theme")) { if (!CThemes.Init()) { throw new CLoadingException("theme"); } } using (CBenchmark.Time("Load Theme")) { CThemes.Load(); } Application.DoEvents(); // Load Cover using (CBenchmark.Time("Init Cover")) { if (!CCover.Init()) { throw new CLoadingException("covertheme"); } } Application.DoEvents(); // Init Screens using (CBenchmark.Time("Init Screens")) { CGraphics.Init(); } Application.DoEvents(); // Init Server using (CBenchmark.Time("Init Server")) { CVocaluxeServer.Init(); } Application.DoEvents(); // Init Input using (CBenchmark.Time("Init Input")) { CController.Init(); CController.Connect(); } Application.DoEvents(); // Init Game using (CBenchmark.Time("Init Game")) { CGame.Init(); CProfiles.Update(); CConfig.UsePlayers(); } Application.DoEvents(); // Init Party Modes using (CBenchmark.Time("Init Party Modes")) { if (!CParty.Init()) { throw new CLoadingException("Party Modes"); } } Application.DoEvents(); //Only reasonable point to call GC.Collect() because initialization may cause lots of garbage //Rely on GC doing its job afterwards and call Dispose methods where appropriate GC.Collect(); } } catch (Exception e) { CLog.Error(e, "Error on start up: {ExceptionMessage}", CLog.Params(e.Message), show: true); if (_SplashScreen != null) { _SplashScreen.Close(); } _CloseProgram(); return; } Application.DoEvents(); // Start Main Loop if (_SplashScreen != null) { _SplashScreen.Close(); } CDraw.MainLoop(); }