protected override void OnRenderUI(GuiRenderer renderer)
        {
            base.OnRenderUI(renderer);

            Vec2 size = new Vec2(512, 215.0f);

            size *= 1.0f + Time * .015f;
            size /= new Vec2(768.0f * renderer.AspectRatio, 768.0f);

            Rect rectangle = new Rect(-size / 2, size / 2) + new Vec2(.5f, .5f);

            float alpha = 0;

            if (Time > 2 && Time <= 3)
            {
                alpha = Time - 2;
            }
            else if (Time > 3 && Time <= lifeTime - 2 - 2)
            {
                alpha = 1;
            }
            else if (Time >= lifeTime - 2 - 2 && Time < lifeTime - 1)
            {
                alpha = 1 - (Time - (lifeTime - 2 - 2)) / 3;
            }

            if (alpha != 0)
            {
                renderer.AddQuad(rectangle, new Rect(0, 0, 1, 1), engineTexture,
                                 new ColorValue(1, 1, 1, alpha));
            }
        }
Ejemplo n.º 2
0
        protected override void OnRenderUI(GuiRenderer renderer)
        {
            base.OnRenderUI(renderer);

            if (Map.Instance == null)
            {
                renderer.AddQuad(new Rect(0, 0, 1, 1),
                                 new ColorValue(.2f, .2f, .2f) * window.ColorMultiplier);
            }
        }
Ejemplo n.º 3
0
        void DoFullscreenFading(GuiRenderer renderer)
        {
            if (fullscreenFadingRemainingFrames > 0)
            {
                fullscreenFadingRemainingFrames--;

                float alpha = (float)fullscreenFadingRemainingFrames / 30;
                MathFunctions.Saturate(ref alpha);
                renderer.AddQuad(new Rect(0, 0, 1, 1), new ColorValue(0, 0, 0, alpha));
            }
        }
Ejemplo n.º 4
0
        public override void OnRenderScreenUI(GuiRenderer renderer)
        {
            base.OnRenderScreenUI(renderer);

            if (drawTextOnScreen)
            {
                renderer.AddText("Add-on Example!", new Vec2(.5f, .9f), HorizontalAlign.Center, VerticalAlign.Top,
                                 new ColorValue(1, 0, 0));
                renderer.AddQuad(new Rect(.3f, .94f, .7f, .95f), new ColorValue(1, 1, 0));
            }
        }
