Show Resource.cpp syntax highlighted
/**
**************************************************************************************
*Palisma - Secrets of the Illuminati is an open-source 2D RPG *
*Copyright (C) 2006, Tony Sparks *
* *
*This library is free software; you can redistribute it and/or *
*modify it under the terms of the GNU Lesser General Public *
*License as published by the Free Software Foundation; either *
*version 2.1 of the License, or (at your option) any later version. *
* *
*This library is distributed in the hope that it will be useful, *
*but WITHOUT ANY WARRANTY; without even the implied warranty of *
*MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
*Lesser General Public License for more details. *
* *
*You should have received a copy of the GNU Lesser General Public *
*License along with this library; if not, write to the Free Software *
*Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
**************************************************************************************
*/
#include "StdAfx.h"
#include "Resource.h"
#include "physfs.h"
#include "kernel.h"
extern Kernel* g_kernel;
Resource::Resource(void)
{
PHYSFS_init(NULL);
loadArc_f.Set( this );
g_kernel->GetConsole()->AddCommand( &loadArc_f, "load" );
}
/** Load a zip archive into memory */
void Resource::LoadArchive( const std::string &zip )
{
PHYSFS_addToSearchPath( zip.c_str(), 0); // load to the front
}
/** Load an image into mem */
Image* Resource::LoadSingleImage(const std::string &s)
{
return m_textureLoader.CreateImage( s );
}
/** Load a sub-image into mem */
Image* Resource::LoadImages(const std::string &s, int r, int c)
{
return m_textureLoader.CreateImage( s, r, c );
}
/** Load a sound file */
SoundSource* Resource::LoadSound( const std::string &s )
{
return g_kernel->GetSound()->LoadSound( s );
}
/** Number of sounds in cache */
int Resource::Sounds()
{
return g_kernel->GetSound()->NumSounds();
}
/** Number of textures in cache */
int Resource::Textures()
{
return m_textureLoader.NumTextures();
}
Resource::~Resource(void)
{
PHYSFS_deinit();
g_kernel->GetConsole()->RemoveCommand( "load" );
}
See more files for this project here