void sge_Rect(SDL_Surface *Surface, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Uint32 color) { _HLine(Surface,x1,x2,y1,color); _HLine(Surface,x1,x2,y2,color); _VLine(Surface,x1,y1,y2,color); _VLine(Surface,x2,y1,y2,color); #if 1 sge_UpdateRect(Surface, x1, y1, x2-x1, 1); sge_UpdateRect(Surface, x1, y2, x2-x1+1, 1); /* Hmm? */ sge_UpdateRect(Surface, x1, y1, 1, y2-y1); sge_UpdateRect(Surface, x2, y1, 1, y2-y1); #endif }
void InputKeys( int a_iPlayerNumber ) { SDL_BlitSurface( poBackground, NULL, gamescreen, NULL ); DrawGradientText( "Input keys", titleFont, 10, gamescreen ); SDL_Flip( gamescreen ); static const char* apcKeyNames[9] = { "up", "down", "left", "right", "block", "low punch", "high punch", "low kick", "high kick" }; char acBuffer[1024]; char acSide[128]; char acFormat[128]; int iY = 75; int iYIncrement = 35; SDLKey enKey; const char* pcJoyName = g_oJoystick.GetJoystickName( a_iPlayerNumber ); if ( NULL != pcJoyName ) { DrawTextMSZ( pcJoyName, inkFont, gamescreen->w/2, iY, AlignHCenter|UseShadow, C_LIGHTCYAN, gamescreen ); iY += iYIncrement + 10; } DrawTextMSZ( "Press Escape to abort", inkFont, gamescreen->w/2, gamescreen->h-10-iYIncrement, AlignHCenter|UseShadow, C_LIGHTGRAY, gamescreen ); strcpy( acSide, Translate(a_iPlayerNumber ? "Left" : "Right") ); strcpy( acFormat, Translate("%s player-'%s'?") ); for ( int i=0; i<9; ++i ) { // 1. PRINT THE FONT AND THE CURRENT KEYSYM sprintf( acBuffer, acFormat, acSide, Translate(apcKeyNames[i]) ); int w = DrawTextMSZ( acBuffer, inkFont, 10, iY, UseShadow, C_WHITE, gamescreen ); enKey = (SDLKey) g_oState.m_aiPlayerKeys[a_iPlayerNumber][i]; g_oBackend.PerlEvalF( "GetKeysym(%d);", enKey ); DrawTextMSZ( g_oBackend.GetPerlString("keysym"), inkFont, w+30, iY, UseShadow, C_LIGHTCYAN, gamescreen ); // 2. INPUT THE NEW KEY enKey = GetKey( false ); if ( SDLK_ESCAPE == enKey ) { SDL_BlitSurface( poBackground, NULL, gamescreen, NULL ); SDL_Flip( gamescreen ); return; } // 3. PRINT THE NEW KEY g_oState.m_aiPlayerKeys[a_iPlayerNumber][i] = enKey; g_oBackend.PerlEvalF( "GetKeysym(%d);", enKey ); sge_Blit( poBackground, gamescreen, w+10, iY, w+10, iY, gamescreen->w, 50 ); DrawTextMSZ( g_oBackend.GetPerlString("keysym"), inkFont, w+30, iY, UseShadow, C_WHITE, gamescreen ); sge_UpdateRect( gamescreen, w+10, iY, gamescreen->w, 50 ); iY += iYIncrement; } sge_Blit( poBackground, gamescreen, 0, 470-iYIncrement, 0, 470-iYIncrement, gamescreen->w, gamescreen->h ); sge_UpdateRect( gamescreen, 0, 470-iYIncrement, gamescreen->w, gamescreen->h ); DrawTextMSZ( "Thanks!", inkFont, gamescreen->w/2, iY + 20, UseShadow | AlignCenter, C_WHITE, gamescreen ); GetKey( true ); SDL_BlitSurface( poBackground, NULL, gamescreen, NULL ); SDL_Flip( gamescreen ); }