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_BOXRESOURCE_INCLUDED 00070 #define KYRA_BOXRESOURCE_INCLUDED 00071 00072 #include "kyraresource.h" 00073 #include "../engine/krmath.h" 00074 #include "../util/glcirclelist.h" 00075 #include "color.h" 00076 00077 class KrBox; 00078 struct KrPaintInfo; 00079 00080 00086 class KrBoxResource : public KrResource 00087 { 00088 public: 00106 KrBoxResource( const std::string& name, 00107 int width, 00108 int height, 00109 const KrRGBA* colorArray, 00110 int numColors, 00111 int boxtype ); 00112 00113 virtual ~KrBoxResource() {} 00114 00115 enum 00116 { 00117 OUTLINE, 00118 FILL, 00119 CROSSHAIR 00120 }; 00121 00122 enum { 00123 COLOR_ARRAY_SIZE = 4, 00124 MASK = 3, 00125 }; 00126 00127 virtual U32 Type() { return KYRATAG_BOX; } 00128 virtual const std::string& TypeName() { return boxName; } 00129 virtual KrBoxResource* ToBoxResource() { return this; } 00130 00131 int Width() const { return width; } 00132 int Height() const { return height; } 00133 const KrRGBA* ColorArray() const { return colorArray; } 00134 int BoxType() const { return boxtype; } 00135 00136 /* Draw a box resource. 00137 @param paintInfo Information about the target surface for drawing (optimizing). 00138 @param x X location in pixels. 00139 @param y Y location in pixels. 00140 @param cForm Color transformation applied to the drawing. 00141 @param clip A clipping rectangle, which can be null. 00142 */ 00143 void Draw( KrPaintInfo* paintInfo, 00144 const KrMatrix2& matrix, 00145 const KrColorTransform& cForm, 00146 const KrRect& clipping, 00147 int openGLZ ); 00148 00149 /* Do a HitTest (see KrImageTree::HitTest) in transformed 00150 coordinates. So the tree object that made this call 00151 has already transformed the x and y into local pixel coords. 00152 */ 00153 bool HitTestTransformed( int x, int y, int hitFlags ); 00154 00155 /* Given a hotspot x and y, and scale factors, 00156 return the bounding box for the box resource. 00157 */ 00158 void CalculateBounds( const KrMatrix2& matrix, 00159 KrRect* bounds ) const; 00160 00161 private: 00162 void DrawOpenGL(KrPaintInfo* paintInfo, 00163 const KrMatrix2& matrix, 00164 const KrColorTransform& cForm, 00165 const KrRect& clipping, 00166 int openGLZ ); 00167 00168 static const std::string boxName; 00169 static int boxId; 00170 00171 KrRGBA colorArray[COLOR_ARRAY_SIZE]; 00172 int width; 00173 int height; 00174 int boxtype; 00175 bool sourceAlpha; // is there alpha in our colorArray? 00176 }; 00177 00178 00179 #endif