예제 #1
0
        private static void _DeleteProfile(Guid profileID)
        {
            if (!IsProfileIDValid(profileID))
            {
                return;
            }

            if (string.IsNullOrEmpty(_Profiles[profileID].FilePath))
            {
                _RemoveProfile(profileID);
                return;
            }

            try
            {
                //Check if profile saved in config
                for (int i = 0; i < CSettings.MaxNumPlayer; i++)
                {
                    if (CConfig.Config.Game.Players[i] == GetProfileFileName(profileID))
                    {
                        CConfig.Config.Game.Players[i] = string.Empty;
                        CConfig.SaveConfig();
                    }
                }
                File.Delete(_Profiles[profileID].FilePath);
                _RemoveProfile(profileID);

                //Check if profile is selected in game
                for (int i = 0; i < CGame.Players.Length; i++)
                {
                    if (CGame.Players[i].ProfileID == profileID)
                    {
                        CGame.Players[i].ProfileID = Guid.Empty;
                    }
                }
            }
            catch (Exception)
            {
                CLog.Error("Can't delete Profile File " + _Profiles[profileID].FilePath);
            }
            _ProfilesChanged = true;
        }
예제 #2
0
파일: CMain.cs 프로젝트: da-ka/Vocaluxe
 public int GetMusicVolume(EMusicType type)
 {
     return(CConfig.GetVolumeByType(type));
 }
예제 #3
0
파일: CMain.cs 프로젝트: da-ka/Vocaluxe
 public int GetNumScreens()
 {
     return(CConfig.GetNumScreens());
 }
예제 #4
0
파일: CMain.cs 프로젝트: da-ka/Vocaluxe
 public int GetMaxNumMics()
 {
     return(CConfig.GetMaxNumMics());
 }
예제 #5
0
파일: CMain.cs 프로젝트: da-ka/Vocaluxe
 public bool IsMicConfigured(int playerNr)
 {
     return(CConfig.IsMicConfig(playerNr));
 }
