Example #1
0
        private float _GetFactor(char chr, TextFormatFlags flags)
        {
            if (CFonts.Style == EStyle.Normal)
                return 1f;

            EStyle style = CFonts.Style;

            CFonts.Style = EStyle.Normal;
            CFonts.Height = Sizeh;
            float hStyle, hNormal;
            using (Graphics g = Graphics.FromHwnd(IntPtr.Zero))
            {
                System.Drawing.Font fo = CFonts.GetFont();
                Size sizeB = TextRenderer.MeasureText(g, chr.ToString(), fo, new Size(int.MaxValue, int.MaxValue), flags);
                //SizeF size = g.MeasureString(chr.ToString(), fo);
                hNormal = sizeB.Height;
            }
            CFonts.Style = style;
            using (Graphics g = Graphics.FromHwnd(IntPtr.Zero))
            {
                System.Drawing.Font fo = CFonts.GetFont();
                Size sizeB = TextRenderer.MeasureText(g, chr.ToString(), fo, new Size(int.MaxValue, int.MaxValue), flags);
                //size = g.MeasureString(chr.ToString(), fo);
                hStyle = sizeB.Height;
            }
            return hNormal / hStyle;
        }
Example #2
0
 public RectangleF GetTextBounds(CText text, float Height)
 {
     CFonts.Height = Height;
     CFonts.SetFont(text.Fon);
     CFonts.Style = text.Style;
     return(new RectangleF(text.X, text.Y, CFonts.GetTextWidth(CLanguage.Translate(text.Text)), CFonts.GetTextHeight(CLanguage.Translate(text.Text))));
 }
Example #3
0
        private void OnChange()
        {
            if (_OldTheme != SelectSlides[htSelectSlides(SelectSlideTheme)].Selection)
            {
                CConfig.Theme = CTheme.ThemeNames[SelectSlides[htSelectSlides(SelectSlideTheme)].Selection];
                _OldTheme     = SelectSlides[htSelectSlides(SelectSlideTheme)].Selection;

                CTheme.UnloadSkins();
                CFonts.UnloadThemeFonts(CConfig.Theme);
                CTheme.ListSkins();
                CConfig.Skin = CTheme.SkinNames[0];
                _OldSkin     = 0;
                _TempSkin    = _OldSkin;

                CConfig.SaveConfig();

                CTheme.LoadSkins();
                CTheme.LoadTheme();
                CGraphics.ReloadTheme();

                OnShow();
                OnShowFinish();
                return;
            }

            if (_TempSkin != SelectSlides[htSelectSlides(SelectSlideSkin)].Selection)
            {
                _TempSkin = SelectSlides[htSelectSlides(SelectSlideSkin)].Selection;

                PauseBG();
                CConfig.Skin = CTheme.SkinNames[_TempSkin];
                CGraphics.ReloadSkin();
                ResumeBG();
            }
        }
Example #4
0
 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);
 }
Example #5
0
        public void DrawRelative(float rx, float ry, bool reflection, float reflectionSpace, float reflectionHeight, float rectHeight)
        {
            // Update Text
            Text = Text;

            float h = Height;

            float x = X + rx;
            float y = Y + ry;

            RectangleF bounds = CDraw.GetTextBounds(this);

            while (bounds.Width > Bounds.W)
            {
                h     -= 0.2f;
                y     += 0.1f;
                bounds = CDraw.GetTextBounds(this, h);
            }

            switch (Align)
            {
            case EAlignment.Center:
                x = x - bounds.Width / 2;
                break;

            case EAlignment.Right:
                x = x - bounds.Width;
                break;

            default:
                break;
            }

            SColorF CurrentColor = new SColorF(Color);

            if (Selected)
            {
                CurrentColor = new SColorF(SColor);
            }

            SColorF color = new SColorF(CurrentColor.R, CurrentColor.G, CurrentColor.B, CurrentColor.A * Alpha);

            CFonts.SetFont(Fon);
            CFonts.Style = Style;
            CFonts.DrawText(_Text, h, x, y, Z, color);

            if (reflection)
            {
                float space  = (rectHeight - Y - bounds.Height) * 2f + reflectionSpace;
                float height = reflectionHeight - (rectHeight - Y) + bounds.Height;
                CFonts.DrawTextReflection(_Text, h, x, y, Z, color, space, height);
            }

            if (Selected && (CSettings.GameState == EGameState.EditTheme))
            {
                CDraw.DrawColor(new SColorF(0.5f, 1f, 0.5f, 0.5f * CGraphics.GlobalAlpha), new SRectF(x, y, bounds.Width, bounds.Height, Z));
            }
        }
