public void BaseRender(float elapsedms, GraphicsDevice g, SpriteBatch sb, InputManager input, float dx, float dy) { dx += x; dy += y; SelfRender(elapsedms, g, sb, input, dx, dy); if (ComponentsVisible) { for (int i = 0; i < Components.Count; i++) { BaseRenderLoopComponent = Components[i]; if (BaseRenderLoopComponent.Visible && !BaseRenderLoopComponent.SkipBaseRender) { BaseRenderLoopComponent.Render(elapsedms, g, sb, input, dx + InnerX, dy + InnerY); } } } }
public override void Render(float elapsedms, GraphicsDevice g, SpriteBatch sb, InputManager input, float dx, float dy) { // note: this component overwrites the base render logic Rectangle oldrect = RenderTargetScope.Open(sb, (int)Math.Floor(dx + x), (int)Math.Floor(dy + y), Width, Height); { dx += x; dy += y; SelfRender(elapsedms, g, sb, input, dx, dy); if (ComponentsVisible) { int count = 0; int totalw = 0; int totalh = 0; for (int i = StartingIndex; i < Components.Count && (MaxIndex == -1 || i <= MaxIndex) && (MaxCount == -1 || count < MaxCount); i++) { UIComponent u = Components[i]; if (u.Visible) { int uw = 0; int uh = 0; if (AutoOrientation == eUIOrientation.HORIZONTAL) { u.y = MarginY; uh = Height - MarginY * 2; if (FixedWidthPerIndex > 0) { u.x = MarginX + count * (MarginX * 2 + FixedWidthPerIndex); uw = FixedWidthPerIndex; } else { u.x = MarginX + totalw; totalw += u.GetWidth() + MarginX * 2; uw = u.GetWidth(); } } else { u.x = MarginX; uw = Width - MarginX * 2; if (FixedHeightPerIndex > 0) { u.y = MarginY + count * (MarginY * 2 + FixedHeightPerIndex); uh = FixedHeightPerIndex; } else { u.y = MarginY + totalh; totalh += u.GetHeight() + MarginY * 2; uh = u.GetHeight(); } } if (AlternateBackgrounds && count % 2 == 0) { Draw.DrawRectangleHandle(sb, (int)(dx + u.x - MarginX), (int)(dy + u.y - MarginY), uw + MarginX * 2, uh + MarginY * 2, BackgroundColor2); } Rectangle inneroldrect = RenderTargetScope.Open(sb, (int)Math.Floor(dx + u.x), (int)Math.Floor(dy + u.y), uw, uh); { u.Render(elapsedms, g, sb, input, dx + InnerX, dy + InnerY); } RenderTargetScope.Close(sb, inneroldrect); // draw border if (HasBorder) { Draw.DrawRectangleHandleOutline(sb, (int)(dx + u.x - MarginX), (int)(dy + u.y - MarginY), uw + MarginX * 2, uh + MarginY * 2, BorderColor, BorderWidth); } } count++; } } if (HasOuterBorder) { Draw.DrawRectangleHandleOutline(sb, (int)dx, (int)dy, Width, Height, OuterBorderColor, OuterBorderWidth); } } RenderTargetScope.Close(sb, oldrect); }