Example #1
0
        public void SetValues(F2 p2, float deltaT)
        {
            startFromBegining = true;
            this.p2.Copy(p2);

            this.deltaT = deltaT;
        }
Example #2
0
        public void SetValues(F2 p1, F2 p2, float deltaT)
        {
            startFromBegining = false;
            this.p1.Copy(p1);
            this.p2.Copy(p2);

            this.deltaT = deltaT;
        }
Example #3
0
        public Viewport(F2 viewportPositionOnScreen, F2 viewportSizeOnScreen)
        {
            this.viewportPositionOnScreen.Copy(viewportPositionOnScreen);
            this.viewportSizeOnScreen.Copy(viewportSizeOnScreen);

            viewportYXRatio = viewportSizeOnScreen.y / viewportSizeOnScreen.x;

            viewportToScreenRatio.x = viewportSizeOnScreen.x;
            viewportToScreenRatio.y = viewportSizeOnScreen.y / viewportYXRatio;
        }
Example #4
0
        private void CalculatePerp()
        {
            F2 diff = p2 - p1;

            if (curvature != 0)
            {
                perp.y = diff.x * curvature;
                perp.x = -diff.y * curvature;
            }
        }
Example #5
0
        public override void Draw(int dt, float depth)
        {
            float screenBarHeight = 0;

            //PositionManager.Get().UiXToScreenXRatio(barHeight, ref screenBarHeight);
            App.Get().defaultUIViewport.ViewportXToScreenXRatio(barHeight, out screenBarHeight);
            float screenBarWidth = 0;

            //PositionManager.Get().UiXToScreenXRatio(Size.x, ref screenBarWidth);
            App.Get().defaultUIViewport.ViewportXToScreenXRatio(barHeight, out screenBarHeight);

            F2 absolutePos = new F2(GetAbsoluteX(), GetAbsoluteY());

            //PositionManager.Get().UiToScreen(absolutePos, screenPos);
            App.Get().defaultUIViewport.ViewportToScreen(absolutePos, ref screenPos);

            cursorPos.y = absolutePos.y;
            cursorPos.x = absolutePos.x + (Value - 0.5f) * Size.x;

            //PositionManager.Get().UiToScreen(cursorPos, cursorPos);
            App.Get().defaultUIViewport.ViewportToScreen(cursorPos, ref cursorPos);

            float screenCursorSide = 0;

            //PositionManager.Get().UiXToScreenXRatio(cursorSide, ref screenCursorSide);
            App.Get().defaultUIViewport.ViewportXToScreenXRatio(cursorSide, out screenCursorSide);

            int   opacity       = (int)(255 * GetAbsoluteOpacity());
            float absoluteDepth = GetAbsoluteDepth();

            App.Get().spriteBatchGui.Draw(texBar,
                                          screenPos.ToVector2(),
                                          null,
                                          Color.FromNonPremultiplied(Color.R, Color.G, Color.B, opacity),
                                          0, new Vector2(texBar.Width / 2, texBar.Height / 2),
                                          new Vector2(screenBarWidth / texBar.Width, screenBarHeight / texBar.Height),
                                          SpriteEffects.None, absoluteDepth);
            App.Get().spriteBatchGui.Draw(texCursor,
                                          cursorPos.ToVector2(),
                                          null,
                                          Color.FromNonPremultiplied(CursorColor.R, CursorColor.G, CursorColor.B, opacity),
                                          0, new Vector2(texCursor.Width / 2, texCursor.Width / 2),
                                          new Vector2(screenCursorSide / texCursor.Width, screenCursorSide / texCursor.Height),
                                          SpriteEffects.None, absoluteDepth + 0.01f);
        }