예제 #6
0
        private static bool _HandleInputs(CKeys keys, CMouse mouse)
        {
            SKeyEvent   keyEvent        = new SKeyEvent();
            SMouseEvent mouseEvent      = new SMouseEvent();
            SKeyEvent   inputKeyEvent   = new SKeyEvent();
            SMouseEvent inputMouseEvent = new SMouseEvent();

            bool popupPlayerControlAllowed = CurrentScreen.CurrentMusicType == EMusicType.Background;
            bool popupVolumeControlAllowed = CurrentScreen.CurrentMusicType != EMusicType.None;

            //Hide volume control for bg-music if bg-music is disabled
            if (popupVolumeControlAllowed && (CurrentScreen.CurrentMusicType == EMusicType.Background || CurrentScreen.CurrentMusicType == EMusicType.BackgroundPreview) && CConfig.Config.Sound.BackgroundMusic == EBackgroundMusicOffOn.TR_CONFIG_OFF)
            {
                popupVolumeControlAllowed = false;
            }

            bool resume = true;
            bool eventsAvailable;
            bool inputEventsAvailable = CController.PollKeyEvent(ref inputKeyEvent);

            while ((eventsAvailable = keys.PollEvent(ref keyEvent)) || inputEventsAvailable)
            {
                if (!eventsAvailable)
                {
                    keyEvent = inputKeyEvent;
                }

                if (keyEvent.IsArrowKey() || keyEvent.Key == Keys.NumPad0 || keyEvent.Key == Keys.D0 || keyEvent.Key == Keys.Add)
                {
                    _Cursor.Deactivate();

                    if (keyEvent.ModAlt && keyEvent.ModCtrl)
                    {
                        switch (keyEvent.Key)
                        {
                        case Keys.Right:
                            if (keyEvent.ModShift)
                            {
                                CConfig.Config.Graphics.BorderLeft++;
                            }
                            else
                            {
                                CConfig.Config.Graphics.BorderRight--;
                            }
                            break;

                        case Keys.Left:
                            if (keyEvent.ModShift)
                            {
                                CConfig.Config.Graphics.BorderLeft--;
                            }
                            else
                            {
                                CConfig.Config.Graphics.BorderRight++;
                            }
                            break;

                        case Keys.Down:
                            if (keyEvent.ModShift)
                            {
                                CConfig.Config.Graphics.BorderTop++;
                            }
                            else
                            {
                                CConfig.Config.Graphics.BorderBottom--;
                            }
                            break;

                        case Keys.Up:
                            if (keyEvent.ModShift)
                            {
                                CConfig.Config.Graphics.BorderTop--;
                            }
                            else
                            {
                                CConfig.Config.Graphics.BorderBottom++;
                            }
                            break;

                        case Keys.D0:
                        case Keys.NumPad0:
                            CConfig.Config.Graphics.BorderLeft      =
                                CConfig.Config.Graphics.BorderRight = CConfig.Config.Graphics.BorderTop = CConfig.Config.Graphics.BorderBottom = 0;
                            break;

                        case Keys.Add:
                            switch (CConfig.Config.Graphics.ScreenAlignment)
                            {
                            case EGeneralAlignment.Middle:
                                CConfig.Config.Graphics.ScreenAlignment = EGeneralAlignment.End;
                                break;

                            case EGeneralAlignment.End:
                                CConfig.Config.Graphics.ScreenAlignment = EGeneralAlignment.Start;
                                break;

                            default:
                                CConfig.Config.Graphics.ScreenAlignment = EGeneralAlignment.Middle;
                                break;
                            }
                            break;
                        }
                        CConfig.SaveConfig();
                        break;
                    }
                }

                if (keyEvent.Key == Keys.F11)
                {
                    if (_CurrentPopupScreen == EPopupScreens.NoPopup)
                    {
                        ShowPopup(EPopupScreens.PopupServerQR);
                    }
                    else
                    {
                        HidePopup(EPopupScreens.PopupServerQR);
                    }
                }

                if (keyEvent.Key == Keys.F8)
                {
                    CLog.ShowLogAssistant("", null);
                }

                if (popupPlayerControlAllowed && keyEvent.Key == Keys.Tab)
                {
                    if (_CurrentPopupScreen == EPopupScreens.NoPopup && CConfig.Config.Sound.BackgroundMusic == EBackgroundMusicOffOn.TR_CONFIG_ON)
                    {
                        ShowPopup(EPopupScreens.PopupPlayerControl);
                    }
                    else
                    {
                        HidePopup(EPopupScreens.PopupPlayerControl);
                    }
                }

                if (popupPlayerControlAllowed && CConfig.Config.Sound.BackgroundMusic != EBackgroundMusicOffOn.TR_CONFIG_OFF)
                {
                    if (keyEvent.Key == Keys.MediaNextTrack)
                    {
                        CBackgroundMusic.Next();
                    }
                    else if (keyEvent.Key == Keys.MediaPreviousTrack)
                    {
                        CBackgroundMusic.Previous();
                    }
                    else if (keyEvent.Key == Keys.MediaPlayPause)
                    {
                        if (CBackgroundMusic.IsPlaying)
                        {
                            CBackgroundMusic.Pause();
                        }
                        else
                        {
                            CBackgroundMusic.Play();
                        }
                    }
                }

                if (keyEvent.ModShift && (keyEvent.Key == Keys.F1))
                {
                    CSettings.ProgramState = EProgramState.EditTheme;
                }
                else if (keyEvent.ModAlt && (keyEvent.Key == Keys.Enter))
                {
                    CConfig.Config.Graphics.FullScreen = (CConfig.Config.Graphics.FullScreen == EOffOn.TR_CONFIG_ON) ? EOffOn.TR_CONFIG_OFF : EOffOn.TR_CONFIG_ON;
                }
                else if (keyEvent.ModAlt && (keyEvent.Key == Keys.P))
                {
                    CDraw.MakeScreenShot();
                }
                else
                {
                    if (_Fading == null)
                    {
                        bool handled = false;
                        if (_CurrentPopupScreen != EPopupScreens.NoPopup)
                        {
                            handled = _PopupScreens[(int)_CurrentPopupScreen].HandleInput(keyEvent);
                            if (popupVolumeControlAllowed && _CurrentPopupScreen == EPopupScreens.PopupVolumeControl && handled)
                            {
                                _VolumePopupTimer.Restart();
                            }
                        }
                        else if (popupVolumeControlAllowed && _PopupScreens[(int)EPopupScreens.PopupVolumeControl].HandleInput(keyEvent))
                        {
                            ShowPopup(EPopupScreens.PopupVolumeControl);
                            _VolumePopupTimer.Restart();
                        }

                        if (!handled)
                        {
                            resume &= CurrentScreen.HandleInput(keyEvent);
                        }
                    }
                }

                if (!eventsAvailable)
                {
                    inputEventsAvailable = CController.PollKeyEvent(ref inputKeyEvent);
                }
            }

            inputEventsAvailable = CController.PollMouseEvent(ref inputMouseEvent);

            while ((eventsAvailable = mouse.PollEvent(ref mouseEvent)) || inputEventsAvailable)
            {
                if (!eventsAvailable)
                {
                    mouseEvent = inputMouseEvent;
                }

                if (mouseEvent.Wheel != 0)
                {
                    _Cursor.Activate();
                }

                _UpdateMousePosition(mouseEvent.X, mouseEvent.Y);

                bool isOverPopupPlayerControl = CHelper.IsInBounds(_PopupScreens[(int)EPopupScreens.PopupPlayerControl].ScreenArea, mouseEvent);
                if (popupPlayerControlAllowed && isOverPopupPlayerControl)
                {
                    if (_CurrentPopupScreen == EPopupScreens.NoPopup && CConfig.Config.Sound.BackgroundMusic == EBackgroundMusicOffOn.TR_CONFIG_ON)
                    {
                        ShowPopup(EPopupScreens.PopupPlayerControl);
                    }
                }

                if (!isOverPopupPlayerControl && _CurrentPopupScreen == EPopupScreens.PopupPlayerControl)
                {
                    HidePopup(EPopupScreens.PopupPlayerControl);
                }

                bool isOverPopupVolumeControl = CHelper.IsInBounds(_PopupScreens[(int)EPopupScreens.PopupVolumeControl].ScreenArea, mouseEvent);
                if (popupVolumeControlAllowed && isOverPopupVolumeControl)
                {
                    if (_CurrentPopupScreen == EPopupScreens.NoPopup)
                    {
                        ShowPopup(EPopupScreens.PopupVolumeControl);
                        _VolumePopupTimer.Reset();
                        _VolumePopupTimer.Start();
                    }
                }

                if (_CursorOverVolumeControl && !isOverPopupVolumeControl)
                {
                    if (_CurrentPopupScreen == EPopupScreens.PopupVolumeControl)
                    {
                        HidePopup(EPopupScreens.PopupVolumeControl);
                        _VolumePopupTimer.Reset();
                    }
                }
                _CursorOverVolumeControl = isOverPopupVolumeControl;


                bool handled = false;
                if (_CurrentPopupScreen != EPopupScreens.NoPopup)
                {
                    handled = _PopupScreens[(int)_CurrentPopupScreen].HandleMouse(mouseEvent);
                }

                if (!handled && _Fading == null && (_Cursor.IsActive || mouseEvent.LB || mouseEvent.RB || mouseEvent.MB))
                {
                    resume &= CurrentScreen.HandleMouse(mouseEvent);
                }

                if (!eventsAvailable)
                {
                    inputEventsAvailable = CController.PollMouseEvent(ref inputMouseEvent);
                }
            }
            return(resume);
        }
