1
0
Fork 0
mirror of https://github.com/Ellpeck/MLEM.git synced 2024-05-13 12:48:45 +02:00

remove unnecessary references to GraphicsDevice from UiSystem

This commit is contained in:
Ell 2021-03-29 02:26:44 +02:00
parent 28eafffa32
commit e6243b831c
3 changed files with 3 additions and 9 deletions

View file

@ -72,7 +72,7 @@ namespace MLEM.Startup {
this.SpriteBatch = new SpriteBatch(this.GraphicsDevice);
this.InputHandler = new InputHandler(this);
this.Components.Add(this.InputHandler);
this.UiSystem = new UiSystem(this, this.GraphicsDevice, new UntexturedStyle(this.SpriteBatch), this.InputHandler);
this.UiSystem = new UiSystem(this, new UntexturedStyle(this.SpriteBatch), this.InputHandler);
this.Components.Add(this.UiSystem);
this.OnLoadContent?.Invoke(this);
}

View file

@ -230,7 +230,7 @@ namespace MLEM.Ui.Elements {
if (this.renderTarget == null || targetArea.Width != this.renderTarget.Width || targetArea.Height != this.renderTarget.Height) {
if (this.renderTarget != null)
this.renderTarget.Dispose();
this.renderTarget = targetArea.IsEmpty ? null : new RenderTarget2D(this.System.GraphicsDevice, targetArea.Width, targetArea.Height);
this.renderTarget = targetArea.IsEmpty ? null : new RenderTarget2D(this.System.Game.GraphicsDevice, targetArea.Width, targetArea.Height);
}
}

View file

@ -21,10 +21,6 @@ namespace MLEM.Ui {
/// </summary>
public class UiSystem : GameComponent {
/// <summary>
/// The graphics device that this ui system uses for its size calculations
/// </summary>
public readonly GraphicsDevice GraphicsDevice;
private readonly List<RootElement> rootElements = new List<RootElement>();
/// <summary>
@ -177,13 +173,11 @@ namespace MLEM.Ui {
/// Creates a new ui system with the given settings.
/// </summary>
/// <param name="game">The game</param>
/// <param name="device">The graphics device that should be used for viewport calculations</param>
/// <param name="style">The style settings that this ui should have. Use <see cref="UntexturedStyle"/> for the default, untextured style.</param>
/// <param name="inputHandler">The input handler that this ui's <see cref="UiControls"/> should use. If none is supplied, a new input handler is created for this ui.</param>
/// <param name="automaticViewport">If this value is set to true, the ui system's <see cref="Viewport"/> will be set automatically based on the <see cref="GameWindow"/>'s size. Defaults to true.</param>
public UiSystem(Game game, GraphicsDevice device, UiStyle style, InputHandler inputHandler = null, bool automaticViewport = true) : base(game) {
public UiSystem(Game game, UiStyle style, InputHandler inputHandler = null, bool automaticViewport = true) : base(game) {
this.Controls = new UiControls(this, inputHandler);
this.GraphicsDevice = device;
this.style = style;
if (automaticViewport) {