rhythmbullet/RhythmBullet/Zer01HD/Utilities/UI/Screen.cs

103 lines
2.4 KiB
C#

using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace RhythmBullet.Zer01HD.Utilities.UI
{
public enum ScreenState { EnterTransition, ExitTransition, Normal }
public class Screen
{
public bool UseRenderTargetForExitTransition;
private GraphicsDevice GraphicsDevice;
public Screen(bool useEnterTransition = false)
{
State = useEnterTransition ? ScreenState.EnterTransition : ScreenState.Normal;
}
public void Initiate(Rectangle screenSize, GraphicsDevice graphicsDevice)
{
Initiated = true;
this.ScreenSize = screenSize;
this.GraphicsDevice = graphicsDevice;
RenderTarget = new RenderTarget2D(graphicsDevice, ScreenSize.Width, ScreenSize.Height);
}
public virtual void Update(GameTime gameTime)
{
}
public virtual void Draw(SpriteBatch spriteBatch)
{
}
public virtual void EnteringTransition(double delta, bool assetsLoaded, ref Color backgroundColor, RenderTarget2D previousScreenExitFrame)
{
}
public virtual bool ExitingTransition(double delta, bool assetsLoaded, ref Color backgroundColor)
{
return true;
}
public virtual void Show()
{
}
public virtual void Hide()
{
}
public virtual void AssetLoadStateChange(bool state)
{
}
public ScreenState State { get; private set; }
public void DoneEnterTransition()
{
State = ScreenState.Normal;
}
public void StartExitTransition(bool UseRenderTargetForExitTransition = false)
{
this.UseRenderTargetForExitTransition = UseRenderTargetForExitTransition;
State = ScreenState.ExitTransition;
}
public Screen NextScreen
{
get; protected set;
}
public Rectangle ScreenSize
{
get;
protected set;
//Remember to init in init func
}
public RenderTarget2D RenderTarget
{
get;
private set;
}
public bool Initiated
{
get;
private set;
}
}
}