Beispiel #1
0
        public static void Update()
        {
            if (_AllFileNames.Count > 0 && _CurrentMusicStream != -1)
            {
                float timeToPlay;
                if (_CurrentPlaylistElement.Finish == 0f) //No End-Tag defined
                {
                    timeToPlay = CSound.GetLength(_CurrentMusicStream) - CSound.GetPosition(_CurrentMusicStream);
                }
                else //End-Tag found
                {
                    timeToPlay = _CurrentPlaylistElement.Finish - CSound.GetPosition(_CurrentMusicStream);
                }

                bool finished = CSound.IsFinished(_CurrentMusicStream);
                if (_Playing && (timeToPlay <= CSettings.BackgroundMusicFadeTime || finished))
                {
                    if (_RepeatSong)
                    {
                        CSound.SetPosition(_CurrentMusicStream, 0);
                        if (_VideoEnabled && _Video != -1)
                        {
                            CVideo.VdSkip(_Video, 0f, _CurrentPlaylistElement.VideoGap);
                        }
                    }
                    else
                    {
                        Next();
                    }
                }
            }
        }
Beispiel #2
0
        public static STexture GetSkinVideoTexture(string VideoName)
        {
            int SkinIndex = GetSkinIndex();

            if (SkinIndex != -1)
            {
                for (int i = 0; i < _Skins[SkinIndex].VideoList.Count; i++)
                {
                    SkinElement sk = _Skins[SkinIndex].VideoList[i];
                    if (sk.Name == VideoName)
                    {
                        float Time = 0f;
                        if (sk.VideoIndex == -1)
                        {
                            sk.VideoIndex = CVideo.VdLoad(GetVideoFilePath(sk.Name));
                            CVideo.VdSetLoop(sk.VideoIndex, true);
                        }
                        CVideo.VdGetFrame(sk.VideoIndex, ref sk.Texture, Time, ref Time);
                        _Skins[SkinIndex].VideoList[i] = sk;
                        return(sk.Texture);
                    }
                }
            }
            return(new STexture(-1));
        }
Beispiel #3
0
        public static bool UpdateGameLogic(CKeys keys, CMouse mouse)
        {
            bool run = true;

            _Cursor.Visible = mouse.Visible;

            mouse.CopyEvents();
            keys.CopyEvents();

            CVideo.Update();
            CSound.Update();
            CBackgroundMusic.Update();
            CController.Update();
            CProfiles.Update();

            if (CSettings.ProgramState != EProgramState.EditTheme)
            {
                run &= _HandleInputs(keys, mouse);
                run &= _Update();
                CParty.UpdateGame();
            }
            else
            {
                run &= _HandleInputThemeEditor(keys, mouse);
                run &= _Update();
            }

            return(run);
        }
Beispiel #4
0
 public void Close()
 {
     CVideo.Close(ref _VideoStream);
     _Loaded   = false;
     _Finished = false;
     _VideoTimer.Reset();
 }
Beispiel #5
0
 public static void ToggleVideo()
 {
     if (_Video != -1)
     {
         if (_VideoEnabled)
         {
             _VideoEnabled = false;
             CVideo.VdClose(_Video);
             _Video = -1;
             CDraw.RemoveTexture(ref _CurrentVideoTexture);
             return;
         }
         if (CVideo.VdFinished(_Video))
         {
             CVideo.VdClose(_Video);
             CDraw.RemoveTexture(ref _CurrentVideoTexture);
             _Video = -1;
             return;
         }
     }
     else
     {
         LoadVideo();
     }
 }