Example #6
0
        protected override bool _Load()
        {
            if (!_Data.Cursor.HasValue)
            {
                return(false);
            }

            return(CFonts.LoadThemeFonts(_Data.Fonts, Path.Combine(_Folder, Name, CSettings.FolderNameThemeFonts), Name, -1));
        }
Example #7
0
        public void Draw(float begin, float end)
        {
            RectangleF bounds = CDraw.GetTextBounds(this);

            float x = X;

            switch (Align)
            {
            case EAlignment.Center:
                x = X - bounds.Width / 2;
                break;

            case EAlignment.Right:
                x = X - bounds.Width;
                break;

            default:
                break;
            }

            SColorF CurrentColor = new SColorF(Color);

            if (Selected)
            {
                CurrentColor = new SColorF(SColor);
            }

            SColorF color = new SColorF(CurrentColor.R, CurrentColor.G, CurrentColor.B, CurrentColor.A * Alpha);

            CFonts.SetFont(Fon);
            CFonts.Style = Style;

            if (!EditMode)
            {
                CFonts.DrawText(Text, Height, x, Y, Z, color, begin, end);
            }
            else
            {
                CFonts.DrawText(Text + "|", Height, x, Y, Z, color, begin, end);
            }

            if (Reflection)
            {
                // TODO
            }

            if (Selected && (CSettings.GameState == EGameState.EditTheme))
            {
                CDraw.DrawColor(new SColorF(0.5f, 1f, 0.5f, 0.5f), new SRectF(x, Y, bounds.Width, bounds.Height, Z));
            }
        }
Example #8
0
        private void UpdateTextPosition()
        {
            if (_Text == String.Empty)
            {
                return;
            }

            CFonts.SetFont(Fon);
            CFonts.Style = Style;

            float      h      = Height;
            float      y      = Y;
            RectangleF bounds = CFonts.GetTextBounds(this);

            while (bounds.Width > Bounds.W)
            {
                h     -= 0.2f;
                y     += 0.1f;
                bounds = CFonts.GetTextBounds(this, h);
            }

            float x = X;

            switch (Align)
            {
            case EAlignment.Center:
                x = X - bounds.Width / 2;
                break;

            case EAlignment.Right:
                x = X - bounds.Width;
                break;

            default:
                break;
            }

            _DrawPosition.X      = x;
            _DrawPosition.Y      = y;
            _DrawPosition.tH     = h;
            _DrawPosition.Width  = bounds.Width;
            _DrawPosition.Height = bounds.Height;

            _PositionNeedsUpdate = false;
        }
Example #9
0
        public void Draw(bool ForceDraw)
        {
            if (!ForceDraw && !Visible && CSettings.GameState != EGameState.EditTheme)
            {
                return;
            }

            // Update Text
            Text = Text;

            if (_PositionNeedsUpdate)
            {
                UpdateTextPosition();
            }

            CFonts.SetFont(Fon);
            CFonts.Style = Style;

            SColorF CurrentColor = new SColorF(Color);

            if (Selected)
            {
                CurrentColor = new SColorF(SColor);
            }

            SColorF color = new SColorF(CurrentColor.R, CurrentColor.G, CurrentColor.B, CurrentColor.A * Alpha);


            CFonts.DrawText(_Text, _DrawPosition.tH, _DrawPosition.X, _DrawPosition.Y, Z, color);

            if (Reflection)
            {
                CFonts.DrawTextReflection(_Text, _DrawPosition.tH, _DrawPosition.X, _DrawPosition.Y, Z, color, ReflectionSpace, ReflectionHeight);
            }

            if (Selected && (CSettings.GameState == EGameState.EditTheme))
            {
                CDraw.DrawColor(
                    new SColorF(0.5f, 1f, 0.5f, 0.5f * CGraphics.GlobalAlpha),
                    new SRectF(_DrawPosition.X, _DrawPosition.Y, _DrawPosition.Width, _DrawPosition.Height, Z)
                    );
            }
        }
