Fix default UI shader applying effect parameters at the wrong time

Signed-off-by: Ritchie Frodomar <alkalinethunder@gmail.com>
This commit is contained in:
Ritchie Frodomar 2024-08-01 14:56:01 -04:00
parent 9972bffb5d
commit 344c1f682e
2 changed files with 8 additions and 12 deletions

View file

@ -39,15 +39,10 @@ public class MonoGameEffect :
underlyingEffect.Dispose();
}
public void UpdateWidgetParameters(float opacity, Matrix widgetTransform)
public void UpdateWidgetParameters(float newOpacity, Matrix newTransform)
{
if (this.widgetTransform != widgetTransform)
{
mustUpdateTransform = true;
this.widgetTransform = widgetTransform;
}
opacityParameter.SetValue(opacity);
widgetTransform = newTransform;
opacity = newOpacity;
}
public void Use(int pass)
@ -56,12 +51,11 @@ public class MonoGameEffect :
Viewport viewport = underlyingEffect.GraphicsDevice.Viewport;
if (mustUpdateTransform || viewport.Width != lastViewport.Width || viewport.Height != lastViewport.Height)
if (viewport.Width != lastViewport.Width || viewport.Height != lastViewport.Height)
{
lastViewport = viewport;
Matrix.CreateOrthographicOffCenter(0, viewport.Width, viewport.Height, 0, -32768, 32768, out transformMatrix);
transformMatrix *= widgetTransform;
transformMatrix = Matrix.CreateOrthographicOffCenter(0, viewport.Width, viewport.Height, 0, -32768, 32768);
}
projectionMatrixProperty?.SetValue(transformMatrix);

View file

@ -1,7 +1,7 @@
using AcidicGUI.CustomProperties;
using AcidicGUI.Events;
using AcidicGUI.Layout;
using AcidicGUI.Widgets;
using Microsoft.Xna.Framework;
namespace SociallyDistant.UI.Shell;
@ -17,6 +17,8 @@ public class Desktop :
internal Desktop(DesktopController desktopController)
{
this.Transform.Scale = Vector3.One * 0.5f;
dock = new Dock(desktopController);
this.desktopController = desktopController;