public MessageBox(string message, string id)
        {
            this.id = id;

            this.message        = new Text(message, Settings.DefaultFont, 30);
            this.message.Origin = new Vector2f(
                this.message.GetLocalBounds().Width / 2,
                this.message.GetLocalBounds().Height / 2
                );

            box = new RectangleShape(
                new Vector2f(
                    Settings.ScreenSize.X * 0.4f,
                    Settings.ScreenSize.Y * 0.5f
                    )
                );
            box.Origin = new Vector2f(
                box.GetLocalBounds().Width / 2,
                box.GetLocalBounds().Height / 2
                );
            box.FillColor        = Settings.DefaultFillColor;
            box.OutlineColor     = Settings.DefaultOutlineColor;
            box.OutlineThickness = 30;

            Show = false;
        }
예제 #2
0
파일: Vertex.cs 프로젝트: Wowo10/GiSP3
        public Vertex(char label, Vector2f pos)
        {
            this.label = label;
            previous   = '0';
            distance   = uint.MaxValue;

            shape = new CircleShape(20);

            shape.FillColor        = new Color(55, 200, 255);  //invisible
            shape.OutlineThickness = 5;
            shape.OutlineColor     = new Color(255, 255, 255); //white

            shape.Position = pos + new Vector2f(5, 5);         //for outlinethickness

            shape.Origin = new Vector2f(shape.GetGlobalBounds().Width / 2, shape.GetGlobalBounds().Height / 2);

            center = new CircleShape(5);

            center.Origin = new Vector2f(center.GetGlobalBounds().Width / 2, center.GetGlobalBounds().Height / 2);

            center.FillColor = new Color(255, 0, 0);

            center.Position = pos;

            bounds = new RectangleShape(new Vector2f(shape.GetLocalBounds().Width, shape.GetLocalBounds().Height));

            bounds.Origin = new Vector2f(bounds.GetLocalBounds().Width / 2, bounds.GetLocalBounds().Height / 2);

            bounds.FillColor = new Color(0, 0, 0, 0);

            bounds.OutlineThickness = 2;
            bounds.OutlineColor     = new Color(0, 0, 0); //white

            bounds.Position = pos;

            Font font = new Font("resources/fonts/Font1.ttf");

            if (font == null)
            {
                System.Console.WriteLine("No Such Font");
            }

            labelchar = new Text();

            labelchar.Font            = font;
            labelchar.CharacterSize   = 40;
            labelchar.Color           = new Color(255, 255, 255);
            labelchar.DisplayedString = label + "";
            labelchar.Position        = pos + new Vector2f(-2, -12); //font offset

            labelchar.Origin = new Vector2f(labelchar.GetGlobalBounds().Width / 2, labelchar.GetGlobalBounds().Height / 2);
        }
예제 #3
0
        public virtual void UpdateOver(Vector2i mousePos)
        {
            var localMousePos = mousePos - GlobalPosition + GlobalOrigin;

            if (rectShape.GetLocalBounds().Contains(localMousePos.X, localMousePos.Y))
            {
                if (UIManager.Drag == null)
                {
                    if (IsAllowDrag && Mouse.IsButtonPressed(Mouse.Button.Left))
                    {
                        UIManager.Drag = this;
                        DragOffset     = mousePos - GlobalPosition;
                        OnDragBegin();
                    }
                }

                if (UIManager.Drag != this)
                {
                    UIManager.Over = this;
                }

                for (int i = 0; i < Childs.Count; i++)
                {
                    Childs[i].UpdateOver(mousePos);
                }
            }
        }
    public ToggleButton(Vector2f ButtonPosition, ToggleOptions buttonOption)
    {
        OuterShape           = new RectangleShape(new Vector2f(30f, 30f));
        OuterShape.FillColor = OuterShape_FillColor;
        OuterShape.Origin    = new Vector2f(OuterShape.GetLocalBounds().Width / 2f, OuterShape.GetLocalBounds().Height / 2f);
        OuterShape.Position  = ButtonPosition;

        InnerShape           = new RectangleShape(OuterShape.Size / 2f);
        InnerShape.FillColor = OuterShape.FillColor;
        InnerShape.Origin    = new Vector2f(InnerShape.GetLocalBounds().Width / 2f, InnerShape.GetLocalBounds().Height / 2f);
        InnerShape.Position  = OuterShape.Position;

        ToggleOption = buttonOption;

        ToggleButtonList.Add(this);
    }
