Exemplo n.º 1
0
        public BasicLabel(UIManager manager_, Widget parent_, DCFont font, TextStyle style, Color color, string str, uint size = 30 )
            : base(manager_, parent_)
        {
            Manager.RegisterWidgetType("BasicLabel", "Widget");

            myFont = font;
            myText = str;
            myTextSize = size;
            myStyle = style;
            myTextColor = color;
            updateSize();
        }
Exemplo n.º 2
0
 public Label(UIManager manager_, Widget parent_, DCFont font, string str, uint size = 30 )
     : base(manager_, parent_)
 {
     Manager.RegisterWidgetType("Label", "Widget");
     myCharacterSize = size;
     Font = font;
     Text = str;
 }
Exemplo n.º 3
0
        public void LoadContent()
        {
            mySong.DoLoad();

            ThemeSelectionMenuStyle myStyle = myApp.guiStyle.ThemeSelectionMenuStyle;
            ImagePart[] textures = myStyle.LabelsTextures;

            myUIManager = new UIManager(myApp.window);

            DCFont myFont = new DCFont(new Font("Content/verdana.ttf"));

            Frame playerScoreLabelFrame = new Frame(myUIManager, null);
            playerScoreLabelFrame.BordersImagesParts = textures;
            playerScoreLabelFrame.Visible = true;

            playerScoreLabel = new Label(myUIManager, null, myFont, myPlayer.Name + "   " + myPlayer.Score);
            playerScoreLabel.Tint = Color.White;
            playerScoreLabel.Visible = true;
            playerScoreLabelFrame.Position = new Vector2f(50f, 20f);
            playerScoreLabelFrame.ContainedWidget = playerScoreLabel;

            Frame songNameFrame = new Frame(myUIManager, null);
            songNameFrame.BordersImagesParts = textures;
            songNameFrame.Visible = true;

            Label songNameLabel = new Label(myUIManager, null, myFont, mySong.Name);
            songNameLabel.Tint = Color.White;
            songNameLabel.Visible = true;
            songNameFrame.ContainedWidget = songNameLabel;

            songNameFrame.TopRightPosition = new Vector2f(myUIManager.ScreenSize.X - 50f, 20f);
            //songNameFrame.Position = new Vector2f(0.5f * (myUIManager.ScreenSize.X - songNameFrame.Size.X), (1f/8f) * myUIManager.ScreenSize.Y - 0.5f* songNameFrame.Size.Y );

            lyricsLabelFrame = new Frame(myUIManager, null);
            lyricsLabelFrame.BordersImagesParts = textures;
            lyricsLabelFrame.Visible = true;

            lyricsLabel = new Label(myUIManager, null, myFont, "");
            lyricsLabel.Tint = Color.White;
            lyricsLabel.Visible = true;
            lyricsLabelFrame.ContainedWidget = lyricsLabel;
            lyricsLabelFrame.CenterPosition = new Vector2f(0.5f * (float)myApp.window.Size.X, 0.75f * (float)myApp.window.Size.Y);
        }
