コード例 #1
0
        }   // end of Deactivate()

        public void Update()
        {
            touchedThisFrame = false;
            if (active)
            {
                InGame.SetViewportToScreen();

                camera.Resolution = new Point((int)BokuGame.ScreenSize.X, (int)BokuGame.ScreenSize.Y);
                camera.Recalc();
                camera.Update();

                Matrix matrix = Matrix.Identity;
                brightnessSlider.Update(ref matrix);
                durationSlider.Update(ref matrix);
                ledGrid.Update(ref matrix);
                bar.Update(ref matrix);

                switch (GamePadInput.ActiveMode)
                {
                case GamePadInput.InputMode.GamePad:
                    HandleGamePad();
                    break;

                case GamePadInput.InputMode.Touch:
                    HandleTouch();
                    break;

                case GamePadInput.InputMode.KeyboardMouse:
                    HandleMouse();
                    break;
                }

                // Adjust alpha value for stick icons if needed.
                float targetAlpha = GamePadInput.ActiveMode == GamePadInput.InputMode.GamePad ? 1.0f : 0.0f;
                if (targetAlpha != _stickAlpha)
                {
                    _stickAlpha = targetAlpha;
                    TwitchManager.Set <float> set = delegate(float value, Object param) { stickAlpha = value; };
                    TwitchManager.CreateTwitch <float>(stickAlpha, _stickAlpha, set, 0.2f, TwitchCurve.Shape.EaseOut);
                }

                // touchedThisFrame = true;
            }
        }   // end of Update()
