public override void Render(Camera camera) { GraphicsDevice device = BokuGame.bokuGame.GraphicsDevice; CameraSpaceQuad csquad = CameraSpaceQuad.GetInstance(); ScreenSpaceQuad ssquad = ScreenSpaceQuad.GetInstance(); Color darkTextColor = new Color(20, 20, 20); var size = shared.location.Size; // Render background. var pos = shared.location.Min; if (shared.parent.Active) { var highliteSize = new Vector2(1, 1); ssquad.Render(new Vector4(0, 0, 0, 255), pos - highliteSize, size + (highliteSize * 2)); } ssquad.Render(backgroundTexture, pos, size, @"TexturedRegularAlpha"); var iconOffset = new Vector2(); if (iconTexture != null) { ssquad.Render(iconTexture, pos, new Vector2(iconTexture.Width, iconTexture.Height), @"TexturedRegularAlpha"); iconOffset = new Vector2(iconTexture.Width, iconTexture.Height); } //Setup text clipping var oldViewport = device.Viewport; var newViewport = device.Viewport; newViewport.X = (int)shared.location.Min.X + (int)iconOffset.X; newViewport.Y = (int)shared.location.Min.Y; newViewport.Width = (int)shared.location.Size.X - (int)iconOffset.X; newViewport.Height = (int)shared.location.Size.Y; device.Viewport = newViewport; //handle horizontal scrolling var offset = 0; int curLine, curPos; shared.blob.FindCursorLineAndPosition(out curLine, out curPos); if (curPos > newViewport.Width - 30) { offset = -curPos + ((int)newViewport.Width - 30); } pos = new Vector2(shared.textMargin + offset, shared.textTop + shared.textOffset); //Flash cursor every half second var cursorOn = DateTime.Now.Millisecond > 500 & shared.parent.Active; //Render text shared.blob.RenderWithButtons(pos, darkTextColor, renderCursor: cursorOn); //Restore viewport device.Viewport = oldViewport; } // end of TextInput RenderObj Render()
} // TwitchedOrientation() public void RenderToTexture() { dirty = false; GraphicsDevice device = BokuGame.bokuGame.GraphicsDevice; InGame.SetRenderTarget(rt); InGame.Clear(Color.Black); ScreenSpaceQuad quad = ScreenSpaceQuad.GetInstance(); // Render the thumbnail. if (Thumbnail != null) { // Figure out how much of the thumbnail to crop off since the tiles are square. int crop = (Thumbnail.Width - Thumbnail.Height) / 2; try { quad.Render(Thumbnail, new Vector2(-crop, 0.0f), new Vector2(rt.Width + crop, rt.Height), @"TexturedNoAlpha"); } catch { // At this point what has probably happened is that the thumbnail data has been lost or corrupted // so we need to force it to reload and then set the dirty flag on this element so the rt is redone. // Note: for now setting dirty to true is commented out since it won't cause the thumbnail texture to // reload and just causes perf to die. Probably related to bug #2221 //dirty = true; } } // Render the title. { const int kTextMargin = 10; const int kTextPosY = 150; string title = TextHelper.AddEllipsis(Font, Title, rt.Width - kTextMargin * 2); Vector2 titleSize = Font().MeasureString(title); // Render the title background. quad.Render( new Vector4(0, 0, 0, 0.25f), new Vector2(0, kTextPosY), new Vector2(rt.Width, titleSize.Y)); // Render the title text. SpriteBatch batch = UI2D.Shared.SpriteBatch; batch.Begin(); TextHelper.DrawString(Font, title, new Vector2((rt.Width - titleSize.X) / 2f, kTextPosY), textColor); batch.End(); } InGame.RestoreRenderTarget(); } // end of UIGridLevelElement RenderToTexture()
} // end of Render() /// <summary> /// Renders a colored 3x3 block at the given position. /// </summary> private void Block(Vector4 colorLo, Vector4 colorHi, int i, int j) { ScreenSpaceQuad quad = ScreenSpaceQuad.GetInstance(); Vector2 pos = new Vector2(6, 3) * new Vector2(i, j); Vector2 size = new Vector2(3, 3); quad.Render(colorLo, pos, size); pos.X += 3; quad.Render(colorHi, pos, size); } // end of Block()
} // end of Hide() public void Update() { if (texture == null) { GraphicsDevice device = BokuGame.bokuGame.GraphicsDevice; RenderTarget2D rt = UI2D.Shared.RenderTarget128_128; InGame.SetRenderTarget(rt); InGame.Clear(Color.Transparent); // Background. ScreenSpaceQuad quad = ScreenSpaceQuad.GetInstance(); Texture2D background = BokuGame.Load <Texture2D>(BokuGame.Settings.MediaPath + @"Textures\GridElements\BlackSquare"); quad.Render(background, Vector2.Zero, new Vector2(rt.Width, rt.Height), "TexturedRegularAlpha"); // Y button Vector2 size = new Vector2(64, 64); quad.Render(ButtonTextures.BButton, new Vector2(44, 24), size, "TexturedRegularAlpha"); // Text. Color color = Color.Yellow; SpriteBatch batch = UI2D.Shared.SpriteBatch; UI2D.Shared.GetFont Font = UI2D.Shared.GetGameFont24Bold; Vector2 position = new Vector2(0, 120 - Font().LineSpacing); position.X = 64 - 0.5f * Font().MeasureString(Strings.Localize("editObjectParams.back")).X; batch.Begin(); TextHelper.DrawString(Font, Strings.Localize("editObjectParams.back"), position, color); batch.End(); InGame.RestoreRenderTarget(); texture = new Texture2D(device, 128, 128, false, SurfaceFormat.Color); // Copy rendertarget result into texture. int[] data = new int[128 * 128]; rt.GetData <int>(data); texture.SetData <int>(data); } double now = Time.WallClockTotalSeconds; if (now - showTime < delayTime || hide) { // Still in delay. alpha = 0.0f; } else { // Either in fade or in full view. float t = (float)(now - showTime - delayTime) / fadeTime; alpha = Math.Min(t, 1.0f); } } // end of Update()
} // end of HandleTouchInput() public override void Render(Camera camera) { ScreenSpaceQuad ssquad = ScreenSpaceQuad.GetInstance(); if (BokuGame.RequiresPowerOf2) { ssquad.Render(diffuse, pos, new Vector2(512, 512), @"TexturedRegularAlpha"); } else { ssquad.Render(diffuse, pos, new Vector2(width, height), @"TexturedRegularAlpha"); } } // end of MessageBoxElement Render()
} // end of Show() public void RefreshTexture() { if (dirty) { InGame.SetRenderTarget(diffuse); InGame.Clear(Color.Transparent); ScreenSpaceQuad quad = ScreenSpaceQuad.GetInstance(); // Title. quad.Render(title.Texture, title.Position, title.Size, @"TexturedRegularAlpha"); // The list. Render these bottom to top so if they overlap we're at least // seeing the selected on unobscured. for (int i = textList.Count - 1; i >= 0; i--) { if (!textList[i].Hidden) { TextLine line = textList[i]; quad.Render(line.Texture, line.Position, line.Size, @"TexturedRegularAlpha"); } } // Render the checkmark. Vector2 offset = new Vector2(Margin.X + 2, 5); Vector2 size = new Vector2(40.0f, 40.0f); quad.Render(Checkmark, textList[curIndex].Position + offset, size, @"TexturedRegularAlpha"); // Render help button. if (ShowHelpButton) { int x = (int)width * dpi - 54; int y = (int)textList[textList.Count - 1].Position.Y; // Align with bottom line of text. Vector2 pos = new Vector2(x, y); size = new Vector2(64, 64); quad.Render(ButtonTextures.YButton, pos, size, "TexturedRegularAlpha"); x -= 10 + (int)Font().MeasureString(Strings.Localize("editObjectParams.help")).X; SpriteBatch batch = UI2D.Shared.SpriteBatch; batch.Begin(); TextHelper.DrawStringWithShadow(Font, batch, x, y, Strings.Localize("editObjectParams.help"), textColor, dropShadowColor, invertDropShadow); batch.End(); } // Restore backbuffer. InGame.RestoreRenderTarget(); dirty = false; } } // end of UIGridTextListElement RefreshTexture()
public void Render(Vector2 pos, bool useBatch) { ScreenSpaceQuad ssquad = ScreenSpaceQuad.GetInstance(); SpriteBatch batch = UI2D.Shared.SpriteBatch; Vector2 margin = new Vector2(6, 6); // margin around button graphic. if (bUseFixedSize) { buttonSize = fixedSize; } // Render rectangular buttons if not in gamepad mode or no button/icon graphic is specified. if (GamePadInput.ActiveMode != GamePadInput.InputMode.GamePad || getTexture == null) { Texture2D buttonTexture = UI2D.Shared.BlackButtonTexture; ssquad.Render(buttonTexture, box.Min, box.Max - box.Min, "TexturedRegularAlpha"); } Vector2 min = pos - margin; if (getTexture != null) { ssquad.Render(getTexture(), pos, buttonSize, "TexturedRegularAlpha"); if (!bUseFixedSize) { pos.X += visibleButtonSize.X; } } if (Font != null) { if (useBatch) { TextHelper.DrawString(Font, label, pos + LabelOffset, renderColor); } else { TextHelper.DrawStringNoBatch(Font, label, pos + LabelOffset, renderColor); } } Vector2 max = max = min + GetSize(); max += 2.0f * margin; box.Set(min, max); // Uncomment to debug hit regions. //ssquad.Render(new Vector4(1, 0, 0, 0.5f), min, max - min); } // end of Render()
} // end of TextLine c'tor /// <summary> /// Renders the text string into the texture. /// </summary> private void RefreshTexture() { InGame.SetRenderTarget(diffuse); InGame.Clear(Color.Transparent); Point position = UIGridTextListElement.Margin; // Render the checkbox if needed. if (checkbox) { ScreenSpaceQuad quad = ScreenSpaceQuad.GetInstance(); Vector2 size = new Vector2(40.0f, 40.0f); quad.Render(UIGridTextListElement.Checkbox, new Vector2(position.X, position.Y), size, @"TexturedRegularAlpha"); position.X += (int)size.X; } // Render the text. SpriteBatch batch = UI2D.Shared.SpriteBatch; batch.Begin(); TextHelper.DrawStringWithShadow(Font, batch, position.X, position.Y, text, Color.White, Color.Black, false); batch.End(); // Restore backbuffer. InGame.RestoreRenderTarget(); Size = new Vector2(diffuse.Width, diffuse.Height); } // end of TextLine RefreshTexture()
} // 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 PreGameRacing Update() public override void Render(Camera camera) { ScreenSpaceQuad quad = ScreenSpaceQuad.GetInstance(); Vector2 center = 0.5f * new Vector2(BokuGame.bokuGame.GraphicsDevice.Viewport.Width, BokuGame.bokuGame.GraphicsDevice.Viewport.Height); Vector2 size = new Vector2(256.0f); // Pick the right number texture to show. double dt = Time.WallClockTotalSeconds - startTime; Texture2D texture = texture3; if (dt > 2.0) { texture = texture1; dt -= 2.0f; } else if (dt > 1.0) { texture = texture2; dt -= 1.0f; } size *= 1.0f + 2.0f * (float)dt; center -= 0.5f * size; Vector4 color = new Vector4(1.0f, 1.0f, 1.0f, 1.0f - (float)dt); quad.Render(texture, color, center, size, "TexturedRegularAlpha"); } // end of PreGameRacing Render()
} // end of RenderObj c'tor public override void Render(Camera camera) { // Render the parent's list of objects using our local camera. #if !NETFX_CORE if (shared.player == null) #endif { foreach (RenderObject obj in renderList) { obj.Render(shared.camera); } } #if !NETFX_CORE if (shared.player != null && !shared.player.IsDisposed && shared.player.State == MediaState.Playing) { GraphicsDevice device = BokuGame.bokuGame.GraphicsDevice; device.Clear(Color.Black); ScreenSpaceQuad ssquad = ScreenSpaceQuad.GetInstance(); Texture2D vid = shared.player.GetTexture(); int w = device.Viewport.Width; int h = device.Viewport.Height; float scale = (float)w / vid.Width; Vector2 size = new Vector2(w, vid.Height * scale); Vector2 pos = new Vector2(0, (h - size.Y) / 2.0f); ssquad.Render(vid, pos, size, "TexturedNoAlpha"); } #endif } // end of RenderObj Render()
} // end of Update() /// <summary> /// Rendering call. /// </summary> public void Render() { if (Active) { // Center box on screen. // Note we do this here instead of in the Update call because it is // dependent on the viewport size which may be different at the time // when Update is called versus when Render is called. pos = new Vector2(BokuGame.bokuGame.GraphicsDevice.Viewport.Width, BokuGame.bokuGame.GraphicsDevice.Viewport.Height); pos = (pos - new Vector2(width, height)) * 0.5f; ScreenSpaceQuad ssquad = ScreenSpaceQuad.GetInstance(); try { ssquad.Render(diffuse, pos, new Vector2(width, height), @"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 UIGridModularTextElement Render() private void RefreshRT() { GraphicsDevice device = BokuGame.bokuGame.GraphicsDevice; Vector2 textSize = Font().MeasureString(label); RenderTarget2D textRT = UI2D.Shared.RenderTarget512_302; // If label is too wide for button, render it to an extra RT and shrink it down. int margin = 4; float compressionFactor = (rt.Width - 2 * margin) / textSize.X; // If this is <1 we need to compress. if (compressionFactor < 1.0f) { // Text is too wide... InGame.SetRenderTarget(textRT); device.Clear(Color.Transparent); TextHelper.DrawStringNoBatch(Font, label, new Vector2(1, 1), new Color(textColor)); InGame.RestoreRenderTarget(); } InGame.SetRenderTarget(rt); device.Clear(Color.Transparent); // Button background. Vector2 buttonSize = new Vector2(rt.Width, rt.Height); ScreenSpaceQuad ssquad = ScreenSpaceQuad.GetInstance(); ssquad.Render(tile, Vector2.Zero, buttonSize, "TexturedRegularAlpha"); if (compressionFactor < 1.0f) { // Compress text to fit button. Vector2 pos = new Vector2(margin, (buttonSize.Y - textSize.Y) / 2.0f - 1); Vector2 size = new Vector2(textRT.Width * compressionFactor, textRT.Height); ssquad.Render(textRT, pos, size, "TexturedRegularAlpha"); } else { // Center text onto button. Vector2 pos = (buttonSize - textSize) / 2.0f; TextHelper.DrawStringNoBatch(Font, label, pos, new Color(textColor)); } InGame.RestoreRenderTarget(); } // end of RefreshRT()
/// <summary> /// Rendering call. /// </summary> /// <param name="camera">Ignored.</param> public override void Render(Camera camera) { ScreenSpaceQuad ssquad = ScreenSpaceQuad.GetInstance(); ssquad.Render(diffuse, pos, new Vector2(width, height), @"TexturedRegularAlpha"); shared.descBlob.RenderWithButtons(pos, shared.textColor); } // end of Render()
} // end of UnloadContent() public void Render() { RenderTarget2D rt = Shared.RenderTargetDepthStencil1280_720; ScreenSpaceQuad quad = ScreenSpaceQuad.GetInstance(); // Copy the rendered scene to the backbuffer. quad.Render(rt, ScreenWarp.RenderPosition, ScreenWarp.RenderSize, @"TexturedRegularAlpha"); }
} // end of UIGrid2DCheckboxElement Render() #endregion #region Internal /// <summary> /// If the state of the element has changed, we may need to re-create the texture. /// </summary> private void RefreshTexture() { if (dirty) { InGame.SetRenderTarget(diffuse); InGame.Clear(Color.Transparent); int width = diffuse.Width; int height = diffuse.Height; ScreenSpaceQuad quad = ScreenSpaceQuad.GetInstance(); // Render the checkbox. int margin = 2; Vector2 position = new Vector2(margin, margin); Vector2 size = new Vector2(height - 2.0f * margin, height - 2.0f * margin); Vector4 lightGrey = new Vector4(0.7f, 0.7f, 0.7f, 1.0f); quad.Render(checkbox, lightGrey, position, size, @"TexturedRegularAlpha"); // Render the checkmark. if (check) { quad.Render(checkmark, position, size, @"TexturedRegularAlpha"); } // Render the label text into the texture. margin += (int)size.X + 16; int x = 0; int y = (int)((height - Font().LineSpacing) / 2.0f) - 2; int textWidth = (int)Font().MeasureString(label).X; x = TextHelper.CalcJustificationOffset(margin, width, textWidth, justify); SpriteBatch batch = UI2D.Shared.SpriteBatch; batch.Begin(); TextHelper.DrawStringWithShadow(Font, batch, x, y, label, textColor, dropShadowColor, invertDropShadow); batch.End(); // Restore backbuffer. InGame.RestoreRenderTarget(); dirty = false; } } // end of UIGrid2DCheckboxElement Render()
} // end of ToolTipManager Update() public static void Render(Camera camera) { if (alpha > 0.0f) { ScreenSpaceQuad ssquad = ScreenSpaceQuad.GetInstance(); Vector4 color = new Vector4(1, 1, 1, alpha); ssquad.Render(texture, color, curPosition, size, "TexturedRegularAlphaNoZ"); } } // end of ToolTipManager Render()
public static void Render() { if (InGame.inGame.CurrentUpdateMode != InGame.UpdateMode.RunSim) { return; } float scale = Math.Min((float)BokuGame.bokuGame.GraphicsDevice.Viewport.Height / 1024.0f, 1.0f); int center = BokuGame.bokuGame.GraphicsDevice.Viewport.Width / 2; float overscan = BokuGame.bokuGame.GraphicsDevice.Viewport.Height * XmlOptionsData.OverscanPercent / 200.0f; ScreenSpaceQuad quad = ScreenSpaceQuad.GetInstance(); Vector2 buttonSize = defaultButtonSize * scale; // We adjust for widescreen to keep the buttons close to the far right of the screen float startXPos = 0; if (BokuGame.IsWidescreen) { startXPos = 725 * scale * BokuGame.Graphics.GraphicsDevice.Viewport.AspectRatio; } else { startXPos = 650 * scale * BokuGame.Graphics.GraphicsDevice.Viewport.AspectRatio; } float startYPos = 600 * scale; float xSpacing = 150 * scale; float ySpacing = 150 * scale; Vector2[] buttonsPos = new Vector2[numButtons]; for (int i = 0; i < numButtons; i++) { if (!touchButtonVisibility[i]) { continue; } Vector4 drawColor = GetDrawColor((uint)i); buttonsPos[i] = new Vector2(startXPos, startYPos); buttonsPos[i].X += xSpacing * (i % 2); buttonsPos[i].Y += ySpacing * (i / 2); buttonsPos[i].Y += overscan; touchButtonBoxes[i].Set(buttonsPos[i], buttonsPos[i] + buttonSize); quad.Render(touchButtonTextures[i], drawColor, buttonsPos[i], buttonSize, "TexturedRegularAlpha"); } }
} // end of LiveFeedDisplay Render() #endregion #region Internal private void RenderFeedBasePlate() { GraphicsDevice device = BokuGame.Graphics.GraphicsDevice; 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); Vector2 screenSize = new Vector2( BokuGame.Graphics.GraphicsDevice.Viewport.Width, BokuGame.Graphics.GraphicsDevice.Viewport.Height); Vector2 pos = new Vector2(0.0f, 40.0f); Vector2 baseSize = GetScrollBoxSize; Vector2 iconSize = new Vector2(42.0f, 42.0f); Vector4 baseColor = new Vector4(0.0f, 0.0f, 0.0f, 0.7f); // baseSize.X /= 5; // baseSize.Y *= 0.80f; Vector2 headerSize = baseSize; headerSize.X *= 0.8f; headerSize.Y *= 0.055f; Vector2 headerPos = pos; headerPos.Y -= headerSize.Y; Vector2 cornerSize = new Vector2(headerSize.Y * 0.25f, headerSize.Y * 0.25f); Vector2 titlePos = headerPos + textPosition; titlePos.X += iconSize.X; Vector2 iconPos = iconPosition; iconPos.Y += headerPos.Y; ssquad.Render(baseColor, headerPos, headerSize); ssquad.Render(baseColor, pos, baseSize); ssquad.Render(baseColor, headerPos + new Vector2(headerSize.X, cornerSize.Y), new Vector2(cornerSize.X, headerSize.Y - cornerSize.Y)); ssquad.Render(cornerTR, baseColor, headerPos + new Vector2(headerSize.X, 0.0f), cornerSize, "TexturedRegularAlpha"); ssquad.Render(cornerTR, baseColor, pos + new Vector2(baseSize.X, 0.0f), cornerSize, "TexturedRegularAlpha"); ssquad.Render(cornerBR, baseColor, pos + baseSize - new Vector2(0.0f, cornerSize.Y), cornerSize, "TexturedRegularAlpha"); ssquad.Render(baseColor, pos + new Vector2(baseSize.X, cornerSize.Y), new Vector2(cornerSize.X, baseSize.Y - (cornerSize.Y * 2))); blob.RenderWithButtons(titlePos, greyTextColor, false, UIGridElement.Justification.Center); ssquad.Render(Header_bg, iconPos, iconSize, "TexturedRegularAlpha"); }
private static void RenderFirstPersonHealthBar(GameActor actor, Camera camera, Vector3 forward) { ScreenSpaceQuad quad = ScreenSpaceQuad.GetInstance(); { Vector2 size = new Vector2(BackTexture.Width, BackTexture.Height); // Position at center bottom of screen. Vector2 position = new Vector2((camera.Resolution.X - size.X) / 2, (camera.Resolution.Y - size.Y)); // Adjust for vertical overscan. position.Y -= 40; quad.Render(BackTexture, position, size, "TexturedRegularAlphaNoZ"); } { float lifePct = (float)actor.HitPoints / (float)actor.MaxHitPoints; // Scale the life bar to fit within the background texture (originals are same size). Vector2 size = new Vector2(LifeTexture.Width * kLifeBarScalarX, LifeTexture.Height * kLifeBarScalarY); float yDiff = LifeTexture.Height - size.Y; // Position at center bottom of screen. Vector2 position = new Vector2((camera.Resolution.X - size.X) / 2, camera.Resolution.Y - (size.Y + yDiff / 2)); // Adjust for vertical overscan. position.Y -= 40; // Scale the life bar based on current health. size.X *= lifePct; // Tint life bar based on current health. Vector4 tint = GetLifeTint(lifePct); quad.Render(LifeTexture, tint, position, size, "TexturedRegularAlphaNoZ"); } }
} // end of ThoughtBalloon Update() public void Render(Camera camera) { GraphicsDevice device = BokuGame.bokuGame.GraphicsDevice; if (thinker.FirstPerson) { // In first person just render the ballon to the screen in 2D. ScreenSpaceQuad quad = ScreenSpaceQuad.GetInstance(); Vector2 size = new Vector2(contentTexture.Width, contentTexture.Height); Vector2 position = new Vector2(camera.Resolution.X - size.X, 0); // Adjust for overscan. Vector2 res = new Vector2(camera.Resolution.X, -camera.Resolution.Y); position -= res * 0.5f * 5.0f / 100.0f; quad.Render(contentTexture, position, size, "TexturedPreMultAlpha"); } else { // Cull thought balloons based on the actor's bounding sphere. Note that // bounding spheres are in actor local cooords and so need to be translated // by the actor's position. if (camera.Frustum.CullTest(thinker.BoundingSphere.Center + thinker.Movement.Position, thinker.BoundingSphere.Radius) != Frustum.CullResult.TotallyOutside) { Effect effect = ThoughtBalloonManager.Effect; Matrix worldViewProjMatrix = world * camera.ViewMatrix * camera.ProjectionMatrix; effect.Parameters["WorldViewProjMatrix"].SetValue(worldViewProjMatrix); effect.Parameters["WorldMatrix"].SetValue(world); effect.Parameters["ContentTexture"].SetValue(contentTexture); effect.Parameters["Size"].SetValue(size); effect.Parameters["Alpha"].SetValue(alpha); effect.Parameters["BorderColor"].SetValue(color); device.SetVertexBuffer(vbuf); device.Indices = UI2D.Shared.QuadIndexBuff; // Render all passes. for (int i = 0; i < effect.CurrentTechnique.Passes.Count; i++) { EffectPass pass = effect.CurrentTechnique.Passes[i]; pass.Apply(); device.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0, 4, 0, 2); } } } } // end of ThoughtBalloon Render()
} // end of ToastManager Update() public static void Render() { if (alpha > 0.0f) { ScreenSpaceQuad ssquad = ScreenSpaceQuad.GetInstance(); // Animate in from the bottom as well as fade in/out. Vector4 color = new Vector4(1, 1, 1, alpha); curPosition = targetPosition; float t = 1.0f - alpha; t = TwitchCurve.Apply(t, TwitchCurve.Shape.EaseInOut); curPosition.Y += t * size.Y; ssquad.Render(texture, color, curPosition, size, "TexturedRegularAlphaNoZ"); } } // end of ToastManager Render()
} // end of ThoughtBalloon Activate() public void RefreshTexture() { RenderTarget2D rt = UI2D.Shared.RenderTarget256_256; // // Render the frame and text to the rendertarget. // InGame.SetRenderTarget(rt); ScreenSpaceQuad ssquad = ScreenSpaceQuad.GetInstance(); InGame.Clear(Color.Transparent); // Frame ssquad.Render(ThoughtBalloonManager.FrameTexture, Vector2.Zero, new Vector2(rt.Width, rt.Height), "TexturedRegularAlpha"); int width = 238; TextBlob blob = new TextBlob(UI2D.Shared.GetGameFont30Bold, text, width); blob.Justification = Boku.UI2D.UIGridElement.Justification.Center; if (blob.NumLines > 3) { blob.Font = UI2D.Shared.GetGameFont24Bold; if (blob.NumLines > 3) { blob.Font = UI2D.Shared.GetGameFont24Bold; } } duration = defaultDuration * blob.NumLines; int margin = 8; int middle = 76; // Vertical midpoint of space for text. int lineSpacing = blob.Font().LineSpacing; int numLines = Math.Min(4, blob.NumLines); Vector2 pos = new Vector2(margin, middle - (numLines * 0.5f) * lineSpacing); blob.RenderWithButtons(pos, Color.Black, maxLines: numLines); InGame.RestoreRenderTarget(); // // Copy result to local texture. // rt.GetData <int>(_scratchData); contentTexture.SetData <int>(_scratchData); } // end of ThoughtBalloon RefreshTexture()
public void Render() { if (active) { // Render menu using local camera. Fx.ShaderGlobals.SetCamera(camera); // Darken the background to emphasize to the user that they need to pick a tool. ScreenSpaceQuad ssquad = ScreenSpaceQuad.GetInstance(); ssquad.Render(dropShadowTexture, new Vector4(0, 0, 0, 0.9f), new Vector2(0, 0.6f * BokuGame.ScreenSize.Y), new Vector2(BokuGame.ScreenSize.X, 0.4f * BokuGame.ScreenSize.Y), "TexturedRegularAlpha"); grid.Render(camera); // Render reticule around selected tools tile. CameraSpaceQuad csquad = CameraSpaceQuad.GetInstance(); UIGrid2DTextureElement e = (UIGrid2DTextureElement)grid.SelectionElement; Vector2 position = new Vector2(e.Position.X, e.Position.Y); position.X += grid.WorldMatrix.Translation.X; position.Y += grid.WorldMatrix.Translation.Y; position.Y -= 0.14f; // No clue. Nedd to figure this out. Vector2 size = 2.0f * new Vector2(e.Size.X, e.Size.Y); float alpha = 1.0f; csquad.Render(camera, BasePicker.reticuleTexture, alpha, position, size, @"AdditiveBlend"); // Don't bother with trigger icons if we're modal. if (!XmlOptionsData.ModalToolMenu) { // Trigger icons? double curTime = Time.WallClockTotalSeconds; double dTime = curTime - lastChangedTime; if (dTime > kPreFadeTime) { dTime -= kPreFadeTime; float triggerAlpha = Math.Min((float)(dTime / kFadeTime), 1.0f); Vector2 offset = size * 0.4f; size *= 0.4f; // Note the 12/64 in the positioning accounts for the fact that the // button textures only use the upper 40x40 out of the 64x64 space they allocate. // The 12 is actually (64-40)/2. csquad.Render(camera, ButtonTextures.RightTrigger, triggerAlpha, position + offset + size * 12.0f / 64.0f, size, @"TexturedRegularAlpha"); offset.X = -offset.X; csquad.Render(camera, ButtonTextures.LeftTrigger, triggerAlpha, position + offset + size * 12.0f / 64.0f, size, @"TexturedRegularAlpha"); } } } } // end of ToolMenu Render()
public override void Render(Camera camera) { GraphicsDevice device = BokuGame.bokuGame.GraphicsDevice; // Clear the screen & z-buffer. InGame.Clear(backgroundColor); // Set up params for rendering UI with this camera. BokuGame.bokuGame.shaderGlobals.Effect.Parameters["EyeLocation"].SetValue(new Vector4(shared.camera.From, 1.0f)); BokuGame.bokuGame.shaderGlobals.Effect.Parameters["CameraUp"].SetValue(new Vector4(shared.camera.Up, 1.0f)); // Render the active grid using the local camera. UIGrid curGrid = shared.GetGridFromCurTab(); if (curGrid != null) { curGrid.Render(shared.camera); } // Render the backdrop/frame on top of the grid. ScreenSpaceQuad ssquad = ScreenSpaceQuad.GetInstance(); ssquad.Render(shared.backgroundTexture, new Vector2(0.0f), new Vector2(BokuGame.bokuGame.GraphicsDevice.Viewport.Width - 1.0f, BokuGame.bokuGame.GraphicsDevice.Viewport.Height - 1.0f), @"TexturedRegularAlpha"); // Render the tabs. #if !HIDE_MISSIONS shared.missionsTab.Render(shared.camera); #endif shared.myWorldsTab.Render(shared.camera); shared.starterWorldsTab.Render(shared.camera); shared.downloadsTab.Render(shared.camera); // Render the bottom bar. Well, actually, instead of rendering the bar // we'll just steal the texture from it and render than. shared.bottomBar.Render(shared.camera); CameraSpaceQuad csquad = CameraSpaceQuad.GetInstance(); //csquad.Render(shared.camera, shared.bottomBar.Diffuse.GetTexture(), new Vector2(0.0f, -3.35f), new Vector2(9.5f, 0.5f), @"TexturedRegularAlpha"); // Render the buttons for the bottom bar. if (shared.parent.curTab == Tab.MyWorlds || shared.parent.curTab == Tab.Downloads) { csquad.Render(shared.camera, ButtonTextures.XButton, shared.xButtonPosition, shared.buttonSize, @"TexturedRegularAlpha"); } csquad.Render(shared.camera, ButtonTextures.YButton, shared.yButtonPosition, shared.buttonSize, @"TexturedRegularAlpha"); } // end of LoadLevelMenu RenderObj Render()
} // end of UIGrid2DToolElement Update() public override void Render(Camera camera) { // Render the icon. base.Alpha = iconAlpha; base.Render(camera); // Render the text. ScreenSpaceQuad quad = ScreenSpaceQuad.GetInstance(); // Convert position to screenspace. Point pixels = camera.WorldToScreenCoords(Position + parent.WorldMatrix.Translation); Vector2 pos = new Vector2(pixels.X, pixels.Y); // Calc offset to get text to align correctly with the icon. Basically this is // half the icon size in pixels at 96dpi. float offset = base.Size.Y * 0.5f * 96; pos.Y -= offset; Vector4 color = new Vector4(1.0f, 1.0f, 1.0f, descAlpha); quad.Render(textLine.Texture, color, pos, textLine.Size, @"TexturedRegularAlpha"); } // end of UIGrid2DToolElement Render()
} // end of ActorMenuItem c'tor public override void Render(Camera camera) { base.Render(camera); // Add a text label if it exists and we're not getting the texture from cardspace. if (name != null && !TextureIsFromCardSpace) { UI2D.Shared.GetFont Font = UI2D.Shared.GetCardLabel; SpriteBatch batch = UI2D.Shared.SpriteBatch; Point pixelPos = camera.WorldToScreenCoords(worldMatrix.Translation); Vector2 pos = new Vector2(pixelPos.X, pixelPos.Y); name = TextHelper.FilterInvalidCharacters(name); pos.X -= (int)Font().MeasureString(name).X / 2; pos.Y += 42; Color newBlack = new Color(20, 20, 20); batch.Begin(); TextHelper.DrawString(Font, name, pos, newBlack); batch.End(); } // Show the Y button. if (DisplayHelpButton) { Vector3 loc = MyMath.Lerp(worldMatrix.Translation, pieCenter, 0.4f); Point pixelPos = camera.WorldToScreenCoords(loc); Vector2 pos = new Vector2(pixelPos.X, pixelPos.Y); Vector2 size = new Vector2(BokuGame.bokuGame.GraphicsDevice.Viewport.Height / 12.0f); // Center button. pos -= size * (40.0f / 64.0f) / 2.0f; ScreenSpaceQuad ssquad = ScreenSpaceQuad.GetInstance(); ssquad.Render(ButtonTextures.YButton, pos, size, "TexturedRegularAlpha"); DisplayHelpButton = false; } } // end of ActorMenuItem Render()
} // end of PreGameDesc Update() public override void Render(Camera camera) { Texture2D logoTexture = null; if (!string.IsNullOrEmpty(logo)) { switch (logo) { case "n23": logoTexture = BokuGame.Load <Texture2D>(BokuGame.Settings.MediaPath + @"Textures\NASA_JPL"); break; default: logoTexture = null; break; } } Vector2 pos = Vector2.Zero; pos.X = BokuGame.bokuGame.GraphicsDevice.Viewport.Width / 4.0f; pos.Y = BokuGame.bokuGame.GraphicsDevice.Viewport.Height / 2.0f - blob.NumLines / 2.0f * blob.Font().LineSpacing; if (logoTexture != null) { Vector2 logoSize = new Vector2(logoTexture.Width, logoTexture.Height); ScreenSpaceQuad ssquad = ScreenSpaceQuad.GetInstance(); // Position logo in upper right corner. Vector2 logoPos = new Vector2(BokuGame.bokuGame.GraphicsDevice.Viewport.Width * 0.98f - logoSize.X, BokuGame.bokuGame.GraphicsDevice.Viewport.Width * 0.02f); // Force to be pixel aligned. logoPos.X = (int)logoPos.X; logoPos.Y = (int)logoPos.Y; ssquad.Render(logoTexture, logoPos, logoSize, "TexturedRegularAlpha"); } blob.RenderWithButtons(pos, Color.White, outlineColor: Color.Black, outlineWidth: 1.5f, maxLines: 20); } // end of PreGameDesc Render()
} // end of PreGameRacingWithDesc Update() public override void Render(Camera camera) { if (showingDescription) { Vector2 pos = Vector2.Zero; pos.X = BokuGame.bokuGame.GraphicsDevice.Viewport.Width / 4.0f; pos.Y = BokuGame.bokuGame.GraphicsDevice.Viewport.Height / 2.0f - blob.NumLines / 2.0f * blob.Font().LineSpacing; blob.RenderWithButtons(pos, Color.White, outlineColor: Color.Black, outlineWidth: 1.5f, maxLines: 20); } else { ScreenSpaceQuad quad = ScreenSpaceQuad.GetInstance(); Vector2 center = 0.5f * new Vector2(BokuGame.bokuGame.GraphicsDevice.Viewport.Width, BokuGame.bokuGame.GraphicsDevice.Viewport.Height); Vector2 size = new Vector2(256.0f); // Pick the right number texture to show. double dt = Time.WallClockTotalSeconds - startTime; Texture2D texture = texture3; if (dt > 2.0) { texture = texture1; dt -= 2.0f; } else if (dt > 1.0) { texture = texture2; dt -= 1.0f; } size *= 1.0f + 2.0f * (float)dt; center -= 0.5f * size; Vector4 color = new Vector4(1.0f, 1.0f, 1.0f, 1.0f - (float)dt); quad.Render(texture, color, center, size, "TexturedRegularAlpha"); } } // end of PreGameRacingWithDesc Render()
public override void Render(Camera camera) { Vector2 pos = new Vector2(worldMatrix.Translation.X, worldMatrix.Translation.Y); // Get position of center of tile. pos = camera.WorldToScreenCoordsVector2(new Vector3(pos.X, pos.Y, 0.0f)); // Calc screen space position for underlying tile. Vector2 tileSize = camera.WorldToScreenCoordsVector2(new Vector3(width, -height, 0.0f)) - new Vector2(camera.Resolution.X, camera.Resolution.Y) / 2.0f; Vector2 tilePos = pos - tileSize / 2.0f; // Render tile. ScreenSpaceQuad ssquad = ScreenSpaceQuad.GetInstance(); ssquad.Render(rt, tilePos, tileSize, "TexturedRegularAlpha"); /* * // Calc position of text and render. * pos -= Font().MeasureString(label) / 2.0f; * * TextHelper.DrawStringNoBatch(Font, label, pos, new Color(textColor)); */ } // end of UIGridModularTextElement Render()