new cursor while cleaning up from refactor.

This commit is contained in:
Harrison Deng 2018-11-18 00:17:23 -06:00
parent 1195b8228a
commit a4bedd34af
6 changed files with 39 additions and 4 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 82 KiB

After

Width:  |  Height:  |  Size: 272 KiB

View File

@ -35,6 +35,8 @@ namespace RhythmBullet
private bool resizing; private bool resizing;
private bool initialLoadComplete; private bool initialLoadComplete;
private MainScreen mainScreen; private MainScreen mainScreen;
private Texture2D currentCursorTexture;
public RhythmBulletGame() public RhythmBulletGame()
{ {
graphics = new GraphicsDeviceManager(this); graphics = new GraphicsDeviceManager(this);
@ -91,6 +93,8 @@ namespace RhythmBullet
protected override void UnloadContent() protected override void UnloadContent()
{ {
Assets.UnloadAll(); Assets.UnloadAll();
screenManager.Dispose();
currentCursorTexture.Dispose();
} }
/// <summary> /// <summary>
@ -108,10 +112,12 @@ namespace RhythmBullet
{ {
resizing = false; resizing = false;
PostResize(); PostResize();
} else if (!initialLoadComplete) }
else if (!initialLoadComplete)
{ {
Console.WriteLine("Initial load complete."); Debug.WriteLine("Initial load complete.");
initialLoadComplete = true; initialLoadComplete = true;
SetUpCursor();
mainScreen = new MainScreen(Assets); mainScreen = new MainScreen(Assets);
} }
@ -143,6 +149,7 @@ namespace RhythmBullet
Assets.UnloadAll(); Assets.UnloadAll();
QueueContent(); QueueContent();
screenManager.Resize(new LoadingScreen(this, Content.Load<Texture2D>("loading_ring"), 0.4f)); screenManager.Resize(new LoadingScreen(this, Content.Load<Texture2D>("loading_ring"), 0.4f));
SetUpCursor();
} }
private void PostResize() private void PostResize()
@ -159,6 +166,24 @@ namespace RhythmBullet
Assets.Queue<Texture2D>("backgrounds/mainBG"); Assets.Queue<Texture2D>("backgrounds/mainBG");
} }
private void SetUpCursor()
{
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);
GraphicsDevice.SetRenderTarget(renderTarget);
GraphicsDevice.Clear(Color.Transparent);
spriteBatch.Begin();
spriteBatch.Draw(texture, new Rectangle(0, 0, cursorSize, cursorSize), Color.White);
spriteBatch.End();
GraphicsDevice.SetRenderTarget(null);
currentCursorTexture?.Dispose();
currentCursorTexture = renderTarget;
Mouse.SetCursor(MouseCursor.FromTexture2D(currentCursorTexture, currentCursorTexture.Width / 2, currentCursorTexture.Height / 2));
}
private void RequireNextScreen(Screen Screen) private void RequireNextScreen(Screen Screen)
{ {
Screen.NextScreen = mainScreen; Screen.NextScreen = mainScreen;

View File

@ -38,7 +38,6 @@ namespace RhythmBullet.Zer01HD.Screens.MainMenu
public override void Show() public override void Show()
{ {
Mouse.SetCursor(MouseCursor.FromTexture2D(assets.Get<Texture2D>("cursor"), 256, 256));
Transitions.Add(fat); Transitions.Add(fat);
base.Show(); base.Show();
} }

View File

@ -45,7 +45,6 @@ namespace RhythmBullet.Zer01HD.Utilities.ContentSystem
public T Get<T>(string assetName) public T Get<T>(string assetName)
{ {
Console.WriteLine("Attempt get");
lock (queue) lock (queue)
{ {
return (T)assets[assetName]; return (T)assets[assetName];

View File

@ -31,7 +31,18 @@ namespace RhythmBullet.Zer01HD.Utilities.ScreenSystem
this.proportion = proportion; this.proportion = proportion;
this.rotate = rotate; this.rotate = rotate;
Transitions.Add(this); Transitions.Add(this);
}
public override void Show()
{
game.IsMouseVisible = false; game.IsMouseVisible = false;
base.Show();
}
public override void Hide()
{
game.IsMouseVisible = true;
base.Hide();
} }
public void InitiateTransition(Rectangle dimensions) public void InitiateTransition(Rectangle dimensions)

View File

@ -44,6 +44,7 @@ namespace RhythmBullet.Zer01HD.Utilities.ScreenSystem
Debug.WriteLine("Showing " + value.GetType().Name); Debug.WriteLine("Showing " + value.GetType().Name);
Screen.Show(); Screen.Show();
previousScreen?.Hide();
} }
} }