From: Jarda B. <edh...@us...> - 2006-02-09 22:46:20
|
Update of /cvsroot/gemrb/gemrb/gemrb/plugins/Core In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23555/gemrb/plugins/Core Modified Files: Video.h Interface.h Interface.cpp ActorBlock.h ActorBlock.cpp Actor.cpp Log Message: Implemented PST ground circles Implemented Video::SpriteScaleDown() function Loading of WMAP area alias file, leftover from some prev. work, not used now Index: Interface.h =================================================================== RCS file: /cvsroot/gemrb/gemrb/gemrb/plugins/Core/Interface.h,v retrieving revision 1.185 retrieving revision 1.186 diff -C2 -d -r1.185 -r1.186 *** Interface.h 28 Jan 2006 19:56:34 -0000 1.185 --- Interface.h 9 Feb 2006 22:46:11 -0000 1.186 *************** *** 139,142 **** --- 139,146 ---- #define AP_SPELLCAST 9 + /** Max size of actor's ground circle */ + #define MAX_CIRCLE_SIZE 3 + + /** * @class Interface *************** *** 186,189 **** --- 190,195 ---- ieResRef ButtonFont; ieResRef CursorBam; + ieResRef GroundCircleBam[MAX_CIRCLE_SIZE]; + int GroundCircleScale[MAX_CIRCLE_SIZE]; ieResRef TooltipFont; ieResRef TooltipBackResRef; *************** *** 218,221 **** --- 224,228 ---- ieResRef GlobalScript; ieResRef WorldMapName; + TableMgr* AreaAliasTable; Sprite2D **Cursors; int CursorCount; *************** *** 223,226 **** --- 230,234 ---- Sprite2D **TooltipBack; Sprite2D *WindowFrames[4]; + Sprite2D *GroundCircles[MAX_CIRCLE_SIZE][6]; public: Interface(int iargc, char **iargv); *************** *** 500,503 **** --- 508,513 ---- bool ReadAbilityTables(); bool ReadAbilityTable(const ieResRef name, ieWord *mem, int cols, int rows); + /** Reads table of area name mappings for WorldMap (PST only) */ + bool ReadAreaAliasTable(const ieResRef name); /** handles the QuitFlag bits (main loop events) */ void HandleFlags(); Index: Actor.cpp =================================================================== RCS file: /cvsroot/gemrb/gemrb/gemrb/plugins/Core/Actor.cpp,v retrieving revision 1.164 retrieving revision 1.165 diff -C2 -d -r1.164 -r1.165 *** Actor.cpp 29 Jan 2006 13:40:19 -0000 1.164 --- Actor.cpp 9 Feb 2006 22:46:11 -0000 1.165 *************** *** 257,266 **** --- 257,271 ---- { Color* color; + int color_index; + if (Modified[IE_UNSELECTABLE]) { color = &magenta; + color_index = 4; } else if (GetMod(IE_MORALE)<0) {//if current morale < the max morale ? color = &yellow; + color_index = 5; } else if (Modified[IE_STATE_ID] & STATE_PANIC) { color = &yellow; + color_index = 5; } else { switch (Modified[IE_EA]) { *************** *** 273,276 **** --- 278,282 ---- case EA_GOODCUTOFF: color = &green; + color_index = 0; break; *************** *** 279,289 **** case EA_EVILCUTOFF: color = &red; break; default: color = &cyan; break; } } ! SetCircle( anims->GetCircleSize(), *color ); } --- 285,303 ---- case EA_EVILCUTOFF: color = &red; + color_index = 1; break; default: color = &cyan; + color_index = 2; break; } } ! ! ! int csize = anims->GetCircleSize() - 1; ! if (csize >= MAX_CIRCLE_SIZE) ! csize = MAX_CIRCLE_SIZE - 1; ! ! SetCircle( anims->GetCircleSize(), *color, core->GroundCircles[csize][color_index], core->GroundCircles[csize][(color_index == 0) ? 3 : color_index] ); } Index: Video.h =================================================================== RCS file: /cvsroot/gemrb/gemrb/gemrb/plugins/Core/Video.h,v retrieving revision 1.55 retrieving revision 1.56 diff -C2 -d -r1.55 -r1.56 *** Video.h 28 Jan 2006 19:56:34 -0000 1.55 --- Video.h 9 Feb 2006 22:46:11 -0000 1.56 *************** *** 176,179 **** --- 176,180 ---- * It is used to mask clicks to non-rectangular shaped controls */ virtual bool IsSpritePixelTransparent(Sprite2D* sprite, unsigned short x, unsigned short y) = 0; + virtual Sprite2D* SpriteScaleDown( Sprite2D* sprite, unsigned int ratio ) = 0; }; Index: Interface.cpp =================================================================== RCS file: /cvsroot/gemrb/gemrb/gemrb/plugins/Core/Interface.cpp,v retrieving revision 1.387 retrieving revision 1.388 diff -C2 -d -r1.387 -r1.388 *** Interface.cpp 28 Jan 2006 19:56:34 -0000 1.387 --- Interface.cpp 9 Feb 2006 22:46:11 -0000 1.388 *************** *** 179,182 **** --- 179,186 ---- strncpy( Palette256, "MPAL256", sizeof(Palette256) ); strcpy( TooltipBackResRef, "\0" ); + for (int size = 0; size < MAX_CIRCLE_SIZE; size++) { + strcpy( GroundCircleBam[size], "\0" ); + GroundCircleScale[size] = 0; + } TooltipColor.r = 0; TooltipColor.g = 255; *************** *** 192,195 **** --- 196,201 ---- GameFeatures = 0; memset( WindowFrames, 0, sizeof( WindowFrames )); + memset( GroundCircles, 0, sizeof( GroundCircles )); + AreaAliasTable = NULL; } *************** *** 560,563 **** --- 566,586 ---- } + bool Interface::ReadAreaAliasTable(const ieResRef tablename) + { + int table = LoadTable( tablename ); + + if (table < 0) { + return false; + } + AreaAliasTable = GetTable( table ); + if (!AreaAliasTable) { + DelTable( table ); + return false; + } + printf("XXX: %s\n", AreaAliasTable->QueryField( "AR0306a", "MAP_AREA" )); + return true; + } + + /** this is the main loop */ void Interface::Main() *************** *** 1084,1089 **** } - printStatus( "OK", LIGHT_GREEN ); - { ieDword i = 0; --- 1107,1110 ---- *************** *** 1096,1099 **** --- 1117,1149 ---- } + printStatus( "OK", LIGHT_GREEN ); + + // Load ground circle bitmaps (PST only) + printMessage( "Core", "Loading Ground circle bitmaps...", WHITE ); + for (int size = 0; size < MAX_CIRCLE_SIZE; size++) { + if (GroundCircleBam[size][0]) { + str = key->GetResource( GroundCircleBam[size], IE_BAM_CLASS_ID ); + anim->Open( str, true ); + if (anim->GetCycleCount() != 6) { + // unknown type of circle anim + printStatus( "ERROR", LIGHT_RED ); + goto end_of_init; + } + + for (int i = 0; i < 6; i++) { + Sprite2D* sprite = anim->GetFrameFromCycle( i, 0 ); + if (GroundCircleScale[size]) { + GroundCircles[size][i] = video->SpriteScaleDown( sprite, GroundCircleScale[size] ); + video->FreeSprite( sprite ); + } + else + GroundCircles[size][i] = sprite; + } + } + } + + printStatus( "OK", LIGHT_GREEN ); + + printMessage( "Core", "Bringing up the Global Timer...", WHITE ); timer = new GlobalTimer(); *************** *** 1168,1171 **** --- 1218,1230 ---- } + printMessage( "Core", "Initializing area aliases...\n", WHITE ); + ret = ReadAreaAliasTable( "WMAPLAY" ); + if (ret) { + printStatus( "OK", LIGHT_GREEN ); + } + else { + printStatus( "ERROR", LIGHT_RED ); + } + printMessage( "Core", "Core Initialization Complete!\n", WHITE ); ret = GEM_OK; *************** *** 1696,1699 **** --- 1755,1777 ---- TooltipMargin = ini->GetKeyAsInt( "resources", "TooltipMargin", TooltipMargin ); + // The format of GroundCircle can be: + // GroundCircleBAM1 = wmpickl/3 + // to denote that the bitmap should be scaled down 3x + for (int size = 0; size < MAX_CIRCLE_SIZE; size++) { + char name[30]; + sprintf( name, "GroundCircleBAM%d", size+1 ); + s = ini->GetKeyAsString( "resources", name, NULL ); + if (s) { + char *pos = strchr( s, '/' ); + if (pos) { + GroundCircleScale[size] = atoi( pos+1 ); + strncpy( GroundCircleBam[size], s, pos - s ); + GroundCircleBam[size][pos - s] = '\0'; + } else { + strcpy( GroundCircleBam[size], s ); + } + } + } + s = ini->GetKeyAsString( "resources", "INIConfig", NULL ); if (s) Index: ActorBlock.h =================================================================== RCS file: /cvsroot/gemrb/gemrb/gemrb/plugins/Core/ActorBlock.h,v retrieving revision 1.99 retrieving revision 1.100 diff -C2 -d -r1.99 -r1.100 *** ActorBlock.h 14 Jan 2006 21:14:05 -0000 1.99 --- ActorBlock.h 9 Feb 2006 22:46:11 -0000 1.100 *************** *** 222,225 **** --- 222,226 ---- Color selectedColor; Color overColor; + Sprite2D *circleBitmap[2]; int size; // current SpriteCover for wallgroups *************** *** 232,236 **** bool IsSelected(); void Select(int Value); ! void SetCircle(int size, Color color); /* store SpriteCover */ --- 233,237 ---- bool IsSelected(); void Select(int Value); ! void SetCircle(int size, Color color, Sprite2D* normal_circle, Sprite2D* selected_circle); /* store SpriteCover */ Index: ActorBlock.cpp =================================================================== RCS file: /cvsroot/gemrb/gemrb/gemrb/plugins/Core/ActorBlock.cpp,v retrieving revision 1.134 retrieving revision 1.135 diff -C2 -d -r1.134 -r1.135 *** ActorBlock.cpp 28 Jan 2006 19:56:33 -0000 1.134 --- ActorBlock.cpp 9 Feb 2006 22:46:11 -0000 1.135 *************** *** 450,453 **** --- 450,455 ---- size = 0; cover = NULL; + circleBitmap[0] = NULL; + circleBitmap[1] = NULL; } *************** *** 468,473 **** --- 470,478 ---- } Color* col = NULL; + Sprite2D* sprite = circleBitmap[0]; + if (Selected) { col = &selectedColor; + sprite = circleBitmap[1]; } else if (Over) { col = &overColor; *************** *** 475,480 **** return; } ! core->GetVideoDriver()->DrawEllipse( Pos.x - vp.x, Pos.y - vp.y, ! size * 10, ( ( size * 15 ) / 2 ), *col ); } --- 480,491 ---- return; } ! ! if (sprite) { ! core->GetVideoDriver()->BlitSprite( sprite, Pos.x - vp.x, Pos.y - vp.y, true ); ! } ! else { ! core->GetVideoDriver()->DrawEllipse( Pos.x - vp.x, Pos.y - vp.y, ! size * 10, ( ( size * 15 ) / 2 ), *col ); ! } } *************** *** 510,514 **** } ! void Selectable::SetCircle(int circlesize, Color color) { size = circlesize; --- 521,525 ---- } ! void Selectable::SetCircle(int circlesize, Color color, Sprite2D* normal_circle, Sprite2D* selected_circle) { size = circlesize; *************** *** 517,520 **** --- 528,533 ---- overColor.g = color.g >> 1; overColor.b = color.b >> 1; + circleBitmap[0] = normal_circle; + circleBitmap[1] = selected_circle; } |