public override bool Draw(UltimaBatcher2D batcher, int x, int y) { if (_scene.ViewportTexture == null) { return(false); } Rectangle rectangle = ScissorStack.CalculateScissors(Matrix.Identity, x, y, Width, Height); if (ScissorStack.PushScissors(rectangle)) { batcher.EnableScissorTest(true); ResetHueVector(); if (ProfileManager.Current != null && ProfileManager.Current.UseXBR) { // draw regular world _xBR.SetSize(_scene.ViewportTexture.Width, _scene.ViewportTexture.Height); batcher.End(); batcher.Begin(_xBR); batcher.Draw2D(_scene.ViewportTexture, x, y, Width, Height, ref _hueVector); batcher.End(); batcher.Begin(); } else { batcher.Draw2D(_scene.ViewportTexture, x, y, Width, Height, ref _hueVector); } // draw lights // if (_scene.UseAltLights) // { // batcher.SetBlendState(_altLightsBlend); // _hueVector.Z = 0.5f; // batcher.Draw2D(_scene.LightRenderTarget, x, y, Width, Height, ref _hueVector); // _hueVector.Z = 0; // batcher.SetBlendState(null); // } // else if (_scene.UseLights) // { // batcher.SetBlendState(_darknessBlend); // batcher.Draw2D(_scene.LightRenderTarget, x, y, Width, Height, ref _hueVector); // batcher.SetBlendState(null); // } // draw overheads _scene.DrawSelection(batcher, x, y); _scene.DrawOverheads(batcher, x, y); base.Draw(batcher, x, y); batcher.EnableScissorTest(false); ScissorStack.PopScissors(); } return(true); }
public override bool Draw(UltimaBatcher2D batcher, int x, int y) { base.Draw(batcher, x, y); Rectangle scissor = ScissorStack.CalculateScissors(Matrix.Identity, x, y, Width, Height); if (ScissorStack.PushScissors(batcher.GraphicsDevice, scissor)) { batcher.EnableScissorTest(true); RenderedText t = _bookPage.renderedText; int startpage = (ActivePage - 1) * 2; if (startpage < BookPageCount) { int poy = _bookPage._pageCoords[startpage, 0], phy = _bookPage._pageCoords[startpage, 1]; _bookPage.DrawSelection(batcher, x + RIGHT_X, y + UPPER_MARGIN, poy, poy + phy); t.Draw(batcher, x + RIGHT_X, y + UPPER_MARGIN, 0, poy, t.Width, phy); if (startpage == _bookPage._caretPage) { if (_bookPage._caretPos.Y < poy + phy) { if (_bookPage._caretPos.Y >= poy) { if (_bookPage.HasKeyboardFocus) { _bookPage.renderedCaret.Draw(batcher, _bookPage._caretPos.X + x + RIGHT_X, _bookPage._caretPos.Y + y + UPPER_MARGIN - poy, 0, 0, _bookPage.renderedCaret.Width, _bookPage.renderedCaret.Height); } } else { _bookPage._caretPage = _bookPage.GetCaretPage(); } } else if (_bookPage._caretPos.Y <= _bookPage.Height) { if (_bookPage._caretPage + 2 < _bookPage._pagesChanged.Length) { _bookPage._focusPage = _bookPage._caretPage++; SetActivePage(_bookPage._caretPage / 2 + 2); } } } } startpage--; if (startpage > 0) { int poy = _bookPage._pageCoords[startpage, 0], phy = _bookPage._pageCoords[startpage, 1]; _bookPage.DrawSelection(batcher, x + LEFT_X, y + UPPER_MARGIN, poy, poy + phy); t.Draw(batcher, x + LEFT_X, y + UPPER_MARGIN, 0, poy, t.Width, phy); if (startpage == _bookPage._caretPage) { if (_bookPage._caretPos.Y < poy + phy) { if (_bookPage._caretPos.Y >= poy) { if (_bookPage.HasKeyboardFocus) { _bookPage.renderedCaret.Draw(batcher, _bookPage._caretPos.X + x + LEFT_X, _bookPage._caretPos.Y + y + UPPER_MARGIN - poy, 0, 0, _bookPage.renderedCaret.Width, _bookPage.renderedCaret.Height); } } else if (_bookPage._caretPage > 0) { _bookPage._focusPage = _bookPage._caretPage--; SetActivePage(_bookPage._caretPage / 2 + 1); } } else if (_bookPage._caretPos.Y <= _bookPage.Height) { if (_bookPage._caretPage + 2 < _bookPage._pagesChanged.Length) { _bookPage._caretPage++; } } } } batcher.EnableScissorTest(false); ScissorStack.PopScissors(batcher.GraphicsDevice); } return(true); }
public override void draw(Graphics graphics, float parentAlpha) { if (_widget == null) { return; } update(); validate(); // setup transform for this group. if (transform) { applyTransform(graphics, computeTransform()); } if (_scrollX) { _hKnobBounds.X = _hScrollBounds.X + (int)((_hScrollBounds.Width - _hKnobBounds.Width) * getVisualScrollPercentX()); } if (_scrollY) { _vKnobBounds.Y = _vScrollBounds.Y + (int)((_vScrollBounds.Height - _vKnobBounds.Height) * getVisualScrollPercentY()); } // calculate the widget's position depending on the scroll state and available widget area. float eleY = _widgetAreaBounds.Y; if (!_scrollY) { eleY -= _maxY; } else { eleY -= _visualAmountY; } float eleX = _widgetAreaBounds.Y; if (_scrollX) { eleX -= (int)_visualAmountX; } if (!_fadeScrollBars && _scrollbarsOnTop) { if (_scrollX && _hScrollOnBottom) { var scrollbarHeight = 0f; if (_style.hScrollKnob != null) { scrollbarHeight = _style.hScrollKnob.minHeight; } if (_style.hScroll != null) { scrollbarHeight = Math.Max(scrollbarHeight, _style.hScroll.minHeight); } eleY += scrollbarHeight; } if (_scrollY && !_vScrollOnRight) { var scrollbarWidth = 0f; if (_style.hScrollKnob != null) { scrollbarWidth = _style.hScrollKnob.minWidth; } if (_style.hScroll != null) { scrollbarWidth = Math.Max(scrollbarWidth, _style.hScroll.minWidth); } eleX += scrollbarWidth; } } _widget.setPosition(eleX, eleY); if (_widget is ICullable) { var cull = new Rectangle( (int)(-_widget.getX() + _widgetAreaBounds.X), (int)(-_widget.getY() + _widgetAreaBounds.Y), _widgetAreaBounds.Width, _widgetAreaBounds.Height); ((ICullable)_widget).setCullingArea(cull); } // draw the background var color = getColor(); color = new Color(color, (int)(color.A * parentAlpha)); if (_style.background != null) { _style.background.draw(graphics, 0, 0, getWidth(), getHeight(), color); } // caculate the scissor bounds based on the batch transform, the available widget area and the camera transform. We need to // project those to screen coordinates for OpenGL to consume. var scissor = ScissorStack.calculateScissors(stage?.camera, graphics.batcher.transformMatrix, _widgetAreaBounds); if (ScissorStack.pushScissors(scissor)) { graphics.batcher.enableScissorTest(true); drawChildren(graphics, parentAlpha); graphics.batcher.enableScissorTest(false); ScissorStack.popScissors(); } // render scrollbars and knobs on top var alpha = (float)color.A; color.A = (byte)(alpha * (_fadeAlpha / _fadeAlphaSeconds)); if (_scrollX && _scrollY) { if (_style.corner != null) { _style.corner.draw(graphics, _hScrollBounds.X + _hScrollBounds.Width, _hScrollBounds.Y, _vScrollBounds.Width, _vScrollBounds.Y, color); } } if (_scrollX) { if (_style.hScroll != null) { _style.hScroll.draw(graphics, _hScrollBounds.X, _hScrollBounds.Y, _hScrollBounds.Width, _hScrollBounds.Height, color); } if (_style.hScrollKnob != null) { _style.hScrollKnob.draw(graphics, _hKnobBounds.X, _hKnobBounds.Y, _hKnobBounds.Width, _hKnobBounds.Height, color); } } if (_scrollY) { if (_style.vScroll != null) { _style.vScroll.draw(graphics, _vScrollBounds.X, _vScrollBounds.Y, _vScrollBounds.Width, _vScrollBounds.Height, color); } if (_style.vScrollKnob != null) { _style.vScrollKnob.draw(graphics, _vKnobBounds.X, _vKnobBounds.Y, _vKnobBounds.Width, _vKnobBounds.Height, color); } } if (transform) { resetTransform(graphics); } }
/// <summary> /// Ends clipping begun by clipBegin(Batcher, float, float, float, float) /// </summary> /// <returns>The end.</returns> public void clipEnd(Batcher batcher) { batcher.enableScissorTest(false); ScissorStack.popScissors(); }
public override void Draw(GdxSpriteBatch spriteBatch, float parentAlpha) { if (_widget == null) { return; } Validate(); // Setup transform for this group ApplyTransform(spriteBatch, ComputeTransform()); if (IsScrollX) { _hKnobBounds.X = _hScrollBounds.X + (int)((_hScrollBounds.Width - _hKnobBounds.Width) * ScrollPercentX); } if (IsScrollY) { _vKnobBounds.Y = _vScrollBounds.Y + (int)((_vScrollBounds.Height - _vKnobBounds.Height) * (1 - ScrollPercentY)); } // Calculate the widget's position depending on the scroll state and available widget area. float y = _widgetAreaBounds.Y; if (!IsScrollY) { y -= (int)MaxY; } else { y -= (int)(MaxY - _visualAmountY); } if (!_fadeScrollBars && ScrollBarsOnTop && IsScrollX) { float scollbarHeight = 0; if (_style.HScrollKnob != null) { scollbarHeight = _style.HScrollKnob.MinHeight; } if (_style.HScroll != null) { scollbarHeight = Math.Max(scollbarHeight, _style.HScroll.MinHeight); } y += scollbarHeight; } float x = _widgetAreaBounds.X; if (IsScrollX) { x -= (int)_visualAmountX; } _widget.SetPosition(x, y); if (_widget is ICullable) { _widgetCullingArea.X = -_widget.X + _widgetAreaBounds.X; _widgetCullingArea.Y = -_widget.Y + _widgetAreaBounds.Y; _widgetCullingArea.Width = _widgetAreaBounds.Width; _widgetCullingArea.Height = _widgetAreaBounds.Height; (_widget as ICullable).SetCullingArea(_widgetCullingArea); } // Caculate the scissor bounds based on the batch transform, the available widget area and the camera transform. We need to // project those to screen coordinates for OpenGL ES to consume. _scissorBounds = ScissorStack.CalculateScissors(Stage.Camera, spriteBatch.TransformMatrix, (Rectangle)_widgetAreaBounds); // Draw the background ninepatch spriteBatch.Color = Color.MultiplyAlpha(parentAlpha); if (_style.Background != null) { _style.Background.Draw(spriteBatch, 0, 0, Width, Height); } spriteBatch.Flush(); // Enable scissors for widget area and draw the widget. if (Stage.ScissorStack.PushScissors(_scissorBounds)) { DrawChildren(spriteBatch, parentAlpha); Stage.ScissorStack.PopScissors(); } // Render scrollbars and knobs on top. spriteBatch.Color = Color.MultiplyAlpha(parentAlpha * Interpolation.Fade.Apply(_fadeAlpha / FadeAlphaSeconds)); if (IsScrollX && IsScrollY) { if (_style.Corner != null) { _style.Corner.Draw(spriteBatch, _hScrollBounds.X + _hScrollBounds.Width, _hScrollBounds.Y, _vScrollBounds.Width, _vScrollBounds.Height); } } if (IsScrollX) { if (_style.HScroll != null) { _style.HScroll.Draw(spriteBatch, _hScrollBounds.X, _hScrollBounds.Y, _hScrollBounds.Width, _hScrollBounds.Height); } if (_style.HScrollKnob != null) { _style.HScrollKnob.Draw(spriteBatch, _hKnobBounds.X, _hKnobBounds.Y, _hKnobBounds.Width, _hKnobBounds.Height); } } if (IsScrollY) { if (_style.VScroll != null) { _style.VScroll.Draw(spriteBatch, _vScrollBounds.X, _vScrollBounds.Y, _vScrollBounds.Width, _vScrollBounds.Height); } if (_style.VScrollKnob != null) { _style.VScrollKnob.Draw(spriteBatch, _vKnobBounds.X, _vKnobBounds.Y, _vKnobBounds.Width, _vKnobBounds.Height); } } ResetTransform(spriteBatch); }