Beispiel #6
0
        public static void ResetToTime(float time, float nextStart, int soundStream, CVideoStream vidStream)
        {
            if (time < 0)
            {
                time = 0;
            }

            CurrentBeatF = GetBeatFromTime(time, GetSong().BPM, GetSong().Gap);

            for (int p = 0; p < _NumPlayers; p++)
            {
                Players[p].Points            = 0;
                Players[p].PointsGoldenNotes = 0;
                Players[p].PointsLineBonus   = 0;
                int l          = 0;
                int deleteLine = 0;
                foreach (CSungLine line in Players[p].SungLines)
                {
                    int n          = -1;
                    int deleteNote = 0;
                    Players[p].PointsLineBonus += line.BonusPoints;
                    foreach (CSungNote note in line.Notes)
                    {
                        if (note.StartBeat < nextStart)
                        {
                            if (note.Hit && note.HitNote.Type == ENoteType.Golden)
                            {
                                Players[p].PointsGoldenNotes += note.Points;
                            }
                            Players[p].Points += note.Points;
                        }
                        else if (deleteNote != -1)
                        {
                            deleteNote = n;
                        }
                        n++;
                    }
                    while (line.NoteCount > n && n >= 0)
                    {
                        if (line.Notes[n].Hit && line.Notes[n].HitNote.Type == ENoteType.Golden)
                        {
                            Players[p].PointsGoldenNotes -= line.Notes[n].Points;
                        }
                        Players[p].Points -= line.Notes[n].Points;
                        line.DeleteNote(n);
                    }

                    if (line.LastNoteBeat > CurrentBeat && deleteLine == 0)
                    {
                        deleteLine = l;
                    }
                    l++;
                }
                Players[p].SungLines.RemoveRange(deleteLine, Players[p].SungLines.Count - deleteLine);
            }

            CSound.SetPosition(soundStream, time);
            CVideo.Skip(vidStream, time, GetSong().VideoGap);
        }
Beispiel #7
0
 public void Pause()
 {
     if (_VideoStream != null)
     {
         CVideo.Pause(_VideoStream);
     }
     _VideoTimer.Stop();
 }
Beispiel #8
0
 public void Start()
 {
     _VideoTimer.Reset();
     _Finished = false;
     //CVideo.VdSkip(_VideoStream, 0f, 0f);
     _VideoTimer.Start();
     CVideo.Resume(_VideoStream);
 }
Beispiel #9
0
 public void Close()
 {
     CVideo.VdClose(_VideoStream);
     CDraw.RemoveTexture(ref _VideoTexture);
     _Loaded   = false;
     _Finished = false;
     _VideoTimer.Reset();
 }
Beispiel #10
0
 public void Resume()
 {
     if (_VideoStream == null)
     {
         return;
     }
     CVideo.Resume(_VideoStream);
     _VideoTimer.Start();
 }
Beispiel #11
0
 public void Load(string videoName)
 {
     _VideoStream = CThemes.GetSkinVideo(videoName, -1, false);
     if (_VideoStream == null)
     {
         return;
     }
     _Loaded = true;
     CVideo.Pause(_VideoStream);
 }
Beispiel #12
0
        public void PreLoad()
        {
            float VideoTime = 0f;

            while (_VideoTexture.index == -1 && VideoTime < 1f)
            {
                float dummy = 0f;
                CVideo.VdGetFrame(_VideoStream, ref _VideoTexture, 0, ref dummy);
                VideoTime += 0.05f;
            }
        }
Beispiel #13
0
 private static void LoadVideo()
 {
     if (_Video == -1)
     {
         _Video = CVideo.VdLoad(_CurrentPlaylistElement.VideoFilePath);
         CVideo.VdSkip(_Video, 0f, _CurrentPlaylistElement.VideoGap);
         _VideoEnabled = true;
         _FadeTimer.Reset();
         _FadeTimer.Start();
     }
 }
Beispiel #14
0
 public void Resume(CVideoStream stream)
 {
     try
     {
         CVideo.Resume(stream);
     }
     catch (NotSupportedException e)
     {
         CLog.Error($"Clould not resume the background video: {e.Message}");
     }
 }
Beispiel #15
0
 public void Close(ref CVideoStream stream)
 {
     try
     {
         CVideo.Close(ref stream);
     }
     catch (NotSupportedException e)
     {
         CLog.Error($"Clould not close the background video: {e.Message}");
     }
 }