Example #10
0
        public override bool Draw()
        {
            base.DrawBG();

            //if (Snowflakes == null)
            //    Snowflakes = new CParticleEffect(300, new SColorF(1, 1, 1, 1), new SRectF(0, 0, CSettings.iRenderW, 0, 0.5f), "Snowflake", 25, EParticeType.Snow);

            //Snowflakes.Update();
            //Snowflakes.Draw();

            base.DrawFG();

            if (CSettings.VersionRevision != ERevision.Release)
            {
                CFonts.SetFont("Normal");
                CFonts.Style = EStyle.Normal;
                CDraw.DrawText(CSettings.GetFullVersionText(), 10, 680, 40);
            }

            return(true);
        }
Example #11
0
        private void SaveConfig()
        {
            CConfig.Theme          = CTheme.ThemeNames[SelectSlides[htSelectSlides(SelectSlideTheme)].Selection];
            CConfig.Skin           = CTheme.SkinNames[SelectSlides[htSelectSlides(SelectSlideSkin)].Selection];
            CConfig.CoverTheme     = CCover.CoverThemes[SelectSlides[htSelectSlides(SelectSlideCover)].Selection];
            CConfig.DrawNoteLines  = (EOffOn)SelectSlides[htSelectSlides(SelectSlideNoteLines)].Selection;
            CConfig.DrawToneHelper = (EOffOn)SelectSlides[htSelectSlides(SelectSlideToneHelper)].Selection;
            CConfig.TimerLook      = (ETimerLook)SelectSlides[htSelectSlides(SelectSlideTimerLook)].Selection;
            CConfig.FadePlayerInfo = (EFadePlayerInfo)SelectSlides[htSelectSlides(SelectSlideFadeInfo)].Selection;
            CConfig.CoverLoading   = (ECoverLoading)SelectSlides[htSelectSlides(SelectSlideCoverLoading)].Selection;

            CConfig.SaveConfig();

            if (_OldCoverTheme != SelectSlides[htSelectSlides(SelectSlideCover)].Selection)
            {
                CCover.ReloadCover();
                CSongs.Sort(CConfig.SongSorting);
            }

            if (_OldTheme != SelectSlides[htSelectSlides(SelectSlideTheme)].Selection)
            {
                CConfig.Theme = CTheme.ThemeNames[SelectSlides[htSelectSlides(SelectSlideTheme)].Selection];
                _OldTheme     = SelectSlides[htSelectSlides(SelectSlideTheme)].Selection;

                CTheme.UnloadSkins();
                CFonts.UnloadThemeFonts(CConfig.Theme);
                CTheme.ListSkins();
                CConfig.Skin = CTheme.SkinNames[0];
                _OldSkin     = 0;
                _TempSkin    = _OldSkin;

                CConfig.SaveConfig();

                CTheme.LoadSkins();
                CTheme.LoadTheme();
                CGraphics.ReloadTheme();
                return;
            }
        }
Example #12
0
 public override void Unload()
 {
     base.Unload();
     CFonts.UnloadPartyModeFonts(PartyModeID);
 }
