From 256762305ac90db02364a4bbe387c93fff519b13 Mon Sep 17 00:00:00 2001 From: Florian Kuepper Date: Fri, 7 Dec 2012 21:44:47 +0100 Subject: [PATCH] Finished volume-control. --- Output/Languages/Deutsch.xml | 4 + Output/Languages/English.xml | 4 + .../Ambient/Screens/ScreenOptionsSound.xml | 192 +++++++++++++++++- Output/Themes/Ambient/Skin Blue.xml | 5 +- Output/Themes/Ambient/Skin Green.xml | 5 +- Output/Themes/Ambient/Skin Red.xml | 5 +- Output/Themes/Ambient/Skin Yellow.xml | 5 +- .../Changelog_ScreenOptionsSound.txt | 12 ++ Vocaluxe/Menu/CGraphics.cs | 22 ++ Vocaluxe/Menu/CMenu.cs | 4 + Vocaluxe/Screens/CPopupScreenVolumeControl.cs | 140 +++++++++++++ Vocaluxe/Screens/CScreenOptionsSound.cs | 15 +- Vocaluxe/Screens/CScreenSing.cs | 11 +- Vocaluxe/Screens/CScreenSong.cs | 11 + Vocaluxe/Vocaluxe.csproj | 1 + .../Screens/PopupScreenVolumeControl.xml | 119 +++++++++++ 16 files changed, 544 insertions(+), 11 deletions(-) create mode 100644 Vocaluxe/Screens/CPopupScreenVolumeControl.cs create mode 100644 output/themes/Ambient/Screens/PopupScreenVolumeControl.xml diff --git a/Output/Languages/Deutsch.xml b/Output/Languages/Deutsch.xml index 19f1decd..610e191e 100644 --- a/Output/Languages/Deutsch.xml +++ b/Output/Languages/Deutsch.xml @@ -190,6 +190,8 @@ Hintergrundmusik Hintergrundmusiklautstärke Hintergrundmusikquelle + Vorschaulautstärke + Spiellautstärke Designeinstellungen Design @@ -210,5 +212,7 @@ Video-Vorschau Videos während des Singens Videos der Hintergrundmusik + + Lautstärke diff --git a/Output/Languages/English.xml b/Output/Languages/English.xml index b3e2194f..02105784 100644 --- a/Output/Languages/English.xml +++ b/Output/Languages/English.xml @@ -190,6 +190,8 @@ Background Music Background Music Volume Background Music Source + Preview Music Volume + Game Music Volume Theme Options Theme @@ -210,5 +212,7 @@ Video Preview Videos while singing Display current backgroundmusic video + + Volume diff --git a/Output/Themes/Ambient/Screens/ScreenOptionsSound.xml b/Output/Themes/Ambient/Screens/ScreenOptionsSound.xml index 3f23d55c..1433aa5a 100644 --- a/Output/Themes/Ambient/Screens/ScreenOptionsSound.xml +++ b/Output/Themes/Ambient/Screens/ScreenOptionsSound.xml @@ -1,7 +1,7 @@  - 2 + 3 Video @@ -145,6 +145,64 @@ + + + 75 + 285 + + 0,00 + + 32 + + + + StaticColor + + + TextSColor + + Left + + Center + + + + Outline + + TR_SCREENOSOUND_PREVIEWMUSICVOLUME + + + + + + + 75 + 345 + + 0,00 + + 32 + + + + StaticColor + + + TextSColor + + Left + + Center + + + + Outline + + TR_SCREENOSOUND_GAMEMUSICVOLUME + + + + Button @@ -397,5 +455,135 @@ 1 + + + Invisible + + SelectSlideArrowLeft + + SelectSlideArrowRight + + SelectSlide + + SelectSlideArrowLeft + + SelectSlideArrowRight + + SelectSlide + + 500 + 280 + 0,00 + 700 + 50 + + 505 + 285 + 0,00 + 40 + 40 + + 1170 + 285 + 0,00 + 40 + 40 + + + SelectSlideColor + + + SelectSlideSColor + + + SelectSlideHColor + + + ArrowColor + + + ArrowSColor + + + TextColor + + + TextSColor + + 32,00 + + 500,00 + + Outline + + Bold + + 3 + + + + Invisible + + SelectSlideArrowLeft + + SelectSlideArrowRight + + SelectSlide + + SelectSlideArrowLeft + + SelectSlideArrowRight + + SelectSlide + + 500 + 340 + 0,00 + 700 + 50 + + 505 + 345 + 0,00 + 40 + 40 + + 1170 + 345 + 0,00 + 40 + 40 + + + SelectSlideColor + + + SelectSlideSColor + + + SelectSlideHColor + + + ArrowColor + + + ArrowSColor + + + TextColor + + + TextSColor + + 32,00 + + 500,00 + + Outline + + Bold + + 3 + - \ No newline at end of file + diff --git a/Output/Themes/Ambient/Skin Blue.xml b/Output/Themes/Ambient/Skin Blue.xml index 7587328b..34b3ffb5 100644 --- a/Output/Themes/Ambient/Skin Blue.xml +++ b/Output/Themes/Ambient/Skin Blue.xml @@ -333,6 +333,9 @@ Delete.png Save.png Sing.png + Minus.png + Plus.png + VolumeBG.png [Blue]BG_Video.mp4 @@ -340,4 +343,4 @@ [Blue]IntroMid.mp4 [Blue]IntroOut.mp4 - \ No newline at end of file + diff --git a/Output/Themes/Ambient/Skin Green.xml b/Output/Themes/Ambient/Skin Green.xml index a5928d20..c3e20565 100644 --- a/Output/Themes/Ambient/Skin Green.xml +++ b/Output/Themes/Ambient/Skin Green.xml @@ -327,6 +327,9 @@ Delete.png Save.png Sing.png + Minus.png + Plus.png + VolumeBG.png [Green]BG_Video.mp4 @@ -334,4 +337,4 @@ [Green]IntroMid.mp4 [Green]IntroOut.mp4 - \ No newline at end of file + diff --git a/Output/Themes/Ambient/Skin Red.xml b/Output/Themes/Ambient/Skin Red.xml index fd09e46c..04aaa93a 100644 --- a/Output/Themes/Ambient/Skin Red.xml +++ b/Output/Themes/Ambient/Skin Red.xml @@ -327,6 +327,9 @@ Delete.png Save.png Sing.png + Minus.png + Plus.png + VolumeBG.png [Red]BG_Video.mp4 @@ -334,4 +337,4 @@ [Red]IntroMid.mp4 [Red]IntroOut.mp4 - \ No newline at end of file + diff --git a/Output/Themes/Ambient/Skin Yellow.xml b/Output/Themes/Ambient/Skin Yellow.xml index 83fab332..fdc4b49e 100644 --- a/Output/Themes/Ambient/Skin Yellow.xml +++ b/Output/Themes/Ambient/Skin Yellow.xml @@ -327,6 +327,9 @@ Delete.png Save.png Sing.png + Minus.png + Plus.png + VolumeBG.png [Yellow]BG_Video.mp4 @@ -334,4 +337,4 @@ [Yellow]IntroMid.mp4 [Yellow]IntroOut.mp4 - \ No newline at end of file + diff --git a/Output/Themes/Changelog/Changelog_ScreenOptionsSound.txt b/Output/Themes/Changelog/Changelog_ScreenOptionsSound.txt index 5bdf4bfd..d83bd921 100644 --- a/Output/Themes/Changelog/Changelog_ScreenOptionsSound.txt +++ b/Output/Themes/Changelog/Changelog_ScreenOptionsSound.txt @@ -1,5 +1,17 @@ ScreenOptionsSound +++++++++++ +Version 3: + +Add: + + + + +and some texts for description (Text5, Text6) +"TR_SCRsEENOSOUND_PREVIEWMUSICVOLUME" +"TR_SCREENOSOUND_GAMEMUSICVOLUEM" + ++++++++++ Version 2: diff --git a/Vocaluxe/Menu/CGraphics.cs b/Vocaluxe/Menu/CGraphics.cs index b309938a..d921cace 100644 --- a/Vocaluxe/Menu/CGraphics.cs +++ b/Vocaluxe/Menu/CGraphics.cs @@ -40,6 +40,7 @@ namespace Vocaluxe.Menu enum EPopupScreens { PopupPlayerControl = 0, + PopupVolumeControl = 1, NoPopup = -1 } @@ -210,6 +211,11 @@ namespace Vocaluxe.Menu get { return _ZOffset; } } + public static EScreens CurrentScreen + { + get { return _CurrentScreen; } + } + #region public methods public static void InitGraphics() { @@ -235,6 +241,7 @@ namespace Vocaluxe.Menu _Screens.Add(new CScreenCredits()); _PopupScreens.Add(new CPopupScreenPlayerControl()); + _PopupScreens.Add(new CPopupScreenVolumeControl()); CLog.StopBenchmark(1, "Build Screen List"); @@ -454,6 +461,8 @@ namespace Vocaluxe.Menu bool PopupPlayerControlAllowed = _CurrentScreen != EScreens.ScreenOptionsRecord && _CurrentScreen != EScreens.ScreenSing && _CurrentScreen != EScreens.ScreenSong && _CurrentScreen != EScreens.ScreenCredits; + bool PopupVolumeControlAllowed = _CurrentScreen != EScreens.ScreenCredits; + bool Resume = true; while (keys.PollEvent(ref KeyEvent)) { @@ -517,9 +526,22 @@ namespace Vocaluxe.Menu 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); + } + + if (!isOverPopupVolumeControl && _CurrentPopupScreen == EPopupScreens.PopupVolumeControl) + HidePopup(EPopupScreens.PopupVolumeControl); + bool handled = false; if (_CurrentPopupScreen != EPopupScreens.NoPopup) handled = _PopupScreens[(int)_CurrentPopupScreen].HandleMouse(MouseEvent); + if (handled && _CurrentPopupScreen == EPopupScreens.PopupVolumeControl) + _Screens[(int)_CurrentScreen].ApplyVolume(); + if (!handled && !_Fading && (_Cursor.IsActive || MouseEvent.LB || MouseEvent.RB || MouseEvent.MB)) Resume &= _Screens[(int)_CurrentScreen].HandleMouse(MouseEvent); diff --git a/Vocaluxe/Menu/CMenu.cs b/Vocaluxe/Menu/CMenu.cs index 4d96610d..267e69ea 100644 --- a/Vocaluxe/Menu/CMenu.cs +++ b/Vocaluxe/Menu/CMenu.cs @@ -1078,6 +1078,10 @@ namespace Vocaluxe.Menu public abstract bool UpdateGame(); + public virtual void ApplyVolume() + { + } + public virtual void OnShow() { ResumeBG(); diff --git a/Vocaluxe/Screens/CPopupScreenVolumeControl.cs b/Vocaluxe/Screens/CPopupScreenVolumeControl.cs new file mode 100644 index 00000000..95885e83 --- /dev/null +++ b/Vocaluxe/Screens/CPopupScreenVolumeControl.cs @@ -0,0 +1,140 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Text; +using System.Windows.Forms; + +using Vocaluxe.Base; +using Vocaluxe.GameModes; +using Vocaluxe.Lib.Draw; +using Vocaluxe.Menu; +using Vocaluxe.Lib.Song; + +namespace Vocaluxe.Screens +{ + class CPopupScreenVolumeControl : CMenu + { + // Version number for theme files. Increment it, if you've changed something on the theme files! + const int ScreenVersion = 1; + + private const string StaticBG = "StaticBG"; + + private const string SelectSlideVolume = "SelectSlideVolume"; + + + public CPopupScreenVolumeControl() + { + Init(); + } + + protected override void Init() + { + base.Init(); + + _ThemeName = "PopupScreenVolumeControl"; + _ScreenVersion = ScreenVersion; + + _ThemeStatics = new string[] { StaticBG }; + _ThemeSelectSlides = new string[] { SelectSlideVolume }; + + } + + public override void LoadTheme() + { + base.LoadTheme(); + + _ScreenArea = Statics[htStatics(StaticBG)].Rect; + SelectSlides[htSelectSlides(SelectSlideVolume)].AddValues(new string[] { "0", "5", "10", "15", "20", "25", "30", "35", "40", "45", "50", "55", "60", "65", "70", "75", "80", "85", "90", "95", "100" }); + } + + public override bool HandleInput(KeyEvent KeyEvent) + { + base.HandleInput(KeyEvent); + if (KeyEvent.KeyPressed && !Char.IsControl(KeyEvent.Unicode)) + { + + } + else + { + switch (KeyEvent.Key) + { + case Keys.Escape: + case Keys.Back: + CGraphics.HidePopup(EPopupScreens.PopupVolumeControl); + return false; + } + } + + return true; + } + + public override bool HandleMouse(MouseEvent MouseEvent) + { + base.HandleMouse(MouseEvent); + if (MouseEvent.LB) + { + SaveConfig(); + return true; + } + else if (MouseEvent.RB) + { + //CGraphics.HidePopup(EPopupScreens.PopupPlayerControl); + return false; + } + return true; + } + + public override void OnShow() + { + base.OnShow(); + + switch (CGraphics.CurrentScreen) + { + case EScreens.ScreenSong: + SelectSlides[htSelectSlides(SelectSlideVolume)].SetSelectionByValueIndex((int)CConfig.PreviewMusicVolume / 5); + break; + + case EScreens.ScreenSing: + SelectSlides[htSelectSlides(SelectSlideVolume)].SetSelectionByValueIndex((int)CConfig.GameMusicVolume / 5); + break; + + default: + SelectSlides[htSelectSlides(SelectSlideVolume)].SetSelectionByValueIndex((int)CConfig.BackgroundMusicVolume / 5); + break; + } + } + + public override bool UpdateGame() + { + return true; + } + + public override bool Draw() + { + if (!_Active) + return false; + + return base.Draw(); + } + + private void SaveConfig() + { + switch (CGraphics.CurrentScreen) + { + case EScreens.ScreenSong: + CConfig.PreviewMusicVolume = SelectSlides[htSelectSlides(SelectSlideVolume)].Selection * 5; + break; + + case EScreens.ScreenSing: + CConfig.GameMusicVolume = SelectSlides[htSelectSlides(SelectSlideVolume)].Selection * 5; + break; + + default: + CConfig.BackgroundMusicVolume = SelectSlides[htSelectSlides(SelectSlideVolume)].Selection * 5; + CBackgroundMusic.ApplyVolume(); + break; + } + CConfig.SaveConfig(); + } + } +} diff --git a/Vocaluxe/Screens/CScreenOptionsSound.cs b/Vocaluxe/Screens/CScreenOptionsSound.cs index 2e8207f7..929c371b 100644 --- a/Vocaluxe/Screens/CScreenOptionsSound.cs +++ b/Vocaluxe/Screens/CScreenOptionsSound.cs @@ -12,11 +12,13 @@ namespace Vocaluxe.Screens class CScreenOptionsSound : CMenu { // Version number for theme files. Increment it, if you've changed something on the theme files! - const int ScreenVersion = 2; + const int ScreenVersion = 3; private const string SelectSlideBackgroundMusic = "SelectSlideBackgroundMusic"; private const string SelectSlideBackgroundMusicVolume = "SelectSlideBackgroundMusicVolume"; private const string SelectSlideBackgroundMusicSource = "SelectSlideBackgroundMusicSource"; + private const string SelectSlidePreviewMusicVolume = "SelectSlidePreviewMusicVolume"; + private const string SelectSlideGameMusicVolume = "SelectSlideGameMusicVolume"; private const string ButtonExit = "ButtonExit"; @@ -36,7 +38,7 @@ namespace Vocaluxe.Screens _ScreenVersion = ScreenVersion; _ThemeButtons = new string[] { ButtonExit }; - _ThemeSelectSlides = new string[] { SelectSlideBackgroundMusic, SelectSlideBackgroundMusicVolume, SelectSlideBackgroundMusicSource }; + _ThemeSelectSlides = new string[] { SelectSlideBackgroundMusic, SelectSlideBackgroundMusicVolume, SelectSlideBackgroundMusicSource, SelectSlidePreviewMusicVolume, SelectSlideGameMusicVolume }; } public override void LoadTheme() @@ -47,6 +49,11 @@ namespace Vocaluxe.Screens SelectSlides[htSelectSlides(SelectSlideBackgroundMusicVolume)].Selection = CConfig.BackgroundMusicVolume / 5; SelectSlides[htSelectSlides(SelectSlideBackgroundMusicSource)].SetValues((int)CConfig.BackgroundMusicSource); SelectSlides[htSelectSlides(SelectSlideBackgroundMusicSource)].Selection = (int)CConfig.BackgroundMusicSource; + SelectSlides[htSelectSlides(SelectSlidePreviewMusicVolume)].AddValues(new string[] { "0", "5", "10", "15", "20", "25", "30", "35", "40", "45", "50", "55", "60", "65", "70", "75", "80", "85", "90", "95", "100" }); + SelectSlides[htSelectSlides(SelectSlidePreviewMusicVolume)].Selection = CConfig.PreviewMusicVolume / 5; + SelectSlides[htSelectSlides(SelectSlideGameMusicVolume)].AddValues(new string[] { "0", "5", "10", "15", "20", "25", "30", "35", "40", "45", "50", "55", "60", "65", "70", "75", "80", "85", "90", "95", "100" }); + SelectSlides[htSelectSlides(SelectSlideGameMusicVolume)].Selection = CConfig.GameMusicVolume / 5; + } public override bool HandleInput(KeyEvent KeyEvent) @@ -130,6 +137,10 @@ namespace Vocaluxe.Screens } private void SaveConfig() { + CConfig.GameMusicVolume = SelectSlides[htSelectSlides(SelectSlideGameMusicVolume)].Selection * 5; + CConfig.PreviewMusicVolume = SelectSlides[htSelectSlides(SelectSlidePreviewMusicVolume)].Selection * 5; + CConfig.SaveConfig(); + EOffOn NewOffOn = (EOffOn)SelectSlides[htSelectSlides(SelectSlideBackgroundMusic)].Selection; EBackgroundMusicSource NewSource = (EBackgroundMusicSource)SelectSlides[htSelectSlides(SelectSlideBackgroundMusicSource)].Selection; float NewVolume = SelectSlides[htSelectSlides(SelectSlideBackgroundMusicVolume)].Selection * 5; diff --git a/Vocaluxe/Screens/CScreenSing.cs b/Vocaluxe/Screens/CScreenSing.cs index 231ef2e8..5b3b96c7 100644 --- a/Vocaluxe/Screens/CScreenSing.cs +++ b/Vocaluxe/Screens/CScreenSing.cs @@ -236,7 +236,7 @@ namespace Vocaluxe.Screens if (CConfig.GameMusicVolume > 100) CConfig.GameMusicVolume = 100; CConfig.SaveConfig(); - CSound.SetStreamVolume(_CurrentStream, CConfig.GameMusicVolume); + ApplyVolume(); } break; @@ -248,7 +248,7 @@ namespace Vocaluxe.Screens if (CConfig.GameMusicVolume < 0) CConfig.GameMusicVolume = 0; CConfig.SaveConfig(); - CSound.SetStreamVolume(_CurrentStream, CConfig.GameMusicVolume); + ApplyVolume(); } break; } @@ -515,6 +515,11 @@ namespace Vocaluxe.Screens CloseSong(); } + public override void ApplyVolume() + { + CSound.SetStreamVolumeMax(_CurrentStream, CConfig.GameMusicVolume); + } + private void CloseSong() { CSound.FadeAndStop(_CurrentStream, 0f, 0.5f); @@ -569,7 +574,7 @@ namespace Vocaluxe.Screens Texts[htTexts(TextSongName)].Text = songname; _CurrentStream = CSound.Load(song.GetMP3(), true); - CSound.SetStreamVolumeMax(_CurrentStream, 100f); //TODO: Add volume control var + CSound.SetStreamVolumeMax(_CurrentStream, CConfig.GameMusicVolume); CSound.SetStreamVolume(_CurrentStream, _Volume); CSound.SetPosition(_CurrentStream, song.Start); _CurrentTime = song.Start; diff --git a/Vocaluxe/Screens/CScreenSong.cs b/Vocaluxe/Screens/CScreenSong.cs index a4008cea..3dc74033 100644 --- a/Vocaluxe/Screens/CScreenSong.cs +++ b/Vocaluxe/Screens/CScreenSong.cs @@ -317,6 +317,7 @@ namespace Vocaluxe.Screens if (CConfig.PreviewMusicVolume > 100) CConfig.PreviewMusicVolume = 100; CConfig.SaveConfig(); + ApplyVolume(); } else if (KeyEvent.ModSHIFT && (KeyEvent.Key == Keys.Subtract || KeyEvent.Key == Keys.PageDown)) { @@ -324,11 +325,16 @@ namespace Vocaluxe.Screens if (CConfig.PreviewMusicVolume < 0) CConfig.PreviewMusicVolume = 0; CConfig.SaveConfig(); + ApplyVolume(); } return true; } + public void Apply() + { + } + public override bool HandleMouse(MouseEvent MouseEvent) { base.HandleMouse(MouseEvent); @@ -590,6 +596,11 @@ namespace Vocaluxe.Screens SongMenus[htSongMenus(SongMenu)].OnHide(); } + public override void ApplyVolume() + { + SongMenus[htSongMenus(SongMenu)].ApplyVolume(CConfig.PreviewMusicVolume); + } + private void StartSong(int SongNr) { if ((CSongs.Category >= 0) && (SongNr >= 0)) diff --git a/Vocaluxe/Vocaluxe.csproj b/Vocaluxe/Vocaluxe.csproj index 156dd856..fde218c1 100644 --- a/Vocaluxe/Vocaluxe.csproj +++ b/Vocaluxe/Vocaluxe.csproj @@ -235,6 +235,7 @@ Form + diff --git a/output/themes/Ambient/Screens/PopupScreenVolumeControl.xml b/output/themes/Ambient/Screens/PopupScreenVolumeControl.xml new file mode 100644 index 00000000..4fd2de9f --- /dev/null +++ b/output/themes/Ambient/Screens/PopupScreenVolumeControl.xml @@ -0,0 +1,119 @@ + + + + 1 + + + Menu + + 1065 + 672 + -2,00 + 225 + 48 + + + StaticColor + + + + + + + 1067 + 680 + + -2,00 + + 32 + + 80 + + + StaticColor + + + TextSColor + + Left + + Center + + + + Outline + + TR_SCREENPVOLUMECONTROL_VOLUME + + + + + + + Invisible + + Minus + + Plus + + Invisible + + Minus + + Plus + + Invisible + + 1090 + 680 + -2,00 + 200 + 50 + + 1195 + 682 + -2,00 + 30 + 30 + + 1240 + 682 + -2,00 + 30 + 30 + + + SelectSlideColor + + + SelectSlideSColor + + + SelectSlideHColor + + + ArrowColor + + + ArrowSColor + + + TextColor + + + TextSColor + + 32,00 + + 500,00 + + Outline + + Bold + -15,0 + -8,0 + + 1 + + +