protected override void Draw(SpriteBatch spriteBatch) { if (!Visible) { return; } if (ProgressGetter != null) { BarSize = ProgressGetter(); } Rectangle sliderRect = new Rectangle( frame.Rect.X, (int)(frame.Rect.Y + (isHorizontal ? 0 : frame.Rect.Height * (1.0f - barSize))), isHorizontal ? (int)((frame.Rect.Width) * barSize) : frame.Rect.Width, isHorizontal ? (int)(frame.Rect.Height) : (int)(frame.Rect.Height * barSize)); frame.Visible = true; slider.Visible = true; if (AutoDraw) { frame.DrawAuto(spriteBatch); } else { frame.DrawManually(spriteBatch); } Rectangle prevScissorRect = spriteBatch.GraphicsDevice.ScissorRectangle; if (BarSize <= 1.0f) { spriteBatch.End(); spriteBatch.GraphicsDevice.ScissorRectangle = Rectangle.Intersect(prevScissorRect, sliderRect); spriteBatch.Begin(SpriteSortMode.Deferred, rasterizerState: GameMain.ScissorTestEnable); } Color currColor = GetCurrentColor(state); slider.Color = currColor; if (AutoDraw) { slider.DrawAuto(spriteBatch); } else { slider.DrawManually(spriteBatch); } //hide the slider, we've already drawn it manually frame.Visible = false; slider.Visible = false; if (BarSize <= 1.0f) { spriteBatch.End(); spriteBatch.Begin(SpriteSortMode.Deferred, rasterizerState: GameMain.ScissorTestEnable); spriteBatch.GraphicsDevice.ScissorRectangle = prevScissorRect; } }
protected override void Draw(SpriteBatch spriteBatch) { if (!Visible) { return; } if (ProgressGetter != null) { float newSize = MathHelper.Clamp(ProgressGetter(), 0.0f, 1.0f); if (!MathUtils.IsValid(newSize)) { GameAnalyticsManager.AddErrorEventOnce( "GUIProgressBar.Draw:GetProgress", GameAnalyticsSDK.Net.EGAErrorSeverity.Error, "ProgressGetter of a GUIProgressBar (" + ProgressGetter.Target.ToString() + " - " + ProgressGetter.Method.ToString() + ") returned an invalid value (" + newSize + ")\n" + Environment.StackTrace.CleanupStackTrace()); } else { BarSize = newSize; } } var sliderRect = GetSliderRect(barSize); slider.RectTransform.AbsoluteOffset = new Point((int)style.Padding.X, (int)style.Padding.Y); slider.RectTransform.MaxSize = new Point( (int)(Rect.Width - style.Padding.X + style.Padding.Z), (int)(Rect.Height - style.Padding.Y + style.Padding.W)); frame.Visible = showFrame; slider.Visible = BarSize > 0.0f; if (showFrame) { if (AutoDraw) { frame.DrawAuto(spriteBatch); } else { frame.DrawManually(spriteBatch); } } Rectangle prevScissorRect = spriteBatch.GraphicsDevice.ScissorRectangle; if (BarSize <= 1.0f) { spriteBatch.End(); spriteBatch.GraphicsDevice.ScissorRectangle = Rectangle.Intersect(prevScissorRect, sliderRect); spriteBatch.Begin(SpriteSortMode.Deferred, samplerState: GUI.SamplerState, rasterizerState: GameMain.ScissorTestEnable); } Color currColor = GetColor(State); slider.Color = currColor; if (AutoDraw) { slider.DrawAuto(spriteBatch); } else { slider.DrawManually(spriteBatch); } //hide the slider, we've already drawn it manually frame.Visible = false; slider.Visible = false; if (BarSize <= 1.0f) { spriteBatch.End(); spriteBatch.Begin(SpriteSortMode.Deferred, rasterizerState: GameMain.ScissorTestEnable); spriteBatch.GraphicsDevice.ScissorRectangle = prevScissorRect; } }
protected override void Draw(SpriteBatch spriteBatch) { if (!Visible) { return; } if (ProgressGetter != null) { float newSize = MathHelper.Clamp(ProgressGetter(), 0.0f, 1.0f); if (!MathUtils.IsValid(newSize)) { GameAnalyticsManager.AddErrorEventOnce( "GUIProgressBar.Draw:GetProgress", GameAnalyticsSDK.Net.EGAErrorSeverity.Error, "ProgressGetter of a GUIProgressBar (" + ProgressGetter.Target.ToString() + " - " + ProgressGetter.Method.ToString() + ") returned an invalid value (" + newSize + ")\n" + Environment.StackTrace); } else { BarSize = newSize; } } Rectangle sliderRect = new Rectangle( frame.Rect.X, (int)(frame.Rect.Y + (isHorizontal ? 0 : frame.Rect.Height * (1.0f - barSize))), isHorizontal ? (int)((frame.Rect.Width) * barSize) : frame.Rect.Width, isHorizontal ? (int)(frame.Rect.Height) : (int)(frame.Rect.Height * barSize)); frame.Visible = true; slider.Visible = true; if (AutoDraw) { frame.DrawAuto(spriteBatch); } else { frame.DrawManually(spriteBatch); } Rectangle prevScissorRect = spriteBatch.GraphicsDevice.ScissorRectangle; if (BarSize <= 1.0f) { spriteBatch.End(); spriteBatch.GraphicsDevice.ScissorRectangle = Rectangle.Intersect(prevScissorRect, sliderRect); spriteBatch.Begin(SpriteSortMode.Deferred, rasterizerState: GameMain.ScissorTestEnable); } Color currColor = GetCurrentColor(state); slider.Color = currColor; if (AutoDraw) { slider.DrawAuto(spriteBatch); } else { slider.DrawManually(spriteBatch); } //hide the slider, we've already drawn it manually frame.Visible = false; slider.Visible = false; if (BarSize <= 1.0f) { spriteBatch.End(); spriteBatch.Begin(SpriteSortMode.Deferred, rasterizerState: GameMain.ScissorTestEnable); spriteBatch.GraphicsDevice.ScissorRectangle = prevScissorRect; } }