Example #13
0
        public CGlyph(char chr, float maxHigh)
        {
            Sizeh = maxHigh;

            float outline = CFonts.Outline;
            const TextFormatFlags flags = TextFormatFlags.NoPadding | TextFormatFlags.NoPrefix;

            float factor = _GetFactor(chr, flags);
            CFonts.Height = Sizeh * factor;
            System.Drawing.Font fo;
            Size sizeB;
            SizeF size;
            using (Graphics g = Graphics.FromHwnd(IntPtr.Zero))
            {
                fo = CFonts.GetFont();
                sizeB = TextRenderer.MeasureText(g, chr.ToString(), fo, new Size(int.MaxValue, int.MaxValue), flags);

                size = g.MeasureString(chr.ToString(), fo);
            }

            using (Bitmap bmp = new Bitmap((int)(sizeB.Width * 2f), sizeB.Height))
            {
                Graphics g = Graphics.FromImage(bmp);
                g.Clear(Color.Transparent);

                g.SmoothingMode = SmoothingMode.AntiAlias;
                g.InterpolationMode = InterpolationMode.HighQualityBicubic;
                g.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;
                CFonts.Height = Sizeh;
                fo = CFonts.GetFont();

                PointF point = new PointF(
                    outline * Math.Abs(sizeB.Width - size.Width) + (sizeB.Width - size.Width) / 2f + Sizeh / 5f,
                    (sizeB.Height - size.Height - (size.Height + Sizeh / 4f) * (1f - factor)) / 2f);

                using (GraphicsPath path = new GraphicsPath())
                {
                    path.AddString(
                        chr.ToString(),
                        fo.FontFamily,
                        (int)fo.Style,
                        Sizeh,
                        point,
                        new StringFormat());

                    using (Pen pen = new Pen(
                        Color.FromArgb(
                            (int)CFonts.OutlineColor.A * 255,
                            (int)CFonts.OutlineColor.R * 255,
                            (int)CFonts.OutlineColor.G * 255,
                            (int)CFonts.OutlineColor.B * 255),
                        Sizeh * outline))
                    {
                        pen.LineJoin = LineJoin.Round;
                        g.DrawPath(pen, path);
                        g.FillPath(Brushes.White, path);
                    }
                }

                /*
                g.DrawString(
                    chr.ToString(),
                    fo,
                    Brushes.White,
                    point);
                 * */
                Texture = CDraw.AddTexture(bmp);
                //bmp.Save("font/" + chr + CFonts.Style + ".png", ImageFormat.Png);
                Width = (int)((1f + outline / 2f) * sizeB.Width * Texture.Width / factor / bmp.Width);
                g.Dispose();
            }
            fo.Dispose();
        }