コード例 #2
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()
コード例 #3
0
        }   // end of PreRender()

        public void Render()
        {
            if (Active)
            {
                GraphicsDevice device = BokuGame.bokuGame.GraphicsDevice;

                RenderTarget2D rtFull = UI2D.Shared.RenderTargetDepthStencil1024_768;   // Rendertarget we render whole display into.
                RenderTarget2D rt1k   = UI2D.Shared.RenderTarget1024_768;

                Vector2 rtSize = new Vector2(rtFull.Width, rtFull.Height);

                CameraSpaceQuad csquad = CameraSpaceQuad.GetInstance();
                ScreenSpaceQuad ssquad = ScreenSpaceQuad.GetInstance();

                Color darkTextColor  = new Color(20, 20, 20);
                Color greyTextColor  = new Color(127, 127, 127);
                Color greenTextColor = new Color(8, 123, 110);
                Color whiteTextColor = new Color(255, 255, 255);

                // Render the scene to our rendertarget.
                InGame.SetRenderTarget(rtFull);

                // Clear to transparent.
                InGame.Clear(Color.Transparent);


                // Set up params for rendering UI with this camera.
                Fx.ShaderGlobals.SetCamera(camera);

                Vector2 pos;

                // Now render the background tiles.
                Vector2 backgroundSize = new Vector2(backgroundTexture.Width, backgroundTexture.Height);
                pos = (rtSize - backgroundSize) / 2.0f;
                ssquad.Render(backgroundTexture, pos, backgroundSize, @"TexturedRegularAlpha");

                displayPosition = pos;

                // Now render the contents of the rt1k texture but with the edges blended using the mask.
                Vector2 rt1kSize = new Vector2(rt1k.Width, rt1k.Height);
                pos -= new Vector2(40, 70);
                try//minimize bug fix.
                {
                    Vector4 limits = new Vector4(0.095f, 0.112f, 0.57f, 0.64f);
                    ssquad.RenderWithYLimits(rt1k, limits, pos, rt1kSize, @"TexturedPreMultAlpha");
                }
                catch
                {
                    return;
                }

                //
                // Add button icons with labels.
                //

                SpriteBatch batch = UI2D.Shared.SpriteBatch;
                Vector2     min; // Used to capture info for mouse hit boxes.
                Vector2     max;

                batch.Begin();
                {
                    // Calc center position.
                    pos = new Vector2(rtSize.X / 2.0f, rtSize.Y / 2.0f + backgroundSize.Y * 0.28f);

                    // Calc overall width buttons and text.  Leave a button width's space between each section.
                    float aWidth      = Font().MeasureString(Strings.Localize("toast.continue")).X;
                    float xWidth      = Font().MeasureString(Strings.Localize("toast.dismiss")).X;
                    int   buttonWidth = 48;
                    float totalWidth  = aWidth + xWidth + 3.0f * buttonWidth;

                    pos.X -= totalWidth / 2.0f;

                    // A button
                    min = pos;
                    ssquad.Render(ButtonTextures.AButton, pos, new Vector2(56, 56), @"TexturedRegularAlpha");
                    pos.X += buttonWidth;
                    TextHelper.DrawString(Font, Strings.Localize("toast.continue"), pos, labelAColor);
                    max = new Vector2(pos.X + aWidth, min.Y + buttonWidth);
                    hitBoxA.Set(min, max);

                    pos.X += aWidth;

                    // Space
                    pos.X += buttonWidth;

                    // X button
                    min = pos;
                    ssquad.Render(ButtonTextures.XButton, pos, new Vector2(56, 56), @"TexturedRegularAlpha");
                    pos.X += buttonWidth;
                    TextHelper.DrawString(Font, Strings.Localize("toast.dismiss"), pos, labelBColor);
                    max = new Vector2(pos.X + xWidth, min.Y + buttonWidth);
                    hitBoxB.Set(min, max);
                }
                batch.End();

                // Add left stick if needed.
                if (blob.NumLines >= textVisibleLines)
                {
                    pos = displayPosition + new Vector2(-31, 300);
                    ssquad.Render(leftStick, pos, new Vector2(leftStick.Width, leftStick.Height), "TexturedRegularAlpha");
                    min = pos;
                    max = min + new Vector2(leftStick.Width, leftStick.Height / 2.0f);
                    upBox.Set(min, max);
                    min.Y  = max.Y;
                    max.Y += leftStick.Height / 2.0f;
                    downBox.Set(min, max);
                }

                InGame.RestoreRenderTarget();
                InGame.SetViewportToScreen();

                // No put it all together.
                // Start with the background.
                if (useBackgroundThumbnail)
                {
                    if (!thumbnail.GraphicsDevice.IsDisposed && !thumbnail.IsDisposed)
                    {
                        // Render the blurred thumbnail (if valid) full screen.
                        if (!thumbnail.GraphicsDevice.IsDisposed)
                        {
                            InGame.RestoreViewportToFull();
                            Vector2 screenSize = new Vector2(device.Viewport.Width, device.Viewport.Height);
                            ssquad.Render(thumbnail, Vector2.Zero, screenSize, @"TexturedNoAlpha");
                            InGame.SetViewportToScreen();
                        }
                    }
                    else
                    {
                        // No valid thumbnail, clear to dark.
                        device.Clear(darkTextColor);
                    }
                }

                // Calc scaling and position for rt.
                renderPosition = Vector2.Zero;
                renderScale    = 1.0f;

                // The part of the dialog we care about is 1024x600 so we want to use
                // that as the size to fit to the screen.
                Vector2 dialogSize = new Vector2(1024, 600);
                Vector2 scale      = BokuGame.ScreenSize / dialogSize;
                renderScale = Math.Min(Math.Min(scale.X, scale.Y), 1.0f);
                Vector2 renderSize = rt1kSize * renderScale;

                // Center on screen.
                renderPosition = (BokuGame.ScreenSize - renderSize) / 2.0f;

                ssquad.Render(rtFull, renderPosition, renderSize, @"TexturedRegularAlpha");
            }
        }   // end of ScrollableModalHint Render()
