} // end of UIGridTextElement Update() public override void Render(Camera camera) { // Add scaling to our world. Matrix world = worldMatrix; world.M11 *= size.X; world.M22 *= size.Y; quad.Render(camera, texture, ref world, baseColor.W); // Render the label on top. The font rendering location is // the top left corner of the box the text is rendering into. // Note as long as we're rendering text directly to the screen // instead of to a texture we can rotate it or tip it in 3D. Vector3 position = Position; position.X -= size.X / 2.0f; position.Y -= size.Y / 2.0f; Matrix textMatrix = worldMatrix; textMatrix.Translation -= Position; // Get back the parent matrix. position = Vector3.Transform(position, textMatrix); Point pos = camera.ToScreenCoords(position); if (pos.Y > -BokuGame.fontBerlinSansFBDemiBold20.Baseline && pos.Y < BokuGame.bokuGame.GraphicsDevice.Viewport.Height + BokuGame.fontBerlinSansFBDemiBold20.Baseline) { BokuGame.fontBerlinSansFBDemiBold20.DrawString(20 + pos.X, pos.Y - BokuGame.fontBerlinSansFBDemiBold20.Baseline - 5, Color.Black, label); } } // end of UIGridTextElement Render()
} // end of HandleTouchInput() public override void Render(Camera camera) { if (rt != null && level != null && !dirty) { // We do this check here to ensure the download state icon's alpha is reset if needed before being rendered. // When this check is performed in Update, we see a fully opaque icon for one frame due to order of operations. if (Level != null) { if (Level.DownloadState != prevDownloadState) { DownloadStateChanged(); } prevDownloadState = Level.DownloadState; } try { SimpleTexturedQuad quad = SimpleTexturedQuad.GetInstance(); // Render thumbnail drop shadow. { float s = Scale; Matrix shadowMatrix = Matrix.CreateScale(3.8f + 0.25f * s * s) * Matrix.CreateTranslation(0, -0.2f * s, 0) * worldMatrix; quad.Render(camera, levelTileShadow, ref shadowMatrix, 0.6f); } // Render the favorite box if (0 != (level.Genres & BokuShared.Genres.Favorite)) { Matrix tileMatrix = Matrix.CreateScale(2.13f) * worldMatrix; quad.Render(camera, favoriteBox, ref tileMatrix, levelTileAlphaMap); } // Render the thumbnail. { Matrix tileMatrix = Matrix.CreateScale(2f) * worldMatrix; quad.Render(camera, rt, ref tileMatrix, levelTileAlphaMap); } if (Level != null) { const float kDownloadStatusX = 0.9f; const float kDownloadStatusY = 0.8f; if (Level.FlaggedByMe) { Matrix m = Matrix.CreateTranslation(kDownloadStatusX, kDownloadStatusY, 0) * worldMatrix; quad.Render(camera, reportAbuse, ref m, 1.0f); } else { switch (Level.DownloadState) { case LevelMetadata.DownloadStates.Queued: { Matrix s = Matrix.CreateTranslation(kDownloadStatusX, kDownloadStatusY - 0.1f, 0) * worldMatrix; quad.Render(camera, statusIconShadow, ref s, 0.75f * downloadStateIconAlpha); Matrix m = Matrix.CreateTranslation(kDownloadStatusX, kDownloadStatusY, 0) * worldMatrix; quad.Render(camera, downloadQueuedIcon, ref m, downloadQueuedAlphaMap, downloadStateIconAlpha); } break; case LevelMetadata.DownloadStates.InProgress: { Matrix s = Matrix.CreateTranslation(kDownloadStatusX, kDownloadStatusY - downloadInProgressAnimOffset - 0.1f, 0) * worldMatrix; quad.Render(camera, statusIconShadow, ref s, 0.75f * downloadStateIconAlpha); Matrix m = Matrix.CreateTranslation(kDownloadStatusX, kDownloadStatusY - downloadInProgressAnimOffset, 0) * worldMatrix; quad.Render(camera, downloadInProgressIcon, ref m, downloadInProgressAlphaMap, downloadStateIconAlpha); } break; case LevelMetadata.DownloadStates.Failed: { Matrix s = Matrix.CreateTranslation(kDownloadStatusX, kDownloadStatusY - 0.1f, 0) * worldMatrix; quad.Render(camera, statusIconShadow, ref s, 0.75f * downloadStateIconAlpha); Matrix m = Matrix.CreateTranslation(kDownloadStatusX, kDownloadStatusY, 0) * worldMatrix; quad.Render(camera, downloadFailedIcon, ref m, downloadFailedAlphaMap, downloadStateIconAlpha); } break; case LevelMetadata.DownloadStates.Complete: { Matrix s = Matrix.CreateTranslation(kDownloadStatusX, kDownloadStatusY - 0.1f, 0) * worldMatrix; quad.Render(camera, statusIconShadow, ref s, 0.75f * downloadStateIconAlpha); Matrix m = Matrix.CreateTranslation(kDownloadStatusX, kDownloadStatusY, 0) * worldMatrix; quad.Render(camera, downloadCompleteIcon, ref m, downloadCompleteAlphaMap, downloadStateIconAlpha); } break; } } } } catch { // This will end up here if the rt call above throws an exception // because it thinks that the rendertarget is still tied to the device. This // only occurs in some device-reset situations. If we do nothing here then // everything is ok next frame. } } } // end of UIGridLevelElement Render()