Example #14
0
        private static void DrawDebugInfos()
        {
            string txt = String.Empty;

            CFonts.Style = EStyle.Normal;
            CFonts.SetFont("Normal");
            SColorF Gray = new SColorF(1f, 1f, 1f, 0.5f);

            float dy = 0;

            if (CConfig.DebugLevel >= EDebugLevel.TR_CONFIG_ONLY_FPS)
            {
                txt           = CTime.GetFPS().ToString("FPS: 000");
                CFonts.Height = 30f;
                RectangleF rect = new RectangleF(CSettings.iRenderW - CFonts.GetTextWidth(txt), dy, CFonts.GetTextWidth(txt), CFonts.GetTextHeight(txt));

                CDraw.DrawColor(Gray, new SRectF(rect.X, rect.Top, rect.Width, rect.Height, CSettings.zNear));
                CFonts.DrawText(txt, rect.X, rect.Y, CSettings.zNear);
                dy += rect.Height;
            }

            if (CConfig.DebugLevel >= EDebugLevel.TR_CONFIG_LEVEL1)
            {
                txt = CSound.GetStreamCount().ToString(CLanguage.Translate("TR_DEBUG_AUDIO_STREAMS") + ": 00");

                RectangleF rect = new RectangleF(CSettings.iRenderW - CFonts.GetTextWidth(txt), dy, CFonts.GetTextWidth(txt), CFonts.GetTextHeight(txt));

                CDraw.DrawColor(Gray, new SRectF(rect.X, rect.Top, rect.Width, rect.Height, CSettings.zNear));
                CFonts.DrawText(txt, rect.X, rect.Y, CSettings.zNear);
                dy += rect.Height;
            }

            if (CConfig.DebugLevel >= EDebugLevel.TR_CONFIG_LEVEL1)
            {
                txt = CVideo.GetNumStreams().ToString(CLanguage.Translate("TR_DEBUG_VIDEO_STREAMS") + ": 00");

                RectangleF rect = new RectangleF(CSettings.iRenderW - CFonts.GetTextWidth(txt), dy, CFonts.GetTextWidth(txt), CFonts.GetTextHeight(txt));

                CDraw.DrawColor(Gray, new SRectF(rect.X, rect.Top, rect.Width, rect.Height, CSettings.zNear));
                CFonts.DrawText(txt, rect.X, rect.Y, CSettings.zNear);
                dy += rect.Height;
            }

            if (CConfig.DebugLevel >= EDebugLevel.TR_CONFIG_LEVEL1)
            {
                txt = CDraw.TextureCount().ToString(CLanguage.Translate("TR_DEBUG_TEXTURES") + ": 00000");

                RectangleF rect = new RectangleF(CSettings.iRenderW - CFonts.GetTextWidth(txt), dy, CFonts.GetTextWidth(txt), CFonts.GetTextHeight(txt));

                CDraw.DrawColor(Gray, new SRectF(rect.X, rect.Top, rect.Width, rect.Height, CSettings.zNear));
                CFonts.DrawText(txt, rect.X, rect.Y, CSettings.zNear);
                dy += rect.Height;
            }

            if (CConfig.DebugLevel >= EDebugLevel.TR_CONFIG_LEVEL2)
            {
                txt = CSound.RecordGetToneAbs(0).ToString(CLanguage.Translate("TR_DEBUG_TONE_ABS") + " P1: 00");

                RectangleF rect = new RectangleF(CSettings.iRenderW - CFonts.GetTextWidth(txt), dy, CFonts.GetTextWidth(txt), CFonts.GetTextHeight(txt));

                CDraw.DrawColor(Gray, new SRectF(rect.X, rect.Top, rect.Width, rect.Height, CSettings.zNear));
                CFonts.DrawText(txt, rect.X, rect.Y, CSettings.zNear);
                dy += rect.Height;


                txt = CSound.RecordGetMaxVolume(0).ToString(CLanguage.Translate("TR_DEBUG_MAX_VOLUME") + " P1: 0.000");

                rect = new RectangleF(CSettings.iRenderW - CFonts.GetTextWidth(txt), dy, CFonts.GetTextWidth(txt), CFonts.GetTextHeight(txt));

                CDraw.DrawColor(Gray, new SRectF(rect.X, rect.Top, rect.Width, rect.Height, CSettings.zNear));
                CFonts.DrawText(txt, rect.X, rect.Y, CSettings.zNear);
                dy += rect.Height;

                txt = CSound.RecordGetToneAbs(1).ToString(CLanguage.Translate("TR_DEBUG_TONE_ABS") + " P2: 00");

                rect = new RectangleF(CSettings.iRenderW - CFonts.GetTextWidth(txt), dy, CFonts.GetTextWidth(txt), CFonts.GetTextHeight(txt));

                CDraw.DrawColor(Gray, new SRectF(rect.X, rect.Top, rect.Width, rect.Height, CSettings.zNear));
                CFonts.DrawText(txt, rect.X, rect.Y, CSettings.zNear);
                dy += rect.Height;


                txt = CSound.RecordGetMaxVolume(1).ToString(CLanguage.Translate("TR_DEBUG_MAX_VOLUME") + " P2: 0.000");

                rect = new RectangleF(CSettings.iRenderW - CFonts.GetTextWidth(txt), dy, CFonts.GetTextWidth(txt), CFonts.GetTextHeight(txt));

                CDraw.DrawColor(Gray, new SRectF(rect.X, rect.Top, rect.Width, rect.Height, CSettings.zNear));
                CFonts.DrawText(txt, rect.X, rect.Y, CSettings.zNear);
                dy += rect.Height;
            }

            if (CConfig.DebugLevel >= EDebugLevel.TR_CONFIG_LEVEL3)
            {
                txt = CSongs.NumSongsWithCoverLoaded.ToString(CLanguage.Translate("TR_DEBUG_SONGS") + ": 00000");

                RectangleF rect = new RectangleF(CSettings.iRenderW - CFonts.GetTextWidth(txt), dy, CFonts.GetTextWidth(txt), CFonts.GetTextHeight(txt));

                CDraw.DrawColor(Gray, new SRectF(rect.X, rect.Top, rect.Width, rect.Height, CSettings.zNear));
                CFonts.DrawText(txt, rect.X, rect.Y, CSettings.zNear);
                dy += rect.Height;
            }

            if (CConfig.DebugLevel >= EDebugLevel.TR_CONFIG_LEVEL_MAX)
            {
                txt = _Cursor.X.ToString(CLanguage.Translate("TR_DEBUG_MOUSE") + " : (0000/") + _Cursor.Y.ToString("0000)");

                RectangleF rect = new RectangleF(CSettings.iRenderW - CFonts.GetTextWidth(txt), dy, CFonts.GetTextWidth(txt), CFonts.GetTextHeight(txt));

                CDraw.DrawColor(Gray, new SRectF(rect.X, rect.Top, rect.Width, rect.Height, CSettings.zNear));
                CFonts.DrawText(txt, rect.X, rect.Y, CSettings.zNear);
                dy += rect.Height;
            }
        }
