# 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
    00018 class SpriteLoader {
    00019 public:
    00020   struct CommonPixel {
    00021     uint8 r;
    00022     uint8 g;
    00023     uint8 b;
    00024     uint8 a;
    00025     uint8 m;
    00026   };
    00027
    00034   struct Sprite {
    00035     uint16 height;
    00036     uint16 width;
    00037     int16 x_offs;
    00038     int16 y_offs;
    00039     SpriteLoader::CommonPixel *data;
    00040
    00045     void AllocateData(size_t size) { this->data = Sprite::buffer.ZeroAllocate(size); }
    00046   private:
    00048     static ReusableBuffer<SpriteLoader::CommonPixel> buffer;
    00049   };
    00050
    00060   virtual bool LoadSprite(SpriteLoader::Sprite *sprite, uint8 file_slot, size_t file_pos, SpriteType sprite_type, ZoomLevel zoom) = 0;
    00061
    00062   virtual ~SpriteLoader() { }
    00063 };
    00064
    00065 #endif /* SPRITELOADER_HPP */