Example #6
0
        public override void Draw(int dt, float depth)
        {
            if (!Visible)
            {
                return;
            }

            F2 screenPosVetor = new F2();

            //PositionManager.Get().UiToScreen(new F2(GetAbsoluteX(), GetAbsoluteY()),screenPosVetor);
            App.Get().defaultUIViewport.ViewportToScreen(new F2(GetAbsoluteX(), GetAbsoluteY()), ref screenPosVetor);

            Vector2 screenPos = screenPosVetor.ToVector2();

            float opacityFloat = GetAbsoluteOpacity();
            byte  opacity      = (byte)(255 * opacityFloat);
            Color color        = Color.FromNonPremultiplied(Color.R, Color.G, Color.B, opacity);

            App.Get().spriteBatchGui.DrawString(font, Text, screenPos, color,
                                                0, origin, 1, SpriteEffects.None, depth + 0.002f);
            if (Border)
            {
                color.R = borderColor.R;
                color.G = borderColor.G;
                color.B = borderColor.B;
                color.A = (byte)(255 * opacityFloat * opacityFloat * opacityFloat);

                screenPos.X -= 1;
                screenPos.Y -= 1;

                App.Get().spriteBatchGui.DrawString(font, Text, screenPos, color, 0, origin, 1, SpriteEffects.None, depth + 0.001f);
                screenPos.X += 2;
                App.Get().spriteBatchGui.DrawString(font, Text, screenPos, color, 0, origin, 1, SpriteEffects.None, depth + 0.001f);
                screenPos.Y += 2;
                App.Get().spriteBatchGui.DrawString(font, Text, screenPos, color, 0, origin, 1, SpriteEffects.None, depth + 0.001f);
                screenPos.X -= 2;
                App.Get().spriteBatchGui.DrawString(font, Text, screenPos, color, 0, origin, 1, SpriteEffects.None, depth + 0.001f);
                screenPos.X += 1;
                screenPos.Y += 1;
                App.Get().spriteBatchGui.DrawString(font, Text, screenPos, color, 0, origin, 1, SpriteEffects.None, depth + 0.001f);
            }
        }
Example #7
0
        public override void Draw(int dt, float depth)
        {
            if (!Visible || texBackground == null)
            {
                return;
            }

            F2 screenPosVetor = new F2();

            //PositionManager.Get().UiToScreen(new F2(GetAbsoluteX(), GetAbsoluteY()), screenPosVetor);
            App.Get().defaultUIViewport.ViewportToScreen(new F2(GetAbsoluteX(), GetAbsoluteY()), ref screenPosVetor);
            F2 screenSizeVetor = new F2();

            //PositionManager.Get().UiToScreenRatio(Size, screenSizeVetor);
            App.Get().defaultUIViewport.ViewportToScreenRatio(Size, ref screenSizeVetor);
            screenSizeVetor.x /= texBackground.Width;
            screenSizeVetor.y /= texBackground.Height;

            App.Get().spriteBatchGui.Draw(texBackground, screenPosVetor.ToVector2(), null,
                                          Color.FromNonPremultiplied(Color.R, Color.G, Color.B, (int)(255 * GetAbsoluteOpacity())),
                                          Rotation.Value, new Vector2(texBackground.Width / 2, texBackground.Height / 2),
                                          screenSizeVetor.ToVector2(),
                                          SpriteEffects.None, depth);
        }
Example #8
0
 protected virtual void InitScreenSize(float screenWidth, float screenHeight)
 {
     screenSize    = new F2(screenWidth, screenHeight);
     screenYXRatio = screenHeight / screenWidth;
 }
Example #9
0
 public F2(F2 toCopy)
 {
     this.x = toCopy.x;
     this.y = toCopy.y;
 }
Example #10
0
 public void Copy(F2 copiedVetor)
 {
     this.x = copiedVetor.x;
     this.y = copiedVetor.y;
 }
Example #11
0
 public AffectorF2(F2 obj, float x1, float y1, float x2, float y2, float deltaT)
 {
     this.obj = obj;
     SetValues(x1, y1, x2, y2, deltaT);
 }
Example #12
0
 public void setDelta(F2 p1, F2 p2)
 {
     Delta.x = p2.x - p1.y;
     Delta.y = p2.y - p1.y;
 }
Example #13
0
 public AffectorF2(F2 obj)
 {
     this.obj = obj;
 }
Example #14
0
 public AffectorF2(F2 obj, F2 p2, float deltaT)
 {
     this.obj = obj;
     SetValues(p2, deltaT);
 }
Example #15
0
 public void ViewportToScreen(F2 input, ref F2 output)
 {
     output.x = input.x * viewportToScreenRatio.x + viewportPositionOnScreen.x;
     output.y = input.y * viewportToScreenRatio.y + viewportPositionOnScreen.y;
 }
Example #16
0
 public void ScreenToViewport(F2 input, ref F2 output)
 {
     output.x = (input.x - viewportPositionOnScreen.x) / viewportToScreenRatio.x;
     output.y = (input.y - viewportPositionOnScreen.y) / viewportToScreenRatio.y;
 }
Example #17
0
 public void ViewportToScreenRatio(F2 input, ref F2 output)
 {
     output.x = input.x * viewportToScreenRatio.x;
     output.y = input.y * viewportToScreenRatio.y;
 }
Example #18
0
 public void ConvertPosition(Viewport other, F2 positionThis, ref F2 positionOther)
 {
     ViewportToScreen(positionThis, ref tmpF2);
     other.ScreenToViewport(tmpF2, ref positionOther);
 }
Example #19
0
 public bool IsInsideViewport(F2 input)
 {
     return(input.x >= 0 && input.x <= 1 && input.y >= 0 && input.y <= viewportYXRatio);
 }