Esempio n. 1
0
        private void PrepareTimeLine()
        {
            CStatic stat = Statics[htStatics(StaticTimeLine)];

            switch (CConfig.TimerLook)
            {
            case ETimerLook.TR_CONFIG_TIMERLOOK_NORMAL:
                _TimeLineRect = new SRectF(stat.Rect.X, stat.Rect.Y, 0f, stat.Rect.H, stat.Rect.Z);
                Statics[htStatics(StaticTimePointer)].Visible = false;
                break;

            case ETimerLook.TR_CONFIG_TIMERLOOK_EXPANDED:
                _TimeRects.Clear();
                Statics[htStatics(StaticTimePointer)].Visible = true;

                CSong song = CGame.GetSong();

                if (song == null)
                {
                    return;
                }

                float TotalTime = CSound.GetLength(_CurrentStream);
                if (song.Finish != 0)
                {
                    TotalTime = song.Finish;
                }

                TotalTime -= song.Start;

                if (TotalTime <= 0f)
                {
                    return;
                }

                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 < Line.Length; j++)
                    {
                        TimeRect trect = new TimeRect();
                        trect.startBeat = Line[j].FirstBeat;
                        trect.endBeat   = Line[j].EndBeat;

                        trect.rect = new CStatic(new STexture(-1),
                                                 new SColorF(1f, 1f, 1f, 1f),
                                                 new SRectF(stat.Rect.X + stat.Rect.W * ((CGame.GetTimeFromBeats(trect.startBeat, song.BPM) + song.Gap - song.Start) / TotalTime),
                                                            stat.Rect.Y,
                                                            stat.Rect.W * (CGame.GetTimeFromBeats((trect.endBeat - trect.startBeat), song.BPM) / TotalTime),
                                                            stat.Rect.H,
                                                            stat.Rect.Z));

                        _TimeRects.Add(trect);
                    }
                }
                break;
            }
        }
Esempio n. 2
0
        private float[] CalcFadingAlpha()
        {
            float dt = 4f;
            float rt = dt * 0.8f;

            CSong Song = CGame.GetSong();

            if (Song == null)
            {
                return(null);
            }

            float[]  Alpha       = new float[Song.Notes.Lines.Length * 2];
            CLines[] lines       = new CLines[Song.Notes.Lines.Length];
            float    CurrentTime = _CurrentTime - Song.Gap;

            for (int i = 0; i < lines.Length; i++)
            {
                lines[i] = Song.Notes.GetLines(i);
                CLine[] line = lines[i].Line;

                // find current line for lyric sub fading (it must be the same as in UpdateLyrics)
                int CurrentLineSub = 0;
                for (int j = 0; j < line.Length; j++)
                {
                    if (line[j].StartBeat <= _CurrentBeat)
                    {
                        if (CGame.GetTimeFromBeats(line[j].FirstBeat, Song.BPM) <= _CurrentTime - Song.Gap + 10f)
                        {
                            CurrentLineSub = j;
                        }
                    }
                }

                // find current line for lyric main fading
                int CurrentLine = 0;
                for (int j = 0; j < line.Length; j++)
                {
                    if (line[j].FirstBeat <= _CurrentBeat)
                    {
                        CurrentLine = j;
                    }
                }

                // default values
                Alpha[i * 2]     = 1f;
                Alpha[i * 2 + 1] = 1f;

                // main line alpha
                if (CurrentLine == 0 && CurrentTime < CGame.GetTimeFromBeats(line[CurrentLine].FirstBeat, Song.BPM))
                {
                    // first main line and fist note is not reached
                    // => fade in
                    float diff = CGame.GetTimeFromBeats(line[CurrentLine].FirstBeat, Song.BPM) - CurrentTime;
                    if (diff > dt)
                    {
                        Alpha[i * 2] = 1f - (diff - dt) / rt;
                    }
                }
                else if (CurrentLine < line.Length - 1 && CGame.GetTimeFromBeats(line[CurrentLine].LastBeat, Song.BPM) < CurrentTime &&
                         CGame.GetTimeFromBeats(line[CurrentLine + 1].FirstBeat, Song.BPM) > CurrentTime)
                {
                    // current position is between two lines

                    // time between the to lines
                    float diff = CGame.GetTimeFromBeats(line[CurrentLine + 1].FirstBeat, Song.BPM) -
                                 CGame.GetTimeFromBeats(line[CurrentLine].LastBeat, Song.BPM);

                    // fade only if there is enough time for fading
                    if (diff > 3.3f * dt)
                    {
                        // time elapsed since last line
                        float last = CurrentTime - CGame.GetTimeFromBeats(line[CurrentLine].LastBeat, Song.BPM);

                        // time to next line
                        float next = CGame.GetTimeFromBeats(line[CurrentLine + 1].FirstBeat, 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;
                            }
                        }
                    }
                }
                else if (CurrentLine == line.Length - 1 && CGame.GetTimeFromBeats(line[CurrentLine].LastBeat, Song.BPM) < CurrentTime)
                {
                    // last main line and last note was reached
                    // => fade out
                    float diff = CurrentTime - CGame.GetTimeFromBeats(line[CurrentLine].LastBeat, Song.BPM);
                    Alpha[i * 2] = 1f - diff / rt;
                }

                // sub
                if (CurrentLineSub < line.Length - 2)
                {
                    float diff = 0f;
                    diff = CGame.GetTimeFromBeats(line[CurrentLineSub + 1].FirstBeat, Song.BPM) - CurrentTime;

                    if (diff > dt)
                    {
                        Alpha[i * 2 + 1] = 1f - (diff - dt) / rt;
                    }
                }

                if (Alpha[i * 2] < 0f)
                {
                    Alpha[i * 2] = 0f;
                }

                if (Alpha[i * 2 + 1] < 0f)
                {
                    Alpha[i * 2 + 1] = 0f;
                }
            }

            return(Alpha);
        }