Beispiel #16
0
 public void Pause(CVideoStream stream)
 {
     try
     {
         CVideo.Pause(stream);
     }
     catch (NotSupportedException e)
     {
         CLog.LogError($"Clould not pause the background video: {e.Message}");
     }
 }
Beispiel #17
0
 public void Start()
 {
     _VideoTimer.Reset();
     _Finished = false;
     if (_VideoStream == null)
     {
         return;
     }
     //CVideo.VdSkip(_VideoStream, 0f, 0f);
     _VideoTimer.Start();
     CVideo.Resume(_VideoStream);
 }
Beispiel #18
0
        private static void _DrawDebugInfos()
        {
            if (CConfig.Config.Debug.DebugLevel == EDebugLevel.TR_CONFIG_OFF)
            {
                return;
            }

            List <String> debugOutput = new List <string> {
                CTime.GetFPS().ToString("FPS: 000")
            };

            if (CConfig.Config.Debug.DebugLevel >= EDebugLevel.TR_CONFIG_LEVEL1)
            {
                debugOutput.Add(CSound.GetStreamCount().ToString(CLanguage.Translate("TR_DEBUG_AUDIO_STREAMS") + ": 00"));
                debugOutput.Add(CVideo.GetNumStreams().ToString(CLanguage.Translate("TR_DEBUG_VIDEO_STREAMS") + ": 00"));
                debugOutput.Add(CDraw.TextureCount().ToString(CLanguage.Translate("TR_DEBUG_TEXTURES") + ": 00000"));
                long memory = GC.GetTotalMemory(false);
                debugOutput.Add((memory / 1000000L).ToString(CLanguage.Translate("TR_DEBUG_MEMORY") + ": 00000 MB"));

                if (CConfig.Config.Debug.DebugLevel >= EDebugLevel.TR_CONFIG_LEVEL2)
                {
                    debugOutput.Add(CRecord.GetToneAbs(0).ToString(CLanguage.Translate("TR_DEBUG_TONE_ABS") + " P1: 00"));
                    debugOutput.Add(CRecord.GetMaxVolume(0).ToString(CLanguage.Translate("TR_DEBUG_MAX_VOLUME") + " P1: 0.000"));
                    debugOutput.Add(CRecord.GetToneAbs(1).ToString(CLanguage.Translate("TR_DEBUG_TONE_ABS") + " P2: 00"));
                    debugOutput.Add(CRecord.GetMaxVolume(1).ToString(CLanguage.Translate("TR_DEBUG_MAX_VOLUME") + " P2: 0.000"));

                    if (CConfig.Config.Debug.DebugLevel >= EDebugLevel.TR_CONFIG_LEVEL3)
                    {
                        debugOutput.Add(CSongs.NumSongsWithCoverLoaded.ToString(CLanguage.Translate("TR_DEBUG_SONGS") + ": 00000"));

                        if (CConfig.Config.Debug.DebugLevel >= EDebugLevel.TR_CONFIG_LEVEL_MAX)
                        {
                            debugOutput.Add(_Cursor.X.ToString(CLanguage.Translate("TR_DEBUG_MOUSE") + " : (0000/") + _Cursor.Y.ToString("0000)"));
                        }
                    }
                }
            }
            CFont   font = new CFont("Normal", EStyle.Normal, 25);
            SColorF gray = new SColorF(1f, 1f, 1f, 0.5f);
            float   y    = 0;

            foreach (string txt in debugOutput)
            {
                float      textWidth = CFonts.GetTextWidth(txt, font);
                RectangleF rect      = new RectangleF(CSettings.RenderW - textWidth, y, textWidth, CFonts.GetTextHeight(txt, font));
                CDraw.DrawRect(gray, new SRectF(rect.X, rect.Top, rect.Width, rect.Height, CSettings.ZNear));
                CFonts.DrawText(txt, font, rect.X, rect.Y, CSettings.ZNear);
                y += rect.Height;
            }
        }
Beispiel #19
0
        public static void Pause()
        {
            if (!_Playing)
            {
                return;
            }

            if (_VideoEnabled && _Video != -1)
            {
                CVideo.VdPause(_Video);
                CVideo.VdSkip(_Video, CSound.GetPosition(_CurrentMusicStream) + CSettings.BackgroundMusicFadeTime, _CurrentPlaylistElement.VideoGap);
            }
            CSound.FadeAndPause(_CurrentMusicStream, 0f, CSettings.BackgroundMusicFadeTime);
            _Playing = false;
        }
Beispiel #20
0
        public static void Stop()
        {
            if (!_Playing)
            {
                return;
            }

            if (_VideoEnabled && _Video != -1)
            {
                CVideo.VdClose(_Video);
                CDraw.RemoveTexture(ref _CurrentVideoTexture);
                _Video = -1;
            }
            CSound.FadeAndStop(_CurrentMusicStream, 0f, CSettings.BackgroundMusicFadeTime);

            _CurrentPlaylistElement = new PlaylistElement();
            _Playing = false;
        }
Beispiel #21
0
        public static void UnloadSkins()
        {
            for (int i = 0; i < _Skins.Count; i++)
            {
                foreach (SkinElement sk in _Skins[i].SkinList.Values)
                {
                    STexture Texture = sk.Texture;
                    CDraw.RemoveTexture(ref Texture);
                }

                for (int j = 0; j < _Skins[i].VideoList.Count; j++)
                {
                    CVideo.VdClose(_Skins[i].VideoList[j].VideoIndex);
                    STexture VideoTexture = _Skins[i].VideoList[j].Texture;
                    CDraw.RemoveTexture(ref VideoTexture);
                }
            }
            _Skins.Clear();
        }
Beispiel #22
0
 public static STexture GetVideoTexture()
 {
     if (_Video != -1)
     {
         float vtime = 0f;
         CVideo.VdGetFrame(_Video, ref _CurrentVideoTexture, CSound.GetPosition(_CurrentMusicStream), ref vtime);
         if (_FadeTimer.ElapsedMilliseconds <= 3000L)
         {
             _CurrentVideoTexture.color.A = (_FadeTimer.ElapsedMilliseconds / 3000f);
         }
         else
         {
             _CurrentVideoTexture.color.A = 1f;
             _FadeTimer.Stop();
         }
         return(_CurrentVideoTexture);
     }
     return(new STexture(-1));
 }
Beispiel #23
0
        public static void Previous()
        {
            if (_PreviousFileNames.Count > 0 || _PreviousMusicIndex >= 0)
            {
                float pos = CSound.GetPosition(_CurrentMusicStream);
                if (CSound.GetPosition(_CurrentMusicStream) >= 1.5f)
                {
                    CSound.SetPosition(_CurrentMusicStream, 0);
                    if (_VideoEnabled && _Video != -1)
                    {
                        CVideo.VdSkip(_Video, 0f, _CurrentPlaylistElement.VideoGap);
                    }
                }
                else
                {
                    Stop();
                    _PreviousMusicIndex--;
                    if (_PreviousMusicIndex < 0)
                    {
                        _PreviousMusicIndex = 0; //No previous songs left, so play the first
                    }
                    _CurrentPlaylistElement = _PreviousFileNames[_PreviousMusicIndex];

                    _CurrentMusicStream = CSound.Load(_CurrentPlaylistElement.MusicFilePath);
                    CSound.SetStreamVolumeMax(_CurrentMusicStream, CConfig.BackgroundMusicVolume);
                    if (_VideoEnabled)
                    {
                        LoadVideo();
                    }
                    CSound.SetStreamVolume(_CurrentMusicStream, 0f);
                    Play();
                }
            }
            else if (_CurrentMusicStream != -1)
            {
                CSound.SetPosition(_CurrentMusicStream, 0);
                if (_VideoEnabled && _Video != -1)
                {
                    CVideo.VdSkip(_Video, 0f, _CurrentPlaylistElement.VideoGap);
                }
            }
        }
