spriteloader.hpp

Go to the documentation of this file.
00001 /* $Id$ */
00002 
00003 /*
00004  * This file is part of OpenTTD.
00005  * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
00006  * OpenTTD 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.
00007  * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
00008  */
00009 
00012 #ifndef SPRITELOADER_HPP
00013 #define SPRITELOADER_HPP
00014 
00015 #include "../core/alloc_type.hpp"
00016 #include "../gfx_type.h"
00017 
00019 class SpriteLoader {
00020 public:
00022   struct CommonPixel {
00023     uint8 r;  
00024     uint8 g;  
00025     uint8 b;  
00026     uint8 a;  
00027     uint8 m;  
00028   };
00029 
00036   struct Sprite {
00037     uint16 height;                   
00038     uint16 width;                    
00039     int16 x_offs;                    
00040     int16 y_offs;                    
00041     SpriteType type;                 
00042     SpriteLoader::CommonPixel *data; 
00043 
00048     void AllocateData(size_t size) { this->data = Sprite::buffer.ZeroAllocate(size); }
00049   private:
00051     static ReusableBuffer<SpriteLoader::CommonPixel> buffer;
00052   };
00053 
00062   virtual bool LoadSprite(SpriteLoader::Sprite *sprite, uint8 file_slot, size_t file_pos, SpriteType sprite_type) = 0;
00063 
00064   virtual ~SpriteLoader() { }
00065 };
00066 
00067 #endif /* SPRITELOADER_HPP */