コード例 #4
0
        }   // end of PreRender()

        public void Render()
        {
            if (Active)
            {
                GraphicsDevice device = BokuGame.bokuGame.GraphicsDevice;

                RenderTarget2D rtFull = UI2D.Shared.RenderTargetDepthStencil1024_768;   // Rendertarget we render whole display into.
                Vector2        rtSize = new Vector2(rtFull.Width, rtFull.Height);

                ScreenSpaceQuad ssquad = ScreenSpaceQuad.GetInstance();

                Color darkTextColor  = new Color(20, 20, 20);
                Color greyTextColor  = new Color(127, 127, 127);
                Color greenTextColor = new Color(8, 123, 110);
                Color whiteTextColor = new Color(255, 255, 255);

                // No put it all together.
                // Start with the background.
                Vector2 screenSize = BokuGame.ScreenSize;
                if (useRtCoords)
                {
                    // Need the size of the RT instead.
                    screenSize = InGame.GetCurrentRenderTargetSize();
                    Debug.Assert(screenSize != Vector2.Zero);
                }

                if (useBackgroundThumbnail)
                {
                    if (!thumbnail.GraphicsDevice.IsDisposed && !thumbnail.IsDisposed)
                    {
                        // Render the blurred thumbnail (if valid) full screen.
                        if (!thumbnail.GraphicsDevice.IsDisposed)
                        {
                            InGame.RestoreViewportToFull();
                            ssquad.Render(thumbnail, Vector2.Zero, screenSize, @"TexturedNoAlpha");
                            InGame.SetViewportToScreen();
                        }
                    }
                    else
                    {
                        // No valid thumbnail, clear to dark.
                        device.Clear(darkTextColor);
                    }
                }

                // Calc scaling and position for rt.
                renderPosition = Vector2.Zero;
                renderScale    = 1.0f;

                // The part of the dialog we care about is 1024x600 so we want to use
                // that as the size to fit to the screen.
                Vector2 dialogSize = new Vector2(1024, 600);
                Vector2 scale      = screenSize / dialogSize;
                renderScale = Math.Min(Math.Min(scale.X, scale.Y), 1.0f);
                Vector2 renderSize = rtSize * renderScale;

                // Center on screen.
                renderPosition = (screenSize - renderSize) / 2.0f;

                // Clamp to pixel coords.
                renderPosition.X = (int)renderPosition.X;
                renderPosition.Y = (int)renderPosition.Y;

                ssquad.Render(rtFull, renderPosition, renderSize, @"TexturedRegularAlpha");
            }
        }   // end of ScrollableTextDisplay Render()
コード例 #5
0
        }   // end of HandleKeyboardMouse()

        public void Render()
        {
            if (active)
            {
                GraphicsDevice device     = BokuGame.bokuGame.GraphicsDevice;
                SpriteBatch    batch      = UI2D.Shared.SpriteBatch;
                Vector2        screenSize = BokuGame.ScreenSize;

                InGame.SetViewportToScreen();

                // Render dialog using local camera.
                Fx.ShaderGlobals.SetCamera(camera);

                device.Clear(ClearOptions.DepthBuffer | ClearOptions.Target, new Color(20, 20, 20), 1.0f, 0);

                // Start by using the blurred version of the scene as a backdrop.
                // If no thumbnail use the black we just cleared to.
                if (thumbnail != null && !thumbnail.IsDisposed && !thumbnail.GraphicsDevice.IsDisposed)
                {
                    batch.Begin(SpriteSortMode.Immediate, BlendState.NonPremultiplied);
                    {
                        Rectangle rect = new Rectangle(0, 0, (int)screenSize.X, (int)screenSize.Y);
                        batch.Draw(thumbnail, rect, Color.White);
                    }
                    batch.End();
                }

                brightnessSlider.Render(camera);
                durationSlider.Render(camera);
                ledGrid.Render(camera);
                bar.Render(camera);

                // If in GamePad input mode, render left and right stick icons.
                // Actual rendering is done based on alpha.
                if (stickAlpha > 0)
                {
                    CameraSpaceQuad csquad = CameraSpaceQuad.GetInstance();
                    Vector2         size   = new Vector2(0.6f, 1.0f);

                    csquad.Render(camera, leftStickTexture, stickAlpha, leftStickPosition, size, "TexturedRegularAlpha");
                    csquad.Render(camera, rightStickTexture, stickAlpha, rightStickPosition, size, "TexturedRegularAlpha");
                }

                // Buttons
                {
                    float margin = 32;
                    // Start with lower bar.
                    Vector3 screen = new Vector3(bar.Position.X, bar.Position.Y, 0);
                    // Convert to pixels.
                    Vector2 barPos = camera.WorldToScreenCoordsVector2(screen);
                    // Find right edge.
                    Vector2 pos = barPos;
                    pos.X += bar.Width / 2.0f * camera.DPI;
                    float barHeight = bar.Height * camera.DPI;
                    // Center on bar.
                    Vector2 size = cancelButton.GetSize();
                    pos.Y -= size.Y / 2.0f;

                    pos.X -= size.X + 2 * margin;

                    cancelButton.Render(pos, useBatch: false);
                    size   = saveButton.GetSize();
                    pos.X -= size.X + margin;
                    saveButton.Render(pos, useBatch: false);

                    // Find left edge for Toggle button.
                    pos.X = barPos.X - bar.Width / 2.0f * camera.DPI + margin;
                    toggleLEDButton.Render(pos, useBatch: false);
                }
            } // end if active
        }     // end of Render()
