began implementing skin system.

This commit is contained in:
Harrison Deng 2019-01-20 23:32:51 -06:00
parent 549d30396e
commit 0e4fd611db

View File

@ -38,7 +38,8 @@ namespace RecrownedAthenaeum
private MainScreen mainScreen; private MainScreen mainScreen;
private Texture2D currentCursorTexture; private Texture2D currentCursorTexture;
internal readonly MusicController musicController; internal readonly MusicController musicController;
private Skin skin; private SkinManager skinManager = new SkinManager();
private readonly ISkin skin;
public RhythmBulletGame() public RhythmBulletGame()
{ {
@ -47,12 +48,13 @@ namespace RecrownedAthenaeum
assets = new ContentManagerController(Content); assets = new ContentManagerController(Content);
musicController = new MusicController(); musicController = new MusicController();
skin = skinManager.Skin;
resolutionContentResolver = new ResolutionContentResolver(); resolutionContentResolver = new ResolutionContentResolver();
FontContentResolver fcr = new FontContentResolver(resolutionContentResolver); FontContentResolver fcr = new FontContentResolver(resolutionContentResolver);
assets.contentPathModifier.Add(typeof(Texture2D), resolutionContentResolver); assets.contentPathModifier.Add(typeof(Texture2D), resolutionContentResolver);
assets.contentPathModifier.Add(typeof(SpriteFont), fcr); assets.contentPathModifier.Add(typeof(SpriteFont), fcr);
preferencesManager = new PreferencesManager(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "/RhythmBullet", preferencesManager = new PreferencesManager(
Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "/RhythmBullet",
new General(), new General(),
new Controls()); new Controls());
preferencesManager.Load(); preferencesManager.Load();
@ -123,12 +125,10 @@ namespace RecrownedAthenaeum
else if (!initialLoadComplete) else if (!initialLoadComplete)
{ {
Debug.WriteLine("Initial load complete."); Debug.WriteLine("Initial load complete.");
initialLoadComplete = true; Initiate();
SetUpCursor();
mainScreen = new MainScreen(assets);
} }
screenManager.UpdateCurrentScreen(gameTime, assets.Done && musicController.musicList.Searched); screenManager.UpdateCurrentScreen(gameTime, CheckReadyForInitiate());
InputUtilities.Update(); InputUtilities.Update();
Camera.Update(); Camera.Update();
@ -156,7 +156,7 @@ namespace RecrownedAthenaeum
assets.UnloadAll(); assets.UnloadAll();
QueueContent(); QueueContent();
screenManager.Resize(new LoadingScreen(this, Content.Load<Texture2D>("loading_ring"), 0.4f, true)); screenManager.Resize(new LoadingScreen(this, Content.Load<Texture2D>("loading_ring"), 0.4f, true));
SetUpCursor(); UpdateCursor();
} }
private void PostResize() private void PostResize()
@ -174,9 +174,16 @@ namespace RecrownedAthenaeum
assets.Queue<TextureAtlas>("UI"); assets.Queue<TextureAtlas>("UI");
} }
private void SetUpCursor() private void Initiate()
{ {
Texture2D texture = assets.Get<Texture2D>("cursor"); initialLoadComplete = true;
UpdateCursor();
mainScreen = new MainScreen(assets);
}
private void UpdateCursor()
{
Texture2D texture = skin.CursorTexture;
int cursorSize = (int)(0.08f * graphics.PreferredBackBufferHeight); int cursorSize = (int)(0.08f * graphics.PreferredBackBufferHeight);
Debug.WriteLine("Cursor size length: " + cursorSize); Debug.WriteLine("Cursor size length: " + cursorSize);
RenderTarget2D renderTarget = new RenderTarget2D(GraphicsDevice, cursorSize, cursorSize); RenderTarget2D renderTarget = new RenderTarget2D(GraphicsDevice, cursorSize, cursorSize);
@ -192,6 +199,11 @@ namespace RecrownedAthenaeum
Mouse.SetCursor(MouseCursor.FromTexture2D(currentCursorTexture, currentCursorTexture.Width / 2, currentCursorTexture.Height / 2)); Mouse.SetCursor(MouseCursor.FromTexture2D(currentCursorTexture, currentCursorTexture.Width / 2, currentCursorTexture.Height / 2));
} }
private bool CheckReadyForInitiate()
{
return assets.Done && musicController.musicList.Searched && skinManager.ReadyForUse;
}
private void ShowFirstScreen(Screen Screen) private void ShowFirstScreen(Screen Screen)
{ {
Screen.NextScreen = mainScreen; Screen.NextScreen = mainScreen;