screens update normal logic during transition now; added comments; book now has an initiate function; image has more functions; minor improvements on module system;
This commit is contained in:
@@ -13,18 +13,27 @@ namespace RhythmBullet.Zer01HD.UI.Book
|
||||
{
|
||||
Camera2D camera;
|
||||
Page targetPage;
|
||||
Rectangle dimensions;
|
||||
Dictionary<string, Page> pages = new Dictionary<string, Page>();
|
||||
|
||||
public Book(Camera2D camera)
|
||||
/// <summary>
|
||||
/// Should be called whenever a valid camera and dimensions for the book exist.
|
||||
/// Initializes book with given parameters.
|
||||
/// </summary>
|
||||
/// <param name="camera">Camera game is currently using.</param>
|
||||
/// <param name="dimensions">Dimensions of the book and the dimensions the pages will use.</param>
|
||||
public void Initialize(Camera2D camera, Rectangle dimensions)
|
||||
{
|
||||
this.camera = camera;
|
||||
this.dimensions = dimensions;
|
||||
}
|
||||
|
||||
public void Draw(SpriteBatch batch)
|
||||
{
|
||||
for (int page = 0; page < pages.Count; page++)
|
||||
for (int pageIndex = 0; pageIndex < pages.Count; pageIndex++)
|
||||
{
|
||||
pages.ElementAt(page).Value.Draw(batch);
|
||||
Page page = pages.ElementAt(pageIndex).Value;
|
||||
page.Draw(batch);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,15 +52,20 @@ namespace RhythmBullet.Zer01HD.UI.Book
|
||||
}
|
||||
}
|
||||
|
||||
for (int page = 0; page < pages.Count; page++)
|
||||
for (int pageIndex = 0; pageIndex < pages.Count; pageIndex++)
|
||||
{
|
||||
pages.ElementAt(page).Value.Update(gameTime);
|
||||
Page page = pages.ElementAt(pageIndex).Value;
|
||||
if (page.NeedsSizeUpdate) page.ApplySize(dimensions.Width, dimensions.Height);
|
||||
page.Update(gameTime);
|
||||
}
|
||||
}
|
||||
|
||||
public void AddPage(Page page)
|
||||
public void AddPages(params Page[] pages)
|
||||
{
|
||||
pages.Add(page.Name, page);
|
||||
foreach (Page page in pages)
|
||||
{
|
||||
this.pages.Add(page.Name, page);
|
||||
}
|
||||
}
|
||||
|
||||
public void RemovePage(Page page)
|
||||
|
@@ -1,4 +1,5 @@
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using RhythmBullet.Zer01HD.UI.Modular;
|
||||
using RhythmBullet.Zer01HD.Utilities.Camera;
|
||||
using System;
|
||||
@@ -12,14 +13,14 @@ namespace RhythmBullet.Zer01HD.UI.Book
|
||||
class Page : UIModuleGroup
|
||||
{
|
||||
private readonly int pageX, pageY;
|
||||
private GraphicsDevice graphicsDevice;
|
||||
public bool NeedsSizeUpdate;
|
||||
|
||||
public Page(int pageX, int pageY, GraphicsDevice graphicsDevice)
|
||||
public Page(int pageX, int pageY) : base(false)
|
||||
{
|
||||
this.graphicsDevice = graphicsDevice;
|
||||
this.pageX = pageX;
|
||||
this.pageY = pageY;
|
||||
ApplySize(graphicsDevice.Viewport.Width, graphicsDevice.Viewport.Height);
|
||||
NeedsSizeUpdate = true;
|
||||
Name = ToString();
|
||||
}
|
||||
|
||||
public virtual void ApplySize(int width, int height)
|
||||
@@ -28,6 +29,7 @@ namespace RhythmBullet.Zer01HD.UI.Book
|
||||
Bounds.Y = pageY * height;
|
||||
Bounds.Width = width;
|
||||
Bounds.Height = height;
|
||||
NeedsSizeUpdate = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user