Exemplo n.º 4
0
        public void LoadContent()
        {
            // récupération du style
            myStyle = myApp.guiStyle.ThemeSelectionMenuStyle;

            myPlayer = null;
            themes = new List<HorizontalLayout>();

            if (myGame.NumPlayers > 0)
            {
                // on trouve le joueur concerné par la sélection
                int numSelections = myGame.Players[0].ChosenThemes.Count;

                for (int i = 1; i < myGame.NumPlayers; i++)
                {
                    if (myGame.Players[i].ChosenThemes.Count < numSelections)
                    {
                        myPlayer = myGame.Players[i];
                        break;
                    }
                }

                if (myPlayer == null)
                    myPlayer = myGame.Players[0];

                // on détermine si l'on doit afficher les scores.
                for (int i = 0; i < myGame.NumPlayers; i++)
                {
                    if (myGame.Players[i].Score > 0)
                    {
                        displayScores = true;
                        break;
                    }
                }
            }
            else
                throw new Exception("Pas de joueur?");

            ImagePart[] labelTextures = myStyle.LabelsTextures;
            ImagePart[] playersNamesTextures = myStyle.PlayersNamesTextures;
            ImagePart[] playersPicsTextures = myStyle.PlayersPicsTextures;
            float themesLabelsBottomSpace = myStyle.ThemesLabelsBottomSpace;
            float themesListRightSpace = myStyle.ThemesListRightSpace;
            float playersSpace = myStyle.PlayersSpace;
            Vector2f picsSize = myStyle.PicsSize;
            Font font = myStyle.Font;
            uint fontSize = myStyle.FontSize;

            myUIManager = new UIManager(myApp.window);

            DCFont myFont = new DCFont(font);

            // Layout principal contenant tout le reste
            mainLayout = new HorizontalLayout(myUIManager, null);
            mainLayout.Visible = true;

            // Affichage des thèmes
            {
                themesLayout = new VerticalLayout(myUIManager, mainLayout);
                themesLayout.Visible = true;
                mainLayout.Add(themesLayout);

                for (int i = 0; i < myGame.NumThemes; i++)
                {
                    HorizontalLayout themeHLayout = new HorizontalLayout(myUIManager, themesLayout);
                    themeHLayout.Visible = true;
                    themesLayout.Add(themeHLayout);
                    themes.Add(themeHLayout);

                    if (!myGame.IsThemeAvalaible(myGame.GetTheme(i)))
                        themeHLayout.Tint = new Color(125, 125, 125);

                    // Frame contenant le nom du thème
                    {
                        Frame themeFrame = new Frame(myUIManager, themeHLayout);
                        themeFrame.BordersImagesParts = myStyle.LabelsTextures;

                        themeFrame.Visible = true;
                        themeHLayout.Add(themeFrame);

                        Label themesNamelabel = new Label(myUIManager, themeFrame, myFont, myGame.GetTheme(i).Name + "   " + myGame.GetTheme(i).Points.ToString(), fontSize);
                        themesNamelabel.Tint = Color.White;
                        themesNamelabel.Visible = true;
                        themeFrame.ContainedWidget = themesNamelabel;
                    }

                    if (i < myGame.NumThemes - 1)
                    {
                        VerticalSpacer sp = new VerticalSpacer(myUIManager, themesLayout, themesLabelsBottomSpace);
                        sp.Visible = true;
                        themesLayout.Add(sp);
                    }
                }
            }

            // Ajout d'un spacer
            HorizontalSpacer msp = new HorizontalSpacer(myUIManager, mainLayout, themesListRightSpace);
            msp.Visible = true;
            mainLayout.Add(msp);

            // Affichage des noms des joueurs (éventuellement leurs scores)
            {
                playersLayout = new HorizontalLayout(myUIManager, mainLayout);
                playersLayout.Visible = true;
                mainLayout.Add(playersLayout);

                for (int i = 0; i < myGame.NumPlayers; i++)
                {
                    Player player = myGame.Players[i];

                    VerticalLayout playerVLayout = new VerticalLayout(myUIManager, playersLayout);
                    playerVLayout.Alignment = HorizontalAlignment.Center;

                    playerVLayout.Visible = true;
                    playersLayout.Add(playerVLayout);

                    // Chargement de la photo du joueur
                    {
                        Frame photoFrame = new Frame(myUIManager, playerVLayout); ;
                        photoFrame.BordersImagesParts = playersPicsTextures;
                        photoFrame.Visible = true;
                        playerVLayout.Add(photoFrame);

                        Caption playerCaption = new Caption(myUIManager, photoFrame);
                        playerCaption.Visible = true;

                        Texture tex = new Texture(player.PhotoSrc);
                        ImagePart img = new ImagePart(tex);
                        playerCaption.ImagePart = img;
                        playerCaption.Size = picsSize;

                        // ajout de la photo
                        photoFrame.ContainedWidget = playerCaption;
                    }

                    // Ajout d'un spacer
                    VerticalSpacer vsp = new VerticalSpacer(myUIManager, playerVLayout, 5f);
                    vsp.Visible = true;
                    playerVLayout.Add(vsp);

                    // Affichage du score du joueur
                    {
                        Frame playerNameFrame = new Frame(myUIManager, playerVLayout);
                        playerNameFrame.BordersImagesParts = playersNamesTextures;
                        playerNameFrame.Visible = true;
                        playerVLayout.Add(playerNameFrame);

                        string str = player.Name;
                        if (displayScores)
                            str += "   " + player.Score.ToString();

                        Label scoreLabel = new Label(myUIManager, playerNameFrame, myFont, str, fontSize);
                        playersScoresLabels.Add(scoreLabel);

                        if (player == myPlayer)
                            scoreLabel.Tint = myStyle.FontHoveredColor;
                        else
                            scoreLabel.Tint = myStyle.FontNormalColor;

                        scoreLabel.Visible = true;

                        playerNameFrame.ContainedWidget = scoreLabel;
                    }

                    // on ajoute le spacer horizontal que si on ajoute pas le dernier joueur
                    if( i < myGame.NumPlayers-1 )
                    {
                        HorizontalSpacer sp = new HorizontalSpacer(myUIManager, playersLayout, playersSpace);
                        sp.Visible = true;
                        playersLayout.Add(sp);
                    }
                }
            }

            currentChoice = myGame.GetNextAcceptableChoice(-1);
            ChangeChoice();

            // centrage du layout principal
            mainLayout.CenterPosition = new Vector2f(myApp.window.Size.X / 2f, myApp.window.Size.Y / 2f);
        }
