diff --git a/Output/AForge.Video.DirectShow.dll b/Output/AForge.Video.DirectShow.dll new file mode 100644 index 00000000..2d14556a Binary files /dev/null and b/Output/AForge.Video.DirectShow.dll differ diff --git a/Output/AForge.Video.dll b/Output/AForge.Video.dll new file mode 100644 index 00000000..7ff735b4 Binary files /dev/null and b/Output/AForge.Video.dll differ diff --git a/Output/Languages/Deutsch.xml b/Output/Languages/Deutsch.xml index 19f1decd..98c84333 100644 --- a/Output/Languages/Deutsch.xml +++ b/Output/Languages/Deutsch.xml @@ -18,6 +18,7 @@ Textures ToneAbs Max. Volume + Geladene Songs Maus Normal @@ -159,10 +160,14 @@ Aktiv Neu Löschen + Snapshot + Snapshot speichern + Snapshot löschen + Webcam Einstellungen Spiel - Sound + Sound Aufnahme Video Songtext @@ -190,6 +195,8 @@ Hintergrundmusik Hintergrundmusiklautstärke Hintergrundmusikquelle + Vorschaulautstärke + Spiellautstärke Designeinstellungen Design @@ -210,5 +217,9 @@ Video-Vorschau Videos während des Singens Videos der Hintergrundmusik + Webcams + Webcamfähigkeiten + + Lautstärke diff --git a/Output/Languages/English.xml b/Output/Languages/English.xml index b3e2194f..c07c4636 100644 --- a/Output/Languages/English.xml +++ b/Output/Languages/English.xml @@ -18,6 +18,7 @@ Textures ToneAbs Max Volume + Loaded songs Mouse Normal @@ -159,10 +160,14 @@ Active New Delete + Take Snapshot + Save Snapshot + Delete Snapshot + Webcam Menu Options Game - Sound + Sound Record Video Lyrics @@ -190,6 +195,8 @@ Background Music Background Music Volume Background Music Source + Preview Music Volume + Game Music Volume Theme Options Theme @@ -210,5 +217,9 @@ Video Preview Videos while singing Display current backgroundmusic video + Webcams + Webcamcapabilities + + Volume diff --git a/Output/Languages/French.xml b/Output/Languages/French.xml index 6da3296d..c4a7f455 100644 --- a/Output/Languages/French.xml +++ b/Output/Languages/French.xml @@ -18,11 +18,13 @@ Textures ToneAbs Volume Max + Chansons chargées Souris Normal Duo Medley + Version courte Vocal Hero Superstar @@ -88,6 +90,10 @@ Musique personnelle et Musique de fond Pas de Musique personnelle Seulement la Musique personnelle + + Tout + Seulement noms et avatars + Rien Chargement @@ -114,10 +120,19 @@ Attention: Aucun profils n'est assigné aux joueurs %v! Choix de la chanson + Chanter + Ajouter à la playlist + Annuler + Choisir une chanson aléatoire + Choisir une catégorie aléatoire + Chanter toutes les chansons + Chanter toutes les chansons visibles + Ouvrir une playlist + Nouvelle playlist + Option de la chanson Rechercher: Pas de Langue Pas d'Année - TODO: New Playlist Pas de Genre Pas d'Edition Toutes les chansons @@ -126,12 +141,14 @@ Pause Arrêter de chanter - Continuer + Continuer + Passer cette chanson Scores Note Points Difficulté + Score total Meilleurs Scores @@ -143,12 +160,17 @@ Actif Nouveau Supprimer + Prendre une photo + Sauvegarder la photo + Supprimer la photo + Webcam Menu des Options Jeu - Son + Son Enregistrement Vidéo + Paroles Thème Options du Jeu @@ -173,6 +195,8 @@ Musique de fond Volume de la Musique de fond Source de la Musique de fond + Volume de la musique de prévisualisation + Volume de la musique du jeu Options du Thème Thème @@ -181,12 +205,21 @@ Afficher les portées Afficher l'aide pour la Tonalité Apparence du Minuteur + Dégradé des info des joueurs Chargement des couvertures + + Options des paroles + Style + Paroles en haut Options Vidéo Vidéo en arrière plan Prévisualisation des Vidéos Vidéos pendant que l'on chante Afficher la vidéo de la musique de fond + Webcams + Webcamcapabilities + + Volume diff --git a/Output/Languages/Spanish.xml b/Output/Languages/Spanish.xml index 2c4a8456..12adb00e 100644 --- a/Output/Languages/Spanish.xml +++ b/Output/Languages/Spanish.xml @@ -146,7 +146,7 @@ Opciones del Menú Juego - Sonido + Sonido Grabación Video Estilos diff --git a/Output/Themes/Ambient/Minus.png b/Output/Themes/Ambient/Minus.png new file mode 100644 index 00000000..9bdede57 Binary files /dev/null and b/Output/Themes/Ambient/Minus.png differ diff --git a/Output/Themes/Ambient/Plus.png b/Output/Themes/Ambient/Plus.png new file mode 100644 index 00000000..5b813c53 Binary files /dev/null and b/Output/Themes/Ambient/Plus.png differ diff --git a/Output/Themes/Ambient/Screens/ScreenOptions.xml b/Output/Themes/Ambient/Screens/ScreenOptions.xml index 808f1d29..39a927f9 100644 --- a/Output/Themes/Ambient/Screens/ScreenOptions.xml +++ b/Output/Themes/Ambient/Screens/ScreenOptions.xml @@ -155,7 +155,7 @@ Outline - TR_SCRENNO_BUTTON_SOUND + TR_SCREENO_BUTTON_SOUND @@ -401,4 +401,4 @@ - \ No newline at end of file + 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/Screens/ScreenOptionsVideo.xml b/Output/Themes/Ambient/Screens/ScreenOptionsVideo.xml index a21e9cdc..683194b0 100644 --- a/Output/Themes/Ambient/Screens/ScreenOptionsVideo.xml +++ b/Output/Themes/Ambient/Screens/ScreenOptionsVideo.xml @@ -1,7 +1,7 @@  - 2 + 3 Video @@ -215,13 +215,71 @@ - Normal + Outline TR_SCREENO_VIDEO_VIDEOSTOBACKGROUND + + + 75 + 345 + + 0,00 + + 32 + + + + StaticColor + + + TextSColor + + Left + + Center + + + + Outline + + TR_SCREENO_VIDEO_WEBCAMDEVICES + + + + + + + 75 + 405 + + 0,00 + + 32 + + + + StaticColor + + + TextSColor + + Left + + Center + + + + Outline + + TR_SCREENO_VIDEO_WEBCAMCAPABILITIES + + + + Button @@ -533,11 +591,157 @@ 205,33 - Normal + 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 + + 205,33 + + Outline + + Bold + + 3 + + + + Invisible + + SelectSlideArrowLeft + + SelectSlideArrowRight + + SelectSlide + + SelectSlideArrowLeft + + SelectSlideArrowRight + + SelectSlide + + 500 + 400 + 0,00 + 700 + 50 + + 505 + 405 + 0,00 + 40 + 40 + + 1170 + 405 + 0,00 + 40 + 40 + + + SelectSlideColor + + + SelectSlideSColor + + + SelectSlideHColor + + + ArrowColor + + + ArrowSColor + + + TextColor + + + TextSColor + + 32,00 + + 150,00 + + Outline + + Bold + + 3 + + + + CoverBackground + + 75 + 460 + 0,00 + 320 + 240 + + + Visible + + + + - \ No newline at end of file + diff --git a/Output/Themes/Ambient/Screens/ScreenProfiles.xml b/Output/Themes/Ambient/Screens/ScreenProfiles.xml index 7bd59c6b..9e161ea7 100644 --- a/Output/Themes/Ambient/Screens/ScreenProfiles.xml +++ b/Output/Themes/Ambient/Screens/ScreenProfiles.xml @@ -1,7 +1,7 @@  - 1 + 2 Video @@ -576,6 +576,218 @@ 26 + + + Button + + Button + + 985 + 600 + 0,00 + 150 + 50 + + + ButtonColor + + + ButtonSColor + + + 75 + 10 + + 32 + + 142 + + + ButtonTextColor + + + ButtonTextSColor + + Center + + Center + + + + Outline + + TR_SCREENPROFILES_BUTTON_TAKESNAPSHOT + + + + + + 10 + 26 + + + + + + 10 + 26 + + + + + Button + + Button + + 985 + 600 + 0,00 + 150 + 50 + + + ButtonColor + + + ButtonSColor + + + 75 + 10 + + 32 + + 142 + + + ButtonTextColor + + + ButtonTextSColor + + Center + + Center + + + + Outline + + TR_SCREENPROFILES_BUTTON_WEBCAM + + + + + + 10 + 26 + + + + + + 10 + 26 + + + + + Button + + Button + + 300 + 205 + 0,00 + 150 + 50 + + + ButtonColor + + + ButtonSColor + + + 75 + 10 + + 32 + + 142 + + + ButtonTextColor + + + ButtonTextSColor + + Center + + Center + + + + Outline + + TR_SCREENPROFILES_BUTTON_SAVESNAPSHOT + + + + + + + + + + + Button + + Button + + 300 + 125 + 0,00 + 150 + 50 + + + ButtonColor + + + ButtonSColor + + + 75 + 10 + + 32 + + 142 + + + ButtonTextColor + + + ButtonTextSColor + + Center + + Center + + + + Outline + + TR_SCREENPROFILES_BUTTON_DISCARDSNAPSHOT + + + + + + + + Invisible @@ -902,4 +1114,4 @@ 2 - \ No newline at end of file + diff --git a/Output/Themes/Ambient/Screens/ScreenSing.xml b/Output/Themes/Ambient/Screens/ScreenSing.xml index 21d12061..f4708b96 100644 --- a/Output/Themes/Ambient/Screens/ScreenSing.xml +++ b/Output/Themes/Ambient/Screens/ScreenSing.xml @@ -1,7 +1,7 @@  - 5 + 6 None @@ -2771,4 +2771,4 @@ - \ No newline at end of file + diff --git a/Output/Themes/Ambient/Skin Blue.xml b/Output/Themes/Ambient/Skin Blue.xml index 7587328b..f4549af2 100644 --- a/Output/Themes/Ambient/Skin Blue.xml +++ b/Output/Themes/Ambient/Skin Blue.xml @@ -333,6 +333,8 @@ Delete.png Save.png Sing.png + Minus.png + Plus.png [Blue]BG_Video.mp4 @@ -340,4 +342,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..994705cd 100644 --- a/Output/Themes/Ambient/Skin Green.xml +++ b/Output/Themes/Ambient/Skin Green.xml @@ -327,6 +327,8 @@ Delete.png Save.png Sing.png + Minus.png + Plus.png [Green]BG_Video.mp4 @@ -334,4 +336,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..b669bfd0 100644 --- a/Output/Themes/Ambient/Skin Red.xml +++ b/Output/Themes/Ambient/Skin Red.xml @@ -327,6 +327,8 @@ Delete.png Save.png Sing.png + Minus.png + Plus.png [Red]BG_Video.mp4 @@ -334,4 +336,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..6e3d562e 100644 --- a/Output/Themes/Ambient/Skin Yellow.xml +++ b/Output/Themes/Ambient/Skin Yellow.xml @@ -327,6 +327,8 @@ Delete.png Save.png Sing.png + Minus.png + Plus.png [Yellow]BG_Video.mp4 @@ -334,4 +336,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/Output/Themes/Changelog/Changelog_ScreenOptionsVideo.txt b/Output/Themes/Changelog/Changelog_ScreenOptionsVideo.txt index a6898ab5..790413d4 100644 --- a/Output/Themes/Changelog/Changelog_ScreenOptionsVideo.txt +++ b/Output/Themes/Changelog/Changelog_ScreenOptionsVideo.txt @@ -1,5 +1,14 @@ ScreenOptionsTheme +++++++++++ +Version 3: + +Add: +, , + +and some texts and static for description (Text6, Text7) +"TR_SCREENO_VIDEO_WEBCAMDEVICES", "TR_SCREENO_VIDEO_WEBCAMCAPABILITIES" + ++++++++++ Version 2: diff --git a/Output/Themes/Changelog/Changelog_ScreenSing.txt b/Output/Themes/Changelog/Changelog_ScreenSing.txt index 9027a30c..85b859da 100644 --- a/Output/Themes/Changelog/Changelog_ScreenSing.txt +++ b/Output/Themes/Changelog/Changelog_ScreenSing.txt @@ -1,7 +1,7 @@ ScreenSing +++++++++ -Version 5 +Version 6 Add: and (only showed when sining duet) diff --git a/Output/x64/acinerella.dll b/Output/x64/acinerella.dll index bd1e8749..e851fd01 100644 Binary files a/Output/x64/acinerella.dll and b/Output/x64/acinerella.dll differ diff --git a/Output/x64/avcodec-54.dll b/Output/x64/avcodec-54.dll index 69e25192..ca074e7c 100644 Binary files a/Output/x64/avcodec-54.dll and b/Output/x64/avcodec-54.dll differ diff --git a/Output/x64/avformat-54.dll b/Output/x64/avformat-54.dll index 861f80f7..40521b17 100644 Binary files a/Output/x64/avformat-54.dll and b/Output/x64/avformat-54.dll differ diff --git a/Output/x64/avutil-51.dll b/Output/x64/avutil-51.dll new file mode 100644 index 00000000..5f8cdf7d Binary files /dev/null and b/Output/x64/avutil-51.dll differ diff --git a/Output/x64/avutil-52.dll b/Output/x64/avutil-52.dll deleted file mode 100644 index 320dcca0..00000000 Binary files a/Output/x64/avutil-52.dll and /dev/null differ diff --git a/Output/x64/swscale-2.dll b/Output/x64/swscale-2.dll index 43f20682..dcc41fd3 100644 Binary files a/Output/x64/swscale-2.dll and b/Output/x64/swscale-2.dll differ diff --git a/Output/x86/acinerella.dll b/Output/x86/acinerella.dll index 7989b0ef..a39e3501 100644 Binary files a/Output/x86/acinerella.dll and b/Output/x86/acinerella.dll differ diff --git a/Output/x86/avcodec-54.dll b/Output/x86/avcodec-54.dll index 31558d7e..97d7f850 100644 Binary files a/Output/x86/avcodec-54.dll and b/Output/x86/avcodec-54.dll differ diff --git a/Output/x86/avformat-54.dll b/Output/x86/avformat-54.dll index 2f7742a4..7328c561 100644 Binary files a/Output/x86/avformat-54.dll and b/Output/x86/avformat-54.dll differ diff --git a/Output/x86/avutil-51.dll b/Output/x86/avutil-51.dll new file mode 100644 index 00000000..5ab61687 Binary files /dev/null and b/Output/x86/avutil-51.dll differ diff --git a/Output/x86/avutil-52.dll b/Output/x86/avutil-52.dll deleted file mode 100644 index 7211cde6..00000000 Binary files a/Output/x86/avutil-52.dll and /dev/null differ diff --git a/Output/x86/swscale-2.dll b/Output/x86/swscale-2.dll index 9a0f1bf6..afa902a0 100644 Binary files a/Output/x86/swscale-2.dll and b/Output/x86/swscale-2.dll differ diff --git a/Vocaluxe/Base/CBackgroundMusic.cs b/Vocaluxe/Base/CBackgroundMusic.cs index ad10b81a..fb3ea35c 100644 --- a/Vocaluxe/Base/CBackgroundMusic.cs +++ b/Vocaluxe/Base/CBackgroundMusic.cs @@ -181,7 +181,7 @@ namespace Vocaluxe.Base { if (_CurrentMusicStream != -1) { - CSound.Fade(_CurrentMusicStream, CConfig.BackgroundMusicVolume, CSettings.BackgroundMusicFadeTime); + CSound.Fade(_CurrentMusicStream, 100f, CSettings.BackgroundMusicFadeTime); CSound.Play(_CurrentMusicStream); if (_VideoEnabled && _Video != -1) CVideo.VdResume(_Video); @@ -276,6 +276,7 @@ namespace Vocaluxe.Base _CurrentPlaylistElement = _PreviousFileNames[_PreviousMusicIndex]; } _CurrentMusicStream = CSound.Load(_CurrentPlaylistElement.MusicFilePath); + CSound.SetStreamVolumeMax(_CurrentMusicStream, CConfig.BackgroundMusicVolume); //Seek to #Start-Tag, if found if (_CurrentPlaylistElement.Start != 0f) @@ -311,6 +312,7 @@ namespace Vocaluxe.Base _CurrentPlaylistElement = _PreviousFileNames[_PreviousMusicIndex]; _CurrentMusicStream = CSound.Load(_CurrentPlaylistElement.MusicFilePath); + CSound.SetStreamVolumeMax(_CurrentMusicStream, CConfig.BackgroundMusicVolume); if (_VideoEnabled) LoadVideo(); CSound.SetStreamVolume(_CurrentMusicStream, 0f); @@ -327,7 +329,7 @@ namespace Vocaluxe.Base public static void ApplyVolume() { - CSound.SetStreamVolume(_CurrentMusicStream, CConfig.BackgroundMusicVolume); + CSound.SetStreamVolumeMax(_CurrentMusicStream, CConfig.BackgroundMusicVolume); } public static void AddOwnMusic() diff --git a/Vocaluxe/Base/CConfig.cs b/Vocaluxe/Base/CConfig.cs index 60a30d7d..14ecf859 100644 --- a/Vocaluxe/Base/CConfig.cs +++ b/Vocaluxe/Base/CConfig.cs @@ -11,6 +11,7 @@ using System.Xml.XPath; using OpenTK.Platform; using Vocaluxe.Lib.Sound; +using Vocaluxe.Lib.Webcam; namespace Vocaluxe.Base { @@ -87,6 +88,12 @@ namespace Vocaluxe.Base OpenAL } + public enum EWebcamLib + { + OpenCV, + AForgeNet + } + public enum ERecordLib { #if WIN @@ -228,9 +235,11 @@ namespace Vocaluxe.Base public static ERecordLib RecordLib = ERecordLib.PortAudio; public static EBufferSize AudioBufferSize = EBufferSize.b2048; public static int AudioLatency = 0; - public static int BackgroundMusicVolume = 50; + public static int BackgroundMusicVolume = 30; public static EOffOn BackgroundMusic = EOffOn.TR_CONFIG_ON; public static EBackgroundMusicSource BackgroundMusicSource = EBackgroundMusicSource.TR_CONFIG_NO_OWN_MUSIC; + public static int PreviewMusicVolume = 50; + public static int GameMusicVolume = 80; // Game public static List SongFolder = new List(); @@ -255,6 +264,8 @@ namespace Vocaluxe.Base // Record public static SMicConfig[] MicConfig; public static int MicDelay = 300; //[ms] + public static EWebcamLib WebcamLib = EWebcamLib.OpenCV; + public static SWebcamConfig WebcamConfig; //Lists to save parameters and values private static List _Params = new List(); @@ -358,7 +369,21 @@ namespace Vocaluxe.Base 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 @@ -427,6 +452,13 @@ namespace Vocaluxe.Base CHelper.TryGetEnumValueFromXML("//root/Video/VideoPreview", navigator, ref VideoPreview); CHelper.TryGetEnumValueFromXML("//root/Video/VideosInSongs", navigator, ref VideosInSongs); CHelper.TryGetEnumValueFromXML("//root/Video/VideosToBackground", navigator, ref VideosToBackground); + + CHelper.TryGetEnumValueFromXML("//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 @@ -447,7 +479,6 @@ namespace Vocaluxe.Base MicDelay = 0; if (MicDelay > 500) MicDelay = 500; - #endregion Record return true; @@ -585,6 +616,12 @@ namespace Vocaluxe.Base writer.WriteComment("Background Music Source"); writer.WriteElementString("BackgroundMusicSource", Enum.GetName(typeof(EBackgroundMusicSource), BackgroundMusicSource)); + writer.WriteComment("Preview Volume from 0 to 100"); + writer.WriteElementString("PreviewMusicVolume", PreviewMusicVolume.ToString()); + + writer.WriteComment("Game Volume from 0 to 100"); + writer.WriteElementString("GameMusicVolume", GameMusicVolume.ToString()); + writer.WriteEndElement(); #endregion Sound @@ -668,6 +705,18 @@ namespace Vocaluxe.Base writer.WriteComment("Show backgroundmusic videos as background: " + ListStrings(Enum.GetNames(typeof(EOffOn)))); writer.WriteElementString("VideosToBackground", Enum.GetName(typeof(EOffOn), VideosToBackground)); + writer.WriteComment("WebcamLib: " + ListStrings(Enum.GetNames(typeof(EWebcamLib)))); + writer.WriteElementString("WebcamLib", Enum.GetName(typeof(EWebcamLib), WebcamLib)); + + writer.WriteStartElement("WebcamConfig"); + + writer.WriteElementString("MonikerString", WebcamConfig.MonikerString); + writer.WriteElementString("Framerate", WebcamConfig.Framerate.ToString()); + writer.WriteElementString("Width", WebcamConfig.Width.ToString()); + writer.WriteElementString("Height", WebcamConfig.Height.ToString()); + + writer.WriteEndElement(); + writer.WriteEndElement(); #endregion Video diff --git a/Vocaluxe/Base/CFont.cs b/Vocaluxe/Base/CFont.cs index 1349f672..0c3fa048 100644 --- a/Vocaluxe/Base/CFont.cs +++ b/Vocaluxe/Base/CFont.cs @@ -123,6 +123,11 @@ namespace Vocaluxe.Base fo.Dispose(); } + public void UnloadTexture() + { + CDraw.RemoveTexture(ref Texture); + } + private float GetFactor(char chr, TextFormatFlags flags) { if (CFonts.Style == EStyle.Normal) @@ -277,6 +282,15 @@ namespace Vocaluxe.Base _htGlyphs.Add(chr, _Glyphs.Count - 1); CFonts.Height = h; } + + public void UnloadAllGlyphs() + { + foreach (CGlyph glyph in _Glyphs) + { + glyph.UnloadTexture(); + } + _Glyphs.Clear(); + } } struct SFont @@ -854,6 +868,27 @@ namespace Vocaluxe.Base writer.WriteEndElement(); } + public static void UnloadThemeFonts(string ThemeName) + { + if (_Fonts.Count == 0) + return; + + int Index = 0; + while (Index < _Fonts.Count) + { + if (_Fonts[Index].IsThemeFont && _Fonts[Index].ThemeName == ThemeName) + { + _Fonts[Index].Normal.UnloadAllGlyphs(); + _Fonts[Index].Italic.UnloadAllGlyphs(); + _Fonts[Index].Bold.UnloadAllGlyphs(); + _Fonts[Index].BoldItalic.UnloadAllGlyphs(); + _Fonts.RemoveAt(Index); + } + else + Index++; + } + } + private static int GetFontIndex(string ThemeName, string FontName) { if (ThemeName == String.Empty || FontName == String.Empty) diff --git a/Vocaluxe/Base/CPlaylists.cs b/Vocaluxe/Base/CPlaylists.cs index c9babd16..c509f4f6 100644 --- a/Vocaluxe/Base/CPlaylists.cs +++ b/Vocaluxe/Base/CPlaylists.cs @@ -80,13 +80,13 @@ namespace Vocaluxe.Base try { File.Delete(_Playlists[PlaylistID].PlaylistFile); - _Playlists.RemoveAt(PlaylistID); } catch (Exception) { - CLog.LogError("Can't delete Profile File " + _Playlists[PlaylistID].PlaylistFile + ".xml"); + CLog.LogError("Can't delete Playlist File " + _Playlists[PlaylistID].PlaylistFile + ".xml"); } } + _Playlists.RemoveAt(PlaylistID); } public static void SavePlaylist(int PlaylistID) diff --git a/Vocaluxe/Base/CSettings.cs b/Vocaluxe/Base/CSettings.cs index 4bfb32ef..c222613c 100644 --- a/Vocaluxe/Base/CSettings.cs +++ b/Vocaluxe/Base/CSettings.cs @@ -47,7 +47,7 @@ namespace Vocaluxe.Base public const int iVersionSub = 0; // patches public const ERevision VersionRevision = ERevision.Alpha; - public const int iBuild = 68; // Increase on every published version! Never Reset! + public const int iBuild = 69; // Increase on every published version! Never Reset! public const int iDatabaseHighscoreVersion = 1; public const int iDatabaseCoverVersion = 1; diff --git a/Vocaluxe/Base/CSound.cs b/Vocaluxe/Base/CSound.cs index 986476e9..7f6414d4 100644 --- a/Vocaluxe/Base/CSound.cs +++ b/Vocaluxe/Base/CSound.cs @@ -108,6 +108,10 @@ namespace Vocaluxe.Base _Playback.SetStreamVolume(Stream, Volume); } + public static void SetStreamVolumeMax(int Stream, float Volume) + { + _Playback.SetStreamVolumeMax(Stream, Volume); + } public static float GetLength(int Stream) { diff --git a/Vocaluxe/Base/CWebcam.cs b/Vocaluxe/Base/CWebcam.cs new file mode 100644 index 00000000..cb735d77 --- /dev/null +++ b/Vocaluxe/Base/CWebcam.cs @@ -0,0 +1,75 @@ +using System; +using System.Collections.Generic; +using System.Text; + +using Vocaluxe.Lib.Webcam; +using Vocaluxe.Lib.Draw; +using System.Drawing; + +namespace Vocaluxe.Base +{ + static class CWebcam + { + private static IWebcam _Webcam; + + public static void Init() + { + switch (CConfig.WebcamLib) + { + case EWebcamLib.AForgeNet: + _Webcam = new CAForgeNet(); + break; + + default: + _Webcam = new CAForgeNet(); + break; + } + _Webcam.Init(); + _Webcam.Select(CConfig.WebcamConfig); + + CConfig.WebcamConfig = _Webcam.GetConfig(); + CConfig.SaveConfig(); + } + + public static bool GetFrame(ref STexture tex) + { + _Webcam.GetFrame(ref tex); + return true; + } + + public static Bitmap GetBitmap() + { + return _Webcam.GetBitmap(); + } + + public static void Close() + { + _Webcam.Close(); + } + + public static void Pause() + { + _Webcam.Pause(); + } + + public static void Start() + { + _Webcam.Start(); + } + + public static void Stop() + { + _Webcam.Stop(); + } + + public static void Select(SWebcamConfig c) + { + _Webcam.Select(c); + } + + public static SWebcamDevice[] GetDevices() + { + return _Webcam.GetDevices(); + } + } +} diff --git a/Vocaluxe/Lib/Sound/COpenALPlay.cs b/Vocaluxe/Lib/Sound/COpenALPlay.cs index 85e17cd4..18d91b37 100644 --- a/Vocaluxe/Lib/Sound/COpenALPlay.cs +++ b/Vocaluxe/Lib/Sound/COpenALPlay.cs @@ -234,6 +234,21 @@ namespace Vocaluxe.Lib.Sound } } + public void SetStreamVolumeMax(int Stream, float Volume) + { + if (_Initialized) + { + lock (MutexDecoder) + { + if (AlreadyAdded(Stream)) + { + _Decoder[GetStreamIndex(Stream)].VolumeMax = Volume; + } + } + + } + } + public float GetLength(int Stream) { if (_Initialized) @@ -399,6 +414,7 @@ namespace Vocaluxe.Lib.Sound private bool _Initialized; private int _ByteCount = 4; private float _Volume = 1f; + private float _VolumeMax = 1f; private Stopwatch _fadeTimer = new Stopwatch(); @@ -500,6 +516,23 @@ namespace Vocaluxe.Lib.Sound } } + public float VolumeMax + { + get { return _VolumeMax * 100f; } + set + { + lock (MutexData) + { + _VolumeMax = value / 100f; + if (_VolumeMax < 0f) + _VolumeMax = 0f; + + if (_VolumeMax > 1f) + _VolumeMax = 1f; + } + } + } + public float Position { get @@ -826,7 +859,7 @@ namespace Vocaluxe.Lib.Sound b[0] = buf[i]; b[1] = buf[i + 1]; - b = BitConverter.GetBytes((Int16)(BitConverter.ToInt16(b, 0) * _Volume)); + b = BitConverter.GetBytes((Int16)(BitConverter.ToInt16(b, 0) * _Volume * _VolumeMax)); buf[i] = b[0]; buf[i + 1] = b[1]; @@ -835,7 +868,7 @@ namespace Vocaluxe.Lib.Sound b[0] = buf[i + 2]; b[1] = buf[i + 3]; - b = BitConverter.GetBytes((Int16)(BitConverter.ToInt16(b, 0) * _Volume)); + b = BitConverter.GetBytes((Int16)(BitConverter.ToInt16(b, 0) * _Volume * _VolumeMax)); buf[i + 2] = b[0]; buf[i + 3] = b[1]; } diff --git a/Vocaluxe/Lib/Sound/CPortAudioPlay.cs b/Vocaluxe/Lib/Sound/CPortAudioPlay.cs index 6c7ebc7c..ebf80f66 100644 --- a/Vocaluxe/Lib/Sound/CPortAudioPlay.cs +++ b/Vocaluxe/Lib/Sound/CPortAudioPlay.cs @@ -218,6 +218,21 @@ namespace Vocaluxe.Lib.Sound } } + public void SetStreamVolumeMax(int Stream, float Volume) + { + if (_Initialized) + { + lock (MutexDecoder) + { + if (AlreadyAdded(Stream)) + { + _Decoder[GetStreamIndex(Stream)].VolumeMax = Volume; + } + } + + } + } + public float GetLength(int Stream) { if (_Initialized) @@ -375,6 +390,7 @@ namespace Vocaluxe.Lib.Sound private bool _Initialized; private int _ByteCount = 4; private float _Volume = 1f; + private float _VolumeMax = 1f; private Stopwatch _fadeTimer = new Stopwatch(); @@ -480,6 +496,23 @@ namespace Vocaluxe.Lib.Sound } } + public float VolumeMax + { + get { return _VolumeMax * 100f; } + set + { + lock (_LockData) + { + _VolumeMax = value / 100f; + if (_VolumeMax < 0f) + _VolumeMax = 0f; + + if (_VolumeMax > 1f) + _VolumeMax = 1f; + } + } + } + public float Position { get @@ -817,7 +850,7 @@ namespace Vocaluxe.Lib.Sound b[0] = buf[i]; b[1] = buf[i + 1]; - b = BitConverter.GetBytes((Int16)(BitConverter.ToInt16(b, 0) * _Volume)); + b = BitConverter.GetBytes((Int16)(BitConverter.ToInt16(b, 0) * _Volume * _VolumeMax)); buf[i] = b[0]; buf[i + 1] = b[1]; @@ -826,7 +859,7 @@ namespace Vocaluxe.Lib.Sound b[0] = buf[i + 2]; b[1] = buf[i + 3]; - b = BitConverter.GetBytes((Int16)(BitConverter.ToInt16(b, 0) * _Volume)); + b = BitConverter.GetBytes((Int16)(BitConverter.ToInt16(b, 0) * _Volume * _VolumeMax)); buf[i + 2] = b[0]; buf[i + 3] = b[1]; } diff --git a/Vocaluxe/Lib/Sound/IPlayback.cs b/Vocaluxe/Lib/Sound/IPlayback.cs index a1fbd9b1..46fe668e 100644 --- a/Vocaluxe/Lib/Sound/IPlayback.cs +++ b/Vocaluxe/Lib/Sound/IPlayback.cs @@ -37,7 +37,8 @@ namespace Vocaluxe.Lib.Sound void Fade(int Stream, float TargetVolume, float Seconds); void FadeAndPause(int Stream, float TargetVolume, float Seconds); void FadeAndStop(int Stream, float TargetVolume, float Seconds); - void SetStreamVolume(int Stream, float Volume); + void SetStreamVolume(int Stream, float Volume); + void SetStreamVolumeMax(int Stream, float Volume); float GetLength(int Stream); float GetPosition(int Stream); diff --git a/Vocaluxe/Lib/Webcam/CAForgeNet.cs b/Vocaluxe/Lib/Webcam/CAForgeNet.cs new file mode 100644 index 00000000..0d520e1a --- /dev/null +++ b/Vocaluxe/Lib/Webcam/CAForgeNet.cs @@ -0,0 +1,182 @@ +using System; +using System.Collections.Generic; +using System.Text; +using Vocaluxe.Base; +using AForge.Video; +using System.Drawing; +using AForge.Video.DirectShow; +using System.Drawing.Imaging; +using System.Runtime.InteropServices; +using Vocaluxe.Lib.Draw; +using System.Threading; + +namespace Vocaluxe.Lib.Webcam +{ + class CAForgeNet : IWebcam + { + private Bitmap _CurrentFrame = new Bitmap(1, 1); + private List _Devices = new List(); + private bool _Paused; + private VideoCaptureDevice _Webcam; + private FilterInfoCollection _WebcamDevices; + private SWebcamConfig _Config; + + public void Close() + { + if (_Webcam != null) + { + _Webcam.SignalToStop(); + _Webcam.NewFrame -= new NewFrameEventHandler(OnFrame); + } + } + + public bool GetFrame(ref STexture Frame) + { + if ((_CurrentFrame != null) && (_Webcam != null)) + { + lock (_CurrentFrame) + { + BitmapData bitmapdata = _CurrentFrame.LockBits(new Rectangle(0, 0, _CurrentFrame.Width, _CurrentFrame.Height), ImageLockMode.ReadOnly, PixelFormat.Format32bppArgb); + byte[] data = new byte[4 * _CurrentFrame.Width * _CurrentFrame.Height]; + Marshal.Copy(bitmapdata.Scan0, data, 0, data.Length); + _CurrentFrame.UnlockBits(bitmapdata); + if (((Frame.index == -1) || (_CurrentFrame.Width != Frame.width)) || (_CurrentFrame.Height != Frame.height)) + { + CDraw.RemoveTexture(ref Frame); + Frame = CDraw.AddTexture(_CurrentFrame.Width, _CurrentFrame.Height, ref data); + } + else + { + CDraw.UpdateTexture(ref Frame, ref data); + } + } + } + return false; + } + + public Bitmap GetBitmap() + { + if ((_CurrentFrame != null) && (_Webcam != null)) + { + lock (_CurrentFrame) + { + return (Bitmap)_CurrentFrame.Clone(); + } + } + else + return null; + } + + public bool Init() + { + _WebcamDevices = new FilterInfoCollection(FilterCategory.VideoInputDevice); + int num = 0; + foreach (FilterInfo info in _WebcamDevices) + { + SWebcamDevice device = new SWebcamDevice { + ID = num, + Name = info.Name, + MonikerString = info.MonikerString, + Capabilities = new List() + }; + num++; + VideoCaptureDevice tmpdev = new VideoCaptureDevice(info.MonikerString); + + for (int i = 0; i < tmpdev.VideoCapabilities.Length; i++ ) + { + SCapabilities item = new SCapabilities + { + Framerate = tmpdev.VideoCapabilities[i].FrameRate, + Height = tmpdev.VideoCapabilities[i].FrameSize.Height, + Width = tmpdev.VideoCapabilities[i].FrameSize.Width + }; + device.Capabilities.Add(item); + } + _Devices.Add(device); + } + return true; + } + + private void OnFrame(object sender, NewFrameEventArgs e) + { + if (!_Paused) + { + lock (_CurrentFrame) + { + _CurrentFrame = (Bitmap) e.Frame.Clone(); + } + } + } + + public void Pause() + { + if (_Webcam != null) + { + _Paused = true; + } + } + + public void Start() + { + if (_Webcam != null) + { + _Webcam.NewFrame -= new NewFrameEventHandler(OnFrame); + //Subscribe to NewFrame event + _Webcam.NewFrame += new NewFrameEventHandler(OnFrame); + _Webcam.Start(); + _Paused = false; + } + } + + public void Stop() + { + if (_Webcam != null) + { + _Webcam.SignalToStop(); + } + } + + public SWebcamDevice[] GetDevices() + { + return _Devices.ToArray(); + } + + public bool Select(SWebcamConfig Config) + { + //Close old camera connection + Close(); + + if (_WebcamDevices == null) + return false; + if (_WebcamDevices.Count < 1) + return false; + + //No MonikerString found, try first webcam + if (Config.MonikerString == String.Empty) + _Webcam = new VideoCaptureDevice(_WebcamDevices[0].MonikerString); + else //Found MonikerString + _Webcam = new VideoCaptureDevice(Config.MonikerString); + + if (_Webcam == null) + return false; + + if (Config.Framerate != 0 && Config.Height != 0 && Config.Width != 0) + { + _Webcam.DesiredFrameRate = Config.Framerate; + _Webcam.DesiredFrameSize = new Size(Config.Width, Config.Height); + } + + _Config.Framerate = _Webcam.DesiredFrameRate; + _Config.Height = _Webcam.DesiredFrameSize.Height; + _Config.Width = _Webcam.DesiredFrameSize.Width; + _Config.MonikerString = _Webcam.Source; + + return true; + } + + public SWebcamConfig GetConfig() + { + return _Config; + } + } +} diff --git a/Vocaluxe/Lib/Webcam/IWebcam.cs b/Vocaluxe/Lib/Webcam/IWebcam.cs new file mode 100644 index 00000000..5b0ed223 --- /dev/null +++ b/Vocaluxe/Lib/Webcam/IWebcam.cs @@ -0,0 +1,48 @@ +using System; +using System.Collections.Generic; +using System.Text; +using Vocaluxe.Lib.Draw; +using System.Drawing; + +namespace Vocaluxe.Lib.Webcam +{ + struct SWebcamDevice + { + public int ID; + public string Name; + public string MonikerString; + public List Capabilities; + } + + struct SCapabilities + { + public int Framerate; + public int Width; + public int Height; + } + + struct SWebcamConfig + { + public string MonikerString; + public int Framerate; + public int Width; + public int Height; + } + + interface IWebcam + { + bool Init(); + + void Start(); + void Pause(); + void Stop(); + void Close(); + + bool GetFrame(ref STexture Frame); + Bitmap GetBitmap(); + SWebcamConfig GetConfig(); + SWebcamDevice[] GetDevices(); + + bool Select(SWebcamConfig sWebcamConfig); + } +} diff --git a/Vocaluxe/Menu/CGraphics.cs b/Vocaluxe/Menu/CGraphics.cs index 797a454e..75b8b52e 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 } @@ -200,6 +201,11 @@ namespace Vocaluxe.Menu private static List _Screens = new List(); private static List _PopupScreens = new List(); + private static float _SavedBackgroundMusicVolume; + private static float _SavedPreviewMusicVolume; + private static float _SavedGameMusicVolume; + private static Stopwatch _VolumePopupTimer; + public static float GlobalAlpha { get { return _GlobalAlpha; } @@ -210,6 +216,11 @@ namespace Vocaluxe.Menu get { return _ZOffset; } } + public static EScreens CurrentScreen + { + get { return _CurrentScreen; } + } + #region public methods public static void InitGraphics() { @@ -235,6 +246,7 @@ namespace Vocaluxe.Menu _Screens.Add(new CScreenCredits()); _PopupScreens.Add(new CPopupScreenPlayerControl()); + _PopupScreens.Add(new CPopupScreenVolumeControl()); CLog.StopBenchmark(1, "Build Screen List"); @@ -242,6 +254,7 @@ namespace Vocaluxe.Menu _NextScreen = EScreens.ScreenNull; _CurrentPopupScreen = EPopupScreens.NoPopup; _FadingTimer = new Stopwatch(); + _VolumePopupTimer = new Stopwatch(); _GlobalAlpha = 1f; _ZOffset = 0f; @@ -317,6 +330,10 @@ namespace Vocaluxe.Menu public static void InitFirstScreen() { + _SavedBackgroundMusicVolume = CConfig.BackgroundMusicVolume; + _SavedGameMusicVolume = CConfig.GameMusicVolume; + _SavedPreviewMusicVolume = CConfig.PreviewMusicVolume; + _Screens[(int)_CurrentScreen].OnShow(); _Screens[(int)_CurrentScreen].OnShowFinish(); } @@ -457,6 +474,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; bool EventsAvailable = false; bool InputEventsAvailable = CInput.PollKeyEvent(ref InputKeyEvent); @@ -534,9 +553,28 @@ 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); + _VolumePopupTimer.Reset(); + } + } + + if (!isOverPopupVolumeControl && _CurrentPopupScreen == EPopupScreens.PopupVolumeControl) + { + HidePopup(EPopupScreens.PopupVolumeControl); + _VolumePopupTimer.Reset(); + } + 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); @@ -591,6 +629,34 @@ namespace Vocaluxe.Menu private static bool Update() { + //User changed volume with keyboard, pop-up isn't visible yet + if ((_SavedPreviewMusicVolume != CConfig.PreviewMusicVolume || _SavedGameMusicVolume != CConfig.GameMusicVolume || _SavedBackgroundMusicVolume != CConfig.BackgroundMusicVolume) + && (_CurrentPopupScreen != EPopupScreens.PopupVolumeControl && !_VolumePopupTimer.IsRunning)) + { + _VolumePopupTimer.Start(); + _SavedBackgroundMusicVolume = CConfig.BackgroundMusicVolume; + _SavedGameMusicVolume = CConfig.GameMusicVolume; + _SavedPreviewMusicVolume = CConfig.PreviewMusicVolume; + } + //User changed volume with keyboard, pop-up is already visible + else if ((_SavedPreviewMusicVolume != CConfig.PreviewMusicVolume || _SavedGameMusicVolume != CConfig.GameMusicVolume || _SavedBackgroundMusicVolume != CConfig.BackgroundMusicVolume) + && (_CurrentPopupScreen == EPopupScreens.PopupVolumeControl && _VolumePopupTimer.IsRunning)) + { + _VolumePopupTimer.Reset(); + _VolumePopupTimer.Start(); + _SavedBackgroundMusicVolume = CConfig.BackgroundMusicVolume; + _SavedGameMusicVolume = CConfig.GameMusicVolume; + _SavedPreviewMusicVolume = CConfig.PreviewMusicVolume; + } + if (_VolumePopupTimer.IsRunning && _VolumePopupTimer.ElapsedMilliseconds < 1500 && _CurrentPopupScreen != EPopupScreens.PopupVolumeControl) + ShowPopup(EPopupScreens.PopupVolumeControl); + if(_VolumePopupTimer.IsRunning && _VolumePopupTimer.ElapsedMilliseconds >= 1500 && _CurrentPopupScreen == EPopupScreens.PopupVolumeControl) + { + _VolumePopupTimer.Reset(); + HidePopup(EPopupScreens.PopupVolumeControl); + } + if (!_Cursor.IsActive && _CurrentPopupScreen == EPopupScreens.PopupVolumeControl) + HidePopup(EPopupScreens.PopupVolumeControl); if (_CurrentPopupScreen != EPopupScreens.NoPopup) _PopupScreens[(int)_CurrentPopupScreen].UpdateGame(); return _Screens[(int)_CurrentScreen].UpdateGame(); @@ -686,7 +752,7 @@ namespace Vocaluxe.Menu dy += rect.Height; } - if (CConfig.DebugLevel >= EDebugLevel.TR_CONFIG_LEVEL2) + if (CConfig.DebugLevel >= EDebugLevel.TR_CONFIG_LEVEL3) { txt = CSongs.NumSongsWithCoverLoaded.ToString(CLanguage.Translate("TR_DEBUG_SONGS") + ": 00000"); @@ -697,7 +763,7 @@ namespace Vocaluxe.Menu dy += rect.Height; } - if (CConfig.DebugLevel >= EDebugLevel.TR_CONFIG_LEVEL2) + if (CConfig.DebugLevel >= EDebugLevel.TR_CONFIG_LEVEL_MAX) { txt = _Cursor.X.ToString(CLanguage.Translate("TR_DEBUG_MOUSE") + " : (0000/") + _Cursor.Y.ToString("0000)"); diff --git a/Vocaluxe/Menu/CMenu.cs b/Vocaluxe/Menu/CMenu.cs index a1e2ef51..d639d91e 100644 --- a/Vocaluxe/Menu/CMenu.cs +++ b/Vocaluxe/Menu/CMenu.cs @@ -912,6 +912,36 @@ namespace Vocaluxe.Menu if (KeyEvent.Key == Keys.Right) NextElement(); } + if (!CBackgroundMusic.Disabled) + { + if (KeyEvent.ModSHIFT && (KeyEvent.Key == Keys.Add || KeyEvent.Key == Keys.PageUp)) + { + CConfig.BackgroundMusicVolume = CConfig.BackgroundMusicVolume + 5; + if (CConfig.BackgroundMusicVolume > 100) + CConfig.BackgroundMusicVolume = 100; + CConfig.SaveConfig(); + } + else if (KeyEvent.ModSHIFT && (KeyEvent.Key == Keys.Subtract || KeyEvent.Key == Keys.PageDown)) + { + CConfig.BackgroundMusicVolume = CConfig.BackgroundMusicVolume - 5; + if (CConfig.BackgroundMusicVolume < 0) + CConfig.BackgroundMusicVolume = 0; + CConfig.SaveConfig(); + } + else if (KeyEvent.Key == Keys.MediaNextTrack) + CBackgroundMusic.Next(); + else if (KeyEvent.Key == Keys.MediaPreviousTrack) + CBackgroundMusic.Previous(); + else if (KeyEvent.Key == Keys.MediaPlayPause) + { + if (CBackgroundMusic.Playing) + CBackgroundMusic.Pause(); + else + CBackgroundMusic.Play(); + } + + CBackgroundMusic.ApplyVolume(); + } return true; } @@ -1060,6 +1090,10 @@ namespace Vocaluxe.Menu public abstract bool UpdateGame(); + public virtual void ApplyVolume() + { + } + public virtual void OnShow() { ResumeBG(); diff --git a/Vocaluxe/Menu/CPlaylist.cs b/Vocaluxe/Menu/CPlaylist.cs index 69dbf8c9..6b08a68d 100644 --- a/Vocaluxe/Menu/CPlaylist.cs +++ b/Vocaluxe/Menu/CPlaylist.cs @@ -272,45 +272,45 @@ namespace Vocaluxe.Menu if (_Theme.ButtonPlaylistClose.Rect.Y < CompleteRect.Y) CompleteRect.Y = _Theme.ButtonPlaylistClose.Rect.Y; if (_Theme.ButtonPlaylistClose.Rect.W + _Theme.ButtonPlaylistClose.Rect.X > CompleteRect.W + CompleteRect.X) - CompleteRect.W += _Theme.ButtonPlaylistClose.Rect.W + _Theme.ButtonPlaylistClose.Rect.X - CompleteRect.X; + CompleteRect.W = _Theme.ButtonPlaylistClose.Rect.W + _Theme.ButtonPlaylistClose.Rect.X - CompleteRect.X; if (_Theme.ButtonPlaylistClose.Rect.Y + _Theme.ButtonPlaylistClose.Rect.H > CompleteRect.Y + CompleteRect.H) - CompleteRect.H += _Theme.ButtonPlaylistClose.Rect.H + _Theme.ButtonPlaylistClose.Rect.Y - CompleteRect.Y; + CompleteRect.H = _Theme.ButtonPlaylistClose.Rect.H + _Theme.ButtonPlaylistClose.Rect.Y - CompleteRect.Y; //ButtonPlaylistName if (_Theme.ButtonPlaylistName.Rect.X < CompleteRect.X) CompleteRect.X = _Theme.ButtonPlaylistName.Rect.X; if (_Theme.ButtonPlaylistName.Rect.Y < CompleteRect.Y) CompleteRect.Y = _Theme.ButtonPlaylistName.Rect.Y; if (_Theme.ButtonPlaylistName.Rect.W + _Theme.ButtonPlaylistName.Rect.X > CompleteRect.W + CompleteRect.X) - CompleteRect.W += _Theme.ButtonPlaylistName.Rect.W + _Theme.ButtonPlaylistName.Rect.X - CompleteRect.X; + CompleteRect.W = _Theme.ButtonPlaylistName.Rect.W + _Theme.ButtonPlaylistName.Rect.X - CompleteRect.X; if (_Theme.ButtonPlaylistName.Rect.Y + _Theme.ButtonPlaylistName.Rect.H > CompleteRect.Y + CompleteRect.H) - CompleteRect.H += _Theme.ButtonPlaylistName.Rect.H + _Theme.ButtonPlaylistName.Rect.Y - CompleteRect.Y; + CompleteRect.H = _Theme.ButtonPlaylistName.Rect.H + _Theme.ButtonPlaylistName.Rect.Y - CompleteRect.Y; //ButtonPlaylistSing if (_Theme.ButtonPlaylistSing.Rect.X < CompleteRect.X) CompleteRect.X = _Theme.ButtonPlaylistSing.Rect.X; if (_Theme.ButtonPlaylistSing.Rect.Y < CompleteRect.Y) CompleteRect.Y = _Theme.ButtonPlaylistSing.Rect.Y; if (_Theme.ButtonPlaylistSing.Rect.W + _Theme.ButtonPlaylistSing.Rect.X > CompleteRect.W + CompleteRect.X) - CompleteRect.W += _Theme.ButtonPlaylistSing.Rect.W + _Theme.ButtonPlaylistSing.Rect.X - CompleteRect.X; + CompleteRect.W = _Theme.ButtonPlaylistSing.Rect.W + _Theme.ButtonPlaylistSing.Rect.X - CompleteRect.X; if (_Theme.ButtonPlaylistSing.Rect.Y + _Theme.ButtonPlaylistSing.Rect.H > CompleteRect.Y + CompleteRect.H) - CompleteRect.H += _Theme.ButtonPlaylistSing.Rect.H + _Theme.ButtonPlaylistSing.Rect.Y - CompleteRect.Y; + CompleteRect.H = _Theme.ButtonPlaylistSing.Rect.H + _Theme.ButtonPlaylistSing.Rect.Y - CompleteRect.Y; //ButtonPlaylistSave if (_Theme.ButtonPlaylistSave.Rect.X < CompleteRect.X) CompleteRect.X = _Theme.ButtonPlaylistSave.Rect.X; if (_Theme.ButtonPlaylistSave.Rect.Y < CompleteRect.Y) CompleteRect.Y = _Theme.ButtonPlaylistSave.Rect.Y; if (_Theme.ButtonPlaylistSave.Rect.W + _Theme.ButtonPlaylistSave.Rect.X > CompleteRect.W + CompleteRect.X) - CompleteRect.W += _Theme.ButtonPlaylistSave.Rect.W + _Theme.ButtonPlaylistSave.Rect.X - CompleteRect.X; + CompleteRect.W = _Theme.ButtonPlaylistSave.Rect.W + _Theme.ButtonPlaylistSave.Rect.X - CompleteRect.X; if (_Theme.ButtonPlaylistSave.Rect.Y + _Theme.ButtonPlaylistSave.Rect.H > CompleteRect.Y + CompleteRect.H) - CompleteRect.H += _Theme.ButtonPlaylistSave.Rect.H + _Theme.ButtonPlaylistSave.Rect.Y - CompleteRect.Y; + CompleteRect.H = _Theme.ButtonPlaylistSave.Rect.H + _Theme.ButtonPlaylistSave.Rect.Y - CompleteRect.Y; //ButtonPlaylistDelete if (_Theme.ButtonPlaylistDelete.Rect.X < CompleteRect.X) CompleteRect.X = _Theme.ButtonPlaylistDelete.Rect.X; if (_Theme.ButtonPlaylistDelete.Rect.Y < CompleteRect.Y) CompleteRect.Y = _Theme.ButtonPlaylistDelete.Rect.Y; if (_Theme.ButtonPlaylistDelete.Rect.W + _Theme.ButtonPlaylistDelete.Rect.X > CompleteRect.W + CompleteRect.X) - CompleteRect.W += _Theme.ButtonPlaylistDelete.Rect.W + _Theme.ButtonPlaylistDelete.Rect.X - CompleteRect.X; + CompleteRect.W = _Theme.ButtonPlaylistDelete.Rect.W + _Theme.ButtonPlaylistDelete.Rect.X - CompleteRect.X; if (_Theme.ButtonPlaylistDelete.Rect.Y + _Theme.ButtonPlaylistDelete.Rect.H > CompleteRect.Y + CompleteRect.H) - CompleteRect.H += _Theme.ButtonPlaylistDelete.Rect.H + _Theme.ButtonPlaylistDelete.Rect.Y - CompleteRect.Y; + CompleteRect.H = _Theme.ButtonPlaylistDelete.Rect.H + _Theme.ButtonPlaylistDelete.Rect.Y - CompleteRect.Y; LoadTextures(); } return _ThemeLoaded; @@ -425,7 +425,7 @@ namespace Vocaluxe.Menu public bool IsMouseOver(MouseEvent MouseEvent) { - return CHelper.IsInBounds(Rect, MouseEvent.X, MouseEvent.Y) || _Interactions.IsMouseOver(MouseEvent); + return CHelper.IsInBounds(CompleteRect, MouseEvent.X, MouseEvent.Y) || _Interactions.IsMouseOver(MouseEvent); } public void UnloadTextures() @@ -934,7 +934,7 @@ namespace Vocaluxe.Menu //Change order with holding LB if (MouseEvent.LBH && CurrentPlaylistElement != -1 && PlaylistElementContents.Count > 1 && DragAndDropSongID == -1) { - + ChangeOrderSource = CurrentPlaylistElement + Offset; //Update of Drag/Drop-Texture @@ -1076,7 +1076,7 @@ namespace Vocaluxe.Menu } } } - + UpdatePlaylist(); } _EditMode = EEditMode.None; diff --git a/Vocaluxe/Menu/CSelectSlide.cs b/Vocaluxe/Menu/CSelectSlide.cs index 9555a575..0d51f358 100644 --- a/Vocaluxe/Menu/CSelectSlide.cs +++ b/Vocaluxe/Menu/CSelectSlide.cs @@ -743,8 +743,8 @@ namespace Vocaluxe.Menu if (_NumVisible < 1 || _ValueNames.Count == 0) return; - float x = Rect.X + Rect.W * 0.1f; - float dx = Rect.W * 0.8f / _NumVisible; + float x = Rect.X + (Rect.W - TextRelativeX) * 0.1f; + float dx = (Rect.W - TextRelativeX) * 0.8f / _NumVisible; //float y = Rect.Y + (Rect.H - TextH); int offset = _Selection - (int)_NumVisible/2; diff --git a/Vocaluxe/Menu/CStatic.cs b/Vocaluxe/Menu/CStatic.cs index d9cddad7..02c695d4 100644 --- a/Vocaluxe/Menu/CStatic.cs +++ b/Vocaluxe/Menu/CStatic.cs @@ -53,6 +53,8 @@ namespace Vocaluxe.Menu public float Alpha; + public EAspect Aspect = EAspect.Stretch; + public CStatic() { _Theme = new SThemeStatic(); @@ -213,25 +215,25 @@ namespace Vocaluxe.Menu public void Draw() { - Draw(1f, Rect.Z, false, false); + Draw(1f, Rect.Z, Aspect, false); } - public void Draw(bool aspect) + public void Draw(EAspect aspect) { Draw(1f, Rect.Z, aspect, false); } - public void Draw(float scale, bool aspect) + public void Draw(float scale, EAspect aspect) { Draw(scale, Rect.Z, aspect, false); } public void ForceDraw() { - Draw(1f, Rect.Z, false, true); + Draw(1f, Rect.Z, Aspect, true); } - public void Draw(float scale, float z, bool aspect, bool ForceDraw) + public void Draw(float scale, float z, EAspect aspect, bool ForceDraw) { STexture texture; if (_Texture.index != -1) @@ -248,11 +250,11 @@ namespace Vocaluxe.Menu SRectF rect = bounds; - if (aspect) + if (aspect != EAspect.Stretch) { RectangleF bounds2 = new RectangleF(bounds.X, bounds.Y, bounds.W, bounds.H); RectangleF rect2 = new RectangleF(0f, 0f, texture.width, texture.height); - CHelper.SetRect(bounds2, ref rect2, texture.width / texture.height, EAspect.Crop); + CHelper.SetRect(bounds2, ref rect2, texture.width / texture.height, aspect); rect.X = rect2.X; rect.Y = rect2.Y; diff --git a/Vocaluxe/Menu/SongMenu/CSongMenu.cs b/Vocaluxe/Menu/SongMenu/CSongMenu.cs index 5e1836d9..3163d783 100644 --- a/Vocaluxe/Menu/SongMenu/CSongMenu.cs +++ b/Vocaluxe/Menu/SongMenu/CSongMenu.cs @@ -73,6 +73,11 @@ namespace Vocaluxe.Menu.SongMenu _SongMenu.Draw(); } + public void ApplyVolume(float VolumeMax) + { + _SongMenu.ApplyVolume(VolumeMax); + } + public bool IsActive() { return _SongMenu.IsActive(); diff --git a/Vocaluxe/Menu/SongMenu/CSongMenuFramework.cs b/Vocaluxe/Menu/SongMenu/CSongMenuFramework.cs index 045ec139..7f29d380 100644 --- a/Vocaluxe/Menu/SongMenu/CSongMenuFramework.cs +++ b/Vocaluxe/Menu/SongMenu/CSongMenuFramework.cs @@ -117,6 +117,8 @@ namespace Vocaluxe.Menu.SongMenu private int _LockedInternal = -1; protected bool _Active = false; + protected float _MaxVolume = 100f; + protected int _PreviewSelected //for preview only { get @@ -510,6 +512,16 @@ namespace Vocaluxe.Menu.SongMenu } + public virtual void ApplyVolume(float VolumeMax) + { + _MaxVolume = VolumeMax; + + foreach (int stream in _streams) + { + CSound.SetStreamVolumeMax(stream, _MaxVolume); + } + } + public virtual bool IsActive() { return _Active; @@ -598,6 +610,11 @@ namespace Vocaluxe.Menu.SongMenu CSongs.Category = -1; } + public void ApplyVolume() + { + CSound.SetStreamVolume(_actsongstream, CConfig.PreviewMusicVolume); + } + protected void SelectSong(int nr) { if (CSongs.Category >= 0 && (CSongs.NumVisibleSongs > 0) && (nr >= 0) && ((_actsong != nr) || (_streams.Count == 0))) @@ -619,6 +636,7 @@ namespace Vocaluxe.Menu.SongMenu int _stream = CSound.Load(Path.Combine(CSongs.VisibleSongs[_actsong].Folder, CSongs.VisibleSongs[_actsong].MP3FileName), true); + CSound.SetStreamVolumeMax(_stream, _MaxVolume); CSound.SetStreamVolume(_stream, 0f); float startposition = CSongs.VisibleSongs[_actsong].PreviewStart; diff --git a/Vocaluxe/Menu/SongMenu/CSongMenuTileBoard.cs b/Vocaluxe/Menu/SongMenu/CSongMenuTileBoard.cs index 47710511..e0342575 100644 --- a/Vocaluxe/Menu/SongMenu/CSongMenuTileBoard.cs +++ b/Vocaluxe/Menu/SongMenu/CSongMenuTileBoard.cs @@ -412,13 +412,13 @@ namespace Vocaluxe.Menu.SongMenu foreach (CStatic tile in _Tiles) { if (tile.Selected && _Active) - tile.Draw(1.2f, tile.Rect.Z - 0.1f, true, false); + tile.Draw(1.2f, tile.Rect.Z - 0.1f, EAspect.Crop, false); else { if (tile.Texture.index != _CoverTexture.index) - tile.Draw(1f, tile.Rect.Z, true, false); + tile.Draw(1f, tile.Rect.Z, EAspect.Crop, false); else - tile.Draw(1f, tile.Rect.Z, false, false); + tile.Draw(1f, tile.Rect.Z, EAspect.Stretch, false); } } @@ -469,11 +469,12 @@ namespace Vocaluxe.Menu.SongMenu } } - _CoverBig.Draw(1f, true); - if (_vidtex.color.A < 1) - _CoverBig.Draw(1f, true); _TextBG.Draw(); + _CoverBig.Draw(1f, EAspect.Crop); + if (_vidtex.color.A < 1) + _CoverBig.Draw(1f, EAspect.Crop); + if (_vidtex.index != -1 && _Video != -1) { RectangleF bounds = new RectangleF(_CoverBig.Rect.X, _CoverBig.Rect.Y, _CoverBig.Rect.W, _CoverBig.Rect.H); diff --git a/Vocaluxe/Menu/SongMenu/ISongMenu.cs b/Vocaluxe/Menu/SongMenu/ISongMenu.cs index 8361daba..21d0015a 100644 --- a/Vocaluxe/Menu/SongMenu/ISongMenu.cs +++ b/Vocaluxe/Menu/SongMenu/ISongMenu.cs @@ -17,6 +17,8 @@ namespace Vocaluxe.Menu.SongMenu void HandleMouse(ref MouseEvent MouseEvent); void Draw(); + void ApplyVolume(float VolumeMax); + int GetSelectedSong(); CStatic GetSelectedSongCover(); void SetSelectedSong(int VisibleSongNr); diff --git a/Vocaluxe/Program.cs b/Vocaluxe/Program.cs index 8cd97f60..92d59f0b 100644 --- a/Vocaluxe/Program.cs +++ b/Vocaluxe/Program.cs @@ -89,6 +89,13 @@ namespace Vocaluxe 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(); @@ -185,6 +192,7 @@ namespace Vocaluxe CDraw.Unload(); CLog.CloseAll(); CDataBase.CloseConnections(); + CWebcam.Close(); } catch (Exception) { diff --git a/Vocaluxe/Screens/CPopupScreenVolumeControl.cs b/Vocaluxe/Screens/CPopupScreenVolumeControl.cs new file mode 100644 index 00000000..a3c0f4aa --- /dev/null +++ b/Vocaluxe/Screens/CPopupScreenVolumeControl.cs @@ -0,0 +1,158 @@ +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.Wheel > 0 && CHelper.IsInBounds(_ScreenArea, MouseEvent)) + { + if (SelectSlides[htSelectSlides(SelectSlideVolume)].Selection - MouseEvent.Wheel >= 0) + SelectSlides[htSelectSlides(SelectSlideVolume)].SetSelectionByValueIndex(SelectSlides[htSelectSlides(SelectSlideVolume)].Selection - MouseEvent.Wheel); + else if (SelectSlides[htSelectSlides(SelectSlideVolume)].Selection - MouseEvent.Wheel < 0) + SelectSlides[htSelectSlides(SelectSlideVolume)].SetSelectionByValueIndex(0); + SaveConfig(); + return true; + } + else if (MouseEvent.Wheel < 0 && CHelper.IsInBounds(_ScreenArea, MouseEvent)) + { + if (SelectSlides[htSelectSlides(SelectSlideVolume)].Selection - MouseEvent.Wheel < SelectSlides[htSelectSlides(SelectSlideVolume)].NumValues) + SelectSlides[htSelectSlides(SelectSlideVolume)].SetSelectionByValueIndex(SelectSlides[htSelectSlides(SelectSlideVolume)].Selection - MouseEvent.Wheel); + else if (SelectSlides[htSelectSlides(SelectSlideVolume)].Selection - MouseEvent.Wheel >= SelectSlides[htSelectSlides(SelectSlideVolume)].NumValues) + SelectSlides[htSelectSlides(SelectSlideVolume)].SetSelectionByValueIndex(SelectSlides[htSelectSlides(SelectSlideVolume)].NumValues - 1); + 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..519fddfc 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) @@ -113,6 +120,10 @@ namespace Vocaluxe.Screens public override bool UpdateGame() { + if (_BackgroundMusicVolume != CConfig.BackgroundMusicVolume) + { + SelectSlides[htSelectSlides(SelectSlideBackgroundMusicVolume)].Selection = CConfig.BackgroundMusicVolume / 5; + } return true; } @@ -127,9 +138,16 @@ namespace Vocaluxe.Screens base.OnShow(); _BackgroundMusic = CConfig.BackgroundMusic; _BackgroundMusicVolume = CConfig.BackgroundMusicVolume; + + SelectSlides[htSelectSlides(SelectSlideGameMusicVolume)].Selection = CConfig.GameMusicVolume / 5; + SelectSlides[htSelectSlides(SelectSlidePreviewMusicVolume)].Selection = CConfig.PreviewMusicVolume / 5; } 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/CScreenOptionsTheme.cs b/Vocaluxe/Screens/CScreenOptionsTheme.cs index 8f7369dc..7250b268 100644 --- a/Vocaluxe/Screens/CScreenOptionsTheme.cs +++ b/Vocaluxe/Screens/CScreenOptionsTheme.cs @@ -183,6 +183,7 @@ namespace Vocaluxe.Screens _OldTheme = SelectSlides[htSelectSlides(SelectSlideTheme)].Selection; CTheme.UnloadSkins(); + CFonts.UnloadThemeFonts(CConfig.Theme); CTheme.ListSkins(); CConfig.Skin = CTheme.SkinNames[0]; _OldSkin = 0; @@ -205,6 +206,7 @@ namespace Vocaluxe.Screens _OldTheme = SelectSlides[htSelectSlides(SelectSlideTheme)].Selection; CTheme.UnloadSkins(); + CFonts.UnloadThemeFonts(CConfig.Theme); CTheme.ListSkins(); CConfig.Skin = CTheme.SkinNames[0]; _OldSkin = 0; diff --git a/Vocaluxe/Screens/CScreenOptionsVideo.cs b/Vocaluxe/Screens/CScreenOptionsVideo.cs index fd693db6..3e15a258 100644 --- a/Vocaluxe/Screens/CScreenOptionsVideo.cs +++ b/Vocaluxe/Screens/CScreenOptionsVideo.cs @@ -5,6 +5,7 @@ using System.Windows.Forms; using Vocaluxe.Base; using Vocaluxe.Menu; +using Vocaluxe.Lib.Webcam; namespace Vocaluxe.Screens @@ -12,15 +13,24 @@ namespace Vocaluxe.Screens class CScreenOptionsVideo : 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 SelectSlideVideoBackgrounds = "SelectSlideVideoBackgrounds"; private const string SelectSlideVideoPreview = "SelectSlideVideoPreview"; private const string SelectSlideVideosInSongs = "SelectSlideVideosInSongs"; private const string SelectSlideVideosToBackground = "SelectSlideVideosToBackground"; + private const string SelectSlideWebcamDevices = "SelectSlideWebcamDevices"; + private const string SelectSlideWebcamCapabilities = "SelectSlideWebcamCapabilities"; + + private const string StaticWebcamOutput = "StaticWebcamOutput"; private const string ButtonExit = "ButtonExit"; + private SWebcamConfig _Config; + Lib.Draw.STexture _WebcamTexture = new Lib.Draw.STexture(-1); + private int _DeviceNr; + private int _CapabilityNr; + public CScreenOptionsVideo() { Init(); @@ -33,8 +43,9 @@ namespace Vocaluxe.Screens _ThemeName = "ScreenOptionsVideo"; _ScreenVersion = ScreenVersion; + _ThemeStatics = new string[] { StaticWebcamOutput }; _ThemeButtons = new string[] { ButtonExit }; - _ThemeSelectSlides = new string[] { SelectSlideVideoBackgrounds, SelectSlideVideoPreview, SelectSlideVideosInSongs, SelectSlideVideosToBackground }; + _ThemeSelectSlides = new string[] { SelectSlideVideoBackgrounds, SelectSlideVideoPreview, SelectSlideVideosInSongs, SelectSlideVideosToBackground, SelectSlideWebcamDevices, SelectSlideWebcamCapabilities }; } public override void LoadTheme() @@ -78,10 +89,18 @@ namespace Vocaluxe.Screens break; case Keys.Left: + if (SelectSlides[htSelectSlides(SelectSlideWebcamDevices)].Selected) + OnDeviceEvent(); + if (SelectSlides[htSelectSlides(SelectSlideWebcamCapabilities)].Selected) + OnCapabilitiesEvent(); SaveConfig(); break; case Keys.Right: + if (SelectSlides[htSelectSlides(SelectSlideWebcamDevices)].Selected) + OnDeviceEvent(); + if (SelectSlides[htSelectSlides(SelectSlideWebcamCapabilities)].Selected) + OnCapabilitiesEvent(); SaveConfig(); break; } @@ -101,6 +120,10 @@ namespace Vocaluxe.Screens if (MouseEvent.LB && IsMouseOver(MouseEvent)) { + if (SelectSlides[htSelectSlides(SelectSlideWebcamDevices)].Selected) + OnDeviceEvent(); + if (SelectSlides[htSelectSlides(SelectSlideWebcamCapabilities)].Selected) + OnCapabilitiesEvent(); SaveConfig(); if (Buttons[htButtons(ButtonExit)].Selected) { @@ -112,6 +135,8 @@ namespace Vocaluxe.Screens public override bool UpdateGame() { + CWebcam.GetFrame(ref _WebcamTexture); + Statics[htStatics(StaticWebcamOutput)].Texture = _WebcamTexture; SelectSlides[htSelectSlides(SelectSlideVideosToBackground)].Selection = (int)CConfig.VideosToBackground; return true; } @@ -119,18 +144,138 @@ namespace Vocaluxe.Screens public override bool Draw() { base.Draw(); + return true; } + public override void OnClose() + { + base.OnClose(); + CWebcam.Close(); + } + + public override void OnShow() + { + base.OnShow(); + SelectSlides[htSelectSlides(SelectSlideWebcamDevices)].Clear(); + SelectSlides[htSelectSlides(SelectSlideWebcamCapabilities)].Clear(); + + _DeviceNr = -1; + _CapabilityNr = -1; + + SWebcamDevice[] devices = CWebcam.GetDevices(); + + if (devices != null) + { + if (devices.Length > 0) + { + _DeviceNr = 0; + _CapabilityNr = 0; + GetFirstConfiguredWebcamDevice(ref _DeviceNr, ref _CapabilityNr); + + foreach (SWebcamDevice d in devices) + { + SelectSlides[htSelectSlides(SelectSlideWebcamDevices)].AddValue(d.Name); + } + SelectSlides[htSelectSlides(SelectSlideWebcamDevices)].Selection = _DeviceNr; + + foreach (SCapabilities c in devices[_DeviceNr].Capabilities) + { + SelectSlides[htSelectSlides(SelectSlideWebcamCapabilities)].AddValue(c.Width.ToString() + " x " + c.Height.ToString() + " @ " + c.Framerate.ToString() + " FPS "); + } + _Config.MonikerString = devices[SelectSlides[htSelectSlides(SelectSlideWebcamDevices)].Selection].MonikerString; + _Config.Width = devices[SelectSlides[htSelectSlides(SelectSlideWebcamDevices)].Selection].Capabilities[SelectSlides[htSelectSlides(SelectSlideWebcamCapabilities)].Selection].Width; + _Config.Height = devices[SelectSlides[htSelectSlides(SelectSlideWebcamDevices)].Selection].Capabilities[SelectSlides[htSelectSlides(SelectSlideWebcamCapabilities)].Selection].Height; + _Config.Framerate = devices[SelectSlides[htSelectSlides(SelectSlideWebcamDevices)].Selection].Capabilities[SelectSlides[htSelectSlides(SelectSlideWebcamCapabilities)].Selection].Framerate; + CWebcam.Close(); + CWebcam.Select(CConfig.WebcamConfig); + CWebcam.Start(); + } + } + SelectSlides[htSelectSlides(SelectSlideWebcamDevices)].Visible = (devices != null && devices.Length > 0); + SelectSlides[htSelectSlides(SelectSlideWebcamCapabilities)].Visible = (devices != null && devices.Length > 0); + Statics[htStatics(StaticWebcamOutput)].Visible = (devices != null && devices.Length > 0); + } + private void SaveConfig() { CConfig.VideoBackgrounds = (EOffOn)SelectSlides[htSelectSlides(SelectSlideVideoBackgrounds)].Selection; CConfig.VideoPreview = (EOffOn)SelectSlides[htSelectSlides(SelectSlideVideoPreview)].Selection; CConfig.VideosInSongs = (EOffOn)SelectSlides[htSelectSlides(SelectSlideVideosInSongs)].Selection; CConfig.VideosToBackground = (EOffOn)SelectSlides[htSelectSlides(SelectSlideVideosToBackground)].Selection; + + CConfig.WebcamConfig = _Config; CBackgroundMusic.VideoEnabled = true; CConfig.SaveConfig(); } + + private void OnDeviceEvent() + { + if (SelectSlides[htSelectSlides(SelectSlideWebcamDevices)].Selection != _DeviceNr) + { + SelectSlides[htSelectSlides(SelectSlideWebcamCapabilities)].Clear(); + _DeviceNr = SelectSlides[htSelectSlides(SelectSlideWebcamDevices)].Selection; + _CapabilityNr = 0; + + SWebcamDevice[] d = CWebcam.GetDevices(); + for (int i = 0; i < d[SelectSlides[htSelectSlides(SelectSlideWebcamDevices)].Selection].Capabilities.Count; i++) + { + SelectSlides[htSelectSlides(SelectSlideWebcamCapabilities)].AddValue(d[_DeviceNr].Capabilities[i].Width.ToString() + " x " + d[_DeviceNr].Capabilities[i].Height.ToString() + " @ " + d[_DeviceNr].Capabilities[i].Framerate.ToString() + "FPS"); + } + SelectSlides[htSelectSlides(SelectSlideWebcamCapabilities)].Selection = 0; + + _Config.MonikerString = d[SelectSlides[htSelectSlides(SelectSlideWebcamDevices)].Selection].MonikerString; + _Config.Width = d[SelectSlides[htSelectSlides(SelectSlideWebcamDevices)].Selection].Capabilities[SelectSlides[htSelectSlides(SelectSlideWebcamCapabilities)].Selection].Width; + _Config.Height = d[SelectSlides[htSelectSlides(SelectSlideWebcamDevices)].Selection].Capabilities[SelectSlides[htSelectSlides(SelectSlideWebcamCapabilities)].Selection].Height; + _Config.Framerate = d[SelectSlides[htSelectSlides(SelectSlideWebcamDevices)].Selection].Capabilities[SelectSlides[htSelectSlides(SelectSlideWebcamCapabilities)].Selection].Framerate; + + CWebcam.Close(); + CWebcam.Select(_Config); + CWebcam.Start(); + } + } + + private void OnCapabilitiesEvent() + { + if (SelectSlides[htSelectSlides(SelectSlideWebcamCapabilities)].Selection != _CapabilityNr) + { + _CapabilityNr = SelectSlides[htSelectSlides(SelectSlideWebcamCapabilities)].Selection; + + SWebcamDevice[] d = CWebcam.GetDevices(); + _Config.MonikerString = d[SelectSlides[htSelectSlides(SelectSlideWebcamDevices)].Selection].MonikerString; + _Config.Width = d[SelectSlides[htSelectSlides(SelectSlideWebcamDevices)].Selection].Capabilities[SelectSlides[htSelectSlides(SelectSlideWebcamCapabilities)].Selection].Width; + _Config.Height = d[SelectSlides[htSelectSlides(SelectSlideWebcamDevices)].Selection].Capabilities[SelectSlides[htSelectSlides(SelectSlideWebcamCapabilities)].Selection].Height; + _Config.Framerate = d[SelectSlides[htSelectSlides(SelectSlideWebcamDevices)].Selection].Capabilities[SelectSlides[htSelectSlides(SelectSlideWebcamCapabilities)].Selection].Framerate; + + CWebcam.Close(); + CWebcam.Select(_Config); + CWebcam.Start(); + } + } + + private void GetFirstConfiguredWebcamDevice(ref int Device, ref int Capabilities) + { + SWebcamDevice[] devices = CWebcam.GetDevices(); + + if (devices == null) + return; + + for (int i = 0; i < devices.Length; i++) + { + if (devices[i].MonikerString == CConfig.WebcamConfig.MonikerString) + { + for (int j = 0; j < devices[i].Capabilities.Count; j++) + { + if (devices[i].Capabilities[j].Framerate == CConfig.WebcamConfig.Framerate && devices[i].Capabilities[j].Width == CConfig.WebcamConfig.Width && devices[i].Capabilities[j].Height == CConfig.WebcamConfig.Height) + { + Device = i; + Capabilities = j; + return; + } + } + } + } + } } } diff --git a/Vocaluxe/Screens/CScreenProfiles.cs b/Vocaluxe/Screens/CScreenProfiles.cs index 394e165d..ec94f1e5 100644 --- a/Vocaluxe/Screens/CScreenProfiles.cs +++ b/Vocaluxe/Screens/CScreenProfiles.cs @@ -5,6 +5,9 @@ using System.Windows.Forms; using Vocaluxe.Base; using Vocaluxe.Menu; +using System.Drawing; +using System.IO; +using Vocaluxe.Lib.Draw; namespace Vocaluxe.Screens { @@ -17,7 +20,7 @@ namespace Vocaluxe.Screens class CScreenProfiles : CMenu { // Version number for theme files. Increment it, if you've changed something on the theme files! - const int ScreenVersion = 1; + const int ScreenVersion = 2; private const string SelectSlideProfiles = "SelectSlideProfiles"; private const string SelectSlideDifficulty = "SelectSlideDifficulty"; @@ -29,10 +32,17 @@ namespace Vocaluxe.Screens private const string ButtonSave = "ButtonSave"; private const string ButtonNew = "ButtonNew"; private const string ButtonDelete = "ButtonDelete"; + private const string ButtonWebcam = "ButtonWebcam"; + private const string ButtonSaveSnapshot = "ButtonSaveSnapshot"; + private const string ButtonDiscardSnapshot = "ButtonDiscardSnapshot"; + private const string ButtonTakeSnapshot = "ButtonTakeSnapshot"; private const string StaticAvatar = "StaticAvatar"; private EEditMode _EditMode; + + private Lib.Draw.STexture _WebcamTexture = new Lib.Draw.STexture(-1); + private Bitmap _Snapshot = null; public CScreenProfiles() { @@ -45,7 +55,7 @@ namespace Vocaluxe.Screens _ThemeName = "ScreenProfiles"; _ScreenVersion = ScreenVersion; - _ThemeButtons = new string[] { ButtonPlayerName, ButtonExit, ButtonSave, ButtonNew, ButtonDelete }; + _ThemeButtons = new string[] { ButtonPlayerName, ButtonExit, ButtonSave, ButtonNew, ButtonDelete, ButtonWebcam, ButtonSaveSnapshot, ButtonDiscardSnapshot, ButtonTakeSnapshot }; _ThemeSelectSlides = new string[] { SelectSlideProfiles, SelectSlideDifficulty, SelectSlideAvatars, SelectSlideGuestProfile, SelectSlideActive }; _ThemeStatics = new string[] { StaticAvatar }; @@ -56,6 +66,13 @@ namespace Vocaluxe.Screens { base.LoadTheme(); + Buttons[htButtons(ButtonSaveSnapshot)].Visible = false; + Buttons[htButtons(ButtonDiscardSnapshot)].Visible = false; + Buttons[htButtons(ButtonTakeSnapshot)].Visible = false; + if (CWebcam.GetDevices().Length > 0) + Buttons[htButtons(ButtonWebcam)].Visible = true; + else + Buttons[htButtons(ButtonWebcam)].Visible = false; SelectSlides[htSelectSlides(SelectSlideDifficulty)].SetValues(0); SelectSlides[htSelectSlides(SelectSlideGuestProfile)].SetValues(0); SelectSlides[htSelectSlides(SelectSlideActive)].SetValues(0); @@ -108,6 +125,18 @@ namespace Vocaluxe.Screens } else if (Buttons[htButtons(ButtonDelete)].Selected) { DeleteProfile(); + } else if (Buttons[htButtons(ButtonWebcam)].Selected && CWebcam.GetDevices().Length > 0) + { + OnWebcam(); + } else if (Buttons[htButtons(ButtonSaveSnapshot)].Selected && CWebcam.GetDevices().Length > 0) + { + OnSaveSnapshot(); + } else if (Buttons[htButtons(ButtonDiscardSnapshot)].Selected && CWebcam.GetDevices().Length > 0) + { + OnDiscardSnapshot(); + } else if (Buttons[htButtons(ButtonTakeSnapshot)].Selected && CWebcam.GetDevices().Length > 0) + { + OnTakeSnapshot(); } break; @@ -179,6 +208,8 @@ namespace Vocaluxe.Screens { CProfiles.SetAvatar(SelectSlides[htSelectSlides(SelectSlideProfiles)].Selection, SelectSlides[htSelectSlides(SelectSlideAvatars)].Selection); + if (CWebcam.GetDevices().Length > 0 && _WebcamTexture.index > 0) + OnDiscardSnapshot(); } else if (SelectSlides[htSelectSlides(SelectSlideGuestProfile)].Selected) { CProfiles.SetGuestProfile(SelectSlides[htSelectSlides(SelectSlideProfiles)].Selection, @@ -187,6 +218,18 @@ namespace Vocaluxe.Screens { CProfiles.SetActive(SelectSlides[htSelectSlides(SelectSlideProfiles)].Selection, (EOffOn)SelectSlides[htSelectSlides(SelectSlideActive)].Selection); + } else if (Buttons[htButtons(ButtonWebcam)].Selected && CWebcam.GetDevices().Length > 0) + { + OnWebcam(); + } else if (Buttons[htButtons(ButtonSaveSnapshot)].Selected && CWebcam.GetDevices().Length > 0) + { + OnSaveSnapshot(); + } else if (Buttons[htButtons(ButtonDiscardSnapshot)].Selected && CWebcam.GetDevices().Length > 0) + { + OnDiscardSnapshot(); + } else if (Buttons[htButtons(ButtonTakeSnapshot)].Selected && CWebcam.GetDevices().Length > 0) + { + OnTakeSnapshot(); } } @@ -197,6 +240,68 @@ namespace Vocaluxe.Screens return true; } + private void OnTakeSnapshot() + { + Buttons[htButtons(ButtonSaveSnapshot)].Visible = true; + Buttons[htButtons(ButtonDiscardSnapshot)].Visible = true; + Buttons[htButtons(ButtonWebcam)].Visible = false; + Buttons[htButtons(ButtonTakeSnapshot)].Visible = false; + _Snapshot = CWebcam.GetBitmap(); + } + + private void OnDiscardSnapshot() + { + CWebcam.Stop(); + CDraw.RemoveTexture(ref _WebcamTexture); + _Snapshot = null; + Buttons[htButtons(ButtonSaveSnapshot)].Visible = false; + Buttons[htButtons(ButtonDiscardSnapshot)].Visible = false; + Buttons[htButtons(ButtonTakeSnapshot)].Visible = false; + Buttons[htButtons(ButtonWebcam)].Visible = true; + } + + private void OnSaveSnapshot() + { + string filename = "snapshot"; + int i = 0; + while (File.Exists(Path.Combine(CSettings.sFolderProfiles, filename + i + ".png"))) + { + i++; + } + _Snapshot.Save(Path.Combine(CSettings.sFolderProfiles, filename + i + ".png"), System.Drawing.Imaging.ImageFormat.Png); + CProfiles.LoadAvatars(); + LoadAvatars(); + _Snapshot = null; + CWebcam.Stop(); + CDraw.RemoveTexture(ref _WebcamTexture); + + for (int j = 0; j < CProfiles.Avatars.Length; j++) + { + if (CProfiles.Avatars[j].FileName == (filename + i + ".png")) + { + CProfiles.SetAvatar(SelectSlides[htSelectSlides(SelectSlideProfiles)].Selection, j); + break; + } + + } + + Buttons[htButtons(ButtonSaveSnapshot)].Visible = false; + Buttons[htButtons(ButtonDiscardSnapshot)].Visible = false; + Buttons[htButtons(ButtonTakeSnapshot)].Visible = false; + Buttons[htButtons(ButtonWebcam)].Visible = true; + } + + private void OnWebcam() + { + _Snapshot = null; + CWebcam.Start(); + CWebcam.GetFrame(ref _WebcamTexture); + Buttons[htButtons(ButtonSaveSnapshot)].Visible = false; + Buttons[htButtons(ButtonDiscardSnapshot)].Visible = false; + Buttons[htButtons(ButtonTakeSnapshot)].Visible = true; + Buttons[htButtons(ButtonWebcam)].Visible = false; + } + public override bool UpdateGame() { if (SelectSlides[htSelectSlides(SelectSlideProfiles)].Selection > -1) @@ -211,7 +316,18 @@ namespace Vocaluxe.Screens int avatarNr = CProfiles.GetAvatarNr(SelectSlides[htSelectSlides(SelectSlideProfiles)].Selection); SelectSlides[htSelectSlides(SelectSlideAvatars)].Selection = avatarNr; - Statics[htStatics(StaticAvatar)].Texture = CProfiles.Avatars[avatarNr].Texture; + if (CWebcam.GetDevices().Length > 0 && _WebcamTexture.index > 0) + { + if(_Snapshot == null) + CWebcam.GetFrame(ref _WebcamTexture); + Statics[htStatics(StaticAvatar)].Texture = _WebcamTexture; + + RectangleF bounds = new RectangleF(_WebcamTexture.rect.X, _WebcamTexture.rect.Y, _WebcamTexture.rect.W, _WebcamTexture.rect.H); + RectangleF rect = new RectangleF(0f, 0f, _WebcamTexture.rect.W, _WebcamTexture.rect.H); + CHelper.SetRect(bounds, ref rect, rect.Width / rect.Height, EAspect.Crop); + } + else + Statics[htStatics(StaticAvatar)].Texture = CProfiles.Avatars[avatarNr].Texture; } return true; @@ -227,6 +343,13 @@ namespace Vocaluxe.Screens UpdateGame(); } + public override void OnClose() + { + base.OnClose(); + + OnDiscardSnapshot(); + } + public override bool Draw() { return base.Draw(); diff --git a/Vocaluxe/Screens/CScreenSing.cs b/Vocaluxe/Screens/CScreenSing.cs index c75081c3..11c57146 100644 --- a/Vocaluxe/Screens/CScreenSing.cs +++ b/Vocaluxe/Screens/CScreenSing.cs @@ -17,7 +17,7 @@ namespace Vocaluxe.Screens class CScreenSing : CMenu { // Version number for theme files. Increment it, if you've changed something on the theme files! - const int ScreenVersion = 5; + const int ScreenVersion = 6; struct TimeRect { @@ -75,6 +75,7 @@ namespace Vocaluxe.Screens private int _CurrentVideo = -1; private EAspect _VideoAspect = EAspect.Crop; private STexture _CurrentVideoTexture = new STexture(-1); + private STexture _CurrentWebcamFrameTexture = new STexture(-1); private STexture _Background = new STexture(-1); private float _CurrentTime = 0f; @@ -92,6 +93,7 @@ namespace Vocaluxe.Screens private Stopwatch _TimerDuetText2; private bool _Pause; + private bool _Webcam; public CScreenSing() { @@ -149,6 +151,7 @@ namespace Vocaluxe.Screens public override void LoadTheme() { base.LoadTheme(); + Statics[htStatics(StaticTimeLine)].Visible = false; Statics[htStatics(StaticTimeLineExpandedNormal)].Visible = false; Statics[htStatics(StaticTimeLineExpandedHighlighted)].Visible = false; @@ -184,13 +187,13 @@ namespace Vocaluxe.Screens TogglePause(); if (_Pause) SetInteractionToButton(Buttons[htButtons(ButtonContinue)]); - break; - + break; + case Keys.T: int mode = (int)CConfig.TimerMode; - + mode++; - if (mode > Enum.GetNames(typeof(ETimerMode)).Length-1) + if (mode > Enum.GetNames(typeof(ETimerMode)).Length - 1) { mode = 0; } @@ -215,7 +218,16 @@ namespace Vocaluxe.Screens if(KeyEvent.ModCTRL) LoadNextSong(); break; - + case Keys.W: + if (CWebcam.GetDevices().Length > 0) + { + _Webcam = !_Webcam; + if (_Webcam) + CWebcam.Start(); + else + CWebcam.Stop(); + } + break; case Keys.Enter: if (Buttons[htButtons(ButtonContinue)].Selected && _Pause) TogglePause(); @@ -227,6 +239,30 @@ namespace Vocaluxe.Screens TogglePause(); } break; + + case Keys.Add: + case Keys.PageUp: + if (KeyEvent.ModSHIFT) + { + CConfig.GameMusicVolume = CConfig.GameMusicVolume + 5; + if (CConfig.GameMusicVolume > 100) + CConfig.GameMusicVolume = 100; + CConfig.SaveConfig(); + ApplyVolume(); + } + break; + + case Keys.Subtract: + case Keys.PageDown: + if (KeyEvent.ModSHIFT) + { + CConfig.GameMusicVolume = CConfig.GameMusicVolume - 5; + if (CConfig.GameMusicVolume < 0) + CConfig.GameMusicVolume = 0; + CConfig.SaveConfig(); + ApplyVolume(); + } + break; } } @@ -275,7 +311,7 @@ namespace Vocaluxe.Screens } else Finish = true; - + if (Finish) { LoadNextSong(); @@ -283,7 +319,6 @@ namespace Vocaluxe.Screens UpdateSongText(); UpdateDuetText(); - if (_FadeOut) return true; @@ -322,7 +357,7 @@ namespace Vocaluxe.Screens Texts[htTexts(TextNames[p, CGame.NumPlayer - 1])].Alpha = Alpha[CGame.Player[p].LineNr * 2]; Texts[htTexts(TextScores[p, CGame.NumPlayer - 1])].Alpha = Alpha[CGame.Player[p].LineNr * 2]; } - } + } if (Alpha.Length > 2) { @@ -339,7 +374,7 @@ namespace Vocaluxe.Screens Statics[htStatics(StaticLyricHelper)].Alpha = Alpha[2]; } } - + for (int p = 0; p < CGame.NumPlayer; p++) { @@ -358,18 +393,22 @@ namespace Vocaluxe.Screens float vtime = 0f; CVideo.VdGetFrame(_CurrentVideo, ref _CurrentVideoTexture, _CurrentTime, ref vtime); } - + + if (_Webcam) + CWebcam.GetFrame(ref _CurrentWebcamFrameTexture); + return true; } public override void OnShow() { base.OnShow(); - + _FadeOut = false; - + _CurrentVideo = -1; _CurrentVideoTexture = new STexture(-1); + _CurrentWebcamFrameTexture = new STexture(-1); _CurrentBeat = -100; _CurrentTime = 0f; _FinishTime = 0f; @@ -379,7 +418,7 @@ namespace Vocaluxe.Screens _TimeRects.Clear(); - SingNotes[htSingNotes(SingBars)].Reset(); + SingNotes[htSingNotes(SingBars)].Reset(); for (int i = 0; i < CSettings.MaxNumPlayer; i++) { NoteLines[i] = -1; @@ -389,6 +428,11 @@ namespace Vocaluxe.Screens { Lyrics[i].LyricStyle = CConfig.LyricStyle; } + + for (int p = 0; p < CGame.NumPlayer; p++) + { + Statics[htStatics(StaticAvatars[p, CGame.NumPlayer - 1])].Aspect = EAspect.Crop; + } SetVisuability(); UpdateAvatars(); @@ -411,7 +455,7 @@ namespace Vocaluxe.Screens { if (_Active) { - if (_CurrentVideo != -1 && CConfig.VideosInSongs == EOffOn.TR_CONFIG_ON) + if (_CurrentVideo != -1 && CConfig.VideosInSongs == EOffOn.TR_CONFIG_ON && !_Webcam) { RectangleF bounds = new RectangleF(0, 0, CSettings.iRenderW, CSettings.iRenderH); RectangleF rect = new RectangleF(0f, 0f, _CurrentVideoTexture.width, _CurrentVideoTexture.height); @@ -420,6 +464,15 @@ namespace Vocaluxe.Screens CDraw.DrawTexture(_CurrentVideoTexture, new SRectF(rect.X, rect.Y, rect.Width, rect.Height, 0f), _CurrentVideoTexture.color, new SRectF(bounds.X, bounds.Y, bounds.Width, bounds.Height, 0f), false); } + else if (_Webcam) + { + RectangleF bounds = new RectangleF(0, 0, CSettings.iRenderW, CSettings.iRenderH); + RectangleF rect = new RectangleF(0f, 0f, _CurrentWebcamFrameTexture.width, _CurrentWebcamFrameTexture.height); + CHelper.SetRect(bounds, ref rect, rect.Width / rect.Height, _VideoAspect); + + CDraw.DrawTexture(_CurrentWebcamFrameTexture, new SRectF(rect.X, rect.Y, rect.Width, rect.Height, 0f), + _CurrentVideoTexture.color, new SRectF(bounds.X, bounds.Y, bounds.Width, bounds.Height, 0f), false); + } else { // Draw Background RectangleF bounds = new RectangleF(0, 0, CSettings.iRenderW, CSettings.iRenderH); @@ -460,7 +513,7 @@ namespace Vocaluxe.Screens Lyrics[htLyrics(LyricSubTop)].Draw(-100); Lyrics[htLyrics(LyricMainTop)].Draw(CGame.Beat); - + for (int i = 0; i < CGame.NumPlayer; i++) { @@ -480,7 +533,7 @@ namespace Vocaluxe.Screens foreach (CSelectSlide slide in SelectSlides) slide.Draw(); } - + return true; } @@ -491,6 +544,11 @@ namespace Vocaluxe.Screens CloseSong(); } + public override void ApplyVolume() + { + CSound.SetStreamVolumeMax(_CurrentStream, CConfig.GameMusicVolume); + } + private void CloseSong() { CSound.FadeAndStop(_CurrentStream, 0f, 0.5f); @@ -545,6 +603,7 @@ namespace Vocaluxe.Screens Texts[htTexts(TextSongName)].Text = songname; _CurrentStream = CSound.Load(song.GetMP3(), true); + CSound.SetStreamVolumeMax(_CurrentStream, CConfig.GameMusicVolume); CSound.SetStreamVolume(_CurrentStream, _Volume); CSound.SetPosition(_CurrentStream, song.Start); _CurrentTime = song.Start; @@ -563,7 +622,7 @@ namespace Vocaluxe.Screens CGame.ResetPlayer(); CDraw.RemoveTexture(ref _CurrentVideoTexture); - + if (song.VideoFileName != String.Empty) { _CurrentVideo = CVideo.VdLoad(Path.Combine(song.Folder, song.VideoFileName)); @@ -624,7 +683,7 @@ namespace Vocaluxe.Screens CTheme.GetPlayerColor(p + 1), p); } - + /* case 4: NoteLines[0] = SingNotes[htSingNotes(SingBars)].AddPlayer(new SRectF(35f, 100f, 590f, 200f, -0.5f), CTheme.ThemeColors.Player[0]); @@ -633,7 +692,7 @@ namespace Vocaluxe.Screens NoteLines[3] = SingNotes[htSingNotes(SingBars)].AddPlayer(new SRectF(640f, 350f, 590f, 200f, -0.5f), CTheme.ThemeColors.Player[3]); break; */ - + _TimerSongText.Stop(); _TimerSongText.Reset(); @@ -655,6 +714,8 @@ namespace Vocaluxe.Screens PrepareTimeLine(); CSound.Play(_CurrentStream); CSound.RecordStart(); + if(_Webcam) + CWebcam.Start(); } private void Stop() @@ -665,6 +726,8 @@ namespace Vocaluxe.Screens CGraphics.FadeTo(EScreens.ScreenScore); _FadeOut = true; + if (_Webcam) + CWebcam.Close(); } private void UpdateLyrics() @@ -778,6 +841,7 @@ namespace Vocaluxe.Screens Buttons[htButtons(ButtonContinue)].Visible = false; Buttons[htButtons(ButtonSkip)].Visible = false; CSound.Play(_CurrentStream); + CWebcam.Start(); } } @@ -807,7 +871,7 @@ namespace Vocaluxe.Screens { StaticScores = new string[CSettings.MaxNumPlayer, CSettings.MaxNumPlayer]; StaticAvatars = new string[CSettings.MaxNumPlayer, CSettings.MaxNumPlayer]; - + for (int numplayer = 0; numplayer < CSettings.MaxNumPlayer; numplayer++) { for (int player = 0; player < CSettings.MaxNumPlayer; player++) @@ -833,7 +897,7 @@ namespace Vocaluxe.Screens Statics[htStatics(StaticLyricHelperTop)].Visible = false; Lyrics[htLyrics(LyricMainDuet)].Visible = false; Lyrics[htLyrics(LyricSubDuet)].Visible = false; - + Statics[htStatics(StaticSongText)].Visible = false; Texts[htTexts(TextSongName)].Visible = false; Texts[htTexts(TextDuetName1)].Visible = false; @@ -849,7 +913,7 @@ namespace Vocaluxe.Screens Texts[htTexts(TextNames[player, numplayer])].Visible = ((numplayer + 1 == CGame.NumPlayer) && (CConfig.PlayerInfo == EPlayerInfo.TR_CONFIG_PLAYERINFO_BOTH || CConfig.PlayerInfo == EPlayerInfo.TR_CONFIG_PLAYERINFO_NAME)); Statics[htStatics(StaticScores[player, numplayer])].Visible = (numplayer + 1 == CGame.NumPlayer); - Statics[htStatics(StaticAvatars[player, numplayer])].Visible = ((numplayer + 1 == CGame.NumPlayer) + Statics[htStatics(StaticAvatars[player, numplayer])].Visible = ((numplayer + 1 == CGame.NumPlayer) && (CConfig.PlayerInfo == EPlayerInfo.TR_CONFIG_PLAYERINFO_BOTH || CConfig.PlayerInfo == EPlayerInfo.TR_CONFIG_PLAYERINFO_AVATAR)); } } @@ -941,7 +1005,7 @@ namespace Vocaluxe.Screens time = totaltime; SRectF Rect = Statics[htStatics(StaticLyricHelperDuet)].Rect; - + SColorF Color = new SColorF( Statics[htStatics(StaticLyricHelperDuet)].Color.R, Statics[htStatics(StaticLyricHelperDuet)].Color.G, @@ -1001,7 +1065,7 @@ namespace Vocaluxe.Screens // default values Alpha[i * 2] = 1f; - Alpha[i * 2 + 1] = 1f; + Alpha[i * 2 + 1] = 1f; // main line alpha if (CurrentLine == 0 && CurrentTime < CGame.GetTimeFromBeats(line[CurrentLine].FirstNoteBeat, Song.BPM)) @@ -1033,15 +1097,15 @@ namespace Vocaluxe.Screens float next = CGame.GetTimeFromBeats(line[CurrentLine + 1].FirstNoteBeat, Song.BPM) - CurrentTime; if (last < next) - { + { // fade out Alpha[i * 2] = 1f - last / rt; - } + } else - { + { // fade in if it is time for - if (next > dt) - Alpha[i * 2] = 1f - (next - dt) / rt; + if (next > dt) + Alpha[i * 2] = 1f - (next - dt) / rt; } } } @@ -1056,9 +1120,9 @@ namespace Vocaluxe.Screens // sub if (CurrentLineSub < line.Length - 2) { - float diff = 0f; + float diff = 0f; diff = CGame.GetTimeFromBeats(line[CurrentLineSub + 1].FirstNoteBeat, Song.BPM) - CurrentTime; - + if (diff > dt) { Alpha[i * 2 + 1] = 1f - (diff - dt) / rt; @@ -1199,7 +1263,7 @@ namespace Vocaluxe.Screens float CurrentTime = _CurrentTime - song.Start; if (TotalTime <= 0f) - return; + return; switch (CConfig.TimerMode) { @@ -1282,15 +1346,15 @@ namespace Vocaluxe.Screens CLines[] Lines = new CLines[song.Notes.Lines.Length]; Lines = song.Notes.Lines; for (int i = 0; i < Lines.Length; i++) - { + { CLine[] Line = Lines[i].Line; - for(int j = 0; j 100) + CConfig.PreviewMusicVolume = 100; + CConfig.SaveConfig(); + ApplyVolume(); + } + else if (KeyEvent.ModSHIFT && (KeyEvent.Key == Keys.Subtract || KeyEvent.Key == Keys.PageDown)) + { + CConfig.PreviewMusicVolume = CConfig.PreviewMusicVolume - 5; + if (CConfig.PreviewMusicVolume < 0) + CConfig.PreviewMusicVolume = 0; + CConfig.SaveConfig(); + ApplyVolume(); + } + return true; } @@ -344,7 +367,11 @@ namespace Vocaluxe.Screens if (Playlists[htPlaylists(Playlist)].Visible && _PlaylistActive) { if (Playlists[htPlaylists(Playlist)].HandleMouse(MouseEvent)) + { + if (CPlaylists.NumPlaylists != SelectSlides[htSelectSlides(SelectSlideOptionsPlaylistOpen)].NumValues) + UpdatePlaylistNames(); return true; + } } @@ -416,6 +443,7 @@ namespace Vocaluxe.Screens if (Buttons[htButtons(ButtonOptionsPlaylist)].Selected) { + ToggleSongOptions(ESongOptionsView.None); OpenAndAddPlaylistAction(); return true; } @@ -454,6 +482,7 @@ namespace Vocaluxe.Screens if (Buttons[htButtons(ButtonOptionsOpenPlaylist)].Selected) { + ToggleSongOptions(ESongOptionsView.None); OpenPlaylistAction(); return true; } @@ -575,6 +604,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)) @@ -874,15 +908,13 @@ namespace Vocaluxe.Screens //Open playlist OpenPlaylist(Playlists[htPlaylists(Playlist)].ActivePlaylistID); - Playlists[htPlaylists(Playlist)].ScrollToBottom(); } - ToggleSongOptions(ESongOptionsView.None); } private void OpenAndAddPlaylistAction() { - //Open a playlist and add song - if (Playlists[htPlaylists(Playlist)].ActivePlaylistID != (SelectSlides[htSelectSlides(SelectSlideOptionsPlaylistAdd)].Selection - 1)) + //Open an existing playlist and add song + if (Playlists[htPlaylists(Playlist)].ActivePlaylistID != (SelectSlides[htSelectSlides(SelectSlideOptionsPlaylistAdd)].Selection - 1) && (SelectSlides[htSelectSlides(SelectSlideOptionsPlaylistAdd)].Selection - 1) != -1) { //Check selected game-mode EGameMode gm; @@ -895,18 +927,19 @@ namespace Vocaluxe.Screens gm = GameModes.EGameMode.TR_GAMEMODE_NORMAL; //Check if Playlist really exists - if (SelectSlides[htSelectSlides(SelectSlideOptionsPlaylistAdd)].Selection - 1 < 0) - Playlists[htPlaylists(Playlist)].ActivePlaylistID = CPlaylists.NewPlaylist(); - else + if (SelectSlides[htSelectSlides(SelectSlideOptionsPlaylistAdd)].Selection - 1 >= 0) + { Playlists[htPlaylists(Playlist)].ActivePlaylistID = SelectSlides[htSelectSlides(SelectSlideOptionsPlaylistAdd)].Selection - 1; - - //Add song to playlist - CPlaylists.Playlists[Playlists[htPlaylists(Playlist)].ActivePlaylistID].AddSong(CSongs.VisibleSongs[SongMenus[htSongMenus(SongMenu)].GetSelectedSong()].ID, gm); - - //Open playlist - OpenPlaylist(Playlists[htPlaylists(Playlist)].ActivePlaylistID); - SetSelectSlidePlaylistToCurrentPlaylist(); + //Add song to playlist + CPlaylists.Playlists[Playlists[htPlaylists(Playlist)].ActivePlaylistID].AddSong(CSongs.VisibleSongs[SongMenus[htSongMenus(SongMenu)].GetSelectedSong()].ID, gm); + + //Open playlist + OpenPlaylist(Playlists[htPlaylists(Playlist)].ActivePlaylistID); + + SetSelectSlidePlaylistToCurrentPlaylist(); + Playlists[htPlaylists(Playlist)].ScrollToBottom(); + } } //Create a new playlist and add song else if ((SelectSlides[htSelectSlides(SelectSlideOptionsPlaylistAdd)].Selection - 1) == -1) @@ -932,6 +965,7 @@ namespace Vocaluxe.Screens //Add new playlist to select-slide SelectSlides[htSelectSlides(SelectSlideOptionsPlaylistAdd)].AddValue(CPlaylists.Playlists[Playlists[htPlaylists(Playlist)].ActivePlaylistID].PlaylistName); + SelectSlides[htSelectSlides(SelectSlideOptionsPlaylistOpen)].AddValue(CPlaylists.Playlists[Playlists[htPlaylists(Playlist)].ActivePlaylistID].PlaylistName); SetSelectSlidePlaylistToCurrentPlaylist(); @@ -952,12 +986,14 @@ namespace Vocaluxe.Screens Playlists[htPlaylists(Playlist)].UpdatePlaylist(); Playlists[htPlaylists(Playlist)].ScrollToBottom(); } - ToggleSongOptions(ESongOptionsView.Song); } private void SetSelectSlidePlaylistToCurrentPlaylist() { - SelectSlides[htSelectSlides(SelectSlideOptionsPlaylistAdd)].Selection = Playlists[htPlaylists(Playlist)].ActivePlaylistID + 1; + if (Playlists[htPlaylists(Playlist)].ActivePlaylistID > -1) + SelectSlides[htSelectSlides(SelectSlideOptionsPlaylistAdd)].Selection = Playlists[htPlaylists(Playlist)].ActivePlaylistID + 1; + else + SelectSlides[htSelectSlides(SelectSlideOptionsPlaylistAdd)].Selection = 0; } } } diff --git a/Vocaluxe/Vocaluxe.csproj b/Vocaluxe/Vocaluxe.csproj index 6110d5a7..35339243 100644 --- a/Vocaluxe/Vocaluxe.csproj +++ b/Vocaluxe/Vocaluxe.csproj @@ -29,6 +29,7 @@ true Vocaluxe.MainProgram Vocaluxe.ico + x86 @@ -140,6 +141,16 @@ + + False + ..\Output\AForge.Video.dll + False + + + False + ..\Output\AForge.Video.DirectShow.dll + False + ..\Output\Community.CsharpSqlite.dll @@ -176,6 +187,7 @@ + @@ -211,6 +223,8 @@ + + @@ -239,6 +253,7 @@ Form + diff --git a/output/Themes/Changelog/Changelog_ScreenProfiles.txt b/output/Themes/Changelog/Changelog_ScreenProfiles.txt new file mode 100644 index 00000000..65dae6e8 --- /dev/null +++ b/output/Themes/Changelog/Changelog_ScreenProfiles.txt @@ -0,0 +1,7 @@ +ScreenProfiles + +++++++++++ +Version 2: + +Add: , , , +++++++++++ \ No newline at end of file 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 + + +