Exemplo n.º 1
0
        private bool _GetFirstConfiguredWebcamDevice(out int device, out int capabilities)
        {
            SWebcamDevice[] devices = CWebcam.GetDevices();

            if (devices == null)
            {
                device       = -1;
                capabilities = -1;
                return(false);
            }
            SWebcamConfig curConfig = CConfig.Config.Video.WebcamConfig.HasValue ? CConfig.Config.Video.WebcamConfig.Value : new SWebcamConfig();

            for (int i = 0; i < devices.Length; i++)
            {
                if (devices[i].MonikerString != curConfig.MonikerString)
                {
                    continue;
                }
                for (int j = 0; j < devices[i].Capabilities.Count; j++)
                {
                    if (devices[i].Capabilities[j].Framerate == curConfig.Framerate &&
                        devices[i].Capabilities[j].Width == curConfig.Width &&
                        devices[i].Capabilities[j].Height == curConfig.Height)
                    {
                        device       = i;
                        capabilities = j;
                        return(true);
                    }
                }
            }
            device       = 0;
            capabilities = 0;
            return(true);
        }
Exemplo n.º 2
0
 public static void Select(SWebcamConfig c)
 {
     _Webcam.Select(c);
 }
Exemplo n.º 3
0
 public static bool Select(SWebcamConfig c)
 {
     return(_Webcam != null && _Webcam.Select(c));
 }
Exemplo n.º 4
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/PlayerInfo", navigator, ref PlayerInfo);
                CHelper.TryGetEnumValueFromXML("//root/Theme/FadePlayerInfo", navigator, ref FadePlayerInfo);
                CHelper.TryGetEnumValueFromXML("//root/Theme/CoverLoading", navigator, ref CoverLoading);
                CHelper.TryGetEnumValueFromXML("//root/Theme/LyricStyle", navigator, ref LyricStyle);
                #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);
                if (BackgroundMusicVolume < 0)
                {
                    BackgroundMusicVolume = 0;
                }
                if (BackgroundMusicVolume > 100)
                {
                    BackgroundMusicVolume = 100;
                }
                CHelper.TryGetEnumValueFromXML("//root/Sound/BackgroundMusicSource", navigator, ref BackgroundMusicSource);
                CHelper.TryGetIntValueFromXML("//root/Sound/PreviewMusicVolume", navigator, ref PreviewMusicVolume);
                if (PreviewMusicVolume < 0)
                {
                    PreviewMusicVolume = 0;
                }
                if (PreviewMusicVolume > 100)
                {
                    PreviewMusicVolume = 100;
                }
                CHelper.TryGetIntValueFromXML("//root/Sound/GameMusicVolume", navigator, ref GameMusicVolume);
                if (GameMusicVolume < 0)
                {
                    GameMusicVolume = 0;
                }
                if (GameMusicVolume > 100)
                {
                    GameMusicVolume = 100;
                }
                #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.TryGetEnumValueFromXML <EOffOn>("//root/Game/IgnoreArticles", navigator, ref IgnoreArticles);
                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);

                //Read players from config
                for (i = 1; i <= CSettings.MaxNumPlayer; i++)
                {
                    CHelper.GetValueFromXML("//root/Game/Players/Player" + i.ToString(), navigator, ref Players[i - 1], string.Empty);
                }

                #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);
                CHelper.TryGetEnumValueFromXML <EOffOn>("//root/Video/VideosToBackground", navigator, ref VideosToBackground);

                CHelper.TryGetEnumValueFromXML <EWebcamLib>("//root/Video/WebcamLib", navigator, ref WebcamLib);
                WebcamConfig = new SWebcamConfig();
                CHelper.GetValueFromXML("//root/Video/WebcamConfig/MonikerString", navigator, ref WebcamConfig.MonikerString, String.Empty);
                CHelper.TryGetIntValueFromXML("//root/Video/WebcamConfig/Framerate", navigator, ref WebcamConfig.Framerate);
                CHelper.TryGetIntValueFromXML("//root/Video/WebcamConfig/Width", navigator, ref WebcamConfig.Width);
                CHelper.TryGetIntValueFromXML("//root/Video/WebcamConfig/Height", navigator, ref WebcamConfig.Height);
                #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);
            }
        }