mirror of
https://github.com/digital-jellyfish/Virtu.git
synced 2024-06-02 12:41:31 +00:00
2167383a00
Upgraded to FxCop 10.0. Dropped Silverlight Toolkit dependency (for now). Modified AudioService to avoid deadlocks by using timeouts. Refactored DebugService and implementations. Modified SilverlightVideoService to handle browser zoom. Split Wpf MainWindow into MainPage child control. --HG-- extra : convert_revision : svn%3Affd33b8c-2492-42e0-bdc5-587b920b7d6d/trunk%4048619
92 lines
2.9 KiB
C#
92 lines
2.9 KiB
C#
using Jellyfish.Library;
|
|
using Jellyfish.Virtu.Services;
|
|
using Microsoft.Xna.Framework;
|
|
using Microsoft.Xna.Framework.Graphics;
|
|
|
|
namespace Jellyfish.Virtu
|
|
{
|
|
public sealed class MainGame : GameBase
|
|
{
|
|
public MainGame() :
|
|
base("Virtu")
|
|
{
|
|
#if WINDOWS
|
|
IsMouseVisible = true;
|
|
#endif
|
|
var frameRateCounter = new FrameRateCounter(this); // no initializers; avoids CA2000
|
|
Components.Add(frameRateCounter);
|
|
frameRateCounter.DrawOrder = 1;
|
|
frameRateCounter.FontName = "Consolas";
|
|
|
|
_debugService = new DebugService(_machine);
|
|
#if WINDOWS_PHONE
|
|
_storageService = new IsolatedStorageService(_machine);
|
|
#else
|
|
_storageService = new XnaStorageService(_machine, this);
|
|
#endif
|
|
_keyboardService = new XnaKeyboardService(_machine);
|
|
_gamePortService = new XnaGamePortService(_machine);
|
|
_audioService = new XnaAudioService(_machine, this);
|
|
_videoService = new XnaVideoService(_machine, this);
|
|
|
|
_machine.Services.AddService(typeof(DebugService), _debugService);
|
|
_machine.Services.AddService(typeof(StorageService), _storageService);
|
|
_machine.Services.AddService(typeof(KeyboardService), _keyboardService);
|
|
_machine.Services.AddService(typeof(GamePortService), _gamePortService);
|
|
_machine.Services.AddService(typeof(AudioService), _audioService);
|
|
_machine.Services.AddService(typeof(VideoService), _videoService);
|
|
}
|
|
|
|
protected override void Dispose(bool disposing)
|
|
{
|
|
if (disposing)
|
|
{
|
|
_machine.Dispose();
|
|
_debugService.Dispose();
|
|
_storageService.Dispose();
|
|
_keyboardService.Dispose();
|
|
_gamePortService.Dispose();
|
|
_audioService.Dispose();
|
|
_videoService.Dispose();
|
|
}
|
|
|
|
base.Dispose(disposing);
|
|
}
|
|
|
|
protected override void BeginRun()
|
|
{
|
|
_machine.Start();
|
|
}
|
|
|
|
protected override void Update(GameTime gameTime)
|
|
{
|
|
_keyboardService.Update();
|
|
_gamePortService.Update();
|
|
|
|
base.Update(gameTime);
|
|
}
|
|
|
|
protected override void Draw(GameTime gameTime)
|
|
{
|
|
GraphicsDevice.Clear(Color.Black);
|
|
_videoService.Update();
|
|
|
|
base.Draw(gameTime);
|
|
}
|
|
|
|
protected override void EndRun()
|
|
{
|
|
_machine.Stop();
|
|
}
|
|
|
|
private Machine _machine = new Machine();
|
|
|
|
private DebugService _debugService;
|
|
private StorageService _storageService;
|
|
private KeyboardService _keyboardService;
|
|
private GamePortService _gamePortService;
|
|
private AudioService _audioService;
|
|
private VideoService _videoService;
|
|
}
|
|
}
|