コード例 #6
0
ファイル: MainMenu.cs プロジェクト: eanders-MS/KoduGameLab-1
            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()
コード例 #7
0
            public override void Render(Camera camera)
            {
                // Clear the screen.
                InGame.Clear(Color.Black);

                InGame.SetViewportToScreen();

                // Display current help screen.
                // Basically we're goin to shrink or stretch it to ensure that it is fully displayed without
                // having its aspect ratio changed.
                Vector2 imgSize = new Vector2(shared.curTexture.Width, shared.curTexture.Height);
                Vector2 ratios  = imgSize / BokuGame.ScreenSize;
                float   scale   = 1.0f / Math.Max(ratios.X, ratios.Y);
                Vector2 size    = imgSize * scale;
                Vector2 pos     = (BokuGame.ScreenSize - imgSize * scale) / 2.0f;

                ScreenSpaceQuad quad = ScreenSpaceQuad.GetInstance();

                pos.X += shared.pushOffset;
                quad.Render(shared.curTexture, pos, imgSize * scale, "TexturedNoAlpha");

                // If pushing, also render the previous help screen.
                if (shared.prevTexture != null && shared.pushOffset != 0)
                {
                    float offset = -Math.Sign(shared.pushOffset) * BokuGame.ScreenSize.X;
                    pos.X += offset;
                    quad.Render(shared.prevTexture, pos, imgSize, "TexturedNoAlpha");
                }

                // Label with page number in lower right hand corner.
                if (shared.curScreen >= 0 && shared.curScreen < shared.screenList.Count)
                {
                    // Start with far right corner and subtract off what we don't need.
                    pos = BokuGame.ScreenSize;

                    string str = (shared.curScreen + 1).ToString() + @"/" + shared.screenList.Count.ToString();

                    // Add in arrow buttons for mouse navigation.
                    size  = new Vector2(shared.rightArrowTexture.Width, shared.rightArrowTexture.Height);
                    size *= 0.5f;

                    // And add a bit of a margin.
                    pos -= new Vector2(30, 10 + UI2D.Shared.GameFont18Bold.LineSpacing);

                    // Right arrow.
                    pos.X -= size.X;
                    quad.Render(shared.rightArrowTexture, pos, size, "TexturedRegularAlpha");
                    shared.rightArrowBox.Set(pos, pos + size);

                    // Adjust for length of string.
                    pos.X -= UI2D.Shared.GameFont18Bold.MeasureString(str).X;

                    SpriteBatch batch = UI2D.Shared.SpriteBatch;
//                    Color blueText = new Color(12, 150, 209);
                    Color blueText = new Color(241, 221, 83);
                    Color shadow   = new Color(4, 50, 70);
//                    Color highlight = new Color(200, 230, 240);
                    Color highlight = new Color(255, 255, 240);
                    batch.Begin();
                    // shadow
                    TextHelper.DrawString(UI2D.Shared.GetGameFont18Bold, str, pos + new Vector2(1, 1), shadow);
                    // other dirs.
                    TextHelper.DrawString(UI2D.Shared.GetGameFont18Bold, str, pos + new Vector2(1, -1), shadow);
                    TextHelper.DrawString(UI2D.Shared.GetGameFont18Bold, str, pos + new Vector2(-1, 1), shadow);
                    // highlight
                    TextHelper.DrawString(UI2D.Shared.GetGameFont18Bold, str, pos + new Vector2(-1, -1), highlight);
                    // Front face
                    TextHelper.DrawString(UI2D.Shared.GetGameFont18Bold, str, pos, blueText);
                    batch.End();

                    // Left arrow.
                    pos.X -= size.X;
                    quad.Render(shared.leftArrowTexture, pos, size, "TexturedRegularAlpha");
                    shared.leftArrowBox.Set(pos, pos + size);

                    //Back button
                    //some padding on left of screen
                    pos.X = 30;
                    quad.Render(shared.backTexture, pos, size, "TexturedRegularAlpha");
                    shared.backBox.Set(pos, pos + size);
                }
            }