Example #15
0
        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();
        }
Example #16
0
        private void UpdateTextPosition()
        {
            if (_Text == String.Empty)
            {
                return;
            }

            CFonts.SetFont(Fon);
            CFonts.Style = Style;

            float      h      = Height;
            float      y      = Y;
            RectangleF bounds = CFonts.GetTextBounds(this);

            if (bounds.Width > Bounds.W && Bounds.W > 0f && bounds.Width > 0f)
            {
                float factor = Bounds.W / bounds.Width;
                float step   = h * (1 - factor);
                h *= factor;
                switch (HAlign)
                {
                case EHAlignment.Top:
                    y += step * 0.25f;
                    break;

                case EHAlignment.Center:
                    y += step * 0.50f;
                    break;

                case EHAlignment.Bottom:
                    y += step * 0.75f;
                    break;

                default:
                    break;
                }

                bounds = CFonts.GetTextBounds(this, h);
            }

            float x = X;

            switch (Align)
            {
            case EAlignment.Center:
                x = X - bounds.Width / 2;
                break;

            case EAlignment.Right:
                x = X - bounds.Width;
                break;

            default:
                break;
            }

            _DrawPosition.X      = x;
            _DrawPosition.Y      = y;
            _DrawPosition.tH     = h;
            _DrawPosition.Width  = bounds.Width;
            _DrawPosition.Height = bounds.Height;

            _PositionNeedsUpdate = false;
        }
Example #17
0
        public void DrawRelative(float rx, float ry, bool reflection, float reflectionSpace, float reflectionHeight, float rectHeight)
        {
            // Update Text
            Text = Text;

            float h = Height;

            float x = X + rx;
            float y = Y + ry;

            RectangleF bounds = CDraw.GetTextBounds(this);

            if (bounds.Width > Bounds.W && Bounds.W > 0f && bounds.Width > 0f)
            {
                float factor = Bounds.W / bounds.Width;
                float step   = h * (1 - factor);
                h *= factor;
                switch (HAlign)
                {
                case EHAlignment.Top:
                    y += step * 0.25f;
                    break;

                case EHAlignment.Center:
                    y += step * 0.50f;
                    break;

                case EHAlignment.Bottom:
                    y += step * 0.75f;
                    break;

                default:
                    break;
                }

                bounds = CFonts.GetTextBounds(this, h);
            }

            switch (Align)
            {
            case EAlignment.Center:
                x = x - bounds.Width / 2;
                break;

            case EAlignment.Right:
                x = x - bounds.Width;
                break;

            default:
                break;
            }


            SColorF CurrentColor = new SColorF(Color);

            if (Selected)
            {
                CurrentColor = new SColorF(SColor);
            }

            SColorF color = new SColorF(CurrentColor.R, CurrentColor.G, CurrentColor.B, CurrentColor.A * Alpha);

            CFonts.SetFont(Fon);
            CFonts.Style = Style;

            if (!EditMode)
            {
                CFonts.DrawText(_Text, h, x, y, Z, color);
            }
            else
            {
                CFonts.DrawText(_Text + "|", h, x, y, Z, color);
            }

            if (reflection)
            {
                float space  = (rectHeight - Y - bounds.Height) * 2f + reflectionSpace;
                float height = reflectionHeight - (rectHeight - Y) + bounds.Height;

                if (!EditMode)
                {
                    CFonts.DrawTextReflection(_Text, h, x, y, Z, color, space, height);
                }
                else
                {
                    CFonts.DrawTextReflection(_Text + "|", h, x, y, Z, color, space, height);
                }
            }

            if (Selected && (CSettings.GameState == EGameState.EditTheme))
            {
                CDraw.DrawColor(new SColorF(0.5f, 1f, 0.5f, 0.5f * CGraphics.GlobalAlpha), new SRectF(x, y, bounds.Width, bounds.Height, Z));
            }
        }