예제 #5
0
        public override void UpdateOver(Vector2i mousePos)
        {
            base.UpdateOver(mousePos);

            if (IsVisibleTitleBar)
            {
                var localMousePos = mousePos - GlobalPosition + GlobalOrigin;
                IsAllowDrag = UIManager.Drag == this || rectShapeTitleBar.GetLocalBounds().Contains(localMousePos.X, localMousePos.Y);
            }
        }
예제 #6
0
        private static bool RectanglesOverlap(RectangleShape shape, Sprite sprite)
        {
            FloatRect intersection;
            IntRect   firstSubRect, secondSubRect;

            FloatRect rect1Bounds      = shape.GetLocalBounds();
            FloatRect rect2Bounds      = (sprite.GetLocalBounds());
            Vector2f  rect1Size        = new Vector2f(rect1Bounds.Width, rect1Bounds.Height);
            Vector2f  rect2Size        = new Vector2f(rect2Bounds.Width, rect2Bounds.Height);
            Vector2f  rect1TopLeft     = sprite.InverseTransform.TransformPoint(shape.Transform.TransformPoint(0, 0));
            Vector2f  rect1TopRight    = sprite.InverseTransform.TransformPoint(shape.Transform.TransformPoint(rect1Size.X, 0));
            Vector2f  rect1BottomRight = sprite.InverseTransform.TransformPoint(shape.Transform.TransformPoint(rect1Size));
            Vector2f  rect1BottomLeft  = sprite.InverseTransform.TransformPoint(shape.Transform.TransformPoint(0, rect1Size.Y));
            Vector2f  rect2TopLeft     = shape.InverseTransform.TransformPoint(sprite.Transform.TransformPoint(0, 0));
            Vector2f  rect2TopRight    = shape.InverseTransform.TransformPoint(sprite.Transform.TransformPoint(rect2Size.X, 0));
            Vector2f  rect2BottomRight = shape.InverseTransform.TransformPoint(sprite.Transform.TransformPoint(rect2Size));
            Vector2f  rect2BottomLeft  = shape.InverseTransform.TransformPoint(sprite.Transform.TransformPoint(0, rect2Size.Y));

            bool level1 = (rect1Bounds.Contains(rect2TopLeft.X, rect1TopLeft.Y)) ||
                          (rect1Bounds.Contains(rect2TopRight.X, rect2TopRight.Y)) ||
                          (rect1Bounds.Contains(rect2BottomLeft.X, rect2BottomLeft.Y)) ||
                          (rect1Bounds.Contains(rect2BottomRight.X, rect1BottomRight.Y)) ||
                          (rect2Bounds.Contains(rect1TopLeft.X, rect1TopLeft.Y)) ||
                          (rect2Bounds.Contains(rect1TopRight.X, rect1TopRight.Y)) ||
                          (rect2Bounds.Contains(rect1BottomLeft.X, rect1BottomLeft.Y)) ||
                          (rect2Bounds.Contains(rect1BottomRight.X, rect1BottomRight.Y));


            List <Vector2f> rect1Points = new List <Vector2f>
            {
                rect1BottomLeft,
                rect1BottomRight,
                rect1TopRight,
                rect1TopLeft,
            };

            if (!satRectangleAndPoints(rect2Size, rect1Points))
            {
                return(false);
            }
            List <Vector2f> rect2Points = new List <Vector2f>
            {
                rect2BottomLeft,
                rect2BottomRight,
                rect2TopRight,
                rect2TopLeft,
            };

            return(satRectangleAndPoints(rect1Size, rect2Points));


            //return xOverlap && yOverlap;
        }