コード例 #8
0
        public void PreRender()
        {
            RenderTarget2D rt = Shared.RenderTargetDepthStencil1280_720;

            Vector2 rtSize = new Vector2(rt.Width, rt.Height);

            ScreenWarp.FitRtToScreen(rtSize);

            // Render the scene to our rendertarget.
            InGame.SetRenderTarget(rt);
            InGame.Clear(Color.Transparent);

            // Set up params for rendering UI with this camera.
            ShaderGlobals.SetCamera(camera);

            ScreenSpaceQuad quad = ScreenSpaceQuad.GetInstance();

            SpriteBatch batch = Shared.SpriteBatch;

            var center    = new Vector2(640, 360);
            var dialogMin = center - new Vector2(dialogWidth / 2, dialogHeight / 2);
            var dialogMax = center + new Vector2(dialogWidth / 2, dialogHeight / 2);


            // Top and bottom of dialog.
            var     size = new Vector2(dialogWidth, whiteTop.Height);
            Vector2 pos  = dialogMin;

            quad.Render(whiteTop, new Vector4(0, 0, 0, 1), pos, size, "TexturedRegularAlpha");
            pos += new Vector2(0, dialogHeight - 16);
            quad.Render(whiteBottom, new Vector4(0, 0, 0, 1), pos, size, "TexturedRegularAlpha");

            //dialog center
            size    = new Vector2(dialogWidth, dialogHeight);
            pos     = dialogMin;
            pos.Y  += 16;
            size.Y  = dialogHeight - 32;
            pos.X  += 1; //to match size of top and bottom pieces
            size.X -= 2; //
            quad.Render(new Vector4(0, 0, 0, 1), pos, size);

            //top and bottom highlights
            int highlightMargin = 3;

            pos    = dialogMin + new Vector2(highlightMargin, 2);
            size.X = dialogWidth - 2 * highlightMargin;
            size.Y = 30;
            quad.Render(blackHighlight, new Vector4(1, 1, 1, 0.2f), pos, size, "AdditiveBlendWithAlpha");

            pos    = dialogMin + new Vector2(highlightMargin, dialogHeight - 60);
            size.X = dialogWidth - 2 * highlightMargin;
            size.Y = 30;
            quad.Render(blackHighlight, new Vector4(1, 1, 1, 0.2f), pos, size, "AdditiveBlendWithAlpha");

            batch.Begin();

            //Dialog title.
            TextHelper.DrawString(Shared.GetGameFont20, title, dialogMin + new Vector2(10, 10 + 5), Color.White);

            //Ok and Cancel buttons
            var buttonSize = cancelButton.GetSize();

            pos = dialogMax - buttonSize - new Vector2(10, 10);
            cancelButton.Render(pos);

            buttonSize = okButton.GetSize();
            pos       -= new Vector2(buttonSize.X + 20, 0);
            okButton.Render(pos);

            batch.End();

            // Render text box
            textLineEditor.Render(camera);

            InGame.RestoreRenderTarget();

            InGame.SetViewportToScreen();
        }   // end of Render()