예제 #7
0
        public static bool Draw()
        {
            if (NextScreen != null && _Fading == null)
            {
                _Fading = new CFading(0f, 1f, CConfig.Config.Graphics.FadeTime);

                if (NextScreen.PartyModeID != -1)
                {
                    CFonts.PartyModeID = NextScreen.PartyModeID;
                    NextScreen.OnShow();
                    CFonts.PartyModeID = -1;
                }
                else
                {
                    NextScreen.OnShow();
                }
                if (_Cursor.IsActive)
                {
                    NextScreen.ProcessMouseMove(_Cursor.X, _Cursor.Y);
                }

                HidePopup(EPopupScreens.PopupPlayerControl);
                if (NextScreen.CurrentMusicType != EMusicType.Background && NextScreen.CurrentMusicType != EMusicType.Preview && NextScreen.CurrentMusicType != EMusicType.BackgroundPreview)
                {
                    CBackgroundMusic.Disabled = true;
                }
            }

            if (_Fading != null)
            {
                Debug.Assert(NextScreen != null);
                bool  finished;
                float newAlpha = _Fading.GetValue(out finished);

                if (!finished)
                {
                    ZOffset = CSettings.ZFar / 2;
                    _DrawScreen(CurrentScreen);

                    GlobalAlpha = newAlpha;
                    ZOffset     = 0f;
                    _DrawScreen(NextScreen);

                    GlobalAlpha = 1f;
                    int oldVol = CConfig.GetVolumeByType(CurrentScreen.CurrentMusicType);
                    int newVol = CConfig.GetVolumeByType(NextScreen.CurrentMusicType);
                    CSound.SetGlobalVolume((int)((newVol - oldVol) * newAlpha + oldVol));
                }
                else
                {
                    _FinishScreenFading();
                    if (_Cursor.IsActive)
                    {
                        CurrentScreen.ProcessMouseMove(_Cursor.X, _Cursor.Y);
                    }

                    _DrawScreen(CurrentScreen);
                }
            }
            else
            {
                _DrawScreen(CurrentScreen);
            }

            foreach (IMenu popup in _PopupScreens)
            {
                popup.Draw();
            }

            _Cursor.Draw();
            _DrawDebugInfos();

            return(true);
        }