예제 #7
0
    public Panel(Vector2f size, Vector2f position, PanelModes modeRef)
    {
        PanelShape = new RectangleShape(size);
        PanelShape.OutlineColor     = new Color(0, 0, 0);
        PanelShape.FillColor        = FillColor_Inactive;
        PanelShape.OutlineThickness = 2;
        PanelShape.Origin           = new Vector2f(PanelShape.GetLocalBounds().Width / 2f, PanelShape.GetLocalBounds().Top);
        PanelShape.Position         = position;

        PanelMode = modeRef;
        IsActive  = false;
        PanelList.Add(this);
    }
예제 #8
0
        private Text CreateTextTitleLobby()
        {
            Text text = new Text()
            {
                Style           = Text.Styles.Regular,
                Font            = new Font("../../../../Ui/Resources/Fonts/Cocogoose/CocogooseBold.ttf"),
                CharacterSize   = 30,
                DisplayedString = "Lobby en cours . . .",
            };

            text.Position = new Vector2f(_backLobby.Position.X + (_backLobby.GetLocalBounds().Width / 2) - (text.GetLocalBounds().Width / 2f), _backLobby.Position.Y + 30f);

            return(text);
        }
예제 #9
0
 public FloatRect GetLocalBounds()
 {
     return(background.GetLocalBounds());
 }
예제 #10
0
        protected override void UpdateDrawable()
        {
            base.UpdateDrawable();

            if (isCircle)
            {
                var circle = new CircleShape(radius);
                circle.OutlineThickness = OutlineThickness;
                circle.OutlineColor     = OutlineColor.SFMLColor;
                circle.FillColor        = Color.SFMLColor;
                circle.SetPointCount((uint)CirclePointCount);
                SFMLDrawable = circle;
                Width        = (int)circle.GetLocalBounds().Width;
                Height       = (int)circle.GetLocalBounds().Height;
            }
            else
            {
                if (isShape)
                {
                    var rect = new RectangleShape(new Vector2f(rectWidth, rectHeight));
                    rect.OutlineColor     = OutlineColor.SFMLColor;
                    rect.OutlineThickness = OutlineThickness;
                    rect.FillColor        = Color.SFMLColor;
                    SFMLDrawable          = rect;
                    Width  = (int)rect.GetLocalBounds().Width;
                    Height = (int)rect.GetLocalBounds().Height;
                }
                else
                {
                    SFMLVertices.Clear();

                    float x1, y1, x2, y2, u1, v1, u2, v2, cx1, cy1, cx2, cy2;

                    cx1 = ClippingRegion.Left;
                    cy1 = ClippingRegion.Top;
                    cx2 = ClippingRegion.Right;
                    cy2 = ClippingRegion.Bottom;

                    x1 = Util.Max(0, cx1);
                    u1 = TextureLeft + x1;

                    if (FlippedX)
                    {
                        u1 = TextureRegion.Width - u1 + TextureLeft + TextureRegion.Left;
                    }

                    y1 = Util.Max(0, cy1);
                    v1 = TextureTop + y1;

                    if (FlippedY)
                    {
                        v1 = TextureRegion.Height - v1 + TextureTop + TextureRegion.Top;
                    }

                    x2 = Util.Min(TextureRegion.Right, cx2);
                    u2 = TextureLeft + x2;

                    if (FlippedX)
                    {
                        u2 = TextureRegion.Width - u2 + TextureLeft + TextureRegion.Left;
                    }

                    y2 = Util.Min(TextureRegion.Bottom, cy2);
                    v2 = TextureTop + y2;

                    if (FlippedY)
                    {
                        v2 = TextureRegion.Height - v2 + TextureTop + TextureRegion.Top;
                    }

                    SFMLVertices.Append(x1, y1, Color, u1, v1);
                    SFMLVertices.Append(x1, y2, Color, u1, v2);
                    SFMLVertices.Append(x2, y2, Color, u2, v2);
                    SFMLVertices.Append(x2, y1, Color, u2, v1);

                    Width  = TextureRegion.Width;
                    Height = TextureRegion.Height;
                }
            }
        }
예제 #11
0
 public Vector2f GetSize()
 {
     return(new Vector2f(ColoredRegionSize.X + whiteBackground.GetLocalBounds().Width, ColoredRegionSize.Y));
 }
예제 #12
0
 public FloatRect GetLocalBounds()
 {
     return(rectangle.GetLocalBounds());
 }