00001 /*--License: 00002 Kyra Sprite Engine 00003 Copyright Lee Thomason (Grinning Lizard Software) 2001-2002 00004 www.grinninglizard.com/kyra 00005 www.sourceforge.net/projects/kyra 00006 00007 Kyra is provided under 2 licenses: 00008 00009 - The GPL, with no additional restrictions. 00010 - The LGPL, provided you display the Kyra splash screen, described below. 00011 00012 00013 --- GPL License -- 00014 This program is free software; you can redistribute it and/or 00015 modify it under the terms of the GNU General Public License 00016 as published by the Free Software Foundation; either version 2 00017 of the License, or (at your option) any later version. 00018 00019 This program is distributed in the hope that it will be useful, 00020 but WITHOUT ANY WARRANTY; without even the implied warranty of 00021 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00022 GNU General Public License for more details. 00023 00024 You should have received a copy of the GNU General Public License 00025 along with this program; if not, write to the Free Software 00026 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00027 00028 The full text of the license can be found in license.txt 00029 00030 00031 --- LGPL License -- 00032 **Provided you kindly display the Kyra splash screen (details below), 00033 you may use the LGPL license:** 00034 00035 This library is free software; you can redistribute it and/or 00036 modify it under the terms of the GNU Lesser General Public 00037 License as published by the Free Software Foundation; either 00038 version 2.1 of the License, or (at your option) any later version. 00039 00040 This library is distributed in the hope that it will be useful, 00041 but WITHOUT ANY WARRANTY; without even the implied warranty of 00042 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00043 Lesser General Public License for more details. 00044 00045 You should have received a copy of the GNU Lesser General Public 00046 License along with this library; if not, write to the Free Software 00047 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00048 00049 The full text of the license can be found in lgpl.txt 00050 00051 00052 --- Kyra Splash Screen. 00053 00054 It would be appreciate if you display the Kyra splash screen when using 00055 either license, however it is only required for the LGPL. All the 00056 resources for the splash are compiled into the library, and it can be 00057 accessed through the following API: 00058 00059 KrEngine::StartSplash 00060 KrEngine::UpdateSplash 00061 KrEngine::EndSplash 00062 00063 Full documentation is provided with the KrEngine class. The splash screen 00064 should be displayed for 2 seconds. 00065 00066 Thank you. 00067 */ 00068 00069 #ifndef KYRA_ACTION_INCLUDED 00070 #define KYRA_ACTION_INCLUDED 00071 00072 #include "SDL.h" 00073 #include "rle.h" 00074 #include "../util/gldynarray.h" 00075 00076 #pragma warning( disable : 4530 ) 00077 #pragma warning( disable : 4786 ) 00078 #include <string> 00079 00080 class KrCanvasResource; 00081 class KrEncoder; 00082 class KrCollisionMap; 00083 00084 00089 class KrAction 00090 { 00091 public: 00092 /* Create an empty KrAction. Used with the AddFrame method 00093 to create an action. 00094 */ 00095 KrAction( const std::string& name ); 00096 00098 KrAction( SDL_RWops* data ); 00099 00100 ~KrAction(); 00101 00103 const std::string& Name() const { return name; } 00105 U32 Id() const { return id; } 00106 00107 /* Draw the action to the surface. 00108 Normally called by the Sprite. 00109 @param paintInfo Target surface information 00110 @param frame The frame number to draw. 00111 @param x x value to draw -- measured at hotspot. 00112 @param y y value to draw -- measured at hotspot. 00113 @param cForm The color transformation to use. 00114 @param clip A clipping rectangle. (Can be NULL) 00115 */ 00116 void Draw( KrPaintInfo* paintInfo, 00117 int frame, 00118 const KrMatrix2& matrix, 00119 const KrColorTransform& cForm, 00120 const KrRect& clip, 00121 int openGLZ ); 00122 00124 int NumFrames() const { return numFrames; } 00125 00127 const KrRle& Frame( int i ) const { GLASSERT( i >= 0 ); 00128 GLASSERT( i < numFrames ); 00129 return frame[ i ]; } 00130 00131 /* Get a non-conts pointer to the frame. A special case call. 00132 */ 00133 KrRle* GetFrame( int i ) const { GLASSERT( i >= 0 ); 00134 GLASSERT( i < numFrames ); 00135 return &frame[ i ]; } 00136 00137 bool HitTestTransformed( int frame, int x, int y, int hitFlags ); 00138 00139 // internal 00140 void CacheScale( GlFixed xScale, GlFixed yScale ); 00141 bool IsScaleCached( GlFixed xScale, GlFixed yScale ); 00142 void FreeScaleCache(); 00143 KrCollisionMap* GetCollisionMap( GlFixed xScale, GlFixed yScale, int frame ); 00144 00145 void AddFrame() { GrowFrameArray( numFrames + 1 ); } 00146 00150 KrCanvasResource* CreateCanvasResource( int frame, int* hotx, int* hoty ); 00151 00152 void CalculateBounds( int frame, const KrMatrix2& xForm, KrRect* bounds ); 00153 00154 void Save( KrEncoder* encoder ); 00155 00156 private: 00157 struct CachedBlock 00158 { 00159 GlFixed xScale, 00160 yScale; 00161 KrRle** frame; 00162 00163 bool operator==( const CachedBlock& ) { GLASSERT( 0 ); return false; } // be nice to buggy compilers. 00164 }; 00165 void GrowFrameArray( int newSize ); 00166 00167 GlDynArray< CachedBlock > cache; 00168 00169 std::string name; 00170 U32 id; 00171 KrRle* frame; // Can't use dynamic array since it doesn't have proper copy 00172 int numFrames; 00173 }; 00174 00175 00176 #endif