added convenience asset passing for books and pages.
This commit is contained in:
parent
449ac58c6f
commit
6ba5274942
@ -1,6 +1,7 @@
|
|||||||
using Microsoft.Xna.Framework;
|
using Microsoft.Xna.Framework;
|
||||||
using Microsoft.Xna.Framework.Graphics;
|
using Microsoft.Xna.Framework.Graphics;
|
||||||
using RecrownedAthenaeum.Camera;
|
using RecrownedAthenaeum.Camera;
|
||||||
|
using RecrownedAthenaeum.ContentSystem;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
|
||||||
@ -11,11 +12,21 @@ namespace RecrownedAthenaeum.UI.Book
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class Book
|
public class Book
|
||||||
{
|
{
|
||||||
|
readonly ContentManagerController assets;
|
||||||
Camera2D camera;
|
Camera2D camera;
|
||||||
Page targetPage;
|
Page targetPage;
|
||||||
Rectangle dimensions;
|
Rectangle dimensions;
|
||||||
Dictionary<string, Page> pages = new Dictionary<string, Page>();
|
Dictionary<string, Page> pages = new Dictionary<string, Page>();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Creates a book.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="assets"><see cref="ContentManagerController"/> that holds the assets that are to be used in the pages for this book during initialization.</param>
|
||||||
|
public Book(ContentManagerController assets)
|
||||||
|
{
|
||||||
|
this.assets = assets;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Should be called whenever a valid camera and dimensions for the book exist.
|
/// Should be called whenever a valid camera and dimensions for the book exist.
|
||||||
/// Initializes book with given parameters.
|
/// Initializes book with given parameters.
|
||||||
@ -76,7 +87,7 @@ namespace RecrownedAthenaeum.UI.Book
|
|||||||
{
|
{
|
||||||
foreach (Page page in pages)
|
foreach (Page page in pages)
|
||||||
{
|
{
|
||||||
page.Initialize();
|
page.Initialize(assets);
|
||||||
this.pages.Add(page.Name, page);
|
this.pages.Add(page.Name, page);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using RecrownedAthenaeum.UI.Modular;
|
using RecrownedAthenaeum.ContentSystem;
|
||||||
|
using RecrownedAthenaeum.UI.Modular;
|
||||||
|
|
||||||
namespace RecrownedAthenaeum.UI.Book
|
namespace RecrownedAthenaeum.UI.Book
|
||||||
{
|
{
|
||||||
@ -43,7 +44,8 @@ namespace RecrownedAthenaeum.UI.Book
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Called only once after a page is added to a <see cref="Book"/>. Generally used to instantiate the modules of the page.
|
/// Called only once after a page is added to a <see cref="Book"/>. Generally used to instantiate the modules of the page.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected internal virtual void Initialize()
|
/// <param name="assets">The assets to be used during initialization passed by the book this page belongs to.</param>
|
||||||
|
protected internal virtual void Initialize(ContentManagerController assets)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user