Esempio n. 1
0
        public void Update(Stopwatch time)
        {
            // updates the score of the player

            if (myPlayer.Score > 0)
                playerScoreLabel.Text = myPlayer.Name + " " + myPlayer.Score;
            else
                playerScoreLabel.Text = myPlayer.Name;

            myUIManager.Update(time);

            float t = (float)(totTime.ElapsedMilliseconds / 1000d);
            int index = mySong.Lyrics.AtTime(0, t);

            atEnd = (t >= (mySong.Music.Duration.TotalMilliseconds / 1000d));
            if (!atEnd)
            {
                Subtitle sub = GetCurrentSubtitle();

                if (sub != prevSubtitle)
                    OnSubtitleChanged();

                prevSubtitle = sub;

                if ( sub != null )
                {
                    // so that the frame fits perfeclty the subtitle
                    lyricsLabelFrame.Size = new Vector2f(0f, 0f);
                    lyricsLabel.Size = new Vector2f(0f, 0f);

                    if (sub.ContainHole)
                    {
                        if (validated < index)// on attend la réponse
                        {
                            waitingForAnswer = true;
                            Stop();
                        }

                        if (waitingForAnswer)
                            lyricsLabel.SetTextFromSlices( sub.GetDisplayedSlices() );
                        else
                            lyricsLabel.Text = sub.CompleteText;
                    }
                    else
                        lyricsLabel.SetTextFromSlices(sub.GetDisplayedSlices());
                }
                else
                    lyricsLabel.Text = "";

                if (lyricsLabel.Text == "")
                    lyricsLabelFrame.Visible = false;
                else
                    lyricsLabelFrame.Visible = true;

                lyricsLabelFrame.CenterPosition = new Vector2f(0.5f * myApp.window.Size.X, 0.75f * myApp.window.Size.Y);
            }
            else
            {
                lyricsLabelFrame.Visible = false;
                waiting = true;
            }

            if (waitingForAnswer)// && !sentWaitingForAnswerNotif)
            {
                myApp.OurGameToControllerPipe.SendMessage(GameToControllerWindowMessage.ApplicationWaitingAnswer);
                Thread.Sleep(10);
            }
        }
Esempio n. 2
0
        public static Lyrics LoadFromFile(String src)
        {
            List<Subtitle> lyrics = new List<Subtitle>();
            StreamReader subStream = File.OpenText(src);

            bool read = true;
            while (read)
            {
                String line = subStream.ReadLine();
                if (line != null)
                {
                    line = line.Trim();
                    if (line != "")
                    {
                        Subtitle sub = null;
                        if (line.StartsWith("'"))
                        {
                            // parole à trou
                            String time = subStream.ReadLine();

                            int pos = time.IndexOf("-->");
                            String startTime = time.Substring(0, pos);
                            String endTime = time.Substring(pos + 3, time.Length - (pos + 3));

                            float start = Lyrics.AsTime(startTime);
                            float end = Lyrics.AsTime(endTime);

                            // d'abord le texte à trou
                            String text = "";

                            line = subStream.ReadLine();
                            while ((line != null) && (line != ""))
                            {
                                text += line + "\n";
                                line = subStream.ReadLine();
                            }

                            // ensuite le texte complet
                            String wholetext = "";

                            line = subStream.ReadLine();
                            while ((line != null) && (line != ""))
                            {
                                wholetext += line + "\n";
                                line = subStream.ReadLine();
                            }

                            sub = new Subtitle(start, end, text, wholetext);
                        }
                        else
                        {
                            // parole normale
                            String time = subStream.ReadLine();

                            int pos = time.IndexOf("-->");
                            String startTime = time.Substring(0, pos);
                            String endTime = time.Substring(pos + 3, time.Length - (pos + 3));

                            float start = Lyrics.AsTime(startTime);
                            float end = Lyrics.AsTime(endTime);

                            // d'abord le texte à trou
                            String text = "";

                            line = subStream.ReadLine();
                            while ((line != null) && (line != ""))
                            {
                                text += line + "\n";
                                line = subStream.ReadLine();
                            }

                            sub = new Subtitle(start, end, text);
                        }
                        lyrics.Add(sub);
                    }
                }
                else
                    read = false;
            }
            return new Lyrics(lyrics);
        }