Shape.h

Go to the documentation of this file.
00001 /*
00002 Copyright (C) 2003-2004 The Pentagram Team
00003 
00004 This program is free software; you can redistribute it and/or
00005 modify it under the terms of the GNU General Public License
00006 as published by the Free Software Foundation; either version 2
00007 of the License, or (at your option) any later version.
00008 
00009 This program is distributed in the hope that it will be useful,
00010 but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012 GNU General Public License for more details.
00013 
00014 You should have received a copy of the GNU General Public License
00015 along with this program; if not, write to the Free Software
00016 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00017 */
00018 
00019 #ifndef SHAPE_H
00020 #define SHAPE_H
00021 
00022 #include <vector>
00023 
00024 class ShapeFrame;
00025 namespace Pentagram { struct Palette; struct Rect; }
00026 struct ConvertShapeFormat;
00027 class IDataSource;
00028 
00029 class Shape 
00030 {
00031 public:
00032         // Parse data, create frames.
00033         // NB: Shape uses data without copying it. It is deleted on destruction
00034         // If format is not specified it will be autodetected
00035         Shape(const uint8* data, uint32 size, const ConvertShapeFormat *format,
00036                 const uint16 flexId, const uint32 shapenum);
00037         Shape(IDataSource *src, const ConvertShapeFormat *format);
00038         virtual ~Shape();
00039         void setPalette(const Pentagram::Palette* pal) { palette = pal; }
00040         const Pentagram::Palette* getPalette() const { return palette; }
00041 
00042         uint32 frameCount() const { return static_cast<uint32>(frames.size()); }
00043 
00047         void getTotalDimensions(sint32& w, sint32& h, sint32& x, sint32& y) const;
00048 
00049         ShapeFrame* getFrame(unsigned int frame)
00050                 { if (frame < frames.size()) return frames[frame]; else return 0; }
00051                 
00052         void getShapeId(uint16 & flexId, uint32 & shapenum);
00053 
00054         // This will detect the format of a shape
00055         static const ConvertShapeFormat *DetectShapeFormat(const uint8* data, uint32 size);
00056         static const ConvertShapeFormat *DetectShapeFormat(IDataSource *ds, uint32 size);
00057 
00058         ENABLE_RUNTIME_CLASSTYPE();
00059 
00060         ENABLE_CUSTOM_MEMORY_ALLOCATION();
00061 
00062 protected:
00063 
00064         // This will load a u8 style shape 'optimized'.
00065         void LoadU8Format(const uint8* data, uint32 size, const ConvertShapeFormat* format);
00066 
00067         // This will load a pentagram style shape 'optimized'.
00068         void LoadPentagramFormat(const uint8* data, uint32 size, const ConvertShapeFormat* format);
00069 
00070         // This will load any sort of shape via a ConvertShapeFormat struct
00071         // Crusader shapes must be loaded this way
00072         void LoadGenericFormat(const uint8* data, uint32 size, const ConvertShapeFormat* format);
00073 
00074         std::vector<ShapeFrame*> frames;
00075 
00076         const Pentagram::Palette* palette;
00077 
00078         const uint8* data;
00079         uint32 size;
00080         const uint16 flexId;
00081         const uint32 shapenum;
00082 };
00083 
00084 
00085 #endif

Generated on Fri Jul 27 22:27:36 2007 for pentagram by  doxygen 1.4.7