00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033 #ifndef KYRA_RENDER_INCLUDED
00034 #define KYRA_RENDER_INCLUDED
00035
00036 #ifdef _MSC_VER
00037
00038 #pragma warning( disable : 4530 )
00039 #pragma warning( disable : 4786 )
00040 #endif
00041
00042 #include "../util/gllist.h"
00043 #include "SDL.h"
00044 #include "../engine/krmath.h"
00045
00046
00047
00048
00049
00050 #include "sprite.h"
00051
00052 class KrEngine;
00053 class KrMappedRect;
00054
00055
00058 class KrImageTree
00059 {
00060 public:
00061
00062
00063
00064 KrImageTree( KrEngine* engine );
00065 ~KrImageTree();
00066
00068 KrImNode* Root() { return offsetRoot; }
00069
00080 void AddNode( KrImNode* parent, KrImNode* addMe );
00081
00090 bool DeleteNode( KrImNode* removeMe );
00091
00093 KrImNode* FindNodeById( int id );
00095 KrImNode* FindNodeByName( const std::string& name );
00096
00111 void HitTest( int x, int y, KrImNode* startHere,
00112 int flags,
00113 std::vector<KrImage*>* outputArray,
00114 int *windowIndex );
00115
00122 bool CheckSiblingCollision( KrImNode* checkThis,
00123 std::vector<KrImage*>* outputArray, int window = 0 );
00124
00135 bool CheckChildCollision( KrImNode* checkThis, KrImNode* parent,
00136 std::vector<KrImage*>* outputArray, int window = 0 );
00137
00144 bool CheckAllCollision( KrImNode* checkThis, std::vector<KrImage*>* outputArray, int window = 0 );
00145
00146 enum
00147 {
00149 ALWAYS_INSIDE_BOX = 0x01,
00151 GET_ALL_HITS = 0x04,
00152 };
00153
00155 void Walk();
00156
00157 void DrawWalk( const grinliz::Rectangle2I& dr, KrPaintInfo* info, int window );
00158
00159
00160
00161 void AddNodeNameHash( const std::string& name, KrImNode* node );
00162 void RemoveNodeNameHash( const std::string& name );
00163 void RemoveNodeIdHash( int id );
00164 void AddNodeIdHash( int id, KrImNode* node );
00165
00166 #ifdef DEBUG
00167 void ValidateTree( KrImNode* root );
00168 #endif
00169
00170 private:
00171
00172 struct StackContext
00173 {
00174 KrImNode* node;
00175 bool invalid;
00176
00177 };
00178
00179 void CheckAllCollisionWalk( bool* hit, KrImNode* parent, KrImage* checkThis, std::vector<KrImage*>* outputArray, int window );
00180
00181
00182 void Walk( KrImNode* node,
00183 bool invalid,
00184 bool visible,
00185 int window );
00186
00187
00188 void DrawWalk( const grinliz::Rectangle2I& dr, KrImNode* node, KrPaintInfo*, int window );
00189
00190 void Clear( KrImNode* root );
00191
00192
00193 bool KrImageTree::HitTestRec( KrImNode* node, int x, int y, int flags, std::vector<KrImage*>* outputArray, int windowIndex );
00194
00195 KrImNode* root;
00196 KrImNode* offsetRoot;
00197 KrEngine* engine;
00198
00199 std::map< U32, KrImNode* > idMap;
00200 std::map< std::string, KrImNode* > nameMap;
00201
00202 int treeDepth;
00203 };
00204
00205
00206 #endif