V-Gears 0
Free Final Fantasy VII engine.
VGears::BackgroundFile Class Reference

A background file representation. More...

#include <VGearsBackgroundFile.h>

Inheritance diagram for VGears::BackgroundFile:
Collaboration diagram for VGears::BackgroundFile:

Classes

struct  Layer
 A layer of a background. More...
 
struct  Page
 A background page/. More...
 
struct  SpriteData
 Data for sprites. More...
 

Public Types

enum  {
  PAGE_DATA_WIDTH = 256 , PAGE_DATA_HEIGHT = PAGE_DATA_WIDTH , PAGE_DATA_SIZE = PAGE_DATA_WIDTH * PAGE_DATA_HEIGHT , SPRITE_WIDTH = 16 ,
  SPRITE_HEIGHT = SPRITE_WIDTH , SPRITE_PIXEL_COUNT = SPRITE_WIDTH * SPRITE_HEIGHT , LAYER_COUNT = 4 , PALETTE_ENTRY_COUNT = 20 ,
  PAGE_COUNT = 42
}
 
typedef std::vector< SpriteDataSpriteList
 
typedef std::vector< SpriteData * > SpritePtrList
 
typedef PaletteFile::Color Color
 
typedef std::vector< uint8Buffer
 
typedef std::vector< ColorColors
 

Public Member Functions

 BackgroundFile (Ogre::ResourceManager *creator, const String &name, Ogre::ResourceHandle handle, const String &group, bool is_manual=false, Ogre::ManualResourceLoader *loader=NULL)
 Constructor. More...
 
virtual ~BackgroundFile ()
 Destructor. More...
 
void SortSprites ()
 Sorts the sprites. More...
 
std::array< Layer, LAYER_COUNT > & GetLayers (void)
 Retrieves the background layers. More...
 
std::array< uint8, PALETTE_ENTRY_COUNT > & GetPalette (void)
 Retrieves the background palette. More...
 
std::array< Page, PAGE_COUNT > & GetPages (void)
 Retrieves the background pages. More...
 
Ogre::Image * CreateImage (const PaletteFilePtr &palette)
 Creates an image from a palette. More...
 
void AddAllSprites (SpritePtrList &sprites)
 Adds all sprites to the background. More...
 

Static Public Attributes

static const String RESOURCE_TYPE
 The type of resource. More...
 

Protected Member Functions

virtual void loadImpl () override final
 Loads the file. More...
 
virtual void unloadImpl () override final
 Unloads the file. More...
 
virtual size_t CalculateSize () const
 Calculates the size of the background. More...
 
virtual size_t CalculateSize (const Layer &layer) const
 Calculates the size of a background layer. More...
 
virtual size_t CalculateSize (const Page &page) const
 Calculates the size of a background page. More...
 

Static Private Member Functions

static bool SpriteSorter (SpriteData sprite1, SpriteData sprite2)
 Sorting algorithm for sprite sorting. More...
 

Private Attributes

std::array< Layer, LAYER_COUNTlayers_
 The list of layers. More...
 
std::array< uint8, PALETTE_ENTRY_COUNTpalette_
 The color palette. More...
 
std::array< Page, PAGE_COUNTpages_
 The background pages. More...
 

Detailed Description

A background file representation.

Member Typedef Documentation

◆ Buffer

typedef std::vector<uint8> VGears::BackgroundFile::Buffer

◆ Color

◆ Colors

typedef std::vector<Color> VGears::BackgroundFile::Colors

◆ SpriteList

◆ SpritePtrList

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator
PAGE_DATA_WIDTH 

Width of the background page, in pixels.

Same as {

See also
PAGE_DATAH_EIGHT}.
PAGE_DATA_HEIGHT 

Height of the background page, in pixels.

Same as {

See also
PAGE_DATA_WIDTH}.
PAGE_DATA_SIZE 

Size of the background page, in pixels.

Same as {

See also
PAGE_DATA_WIDTH} * {
PAGE_DATA_HEIGHT}.
SPRITE_WIDTH 

Width of sprites, in pixels.

Same as {

See also
SPRITE_HEIGHT}.
SPRITE_HEIGHT 

Height of sprites, in pixels.

Same as {

See also
SPRITE_WIDTH}.
SPRITE_PIXEL_COUNT 

Size of sprites, in pixels.

Same as {

See also
SPRITE_WIDTH} * {
SPRITE_HEIGHT}.
LAYER_COUNT 