Exemplo n.º 5
0
        public void LoadContent()
        {
            // récupération du style
            myStyle = myApp.guiStyle.ThemeSelectionMenuStyle;

            ImagePart[] labelTextures = myStyle.LabelsTextures;

            myUIManager = new UIManager(myApp.window);

            DCFont myFont = new DCFont(new Font("Content/verdana.ttf"));

            Frame scoreFrame = new Frame(myUIManager, null );
            scoreFrame.BordersImagesParts = labelTextures;
            scoreFrame.Visible = true;

            myPlayerScoreLabel = new Label(myUIManager, null, myFont, myPlayer.Name + "   " + myPlayer.Score );
            myPlayerScoreLabel.Tint = myStyle.FontNormalColor;
            myPlayerScoreLabel.Visible = true;
            scoreFrame.Position = new Vector2f(50f, 20f);
            scoreFrame.ContainedWidget = myPlayerScoreLabel;

            VerticalLayout vvLayout = new VerticalLayout(myUIManager, null);
            vvLayout.Visible = true;

            for (int i = 0; i < myTheme.NumSongs; i++)
            {
                VerticalSpacer sp = new VerticalSpacer(myUIManager, vvLayout, 40f);
                sp.Visible = true;
                vvLayout.Add(sp);

                Frame songNameFrame = new Frame(myUIManager, vvLayout);
                songNameFrame.BordersImagesParts = labelTextures;
                songNameFrame.Visible = true;
                songNameFrames.Add( songNameFrame );

                Label songNamelabel = new Label(myUIManager, null, myFont, myTheme.GetSong(i).Name);
                songNamelabel.Tint = myStyle.FontNormalColor;
                songNamelabel.Visible = true;
                songNameLabels.Add(songNamelabel);

                songNameFrame.ContainedWidget = songNamelabel;
                vvLayout.Add(songNameFrame);
            }

            vvLayout.CenterPosition = new Vector2f(myApp.window.Size.X, myApp.window.Size.Y) / 2f;

            ChangeChoice();
        }