Exemple #1
0
        public RadioButtonSet(RadioButtonType radioButtonType, Vector2 position, Vector2 elementOffset, List <SpriteText> attatchedTextList, Vector2 attatchedTextOffset, int defaultValue, float layerDepth)
        {
            radioButtonElementList = new List <RadioButtonElement>();

            selectedButtonPreset     = radioButtonStatePresets[radioButtonType];
            this.attatchedTextOffset = attatchedTextOffset;

            for (int i = 0; i < attatchedTextList.Count; i++)
            {
                //Sprite
                Sprite sprite = new Sprite(selectedButtonPreset.SpritePath, layerDepth: layerDepth, sourceRectangle: selectedButtonPreset.StatePreset[ButtonAnimationState.Normal]);
                sprite.Pivot = new Vector2(6, 6);

                //SpriteText
                attatchedTextList[i].Alignment = Alignment.Left;

                //TransparentButton
                TransparentButton button = new TransparentButton(default, default)
Exemple #2
0
        private RoomButton(RoomMetadata roomMetadata, Vector2 buttonPosition, Action <object> action, ButtonPreset buttonPreset)
            : base(ButtonType.RoomButton, DepthParameter.InterfaceButton, action, buttonPosition, buttonPreset)
        {
            spriteList     = new List <Sprite>();
            spriteFontList = new List <NumericSpriteFont>();

            //Since the button elements dont update, the screencenter
            //must be added in order to create the right position
            //on the elements
            buttonPosition += Parameter.ScreenCenter;

            //MAP
            Vector2 mapCenter = buttonPosition + new Vector2(28, 11f);
            Sprite  map       = new Sprite($"Graphics/Maps/{roomMetadata.Map.GameMap}/GameListThumb{roomMetadata.Map.GameMapType}", mapCenter, DepthParameter.InterfaceButtonIcon);

            spriteList.Add(map);

            //RoomStatus
            int rectangleOffset = roomMetadata.IsPlaying ? 0 :
                                  (roomMetadata.IsFull ? 2 * 91 : 91);

            Sprite roomStatus = new Sprite("Interface/StaticButtons/GameList/Status",
                                           mapCenter - new Vector2(100, 0), DepthParameter.InterfaceButtonIcon,
                                           new Rectangle(rectangleOffset, 0, 91, 27))
            {
                Pivot = new Vector2(91 / 2, 27 / 2)
            };

            spriteList.Add(roomStatus);

            //RoomName
            SpriteText[] roomName = new SpriteText[2] {
                new SpriteText(FontTextType.Consolas11, string.Format("{0,3}", roomMetadata.ID) + " ",
                               Color.White, Alignment.Left, DepthParameter.InterfaceButtonText),
                new SpriteText(FontTextType.Consolas11, roomMetadata.Name,
                               Color.White, Alignment.Left, DepthParameter.InterfaceButtonText)
            };

            compositeSpriteText = CompositeSpriteText.CreateCompositeSpriteText(roomName.ToList(), Orientation.Horizontal, Alignment.Left, buttonPosition - new Vector2(115, 25), 0);

            //SpriteFont
            NumericSpriteFont nsf = new NumericSpriteFont(FontType.GameListPlayerCounter,
                                                          1, DepthParameter.InterfaceButtonText,
                                                          Position: buttonPosition + new Vector2(91, -24),
                                                          StartingValue: roomMetadata.NumberOfPlayers,
                                                          attachToCamera: false);

            spriteFontList.Add(nsf);

            NumericSpriteFont nsf2 = new NumericSpriteFont(FontType.GameListPlayerCounter,
                                                           1, DepthParameter.InterfaceButtonText,
                                                           Position: buttonPosition + new Vector2(105, -24),
                                                           StartingValue: (int)roomMetadata.Size,
                                                           attachToCamera: false);

            spriteFontList.Add(nsf2);

            //IsPasswordProtected
            if (roomMetadata.HasPassword)
            {
                Sprite passwordLock = new Sprite("Interface/StaticButtons/GameList/PasswordProtected",
                                                 mapCenter, DepthParameter.InterfaceButtonAnimatedIcon);
                spriteList.Add(passwordLock);
            }

            //HasBuddyInRoom
            if (HasBuddyInside(roomMetadata))
            {
                Sprite buddy = new Sprite("Interface/StaticButtons/GameList/BuddyInside",
                                          mapCenter + new Vector2(32, 0), DepthParameter.InterfaceButtonAnimatedIcon);
                spriteList.Add(buddy);
            }
        }