Ejemplo n.º 1
0
        private static void LoadCursor(XPathNavigator navigator, int SkinIndex)
        {
            string value = String.Empty;

            CHelper.GetValueFromXML("//root/Cursor/Skin", navigator, ref Cursor.SkinName, value);

            CHelper.TryGetFloatValueFromXML("//root/Cursor/W", navigator, ref Cursor.w);
            CHelper.TryGetFloatValueFromXML("//root/Cursor/H", navigator, ref Cursor.h);

            if (CHelper.GetValueFromXML("//root/Cursor/Color", navigator, ref value, value))
            {
                SColorF color = GetColor(value);
                Cursor.r     = color.R;
                Cursor.g     = color.G;
                Cursor.b     = color.B;
                Cursor.a     = color.A;
                Cursor.color = value;
            }
            else
            {
                Cursor.color = String.Empty;
                CHelper.TryGetFloatValueFromXML("//root/Cursor/R", navigator, ref Cursor.r);
                CHelper.TryGetFloatValueFromXML("//root/Cursor/G", navigator, ref Cursor.g);
                CHelper.TryGetFloatValueFromXML("//root/Cursor/B", navigator, ref Cursor.b);
                CHelper.TryGetFloatValueFromXML("//root/Cursor/A", navigator, ref Cursor.a);
            }
        }
