Make editor brushes disposable.
This commit is contained in:
@@ -24,7 +24,7 @@ using OpenRA.Widgets;
|
|||||||
|
|
||||||
namespace OpenRA.Mods.Common.Widgets
|
namespace OpenRA.Mods.Common.Widgets
|
||||||
{
|
{
|
||||||
public class EditorActorBrush : IEditorBrush
|
public sealed class EditorActorBrush : IEditorBrush
|
||||||
{
|
{
|
||||||
public readonly ActorInfo Actor;
|
public readonly ActorInfo Actor;
|
||||||
|
|
||||||
@@ -148,5 +148,7 @@ namespace OpenRA.Mods.Common.Widgets
|
|||||||
preview.Bounds.Width = (int)(zoom * s.X);
|
preview.Bounds.Width = (int)(zoom * s.X);
|
||||||
preview.Bounds.Height = (int)(zoom * s.Y);
|
preview.Bounds.Height = (int)(zoom * s.Y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void Dispose() { }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,13 +24,13 @@ using OpenRA.Widgets;
|
|||||||
|
|
||||||
namespace OpenRA.Mods.Common.Widgets
|
namespace OpenRA.Mods.Common.Widgets
|
||||||
{
|
{
|
||||||
public interface IEditorBrush
|
public interface IEditorBrush : IDisposable
|
||||||
{
|
{
|
||||||
bool HandleMouseInput(MouseInput mi);
|
bool HandleMouseInput(MouseInput mi);
|
||||||
void Tick();
|
void Tick();
|
||||||
}
|
}
|
||||||
|
|
||||||
public class EditorDefaultBrush : IEditorBrush
|
public sealed class EditorDefaultBrush : IEditorBrush
|
||||||
{
|
{
|
||||||
public readonly ActorInfo Actor;
|
public readonly ActorInfo Actor;
|
||||||
|
|
||||||
@@ -110,5 +110,6 @@ namespace OpenRA.Mods.Common.Widgets
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void Tick() { }
|
public void Tick() { }
|
||||||
|
public void Dispose() { }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ using OpenRA.Widgets;
|
|||||||
|
|
||||||
namespace OpenRA.Mods.Common.Widgets
|
namespace OpenRA.Mods.Common.Widgets
|
||||||
{
|
{
|
||||||
public class EditorResourceBrush : IEditorBrush
|
public sealed class EditorResourceBrush : IEditorBrush
|
||||||
{
|
{
|
||||||
public readonly ResourceTypeInfo ResourceType;
|
public readonly ResourceTypeInfo ResourceType;
|
||||||
|
|
||||||
@@ -119,5 +119,7 @@ namespace OpenRA.Mods.Common.Widgets
|
|||||||
preview.Bounds.X = cellScreenPixel.X;
|
preview.Bounds.X = cellScreenPixel.X;
|
||||||
preview.Bounds.Y = cellScreenPixel.Y;
|
preview.Bounds.Y = cellScreenPixel.Y;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void Dispose() { }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ using OpenRA.Widgets;
|
|||||||
|
|
||||||
namespace OpenRA.Mods.Common.Widgets
|
namespace OpenRA.Mods.Common.Widgets
|
||||||
{
|
{
|
||||||
public class EditorTileBrush : IEditorBrush
|
public sealed class EditorTileBrush : IEditorBrush
|
||||||
{
|
{
|
||||||
public readonly ushort Template;
|
public readonly ushort Template;
|
||||||
|
|
||||||
@@ -156,5 +156,7 @@ namespace OpenRA.Mods.Common.Widgets
|
|||||||
preview.Bounds.Width = (int)(zoom * bounds.Width);
|
preview.Bounds.Width = (int)(zoom * bounds.Width);
|
||||||
preview.Bounds.Height = (int)(zoom * bounds.Height);
|
preview.Bounds.Height = (int)(zoom * bounds.Height);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void Dispose() { }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -48,6 +48,9 @@ namespace OpenRA.Mods.Common.Widgets
|
|||||||
public void ClearBrush() { SetBrush(null); }
|
public void ClearBrush() { SetBrush(null); }
|
||||||
public void SetBrush(IEditorBrush brush)
|
public void SetBrush(IEditorBrush brush)
|
||||||
{
|
{
|
||||||
|
if (CurrentBrush != null)
|
||||||
|
CurrentBrush.Dispose();
|
||||||
|
|
||||||
CurrentBrush = brush ?? defaultBrush;
|
CurrentBrush = brush ?? defaultBrush;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user