} // end of HandleMouseInput() /// <summary> /// Rendering call. /// </summary> public void Render() { if (Active) { // Get screen size. Vector2 screenSize = InGame.GetCurrentRenderTargetSize(); // If no rendertarget, use system size. if (screenSize == Vector2.Zero) { screenSize = BokuGame.ScreenSize; } // Center box on screen. Vector2 size = new Vector2(width, height); pos = (screenSize - size) / 2.0f; ScreenSpaceQuad ssquad = ScreenSpaceQuad.GetInstance(); try { ssquad.Render(diffuse, pos, size, @"TexturedRegularAlpha"); } catch { // Another one of those places where the first time through the system thinks // that the render target is still set on the device and throws an exception // when we try and get the texture. We can catch it here and do nothing since // it will be fine next frame. } } } // end of Render()
} // 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()
} // 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); // Get display size, may be a rt. Vector2 displaySize = BokuGame.ScreenSize; if (useRtCoords) { // Need rt size. displaySize = InGame.GetCurrentRenderTargetSize(); InGame.SetViewportToRendertarget(); } // 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 = (displaySize - 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; // Clamp position to integer coords. pos.X = (int)pos.X; pos.Y = (int)pos.Y; ssquad.Render(UI2D.Shared.RenderTarget512_512, pos, new Vector2(512, 512), "TexturedRegularAlpha"); // // 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(displaySize.X / 2.0f, displaySize.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; int buttonWidth = 48; float totalWidth = aWidth + 1.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); batch.End(); // Restore write to alpha. device.BlendState = BlendState.NonPremultiplied; } } // end of TextDisplay Render()