Number of layers in a background.

PALETTE_ENTRY_COUNT 

Number of palettes in a background.

PAGE_COUNT 

Number of pages in a background.

Todo:
What are pages?

Constructor & Destructor Documentation

◆ BackgroundFile()

VGears::BackgroundFile::BackgroundFile ( Ogre::ResourceManager *  creator,
const String name,
Ogre::ResourceHandle  handle,
const String group,
bool  is_manual = false,
Ogre::ManualResourceLoader *  loader = NULL 
)

Constructor.

Parameters
[in]creatorPointer to the ResourceManager that is creating this resource.
[in]nameThe unique name of the resource.
[in]handle
Todo:
Understand and document.
Parameters
[in]groupThe name of the resource group to which this resource belong.
[in]is_manualTrue if the resource is manually loaded, false otherwise.
[in]loaderPointer to a ManualResourceLoader implementation which will be called when the Resource wishes to load (should be supplied if is_manual is set to true). It can be null, but the Resource will never be able to reload if anything ever causes it to unload. Therefore provision of a proper ManualResourceLoader instance is strongly recommended.

◆ ~BackgroundFile()

VGears::BackgroundFile::~BackgroundFile ( )
virtual

Destructor.

Member Function Documentation

◆ AddAllSprites()

void VGears::BackgroundFile::AddAllSprites ( SpritePtrList sprites)

Adds all sprites to the background.

Parameters
[in]spritesThe list of sprites to add.

◆ CalculateSize() [1/3]

size_t VGears::BackgroundFile::CalculateSize ( ) const
protectedvirtual

Calculates the size of the background.

It includes all layers and pages.

Returns
The total size of the background, in bytes.

◆ CalculateSize() [2/3]

size_t VGears::BackgroundFile::CalculateSize ( const Layer layer) const
protectedvirtual

Calculates the size of a background layer.

Parameters
[in]layerThe layer to calculate size from.
Returns
The total size of the background layer, in bytes.

◆ CalculateSize() [3/3]

size_t VGears::BackgroundFile::CalculateSize ( const Page page) const
protectedvirtual

Calculates the size of a background page.

Parameters
[in]pageThe layer to calculate size from.
Returns
The total size of the background page, in bytes.

◆ CreateImage()

Ogre::Image * VGears::BackgroundFile::CreateImage ( const PaletteFilePtr palette)

Creates an image from a palette.

Parameters
[in]paletteThe color palette for the image.
Returns
The image.

◆ GetLayers()

std::array< Layer, LAYER_COUNT > & VGears::BackgroundFile::GetLayers ( void  )
inline

Retrieves the background layers.

Returns
The list of layers.

◆ GetPages()

std::array< Page, PAGE_COUNT > & VGears::BackgroundFile::GetPages ( void  )
inline

Retrieves the background pages.

Returns
The background pages.

◆ GetPalette()

std::array< uint8, PALETTE_ENTRY_COUNT > & VGears::BackgroundFile::GetPalette ( void  )
inline

Retrieves the background palette.

Returns
The palette.

◆ loadImpl()

void VGears::BackgroundFile::loadImpl ( )
finaloverrideprotectedvirtual

Loads the file.

◆ SortSprites()

void VGears::BackgroundFile::SortSprites ( )

Sorts the sprites.

◆ SpriteSorter()

bool VGears::BackgroundFile::SpriteSorter ( SpriteData  sprite1,
SpriteData  sprite2 
)
staticprivate

Sorting algorithm for sprite sorting.

Parameters
[in]sprite1First sprite to compare.
[in]sprite2Second sprite to compare.
Returns
Ture if sprite 1 goes before sprite 2, false otherwise.

◆ unloadImpl()

void VGears::BackgroundFile::unloadImpl ( )
finaloverrideprotectedvirtual

Unloads the file.

Member Data Documentation

◆ layers_

std::array<Layer, LAYER_COUNT> VGears::BackgroundFile::layers_
private

The list of layers.

◆ pages_

std::array<Page, PAGE_COUNT> VGears::BackgroundFile::pages_
private

The background pages.

◆ palette_

std::array<uint8, PALETTE_ENTRY_COUNT> VGears::BackgroundFile::palette_
private

The color palette.

◆ RESOURCE_TYPE

const String VGears::BackgroundFile::RESOURCE_TYPE
static

The type of resource.


The documentation for this class was generated from the following files: