Beispiel #1
0
            public override void Render(Camera camera)
            {
                if (parent.saveLevelDialog.Active)
                {
                    parent.saveLevelDialog.Render(null);
                }
                else
                {
                    ScreenSpaceQuad ssquad = ScreenSpaceQuad.GetInstance();

                    // This clear is not needed in desktop build but is required to clear z-buffer in WinRT version.
                    // TODO (****) Maybe issue is that z-test should be off for this?
                    InGame.Clear(new Color(20, 20, 20));

                    // Fill the background with the thumbnail if valid.
                    RenderTarget2D smallThumb = InGame.inGame.SmallThumbNail as RenderTarget2D;
                    if (smallThumb != null && !smallThumb.IsDisposed)
                    {
                        SpriteBatch batch = UI2D.Shared.SpriteBatch;
                        batch.Begin(SpriteSortMode.Deferred, BlendState.Opaque);
                        {
                            // Stretch thumbnail across whole screen.  Don't worry about distorting it
                            // since it's blurred anyway.
                            Microsoft.Xna.Framework.Rectangle dstRect = new Microsoft.Xna.Framework.Rectangle((int)BokuGame.ScreenPosition.X, (int)BokuGame.ScreenPosition.Y, (int)BokuGame.ScreenSize.X, (int)BokuGame.ScreenSize.Y);

                            Microsoft.Xna.Framework.Rectangle srcRect;
                            if (BokuGame.ScreenPosition.Y > 0)
                            {
                                // Set srcRect to ignore part of image at top of screen.
                                int y = (int)(BokuGame.ScreenPosition.Y * smallThumb.Height / (float)BokuGame.ScreenSize.Y);
                                srcRect = new Microsoft.Xna.Framework.Rectangle(0, y, smallThumb.Width, smallThumb.Height - y);
                            }
                            else
                            {
                                // Set srcRect to cover full thumbnail.
                                srcRect = new Microsoft.Xna.Framework.Rectangle(0, 0, smallThumb.Width, smallThumb.Height);
                            }
                            batch.Draw(smallThumb, dstRect, srcRect, Color.White);
                        }
                        batch.End();
                    }
                    else
                    {
                        // No thumbnail so just clear to black.
                        InGame.Clear(new Color(20, 20, 20));
                    }

                    InGame.SetViewportToScreen();

                    if (parent.newWorldDialog.Active)
                    {
                        // Hide the dialog if auth UI is active.  Just keeps things cleaner.
                        if (!AuthUI.IsModalActive)
                        {
                            // If options menu is active, render instead of main menu.
                            parent.newWorldDialog.Render(BokuGame.ScreenSize);
                        }
                    }
                    else
                    {
                        // Render menu using local camera.
                        shared.camera.Resolution = new Point((int)BokuGame.ScreenSize.X, (int)BokuGame.ScreenSize.Y);
                        shared.camera.Update();
                        Fx.ShaderGlobals.SetCamera(shared.camera);
                        shared.menu.Render(shared.camera);

                        {
                            CameraSpaceQuad quad = CameraSpaceQuad.GetInstance();
                            // Position Home icon on same baseline as menu title text.
                            // Assume uniform scaling.
                            float height = shared.menu.Height * shared.menu.WorldMatrix.M22;
                            float y      = height / 2.0f - 0.18f;
                            quad.Render(shared.camera, parent.homeTexture, new Vector2(-2.4f, y), new Vector2(1.2f, 1.2f), "TexturedRegularAlpha");
                        }

                        // Render sign out button if user is logged in.
                        Vector2 screenSize = BokuGame.ScreenSize;

                        // Messages will only render if active.
                        parent.saveChangesMessage.Render();
                        parent.saveChangesWithDiscardMessage.Render();
                        parent.shareSuccessMessage.Render();
                        parent.noCommunityMessage.Render();

                        shared.communityShareMenu.Render();

                        HelpOverlay.Render();
                    }
                }
            }   // end of Render()
