began implementing music controller system.

This commit is contained in:
Harrison Deng 2018-11-19 23:08:11 -06:00
parent 673cdd0b79
commit 1edebdd223

View File

@ -1,6 +1,7 @@
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using RhythmBullet.Zer01HD.Audio;
using RhythmBullet.Zer01HD.ContentResolvers;
using RhythmBullet.Zer01HD.Preferences;
using RhythmBullet.Zer01HD.Screens.MainMenu;
@ -27,7 +28,7 @@ namespace RhythmBullet
GraphicsDeviceManager graphics;
SpriteBatch spriteBatch;
public readonly ContentManagerController Assets;
public readonly ContentManagerController assets;
readonly ResolutionContentResolver resolutionContentResolver;
public PreferencesManager preferencesManager;
private ScreenManager screenManager;
@ -36,17 +37,20 @@ namespace RhythmBullet
private bool initialLoadComplete;
private MainScreen mainScreen;
private Texture2D currentCursorTexture;
internal readonly MusicController musicController;
public RhythmBulletGame()
{
graphics = new GraphicsDeviceManager(this);
Content.RootDirectory = "Content";
Assets = new ContentManagerController(Content);
assets = new ContentManagerController(Content);
musicController = new MusicController();
resolutionContentResolver = new ResolutionContentResolver();
FontContentResolver fcr = new FontContentResolver(resolutionContentResolver);
Assets.contentPathModifier.Add(typeof(Texture2D), resolutionContentResolver);
Assets.contentPathModifier.Add(typeof(SpriteFont), fcr);
assets.contentPathModifier.Add(typeof(Texture2D), resolutionContentResolver);
assets.contentPathModifier.Add(typeof(SpriteFont), fcr);
preferencesManager = new PreferencesManager(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "/RhythmBullet",
new General(),
new Controls());
@ -67,6 +71,8 @@ namespace RhythmBullet
Resolution resolution = preferencesManager.GetPreferences<General>().Resolution;
resolutionContentResolver.Width = resolution.Width;
resolutionContentResolver.Height = resolution.Height;
musicController.musicList.path = preferencesManager.GetPreferences<General>().MusicDirectory;
musicController.musicList.StartSearch();
Debug.WriteLine("Initial setup complete.");
base.Initialize();
}
@ -92,7 +98,7 @@ namespace RhythmBullet
/// </summary>
protected override void UnloadContent()
{
Assets.UnloadAll();
assets.UnloadAll();
screenManager.Dispose();
currentCursorTexture.Dispose();
}
@ -104,9 +110,9 @@ namespace RhythmBullet
/// <param name="gameTime">Provides a snapshot of timing values.</param>
protected override void Update(GameTime gameTime)
{
if (!Assets.Done)
if (!assets.Done)
{
Assets.Update();
assets.Update();
}
else if (resizing)
{
@ -118,10 +124,10 @@ namespace RhythmBullet
Debug.WriteLine("Initial load complete.");
initialLoadComplete = true;
SetUpCursor();
mainScreen = new MainScreen(Assets);
mainScreen = new MainScreen(assets);
}
screenManager.UpdateCurrentScreen(gameTime, Assets.Done);
screenManager.UpdateCurrentScreen(gameTime, assets.Done && musicController.musicList.Searched);
InputUtilities.Update();
Camera.Update();
@ -146,7 +152,7 @@ namespace RhythmBullet
graphics.PreferredBackBufferWidth = width;
graphics.PreferredBackBufferHeight = height;
resizing = true;
Assets.UnloadAll();
assets.UnloadAll();
QueueContent();
screenManager.Resize(new LoadingScreen(this, Content.Load<Texture2D>("loading_ring"), 0.4f));
SetUpCursor();
@ -160,15 +166,15 @@ namespace RhythmBullet
private void QueueContent()
{
Assets.Queue<Texture2D>("cursor", false);
Assets.Queue<Texture2D>("title");
Assets.Queue<Texture2D>("default_cover", false);
Assets.Queue<Texture2D>("backgrounds/mainBG");
assets.Queue<Texture2D>("cursor", false);
assets.Queue<Texture2D>("title");
assets.Queue<Texture2D>("default_cover", false);
assets.Queue<Texture2D>("backgrounds/mainBG");
}
private void SetUpCursor()
{
Texture2D texture = Assets.Get<Texture2D>("cursor");
Texture2D texture = assets.Get<Texture2D>("cursor");
int cursorSize = (int)(0.08f * graphics.PreferredBackBufferHeight);
Debug.WriteLine("Cursor size length: " + cursorSize);
RenderTarget2D renderTarget = new RenderTarget2D(GraphicsDevice, cursorSize, cursorSize);