Esempio n. 3
0
        private void UpdateLyrics()
        {
            if (_FadeOut)
            {
                return;
            }

            CSong song = CGame.GetSong();

            if (song == null)
            {
                return;
            }

            CLines[] lines = new CLines[song.Notes.Lines.Length];

            _CurrentBeat = CGame.CurrentBeat;
            for (int i = 0; i < lines.Length; i++)
            {
                if (i > 1)
                {
                    break; // for later
                }
                lines[i] = song.Notes.GetLines(i);
                CLine[] line = lines[i].Line;

                // find current line (it must be the same as in CalcFadingAlpha)
                int nr = -1;
                for (int j = 0; j < line.Length; j++)
                {
                    if (line[j].StartBeat <= _CurrentBeat)
                    {
                        if (CGame.GetTimeFromBeats(line[j].FirstBeat, song.BPM) <= _CurrentTime - song.Gap + 10f)
                        {
                            nr = j;
                        }
                    }
                }

                if (nr != -1)
                {
                    for (int j = 0; j < CGame.NumPlayer; j++)
                    {
                        if (CGame.Player[j].LineNr == i)
                        {
                            SingNotes[htSingNotes(SingBars)].AddLine(NoteLines[j], line, nr, j);
                        }
                    }

                    if (i == 0 && !song.IsDuet || i == 1 && song.IsDuet)
                    {
                        Lyrics[htLyrics(LyricMain)].SetLine(line[nr]);
                        Lyrics[htLyrics(LyricMainTop)].SetLine(line[nr]);
                        _TimeToFirstNote          = CGame.GetTimeFromBeats(line[nr].FirstBeat - line[nr].StartBeat, song.BPM);
                        _RemainingTimeToFirstNote = CGame.GetTimeFromBeats(line[nr].FirstBeat - CGame.GetBeatFromTime(_CurrentTime, song.BPM, song.Gap), song.BPM);

                        if (line.Length >= nr + 2)
                        {
                            Lyrics[htLyrics(LyricSub)].SetLine(line[nr + 1]);
                            Lyrics[htLyrics(LyricSubTop)].SetLine(line[nr + 1]);
                        }
                        else
                        {
                            Lyrics[htLyrics(LyricSub)].Clear();
                            Lyrics[htLyrics(LyricSubTop)].Clear();
                        }
                    }
                    if (i == 0 && song.IsDuet)
                    {
                        Lyrics[htLyrics(LyricMainDuet)].SetLine(line[nr]);
                        _TimeToFirstNoteDuet          = CGame.GetTimeFromBeats(line[nr].FirstBeat - line[nr].StartBeat, song.BPM);
                        _RemainingTimeToFirstNoteDuet = CGame.GetTimeFromBeats(line[nr].FirstBeat - CGame.GetBeatFromTime(_CurrentTime, song.BPM, song.Gap), song.BPM);

                        if (line.Length >= nr + 2)
                        {
                            Lyrics[htLyrics(LyricSubDuet)].SetLine(line[nr + 1]);
                        }
                        else
                        {
                            Lyrics[htLyrics(LyricSubDuet)].Clear();
                        }
                    }
                }
                else
                {
                    if (i == 0 && !song.IsDuet || i == 1 && song.IsDuet)
                    {
                        Lyrics[htLyrics(LyricMain)].Clear();
                        Lyrics[htLyrics(LyricSub)].Clear();
                        Lyrics[htLyrics(LyricMainTop)].Clear();
                        Lyrics[htLyrics(LyricSubTop)].Clear();
                        _TimeToFirstNote = 0f;
                    }

                    if (i == 0 && song.IsDuet)
                    {
                        Lyrics[htLyrics(LyricMainDuet)].Clear();
                        Lyrics[htLyrics(LyricSubDuet)].Clear();
                        _TimeToFirstNoteDuet = 0f;
                    }
                }
            }
        }