using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using RecrownedAthenaeum.ContentSystem;
using RecrownedAthenaeum.Input;
using RecrownedAthenaeum.Render;
using RecrownedAthenaeum.UI.ScreenSystem;
using RecrownedAthenaeum.UI.BookSystem;
using RecrownedAthenaeum.UI.SkinSystem;
using RhythmBullet.Screens.Transitions;

namespace RhythmBullet.Screens.MainMenu
{
    class MainScreen : Screen
    {
        readonly ContentManagerController assets;
        readonly FadeAwayTransition fat;
        readonly Texture2D background;
        readonly Book book;
        readonly MainPage mainPage;
        Rectangle screenSize;

        public MainScreen(ContentManagerController assets, ISkin skin, Camera2D camera) : base(true)
        {
            this.assets = assets;
            fat = new FadeAwayTransition(1.5f);
            book = new Book(assets, skin, camera);
            mainPage = new MainPage();
            book.AddPages(mainPage);
            InputUtilities.InputListeners.Add(book);
        }

        public override void ApplySize(int width, int height)
        {
            screenSize.Width = width;
            screenSize.Height = height;
            book.ApplySize(width, height);
            base.ApplySize(width, height);
        }

        public override void Show()
        {
            Transitions.Add(fat);
            base.Show();
        }

        public override void Draw(ConsistentSpriteBatch 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);
        }
    }
}