コード例 #9
0
        }   // end of HandleMouseInput()

        public void Render()
        {
            if (Active)
            {
                GraphicsDevice device = BokuGame.bokuGame.GraphicsDevice;
                InGame.SetViewportToScreen();

                ScreenSpaceQuad ssquad = ScreenSpaceQuad.GetInstance();

                Color darkTextColor  = new Color(20, 20, 20);
                Color greyTextColor  = new Color(127, 127, 127);
                Color greenTextColor = new Color(8, 123, 110);
                Color whiteTextColor = new Color(255, 255, 255);

                // Start with the background.
                if (useBackgroundThumbnail)
                {
                    if (!thumbnail.GraphicsDevice.IsDisposed && !thumbnail.IsDisposed)
                    {
                        // Render the blurred thumbnail (if valid) full screen.
                        if (!thumbnail.GraphicsDevice.IsDisposed)
                        {
                            InGame.RestoreViewportToFull();
                            Vector2 screenSize = new Vector2(device.Viewport.Width, device.Viewport.Height);
                            ssquad.Render(thumbnail, Vector2.Zero, screenSize, @"TexturedNoAlpha");
                            InGame.SetViewportToScreen();
                        }
                    }
                    else
                    {
                        // No valid thumbnail, clear to dark.
                        device.Clear(darkTextColor);
                    }
                }

                //
                // Background frame.
                //
                Vector2 size = new Vector2(backgroundTexture.Width, backgroundTexture.Height);
                renderPosition = (BokuGame.ScreenSize - size) / 2.0f;

                ssquad.Render(backgroundTexture, renderPosition, size, "TexturedRegularAlpha");

                //
                // Text.
                //

                // Disable write to alpha.
                device.BlendState = UI2D.Shared.BlendStateColorWriteRGB;

                Vector2 pos        = renderPosition;
                int     blankLines = maxLines - blob.NumLines;
                pos.Y += blankLines / 2.0f * Font().LineSpacing;
                blob.RenderWithButtons(pos + textPosition, greyTextColor);

                //
                // Add button icons with labels.
                //

                SpriteBatch batch = UI2D.Shared.SpriteBatch;
                batch.Begin();

                Vector2 min;    // Used to capture info for mouse hit boxes.
                Vector2 max;

                // Calc center position.
                pos = new Vector2(BokuGame.ScreenSize.X / 2.0f, BokuGame.ScreenSize.Y / 2.0f + size.Y / 2.0f - 1.8f * Font().LineSpacing);

                // Calc overall width buttons and text.  Leave a button width's space between each section.
                float aWidth      = Font().MeasureString(Strings.Localize("toast.continue")).X;
                float xWidth      = Font().MeasureString(Strings.Localize("toast.dismiss")).X;
                int   buttonWidth = 48;
                float totalWidth  = aWidth + xWidth + 3.0f * buttonWidth;

                pos.X -= totalWidth / 2.0f;

                // A button
                min = pos;
                ssquad.Render(ButtonTextures.AButton, pos, new Vector2(56, 56), @"TexturedRegularAlpha");
                pos.X += buttonWidth;
                TextHelper.DrawString(Font, Strings.Localize("toast.continue"), pos, labelAColor);
                max = new Vector2(pos.X + aWidth, min.Y + buttonWidth);
                hitBoxA.Set(min, max);

                pos.X += aWidth;

                // Space
                pos.X += buttonWidth;

                // X button
                min = pos;
                ssquad.Render(ButtonTextures.XButton, pos, new Vector2(56, 56), @"TexturedRegularAlpha");
                pos.X += buttonWidth;
                TextHelper.DrawString(Font, Strings.Localize("toast.dismiss"), pos, labelBColor);
                max = new Vector2(pos.X + xWidth, min.Y + buttonWidth);
                hitBoxB.Set(min, max);

                batch.End();

                // Restore write to alpha.
                device.BlendState = BlendState.AlphaBlend;
            }
        }   // end of ModalHint Render()