From 6ba5274942214b85f54c31d16118ecbc8ce480d8 Mon Sep 17 00:00:00 2001 From: Recrown Date: Sun, 27 Jan 2019 15:24:31 -0600 Subject: [PATCH] added convenience asset passing for books and pages. --- RecrownedAthenaeum/UI/Book/Book.cs | 13 ++++++++++++- RecrownedAthenaeum/UI/Book/Page.cs | 6 ++++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/RecrownedAthenaeum/UI/Book/Book.cs b/RecrownedAthenaeum/UI/Book/Book.cs index 18e7a46..071b54d 100644 --- a/RecrownedAthenaeum/UI/Book/Book.cs +++ b/RecrownedAthenaeum/UI/Book/Book.cs @@ -1,6 +1,7 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using RecrownedAthenaeum.Camera; +using RecrownedAthenaeum.ContentSystem; using System.Collections.Generic; using System.Linq; @@ -11,11 +12,21 @@ namespace RecrownedAthenaeum.UI.Book /// public class Book { + readonly ContentManagerController assets; Camera2D camera; Page targetPage; Rectangle dimensions; Dictionary pages = new Dictionary(); + /// + /// Creates a book. + /// + /// that holds the assets that are to be used in the pages for this book during initialization. + public Book(ContentManagerController assets) + { + this.assets = assets; + } + /// /// Should be called whenever a valid camera and dimensions for the book exist. /// Initializes book with given parameters. @@ -76,7 +87,7 @@ namespace RecrownedAthenaeum.UI.Book { foreach (Page page in pages) { - page.Initialize(); + page.Initialize(assets); this.pages.Add(page.Name, page); } } diff --git a/RecrownedAthenaeum/UI/Book/Page.cs b/RecrownedAthenaeum/UI/Book/Page.cs index c27670e..488f244 100644 --- a/RecrownedAthenaeum/UI/Book/Page.cs +++ b/RecrownedAthenaeum/UI/Book/Page.cs @@ -1,4 +1,5 @@ -using RecrownedAthenaeum.UI.Modular; +using RecrownedAthenaeum.ContentSystem; +using RecrownedAthenaeum.UI.Modular; namespace RecrownedAthenaeum.UI.Book { @@ -43,7 +44,8 @@ namespace RecrownedAthenaeum.UI.Book /// /// Called only once after a page is added to a . Generally used to instantiate the modules of the page. /// - protected internal virtual void Initialize() + /// The assets to be used during initialization passed by the book this page belongs to. + protected internal virtual void Initialize(ContentManagerController assets) { }