Beispiel #24
0
        public void Draw()
        {
            if (!_Loaded)
            {
                return;
            }

            if (!_Finished)
            {
                float videoTime = _VideoTimer.ElapsedMilliseconds / 1000f;
                _Finished = CVideo.Finished(_VideoStream);

                CVideo.GetFrame(_VideoStream, videoTime);
            }
            if (_VideoStream.Texture == null)
            {
                return;
            }

            CDraw.DrawTexture(_VideoStream.Texture, CSettings.RenderRect, EAspect.Crop);
        }
Beispiel #25
0
        public static void SkinVideoResume(string VideoName)
        {
            int SkinIndex = GetSkinIndex();

            if (SkinIndex != -1)
            {
                for (int i = 0; i < _Skins[SkinIndex].VideoList.Count; i++)
                {
                    SkinElement sk = _Skins[SkinIndex].VideoList[i];
                    if (sk.Name == VideoName)
                    {
                        if (sk.VideoIndex == -1)
                        {
                            sk.VideoIndex = CVideo.VdLoad(GetVideoFilePath(sk.Name));
                            CVideo.VdSetLoop(sk.VideoIndex, true);
                        }
                        CVideo.VdResume(sk.VideoIndex);
                        _Skins[SkinIndex].VideoList[i] = sk;
                        return;
                    }
                }
            }
        }
Beispiel #26
0
        public static void Play()
        {
            if (_Playing)
            {
                return;
            }

            if (CConfig.BackgroundMusic == EOffOn.TR_CONFIG_ON)
            {
                if (_AllFileNames.Count > 0)
                {
                    if (_CurrentMusicStream != -1)
                    {
                        CSound.Fade(_CurrentMusicStream, 100f, CSettings.BackgroundMusicFadeTime);
                        CSound.Play(_CurrentMusicStream);
                        if (_VideoEnabled && _Video != -1)
                        {
                            CVideo.VdResume(_Video);
                        }
                        _Playing = true;
                    }
                    else
                    {
                        Next();
                    }

                    if (!IsBackgroundFile(_CurrentPlaylistElement))
                    {
                        _CanSing = true;
                    }
                    else
                    {
                        _CanSing = false;
                    }
                }
            }
        }
Beispiel #27
0
        public void Draw()
        {
            if (!_Finished)
            {
                float VideoTime = _VideoTimer.ElapsedMilliseconds / 1000f;
                _Finished = CVideo.VdFinished(_VideoStream);

                STexture tex = new STexture(-1);
                tex.height = 0f;
                CVideo.VdGetFrame(_VideoStream, ref tex, VideoTime, ref VideoTime);

                if (tex.height > 0)
                {
                    CDraw.RemoveTexture(ref _VideoTexture);
                    _VideoTexture = tex;
                }
            }
            RectangleF bounds = new RectangleF(0f, 0f, CSettings.iRenderW, CSettings.iRenderH);
            RectangleF rect   = new RectangleF(0f, 0f, _VideoTexture.width, _VideoTexture.height);

            CHelper.SetRect(bounds, ref rect, rect.Width / rect.Height, EAspect.Crop);

            CDraw.DrawTexture(_VideoTexture, new SRectF(rect.X, rect.Y, rect.Width, rect.Height, CSettings.zFar / 4));
        }
Beispiel #28
0
        public void PreLoad()
        {
            if (!_Loaded || _VideoStream == null)
            {
                return;
            }
            bool paused = _VideoTimer.IsRunning;

            if (paused)
            {
                CVideo.Resume(_VideoStream);
            }
            float videoTime = 0f;

            while (_VideoStream.Texture == null && videoTime < 1f)
            {
                CVideo.GetFrame(_VideoStream, 0);
                videoTime += 0.05f;
            }
            if (paused)
            {
                CVideo.Pause(_VideoStream);
            }
        }
Beispiel #29
0
 public void SetLoop(CVideoStream stream, bool loop = true)
 {
     CVideo.SetLoop(stream, loop);
 }
Beispiel #30
0
 public bool IsFinished(CVideoStream stream)
 {
     return(CVideo.Finished(stream));
 }