Ejemplo n.º 5
0
        void Draw2DRectangles(GuiRenderer renderer)
        {
            Rect rect = new Rect(.01f, .9f, .25f, .99f);

            renderer.AddQuad(rect, new ColorValue(.5f, .5f, .5f, .5f));

            Rect rect2 = rect;

            rect2.Expand(new Vec2(.005f / renderer.AspectRatio, .005f));
            renderer.AddRectangle(rect2, new ColorValue(1, 1, 0));

            AddTextWithShadow(renderer, fontMedium, "2D GUI Drawing", rect.GetCenter(), HorizontalAlign.Center,
                              VerticalAlign.Center, new ColorValue(1, 1, 1));
        }
        public void RenderScreenUI(GuiRenderer renderer)
        {
            for (int viewIndex = 0; viewIndex < views.Count; viewIndex++)
            {
                View view = views[viewIndex];

                //draw view on screen
                if (view.Opacity > 0)
                {
                    renderer.PushTextureFilteringMode(GuiRenderer.TextureFilteringModes.Point);
                    renderer.AddQuad(view.Rectangle, new Rect(0, 0, 1, 1), view.Texture,
                                     new ColorValue(1, 1, 1, view.Opacity), true);
                    renderer.PopTextureFilteringMode();
                }

                //draw debug info
                if (drawDebugInfo)
                {
                    Viewport   screenViewport = renderer.ViewportForScreenGuiRenderer;
                    Vec2       pixelOffset    = 1.0f / screenViewport.DimensionsInPixels.Size.ToVec2();
                    ColorValue color          = new ColorValue(1, 1, 0);
                    renderer.AddRectangle(new Rect(
                                              view.Rectangle.LeftTop + pixelOffset,
                                              view.Rectangle.RightBottom - pixelOffset * 2),
                                          color);
                    renderer.AddLine(view.Rectangle.LeftTop, view.Rectangle.RightBottom, color);
                    renderer.AddLine(view.Rectangle.RightTop, view.Rectangle.LeftBottom, color);

                    if (debugFont == null)
                    {
                        debugFont = FontManager.Instance.LoadFont("Default", .03f);
                    }

                    string sizeString = "";
                    if (view.Texture != null)
                    {
                        sizeString = string.Format("{0}x{1}", view.Texture.Size.X, view.Texture.Size.Y);
                    }
                    string text     = string.Format("View {0}, {1}", viewIndex, sizeString);
                    Vec2   position = new Vec2(view.Rectangle.Right - pixelOffset.X * 5, view.Rectangle.Top);
                    AddTextWithShadow(renderer, debugFont, text, position, HorizontalAlign.Right,
                                      VerticalAlign.Top, new ColorValue(1, 1, 1));
                }
            }
        }
        void DrawFadingScreenQuad(GuiRenderer renderer)
        {
            const float fadeTime = 1;

            float minTimeToPoint;

            {
                //distance to start time.
                minTimeToPoint = demoModeTime;

                float time = 0;
                foreach (MapCameraCurve curve in cameraCurves)
                {
                    float length = curve.GetCurveMaxTime();
                    time += length;

                    float d = Math.Abs(demoModeTime - time);
                    if (d < minTimeToPoint)
                    {
                        minTimeToPoint = d;
                    }
                }

                //first half second is always black
                if (demoModeTime < .5f)
                {
                    minTimeToPoint = 0;
                }
            }

            //draw fading quad
            if (minTimeToPoint < fadeTime)
            {
                float alpha = minTimeToPoint / fadeTime;
                MathFunctions.Saturate(ref alpha);
                alpha = 1.0f - alpha;
                if (alpha > .001f)
                {
                    renderer.AddQuad(new Rect(0, 0, 1, 1), new ColorValue(0, 0, 0, alpha));
                }
            }
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Draw a target at center of screen
        /// </summary>
        /// <param name="renderer"></param>
        void DrawTarget( GuiRenderer renderer )
        {
            Unit playerUnit = GetPlayerUnit();

            Weapon weapon = null;
            {
                //PlayerCharacter specific
                PlayerCharacter playerCharacter = playerUnit as PlayerCharacter;
                if( playerCharacter != null )
                    weapon = playerCharacter.ActiveWeapon;

                //Turret specific
                Turret turret = playerUnit as Turret;
                if( turret != null )
                    weapon = turret.MainGun;

                //Tank specific
                Tank tank = playerUnit as Tank;
                if( tank != null )
                    weapon = tank.MainGun;
            }

            //draw quad
            if( weapon != null || currentAttachedGuiObject != null || currentSwitch != null )
            {
                Texture texture = TextureManager.Instance.Load( "Cursors/Target.png" );
                float size = .02f;
                float aspect = RendererWorld.Instance.DefaultCamera.AspectRatio;
                Rect rectangle = new Rect(
                    .5f - size, .5f - size * aspect,
                    .5f + size, .5f + size * aspect );
                renderer.AddQuad( rectangle, new Rect( 0, 0, 1, 1 ), texture );
            }

            //Tank specific
            DrawTankGunTarget( renderer );
        }
Ejemplo n.º 9
0
        //Tank specific
        void DrawTankGunTarget( GuiRenderer renderer )
        {
            Tank tank = GetPlayerUnit() as Tank;
            if( tank == null )
                return;

            Gun gun = tank.MainGun;
            if( gun == null )
                return;

            Vec3 gunPosition = gun.GetInterpolatedPosition();
            Vec3 gunDirection = gun.GetInterpolatedRotation() * new Vec3( 1, 0, 0 );

            RayCastResult[] piercingResult = PhysicsWorld.Instance.RayCastPiercing(
                new Ray( gunPosition, gunDirection * 1000 ),
                (int)ContactGroup.CastOnlyContact );

            bool finded = false;
            Vec3 pos = Vec3.Zero;

            foreach( RayCastResult result in piercingResult )
            {
                bool ignore = false;

                MapObject obj = MapSystemWorld.GetMapObjectByBody( result.Shape.Body );

                Dynamic dynamic = obj as Dynamic;
                if( dynamic != null && dynamic.GetParentUnit() == tank )
                    ignore = true;

                if( !ignore )
                {
                    finded = true;
                    pos = result.Position;
                    break;
                }
            }

            if( !finded )
                pos = gunPosition + gunDirection * 1000;

            Vec2 screenPos;
            RendererWorld.Instance.DefaultCamera.ProjectToScreenCoordinates( pos, out screenPos );

            //draw quad
            {
                Texture texture = TextureManager.Instance.Load( "Cursors/Target.png" );
                float size = .015f;
                float aspect = RendererWorld.Instance.DefaultCamera.AspectRatio;
                Rect rectangle = new Rect(
                    screenPos.X - size, screenPos.Y - size * aspect,
                    screenPos.X + size, screenPos.Y + size * aspect );
                renderer.AddQuad( rectangle, new Rect( 0, 0, 1, 1 ), texture,
                    new ColorValue( 0, 1, 0 ) );
            }
        }
Ejemplo n.º 10
0
        void DrawPlayersStatistics( GuiRenderer renderer )
        {
            if( IsCutSceneEnabled() )
                return;

            if( PlayerManager.Instance == null )
                return;

            renderer.AddQuad( new Rect( .1f, .2f, .9f, .8f ), new ColorValue( 0, 0, 1, .5f ) );

            renderer.AddText( "Players statistics", new Vec2( .5f, .25f ),
                HorizontalAlign.Center, VerticalAlign.Center );

            if( EntitySystemWorld.Instance.IsServer() || EntitySystemWorld.Instance.IsSingle() )
            {
                float posy = .3f;

                foreach( PlayerManager.ServerOrSingle_Player player in
                    PlayerManager.Instance.ServerOrSingle_Players )
                {
                    string text = string.Format( "{0},   Frags: {1},   Ping: {2} ms", player.Name,
                        player.Frags, (int)( player.Ping * 1000 ) );
                    renderer.AddText( text, new Vec2( .2f, posy ), HorizontalAlign.Left,
                        VerticalAlign.Center );

                    posy += .025f;
                }
            }

            if( EntitySystemWorld.Instance.IsClientOnly() )
            {
                float posy = .3f;

                foreach( PlayerManager.Client_Player player in PlayerManager.Instance.Client_Players )
                {
                    string text = string.Format( "{0},   Frags: {1},   Ping: {2} ms", player.Name,
                        player.Frags, (int)( player.Ping * 1000 ) );
                    renderer.AddText( text, new Vec2( .2f, posy ), HorizontalAlign.Left,
                        VerticalAlign.Center );

                    posy += .025f;
                }
            }
        }
Ejemplo n.º 11
0
        protected override void OnRenderUI( GuiRenderer renderer )
        {
            base.OnRenderUI( renderer );

            Vec2I size = GetNeededSize();

            if( browser == null )
                CreateBrowser();

            //update brower engine and texture
            if( browser != null )
            {
                if( viewSize != size /*&& !browser.IsResizing */)
                {
                    var oldSize = viewSize;
                    viewSize = size;
                    OnResized( oldSize, viewSize );
                }

                //create texture
                if( texture == null || textureSize != size )
                {
                    if( texture != null )
                    {
                        texture.Dispose();
                        texture = null;
                    }

                    textureSize = size;

                    string textureName = TextureManager.Instance.GetUniqueName( "WebBrowserControl" );
                    texture = TextureManager.Instance.Create( textureName, Texture.Type.Type2D, textureSize,
                        1, 0, PixelFormat.A8R8G8B8, Texture.Usage.DynamicWriteOnlyDiscardable );
                    forceUpdateTexture = true;
                }

                //update texture
                if( /*browser.IsDirty ||*/ forceUpdateTexture )
                {
                    if( texture != null )
                        UpdateTexture();
                    forceUpdateTexture = false;
                }
            }

            //draw texture
            {
                bool backColorZero = BackColor == new ColorValue( 0, 0, 0, 0 );

                ColorValue color = backColorZero ? new ColorValue( 1, 1, 1 ) : BackColor;
                if( texture == null )
                    color = new ColorValue( 0, 0, 0, color.Alpha );
                color *= GetTotalColorMultiplier();

                color.Clamp( new ColorValue( 0, 0, 0, 0 ), new ColorValue( 1, 1, 1, 1 ) );

                Rect rect;
                GetScreenRectangle( out rect );

                if( renderer.IsScreen && !renderer._OutGeometryTransformEnabled )
                {
                    //screen per pixel accuracy

                    Vec2 viewportSize = renderer.ViewportForScreenGuiRenderer.DimensionsInPixels.Size.ToVec2();

                    Vec2 leftTop = rect.LeftTop;
                    leftTop *= viewportSize;
                    leftTop = new Vec2( (int)( leftTop.X + .9999f ), (int)( leftTop.Y + .9999f ) );
                    if( RenderSystem.Instance.IsDirect3D() )
                        leftTop -= new Vec2( .5f, .5f );
                    leftTop /= viewportSize;

                    Vec2 rightBottom = rect.RightBottom;
                    rightBottom *= viewportSize;
                    rightBottom = new Vec2( (int)( rightBottom.X + .9999f ), (int)( rightBottom.Y + .9999f ) );
                    if( RenderSystem.Instance.IsDirect3D() )
                        rightBottom -= new Vec2( .5f, .5f );
                    rightBottom /= viewportSize;

                    Rect fixedRect = new Rect( leftTop, rightBottom );

                    renderer.AddQuad( fixedRect, new Rect( 0, 0, 1, 1 ), texture, color, true );
                }
                else
                {
                    renderer.AddQuad( rect, new Rect( 0, 0, 1, 1 ), texture, color, true );
                }
            }

            if( !IsSupportedByThisPlatform() )
            {
                renderer.AddText( string.Format( "WebBrowserControl: {0} is not supported.", PlatformInfo.Platform ),
                    new Vec2( .5f, .5f ), Renderer.HorizontalAlign.Center, Renderer.VerticalAlign.Center, new ColorValue( 1, 0, 0 ) );
            }
        }
        private void DrawArea_RenderUI(Control sender, GuiRenderer renderer)
        {
            Rect rectangle = sender.GetScreenRectangle();
            bool clipRectangle = true;
            ColorValue[] colors = new ColorValue[]{
				new ColorValue( 1 ,0, 0 ),
				new ColorValue( 0, 1, 0 ),
				new ColorValue( 0, 0, 1 ),
				new ColorValue( 1, 1, 0 ),
				new ColorValue( 1, 1, 1 )};

            if (clipRectangle)
                renderer.PushClipRectangle(rectangle);

            //draw triangles
            if (GetDrawAreaMode() == DrawAreaModes.Triangles)
            {
                float distance = rectangle.GetSize().X / 2;

                List<GuiRenderer.TriangleVertex> triangles = new List<GuiRenderer.TriangleVertex>(256);

                Radian angle = -EngineApp.Instance.Time;

                const int steps = 30;
                Vec2 lastPosition = Vec2.Zero;
                for (int step = 0; step < steps + 1; step++)
                {
                    Vec2 localPos = new Vec2(MathFunctions.Cos(angle), MathFunctions.Sin(angle)) * distance;
                    Vec2 pos = rectangle.GetCenter() + new Vec2(localPos.X, localPos.Y * renderer.AspectRatio);

                    if (step != 0)
                    {
                        ColorValue color = colors[step % colors.Length];
                        ColorValue color2 = color;
                        color2.Alpha = 0;
                        triangles.Add(new GuiRenderer.TriangleVertex(rectangle.GetCenter(), color));
                        triangles.Add(new GuiRenderer.TriangleVertex(lastPosition, color2));
                        triangles.Add(new GuiRenderer.TriangleVertex(pos, color2));
                    }

                    angle += (MathFunctions.PI * 2) / steps;
                    lastPosition = pos;
                }

                renderer.AddTriangles(triangles);
            }

            //draw quads
            if (GetDrawAreaMode() == DrawAreaModes.Quads)
            {
                //draw background
                {
                    Texture texture = TextureManager.Instance.Load("GUI\\Textures\\NeoAxisLogo.png");
                    renderer.AddQuad(rectangle, new Rect(0, -.3f, 1, 1.4f), texture,
                        new ColorValue(1, 1, 1), true);
                }

                //draw bars
                {
                    float time = EngineApp.Instance.Time;

                    EngineRandom random = new EngineRandom(0);

                    int count = 15;
                    float stepOffset = rectangle.GetSize().X / count;
                    float size = stepOffset * .9f;
                    for (int n = 0; n < count; n++)
                    {
                        float v = MathFunctions.Cos(time * random.NextFloat());
                        float v2 = (v + 1) / 2;

                        ColorValue color = colors[n % colors.Length];
                        Rect rect = new Rect(
                            rectangle.Left + stepOffset * n, rectangle.Bottom - rectangle.GetSize().Y * v2,
                            rectangle.Left + stepOffset * n + size, rectangle.Bottom);
                        renderer.AddQuad(rect, color);
                    }
                }
            }

            //draw lines
            if (GetDrawAreaMode() == DrawAreaModes.Lines)
            {
                float maxDistance;
                {
                    Vec2 s = rectangle.GetSize() / 2;
                    maxDistance = MathFunctions.Sqrt(s.X * s.X + s.Y * s.Y);
                }

                int step = 0;
                float distance = 0;
                Radian angle = -EngineApp.Instance.Time;
                Vec2 lastPosition = Vec2.Zero;

                while (distance < maxDistance)
                {
                    Vec2 localPos = new Vec2(MathFunctions.Cos(angle), MathFunctions.Sin(angle)) * distance;
                    Vec2 pos = rectangle.GetCenter() + new Vec2(localPos.X, localPos.Y * renderer.AspectRatio);

                    if (step != 0)
                    {
                        ColorValue color = colors[step % colors.Length];
                        renderer.AddLine(lastPosition, pos, color);
                    }

                    step++;
                    angle += MathFunctions.PI / 10;
                    distance += .001f;
                    lastPosition = pos;
                }
            }

            //draw text
            if (GetDrawAreaMode() == DrawAreaModes.Text)
            {
                string text;

                //draw text with specified font.
                text = "Map Editor is a tool to create worlds for your project. The tool is a complex editor to manage " +
                    "objects on the map.";
                renderer.AddTextWordWrap(drawAreaBigFont, text, rectangle, HorizontalAlign.Left, false, VerticalAlign.Top, 0,
                    new ColorValue(1, 1, 1));

                //draw text with word wrap.
                text = "Deployment Tool is a tool to deploy the final version of your application to specified platforms. " +
                    "This utility is useful to automate the final product's creation.";
                renderer.AddTextWordWrap(drawAreaSmallFont, text, rectangle, HorizontalAlign.Right, false, VerticalAlign.Bottom, 0,
                    new ColorValue(1, 1, 0));
            }

            if (clipRectangle)
                renderer.PopClipRectangle();
        }
Ejemplo n.º 13
0
		protected override void OnRenderUI(GuiRenderer renderer)
		{
			Rect r = new Rect();
			var pos = this.GetScreenPosition();
			var sz = this.GetScreenSize();
			r.Left = pos.X;
			r.Right = r.Left + sz.X;
			r.Top = pos.Y;
			r.Bottom = r.Top + sz.Y;
			if (mBorderRadius.Value != Vec2.Zero)
			{
#if DebugDraw
				ColorValue debugColor = new ColorValue(0f, 1f, 0f, .5f);
				ColorValue debugColor2 = new ColorValue(0f, 0f, 1f, .5f);
#endif

				Vec2 screenRelRad = this.ScreenFromValue(mBorderRadius);

				// By using clipping and a set of 3 rectangles, we ensure that each point
				// on the screen is only drawn once, thus allowing the alpha value to be
				// used in the color without it looking weird.

				// Top-Left
#if DebugDraw
				renderer.AddCircle(r.LeftTop + screenRelRad, debugColor, screenRelRad, (float)Math.PI, (float)(Math.PI * 1.5f));
#else
				renderer.AddCircle(r.LeftTop + screenRelRad, mColor, screenRelRad, (float)Math.PI, (float)(Math.PI * 1.5f));
#endif

				// Top-Right
#if DebugDraw
				renderer.AddCircle(new Vec2(r.Right - screenRelRad.X, r.Top + screenRelRad.Y), debugColor, screenRelRad, (float)(Math.PI * 1.5f));
#else
				renderer.AddCircle(new Vec2(r.Right - screenRelRad.X, r.Top + screenRelRad.Y), mColor, screenRelRad, (float)(Math.PI * 1.5f));
#endif

				// Bottom-Right
#if DebugDraw
				renderer.AddCircle(new Vec2(r.Right - screenRelRad.X, r.Bottom - screenRelRad.Y), debugColor, screenRelRad, 0f, (float)(Math.PI * 0.5f));
#else
				renderer.AddCircle(new Vec2(r.Right - screenRelRad.X, r.Bottom - screenRelRad.Y), mColor, screenRelRad, 0f, (float)(Math.PI * 0.5f));
#endif

				// Bottom-Left
#if DebugDraw
				renderer.AddCircle(new Vec2(r.Left + screenRelRad.X, r.Bottom - screenRelRad.Y), debugColor, screenRelRad, (float)(Math.PI * 0.5), (float)Math.PI);
#else
				renderer.AddCircle(new Vec2(r.Left + screenRelRad.X, r.Bottom - screenRelRad.Y), mColor, screenRelRad, (float)(Math.PI * 0.5), (float)Math.PI);
#endif

				// Middle-Middle
#if DebugDraw
				renderer.AddQuad(new Rect(r.Left, r.Top + screenRelRad.Y, r.Right, r.Bottom - screenRelRad.Y), debugColor2);
#else
				renderer.AddQuad(new Rect(r.Left, r.Top + screenRelRad.Y, r.Right, r.Bottom - screenRelRad.Y), mColor);
#endif
				// Middle-Top
				renderer.AddQuad(new Rect(r.Left + screenRelRad.X, r.Top, r.Right - screenRelRad.X, r.Top + screenRelRad.Y), mColor);
				// Middle-Bottom
				renderer.AddQuad(new Rect(r.Left + screenRelRad.X, r.Bottom - screenRelRad.Y, r.Right - screenRelRad.X, r.Bottom), mColor);


				if (mBorderWidth.Value != Vec2.Zero)
				{
					Vec2 screenRel = this.ScreenFromValue(mBorderWidth);

					float xHalfWidth = screenRel.X / 2;
					float yHalfWidth = screenRel.Y / 2;
					// Top
					renderer.AddQuad(new Rect(r.Left + screenRelRad.X, r.Top + yHalfWidth, r.Right - screenRelRad.X, r.Top - yHalfWidth), mBorderColor);
					// Right
					renderer.AddQuad(new Rect(r.Right - xHalfWidth, r.Top + screenRelRad.Y, r.Right + xHalfWidth, r.Bottom - screenRelRad.Y), mBorderColor);
					// Bottom
					renderer.AddQuad(new Rect(r.Left + screenRelRad.X, r.Bottom - yHalfWidth, r.Right - screenRelRad.X, r.Bottom + yHalfWidth), mBorderColor);
					// Left
					renderer.AddQuad(new Rect(r.Left - xHalfWidth, r.Top + screenRelRad.Y, r.Left + xHalfWidth, r.Bottom - screenRelRad.Y), mBorderColor);

					// Top-Left
					BezierCurve curve = new BezierCurve();
					curve.AddValue(0, new Vec3(r.Left, r.Top + screenRelRad.Y, 0f));
					curve.AddValue(1, new Vec3(r.LeftTop, 0f));
					curve.AddValue(2, new Vec3(r.Left + screenRelRad.X, r.Top, 0f));
					renderer.AddTriangles(LineRenderer.GenerateTrianglesFromCurve(renderer, curve, 0.1f, screenRel, mBorderColor));

					// Top-Right
					curve = new BezierCurve();
					curve.AddValue(0, new Vec3(r.Right - screenRelRad.X, r.Top, 0f));
					curve.AddValue(1, new Vec3(r.RightTop, 0f));
					curve.AddValue(2, new Vec3(r.Right, r.Top + screenRelRad.Y, 0f));
					renderer.AddTriangles(LineRenderer.GenerateTrianglesFromCurve(renderer, curve, 0.1f, screenRel, mBorderColor));

					// Bottom-Right
					curve = new BezierCurve();
					curve.AddValue(0, new Vec3(r.Right, r.Bottom - screenRelRad.Y, 0f));
					curve.AddValue(1, new Vec3(r.RightBottom, 0f));
					curve.AddValue(2, new Vec3(r.Right - screenRelRad.X, r.Bottom, 0f));
					renderer.AddTriangles(LineRenderer.GenerateTrianglesFromCurve(renderer, curve, 0.1f, screenRel, mBorderColor));

					// Bottom-Left
					curve = new BezierCurve();
					curve.AddValue(0, new Vec3(r.Left + screenRelRad.X, r.Bottom, 0f));
					curve.AddValue(1, new Vec3(r.LeftBottom, 0f));
					curve.AddValue(2, new Vec3(r.Left, r.Bottom - screenRelRad.Y, 0f));
					renderer.AddTriangles(LineRenderer.GenerateTrianglesFromCurve(renderer, curve, 0.1f, screenRel, mBorderColor));
				}
			}
			else
			{
				// Center
				renderer.AddQuad(r, Color);

				if (mBorderWidth.Value != Vec2.Zero)
				{
					Vec2 screenRel = this.ScreenFromValue(mBorderWidth);

					float xHalfWidth = screenRel.X / 2;
					float yHalfWidth = screenRel.Y / 2;
					// Top
					renderer.AddQuad(new Rect(r.Left, r.Top + yHalfWidth, r.Right + xHalfWidth, r.Top - yHalfWidth), mBorderColor);
					// Right
					renderer.AddQuad(new Rect(r.Right - xHalfWidth, r.Bottom + yHalfWidth, r.Right + xHalfWidth, r.Top), mBorderColor);
					// Bottom
					renderer.AddQuad(new Rect(r.Left - xHalfWidth, r.Bottom + yHalfWidth, r.Right, r.Bottom - yHalfWidth), mBorderColor);
					// Left
					renderer.AddQuad(new Rect(r.Left - xHalfWidth, r.Bottom, r.Left + xHalfWidth, r.Top - yHalfWidth), mBorderColor);
				}
			}
		}
Ejemplo n.º 14
0
 private void RenderFadingOut(GuiRenderer renderer)
 {
     if (IsScreenFadingOut())
     {
         if (fadingOutTimer != 0)
         {
             float alpha = 1.0f - fadingOutTimer / fadingTime;
             MathFunctions.Saturate(ref alpha);
             renderer.AddQuad(new Rect(0, 0, 1, 1), new ColorValue(0, 0, 0, alpha));
         }
     }
 }
Ejemplo n.º 15
0
        protected override void OnRenderUI( GuiRenderer renderer )
        {
            base.OnRenderUI( renderer );

            Vec2 size = new Vec2( 512, 215.0f );
            size *= 1.0f + Time * .015f;
            size /= new Vec2( 768.0f * renderer.AspectRatio, 768.0f );

            Rect rectangle = new Rect( -size / 2, size / 2 ) + new Vec2( .5f, .5f );

            float alpha = 0;

            if( Time > 2 && Time <= 3 )
                alpha = Time - 2;
            else if( Time > 3 && Time <= lifeTime - 2 - 2 )
                alpha = 1;
            else if( Time >= lifeTime - 2 - 2 && Time < lifeTime - 1 )
                alpha = 1 - ( Time - ( lifeTime - 2 - 2 ) ) / 3;

            if( alpha != 0 )
                renderer.AddQuad( rectangle, new Rect( 0, 0, 1, 1 ), engineTexture,
                    new ColorValue( 1, 1, 1, alpha ) );
        }
Ejemplo n.º 16
0
        void DrawPlayersStatistics( GuiRenderer renderer )
        {
            if( IsCutSceneEnabled() )
                return;

            if( PlayerManager.Instance == null )
                return;

            renderer.AddQuad( new Rect( .1f, .2f, .9f, .8f ), new ColorValue( 0, 0, 1, .5f ) );

            renderer.AddText( "Players statistics", new Vec2( .5f, .25f ),
                HorizontalAlign.Center, VerticalAlign.Center );

            if( EntitySystemWorld.Instance.IsServer() || EntitySystemWorld.Instance.IsSingle() )
            {
                float posy = .3f;
                ICollection<Entity> icol = Entities.Instance.EntitiesCollection;
                String fact = "";
                foreach( PlayerManager.ServerOrSingle_Player player in
                    PlayerManager.Instance.ServerOrSingle_Players )
                {
                    foreach (Entity ent in icol)
                    {
                        Console.WriteLine(ent.UIN + " : "+ent.NetworkUIN+" : "+ent.Name);
                        Console.WriteLine(player.Identifier + " : " + " : " + player.User.Identifier + " : " + player.Name);

                        if (ent.Name.ToString().Contains("Human"))
                        {
                            fact = "Human";
                        }
                        if (ent.Name.ToString().Contains("Statue") && ent.NetworkUIN.Equals(player.User.Identifier))
                        {
                            fact = "Statue";
                        }

                    }

                    string text = string.Format("{0},   Frags: {1},  Faction: {3},  Ping: {2} ms", player.Name,
                        player.Frags, (int)( player.Ping * 1000 ), fact );
                    renderer.AddText( text, new Vec2( .2f, posy ), HorizontalAlign.Left,
                        VerticalAlign.Center );

                    posy += .025f;
                }
            }

            if( EntitySystemWorld.Instance.IsClientOnly() )
            {
                float posy = .3f;
                ICollection<Entity> icol = Entities.Instance.EntitiesCollection;
                String fact = "";
                foreach( PlayerManager.Client_Player player in PlayerManager.Instance.Client_Players )
                {
                    foreach (Entity ent in icol)
                    {
                        if (ent.Name.ToString().Contains("Human") && ent.UIN.Equals(player.User.Identifier))
                        {
                            fact = "Human";
                        }
                        if (ent.Name.ToString().Contains("Statue") && ent.UIN.Equals(player.User.Identifier))
                        {
                            fact = "Statue";
                        }
                    }

                    string text = string.Format("{0},   Frags: {1},  Faction: {3}, ID: {4}, Ping: {2} ms", player.Name,
                        player.Frags, (int)( player.Ping * 1000 ),  fact, player.Identifier );
                    renderer.AddText( text, new Vec2( .2f, posy ), HorizontalAlign.Left,
                        VerticalAlign.Center );

                    posy += .025f;
                }
            }
        }
Ejemplo n.º 17
0
		public static GuiRenderer.TriangleVertex[] GenerateTrianglesFromCurve(GuiRenderer renderer, Curve curve, float step, Vec2 thickness, ColorValue color)
		{
			float maxTime = curve.Times[curve.Times.Count - 1];
			float end = maxTime + step;

			List<Vec2> points = new List<Vec2>();
			for (float time = 0; time < end; time += step)
			{
				points.Add(curve.CalculateValueByTime(time).ToVec2());
			}

#if DebugDraw
			Vec2 xHalf = new Vec2(thickness.X / 16, 0f);
			Vec2 yHalf = new Vec2(0f, thickness.Y / 16);
			float g = 1f;
			// The green progression here is so we can tell which
			// direction the curve was heading.
			foreach (Vec2 point in points)
			{
				renderer.AddQuad(new Rect(point - xHalf, point + yHalf), new ColorValue(1f, g, 0f));
				g -= 0.05f;
			}
#endif

			return GenerateTriangles(points, thickness, color);
		}
Ejemplo n.º 18
0
        protected override void OnRenderUI(GuiRenderer renderer)
        {
            base.OnRenderUI(renderer);

            Vec2I size = GetNeededSize();

            if (browser == null)
            {
                CreateBrowser();
            }

            //update brower engine and texture
            if (browser != null)
            {
                if (viewSize != size /*&& !browser.IsResizing */)
                {
                    var oldSize = viewSize;
                    viewSize = size;
                    OnResized(oldSize, viewSize);
                }

                //create texture
                if (texture == null || textureSize != size || needRecreateTexture)
                {
                    if (texture != null)
                    {
                        texture.Dispose();
                        texture = null;
                    }

                    textureSize = size;

                    string textureName = TextureManager.Instance.GetUniqueName("WebBrowserControl");

                    bool mipmaps = false;
                    if (GetControlManager() != null && GetControlManager() is In3dControlManager)
                    {
                        mipmaps = inGame3DGuiMipmaps;
                    }

                    if (mipmaps)
                    {
                        texture = TextureManager.Instance.Create(textureName, Texture.Type.Type2D, textureSize,
                                                                 1, -1, PixelFormat.A8R8G8B8, Texture.Usage.DynamicWriteOnlyDiscardable | Texture.Usage.AutoMipmap);
                    }
                    else
                    {
                        texture = TextureManager.Instance.Create(textureName, Texture.Type.Type2D, textureSize,
                                                                 1, 0, PixelFormat.A8R8G8B8, Texture.Usage.DynamicWriteOnlyDiscardable);
                    }

                    needUpdateTexture   = true;
                    needRecreateTexture = false;
                }

                if (needInvalidate)
                {
                    browserHost.SetZoomLevel(zoom);
                    browserHost.Invalidate(CefPaintElementType.View);
                    //browserHost.Invalidate( new CefRectangle( 0, 0, 100000, 100000 ), CefPaintElementType.View );
                    needInvalidate = false;
                }

                //update texture
                if (/*browser.IsDirty ||*/ needUpdateTexture)
                {
                    if (texture != null)
                    {
                        UpdateTexture();
                    }
                    needUpdateTexture = false;
                }
            }

            //draw texture
            if (browser != null)
            {
                bool backColorZero = BackColor == new ColorValue(0, 0, 0, 0);

                ColorValue color = backColorZero ? new ColorValue(1, 1, 1) : BackColor;
                if (texture == null)
                {
                    color = new ColorValue(0, 0, 0, color.Alpha);
                }
                color *= GetTotalColorMultiplier();

                color.Clamp(new ColorValue(0, 0, 0, 0), new ColorValue(1, 1, 1, 1));

                Rect rect;
                GetScreenRectangle(out rect);

                if (renderer.IsScreen && !renderer._OutGeometryTransformEnabled)
                {
                    //screen per pixel accuracy

                    Vec2 viewportSize = renderer.ViewportForScreenGuiRenderer.DimensionsInPixels.Size.ToVec2();

                    Vec2 leftTop = rect.LeftTop;
                    leftTop *= viewportSize;
                    leftTop  = new Vec2((int)(leftTop.X + .9999f), (int)(leftTop.Y + .9999f));
                    if (RenderSystem.Instance.IsDirect3D())
                    {
                        leftTop -= new Vec2(.5f, .5f);
                    }
                    leftTop /= viewportSize;

                    Vec2 rightBottom = rect.RightBottom;
                    rightBottom *= viewportSize;
                    rightBottom  = new Vec2((int)(rightBottom.X + .9999f), (int)(rightBottom.Y + .9999f));
                    if (RenderSystem.Instance.IsDirect3D())
                    {
                        rightBottom -= new Vec2(.5f, .5f);
                    }
                    rightBottom /= viewportSize;

                    Rect fixedRect = new Rect(leftTop, rightBottom);

                    renderer.AddQuad(fixedRect, new Rect(0, 0, 1, 1), texture, color, true);
                }
                else
                {
                    renderer.AddQuad(rect, new Rect(0, 0, 1, 1), texture, color, true);
                }
            }

            if (cefRuntimeUnableToLoad)
            {
                renderer.AddTextWordWrap(
                    string.Format("WebBrowserControl: Unable to initialize web browser control. Error: {0}", cefRuntimeUnableToLoadError),
                    GetScreenRectangle(), Renderer.HorizontalAlign.Center, false, Renderer.VerticalAlign.Center, 0, new ColorValue(1, 0, 0));
            }
            else if (!IsSupportedByThisPlatform())
            {
                renderer.AddText(string.Format("WebBrowserControl: {0} is not supported.", PlatformInfo.Platform),
                                 new Vec2(.5f, .5f), Renderer.HorizontalAlign.Center, Renderer.VerticalAlign.Center, new ColorValue(1, 0, 0));
            }
        }
Ejemplo n.º 19
0
        public void DoRenderUI( GuiRenderer renderer )
        {
            if( transparency == 0.0f )
                return;

            if( firstRender )
            {
                texture = TextureManager.Instance.Load( "Gui\\Various\\Console.dds",
                    Texture.Type.Type2D, 0 );
                font = FontManager.Instance.LoadFont( "Default", .025f );

                firstRender = false;
            }

            if( font == null )
                return;

            Rect textureRect = new Rect( 0, 0, 1, 1 );
            textureRect += textureOffset;

            renderer.AddQuad( new Rect( 0, 0, 1, .5f ), textureRect, texture,
                new ColorValue( 1, 1, 1, transparency ), false, new Rect( 0, 0, 1, 1 ) );
            renderer.AddQuad( new Rect( 0, .495f, 1, .5f ),
                new ColorValue( .8f, .8f, .8f, transparency ) );

            string staticText = "Version " + EngineVersionInformation.Version;
            if( staticText != null && staticText != "" )
            {
                renderer.AddText( font, staticText, new Vec2( .99f, .5f - font.Height ),
                    HorizontalAlign.Right, VerticalAlign.Center, new ColorValue( 1, 1, 1, transparency ) );
            }

            float fontheight = font.Height;

            float x = .01f;

            float y = .5f - fontheight;

            string str;
            if( stringDownPosition != strings.Count - 1 )
            {
                str = "- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -" +
                    " - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -" +
                    " - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -" +
                    " - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -" +
                    " - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -";
            }
            else
                str = currentString + "_";

            renderer.AddText( font, str, new Vec2( x, y ), HorizontalAlign.Left,
                VerticalAlign.Center, new ColorValue( 1, 1, 1, transparency ) );

            y -= fontheight + fontheight * .5f;

            int startpos = stringDownPosition;
            if( startpos > strings.Count - 1 )
                startpos = strings.Count - 1;
            for( int n = startpos; n >= 0 && y - fontheight > 0; n-- )
            {
                renderer.AddText( font, strings[ n ].text, new Vec2( x, y ), HorizontalAlign.Left,
                    VerticalAlign.Center, strings[ n ].color * new ColorValue( 1, 1, 1, transparency ) );
                y -= fontheight;
            }
        }
Ejemplo n.º 20
0
        protected override void OnRenderUI(GuiRenderer renderer)
        {
            base.OnRenderUI(renderer);

            Vec2I size = GetNeededSize();

            if (browser == null)
            {
                CreateBrowser();
            }

            //update brower engine and texture
            if (browser != null)
            {
                if (viewSize != size /*&& !browser.IsResizing */)
                {
                    var oldSize = viewSize;
                    viewSize = size;
                    OnResized(oldSize, viewSize);
                }

                //create texture
                if (texture == null || textureSize != size)
                {
                    if (texture != null)
                    {
                        texture.Dispose();
                        texture = null;
                    }

                    textureSize = size;

                    string textureName = TextureManager.Instance.GetUniqueName("WebBrowserControl");
                    texture = TextureManager.Instance.Create(textureName, Texture.Type.Type2D, textureSize,
                                                             1, 0, PixelFormat.A8R8G8B8, Texture.Usage.DynamicWriteOnlyDiscardable);
                    forceUpdateTexture = true;
                }

                //update texture
                if (/*browser.IsDirty ||*/ forceUpdateTexture)
                {
                    if (texture != null)
                    {
                        UpdateTexture();
                    }
                    forceUpdateTexture = false;
                }
            }

            //draw texture
            {
                bool backColorZero = BackColor == new ColorValue(0, 0, 0, 0);

                ColorValue color = backColorZero ? new ColorValue(1, 1, 1) : BackColor;
                if (texture == null)
                {
                    color = new ColorValue(0, 0, 0, color.Alpha);
                }
                color *= GetTotalColorMultiplier();

                color.Clamp(new ColorValue(0, 0, 0, 0), new ColorValue(1, 1, 1, 1));

                Rect rect;
                GetScreenRectangle(out rect);

                if (renderer.IsScreen && !renderer._OutGeometryTransformEnabled)
                {
                    //screen per pixel accuracy

                    Vec2 viewportSize = renderer.ViewportForScreenGuiRenderer.DimensionsInPixels.Size.ToVec2();

                    Vec2 leftTop = rect.LeftTop;
                    leftTop *= viewportSize;
                    leftTop  = new Vec2((int)(leftTop.X + .9999f), (int)(leftTop.Y + .9999f));
                    if (RenderSystem.Instance.IsDirect3D())
                    {
                        leftTop -= new Vec2(.5f, .5f);
                    }
                    leftTop /= viewportSize;

                    Vec2 rightBottom = rect.RightBottom;
                    rightBottom *= viewportSize;
                    rightBottom  = new Vec2((int)(rightBottom.X + .9999f), (int)(rightBottom.Y + .9999f));
                    if (RenderSystem.Instance.IsDirect3D())
                    {
                        rightBottom -= new Vec2(.5f, .5f);
                    }
                    rightBottom /= viewportSize;

                    Rect fixedRect = new Rect(leftTop, rightBottom);

                    renderer.AddQuad(fixedRect, new Rect(0, 0, 1, 1), texture, color, true);
                }
                else
                {
                    renderer.AddQuad(rect, new Rect(0, 0, 1, 1), texture, color, true);
                }
            }

            if (!IsSupportedByThisPlatform())
            {
                renderer.AddText(string.Format("WebBrowserControl: {0} is not supported.", PlatformInfo.Platform),
                                 new Vec2(.5f, .5f), Renderer.HorizontalAlign.Center, Renderer.VerticalAlign.Center, new ColorValue(1, 0, 0));
            }
        }
Ejemplo n.º 21
0
        public void DoRenderUI(GuiRenderer renderer)
        {
            if (transparency == 0.0f)
            {
                return;
            }

            if (firstRender)
            {
                texture = TextureManager.Instance.Load("Gui\\Various\\Console.dds",
                                                       Texture.Type.Type2D, 0);
                font = FontManager.Instance.LoadFont("Default", .025f);

                firstRender = false;
            }

            if (font == null)
            {
                return;
            }

            Rect textureRect = new Rect(0, 0, 1, 1);

            textureRect += textureOffset;

            renderer.PushClipRectangle(new Rect(0, 0, 1, 1));
            renderer.AddQuad(new Rect(0, 0, 1, .5f), textureRect, texture,
                             new ColorValue(1, 1, 1, transparency), false);
            renderer.PopClipRectangle();
            renderer.AddQuad(new Rect(0, .495f, 1, .5f),
                             new ColorValue(.8f, .8f, .8f, transparency));

            string staticText = "Version " + EngineVersionInformation.Version;

            if (staticText != null && staticText != "")
            {
                renderer.AddText(font, staticText, new Vec2(.99f, .5f - font.Height),
                                 HorizontalAlign.Right, VerticalAlign.Center, new ColorValue(1, 1, 1, transparency));
            }

            float fontheight = font.Height;

            float x = .01f;

            float y = .5f - fontheight;

            string str;

            if (stringDownPosition != strings.Count - 1)
            {
                str = "- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -" +
                      " - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -" +
                      " - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -" +
                      " - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -" +
                      " - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -";
            }
            else
            {
                str = currentString + "_";
            }

            renderer.AddText(font, str, new Vec2(x, y), HorizontalAlign.Left,
                             VerticalAlign.Center, new ColorValue(1, 1, 1, transparency));

            y -= fontheight + fontheight * .5f;

            int startpos = stringDownPosition;

            if (startpos > strings.Count - 1)
            {
                startpos = strings.Count - 1;
            }
            for (int n = startpos; n >= 0 && y - fontheight > 0; n--)
            {
                renderer.AddText(font, strings[n].text, new Vec2(x, y), HorizontalAlign.Left,
                                 VerticalAlign.Center, strings[n].color * new ColorValue(1, 1, 1, transparency));
                y -= fontheight;
            }
        }
Ejemplo n.º 22
0
        private void DisplayTextureOverPosition(Vec3 position, Texture texture, GuiRenderer renderer, ColorValue color)
        {
            Vec2I size = texture.SourceSize / 2;
            float sizeX = (float)size.X / (float)EngineApp.Instance.VideoMode.X;
            float sizeY = (float)size.Y / (float)EngineApp.Instance.VideoMode.Y;

            Vec2 screenPos;
            RendererWorld.Instance.DefaultCamera.ProjectToScreenCoordinates(position, out screenPos);

            if (screenPos.X != 0 && screenPos.Y != 0)
            {
                renderer.AddQuad(new Rect(new Vec2(screenPos.X - sizeX / 2, screenPos.Y - sizeY / 2), new Vec2(screenPos.X + sizeX / 2, screenPos.Y + sizeY / 2)), new Rect(0, 0, 1f, 1f), texture, color);
            }
        }
Ejemplo n.º 23
0
        void DrawHUD( GuiRenderer renderer )
        {
            if( selectMode && selectDraggedMouse )
            {
                Rect rect = new Rect( selectStartPos );
                rect.Add( EngineApp.Instance.MousePosition );

                Vec2i windowSize = EngineApp.Instance.VideoMode.Size;
                Vec2 thickness = new Vec2( 1.0f / (float)windowSize.X, 1.0f / (float)windowSize.Y );

                renderer.AddQuad( new Rect( rect.Left, rect.Top + thickness.Y,
                    rect.Right, rect.Top + thickness.Y * 2 ), new ColorValue( 0, 0, 0, .5f ) );
                renderer.AddQuad( new Rect( rect.Left, rect.Bottom,
                    rect.Right, rect.Bottom + thickness.Y ), new ColorValue( 0, 0, 0, .5f ) );
                renderer.AddQuad( new Rect( rect.Left + thickness.X, rect.Top,
                    rect.Left + thickness.X * 2, rect.Bottom ), new ColorValue( 0, 0, 0, .5f ) );
                renderer.AddQuad( new Rect( rect.Right, rect.Top,
                    rect.Right + thickness.X, rect.Bottom ), new ColorValue( 0, 0, 0, .5f ) );

                renderer.AddQuad( new Rect( rect.Left, rect.Top,
                    rect.Right, rect.Top + thickness.Y ), new ColorValue( 0, 1, 0, 1 ) );
                renderer.AddQuad( new Rect( rect.Left, rect.Bottom - thickness.Y,
                    rect.Right, rect.Bottom ), new ColorValue( 0, 1, 0, 1 ) );
                renderer.AddQuad( new Rect( rect.Left, rect.Top,
                    rect.Left + thickness.X, rect.Bottom ), new ColorValue( 0, 1, 0, 1 ) );
                renderer.AddQuad( new Rect( rect.Right - thickness.X, rect.Top,
                    rect.Right, rect.Bottom ), new ColorValue( 0, 1, 0, 1 ) );
            }
        }
Ejemplo n.º 24
0
        private void RenderFadingIn(GuiRenderer renderer)
        {
            if (fadingInRemainingTime > 0)
            {
                //we are skip some amount of frames because resources can be loaded during it.
                if (fadingInSkipFirstFrames == 0)
                {
                    fadingInRemainingTime -= RendererWorld.Instance.FrameRenderTimeStep;
                    if (fadingInRemainingTime < 0)
                        fadingInRemainingTime = 0;
                }
                else
                    fadingInSkipFirstFrames--;

                float alpha = (float)fadingInRemainingTime / 1;
                MathFunctions.Saturate(ref alpha);
                renderer.AddQuad(new Rect(0, 0, 1, 1), new ColorValue(0, 0, 0, alpha));
            }
        }
Ejemplo n.º 25
0
        protected override void OnRenderUI( GuiRenderer renderer )
        {
            base.OnRenderUI( renderer );

            if( Map.Instance == null )
            {
                renderer.AddQuad( new Rect( 0, 0, 1, 1 ),
                    new ColorValue( .2f, .2f, .2f ) * window.ColorMultiplier );
            }
        }
        public void RenderScreenUI(GuiRenderer renderer)
        {
            for (int viewIndex = 0; viewIndex < views.Count; viewIndex++)
            {
                View view = views[viewIndex];

                //draw view on screen
                if (view.Opacity > 0)
                {
                    renderer.PushTextureFilteringMode(GuiRenderer.TextureFilteringModes.Point);
                    renderer.AddQuad(view.Rectangle, new Rect(0, 0, 1, 1), view.Texture,
                        new ColorValue(1, 1, 1, view.Opacity), true);
                    renderer.PopTextureFilteringMode();
                }

                //draw debug info
                if (drawDebugInfo)
                {
                    Viewport screenViewport = renderer.ViewportForScreenGuiRenderer;
                    Vec2 pixelOffset = 1.0f / screenViewport.DimensionsInPixels.Size.ToVec2();
                    ColorValue color = new ColorValue(1, 1, 0);
                    renderer.AddRectangle(new Rect(
                        view.Rectangle.LeftTop + pixelOffset,
                        view.Rectangle.RightBottom - pixelOffset * 2),
                        color);
                    renderer.AddLine(view.Rectangle.LeftTop, view.Rectangle.RightBottom, color);
                    renderer.AddLine(view.Rectangle.RightTop, view.Rectangle.LeftBottom, color);

                    if (debugFont == null)
                        debugFont = FontManager.Instance.LoadFont("Default", .03f);

                    string sizeString = "";
                    if (view.Texture != null)
                        sizeString = string.Format("{0}x{1}", view.Texture.Size.X, view.Texture.Size.Y);
                    string text = string.Format("View {0}, {1}", viewIndex, sizeString);
                    Vec2 position = new Vec2(view.Rectangle.Right - pixelOffset.X * 5, view.Rectangle.Top);
                    AddTextWithShadow(renderer, debugFont, text, position, HorizontalAlign.Right,
                        VerticalAlign.Top, new ColorValue(1, 1, 1));
                }
            }
        }
Ejemplo n.º 27
0
        private void DisplayTextureOverPosition(Vec2 screenPos, Texture texture, GuiRenderer renderer, ColorValue color)
        {
            Vec2I size = texture.SourceSize / 2;
            float sizeX = (float)size.X / (float)EngineApp.Instance.VideoMode.X;
            float sizeY = (float)size.Y / (float)EngineApp.Instance.VideoMode.Y;

            if (screenPos.X != 0 && screenPos.Y != 0)
            {
                renderer.AddQuad(new Rect(new Vec2(screenPos.X - sizeX / 2, screenPos.Y - sizeY / 2), new Vec2(screenPos.X + sizeX / 2, screenPos.Y + sizeY / 2)), new Rect(0, 0, 1f, 1f), texture, color);
            }
        }
Ejemplo n.º 28
0
        //Draw minimap
        void Minimap_RenderUI( EControl sender, GuiRenderer renderer )
        {
            Rect screenMapRect = sender.GetScreenRectangle();

            Bounds initialBounds = Map.Instance.InitialCollisionBounds;
            Rect mapRect = new Rect( initialBounds.Minimum.ToVec2(), initialBounds.Maximum.ToVec2() );

            Vec2 mapSizeInv = new Vec2( 1, 1 ) / mapRect.Size;

            //draw units
            Vec2 screenPixel = new Vec2( 1, 1 ) / new Vec2( EngineApp.Instance.VideoMode.Size.ToVec2() );

            foreach( Entity entity in Map.Instance.Children )
            {
                RTSUnit unit = entity as RTSUnit;
                if( unit == null )
                    continue;

                Rect rect = new Rect( unit.MapBounds.Minimum.ToVec2(), unit.MapBounds.Maximum.ToVec2() );

                rect -= mapRect.Minimum;
                rect.Minimum *= mapSizeInv;
                rect.Maximum *= mapSizeInv;
                rect.Minimum = new Vec2( rect.Minimum.X, 1.0f - rect.Minimum.Y );
                rect.Maximum = new Vec2( rect.Maximum.X, 1.0f - rect.Maximum.Y );
                rect.Minimum *= screenMapRect.Size;
                rect.Maximum *= screenMapRect.Size;
                rect += screenMapRect.Minimum;

                //increase 1 pixel
                rect.Maximum += new Vec2( screenPixel.X, -screenPixel.Y );

                ColorValue color;

                if( playerFaction == null || unit.Intellect == null || unit.Intellect.Faction == null )
                    color = new ColorValue( 1, 1, 0 );
                else if( playerFaction == unit.Intellect.Faction )
                    color = new ColorValue( 0, 1, 0 );
                else
                    color = new ColorValue( 1, 0, 0 );

                renderer.AddQuad( rect, color );
            }

            //Draw camera borders
            {
                Camera camera = RendererWorld.Instance.DefaultCamera;

                if( camera.Position.Z > 0 )
                {

                    Plane groundPlane = new Plane( 0, 0, 1, 0 );

                    Vec2[] points = new Vec2[ 4 ];

                    for( int n = 0; n < 4; n++ )
                    {
                        Vec2 p = Vec2.Zero;

                        switch( n )
                        {
                        case 0: p = new Vec2( 0, 0 ); break;
                        case 1: p = new Vec2( 1, 0 ); break;
                        case 2: p = new Vec2( 1, 1 ); break;
                        case 3: p = new Vec2( 0, 1 ); break;
                        }

                        Ray ray = camera.GetCameraToViewportRay( p );

                        float scale;
                        groundPlane.RayIntersection( ray, out scale );

                        Vec3 pos = ray.GetPointOnRay( scale );
                        if( ray.Direction.Z > 0 )
                            pos = ray.Origin + ray.Direction.GetNormalize() * 10000;

                        Vec2 point = pos.ToVec2();

                        point -= mapRect.Minimum;
                        point *= mapSizeInv;
                        point = new Vec2( point.X, 1.0f - point.Y );
                        point *= screenMapRect.Size;
                        point += screenMapRect.Minimum;

                        points[ n ] = point;
                    }

                    for( int n = 0; n < 4; n++ )
                        renderer.AddLine( points[ n ], points[ ( n + 1 ) % 4 ], new ColorValue( 1, 1, 1 ),
                            screenMapRect );
                }
            }
        }
        private void DrawFadingScreenQuad(GuiRenderer renderer)
        {
            const float fadeTime = 1;

            float minTimeToPoint;
            {
                //distance to start time.
                minTimeToPoint = demoModeTime;

                float time = 0;
                foreach (MapCameraCurve curve in cameraCurves)
                {
                    float length = curve.GetCurveMaxTime();
                    time += length;

                    float d = Math.Abs(demoModeTime - time);
                    if (d < minTimeToPoint)
                        minTimeToPoint = d;
                }

                //first half second is always black
                if (demoModeTime < .5f)
                    minTimeToPoint = 0;
            }

            //draw fading quad
            if (minTimeToPoint < fadeTime)
            {
                float alpha = minTimeToPoint / fadeTime;
                MathFunctions.Saturate(ref alpha);
                alpha = 1.0f - alpha;
                if (alpha > .001f)
                    renderer.AddQuad(new Rect(0, 0, 1, 1), new ColorValue(0, 0, 0, alpha));
            }
        }
Ejemplo n.º 30
0
		public override void OnRenderScreenUI( GuiRenderer renderer )
		{
			base.OnRenderScreenUI( renderer );

			if( drawTextOnScreen )
			{
				renderer.AddText( "Add-on Example!", new Vec2( .5f, .9f ), HorizontalAlign.Center, VerticalAlign.Top,
					new ColorValue( 1, 0, 0 ) );
				renderer.AddQuad( new Rect( .3f, .94f, .7f, .95f ), new ColorValue( 1, 1, 0 ) );
			}
		}
Ejemplo n.º 31
0
        private void DrawArea_RenderUI(Control sender, GuiRenderer renderer)
        {
            Rect rectangle     = sender.GetScreenRectangle();
            bool clipRectangle = true;

            ColorValue[] colors = new ColorValue[] {
                new ColorValue(1, 0, 0),
                new ColorValue(0, 1, 0),
                new ColorValue(0, 0, 1),
                new ColorValue(1, 1, 0),
                new ColorValue(1, 1, 1)
            };

            if (clipRectangle)
            {
                renderer.PushClipRectangle(rectangle);
            }

            //draw triangles
            if (GetDrawAreaMode() == DrawAreaModes.Triangles)
            {
                float distance = rectangle.GetSize().X / 2;

                List <GuiRenderer.TriangleVertex> triangles = new List <GuiRenderer.TriangleVertex>(256);

                Radian angle = -EngineApp.Instance.Time;

                const int steps        = 30;
                Vec2      lastPosition = Vec2.Zero;
                for (int step = 0; step < steps + 1; step++)
                {
                    Vec2 localPos = new Vec2(MathFunctions.Cos(angle), MathFunctions.Sin(angle)) * distance;
                    Vec2 pos      = rectangle.GetCenter() + new Vec2(localPos.X, localPos.Y * renderer.AspectRatio);

                    if (step != 0)
                    {
                        ColorValue color  = colors[step % colors.Length];
                        ColorValue color2 = color;
                        color2.Alpha = 0;
                        triangles.Add(new GuiRenderer.TriangleVertex(rectangle.GetCenter(), color));
                        triangles.Add(new GuiRenderer.TriangleVertex(lastPosition, color2));
                        triangles.Add(new GuiRenderer.TriangleVertex(pos, color2));
                    }

                    angle       += (MathFunctions.PI * 2) / steps;
                    lastPosition = pos;
                }

                renderer.AddTriangles(triangles);
            }

            //draw quads
            if (GetDrawAreaMode() == DrawAreaModes.Quads)
            {
                //draw background
                {
                    Texture texture = TextureManager.Instance.Load("GUI\\Textures\\NeoAxisLogo.png");
                    renderer.AddQuad(rectangle, new Rect(0, -.3f, 1, 1.4f), texture,
                                     new ColorValue(1, 1, 1), true);
                }

                //draw bars
                {
                    float time = EngineApp.Instance.Time;

                    EngineRandom random = new EngineRandom(0);

                    int   count      = 15;
                    float stepOffset = rectangle.GetSize().X / count;
                    float size       = stepOffset * .9f;
                    for (int n = 0; n < count; n++)
                    {
                        float v  = MathFunctions.Cos(time * random.NextFloat());
                        float v2 = (v + 1) / 2;

                        ColorValue color = colors[n % colors.Length];
                        Rect       rect  = new Rect(
                            rectangle.Left + stepOffset * n, rectangle.Bottom - rectangle.GetSize().Y *v2,
                            rectangle.Left + stepOffset * n + size, rectangle.Bottom);
                        renderer.AddQuad(rect, color);
                    }
                }
            }

            //draw lines
            if (GetDrawAreaMode() == DrawAreaModes.Lines)
            {
                float maxDistance;
                {
                    Vec2 s = rectangle.GetSize() / 2;
                    maxDistance = MathFunctions.Sqrt(s.X * s.X + s.Y * s.Y);
                }

                int    step         = 0;
                float  distance     = 0;
                Radian angle        = -EngineApp.Instance.Time;
                Vec2   lastPosition = Vec2.Zero;

                while (distance < maxDistance)
                {
                    Vec2 localPos = new Vec2(MathFunctions.Cos(angle), MathFunctions.Sin(angle)) * distance;
                    Vec2 pos      = rectangle.GetCenter() + new Vec2(localPos.X, localPos.Y * renderer.AspectRatio);

                    if (step != 0)
                    {
                        ColorValue color = colors[step % colors.Length];
                        renderer.AddLine(lastPosition, pos, color);
                    }

                    step++;
                    angle       += MathFunctions.PI / 10;
                    distance    += .001f;
                    lastPosition = pos;
                }
            }

            //draw text
            if (GetDrawAreaMode() == DrawAreaModes.Text)
            {
                string text;

                //draw text with specified font.
                text = "Map Editor is a tool to create worlds for your project. The tool is a complex editor to manage " +
                       "objects on the map.";
                renderer.AddTextWordWrap(drawAreaBigFont, text, rectangle, HorizontalAlign.Left, false, VerticalAlign.Top, 0,
                                         new ColorValue(1, 1, 1));

                //draw text with word wrap.
                text = "Deployment Tool is a tool to deploy the final version of your application to specified platforms. " +
                       "This utility is useful to automate the final product's creation.";
                renderer.AddTextWordWrap(drawAreaSmallFont, text, rectangle, HorizontalAlign.Right, false, VerticalAlign.Bottom, 0,
                                         new ColorValue(1, 1, 0));
            }

            if (clipRectangle)
            {
                renderer.PopClipRectangle();
            }
        }
Ejemplo n.º 32
0
        public void DoRenderUI()
        {
            GuiRenderer renderer = EngineApp.Instance.ScreenGuiRenderer;

            if (transparency == 0.0f)
            {
                return;
            }

            //load backgrouund texture and font
            if (texture != null && texture.IsDisposed())
            {
                needLoadTextureAndFont = true;
            }
            if (needLoadTextureAndFont)
            {
                texture = TextureManager.Instance.Load("GUI\\Textures\\Console.png", Texture.Type.Type2D, 0);
                font    = FontManager.Instance.LoadFont("Default", .025f);
                needLoadTextureAndFont = false;
            }

            if (font == null)
            {
                return;
            }

            Vec2 viewportSize = renderer.ViewportForScreenGuiRenderer.DimensionsInPixels.Size.ToVec2();
            Vec2 shadowOffset = new Vec2(1, 1) / viewportSize;

            //draw background
            Rect textureRect = new Rect(0, 0, 10 * renderer.AspectRatio, 10 / 2);

            textureRect -= textureOffset;
            renderer.AddQuad(new Rect(0, 0, 1, .5f), textureRect, texture, new ColorValue(1, 1, 1, transparency), false);

            //draw border line
            renderer.AddQuad(new Rect(0, .5f, 1, .508f), new ColorValue(0.29f, 0.6f, 0.86f, 0.9f * transparency));

            //draw background info
            string staticText = string.Format(
                "NeoAxis 3D Engine {0}\r\nPress \"~\" to hide console\r\nPress \"Ctrl + ~\" to hide and disable auto opening",
                EngineVersionInformation.Version);

            renderer.AddTextWordWrap(staticText, new Rect(0, 0, .995f, .495f), HorizontalAlign.Right, false, VerticalAlign.Bottom, 0,
                                     new ColorValue(.5f, .5f, .6f, transparency));

            float fontheight = font.Height;

            float x = .01f;

            float y = .5f - fontheight;

            string str;

            if (stringDownPosition != strings.Count - 1)
            {
                str = "- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -" +
                      " - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -" +
                      " - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -" +
                      " - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -" +
                      " - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -";
            }
            else
            {
                str = currentString + "_";
            }

            renderer.PushClipRectangle(new Rect(0, 0, .975f, 1));
            renderer.AddText(font, str, new Vec2(x, y) + shadowOffset, HorizontalAlign.Left,
                             VerticalAlign.Center, new ColorValue(0, 0, 0, transparency / 2));
            renderer.AddText(font, str, new Vec2(x, y), HorizontalAlign.Left,
                             VerticalAlign.Center, new ColorValue(1, 1, 1, transparency));
            renderer.PopClipRectangle();

            y -= fontheight + fontheight * .5f;

            int startpos = stringDownPosition;

            if (startpos > strings.Count - 1)
            {
                startpos = strings.Count - 1;
            }
            for (int n = startpos; n >= 0 && y - fontheight > 0; n--)
            {
                renderer.AddText(font, strings[n].text, new Vec2(x, y) + shadowOffset, HorizontalAlign.Left,
                                 VerticalAlign.Center, strings[n].color * new ColorValue(0, 0, 0, transparency / 2));
                renderer.AddText(font, strings[n].text, new Vec2(x, y), HorizontalAlign.Left,
                                 VerticalAlign.Center, strings[n].color * new ColorValue(1, 1, 1, transparency));
                y -= fontheight;
            }
        }
Ejemplo n.º 33
0
        void DrawArea_RenderUI( Control sender, GuiRenderer renderer )
        {
            Rect rectangle = sender.GetScreenRectangle();
            bool clipRectangle = true;
            ColorValue[] colors = new ColorValue[]{
                new ColorValue( 1 ,0, 0 ),
                new ColorValue( 0, 1, 0 ),
                new ColorValue( 0, 0, 1 ),
                new ColorValue( 1, 1, 0 ),
                new ColorValue( 1, 1, 1 )};

            if( clipRectangle )
                renderer.PushClipRectangle( rectangle );

            //draw triangles
            if( GetDrawAreaMode() == DrawAreaModes.Triangles )
            {
                float distance = rectangle.GetSize().X / 2;

                List<GuiRenderer.TriangleVertex> triangles = new List<GuiRenderer.TriangleVertex>( 256 );

                Radian angle = -EngineApp.Instance.Time;

                const int steps = 30;
                Vec2 lastPosition = Vec2.Zero;
                for( int step = 0; step < steps + 1; step++ )
                {
                    Vec2 localPos = new Vec2( MathFunctions.Cos( angle ), MathFunctions.Sin( angle ) ) * distance;
                    Vec2 pos = rectangle.GetCenter() + new Vec2( localPos.X, localPos.Y * renderer.AspectRatio );

                    if( step != 0 )
                    {
                        ColorValue color = colors[ step % colors.Length ];
                        ColorValue color2 = color;
                        color2.Alpha = 0;
                        triangles.Add( new GuiRenderer.TriangleVertex( rectangle.GetCenter(), color ) );
                        triangles.Add( new GuiRenderer.TriangleVertex( lastPosition, color2 ) );
                        triangles.Add( new GuiRenderer.TriangleVertex( pos, color2 ) );
                    }

                    angle += ( MathFunctions.PI * 2 ) / steps;
                    lastPosition = pos;
                }

                renderer.AddTriangles( triangles );
            }

            //draw quads
            if( GetDrawAreaMode() == DrawAreaModes.Quads )
            {
                //draw background
                {
                    Texture texture = TextureManager.Instance.Load( "Gui\\Various\\Logo.png" );
                    renderer.AddQuad( rectangle, new Rect( 0, -.3f, 1, 1.4f ), texture,
                        new ColorValue( 1, 1, 1 ), true );
                }

                //draw bars
                {
                    float time = EngineApp.Instance.Time;

                    EngineRandom random = new EngineRandom( 0 );

                    int count = 15;
                    float stepOffset = rectangle.GetSize().X / count;
                    float size = stepOffset * .9f;
                    for( int n = 0; n < count; n++ )
                    {
                        float v = MathFunctions.Cos( time * random.NextFloat() );
                        float v2 = ( v + 1 ) / 2;

                        ColorValue color = colors[ n % colors.Length ];
                        Rect rect = new Rect(
                            rectangle.Left + stepOffset * n, rectangle.Bottom - rectangle.GetSize().Y * v2,
                            rectangle.Left + stepOffset * n + size, rectangle.Bottom );
                        renderer.AddQuad( rect, color );
                    }
                }
            }

            //draw lines
            if( GetDrawAreaMode() == DrawAreaModes.Lines )
            {
                float maxDistance;
                {
                    Vec2 s = rectangle.GetSize() / 2;
                    maxDistance = MathFunctions.Sqrt( s.X * s.X + s.Y * s.Y );
                }

                int step = 0;
                float distance = 0;
                Radian angle = -EngineApp.Instance.Time;
                Vec2 lastPosition = Vec2.Zero;

                while( distance < maxDistance )
                {
                    Vec2 localPos = new Vec2( MathFunctions.Cos( angle ), MathFunctions.Sin( angle ) ) * distance;
                    Vec2 pos = rectangle.GetCenter() + new Vec2( localPos.X, localPos.Y * renderer.AspectRatio );

                    if( step != 0 )
                    {
                        ColorValue color = colors[ step % colors.Length ];
                        renderer.AddLine( lastPosition, pos, color );
                    }

                    step++;
                    angle += MathFunctions.PI / 10;
                    distance += .001f;
                    lastPosition = pos;
                }
            }

            //draw text
            if( GetDrawAreaMode() == DrawAreaModes.Text )
            {
                //draw text with specified font.
                renderer.AddText( drawAreaBigFont, "Big Font Sample", rectangle.LeftTop, HorizontalAlign.Left,
                    VerticalAlign.Top, new ColorValue( 1, 1, 1 ) );

                //draw text with word wrap.
                string text = "Test Test Test.\n\nThe expandable user interface system is a unified system " +
                    "for the creation of end-user controls, menus, dialogues, windows and HUD screens. " +
                    "With the help of this system the end-user exercises control over the application.";
                renderer.AddTextWordWrap( text, rectangle, HorizontalAlign.Right, false, VerticalAlign.Bottom, 0,
                    new ColorValue( 1, 1, 0 ) );
            }

            if( clipRectangle )
                renderer.PopClipRectangle();
        }
Ejemplo n.º 34
0
		void Draw2DRectangles( GuiRenderer renderer )
		{
			Rect rect = new Rect( .01f, .9f, .25f, .99f );
			renderer.AddQuad( rect, new ColorValue( .5f, .5f, .5f, .5f ) );

			Rect rect2 = rect;
			rect2.Expand( new Vec2( .005f / renderer.AspectRatio, .005f ) );
			renderer.AddRectangle( rect2, new ColorValue( 1, 1, 0 ) );

			AddTextWithShadow( renderer, fontMedium, "2D GUI Drawing", rect.GetCenter(), HorizontalAlign.Center,
				VerticalAlign.Center, new ColorValue( 1, 1, 1 ) );
		}
Ejemplo n.º 35
0
        protected override void OnRenderUI(GuiRenderer renderer)
        {
            base.OnRenderUI(renderer);

            Vec2 size = new Vec2(1035.0f / 1024.0f, 235.0f / 768.0f);

            Rect rectangle = new Rect(-size / 2, size / 2) + new Vec2(.5f, .5f);

            float alpha = 0;

            if (Time > 2 && Time <= 3)
                alpha = Time - 2;
            else if (Time > 3 && Time <= lifeTime - 2 - 2)
                alpha = 1;
            else if (Time >= lifeTime - 2 - 2 && Time < lifeTime - 1)
                alpha = 1 - (Time - (lifeTime - 2 - 2)) / 3;

            if (alpha != 0)
            {
                renderer.AddQuad(rectangle, new Rect(0, 0, 1, 1), StudioTexture,
                    new ColorValue(1, 1, 1, alpha));
            }
        }