Ejemplo n.º 2
0
        private static void LoadColors(XPathNavigator navigator, int SkinIndex)
        {
            Skin skin = _Skins[SkinIndex];

            List <SColorF> PlayerColors = new List <SColorF>();
            float          value        = 0f;

            int i = 1;

            while (CHelper.TryGetFloatValueFromXML("//root/Colors/Player" + i.ToString() + "/R", navigator, ref value))
            {
                SColorF color = new SColorF();

                color.R = value;
                CHelper.TryGetFloatValueFromXML("//root/Colors/Player" + i.ToString() + "/G", navigator, ref color.G);
                CHelper.TryGetFloatValueFromXML("//root/Colors/Player" + i.ToString() + "/B", navigator, ref color.B);
                CHelper.TryGetFloatValueFromXML("//root/Colors/Player" + i.ToString() + "/A", navigator, ref color.A);

                PlayerColors.Add(color);
                i++;
            }
            skin.ThemeColors.Player = PlayerColors.ToArray();

            List <SColorScheme> ColorScheme = new List <SColorScheme>();
            List <string>       names       = CHelper.GetValuesFromXML("ColorSchemes", navigator);

            foreach (string str in names)
            {
                SColorScheme scheme = new SColorScheme();
                scheme.Name = str;

                CHelper.TryGetFloatValueFromXML("//root/ColorSchemes/" + str + "/R", navigator, ref scheme.Color.R);
                CHelper.TryGetFloatValueFromXML("//root/ColorSchemes/" + str + "/G", navigator, ref scheme.Color.G);
                CHelper.TryGetFloatValueFromXML("//root/ColorSchemes/" + str + "/B", navigator, ref scheme.Color.B);
                CHelper.TryGetFloatValueFromXML("//root/ColorSchemes/" + str + "/A", navigator, ref scheme.Color.A);

                ColorScheme.Add(scheme);
            }
            skin.ThemeColors.ColorSchemes = ColorScheme.ToArray();

            _Skins[SkinIndex] = skin;
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Loads theme fonts from skin file
        /// </summary>
        public static void LoadThemeFonts(string ThemeName, string FontFolder, XPathNavigator navigator)
        {
            string value = string.Empty;
            int    i     = 1;

            while (CHelper.GetValueFromXML("//root/Fonts/Font" + i.ToString() + "/Folder", navigator, ref value, value))
            {
                SFont sf = new SFont();
                sf.Folder = value;

                sf.IsThemeFont = true;
                sf.ThemeName   = ThemeName;

                bool ok = true;

                ok           &= CHelper.GetValueFromXML("//root/Fonts/Font" + i.ToString() + "/FileNormal", navigator, ref value, value);
                sf.FileNormal = value;
                value         = Path.Combine(FontFolder, Path.Combine(sf.Folder, value));
                CFont f = new CFont(value);
                sf.Normal = f;

                string name = String.Empty;
                ok     &= CHelper.GetValueFromXML("//root/Fonts/Font" + i.ToString() + "/Name", navigator, ref name, value);
                sf.Name = name;

                ok           &= CHelper.GetValueFromXML("//root/Fonts/Font" + i.ToString() + "/FileItalic", navigator, ref value, value);
                sf.FileItalic = value;
                value         = Path.Combine(FontFolder, Path.Combine(sf.Folder, value));
                f             = new CFont(value);
                sf.Italic     = f;

                ok         &= CHelper.GetValueFromXML("//root/Fonts/Font" + i.ToString() + "/FileBold", navigator, ref value, value);
                sf.FileBold = value;
                value       = Path.Combine(FontFolder, Path.Combine(sf.Folder, value));
                f           = new CFont(value);
                sf.Bold     = f;

                ok &= CHelper.GetValueFromXML("//root/Fonts/Font" + i.ToString() + "/FileBoldItalic", navigator, ref value, value);
                sf.FileBoldItalic = value;
                value             = Path.Combine(FontFolder, Path.Combine(sf.Folder, value));
                f             = new CFont(value);
                sf.BoldItalic = f;

                sf.Outline = 0f;
                ok        &= CHelper.TryGetFloatValueFromXML("//root/Fonts/Font" + i.ToString() + "/Outline", navigator, ref sf.Outline);

                sf.OutlineColor = new SColorF(0f, 0f, 0f, 1f);
                ok &= CHelper.TryGetFloatValueFromXML("//root/Fonts/Font" + i.ToString() + "/OutlineColorR", navigator, ref sf.OutlineColor.R);
                ok &= CHelper.TryGetFloatValueFromXML("//root/Fonts/Font" + i.ToString() + "/OutlineColorG", navigator, ref sf.OutlineColor.G);
                ok &= CHelper.TryGetFloatValueFromXML("//root/Fonts/Font" + i.ToString() + "/OutlineColorB", navigator, ref sf.OutlineColor.B);
                ok &= CHelper.TryGetFloatValueFromXML("//root/Fonts/Font" + i.ToString() + "/OutlineColorA", navigator, ref sf.OutlineColor.A);

                if (ok)
                {
                    _Fonts.Add(sf);
                }
                else
                {
                    CLog.LogError("Error loading theme fonts for theme \"" + ThemeName + "\": Error in Font" + i.ToString());
                }
                i++;
            }

            CLog.StartBenchmark(1, "BuildGlyphs");
            BuildGlyphs();
            CLog.StopBenchmark(1, "BuildGlyphs");
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Load default fonts
        /// </summary>
        /// <returns></returns>
        private static bool LoadFontList()
        {
            bool           loaded    = false;
            XPathDocument  xPathDoc  = null;
            XPathNavigator navigator = null;

            try
            {
                xPathDoc  = new XPathDocument(System.IO.Path.Combine(CSettings.sFolderFonts, CSettings.sFileFonts));
                navigator = xPathDoc.CreateNavigator();
                loaded    = true;
            }
            catch (Exception e)
            {
                CLog.LogError("Error loading default fonts: " + e.Message);
                loaded = false;
                if (navigator != null)
                {
                    navigator = null;
                }

                if (xPathDoc != null)
                {
                    xPathDoc = null;
                }
            }
            _Fonts.Clear();

            if (loaded)
            {
                string value = string.Empty;
                int    i     = 1;
                while (CHelper.GetValueFromXML("//root/Font" + i.ToString() + "/Folder", navigator, ref value, value))
                {
                    string Folder = value;

                    CHelper.GetValueFromXML("//root/Font" + i.ToString() + "/FileNormal", navigator, ref value, value);
                    value = Path.Combine(Directory.GetCurrentDirectory(),
                                         Path.Combine(CSettings.sFolderFonts, Path.Combine(Folder, value)));
                    CFont f  = new CFont(value);
                    SFont sf = new SFont();
                    sf.Normal = f;

                    string name = String.Empty;
                    CHelper.GetValueFromXML("//root/Font" + i.ToString() + "/Name", navigator, ref name, value);
                    sf.Name        = name;
                    sf.IsThemeFont = false;
                    sf.ThemeName   = String.Empty;

                    CHelper.GetValueFromXML("//root/Font" + i.ToString() + "/FileItalic", navigator, ref value, value);
                    value = Path.Combine(Directory.GetCurrentDirectory(),
                                         Path.Combine(CSettings.sFolderFonts, Path.Combine(Folder, value)));
                    f         = new CFont(value);
                    sf.Italic = f;

                    CHelper.GetValueFromXML("//root/Font" + i.ToString() + "/FileBold", navigator, ref value, value);
                    value = Path.Combine(Directory.GetCurrentDirectory(),
                                         Path.Combine(CSettings.sFolderFonts, Path.Combine(Folder, value)));
                    f       = new CFont(value);
                    sf.Bold = f;

                    CHelper.GetValueFromXML("//root/Font" + i.ToString() + "/FileBoldItalic", navigator, ref value, value);
                    value = Path.Combine(Directory.GetCurrentDirectory(),
                                         Path.Combine(CSettings.sFolderFonts, Path.Combine(Folder, value)));
                    f             = new CFont(value);
                    sf.BoldItalic = f;

                    sf.Outline = 0f;
                    CHelper.TryGetFloatValueFromXML("//root/Font" + i.ToString() + "/Outline", navigator, ref sf.Outline);

                    sf.OutlineColor = new SColorF(0f, 0f, 0f, 1f);
                    CHelper.TryGetFloatValueFromXML("//root/Font" + i.ToString() + "/OutlineColorR", navigator, ref sf.OutlineColor.R);
                    CHelper.TryGetFloatValueFromXML("//root/Font" + i.ToString() + "/OutlineColorG", navigator, ref sf.OutlineColor.G);
                    CHelper.TryGetFloatValueFromXML("//root/Font" + i.ToString() + "/OutlineColorB", navigator, ref sf.OutlineColor.B);
                    CHelper.TryGetFloatValueFromXML("//root/Font" + i.ToString() + "/OutlineColorA", navigator, ref sf.OutlineColor.A);

                    _Fonts.Add(sf);
                    i++;
                }
            }
            return(loaded);
        }
Ejemplo n.º 5
0
        public static bool LoadConfig()
        {
            #region Inits
            bool           loaded    = false;
            XPathDocument  xPathDoc  = null;
            XPathNavigator navigator = null;

            try
            {
                xPathDoc  = new XPathDocument(CSettings.sFileConfig);
                navigator = xPathDoc.CreateNavigator();
                loaded    = true;
            }
            catch (Exception)
            {
                CLog.LogError("Error opening Config.xml (FileName: " + CSettings.sFileConfig);
                loaded = false;
                if (navigator != null)
                {
                    navigator = null;
                }

                if (xPathDoc != null)
                {
                    xPathDoc = null;
                }
            }
            #endregion Inits

            if (loaded)
            {
                string value = string.Empty;

                #region Debug
                CHelper.TryGetEnumValueFromXML <EDebugLevel>("//root/Debug/DebugLevel", navigator, ref DebugLevel);
                #endregion Debug

                #region Graphics
                CHelper.TryGetEnumValueFromXML <ERenderer>("//root/Graphics/Renderer", navigator, ref Renderer);
                CHelper.TryGetEnumValueFromXML <ETextureQuality>("//root/Graphics/TextureQuality", navigator, ref TextureQuality);
                CHelper.TryGetIntValueFromXML("//root/Graphics/CoverSize", navigator, ref CoverSize);
                if (CoverSize > 1024)
                {
                    CoverSize = 1024;
                }
                if (CoverSize < 32)
                {
                    CoverSize = 32;
                }

                CHelper.TryGetIntValueFromXML("//root/Graphics/ScreenW", navigator, ref ScreenW);
                CHelper.TryGetIntValueFromXML("//root/Graphics/ScreenH", navigator, ref ScreenH);
                CHelper.TryGetEnumValueFromXML <EAntiAliasingModes>("//root/Graphics/AAMode", navigator, ref AAMode);
                CHelper.TryGetEnumValueFromXML <EColorDeep>("//root/Graphics/Colors", navigator, ref Colors);
                CHelper.TryGetFloatValueFromXML("//root/Graphics/MaxFPS", navigator, ref MaxFPS);
                CHelper.TryGetEnumValueFromXML <EOffOn>("//root/Graphics/VSync", navigator, ref VSync);
                CHelper.TryGetEnumValueFromXML <EOffOn>("//root/Graphics/FullScreen", navigator, ref FullScreen);
                CHelper.TryGetFloatValueFromXML("//root/Graphics/FadeTime", navigator, ref FadeTime);
                #endregion Graphics

                #region Theme
                CHelper.GetValueFromXML("//root/Theme/Name", navigator, ref Theme, Theme);
                CHelper.GetValueFromXML("//root/Theme/Skin", navigator, ref Skin, Skin);
                CHelper.GetValueFromXML("//root/Theme/Cover", navigator, ref CoverTheme, CoverTheme);
                CHelper.TryGetEnumValueFromXML("//root/Theme/DrawNoteLines", navigator, ref DrawNoteLines);
                CHelper.TryGetEnumValueFromXML("//root/Theme/DrawToneHelper", navigator, ref DrawToneHelper);
                CHelper.TryGetEnumValueFromXML("//root/Theme/TimerLook", navigator, ref TimerLook);
                CHelper.TryGetEnumValueFromXML("//root/Theme/CoverLoading", navigator, ref CoverLoading);
                #endregion Theme

                #region Sound
                CHelper.TryGetEnumValueFromXML <EPlaybackLib>("//root/Sound/PlayBackLib", navigator, ref PlayBackLib);
                CHelper.TryGetEnumValueFromXML <ERecordLib>("//root/Sound/RecordLib", navigator, ref RecordLib);
                CHelper.TryGetEnumValueFromXML <EBufferSize>("//root/Sound/AudioBufferSize", navigator, ref AudioBufferSize);

                CHelper.TryGetIntValueFromXML("//root/Sound/AudioLatency", navigator, ref AudioLatency);
                if (AudioLatency < -500)
                {
                    AudioLatency = -500;
                }
                if (AudioLatency > 500)
                {
                    AudioLatency = 500;
                }

                CHelper.TryGetEnumValueFromXML("//root/Sound/BackgroundMusic", navigator, ref BackgroundMusic);
                CHelper.TryGetIntValueFromXML("//root/Sound/BackgroundMusicVolume", navigator, ref BackgroundMusicVolume);
                CHelper.TryGetEnumValueFromXML("//root/Sound/BackgroundMusicSource", navigator, ref BackgroundMusicSource);
                #endregion Sound

                #region Game
                // Songfolder
                value = string.Empty;
                int i = 1;
                while (CHelper.GetValueFromXML("//root/Game/SongFolder" + i.ToString(), navigator, ref value, value))
                {
                    if (i == 1)
                    {
                        SongFolder.Clear();
                    }

                    SongFolder.Add(value);
                    value = string.Empty;
                    i++;
                }

                CHelper.TryGetEnumValueFromXML <ESongMenu>("//root/Game/SongMenu", navigator, ref SongMenu);
                CHelper.TryGetEnumValueFromXML <ESongSorting>("//root/Game/SongSorting", navigator, ref SongSorting);
                CHelper.TryGetFloatValueFromXML("//root/Game/ScoreAnimationTime", navigator, ref ScoreAnimationTime);
                CHelper.TryGetEnumValueFromXML <ETimerMode>("//root/Game/TimerMode", navigator, ref TimerMode);
                CHelper.TryGetIntValueFromXML("//root/Game/NumPlayer", navigator, ref NumPlayer);
                CHelper.TryGetEnumValueFromXML("//root/Game/Tabs", navigator, ref Tabs);
                CHelper.GetValueFromXML("//root/Game/Language", navigator, ref Language, Language);
                CHelper.TryGetEnumValueFromXML <EOffOn>("//root/Game/LyricsOnTop", navigator, ref LyricsOnTop);

                if ((ScoreAnimationTime > 0 && ScoreAnimationTime < 1) || ScoreAnimationTime < 0)
                {
                    ScoreAnimationTime = 1;
                }

                if (NumPlayer < 1 || NumPlayer > CSettings.MaxNumPlayer)
                {
                    NumPlayer = 2;
                }

                List <string> _Languages = new List <string>();
                _Languages = CLanguage.GetLanguages();

                bool _LangExists = false;

                for (i = 0; i < _Languages.Count; i++)
                {
                    if (_Languages[i] == Language)
                    {
                        _LangExists = true;
                    }
                }

                //TODO: What should we do, if English not exists?
                if (_LangExists == false)
                {
                    Language = "English";
                }
                CLanguage.SetLanguage(Language);

                #endregion Game

                #region Video
                CHelper.TryGetEnumValueFromXML <EVideoDecoder>("//root/Video/VideoDecoder", navigator, ref VideoDecoder);
                CHelper.TryGetEnumValueFromXML <EOffOn>("//root/Video/VideoBackgrounds", navigator, ref VideoBackgrounds);
                CHelper.TryGetEnumValueFromXML <EOffOn>("//root/Video/VideoPreview", navigator, ref VideoPreview);
                CHelper.TryGetEnumValueFromXML <EOffOn>("//root/Video/VideosInSongs", navigator, ref VideosInSongs);
                #endregion Video

                #region Record
                MicConfig = new SMicConfig[CSettings.MaxNumPlayer];
                value     = string.Empty;
                for (int p = 1; p <= CSettings.MaxNumPlayer; p++)
                {
                    MicConfig[p - 1] = new SMicConfig(0);
                    CHelper.GetValueFromXML("//root/Record/MicConfig" + p.ToString() + "/DeviceName", navigator, ref MicConfig[p - 1].DeviceName, String.Empty);
                    CHelper.GetValueFromXML("//root/Record/MicConfig" + p.ToString() + "/DeviceDriver", navigator, ref MicConfig[p - 1].DeviceDriver, String.Empty);
                    CHelper.GetValueFromXML("//root/Record/MicConfig" + p.ToString() + "/InputName", navigator, ref MicConfig[p - 1].InputName, String.Empty);
                    CHelper.TryGetIntValueFromXML("//root/Record/MicConfig" + p.ToString() + "/Channel", navigator, ref MicConfig[p - 1].Channel);
                }

                CHelper.TryGetIntValueFromXML("//root/Record/MicDelay", navigator, ref MicDelay);
                MicDelay = (int)(20 * Math.Round(MicDelay / 20.0));
                if (MicDelay < 0)
                {
                    MicDelay = 0;
                }
                if (MicDelay > 500)
                {
                    MicDelay = 500;
                }

                #endregion Record

                return(true);
            }
            else
            {
                return(false);
            }
        }