recrownedathenaeum/TestGame/TestGame.cs

115 lines
4.2 KiB
C#

using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using RecrownedAthenaeum.Render;
using RecrownedAthenaeum.ScreenSystem;
using RecrownedAthenaeum.SpecialTypes;
using RecrownedAthenaeum.UI.Modular.Modules;
using RecrownedAthenaeum.UI.SkinSystem;
using RecrownedAthenaeum.UI.SkinSystem.Definitions;
namespace TestGame
{
/// <summary>
/// This is the main type for your game.
/// </summary>
public class TestGame : Game
{
GraphicsDeviceManager graphics;
ConsistentSpriteBatch spriteBatch;
Camera2D camera;
BasicEffect effect;
UIScrollable uIScrollable;
Texture2D logo;
Image logoImage;
Skin skin;
public TestGame()
{
graphics = new GraphicsDeviceManager(this);
Content.RootDirectory = "Content";
}
/// <summary>
/// Allows the game to perform any initialization it needs to before starting to run.
/// This is where it can query for any required services and load any non-graphic
/// related content. Calling base.Initialize will enumerate through any components
/// and initialize them as well.
/// </summary>
protected override void Initialize()
{
// TODO: Add your initialization logic here
IsMouseVisible = true;
base.Initialize();
}
/// <summary>
/// LoadContent will be called once per game and is the place to load
/// all of your content.
/// </summary>
protected override void LoadContent()
{
// Create a new SpriteBatch, which can be used to draw textures.
spriteBatch = new ConsistentSpriteBatch(GraphicsDevice);
effect = new BasicEffect(GraphicsDevice);
effect.TextureEnabled = true;
effect.VertexColorEnabled = true;
camera = new Camera2D(graphics.PreferredBackBufferWidth, graphics.PreferredBackBufferHeight, effect);
skin = new Skin(Content.Load<TextureAtlas>("UI"), Content.Load<Texture2D>("cursor"));
skin.AddDefinition(new UIScrollableSkinDefinition("ScrollBar", "ScrollBar"));
logo = Content.Load<Texture2D>("RhythmBullet");
skin.Laminate();
uIScrollable = new UIScrollable(skin);
uIScrollable.Width = 256;
uIScrollable.Height = 256;
uIScrollable.HideScrollBars = false;
logoImage = new Image(logo);
uIScrollable.AddModules(logoImage);
// TODO: use this.Content to load your game content here
}
/// <summary>
/// UnloadContent will be called once per game and is the place to unload
/// game-specific content.
/// </summary>
protected override void UnloadContent()
{
// TODO: Unload any non ContentManager content here
}
/// <summary>
/// Allows the game to run logic such as updating the world,
/// checking for collisions, gathering input, and playing audio.
/// </summary>
/// <param name="gameTime">Provides a snapshot of timing values.</param>
protected override void Update(GameTime gameTime)
{
if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
Exit();
uIScrollable.Update(gameTime);
// TODO: Add your update logic here
base.Update(gameTime);
}
/// <summary>
/// This is called when the game should draw itself.
/// </summary>
/// <param name="gameTime">Provides a snapshot of timing values.</param>
protected override void Draw(GameTime gameTime)
{
spriteBatch.effect = effect;
GraphicsDevice.Clear(Color.CornflowerBlue);
spriteBatch.Begin(effect: effect);
Rectangle smallRect = new Rectangle(0, 0, 64, 64);
uIScrollable.Draw(spriteBatch);
Rectangle normal = new Rectangle(0, 0, 128, 128);
spriteBatch.End();
base.Draw(gameTime);
}
}
}