58 lines
		
	
	
		
			2.1 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
			
		
		
	
	
			58 lines
		
	
	
		
			2.1 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
using RecrownedGTK.Assets;
 | 
						|
using RecrownedGTK.Graphics.Render;
 | 
						|
using RecrownedGTK.Graphics.UI.Modular;
 | 
						|
using RecrownedGTK.Graphics.UI.SkinSystem;
 | 
						|
 | 
						|
namespace RecrownedGTK.Graphics.UI.BookSystem
 | 
						|
{
 | 
						|
    /// <summary>
 | 
						|
    /// A page a part of a <see cref="Book"/>.
 | 
						|
    /// </summary>
 | 
						|
    public class Page : UIModuleGroup
 | 
						|
    {
 | 
						|
        private readonly int pageX, pageY;
 | 
						|
        /// <summary>
 | 
						|
        /// Whether or not this book needs to be refreshed with new dimensions.
 | 
						|
        /// </summary>
 | 
						|
        public bool requiresSizeUpdate;
 | 
						|
 | 
						|
        /// <summary>
 | 
						|
        /// Constructs a page.
 | 
						|
        /// </summary>
 | 
						|
        /// <param name="pageX">The X position in the book.</param>
 | 
						|
        /// <param name="pageY">The Y position in the book.</param>
 | 
						|
        public Page(int pageX, int pageY) : base()
 | 
						|
        {
 | 
						|
            this.pageX = pageX;
 | 
						|
            this.pageY = pageY;
 | 
						|
            requiresSizeUpdate = true;
 | 
						|
            name = ToString();
 | 
						|
        }
 | 
						|
 | 
						|
        /// <summary>
 | 
						|
        /// Called when this page is flagged as needing a size update.
 | 
						|
        /// </summary>
 | 
						|
        /// <param name="width">New width.</param>
 | 
						|
        /// <param name="height">New Height</param>
 | 
						|
        public virtual void ApplySize(int width, int height)
 | 
						|
        {
 | 
						|
            X = pageX * width;
 | 
						|
            Y = pageY * height;
 | 
						|
            Width = width;
 | 
						|
            Height = height;
 | 
						|
            requiresSizeUpdate = false;
 | 
						|
        }
 | 
						|
 | 
						|
        /// <summary>
 | 
						|
        /// Called only once after a page is added to a <see cref="Book"/>. Generally used to instantiate the modules of the page.
 | 
						|
        /// </summary>
 | 
						|
        /// <param name="assets">The assets to be used during initialization passed by the book this page belongs to.</param>
 | 
						|
        /// <param name="skin">The skin the book containing this page is given that can be used by this page.</param>
 | 
						|
        /// <param name="basicScissor">The scissor box to use for cropping.</param>
 | 
						|
        protected internal virtual void Initialize(AssetManager assets, ISkin skin, BasicScissor basicScissor)
 | 
						|
        {
 | 
						|
            this.basicScissor = basicScissor;
 | 
						|
        }
 | 
						|
    }
 | 
						|
}
 |