diff --git a/Source/Main.c b/Source/Main.c index 741bfd9..5230c69 100644 --- a/Source/Main.c +++ b/Source/Main.c @@ -156,7 +156,21 @@ void EventHandle() { } void DrawInventory() { - + DebugMsg = TTF_RenderText_Blended( DebugFont, "Inventory", DebugTextColor ); + DrawSurf( ScreenWidth/2 - 4*9, 8, DebugMsg, NULL, Screen ); + int s; + int y = 0; + for ( int i = 0; i < BlocksetNum-1; i++ ) { + s += 1; + int x = ScreenWidth/16 + s*BlockSize + s*BlockSize/4; + if ( x >= ScreenWidth - BlockSize - BlockSize/4 ) { + y += BlockSize + BlockSize/4; + x = ScreenWidth/16; + s = 0; + } + DrawSurf( x, y, BlocksImg, &Blocks[i+1].Img, Screen ); + } + DrawOutlineRect ( SDL_Surface * Dst ); } void DrawMap() { // TODO: Reoptimize this to draw only visible blocks @@ -351,7 +365,7 @@ int main( int argc, char* args[] ) { } if ( Recalc ) { EventHandle(); - SDL_FillRect( Screen, &Screen->clip_rect, SDL_MapRGB( Screen->format, 0xFF, 0xFF, 0xFF ) ); + FillSurfRGB ( 0xFF, 0xFF, 0xFF, Screen ); if ( InGame && !InInventory ) { SetCamera(); DrawMap(); diff --git a/Source/Util.c b/Source/Util.c index a1907b0..c154ce6 100644 --- a/Source/Util.c +++ b/Source/Util.c @@ -28,6 +28,14 @@ void DrawSurf ( int x, int y, SDL_Surface * Src, SDL_Rect * Clip, SDL_Surface * SDL_BlitSurface( Src, Clip, Dst, &Offset ); } +void FillSurfRGB ( int R, int G, int B, SDL_Surface * Dst ) { + SDL_FillRect( Dst, &Dst->clip_rect, SDL_MapRGB( Dst->format, R, G, B ) ); +} + +void DrawOutlineRect ( SDL_Surface * Dst ) { + SDL_FillRect( Dst, 8, 8, 4, 16, SDL_MapRGB( Dst->format, 0x00, 0x00, 0x00 ) ); +} + SDL_Surface * ScreenSet ( int Width, int Height, int Bits, SDL_Surface * Screen ) { Screen = SDL_SetVideoMode ( Width, Height, Bits, #ifdef Target_PocketGo diff --git a/Source/Util.h b/Source/Util.h index 65b8229..31bdb12 100644 --- a/Source/Util.h +++ b/Source/Util.h @@ -3,6 +3,8 @@ SDL_Surface * LoadImage ( char * FilePath ); void DrawSurf ( int x, int y, SDL_Surface * Src, SDL_Rect * Clip, SDL_Surface * Dst ); +void FillSurfRGB ( int R, int G, int B, SDL_Surface * Dst ); +void DrawOutlineRect ( SDL_Surface * Dst ); SDL_Surface * ScreenSet ( int Width, int Height, int Bits, SDL_Surface * Screen ); bool FlipScreen( SDL_Surface * Screen );