refactor and better screen mechanism (probably)

This commit is contained in:
2018-11-17 23:27:05 -06:00
parent 8377bb5ae8
commit 1195b8228a
15 changed files with 89 additions and 71 deletions

View File

@@ -0,0 +1,31 @@
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using RhythmBullet.Zer01HD.UI.Book;
using RhythmBullet.Zer01HD.Utilities.ContentSystem;
using RhythmBullet.Zer01HD.Utilities.UI.Modular.Modules;
namespace RhythmBullet.Zer01HD.Screens.MainMenu
{
internal class MainPage : Page
{
Image title;
internal MainPage(ContentManagerController assets) : base(0, 0)
{
title = new Image(assets.Get<Texture2D>("title"));
AddModule(title);
}
public override void ApplySize(int width, int height)
{
title.Scale = (width - 40) / title.Texture.Width;
title.Bounds.X = (int)((width - title.Bounds.Width) / 2f);
title.Bounds.Y = (int)((height - title.Bounds.Height) / 2f);
base.ApplySize(width, height);
}
public override void Draw(SpriteBatch batch)
{
base.Draw(batch);
}
}
}

View File

@@ -0,0 +1,59 @@

using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using RhythmBullet.Zer01HD.Screens.Transitions;
using RhythmBullet.Zer01HD.UI.Book;
using RhythmBullet.Zer01HD.Utilities.Camera;
using RhythmBullet.Zer01HD.Utilities.ContentSystem;
using RhythmBullet.Zer01HD.Utilities.ScreenSystem;
using System;
namespace RhythmBullet.Zer01HD.Screens.MainMenu
{
class MainScreen : Screen
{
ContentManagerController assets;
FadeAwayTransition fat;
Texture2D background;
Book book;
MainPage mainPage;
public MainScreen(ContentManagerController assets) : base(true)
{
this.assets = assets;
background = assets.Get<Texture2D>("backgrounds/mainBG");
fat = new FadeAwayTransition(1.5f);
book = new Book();
mainPage = new MainPage(assets);
book.AddPages(mainPage);
}
public override void Initiate(GraphicsDevice graphicsDevice, Rectangle screenSize, Camera2D camera)
{
book.Initiate(camera, screenSize);
base.Initiate(graphicsDevice, screenSize, camera);
}
public override void Show()
{
Mouse.SetCursor(MouseCursor.FromTexture2D(assets.Get<Texture2D>("cursor"), 256, 256));
Transitions.Add(fat);
base.Show();
}
public override void Draw(SpriteBatch spriteBatch)
{
spriteBatch.Draw(background, ScreenSize, Color.White);
book.Draw(spriteBatch);
base.Draw(spriteBatch);
}
public override void Update(GameTime gameTime)
{
book.Update(gameTime);
base.Update(gameTime);
}
}
}