Beispiel #2
0
            public override void Render(Camera camera)
            {
                GraphicsDevice device = BokuGame.bokuGame.GraphicsDevice;

                HelpOverlay.RefreshTexture();

                RenderTarget2D rt         = UI2D.Shared.RenderTargetDepthStencil1280_720;
                Vector2        screenSize = BokuGame.ScreenSize;
                Vector2        rtSize     = new Vector2(rt.Width, rt.Height);

                if (skipFrames > 0 || shared.waitingForStorage)
                {
                    InGame.Clear(Color.Black);
                    --skipFrames;
                    return;
                }

                shared.liveFeed.FeedSize = shared.liveFeed.ResetScrollBoxSize;
                InGame.SetRenderTarget(rt);

                // Clear the screen & z-buffer.
                InGame.Clear(Color.Black);

                // Apply the background.
                ScreenSpaceQuad quad = ScreenSpaceQuad.GetInstance();

                Vector2 position = Vector2.Zero;

                quad.Render(shared.backgroundTexture, position, rtSize, @"TexturedNoAlpha");

                Color textColor = new Color(21, 125, 178);

                if (parent.newWorldDialog.Active)
                {
                    // Hide the dialog if auth UI is active.  Just keeps things cleaner.
                    if (!AuthUI.IsModalActive)
                    {
                        // If options menu is active, render instead of main menu.
                        parent.newWorldDialog.Render(new Vector2(rt.Width, rt.Height));
                    }
                }
                else if (shared.optionsMenu.Active)
                {
                    // Hide the menu if auth UI is active.  Just keeps things cleaner.
                    if (!AuthUI.IsModalActive)
                    {
                        // If options menu is active, render instead of main menu.
                        shared.optionsMenu.Render();
                    }
                }
                else
                {
                    // Render url
                    SpriteBatch         batch = UI2D.Shared.SpriteBatch;
                    UI2D.Shared.GetFont Font  = UI2D.Shared.GetGameFont24;
                    Vector2             size  = Font().MeasureString(shared.screenUrl);
                    Vector2             pos   = new Vector2(rt.Width / 2 - size.X / 2, 586);
                    batch.Begin();
                    TextHelper.DrawString(Font, shared.screenUrl, pos, textColor);
                    batch.End();
                    shared.urlBox.Set(pos, pos + size);

                    // Hide the menu if auth UI is active.  Just keeps things cleaner.
                    if (!AuthUI.IsModalActive)
                    {
                        // Render menu using local cameras.
                        ShaderGlobals.SetCamera(shared.camera);
                        shared.menu.WorldMatrix = Matrix.CreateTranslation(0.0f, -0.3f, 0.0f);
                        shared.menu.Render(shared.camera);
                    }

                    // Render Boku.
                    ShaderGlobals.SetCamera(shared.bokuCamera);
                    string oldRig = BokuGame.bokuGame.shaderGlobals.PushLightRig(ShaderGlobals.GreeterRigName);

                    // TODO (****) How to temporarily disable point lights???
                    // Do we really need to?
                    //Luz.SetToEffect(true); // disable scene point lights

                    if (BokuGame.bMarsMode)
                    {
                        shared.boku.Movement.Position = new Vector3(-0.0f, 0.25f, -0.5f);
                        shared.boku.ReScale           = 0.50f;

                        //quad = ScreenSpaceQuad.GetInstance();
                        //float wid=shared.jplTexture.Width/2;
                        //position = new Vector2(1250-(wid), 20);
                        //quad.Render(shared.jplTexture, position, new Vector2(wid, shared.jplTexture.Height/2), @"TexturedRegularAlpha");
                    }
                    else
                    {
                        shared.boku.Movement.Position = new Vector3(0.0f, 0.0f, 0.0f);
                    }
                    fVal += 0.01f;

                    // Be sure to set the right camera so the env map looks correct.
                    ShaderGlobals.SetCamera(shared.bokuCamera);

                    shared.boku.RenderObject.Render(shared.bokuCamera);

                    // TODO (****) How to temporarily disable point lights???
                    //Luz.SetToEffect(false); // re-enable scene point lights
                    BokuGame.bokuGame.shaderGlobals.PopLightRig(oldRig);
                }

                InGame.RestoreRenderTarget();

                InGame.Clear(new Color(20, 20, 20));
                InGame.SetViewportToScreen();

                // Copy the rendered scene to the backbuffer.
                {
                    ScreenWarp.FitRtToScreen(rtSize);

                    quad.Render(rt, ScreenWarp.RenderPosition, ScreenWarp.RenderSize, @"TexturedNoAlpha");
                }

                // Render news feed.
                if (!shared.optionsMenu.Active)
                {
                    shared.liveFeed.Render();
                }

                // Hide overlay if auth UI is active.
                if (!AuthUI.IsModalActive)
                {
                    HelpOverlay.Render();
                }

                // Render text dialogs if being shown by OptionsMenu.
                // TODO (****) Need to get rid of rendering to RTs where possible.
                // TODO (****) Need to split OptionsMenu from MainMenu.
                if (shared.optionsMenu.Active)
                {
                    InGame.inGame.shared.smallTextDisplay.Render();
                    InGame.inGame.shared.scrollableTextDisplay.Render();
                }

                MainMenu.Instance.prevSessionCrashedMessage.Render();
                MainMenu.Instance.noCommunityMessage.Render();
                MainMenu.Instance.noSharingMessage.Render();
            }   // end of Render()