Example #18
0
        static void Main(string[] args)
        {
            AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(AssemblyResolver);

            // Close program if there is another instance running
            if (!EnsureSingleInstance())
            {
                //TODO: put it into language file
                MessageBox.Show("Another Instance of Vocaluxe is already runnning!");
                return;
            }

            Application.DoEvents();

            try
            {
                // Init Log
                CLog.Init();

                CSettings.CreateFolders();
                Application.DoEvents();

                // Init Language
                CLog.StartBenchmark(0, "Init Language");
                CLanguage.Init();
                CLog.StopBenchmark(0, "Init Language");

                Application.DoEvents();

                // load config
                CLog.StartBenchmark(0, "Init Config");
                CConfig.LoadCommandLineParams(args);
                CConfig.UseCommandLineParamsBefore();
                CConfig.Init();
                CConfig.UseCommandLineParamsAfter();
                CLog.StopBenchmark(0, "Init Config");

                Application.DoEvents();
                _SplashScreen = new SplashScreen();
                Application.DoEvents();

                // Init Draw
                CLog.StartBenchmark(0, "Init Draw");
                CDraw.InitDraw();
                CLog.StopBenchmark(0, "Init Draw");

                Application.DoEvents();

                // Init Database
                CLog.StartBenchmark(0, "Init Database");
                CDataBase.Init();
                CLog.StopBenchmark(0, "Init Database");

                Application.DoEvents();

                // Init Playback
                CLog.StartBenchmark(0, "Init Playback");
                CSound.PlaybackInit();
                CLog.StopBenchmark(0, "Init Playback");

                Application.DoEvents();

                // Init Record
                CLog.StartBenchmark(0, "Init Record");
                CSound.RecordInit();
                CLog.StopBenchmark(0, "Init Record");

                Application.DoEvents();

                //Init Webcam
                CLog.StartBenchmark(0, "Init Webcam");
                CWebcam.Init();
                CLog.StopBenchmark(0, "Init Webcam");

                Application.DoEvents();

                // Init Background Music
                CLog.StartBenchmark(0, "Init Background Music");
                CBackgroundMusic.Init();
                CLog.StopBenchmark(0, "Init Background Music");

                Application.DoEvents();

                // Init Profiles
                CLog.StartBenchmark(0, "Init Profiles");
                CProfiles.Init();
                CLog.StopBenchmark(0, "Init Profiles");

                Application.DoEvents();

                // Init Font
                CLog.StartBenchmark(0, "Init Font");
                CFonts.Init();
                CLog.StopBenchmark(0, "Init Font");

                Application.DoEvents();

                // Init VideoDecoder
                CLog.StartBenchmark(0, "Init Videodecoder");
                CVideo.Init();
                CLog.StopBenchmark(0, "Init Videodecoder");

                Application.DoEvents();

                // Load Cover
                CLog.StartBenchmark(0, "Init Cover");
                CCover.Init();
                CLog.StopBenchmark(0, "Init Cover");

                Application.DoEvents();

                // Theme System
                CLog.StartBenchmark(0, "Init Theme");
                CTheme.InitTheme();
                CLog.StopBenchmark(0, "Init Theme");

                Application.DoEvents();

                // Init Screens
                CLog.StartBenchmark(0, "Init Screens");
                CGraphics.InitGraphics();
                CLog.StopBenchmark(0, "Init Screens");

                Application.DoEvents();

                // Init Input
                CLog.StartBenchmark(0, "Init Input");
                CInput.Init();
                CLog.StopBenchmark(0, "Init Input");

                // Init Game;
                CLog.StartBenchmark(0, "Init Game");
                CGame.Init();
                CLog.StopBenchmark(0, "Init Game");
            }
            catch (Exception e)
            {
                MessageBox.Show("Error on start up: " + e.Message + e.StackTrace);
                CLog.LogError("Error on start up: " + e.Message + e.StackTrace);
                CloseProgram();
                Environment.Exit(Environment.ExitCode);
            }
            Application.DoEvents();

            // Start Main Loop
            _SplashScreen.Close();

            try
            {
                CDraw.MainLoop();
            }
            catch (Exception e)
            {
                MessageBox.Show("Unhandled error: " + e.Message + e.StackTrace);
                CLog.LogError("Unhandled error: " + e.Message + e.StackTrace);
            }

            CloseProgram();
        }
