Skip to content

Commit

Permalink
DebugOverlay cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Xeeynamo committed May 23, 2020
1 parent fa6c308 commit 5fde86f
Showing 1 changed file with 5 additions and 26 deletions.
31 changes: 5 additions & 26 deletions OpenKh.Game/Debugging/DebugOverlay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@
using OpenKh.Engine.Renders;
using OpenKh.Game.Infrastructure;
using OpenKh.Game.States;
using OpenKh.Kh2;
using OpenKh.Kh2.Messages;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;

namespace OpenKh.Game.Debugging
{
Expand All @@ -22,13 +20,7 @@ public class DebugOverlay : IState, IDebug
private readonly IStateChange _stateChange;
private bool _overrideExternalDebugFeatures = false;

private Texture2D _texFontSys1;
private Texture2D _texFontSys2;
private Texture2D _texFontEvt1;
private Texture2D _texFontEvt2;
private Texture2D _texFontIcon;

private SpriteBatch _spriteBatch;
private MonoDrawing _drawing;
private IMessageEncoder _encoder;
private IMessageRenderer _messageRenderer;
private DrawContext _messageDrawContext;
Expand All @@ -45,36 +37,23 @@ public DebugOverlay(IStateChange stateChange)

public void Initialize(StateInitDesc initDesc)
{
_spriteBatch = new SpriteBatch(initDesc.GraphicsDevice.GraphicsDevice);

_dataContent = initDesc.DataContent;
_archiveManager = initDesc.ArchiveManager;
_kernel = initDesc.Kernel;
_inputManager = initDesc.InputManager;
_graphics = initDesc.GraphicsDevice;

_texFontSys1 = _kernel.FontContext.ImageSystem.CreateTexture(_graphics.GraphicsDevice);
_texFontSys2 = _kernel.FontContext.ImageSystem2.CreateTexture(_graphics.GraphicsDevice);
_texFontEvt1 = _kernel.FontContext.ImageEvent.CreateTexture(_graphics.GraphicsDevice);
_texFontEvt2 = _kernel.FontContext.ImageEvent2.CreateTexture(_graphics.GraphicsDevice);
_texFontIcon = _kernel.FontContext.ImageIcon.CreateTexture(_graphics.GraphicsDevice);

var drawing = new MonoDrawing(
initDesc.GraphicsDevice.GraphicsDevice, initDesc.ContentManager);
_drawing = new MonoDrawing(_graphics.GraphicsDevice, initDesc.ContentManager);

var messageContext = _kernel.SystemMessageContext;
_encoder = messageContext.Encoder;
_messageRenderer = new Kh2MessageRenderer(drawing, messageContext);
_messageRenderer = new Kh2MessageRenderer(_drawing, messageContext);
}

public void Destroy()
{
_spriteBatch?.Dispose();
_texFontSys1?.Dispose();
_texFontSys2?.Dispose();
_texFontEvt1?.Dispose();
_texFontEvt2?.Dispose();
_texFontIcon?.Dispose();
_drawing.Dispose();
// TODO destroy textures created by Kh2MessageRenderer
}

public void Update(DeltaTimes deltaTimes)
Expand Down

0 comments on commit 5fde86f

Please sign in to comment.