/// <summary>Immediately releases all resources used the GUI manager</summary> public void Dispose() { // Unregister the service if we have registered it before if (_gameServices != null) { var registeredService = _gameServices.GetService(typeof(IGuiService)); if (ReferenceEquals(registeredService, this)) { _gameServices.RemoveService(typeof(IGuiService)); } } // Dispose the input capturer, if necessary if (_inputCapturer != null) { var disposableInputCapturer = _inputCapturer as IDisposable; disposableInputCapturer?.Dispose(); _updateableInputCapturer = null; _inputCapturer = null; } // Dispose the GUI visualizer, if necessary if (_guiVisualizer != null) { var disposableguiVisualizer = _guiVisualizer as IDisposable; disposableguiVisualizer?.Dispose(); _updateableGuiVisualizer = null; _guiVisualizer = null; } }
public void TestVisualizerUpdate() { using (GuiManager guiManager = new GuiManager(new GameServiceContainer())) { DummyVisualizer dummy = new DummyVisualizer(); IGuiVisualizer visualizer = guiManager.Visualizer; guiManager.Visualizer = dummy; tryDispose(visualizer); Assert.AreEqual(0, dummy.UpdateCallCount); guiManager.Update(new GameTime()); Assert.AreEqual(1, dummy.UpdateCallCount); } }
public void TestDrawing() { using (GuiManager guiManager = new GuiManager(new GameServiceContainer())) { DummyVisualizer dummy = new DummyVisualizer(); IGuiVisualizer visualizer = guiManager.Visualizer; guiManager.Visualizer = dummy; tryDispose(visualizer); guiManager.Screen = new Screen(); Assert.AreEqual(0, dummy.DrawCallCount); guiManager.Draw(new GameTime()); Assert.AreEqual(1, dummy.DrawCallCount); } }
public void TestVisualizerAssignment() { using (GuiManager guiManager = new GuiManager(new GameServiceContainer())) { IGuiVisualizer visualizer = new DummyVisualizer(); try { IGuiVisualizer newVisualizer = visualizer; Assert.AreNotSame(newVisualizer, guiManager.Visualizer); { IGuiVisualizer oldVisualizer = guiManager.Visualizer; guiManager.Visualizer = newVisualizer; visualizer = oldVisualizer; } Assert.AreSame(newVisualizer, guiManager.Visualizer); } finally { tryDispose(visualizer); } } }
public override void LoadContent(DeviceContext context) { _guiVisualizer = ToDispose(FlatGuiVisualizer.FromFile(_d3DEngine, _skinPath, _plugInComponentAssemblies)); }