Example #19
0
        public void Draw(bool ForceDraw)
        {
            if (!ForceDraw && !Visible && CSettings.GameState != EGameState.EditTheme)
            {
                return;
            }

            // Update Text
            Text = Text;

            if (_PositionNeedsUpdate)
            {
                UpdateTextPosition();
            }

            CFonts.SetFont(Fon);
            CFonts.Style = Style;

            SColorF CurrentColor = new SColorF(Color);

            if (Selected)
            {
                CurrentColor = new SColorF(SColor);
            }

            SColorF color = new SColorF(CurrentColor.R, CurrentColor.G, CurrentColor.B, CurrentColor.A * Alpha);

            if (!EditMode)
            {
                CFonts.DrawText(_Text, _DrawPosition.tH, _DrawPosition.X, _DrawPosition.Y, Z, color);
            }
            else
            {
                CFonts.DrawText(_Text + "|", _DrawPosition.tH, _DrawPosition.X, _DrawPosition.Y, Z, color);
            }

            if (Reflection)
            {
                float sFactor = 0f;
                switch (HAlign)
                {
                case EHAlignment.Top:
                    sFactor = (Height - _DrawPosition.tH) * 1.5f;
                    break;

                case EHAlignment.Center:
                    sFactor = (Height - _DrawPosition.tH) * 1.0f;
                    break;

                case EHAlignment.Bottom:
                    sFactor = (Height - _DrawPosition.tH) * 0.5f;
                    break;

                default:
                    break;
                }
                if (!EditMode)
                {
                    CFonts.DrawTextReflection(_Text, _DrawPosition.tH, _DrawPosition.X, _DrawPosition.Y, Z, color, ReflectionSpace + sFactor, ReflectionHeight);
                }
                else
                {
                    CFonts.DrawTextReflection(_Text + "|", _DrawPosition.tH, _DrawPosition.X, _DrawPosition.Y, Z, color, ReflectionSpace + sFactor, ReflectionHeight);
                }
            }

            if (Selected && (CSettings.GameState == EGameState.EditTheme))
            {
                CDraw.DrawColor(
                    new SColorF(0.5f, 1f, 0.5f, 0.5f * CGraphics.GlobalAlpha),
                    new SRectF(_DrawPosition.X, _DrawPosition.Y, _DrawPosition.Width, _DrawPosition.Height, Z)
                    );
            }
        }
Example #20
0
        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();
        }
Example #21
0
 protected override bool _Load()
 {
     return(CFonts.LoadThemeFonts(_Data.Fonts, Path.Combine(_Folder, "..", CSettings.FolderNamePartyModeFonts), Name, PartyModeID));
 }
Example #22
0
 // Draw Basic Text
 public void DrawText(string Text, int x, int y, float h, float z)
 {
     CFonts.DrawText(Text, h, x, y, z, new SColorF(1, 1, 1, 1));
 }
Example #23
0
        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();
        }
Example #24
0
 public override void Unload()
 {
     base.Unload();
     CFonts.UnloadThemeFonts(Name);
 }