예제 #8
0
        public static void CheckAndApplyConfig(EOffOn NewOnOff, EBackgroundMusicSource NewSource, float NewVolume)
        {
            if (CConfig.BackgroundMusic != NewOnOff)
            {
                CConfig.BackgroundMusic = NewOnOff;
                if (NewOnOff == EOffOn.TR_CONFIG_ON)
                {
                    Play();
                }
                else
                {
                    Pause();
                }
            }

            if (CConfig.BackgroundMusicSource != NewSource)
            {
                CConfig.BackgroundMusicSource = NewSource;

                switch (NewSource)
                {
                case EBackgroundMusicSource.TR_CONFIG_NO_OWN_MUSIC:
                    if (!_BackgroundMusicAdded)
                    {
                        AddBackgroundMusic();
                    }

                    RemoveOwnMusic();
                    break;

                case EBackgroundMusicSource.TR_CONFIG_ONLY_OWN_MUSIC:
                    if (!_OwnMusicAdded)
                    {
                        AddOwnMusic();
                    }

                    RemoveBackgroundMusic();
                    break;

                case EBackgroundMusicSource.TR_CONFIG_OWN_MUSIC:
                    if (!_BackgroundMusicAdded)
                    {
                        AddBackgroundMusic();
                    }

                    if (!_OwnMusicAdded)
                    {
                        AddOwnMusic();
                    }
                    break;
                }
            }

            if (CConfig.BackgroundMusicVolume != NewVolume)
            {
                CConfig.BackgroundMusicVolume = (int)NewVolume;
                ApplyVolume();
            }

            CConfig.SaveConfig();
        }
예제 #9
0
 public static float GetRenderAspect()
 {
     return(RenderW * CConfig.GetNumScreens() / (float)RenderH);
 }