public override void Update() { if (AuthUI.IsModalActive) { return; } if (parent.newWorldDialog.Active) { parent.newWorldDialog.Update(); return; } // We need to do this ever frame instead of just at activation // time since deactivation of the previous scene and activation // of this scene don't always happen in that order. AuthUI.ShowStatusDialog(); parent.saveLevelDialog.Update(); shared.communityShareMenu.Update(); parent.saveChangesMessage.Update(); parent.saveChangesWithDiscardMessage.Update(); parent.shareSuccessMessage.Update(); parent.noCommunityMessage.Update(); // If any of the dialogs are active, we don't want to look for input. if (parent.saveLevelDialog.Active || parent.saveChangesMessage.Active || parent.saveChangesWithDiscardMessage.Active || parent.shareSuccessMessage.Active || parent.noCommunityMessage.Active ) { return; } // Ensure camera matches screen. shared.camera.Resolution = new Point((int)BokuGame.ScreenSize.X, (int)BokuGame.ScreenSize.Y); shared.camera.Update(); // Update menu. shared.menu.Update(shared.camera, ref shared.worldMatrix); // Ensure the help overlay is up to date. HelpOverlay.RefreshTexture(); } // end of MiniHub UpdateObj Update()
public override void Render(Camera camera) { if (!parent.Active) { return; } ScreenSpaceQuad quad = ScreenSpaceQuad.GetInstance(); GraphicsDevice device = BokuGame.bokuGame.GraphicsDevice; HelpOverlay.RefreshTexture(); RenderTarget2D rt = UI2D.Shared.RenderTarget1024_768; Vector2 screenSize = new Vector2(device.Viewport.Width, device.Viewport.Height); Vector2 rtSize = new Vector2(rt.Width, rt.Height); if (shared.dataChanged) { shared.dataChanged = false; #if RenderColorBlocks InGame.SetRenderTarget(rt); // Clear the screen. InGame.Clear(Color.Black); // Render data block to screen. Vector4 colorLo = new Vector4(0, 0, 0, 1); Vector4 colorHi = new Vector4(0, 0, 0, 1); for (int j = 0; j < blockH; j++) { for (int i = 0; i < blockW; i++) { byte b = shared.data[i + j * blockW]; byte lo = (byte)(b & 0x0f); byte hi = (byte)((b & 0xf0) >> 4); // Least significant bits go into red. colorLo.X = (lo & 0x03) * 0.25f + 0.125f; colorLo.Y = ((lo >> 2) & 0x03) * 0.25f + 0.125f; colorHi.X = (hi & 0x03) * 0.25f + 0.125f; colorHi.Y = ((hi >> 2) & 0x03) * 0.25f + 0.125f; Block(colorLo, colorHi, i, j); } } InGame.RestoreRenderTarget(); #else try { // Render data block into memory. Color colorLo = Color.Black; Color colorHi = Color.Black; for (int j = 0; j < blockH; j++) { for (int i = 0; i < blockW; i++) { byte b = shared.data[i + j * blockW]; byte lo = (byte)(b & 0x0f); byte hi = (byte)((b & 0xf0) >> 4); // Least significant bits go into red. colorLo.R = (byte)((lo & 0x03) * 64 + 32); colorLo.G = (byte)(((lo >> 2) & 0x03) * 64 + 32); colorHi.R = (byte)((hi & 0x03) * 64 + 32); colorHi.G = (byte)(((hi >> 2) & 0x03) * 64 + 32); MemBlock(colorLo, colorHi, i, j); } } shared.texture.SetData <Color>(shared.colors); // Copy to rendertarget. InGame.SetRenderTarget(rt); quad.Render(shared.texture, Vector2.Zero, new Vector2(shared.texture.Width, shared.texture.Height), "TexturedNoAlpha"); InGame.RestoreRenderTarget(); } catch (Exception e) { if (e != null) { } // Something faileded, try again next frame. shared.dataChanged = true; } #endif } InGame.Clear(Color.Black); quad.Render(rt, Vector2.Zero, rtSize, @"TexturedNoAlpha"); } // end of Render()
public override void Render(Camera camera) { GraphicsDevice device = BokuGame.bokuGame.GraphicsDevice; HelpOverlay.RefreshTexture(); RenderTarget2D rt = UI2D.Shared.RenderTargetDepthStencil1280_720; Vector2 screenSize = BokuGame.ScreenSize; Vector2 rtSize = new Vector2(rt.Width, rt.Height); if (skipFrames > 0 || shared.waitingForStorage) { InGame.Clear(Color.Black); --skipFrames; return; } shared.liveFeed.FeedSize = shared.liveFeed.ResetScrollBoxSize; InGame.SetRenderTarget(rt); // Clear the screen & z-buffer. InGame.Clear(Color.Black); // Apply the background. ScreenSpaceQuad quad = ScreenSpaceQuad.GetInstance(); Vector2 position = Vector2.Zero; quad.Render(shared.backgroundTexture, position, rtSize, @"TexturedNoAlpha"); Color textColor = new Color(21, 125, 178); if (parent.newWorldDialog.Active) { // Hide the dialog if auth UI is active. Just keeps things cleaner. if (!AuthUI.IsModalActive) { // If options menu is active, render instead of main menu. parent.newWorldDialog.Render(new Vector2(rt.Width, rt.Height)); } } else if (shared.optionsMenu.Active) { // Hide the menu if auth UI is active. Just keeps things cleaner. if (!AuthUI.IsModalActive) { // If options menu is active, render instead of main menu. shared.optionsMenu.Render(); } } else { // Render url SpriteBatch batch = UI2D.Shared.SpriteBatch; UI2D.Shared.GetFont Font = UI2D.Shared.GetGameFont24; Vector2 size = Font().MeasureString(shared.screenUrl); Vector2 pos = new Vector2(rt.Width / 2 - size.X / 2, 586); batch.Begin(); TextHelper.DrawString(Font, shared.screenUrl, pos, textColor); batch.End(); shared.urlBox.Set(pos, pos + size); // Hide the menu if auth UI is active. Just keeps things cleaner. if (!AuthUI.IsModalActive) { // Render menu using local cameras. ShaderGlobals.SetCamera(shared.camera); shared.menu.WorldMatrix = Matrix.CreateTranslation(0.0f, -0.3f, 0.0f); shared.menu.Render(shared.camera); } // Render Boku. ShaderGlobals.SetCamera(shared.bokuCamera); string oldRig = BokuGame.bokuGame.shaderGlobals.PushLightRig(ShaderGlobals.GreeterRigName); // TODO (****) How to temporarily disable point lights??? // Do we really need to? //Luz.SetToEffect(true); // disable scene point lights if (BokuGame.bMarsMode) { shared.boku.Movement.Position = new Vector3(-0.0f, 0.25f, -0.5f); shared.boku.ReScale = 0.50f; //quad = ScreenSpaceQuad.GetInstance(); //float wid=shared.jplTexture.Width/2; //position = new Vector2(1250-(wid), 20); //quad.Render(shared.jplTexture, position, new Vector2(wid, shared.jplTexture.Height/2), @"TexturedRegularAlpha"); } else { shared.boku.Movement.Position = new Vector3(0.0f, 0.0f, 0.0f); } fVal += 0.01f; // Be sure to set the right camera so the env map looks correct. ShaderGlobals.SetCamera(shared.bokuCamera); shared.boku.RenderObject.Render(shared.bokuCamera); // TODO (****) How to temporarily disable point lights??? //Luz.SetToEffect(false); // re-enable scene point lights BokuGame.bokuGame.shaderGlobals.PopLightRig(oldRig); } InGame.RestoreRenderTarget(); InGame.Clear(new Color(20, 20, 20)); InGame.SetViewportToScreen(); // Copy the rendered scene to the backbuffer. { ScreenWarp.FitRtToScreen(rtSize); quad.Render(rt, ScreenWarp.RenderPosition, ScreenWarp.RenderSize, @"TexturedNoAlpha"); } // Render news feed. if (!shared.optionsMenu.Active) { shared.liveFeed.Render(); } // Hide overlay if auth UI is active. if (!AuthUI.IsModalActive) { HelpOverlay.Render(); } // Render text dialogs if being shown by OptionsMenu. // TODO (****) Need to get rid of rendering to RTs where possible. // TODO (****) Need to split OptionsMenu from MainMenu. if (shared.optionsMenu.Active) { InGame.inGame.shared.smallTextDisplay.Render(); InGame.inGame.shared.scrollableTextDisplay.Render(); } MainMenu.Instance.prevSessionCrashedMessage.Render(); MainMenu.Instance.noCommunityMessage.Render(); MainMenu.Instance.noSharingMessage.Render(); } // end of Render()