public static bool CheckRequirements() { #if WIN if (!_IsVC2010Installed()) { CLog.Fatal( "VC++ 2010 Redistributables are missing. Please install them first. \r\nDownload(x86): https://www.microsoft.com/de-de/download/details.aspx?id=5555 \r\nDownload(x64): https://www.microsoft.com/de-de/download/details.aspx?id=14632"); return(false); } /* * if (!_IsVC2012Installed()) * { * CLog.Fatal( * "VC++ 2012 Redistributables are missing. Please install them first.\r\nDownload: http://www.microsoft.com/de-de/download/details.aspx?id=30679"); * return false; * } * bool vc2008Installed = _IsVC2008Installed(); * if (!vc2008Installed) * { * CLog.Fatal( * "VC++ 2008 Redistributables are missing. Portaudio might not be working.\r\nDownload: http://www.microsoft.com/de-de/download/details.aspx?id=29"); * } * if (!vc2008Installed && !_IsVC2010Installed()) * { * CLog.Fatal( * "VC++ 2010 and 2008 Redistributables are missing. Please install them first. VC++ 2008 is preferred as Portaudio doesn't work with VC++ 2010.\r\nDownload(2008): http://www.microsoft.com/de-de/download/details.aspx?id=29 \r\nDownload(2010): http://www.microsoft.com/de-de/download/details.aspx?id=5555"); * return false; * } */ #endif //TODO: check for dependencies on linux? return(true); }
// ReSharper disable InconsistentNaming private static void Main(string[] args) // ReSharper restore InconsistentNaming { #if !DEBUG AppDomain.CurrentDomain.UnhandledException += UnhandledExceptionHandler; #endif AppDomain.CurrentDomain.AssemblyResolve += _AssemblyResolver; COSFunctions.AddEnvironmentPath(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "libs\\unmanaged\\")); #if ARCH_X86 COSFunctions.AddEnvironmentPath(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "libs\\unmanaged\\x86\\")); #endif #if ARCH_X64 COSFunctions.AddEnvironmentPath(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "libs\\unmanaged\\x64\\")); #endif // Close program if there is another instance running if (!_EnsureSingleInstance()) { return; } #if !DEBUG try { _Run(args); } catch (Exception e) { CLog.Fatal(e, "Unhandled error: {ErrorMessage}", CLog.Params(e.Message)); } #else _Run(args); #endif _CloseProgram(); }
/// <summary> /// Loads the currently selected theme trying all others if current theme failed loading<br /> /// Therefore CConfig.Theme/Skin might be changed!<br /> /// Closes the program on failure! /// </summary> public static void Load() { 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()) { break; } theme.Unload(); CLog.Error("Failed to load theme {ThemeName}! Removing...", CLog.Params(theme.Name, theme), true); _Themes.Remove(theme); theme = _Themes.FirstOrDefault(th => th is CBaseTheme); } CurrentThemes.Add(-1, theme); if (theme == null) { CLog.Fatal("No themes found! Cannot continue!"); } else { 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); } } }
public override bool Init() { string oldDBFilePath = Path.Combine(CSettings.DataFolder, CSettings.FileNameOldHighscoreDB); if (File.Exists(oldDBFilePath)) { if (File.Exists(_FilePath)) { if (!_CreateOrConvert(oldDBFilePath)) { CLog.Fatal("Cannot init Highscore DB: Error opening old database: {DBFile}" + CLog.Params(oldDBFilePath)); return(false); } if (!_CreateOrConvert(_FilePath)) { CLog.Fatal("Cannot init Highscore DB: Error opening database: {DBFile}", CLog.Params(_FilePath)); return(false); } if (!_ImportData(oldDBFilePath)) { CLog.Fatal("Cannot init Highscore DB: Error importing data"); return(false); } } else { File.Copy(oldDBFilePath, _FilePath); if (!_CreateOrConvert(_FilePath)) { CLog.Fatal("Cannot init Highscore DB: Error opening database: {DBFile}" + CLog.Params(_FilePath)); return(false); } } File.Delete(oldDBFilePath); } else if (!_CreateOrConvert(_FilePath)) { CLog.Fatal("Cannot init Highscore DB: Error opening database: {DBFile}", CLog.Params(_FilePath)); return(false); } return(true); }
private static int _GetFontIndex(string fontName) { if (fontName != "") { int index = _GetPartyFontIndex(fontName, PartyModeID); if (index < 0) { index = _GetThemeFontIndex(fontName, CConfig.Config.Theme.Theme); } if (index >= 0) { return(index); } for (int i = 0; i < _FontFamilies.Count; i++) { if (_FontFamilies[i].Name == fontName) { return(i); } } if (!_LoggedMissingFonts.Contains(fontName)) { _LoggedMissingFonts.Add(fontName); CLog.Error("Font \"" + fontName + "\" not found!"); } } else { CLog.Error("Empty fontName requested"); } if (_FontFamilies.Count == 0) { CLog.Fatal("No fonts found!"); } return(0); }
private static void UnhandledExceptionHandler(object sender, UnhandledExceptionEventArgs args) { var e = (Exception)args.ExceptionObject; CLog.Fatal(e, "Unhandled exception: {ExceptionMessage}", CLog.Params(e.Message)); }
public virtual void LoadTheme(string xmlPath) { ThemePath = xmlPath; string file = Path.Combine(xmlPath, ThemeName + ".xml"); try { CXmlDeserializer deserializer = new CXmlDeserializer(new CLoadThemeErrorHandler()); Theme = deserializer.Deserialize <SThemeScreen>(file); foreach (SThemeBackground bg in Theme.Backgrounds) { _AddBackground(new CBackground(bg, PartyModeID), bg.Name); } foreach (SThemeButton bt in Theme.Buttons) { _AddButton(new CButton(bt, PartyModeID), bt.Name); } foreach (SThemeEqualizer eq in Theme.Equalizers) { _AddEqualizer(new CEqualizer(eq, PartyModeID), eq.Name); } foreach (SThemeLyrics ly in Theme.Lyrics) { _AddLyric(new CLyric(ly, PartyModeID), ly.Name); } foreach (SThemeNameSelection ns in Theme.NameSelections) { _AddNameSelection(new CNameSelection(ns, PartyModeID), ns.Name); } foreach (SThemeParticleEffect pe in Theme.ParticleEffects) { _AddParticleEffect(new CParticleEffect(pe, PartyModeID), pe.Name); } foreach (SThemePlaylist pl in Theme.Playlists) { _AddPlaylist(new CPlaylist(pl, PartyModeID), pl.Name); } foreach (SThemeProgressBar pb in Theme.ProgressBars) { _AddProgressBar(new CProgressBar(pb, PartyModeID), pb.Name); } foreach (SThemeScreenSetting ss in Theme.ScreenSettings) { _AddScreenSetting(new CScreenSetting(ss, PartyModeID), ss.Name); } foreach (SThemeSelectSlide sl in Theme.SelectSlides) { _AddSelectSlide(new CSelectSlide(sl, PartyModeID), sl.Name); } foreach (SThemeSingBar sb in Theme.SingNotes) { _AddSingNote(new CSingNotes(sb, PartyModeID), sb.Name); } foreach (SThemeSongMenu sm in Theme.SongMenus) { _AddSongMenu(CSongMenuFactory.CreateSongMenu(sm, PartyModeID), sm.Name); } foreach (SThemeStatic st in Theme.Statics) { _AddStatic(new CStatic(st, PartyModeID), st.Name); } foreach (SThemeText te in Theme.Texts) { _AddText(new CText(te, PartyModeID), te.Name); } if (_ScreenVersion != Theme.Informations.ScreenVersion) { string msg = "Can't load screen file of screen \"" + ThemeName + "\", "; if (Theme.Informations.ScreenVersion < _ScreenVersion) { msg += "the file ist outdated! "; } else { msg += "the file is for newer program versions! "; } msg += "Current screen version is " + _ScreenVersion; CLog.Error(msg); } foreach (IThemeable el in _Elements.Select(_GetElement).OfType <IThemeable>()) { el.LoadSkin(); } } catch (Exception e) { CLog.Fatal(e, "Error while reading {ThemeName}.xml", CLog.Params(ThemeName), true); } }
public override void LoadTheme(string xmlPath) { bool ressourceOK = true; //Vocaluxe-Logo ressourceOK &= CDataBase.GetCreditsRessource("Logo_voc.png", ref _TexLogo); //Little stars for logo ressourceOK &= CDataBase.GetCreditsRessource("PerfectNoteStar.png", ref _TexPerfectNoteStar); ressourceOK &= CDataBase.GetCreditsRessource("redDot.png", ref _TexRedDot); ressourceOK &= CDataBase.GetCreditsRessource("blueDot.png", ref _TexBlueDot); ressourceOK &= CDataBase.GetCreditsRessource("brunzel.png", ref _TexNameBrunzel); ressourceOK &= CDataBase.GetCreditsRessource("Darkice.png", ref _TexNameDarkice); ressourceOK &= CDataBase.GetCreditsRessource("flokuep.png", ref _TexNameFlokuep); ressourceOK &= CDataBase.GetCreditsRessource("flamefire.png", ref _TexNameFlamefire); ressourceOK &= CDataBase.GetCreditsRessource("lukeIam.png", ref _TexNameLukeIam); ressourceOK &= CDataBase.GetCreditsRessource("bohning.png", ref _TexNameBohning); ressourceOK &= CDataBase.GetCreditsRessource("mesand.png", ref _TexNameMesand); ressourceOK &= CDataBase.GetCreditsRessource("babene03.png", ref _TexNameBabene03); if (!ressourceOK) { CLog.Fatal("Could not load all ressources!"); } //Prepare Text int lastY = 280; foreach (string[] paragraph in _Paragraphs) { string line = ""; for (int e = 0; e < paragraph.Length; e++) { if (paragraph[e] == null) { continue; } string newLine = " " + paragraph[e]; CText text = GetNewText(75, lastY, -2, 25, -1, EAlignment.Left, EStyle.Bold, "Outline", new SColorF(1, 1, 1, 1), line); text.Visible = false; if (CFonts.GetTextBounds(text).Width < (CSettings.RenderW - 220)) { line += newLine; //Check if all words are used if ((e + 1) == paragraph.Length) { text.Text = line; _ParagraphTexts.Add(text); line = ""; lastY += 40; } } else { _ParagraphTexts.Add(text); line = newLine; lastY += 27; } _AddText(text); } } CBackground bg = new CBackground(_BGTheme, -1); bg.LoadSkin(); _AddBackground(bg); //Vocaluxe-Logo _Logo = GetNewStatic(_TexLogo, new SColorF(1, 1, 1, 1), new SRectF((float)(CSettings.RenderW - _TexLogo.OrigSize.Width) / 2, -270, _TexLogo.OrigSize.Width, _TexLogo.OrigSize.Height, -2)); _AddStatic(_Logo); //Little stars for logo var numstars = (int)(_Logo.Rect.W * 0.25f / 2f); var partRect = new SRectF(_Logo.Rect.X, _Logo.Rect.Y, _Logo.Rect.W, _Logo.Rect.H, -1); _StarsRed = _GetStarParticles(numstars, true, partRect, true); _StarsBlue = _GetStarParticles(numstars, false, partRect, true); _AddParticleEffect(_StarsRed); _AddParticleEffect(_StarsBlue); //Credit names _CreditNames = new List <CCreditName>(); _AddNewCreditName(_TexNameBrunzel, 502, 29, true); _AddNewCreditName(_TexNameDarkice, 360, 55, true); _AddNewCreditName(_TexNameFlokuep, 214, 14, true); _AddNewCreditName(_TexNameFlamefire, 496, 46, true); _AddNewCreditName(_TexNameLukeIam, 411, 26, true); _AddNewCreditName(_TexNameBohning, 383, 54, false); _AddNewCreditName(_TexNameMesand, 525, 13, false); _AddNewCreditName(_TexNameBabene03, 33, 26, false); _AddTranslations(); }
/// <summary> /// Creates a new Instance of the CDirect3D Class /// </summary> public CDirect3D() { _Form = new CRenderFormHook { ClientSize = new Size(CConfig.Config.Graphics.ScreenW * CConfig.Config.Graphics.NumScreens, CConfig.Config.Graphics.ScreenH) }; try { _D3D = new Direct3D(); } catch (Direct3DX9NotFoundException e) { CLog.Error(e, "No DirectX runtimes were found, please download and install them from http://www.microsoft.com/download/en/details.aspx?id=8109"); } _Form.KeyDown += _OnKeyDown; _Form.PreviewKeyDown += _OnPreviewKeyDown; _Form.KeyPress += _OnKeyPress; _Form.KeyUp += _OnKeyUp; _Form.MouseMove += _OnMouseMove; _Form.MouseWheel += _OnMouseWheel; _Form.MouseDown += _OnMouseDown; _Form.MouseUp += _OnMouseUp; _Form.MouseLeave += _OnMouseLeave; _Form.MouseEnter += _OnMouseEnter; _PresentParameters = new PresentParameters { Windowed = true, SwapEffect = SwapEffect.Discard, BackBufferHeight = CConfig.Config.Graphics.ScreenH, BackBufferWidth = CConfig.Config.Graphics.ScreenW * CConfig.Config.Graphics.NumScreens, BackBufferFormat = _D3D.Adapters.DefaultAdapter.CurrentDisplayMode.Format, Multisample = MultisampleType.None, MultisampleQuality = 0 }; //Apply antialiasing and check if antialiasing mode is supported #region Antialiasing int quality; MultisampleType msType; switch (CConfig.Config.Graphics.AAMode) { case EAntiAliasingModes.X2: msType = MultisampleType.TwoSamples; break; case EAntiAliasingModes.X4: msType = MultisampleType.FourSamples; break; case EAntiAliasingModes.X8: msType = MultisampleType.EightSamples; break; case EAntiAliasingModes.X16: case EAntiAliasingModes.X32: //x32 is not supported, fallback to x16 msType = MultisampleType.SixteenSamples; break; default: msType = MultisampleType.None; break; } if ( !_D3D.CheckDeviceMultisampleType(_D3D.Adapters.DefaultAdapter.Adapter, DeviceType.Hardware, _D3D.Adapters.DefaultAdapter.CurrentDisplayMode.Format, false, msType, out quality)) { CLog.Error("[Direct3D] This AAMode is not supported by this device or driver, fallback to no AA"); msType = MultisampleType.None; quality = 1; } _PresentParameters.Multisample = msType; _PresentParameters.MultisampleQuality = quality - 1; #endregion Antialiasing //Apply the VSync configuration _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); CreateFlags flags = (caps.DeviceCaps & DeviceCaps.HWTransformAndLight) != 0 ? CreateFlags.HardwareVertexProcessing : CreateFlags.SoftwareVertexProcessing; //Check if Pow2 textures are needed _NonPowerOf2TextureSupported = true; _NonPowerOf2TextureSupported &= (caps.TextureCaps & TextureCaps.Pow2) == 0; _NonPowerOf2TextureSupported &= (caps.TextureCaps & TextureCaps.NonPow2Conditional) == 0; _NonPowerOf2TextureSupported &= (caps.TextureCaps & TextureCaps.SquareOnly) == 0; try { _Device = new Device(_D3D, _D3D.Adapters.DefaultAdapter.Adapter, DeviceType.Hardware, _Form.Handle, flags, _PresentParameters); } catch (Exception e) { CLog.Error(e, "Error during D3D device creation."); } finally { if (_Device == null || _Device.Disposed) { CLog.Fatal( "Something went wrong during device creating, please check if your DirectX redistributables and grafic card drivers are up to date. You can download the DirectX runtimes at http://www.microsoft.com/download/en/details.aspx?id=8109"); } } }