public void CalcSize() { size.X = 2.0f * margin.X + ItemFont().MeasureString(text).X; size.Y = 2.75f * margin.Y + ItemFont().LineSpacing; hitBox.Set(absolutePosition, absolutePosition + size); } // end of CalcSize()
} // end of GetSize() public void Update(Camera camera) { if (!active) { return; } if (GamePadInput.ActiveMode != GamePadInput.InputMode.GamePad) { if (indexFocusedItem < (scrollItems.Count)) { scrollItems[indexFocusedItem].DisableFocus(); } } uiCamera.Update(); //HandleGamepadInput(); Vector2 boxPos = GetBoxPos() + relativePosition; scrollBoxHit.Set(new AABB2D(boxPos, boxPos + ScrollBoxSize)); ConstrainScrollBox(scrollOffset); //handle input *after* the scroll box has been updated //without this, the bounding box won't be properly updated (as done in the preceding few lines) //it works for mouse since this code is called every frame the mouse is over the feed //it *doesnt* work for touch, since this code is only called when a touch occurs (we don't have a hover equivalent) //this way, it works for both HandleMouseInput(camera); HandleTouchInput(); } // end of Update
/// <summary> /// /// </summary> /// <returns>Returns true if autorepeating.</returns> public bool Update() { bool result = false; hitBox.Set(position, position + size); // If pressed, see if touch is still active. If not, clear pressed state. if (Pressed) { TouchContact touch = TouchInput.GetOldestTouch(); if (touch == null || touch.phase == TouchPhase.Ended) { Pressed = false; } // If previously pressed, check for possible autorepeat. // Don't do this for keys with delegates (transition keys). // They should never autorepeat. if (Pressed && OnKey == null) { // Waited long enough to autorepeat? if (Time.GameTimeTotalSeconds - timeOfLastPress >= GamePadInput.Button.AutoRepeatDelay) { if (Time.GameTimeTotalSeconds - timeOfLastRepeat >= 1.0 / GamePadInput.Button.AutoRepeatRate) { // Trigger an autorepeat. result = true; timeOfLastRepeat = Time.GameTimeTotalSeconds; } } } } return(result); } // end of Update()
public void TestSet() { AABB2D aabb = new AABB2D(-Vector2.one, Vector2.one); aabb.Reset(); Assert.IsTrue(aabb.IsEmpty()); Assert.AreEqual(aabb.min, new Vector2(99999f, 99999f)); Assert.AreEqual(aabb.max, new Vector2(-99999f, -99999f)); aabb.Set(Vector2.one); Assert.AreEqual(aabb.min, Vector2.one); Assert.AreEqual(aabb.max, Vector2.one); }
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()
public void Update() { if (active) { string s = ""; s += Strings.Localize("auth.creator") + " : " + Auth.CreatorName; blob.RawText = s; float scale = 0.75f; Vector2 size = new Vector2(blob.GetLineWidth(0), tileTexture.Height * scale); // Add some extra width to allow the text to be centered horizontally. size.X += 32; Vector2 upperRightCorner = new Vector2((int)BokuGame.ScreenPosition.X + (int)BokuGame.ScreenSize.X, 0); Vector2 pos = upperRightCorner - new Vector2(size.X, 0); // Add a bit of a margin from the top of the screen. pos += new Vector2(-8, 8); pos = pos.Truncate(); hitBox.Set(pos, pos + size); tileRect = new Rectangle((int)pos.X, (int)pos.Y, (int)size.X, (int)size.Y); // // Input? // if (GamePadInput.ActiveMode == GamePadInput.InputMode.Touch) { for (int i = 0; i < TouchInput.TouchCount; i++) { TouchContact touch = TouchInput.GetTouchContactByIndex(i); Vector2 touchHit = touch.position; HandleTouchInput(touch, touchHit); } } else if (GamePadInput.ActiveMode == GamePadInput.InputMode.KeyboardMouse) { Vector2 hit = MouseInput.PositionVec; HandleMouseInput(hit); } else if (GamePadInput.ActiveMode == GamePadInput.InputMode.GamePad) { // Do nothing. Since signing in requires keyboard/mouse it // really doesn't make sense to partially support gamepad. } } } // end of Update()
public void Draw(Vector2 position) { blob.RenderWithButtons(position, TextColor); // Set hitbox. Note that the coordinates for the hitbox are relative // to the upper left hand corner of the rendertarget we're currently // drawing to, not the screen. Need to adjust when hit testing. Vector2 size = new Vector2(blob.Font().MeasureString(blob.ScrubbedText).X, blob.TotalSpacing); hitBox.Set(position, position + size); /* * // Debug highlight of hyperlink hitbox. * ScreenSpaceQuad ssquad = ScreenSpaceQuad.GetInstance(); * ssquad.Render(new Vector4(1, 0, 0, 0.5f), position, size); */ }
private static void RefreshTexture() { RenderTarget2D rt = UI2D.Shared.RenderTargetDepthStencil1280_720; ScreenSpaceQuad quad = ScreenSpaceQuad.GetInstance(); InGame.SetRenderTarget(rt); InGame.Clear(Color.Transparent); bool showTeam = (ActiveTeam != Classification.Colors.NotApplicable); bool showPlayer = ActivePlayer != GamePadSensor.PlayerId.Dynamic; if (showTeam || showPlayer) { // Main graphic. Vector2 size = new Vector2(textureWinner.Width, textureWinner.Height); Vector2 pos = new Vector2((rt.Width - size.X) / 2.0f, 0.0f); quad.Render(textureWinner, pos, size, "TexturedPreMultAlpha"); // Team or Player. size = new Vector2(textureTeam.Width, textureTeam.Height); pos = new Vector2((rt.Width - size.X) / 2.0f, 354); quad.Render(textureTeam, pos, size, "TexturedPreMultAlpha"); string label = String.Empty; if (showTeam) { label = Strings.Localize("gameOver.team") + " "; } if (showPlayer) { // Nothing to add here. } // Get correct color for team. Texture2D glyph = null; switch (ActivePlayer) { case GamePadSensor.PlayerId.One: glyph = CardSpace.Cards.CardFaceTexture("filter.player1"); label += CardSpace.Cards.GetLabel("filter.player1"); break; case GamePadSensor.PlayerId.Two: glyph = CardSpace.Cards.CardFaceTexture("filter.player2"); label += CardSpace.Cards.GetLabel("filter.player2"); break; case GamePadSensor.PlayerId.Three: glyph = CardSpace.Cards.CardFaceTexture("filter.player3"); label += CardSpace.Cards.GetLabel("filter.player3"); break; case GamePadSensor.PlayerId.Four: glyph = CardSpace.Cards.CardFaceTexture("filter.player4"); label += CardSpace.Cards.GetLabel("filter.player4"); break; default: // Do nothing... break; } switch (ActiveTeam) { case Classification.Colors.White: glyph = CardSpace.Cards.CardFaceTexture("filter.white"); label += Strings.Localize("colorNames.white"); break; case Classification.Colors.Black: glyph = CardSpace.Cards.CardFaceTexture("filter.Black"); label += Strings.Localize("colorNames.black"); break; case Classification.Colors.Grey: glyph = CardSpace.Cards.CardFaceTexture("filter.Grey"); label += Strings.Localize("colorNames.grey"); break; case Classification.Colors.Red: glyph = CardSpace.Cards.CardFaceTexture("filter.red"); label += Strings.Localize("colorNames.red"); break; case Classification.Colors.Green: glyph = CardSpace.Cards.CardFaceTexture("filter.green"); label += Strings.Localize("colorNames.green"); break; case Classification.Colors.Blue: glyph = CardSpace.Cards.CardFaceTexture("filter.blue"); label += Strings.Localize("colorNames.blue"); break; case Classification.Colors.Orange: glyph = CardSpace.Cards.CardFaceTexture("filter.orange"); label += Strings.Localize("colorNames.orange"); break; case Classification.Colors.Yellow: glyph = CardSpace.Cards.CardFaceTexture("filter.yellow"); label += Strings.Localize("colorNames.yellow"); break; case Classification.Colors.Purple: glyph = CardSpace.Cards.CardFaceTexture("filter.purple"); label += Strings.Localize("colorNames.purple"); break; case Classification.Colors.Pink: glyph = CardSpace.Cards.CardFaceTexture("filter.pink"); label += Strings.Localize("colorNames.pink"); break; case Classification.Colors.Brown: glyph = CardSpace.Cards.CardFaceTexture("filter.brown"); label += Strings.Localize("colorNames.brown"); break; default: break; } // Grabbing the glyph from CardSpace may have changed rendertargets // since we now create them somewhat on demand. InGame.SetRenderTarget(rt); if (glyph != null) { size = new Vector2(90, 90); pos += new Vector2(7, 10); quad.Render(glyph, pos, size, "TexturedPreMultAlpha"); } // Options. if (GamePadInput.ActiveMode == GamePadInput.InputMode.GamePad) { size = new Vector2(textureOptions.Width, textureOptions.Height); pos = new Vector2((rt.Width - size.X) / 2.0f, 470); quad.Render(textureOptions, pos, size, "TexturedPreMultAlpha"); } else { size = new Vector2(textureOptionsKey.Width, textureOptionsKey.Height); pos = new Vector2((rt.Width - size.X) / 2.0f, 470); quad.Render(textureOptionsKey, pos, size, "TexturedPreMultAlpha"); // Add key face icons. Color color = new Color(20, 20, 20); TextBlob blob = new TextBlob(UI2D.Shared.GetGameFont20, "[home]", 100); blob.Justification = Boku.UI2D.UIGridElement.Justification.Center; pos.Y += 16; blob.RenderWithButtons(pos, color); homeHitBox.Set(pos, pos + new Vector2(100, blob.TotalSpacing)); blob.RawText = "[esc]"; pos.Y += 50; blob.RenderWithButtons(pos, color); editHitBox.Set(pos, pos + new Vector2(100, blob.TotalSpacing)); blob.RawText = "[enter]"; pos.Y += 50; blob.RenderWithButtons(pos, color); restartHitBox.Set(pos, pos + new Vector2(100, blob.TotalSpacing)); } // Add button labels. SpriteBatch batch = UI2D.Shared.SpriteBatch; UI2D.Shared.GetFont Font = UI2D.Shared.GetGameFont24Bold; //Color fontColor = new Color(10, 75, 108); Color fontColor = new Color(127, 127, 127); Color shadowColor = new Color(0, 0, 0, 20); Vector2 shadowOffset = new Vector2(0, 6); // Disable writing to alpha channel. // This prevents transparent fringing around the text. GraphicsDevice device = BokuGame.bokuGame.GraphicsDevice; device.BlendState = UI2D.Shared.BlendStateColorWriteRGB; if (label != null) { // Center the team name. int len = (int)Font().MeasureString(label).X; pos = new Vector2(565, 386); pos.X += (textureTeam.Width - textureTeam.Height - len) / 2; TextHelper.DrawStringNoBatch(Font, label, pos + shadowOffset, shadowColor); TextHelper.DrawStringNoBatch(Font, label, pos, fontColor); } pos = new Vector2(572, 482); TextHelper.DrawStringNoBatch(Font, Strings.Localize("gameOver.browse"), pos + shadowOffset, shadowColor); TextHelper.DrawStringNoBatch(Font, Strings.Localize("gameOver.browse"), pos, fontColor); pos.Y += 51; TextHelper.DrawStringNoBatch(Font, Strings.Localize("gameOver.edit"), pos + shadowOffset, shadowColor); TextHelper.DrawStringNoBatch(Font, Strings.Localize("gameOver.edit"), pos, fontColor); pos.Y += 51; TextHelper.DrawStringNoBatch(Font, Strings.Localize("gameOver.restart"), pos + shadowOffset, shadowColor); TextHelper.DrawStringNoBatch(Font, Strings.Localize("gameOver.restart"), pos, fontColor); // Restore default blend state. device.BlendState = BlendState.AlphaBlend; } if (ActiveWinner) { // Main graphic. Vector2 size = new Vector2(textureWinner.Width, textureWinner.Height); Vector2 pos = new Vector2((rt.Width - size.X) / 2.0f, 0.0f); quad.Render(textureWinner, pos, size, "TexturedPreMultAlpha"); // Options. if (GamePadInput.ActiveMode == GamePadInput.InputMode.GamePad) { size = new Vector2(textureOptions.Width, textureOptions.Height); pos = new Vector2((rt.Width - size.X) / 2.0f, 470); quad.Render(textureOptions, pos, size, "TexturedPreMultAlpha"); } else { size = new Vector2(textureOptionsKey.Width, textureOptionsKey.Height); pos = new Vector2((rt.Width - size.X) / 2.0f, 470); quad.Render(textureOptionsKey, pos, size, "TexturedPreMultAlpha"); // Add key face icons. Color color = new Color(20, 20, 20); TextBlob blob = new TextBlob(UI2D.Shared.GetGameFont20, "[home]", 100); blob.Justification = Boku.UI2D.UIGridElement.Justification.Center; pos.Y += 16; blob.RenderWithButtons(pos, color); homeHitBox.Set(pos, pos + new Vector2(100, blob.TotalSpacing)); blob.RawText = "[esc]"; pos.Y += 50; blob.RenderWithButtons(pos, color); editHitBox.Set(pos, pos + new Vector2(100, blob.TotalSpacing)); blob.RawText = "[enter]"; pos.Y += 50; blob.RenderWithButtons(pos, color); restartHitBox.Set(pos, pos + new Vector2(100, blob.TotalSpacing)); } // Add button labels. SpriteBatch batch = UI2D.Shared.SpriteBatch; UI2D.Shared.GetFont Font = UI2D.Shared.GetGameFont24Bold; Color fontColor = new Color(10, 75, 108); pos = new Vector2(572, 482); TextHelper.DrawStringNoBatch(Font, Strings.Localize("gameOver.browse"), pos, fontColor); pos.Y += 51; TextHelper.DrawStringNoBatch(Font, Strings.Localize("gameOver.edit"), pos, fontColor); pos.Y += 51; TextHelper.DrawStringNoBatch(Font, Strings.Localize("gameOver.restart"), pos, fontColor); } if (ActiveGameOver) { // Main graphic. Vector2 size = new Vector2(textureGameOver.Width, textureGameOver.Height); Vector2 pos = new Vector2((rt.Width - size.X) / 2.0f, 0.0f); quad.Render(textureGameOver, pos, size, "TexturedPreMultAlpha"); // Options. if (GamePadInput.ActiveMode == GamePadInput.InputMode.GamePad) { size = new Vector2(textureOptions.Width, textureOptions.Height); pos = new Vector2((rt.Width - size.X) / 2.0f, 470); quad.Render(textureOptions, pos, size, "TexturedPreMultAlpha"); } else { size = new Vector2(textureOptionsKey.Width, textureOptionsKey.Height); pos = new Vector2((rt.Width - size.X) / 2.0f, 470); quad.Render(textureOptionsKey, pos, size, "TexturedPreMultAlpha"); // Add key face icons. Color color = new Color(20, 20, 20); TextBlob blob = new TextBlob(UI2D.Shared.GetGameFont20, "[home]", 100); blob.Justification = Boku.UI2D.UIGridElement.Justification.Center; pos.Y += 16; blob.RenderWithButtons(pos, color); homeHitBox.Set(pos, pos + new Vector2(100, blob.TotalSpacing)); blob.RawText = "[esc]"; pos.Y += 50; blob.RenderWithButtons(pos, color); editHitBox.Set(pos, pos + new Vector2(100, blob.TotalSpacing)); blob.RawText = "[enter]"; pos.Y += 50; blob.RenderWithButtons(pos, color); restartHitBox.Set(pos, pos + new Vector2(100, blob.TotalSpacing)); } // Add button labels. SpriteBatch batch = UI2D.Shared.SpriteBatch; UI2D.Shared.GetFont Font = UI2D.Shared.GetGameFont24Bold; Color fontColor = new Color(10, 75, 108); pos = new Vector2(572, 482); TextHelper.DrawStringNoBatch(Font, Strings.Localize("gameOver.browse"), pos, fontColor); pos.Y += 51; TextHelper.DrawStringNoBatch(Font, Strings.Localize("gameOver.edit"), pos, fontColor); pos.Y += 51; TextHelper.DrawStringNoBatch(Font, Strings.Localize("gameOver.restart"), pos, fontColor); } InGame.RestoreRenderTarget(); dirty = false; } // end of RefreshTexture()
} // end of HandleMouseInput() /// <summary> /// Renders the dialog into a rendertarget. This happens during Update() phase so /// that we don't need to swap rendertargets during the Render call. This allows /// the dialog to be safely rendered into the scene when the scene itself is being /// rendered into a rendertarget. /// </summary> private void PreRender() { GraphicsDevice device = BokuGame.bokuGame.GraphicsDevice; // // First, render the text into a rendertarget. // RenderTarget2D rt1k = UI2D.Shared.RenderTarget1024_768; 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 text into the 1k rendertarget. InGame.SetRenderTarget(rt1k); InGame.Clear(Color.Transparent); // Set up params for rendering UI with this camera. Fx.ShaderGlobals.SetCamera(camera); // // Text. // // If we don't have enough text to go into scrolling, center vertically. int centering = 0; if (blob.NumLines < textVisibleLines) { centering += (int)(blob.TotalSpacing * (textVisibleLines - blob.NumLines) / 2.0f); } Vector2 pos; pos = new Vector2(textMargin, textTop + textOffset + centering); int startLine = 0; if (textOffset < 0) { startLine = -(int)(textOffset / blob.TotalSpacing); pos.Y += startLine * blob.TotalSpacing; } // Clamp to pixel coords. pos.X = (int)pos.X; pos.Y = (int)pos.Y; blob.RenderWithButtons(pos, greyTextColor, startLine: startLine, maxLines: textVisibleLines + 2); InGame.RestoreRenderTarget(); // // Second, render all the chrome with the text into the final rendertarget. RenderTarget2D rtFull = UI2D.Shared.RenderTargetDepthStencil1024_768; // Rendertarget we render whole display into. // 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 rtSize = new Vector2(rtFull.Width, rtFull.Height); // Now render the background tiles. Vector2 backgroundSize = new Vector2(backgroundTexture.Width, backgroundTexture.Height); pos = (rtSize - backgroundSize) / 2.0f; // Clamp to pixel coords. pos.X = (int)pos.X; pos.Y = (int)pos.Y; 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); // Clamp to nearest pixel; pos.X = (int)pos.X; pos.Y = (int)pos.Y; try//minimize bug fix. { Vector4 limits = new Vector4(0.095f, 0.112f, 0.57f, 0.64f); ssquad.RenderWithYLimits(rt1k, limits, pos, rt1kSize, @"TexturedRegularAlpha"); } catch { InGame.RestoreRenderTarget(); return; } // // Add button icon with label. // SpriteBatch batch = UI2D.Shared.SpriteBatch; Vector2 min; // Used to capture info for mouse hit boxes. Vector2 max; batch.Begin(); { pos = new Vector2(rtSize.X / 2.0f, rtSize.Y / 2.0f + backgroundSize.Y * 0.28f); int buttonWidth = 48; pos.X -= (Font().MeasureString(Strings.Localize("textDialog.continue")).X + buttonWidth) / 2.0f; // Also account for B button if we have one. int margin = 24; if (!string.IsNullOrEmpty(textB)) { pos.X -= (Font().MeasureString(textB).X + buttonWidth + margin) / 2.0f; } min = pos; // Render the A button and it's label. ssquad.Render(ButtonTextures.AButton, pos, new Vector2(56, 56), @"TexturedRegularAlpha"); pos.X += buttonWidth; max = new Vector2(pos.X + Font().MeasureString(Strings.Localize("textDialog.continue")).X, min.Y + buttonWidth); hitBoxA.Set(min, max); TextHelper.DrawString(Font, Strings.Localize("textDialog.continue"), pos, labelAColor); pos.X += Font().MeasureString(Strings.Localize("textDialog.continue")).X + margin; min = pos; // Render the B button and it's label. if (!string.IsNullOrEmpty(textB)) { ssquad.Render(ButtonTextures.BButton, pos, new Vector2(56, 56), @"TexturedRegularAlpha"); pos.X += buttonWidth; max = new Vector2(pos.X + Font().MeasureString(textB).X, min.Y + buttonWidth); hitBoxB.Set(min, max); TextHelper.DrawString(Font, textB, pos, labelBColor); } } 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(); } // end of PreRender()
} // end of UIGridModularCheckboxElement Render() /// <summary> /// If the state of the element has changed, we may need to re-create the texture. /// </summary> public void RefreshTexture() { if (dirty || diffuse.IsContentLost) { InGame.SetRenderTarget(diffuse); InGame.Clear(Color.White); int w = diffuse.Width; int h = diffuse.Height; ScreenSpaceQuad quad = ScreenSpaceQuad.GetInstance(); // Render the white background. Vector2 position = Vector2.Zero; Vector2 size = new Vector2(w, nextLevelWhite.Height); quad.Render(nextLevelWhite, position, size, "TexturedNoAlpha"); // And the black parts. position.Y = 70; size.Y = h - 70; quad.Render(nextLevelMiddleBlack, position, size, "TexturedRegularAlpha"); position.Y = 64; size.Y = nextLevelBlack.Height; quad.Render(nextLevelBlack, position, size, "TexturedRegularAlpha"); // Render the image. position.X = 6; position.Y = 70; size.X = size.Y = h - position.Y - 6; if (nextLevel != null) { //render the thumbnail when "on" quad.Render(nextLevel.Thumbnail.Texture, position, size, "TexturedRegularAlpha"); } else { quad.Render(nextLevelNone, position, size, "TexturedRegularAlpha"); } // Disable writing to alpha channel. // This prevents transparent fringing around the text. GraphicsDevice device = BokuGame.bokuGame.GraphicsDevice; device.BlendState = UI2D.Shared.BlendStateColorWriteRGB; // Render the label text into the texture. int margin = 16; position.X = (int)size.X + margin; position.Y = (int)((128 - Font().LineSpacing) / 2.0f); TextBlob blob = null; if (nextLevel != null) { blob = new TextBlob(Font, nextLevel.Name, w - (int)position.X - margin); } else { blob = new TextBlob(Font, Strings.Localize("editWorldParams.noLevelSelected"), w - (int)position.X - margin); } position.Y = (int)((h - blob.TotalSpacing) / 2.0f) - 2; Color fontColor = new Color(127, 127, 127); Color shadowColor = new Color(0, 0, 0, 20); Vector2 shadowOffset = new Vector2(0, 6); //render the main label string label = Strings.Localize("editWorldParams.nextLevel"); // prepare the label position int labelWidth = (int)(Font().MeasureString(label).X); Vector2 labelPosition = Vector2.Zero; labelPosition.X = TextHelper.CalcJustificationOffset(0, w, labelWidth, Justification.Center); labelPosition.Y = (int)((64 - Font().LineSpacing) / 2.0f); SpriteBatch batch = UI2D.Shared.SpriteBatch; batch.Begin(); //render the main label TextHelper.DrawString(Font, label, labelPosition + shadowOffset, shadowColor); TextHelper.DrawString(Font, label, labelPosition, fontColor); batch.End(); //render the world name blob.RenderWithButtons(position, fontColor, shadowColor, shadowOffset, maxLines: 3); //only render X button if we have a level if (nextLevel != null) { float clearLabelLength = Font().MeasureString(Strings.Localize("editWorldParams.clearNextLevel")).X; //render the X button position.X = w - 54; position.Y = h - 54; size = new Vector2(64, 64); quad.Render(ButtonTextures.XButton, position, size, "TexturedRegularAlpha"); //prepare position for "clear" label position.X -= 10 + (int)clearLabelLength; float hitBoxU = (float)(w - clearLabelLength - 64) / (float)w; float hitBoxV = (float)(h - 64) / (float)h; //update the hit box for "clear" - basically bottom right corner clearHitBox.Set(new Vector2(hitBoxU, hitBoxV), new Vector2(1.0f, 1.0f)); //render the clear button text batch.Begin(); TextHelper.DrawString(Font, Strings.Localize("editWorldParams.clearNextLevel"), position + shadowOffset, shadowColor); TextHelper.DrawString(Font, Strings.Localize("editWorldParams.clearNextLevel"), position, fontColor); batch.End(); } else { //no clear hit box if it's not being rendered clearHitBox.Set(Vector2.Zero, Vector2.Zero); } // Restore write channels device.BlendState = BlendState.AlphaBlend; // Restore backbuffer. InGame.RestoreRenderTarget(); dirty = false; } } // end of UIGridModularCheckboxElement 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. 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; } // // Render buttons. // float margin = 64.0f; float totalWidth = continueButton.GetSize().X + /* margin + backButton.GetSize().X + */ margin + exitTutorialButton.GetSize().X; pos = new Vector2(rtSize.X / 2.0f, rtSize.Y / 2.0f + backgroundSize.Y * 0.28f); pos.X -= totalWidth / 2.0f; SpriteBatch batch = UI2D.Shared.SpriteBatch; batch.Begin(); continueButton.Render(pos); pos.X += continueButton.GetSize().X + margin; /* * backButton.Render(pos); * pos.X += backButton.GetSize().X + margin; */ exitTutorialButton.Render(pos); batch.End(); // Add left stick if needed. Vector2 min; Vector2 max; 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 ScrollableTextDisplay Render()
} // end of PreRender() public static void Render() { if (!active || backdrop == null || rt == null) { return; } ScreenSpaceQuad quad = ScreenSpaceQuad.GetInstance(); Vector2 size = new Vector2(rt.Width, rt.Height); backdropBox.Set(Vector2.Zero, size); // Tutorial info needs to go at top of "real" screen. InGame.RestoreViewportToFull(); quad.Render(rt, Vector2.Zero, size, "TexturedNoAlpha"); if (modalDisplay.Active) { quad.Render(dropShadow, Vector2.Zero, BokuGame.ScreenSize, "TexturedRegularAlpha"); } modalDisplay.Render(); // Display debug spew if active. if (DebugMode && active) { Vector2 pos = new Vector2(20, 400); SpriteBatch batch = UI2D.Shared.SpriteBatch; Color color = Color.Yellow; TextBlob blob = new TextBlob(UI2D.Shared.GetGameFont20, "", 1000); string text = "Tutorial Manager\n"; try { text += " current game mode : " + curGameMode.ToString() + "\n"; text += " current help overlay : " + HelpOverlay.Peek() + "\n"; text += " current step\n"; text += " display mode : " + curStep.DisplayMode.ToString() + "\n"; text += " target mode : " + curStep.TargetMode.ToString() + "\n"; if (curStep.CompletionTest != null) { text += " completion test : " + curStep.CompletionTest.Name.ToString() + "\n"; text += " args : " + curStep.CompletionTest.Args.ToString() + "\n"; } text += " current input mode : " + GamePadInput.ActiveMode.ToString() + "\n"; if (curCrumb != null) { text += "current crumb id " + curCrumb.id + "\n"; } } catch { } blob.RawText = text; blob.RenderWithButtons(pos, Color.Black, outlineColor: Color.White, outlineWidth: 1.2f); } } // end of 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); // 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()
public void UpdatePosition(Vector2 pos) { hitbox.Set(pos, pos + new Vector2(width, height)); }
} // end of UIGridModularCameraModeElement Render() /// <summary> /// If the state of the element has changed, we may need to re-create the texture. /// </summary> public void RefreshTexture() { if (dirty || diffuse.IsContentLost) { InGame.SetRenderTarget(diffuse); InGame.Clear(Color.White); int w = diffuse.Width; int h = diffuse.Height; ScreenSpaceQuad quad = ScreenSpaceQuad.GetInstance(); // Render the white background. Vector2 position = Vector2.Zero; Vector2 size = new Vector2(w, white.Height); quad.Render(white, position, size, "TexturedNoAlpha"); // And the black parts. position.Y = 70; size.Y = h - 70; quad.Render(middleBlack, position, size, "TexturedRegularAlpha"); position.Y = 64; size.Y = black.Height; quad.Render(black, position, size, "TexturedRegularAlpha"); // The icons. position.X = (512 - icons.Width) / 2; position.Y = 80; size = new Vector2(icons.Width, icons.Height); quad.Render(icons, position, size, "TexturedRegularAlpha"); // Bounding box Vector2 min = new Vector2(position.X / w, position.Y / h); Vector2 max = new Vector2((position.X + size.X) / w, (140 + 2.0f * indicatorLit.Height) / h); iconButtonBox.Set(min, max); // The indicators. size = new Vector2(indicatorLit.Width, indicatorLit.Height); position = new Vector2(105, 140); quad.Render(CurIndex == 0 ? indicatorLit : indicatorUnlit, position, size, "TexturedRegularAlpha"); position = new Vector2(512 / 2 - size.X / 2, 140); quad.Render(CurIndex == 1 ? indicatorLit : indicatorUnlit, position, size, "TexturedRegularAlpha"); position = new Vector2(512 - 105 - size.X, 140); quad.Render(CurIndex == 2 ? indicatorLit : indicatorUnlit, position, size, "TexturedRegularAlpha"); // Disable writing to alpha channel. // This prevents transparent fringing around the text. GraphicsDevice device = BokuGame.bokuGame.GraphicsDevice; device.BlendState = UI2D.Shared.BlendStateColorWriteRGB; // Render the label and value text into the texture. string title = label + " : "; switch (CurIndex) { case 0: title += Strings.Localize("editWorldParams.cameraModeFixedPosition"); break; case 1: title += Strings.Localize("editWorldParams.cameraModeFixedOffset"); break; case 2: title += Strings.Localize("editWorldParams.cameraModeFree"); break; } int margin = 0; position.X = 0; position.Y = (int)((64 - Font().LineSpacing) / 2.0f); int textWidth = (int)(Font().MeasureString(title).X); justify = Justification.Center; position.X = TextHelper.CalcJustificationOffset(margin, w, textWidth, justify); Color labelColor = new Color(127, 127, 127); Color valueColor = new Color(140, 200, 63); Color shadowColor = new Color(0, 0, 0, 20); Vector2 shadowOffset = new Vector2(0, 6); SpriteBatch batch = UI2D.Shared.SpriteBatch; batch.Begin(); // Title. TextHelper.DrawString(Font, title, position + shadowOffset, shadowColor); TextHelper.DrawString(Font, title, position, labelColor); batch.End(); if (xButtonText != null) { UI2D.Shared.GetFont ButtonFont = UI2D.Shared.GetGameFont18Bold; position.X = w - 44; position.Y = h - 44; size = new Vector2(48, 48); quad.Render(ButtonTextures.XButton, position, size, "TexturedRegularAlpha"); max.X = (position.X + 44) / w; min.Y = position.Y / h; position.X -= 10 + (int)ButtonFont().MeasureString(Strings.Localize("editWorldParams.setCamera")).X; batch.Begin(); TextHelper.DrawString(ButtonFont, Strings.Localize("editWorldParams.setCamera"), position + shadowOffset, shadowColor); TextHelper.DrawString(ButtonFont, Strings.Localize("editWorldParams.setCamera"), position, labelColor); batch.End(); min.X = position.X / w; max.Y = min.Y + (float)ButtonFont().LineSpacing / h; xButtonBox.Set(min, max); } // Restore default blend state. device.BlendState = BlendState.AlphaBlend; // Restore backbuffer. InGame.RestoreRenderTarget(); dirty = false; } } // end of UIGridModularCameraModeElement Render()
} // end of UIGridModularCheckboxElement Render() /// <summary> /// If the state of the element has changed, we may need to re-create the texture. /// </summary> public void RefreshTexture() { if (dirty || diffuse.IsContentLost) { InGame.SetRenderTarget(diffuse); InGame.Clear(Color.White); int w = diffuse.Width; int h = diffuse.Height; ScreenSpaceQuad quad = ScreenSpaceQuad.GetInstance(); // Render the white region with highlight. Vector2 position = new Vector2(h - 2, 0); Vector2 size = new Vector2(w, h) - position; quad.Render(checkboxWhite, position, size, "TexturedNoAlpha"); // Render the checkbox. position = Vector2.Zero; size.X = size.Y; if (check) { quad.Render(checkOn, position, size, "TexturedRegularAlpha"); } else { quad.Render(checkOff, position, size, "TexturedRegularAlpha"); } // Disable writing to alpha channel. // This prevents transparent fringing around the text. GraphicsDevice device = BokuGame.bokuGame.GraphicsDevice; device.BlendState = UI2D.Shared.BlendStateColorWriteRGB; // Render the label text into the texture. int margin = 16; position.X = (int)size.X + margin; TextBlob blob = new TextBlob(Font, label, w - (int)position.X - margin); position.Y = (int)((h - blob.TotalSpacing) / 2.0f) - 2; if (blob.NumLines == 2) { position.Y -= blob.TotalSpacing / 2.0f; } else if (blob.NumLines == 3) { position.Y -= blob.TotalSpacing; } Color fontColor = new Color(127, 127, 127); Color shadowColor = new Color(0, 0, 0, 20); Vector2 shadowOffset = new Vector2(0, 6); blob.RenderWithButtons(position, fontColor, shadowColor, shadowOffset, maxLines: 3); // Render help button. /* * if (ShowHelpButton) * { * position.X = w - 54; * position.Y = h - 54; * size = new Vector2(64, 64); * quad.Render(ButtonTextures.YButton, position, size, "TexturedRegularAlpha"); * position.X -= 10 + (int)font.MeasureString(Strings.Localize("editObjectParams.help")).X; * batch.Begin(); * TextHelper.DrawString(Font, Strings.Localize("editObjectParams.help"), position + shadowOffset, shadowColor); * TextHelper.DrawString(Font, Strings.Localize("editObjectParams.help"), position, fontColor); * batch.End(); * * if (xButtonText != null) * { * position.X = w - 54; * position.Y = h - 54 - Font().LineSpacing - 6; * size = new Vector2(64, 64); * quad.Render(ButtonTextures.XButton, position, size, "TexturedRegularAlpha"); * position.X -= 10 + (int)Font().MeasureString(Strings.Localize("editWorldParams.setCamera")).X; * batch.Begin(); * TextHelper.DrawString(Font, Strings.Localize("editWorldParams.setCamera"), position + shadowOffset, shadowColor); * TextHelper.DrawString(Font, Strings.Localize("editWorldParams.setCamera"), position, fontColor); * batch.End(); * } * } */ if (xButtonText != null) { position.X = w - 54; position.Y = h - 54; size = new Vector2(64, 64); quad.Render(ButtonTextures.XButton, position, size, "TexturedRegularAlpha"); Vector2 min = Vector2.Zero; Vector2 max = Vector2.Zero; max.X = (position.X + 54) / w; min.Y = position.Y / h; position.X -= 10 + (int)Font().MeasureString(Strings.Localize("editWorldParams.setCamera")).X; SpriteBatch batch = UI2D.Shared.SpriteBatch; batch.Begin(); TextHelper.DrawString(Font, Strings.Localize("editWorldParams.setCamera"), position + shadowOffset, shadowColor); TextHelper.DrawString(Font, Strings.Localize("editWorldParams.setCamera"), position, fontColor); batch.End(); min.X = position.X / w; max.Y = min.Y + (float)Font().LineSpacing / h; xButtonBox.Set(min, max); } // Restore default blend state. device.BlendState = BlendState.AlphaBlend; // Restore backbuffer. InGame.RestoreRenderTarget(); dirty = false; } } // end of UIGridModularCheckboxElement Render()
} // end of OnHelp() public void Render() { if (active) { titleRect = new Rectangle(0, 0, dialogWidth, 72); dialogBodyRect = new Rectangle(0, 64, dialogWidth, 320); // Now that we have the final dialog size, center it on the screen. Vector2 pos = BokuGame.ScreenSize / 2.0f; pos.X -= titleRect.Width / 2; pos.Y -= (titleRect.Height + dialogBodyRect.Height) / 2; titleRect.X = (int)pos.X; titleRect.Y = (int)pos.Y; dialogBodyRect.X = titleRect.X; dialogBodyRect.Y = titleRect.Y + titleRect.Height; int padding = 4; helpRect = new Rectangle(titleRect.X + titleRect.Width - titleRect.Height - margin, titleRect.Y + padding, titleRect.Height - 2 * padding, titleRect.Height - 2 * padding); AuthUI.RenderTile(titleBarTexture, titleRect); AuthUI.RenderTile(dialogBodyTexture, dialogBodyRect); // Title bar help icon. AuthUI.RenderTile(helpIcon, helpRect); helpBox.Set(helpRect); // Title bar text. string str = newUserMode ? Strings.Localize("auth.newUserTitle") : Strings.Localize("auth.signInTitle"); blob.RawText = str; blob.Font = UI2D.Shared.GetGameFont30Bold; blob.Justification = UIGridElement.Justification.Left; blob.RenderWithButtons(new Vector2(titleRect.X + margin, titleRect.Y + 6), Color.White, Color.Black, new Vector2(0, 2), maxLines: 1); // Text box labels. int verticalBoxSpacing = blob.TotalSpacing + 4; blob.Font = UI2D.Shared.GetGameFont24; blob.Justification = UIGridElement.Justification.Right; string creatorString = Strings.Localize("auth.creator"); string pinString = Strings.Localize("auth.pin"); int posX = (int)Math.Max(blob.Font().MeasureString(creatorString).X, blob.Font().MeasureString(pinString).X); posX += margin; blob.Width = dialogBodyRect.Width - posX - 2 * margin; pos = new Vector2(dialogBodyRect.X + posX - blob.Width, dialogBodyRect.Y + margin); blob.RawText = creatorString; blob.RenderWithButtons(pos, Color.White); pos.Y += verticalBoxSpacing; blob.RawText = pinString; blob.RenderWithButtons(pos, Color.White); // Text boxes. // Creator. creatorBlob.Justification = UIGridElement.Justification.Left; pos.Y -= verticalBoxSpacing; pos.X = dialogBodyRect.X + posX + margin; int creatorBoxWidth = dialogBodyRect.Width - posX - 2 * margin; Rectangle creatorTextBoxRect = new Rectangle((int)pos.X, (int)pos.Y, creatorBoxWidth, 40); creatorBox.Set(creatorTextBoxRect); // If editing, put a focus highlight around it. if (EditingCreator) { AuthUI.RenderTile(textBoxTexture, creatorTextBoxRect, AuthUI.FocusColor); creatorTextBoxRect = creatorTextBoxRect.Shrink(2); // Also display warning about picking a good creator name. Vector2 warningPos = new Vector2(dialogBodyRect.Left + 8, pinBox.Rectangle.Bottom); int prevWidth = blob.Width; blob.Width = dialogBodyRect.Width - 16; blob.Justification = UIGridElement.Justification.Left; str = Strings.Localize("auth.helpTextShort"); blob.RawText = str; blob.Font = UI2D.Shared.GetGameFont15_75; blob.RenderWithButtons(warningPos, AuthUI.ErrorColor); blob.Font = UI2D.Shared.GetGameFont24; blob.Width = prevWidth; blob.Justification = UIGridElement.Justification.Right; } AuthUI.RenderTile(textBoxTexture, creatorTextBoxRect); creatorBlob.RenderWithButtons(pos, creatorBlob.ScrubbedText == "Guest" ? Color.Gray : Color.Black, renderCursor: EditingCreator); // Pin pos.Y += verticalBoxSpacing; // Use regular blob for measurement. blob.Justification = UIGridElement.Justification.Left; int pinBoxWidth = (int)pinBlob.Font().MeasureString("0000").X; // Assumes 0s are max width characters. Rectangle pinTextBoxRect = new Rectangle((int)pos.X, (int)pos.Y, pinBoxWidth, 40); pinBox.Set(pinTextBoxRect); if (EditingPin) { AuthUI.RenderTile(textBoxTexture, pinTextBoxRect, AuthUI.FocusColor); pinTextBoxRect = pinTextBoxRect.Shrink(2); } AuthUI.RenderTile(textBoxTexture, pinTextBoxRect); // Hack to hide pin numbers. Only show last number unless Guest pin. string rawText = pinBlob.ScrubbedText; // Save existing string. if (pinBlob.ScrubbedText != Auth.DefaultCreatorPin) { str = ""; if (pinBlob.ScrubbedText.Length > 0) { for (int i = 0; i < pinBlob.ScrubbedText.Length - 1; i++) { str += '•'; } str += pinBlob.ScrubbedText[pinBlob.ScrubbedText.Length - 1]; pinBlob.RawText = str; } } pinBlob.RenderWithButtons(pos, pinBlob.ScrubbedText == Auth.DefaultCreatorPin ? Color.Gray : Color.Black, renderCursor: EditingPin); // Restore pinBlob.RawText = rawText; // Pin warnings. if (pinBlob.ScrubbedText != Auth.DefaultCreatorPin && !Auth.IsPinValid(pinBlob.ScrubbedText)) { pos.X += pinTextBoxRect.Width + 8; str = Strings.Localize("auth.pinError"); if (pinBlob.ScrubbedText.Length != 4) { str += "\n" + Strings.Localize("auth.pinTooShort"); } else { str += "\n" + Strings.Localize("auth.pinTooSimple"); } blob.RawText = str; blob.RenderWithButtons(pos, AuthUI.ErrorColor); } // Buttons. Fit at bottom of dialog. pos = new Vector2(dialogBodyRect.Right, dialogBodyRect.Bottom); pos.X -= margin; pos.Y -= margin; pos -= cancelButton.GetSize(); cancelButton.Render(pos, useBatch: false); pos.X -= margin; pos.X -= okButton.GetSize().X; okButton.Render(pos, useBatch: false); // Keep signed in checkbox. // Position vertically just above buttons. pos.X = dialogBodyRect.X + margin; pos.Y = okButton.Box.Min.Y + 32; pos.X += 32; // Adjust for checkbox. blob.RawText = Strings.Localize("auth.keepSignedIn"); blob.Width = dialogBodyRect.Width - 2 * margin - 32; pos.Y -= blob.NumLines * blob.TotalSpacing; Rectangle checkboxRect = new Rectangle((int)pos.X - 32, (int)pos.Y + 4, 32, 32); checkBoxBox.Set(checkboxRect); AuthUI.RenderTile(keepSignedInChecked ? checkboxLit : checkboxUnlit, checkboxRect); blob.RenderWithButtons(pos, Color.White); // Adjust dialog size to CreatorName box is the desired size. // This keeps the entry box the same size regardless of the length // of "Creator" in whatever language is being used. dialogWidth += desiredCreatorNameSpace - (int)creatorBox.Width; scrollableTextDisplay.Render(); } VirtualKeyboard.Render(); } // end of Render()
} // end of UpdateTextColor() /// <summary> /// Render our UI to the screen, but only if now is appropriate. /// </summary> public static void Render() { // In mouse mode, don't render undo/redo icons if pickers are active. bool mouseEdit = inGame.CurrentUpdateMode == UpdateMode.MouseEdit && !InGame.inGame.touchEditUpdateObj.PickersActive; if ((inGame.CurrentUpdateMode == UpdateMode.ToolMenu || mouseEdit) && HaveAnything) { GraphicsDevice device = BokuGame.bokuGame.GraphicsDevice; // Calc position for undo/redo text. int x = 0; int y = (int)(BokuGame.ScreenSize.Y * 0.66f); int buttonSize = 40; UI2D.Shared.GetFont Font = UI2D.Shared.GetGameFont18Bold; SpriteBatch batch = UI2D.Shared.SpriteBatch; // Handle small screens. if (BokuGame.ScreenSize.Y < 720) { Font = UI2D.Shared.GetGameFont15_75; buttonSize = (int)(buttonSize * 0.8f); } if (HaveReDo) { ScreenSpaceQuad quad = ScreenSpaceQuad.GetInstance(); Texture2D texture = GamePadInput.ActiveMode == GamePadInput.InputMode.GamePad ? ButtonTextures.YButton : ButtonTextures.Redo; quad.Render(texture, Vector4.One, new Vector2(x, y), new Vector2(buttonSize), @"TexturedRegularAlpha"); redoHitBox.Set(new Vector2(x, y), new Vector2(x, y) + new Vector2(buttonSize - 12)); } else { redoHitBox.Set(Vector2.Zero, Vector2.Zero); } if (HaveUnDo) { ScreenSpaceQuad quad = ScreenSpaceQuad.GetInstance(); Texture2D texture = GamePadInput.ActiveMode == GamePadInput.InputMode.GamePad ? ButtonTextures.XButton : ButtonTextures.Undo; quad.Render(texture, Vector4.One, new Vector2(x, y + buttonSize - 12), new Vector2(buttonSize), @"TexturedRegularAlpha"); undoHitBox.Set(new Vector2(x, y + buttonSize - 12), new Vector2(x, y + buttonSize - 12) + new Vector2(buttonSize - 12)); } else { undoHitBox.Set(Vector2.Zero, Vector2.Zero); } Color darkGrey = new Color(10, 10, 10); #if NETFX_CORE batch.Begin(); if (HaveReDo) { string str = Strings.Localize("undoStack.redo") + "(" + NumReDo.ToString() + ")"; TextHelper.DrawStringWithShadow(Font, batch, x + buttonSize - 12, y - 4, str, redoTextColor, darkGrey, false); Vector2 max = redoHitBox.Max; max.X += Font().MeasureString(str).X; redoHitBox.Set(redoHitBox.Min, max); } if (HaveUnDo) { string str = Strings.Localize("undoStack.undo") + "(" + NumUnDo.ToString() + ")"; TextHelper.DrawStringWithShadow(Font, batch, x + buttonSize - 12, y + buttonSize - 16, str, undoTextColor, darkGrey, false); Vector2 max = undoHitBox.Max; max.X += Font().MeasureString(str).X; undoHitBox.Set(undoHitBox.Min, max); } batch.End(); #else SysFont.StartBatch(null); if (HaveReDo) { string str = Strings.Localize("undoStack.redo") + "(" + NumReDo.ToString() + ")"; SysFont.DrawString(str, new Vector2(x + buttonSize - 12, y - 4), new RectangleF(), Font().systemFont, redoTextColor, outlineColor: Color.Black, outlineWidth: 1.5f); Vector2 max = redoHitBox.Max; max.X += Font().MeasureString(str).X; redoHitBox.Set(redoHitBox.Min, max); } if (HaveUnDo) { string str = Strings.Localize("undoStack.undo") + "(" + NumUnDo.ToString() + ")"; SysFont.DrawString(str, new Vector2(x + buttonSize - 12, y + buttonSize - 16), new RectangleF(), Font().systemFont, undoTextColor, outlineColor: Color.Black, outlineWidth: 1.5f); Vector2 max = undoHitBox.Max; max.X += Font().MeasureString(str).X; undoHitBox.Set(undoHitBox.Min, max); } SysFont.EndBatch(); #endif } }
} // end of ApplyExclusiveFiltering() public void Render(Camera camera) { if (Active && geometry != null) { // Black background. effect.CurrentTechnique = effect.Techniques["NormalMappedNoTexture"]; effect.Parameters["WorldMatrix"].SetValue(worldMatrix); effect.Parameters["WorldViewProjMatrix"].SetValue(worldMatrix * camera.ViewProjectionMatrix); effect.Parameters["Alpha"].SetValue(1.0f); effect.Parameters["DiffuseColor"].SetValue(new Vector4(0, 0, 0, 1)); effect.Parameters["SpecularColor"].SetValue(new Vector4(0.2f, 0.2f, 0.2f, 1.0f)); effect.Parameters["SpecularPower"].SetValue(32.0f); effect.Parameters["NormalMap"].SetValue(normalMap); geometry.Render(effect); ScreenSpaceQuad quad = ScreenSpaceQuad.GetInstance(); Vector3 upperLeftCorner = worldMatrix.Translation; upperLeftCorner.X -= geometry.Width / 2.0f; upperLeftCorner.Y += geometry.Height / 2.0f; upperLeftCorner.X += tileBorder; upperLeftCorner.Y -= tileBorder / 2.0f; Point loc = camera.WorldToScreenCoords(upperLeftCorner); Vector2 pos = new Vector2(loc.X, loc.Y); loc = camera.WorldToScreenCoords(2.0f * worldMatrix.Translation - upperLeftCorner); Vector2 size = new Vector2(loc.X, loc.Y) - pos; int lineSpacing = Font().LineSpacing; // Render highlight. quad.Render(whiteHighlight, new Vector4(1.0f, 1.0f, 1.0f, 0.3f), pos + new Vector2(-4, 0), new Vector2(w + 6, w / 2.0f), "TexturedRegularAlpha"); // Render the green bar(). for (int i = 0; i < itemList.Count; i++) { if (itemList[i].BarAlpha > 0.0) { quad.Render(greenBar, new Vector4(1.0f, 1.0f, 1.0f, itemList[i].BarAlpha), pos + new Vector2(0, 2 + i * lineSpacing), new Vector2(w, lineSpacing), "TexturedRegularAlpha"); } } // Render the text. SpriteBatch batch = UI2D.Shared.SpriteBatch; batch.Begin(); for (int i = 0; i < itemList.Count; i++) { Vector2 position = pos + new Vector2(margin + checkboxSize + gap, i * lineSpacing); TextHelper.DrawString(Font, itemList[i].Text, position, itemList[i].TextColor); // Calc bounds in UV space. Vector2 min = new Vector2(0, i * lineSpacing); Vector2 max = min + new Vector2(w, lineSpacing); min /= size; max /= size; itemList[i].UVBoundingBox.Set(min, max); } batch.End(); // Render the checkboxes. for (int i = 0; i < itemList.Count; i++) { float a = itemList[i].LitValue; // If not fully lit. if (a < 1.0f) { quad.Render(AllExclusive ? radioButtonUnlit : checkboxUnlit, pos + new Vector2(margin, 6 + i * lineSpacing), new Vector2(checkboxSize), "TexturedRegularAlpha"); } // If lit at all. if (a > 0.0f) { quad.Render(AllExclusive ? radioButtonLit : checkboxLit, new Vector4(1, 1, 1, a), pos + new Vector2(margin, 6 + i * lineSpacing), new Vector2(checkboxSize), "TexturedRegularAlpha"); } } if (GamePadInput.ActiveMode == GamePadInput.InputMode.GamePad) { // Render help. string str = "<a> " + Strings.Localize("saveLevelDialog.change") + "\n<b> " + Strings.Localize("saveLevelDialog.back"); TextBlob blob = new TextBlob(UI2D.Shared.GetGameFont24, str, 400); pos += size; pos.X += 16; pos.Y -= 2.0f * blob.TotalSpacing; blob.RenderWithButtons(pos, Color.White); // Mouse hit boxes for help. changeBox.Set(pos, pos + new Vector2(blob.GetLineWidth(0), blob.TotalSpacing)); backBox.Set(pos + new Vector2(0, blob.TotalSpacing), pos + new Vector2(0, blob.TotalSpacing) + new Vector2(blob.GetLineWidth(1), blob.TotalSpacing)); } } // end if active } // end of ModularCheckboxList Render()
} // end of OnCancel() public void Render() { if (active) { titleRect = new Rectangle(0, 0, 512, 72); dialogBodyRect = new Rectangle(0, 64, 512, 320); // Now that we have the final dialog size, center it on the screen. Vector2 pos = BokuGame.ScreenSize / 2.0f; pos.X -= titleRect.Width / 2; pos.Y -= (titleRect.Height + dialogBodyRect.Height) / 2; titleRect.X = (int)pos.X; titleRect.Y = (int)pos.Y; dialogBodyRect.X = titleRect.X; dialogBodyRect.Y = titleRect.Y + titleRect.Height; AuthUI.RenderTile(titleBarTexture, titleRect); AuthUI.RenderTile(dialogBodyTexture, dialogBodyRect); // Title bar text. string str = Strings.Localize("auth.signOutTitle"); blob.RawText = str; blob.Font = UI2D.Shared.GetGameFont30Bold; blob.Justification = UIGridElement.Justification.Left; blob.RenderWithButtons(new Vector2(titleRect.X + margin, titleRect.Y + 6), Color.White, Color.Black, new Vector2(0, 2), maxLines: 1); // Text box labels. int verticalBoxSpacing = blob.TotalSpacing + 4; blob.Font = UI2D.Shared.GetGameFont24; blob.Justification = UIGridElement.Justification.Left; str = Strings.Localize("auth.currentlySignedInAs") + Auth.CreatorName; blob.Width = dialogBodyRect.Width - 2 * margin; pos = new Vector2(dialogBodyRect.X + margin, dialogBodyRect.Y + margin); blob.RawText = str; blob.RenderWithButtons(pos, Color.White); // Buttons. Fit at bottom of dialog. pos = new Vector2(dialogBodyRect.Right, dialogBodyRect.Bottom); pos.X -= margin; pos.Y -= margin; pos -= cancelButton.GetSize(); cancelButton.Render(pos, useBatch: false); pos.X -= margin; pos.X -= signOutButton.GetSize().X; signOutButton.Render(pos, useBatch: false); // Keep signed in checkbox. // Position vertically just above buttons. pos.X = dialogBodyRect.X + margin; pos.Y = signOutButton.Box.Min.Y; pos.X += 32; // Adjust for checkbox. blob.RawText = Strings.Localize("auth.keepSignedIn"); blob.Width = dialogBodyRect.Width - 2 * margin - 32; pos.Y -= blob.NumLines * blob.TotalSpacing; Rectangle checkboxRect = new Rectangle((int)pos.X - 32, (int)pos.Y + 4, 32, 32); checkBoxBox.Set(checkboxRect); AuthUI.RenderTile(keepSignedInChecked ? checkboxLit : checkboxUnlit, checkboxRect); blob.RenderWithButtons(pos, Color.White); } } // end of Render()
} // end of UIGridModularButtonElement Render() /// <summary> /// If the state of the element has changed, we may need to re-create the texture. /// </summary> public void RefreshTexture() { // dirty = true; // Debug only. if (dirty || diffuse.IsContentLost) { InGame.SetRenderTarget(diffuse); InGame.Clear(Color.White); int w = diffuse.Width; int h = diffuse.Height; ScreenSpaceQuad quad = ScreenSpaceQuad.GetInstance(); // Render the white region with highlight. Vector2 position = new Vector2(h - 2, 0); Vector2 size = new Vector2(w, h) - position; quad.Render(checkboxWhite, position, size, "TexturedNoAlpha"); // Render the black box. position = Vector2.Zero; size.X = size.Y; quad.Render(blackSquare, position, size, "TexturedRegularAlpha"); // Disable writing to alpha channel. // This prevents transparent fringing around the text. GraphicsDevice device = BokuGame.bokuGame.GraphicsDevice; device.BlendState = UI2D.Shared.BlendStateColorWriteRGB; // Render the label text into the texture. int margin = 16; position.X = (int)size.X + margin; string text = label + "\n"; if (aButtonText != null) { text += " <A> " + aButtonText + "\n"; } if (xButtonText != null) { text += " <X> " + xButtonText; } TextBlob blob = new TextBlob(Font, text, w - (int)position.X - margin); position.Y = (int)((h - blob.TotalSpacing) / 2.0f) - 2; if (blob.NumLines == 2) { position.Y -= blob.TotalSpacing / 2.0f; } else if (blob.NumLines == 3) { position.Y -= blob.TotalSpacing; } Color fontColor = new Color(127, 127, 127); Color shadowColor = new Color(0, 0, 0, 20); Vector2 shadowOffset = new Vector2(0, 6); blob.RenderWithButtons(position, fontColor, shadowColor, shadowOffset, maxLines: 3); // Restore default blending. device.BlendState = BlendState.AlphaBlend; int line = blob.NumLines - 1; // Which line in the text has the button. // Calc bounding boxes in UV space for A and X buttons/labels. if (onXButton != null) { Vector2 min = new Vector2(position.X / w, (position.Y + line * blob.TotalSpacing) / h); Vector2 max = min + new Vector2((float)blob.GetLineWidth(line) / w, (float)blob.TotalSpacing / h); xButtonBox.Set(min, max); --line; } if (onAButton != null) { Vector2 min = new Vector2(position.X / w, (position.Y + line * blob.TotalSpacing) / h); Vector2 max = min + new Vector2((float)blob.GetLineWidth(line) / w, (float)blob.TotalSpacing / h); aButtonBox.Set(min, max); } // DEBUG Show hit box for a button as overlay. /* * if (onAButton != null) * { * position = new Vector2(diffuse.Width * aButtonBox.Min.X, diffuse.Height * aButtonBox.Min.Y); * size = new Vector2(diffuse.Width * (aButtonBox.Size.X), diffuse.Height * aButtonBox.Size.Y); * quad.Render(new Vector4(1, 0, 0, 0.5f), position, size); * } * if (onXButton != null) * { * position = new Vector2(diffuse.Width * xButtonBox.Min.X, diffuse.Height * xButtonBox.Min.Y); * size = new Vector2(diffuse.Width * (xButtonBox.Size.X), diffuse.Height * xButtonBox.Size.Y); * quad.Render(new Vector4(0, 1, 0, 0.5f), position, size); * } */ // Restore backbuffer. InGame.RestoreRenderTarget(); dirty = false; } } // end of UIGridModularButtonElement 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. 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()
} // end of LiveFeedDisplay Render() #endregion #region Internal private void RenderFeedBasePlate() { GraphicsDevice device = BokuGame.bokuGame.GraphicsDevice; // default width = 300 px // default height = 190 px // Adjustment Scale X // Adjustment Scale Y Vector2 defaultScreenSize = new Vector2(1280, 1024); Vector2 extraSize = Vector2.Zero; Vector2 cOffset = Vector2.Zero; //center Offset of cloud background; float xCrushScale = 1.0f; float xCrushPixel = 0.0f; extraSize.X = 80;//moves over the word "News" ScreenSpaceQuad ssquad = ScreenSpaceQuad.GetInstance(); Color darkTextColor = new Color(20, 20, 20); Color greyTextColor = new Color(127, 127, 127); Color greenTextColor = new Color(0, 255, 45); Vector2 screenSize = BokuGame.ScreenSize; Vector2 scaledBy = new Vector2(screenSize.X / defaultScreenSize.X, screenSize.Y / defaultScreenSize.Y); if (expanded) { extraSize.Y += 600.0f * scaledBy.Y; } if (scaledBy.X < 0.9f) { xCrushScale = scaledBy.X; xCrushPixel = cloudTL.Width - (cloudTL.Width * scaledBy.X); } Vector2 pos = new Vector2(2.0f, 80.0f); cOffset = pos; cOffset.X += cloudTL.Width; cOffset.Y += cloudTL.Height - 25.0f; Vector2 baseSize = FeedSize; Vector2 iconSize = new Vector2(42.0f, 42.0f); Vector4 baseColor = new Vector4(0.0f, 0.0f, 0.0f, 0.7f); Vector2 headerSize = baseSize; headerSize.X *= 0.8f; headerSize.Y *= 0.055f; Vector2 headerPos = pos; Vector2 baseOffset; baseOffset.Y = (float)cloudTL.Height + cloudLC.Height * scaledBy.Y; headerPos.Y -= headerSize.Y; iconSize = new Vector2(headerSize.Y * 0.95f, headerSize.Y * 0.95f); 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; if (screenSize.X > 1200) { iconPos.Y += 5.0f; } // 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)); //Top left cloud ssquad.Render( cloudTL, cOffset - new Vector2(cloudTL.Width, cloudTL.Height / 1.25f), new Vector2(cloudTL.Width * xCrushScale, cloudTL.Height / 1.25f), "TexturedRegularAlpha"); //Bottom left cloud ssquad.Render( cloudBL, cOffset - new Vector2(cloudBL.Width, -((cloudLC.Height + extraSize.Y) * scaledBy.Y)), //baseOffset.Y + ((cloudLC.Height + extraSize.Y) * scaledBy.Y)), new Vector2(cloudBL.Width * xCrushScale, cloudBL.Height), "TexturedRegularAlpha"); // left center Fill ssquad.Render( cloudLC, cOffset - new Vector2(cloudLC.Width, 0.0f), new Vector2(cloudLC.Width * xCrushScale, (cloudLC.Height + extraSize.Y) * scaledBy.Y), "TexturedRegularAlpha"); //Top right cloud ssquad.Render( cloudTR, cOffset + new Vector2(((cloudTC.Width + extraSize.X) * scaledBy.X) - xCrushPixel, -(cloudTR.Height / 1.25f)), new Vector2(cloudTR.Width * xCrushScale, cloudTR.Height / 1.25f), "TexturedRegularAlpha"); //Bottom right cloud ssquad.Render( cloudBR, cOffset + new Vector2(((cloudTC.Width + extraSize.X) * scaledBy.X) - xCrushPixel, (cloudLC.Height + extraSize.Y) * scaledBy.Y), new Vector2(cloudBR.Width * xCrushScale, cloudBR.Height), "TexturedRegularAlpha"); // right center Fill ssquad.Render( cloudRC, cOffset + new Vector2(((cloudTC.Width + extraSize.X) * scaledBy.X) - xCrushPixel, 0.0f), new Vector2(cloudRC.Width * xCrushScale, (cloudRC.Height + extraSize.Y) * scaledBy.Y), "TexturedRegularAlpha"); // Top center Fill ssquad.Render( cloudTC, cOffset - new Vector2(xCrushPixel, cloudTC.Height / 1.25f), new Vector2((cloudTC.Width + extraSize.X) * scaledBy.X, cloudTC.Height / 1.25f), "TexturedRegularAlpha"); // Top bottom Fill ssquad.Render( cloudBC, cOffset + new Vector2(-xCrushPixel, (cloudLC.Height + extraSize.Y) * scaledBy.Y), new Vector2((cloudBC.Width + extraSize.X) * scaledBy.X, cloudBC.Height), "TexturedRegularAlpha"); // Center Fill ssquad.Render( cloudCenter, cOffset + new Vector2(-xCrushPixel, 0.0f), new Vector2((cloudTC.Width + extraSize.X) * scaledBy.X, (cloudCenter.Height + extraSize.Y) * scaledBy.Y), "TexturedRegularAlpha"); Vector2 moreLessBoxLT = new Vector2( (cOffset.X - ((cloudBL.Width * 0.70f) * xCrushScale) - xCrushPixel), (cOffset.Y + ((cloudLC.Height + extraSize.Y) * scaledBy.Y) + cloudBL.Height * 0.40f)); Vector2 moreLessBoxBR = moreLessBoxLT; float moreLessPos = (cloudBL.Width * xCrushScale * 0.52f); if (newsScroller.Count > 1) { if (!expanded) { moreLessPos -= (float)(flagMoreBlob.GetLineWidth(0) / 3); flagMoreBlob.Justification = UIGridElement.Justification.Center; pos = new Vector2(moreLessPos, moreLessBoxLT.Y + 8); // Clamp to pixel coords so text doesn't look like #$%. pos.X = (int)pos.X; pos.Y = (int)pos.Y; flagMoreBlob.RenderWithButtons(pos, flagMoreLessColor, maxLines: 1); moreLessBoxBR.X += flagMoreBlob.Width * 2.5f; //2.5 makes click area larger. moreLessBoxBR.Y += flagMoreBlob.TotalSpacing * 1.85f; //1.85 makes click area larger. } else { moreLessPos -= (float)(flagLessBlob.GetLineWidth(0) / 3); flagLessBlob.Justification = UIGridElement.Justification.Center; pos = new Vector2(moreLessPos, moreLessBoxLT.Y + 8); // Clamp to pixel coords so text doesn't look like #$%. pos.X = (int)pos.X; pos.Y = (int)pos.Y; flagLessBlob.RenderWithButtons(pos, flagMoreLessColor, maxLines: 1); moreLessBoxBR.X += (int)flagMoreBlob.Width * 2.5f; //2.5 makes click area larger. moreLessBoxBR.Y += (int)flagMoreBlob.TotalSpacing * 1.85f; //1.85 makes click area larger. } moreLessHitBox.Set(moreLessBoxLT, moreLessBoxBR); } else { moreLessHitBox.Set(new Vector2(0, 0), new Vector2(0, 0)); } pos = new Vector2(cOffset.X - ((cloudTL.Width / 1.8f) * xCrushScale) - xCrushPixel, cOffset.Y - cloudTL.Height * 0.65f); // Clamp to pixel coords so text doesn't look like #$%. pos.X = (int)pos.X + 3; pos.Y = (int)pos.Y; smallblob.RenderWithButtons(pos, Active ? greenTextColor : darkTextColor, maxLines: 1); }