diff --git a/Makefile b/Makefile index a7ee1b7..5cf1b71 100644 --- a/Makefile +++ b/Makefile @@ -21,9 +21,11 @@ NCURSESADDONLIBS = -lncurses ifdef _WIN32 NCURSESADDONLIBS += -DNCURSES_STATIC - SDLADDONLIBS += -lSDL_ttf - CCOPT += -LC:/msys64/mingw64/bin/../lib -lmingw32 $(SDLADDONLIBS) $(NCURSESADDONLIBS) -mwindows -D_WIN32 - LIBS = -LC:/msys64/mingw64/bin/../lib -lmingw32 $(SDLADDONLIBS) $(NCURSESADDONLIBS) -mwindows -D_WIN32 + SDLADDONLIBS += -lSDL2_ttf + # CCOPT += -LC:/msys64/mingw64/bin/../lib -lmingw32 $(SDLADDONLIBS) $(NCURSESADDONLIBS) -mwindows -D_WIN32 + # LIBS = -LC:/msys64/mingw64/bin/../lib -lmingw32 $(SDLADDONLIBS) $(NCURSESADDONLIBS) -mwindows -D_WIN32 + CCOPT += -LC:/msys64/mingw32/bin/../lib -lmingw32 $(SDLADDONLIBS) $(NCURSESADDONLIBS) -mwindows -D_WIN32 + LIBS = -LC:/msys64/mingw32/bin/../lib -lmingw32 $(SDLADDONLIBS) $(NCURSESADDONLIBS) -mwindows -D_WIN32 endif ifdef LINUX diff --git a/fonts/FiraCode.ttf b/fonts/FiraCode.ttf new file mode 100644 index 0000000..2cad018 Binary files /dev/null and b/fonts/FiraCode.ttf differ diff --git a/include/button.h b/include/button.h index ad0386a..e42c1b4 100644 --- a/include/button.h +++ b/include/button.h @@ -31,13 +31,13 @@ int iBUTTON_CheckInteraction(SDL_Event *pSDL_EVENT_Ev, int iXCursor, int iYCurso int iBUTTON_AddToList(SDL_Rect *pSDL_RECT_Btm, int iAction){ STRUCT_BUTTON_LIST *pstWrkButtonList; - eMovAction eMvAct = (eMovAction)iAction; + eBtnAction eBtnAct = (eBtnAction)iAction; for ( pstWrkButtonList = &gstButtonList; pstWrkButtonList->pstNext != NULL; pstWrkButtonList = pstWrkButtonList->pstNext ); if ( pstWrkButtonList->iAction == 0 && pstWrkButtonList == &gstButtonList){ pstWrkButtonList->pSDL_RECT_Button = pSDL_RECT_Btm; - pstWrkButtonList->iAction = eMvAct; + pstWrkButtonList->iAction = eBtnAct; pstWrkButtonList->pstNext = NULL; return 0; } @@ -47,7 +47,7 @@ int iBUTTON_AddToList(SDL_Rect *pSDL_RECT_Btm, int iAction){ memset(pstWrkButtonList->pstNext, 0, sizeof(STRUCT_BUTTON_LIST)); pstWrkButtonList = pstWrkButtonList->pstNext; pstWrkButtonList->pSDL_RECT_Button = pSDL_RECT_Btm; - pstWrkButtonList->iAction = eMvAct; + pstWrkButtonList->iAction = eBtnAct; pstWrkButtonList->pstNext = NULL; return 0; diff --git a/include/cattie.h b/include/cattie.h index 0962c9f..e363607 100644 --- a/include/cattie.h +++ b/include/cattie.h @@ -29,6 +29,7 @@ // #define gstCmdLine.szWinHeight 800 #define WINDOW_RATIO gstCmdLine.szWinWidth/gstCmdLine.szWinHeight + #define REDRAW_NONE 0 #define REDRAW_IMAGE 1 #define ERROR_WALKING 10 @@ -37,13 +38,15 @@ #define BUTTON_DIRECTION 1 #define BUTTON_CONFIRM 2 #define BUTTON_ERASE 3 + #define BUTTON_CONFIGURE 4 #define PLAYER_IMG_PATH_IDX 0 #define FORWARD_IMG_PATH_IDX 1 #define LASER_IMG_PATH_IDX 2 #define ROTATE_IMG_PATH_IDX 3 + #define GEAR_IMG_PATH_IDX 4 - #define _MAX_IMG_PATH 4 + // #define _MAX_IMG_PATH 4 #define DEVELOPER "Renato Fermi & Gustavo Bacagine" #define VERSION "1.0" @@ -73,13 +76,14 @@ END_SQUARE } eSqType; - typedef enum MovementAction{ + typedef enum ButtonAction{ FORWARD = 1, TURN, FIRE_LASER, ERASE, - CONFIRM - } eMovAction; + CONFIRM, + CONFIGURE + } eBtnAction; typedef enum WindRose{ NORTH = 1, diff --git a/include/font.h b/include/font.h new file mode 100644 index 0000000..3500f81 --- /dev/null +++ b/include/font.h @@ -0,0 +1,16 @@ +#include +#include + +#define PATH_TO_TTF "fonts" +#define TTF_FONT_TITLE "FiraCode.ttf" + + +TTF_Font *ttfSDL_InitFont(){ + char szFontPath[_MAX_PATH]; + + if ( TTF_Init() ) + return NULL; + + sprintf(szFontPath, "%s/%s", PATH_TO_TTF, TTF_FONT_TITLE); + return TTF_OpenFont(szFontPath, 16); +} \ No newline at end of file diff --git a/include/menu.h b/include/menu.h index 9cd1284..19f845f 100644 --- a/include/menu.h +++ b/include/menu.h @@ -1,4 +1,5 @@ #include +#include #ifndef _CATTIE_H_INC #include @@ -8,57 +9,102 @@ #define MAX_MENU_OPTIONS 6 +enum eMenuOption{ + MENU_OPT_1 = 0, + MENU_OPT_2 , + MENU_OPT_3 , + MENU_OPT_4 , + MENU_OPT_5 , + MENU_OPT_EXIT // 5 +} eMenuOption; + extern int giMENU_SelectedItem; +int gbDrawMenu = TRUE; -void vInitMenu(SDL_Rect *pSDL_RECT_Mn, int iOptionCt){ - SDL_Rect *pSDL_RECT_Wrk; - int iInitCt = 0; - int iMenuOptWidth = iOptionCt*20; - int iMenuOptHeight = iMenuOptWidth; - for ( pSDL_RECT_Wrk = pSDL_RECT_Mn; - iInitCt < iOptionCt; - pSDL_RECT_Wrk++, iInitCt++ ){ - pSDL_RECT_Wrk->x= atoi(gstCmdLine.szWinWidth) / 2 - iMenuOptWidth; - pSDL_RECT_Wrk->y= atoi(gstCmdLine.szWinHeight) / 2 - iMenuOptHeight; - iMenuOptHeight -=20; - pSDL_RECT_Wrk->w = 100; - pSDL_RECT_Wrk->h = 25; - } -} +void vInitMenu(SDL_Rect *pSDL_RECT_Mn, int iOptionCt) { + SDL_Rect *pSDL_RECT_Wrk; + int iInitCt = 0; + int iMenuOptWidth = iOptionCt * 20; + int iMenuOptHeight = iMenuOptWidth; -void vMENU_HandleKey(SDL_Keycode peSDL_KeyCode){ - switch (peSDL_KeyCode) { - case SDLK_UP: - - giMENU_SelectedItem--; - if (giMENU_SelectedItem < 0) { - giMENU_SelectedItem = MAX_MENU_OPTIONS-1; - } - break; - case SDLK_DOWN: - giMENU_SelectedItem++; - if (giMENU_SelectedItem >= MAX_MENU_OPTIONS) { - giMENU_SelectedItem = 0; - } - break; - case SDLK_RETURN: - // Handle menu item selection - break; - } + for (pSDL_RECT_Wrk = pSDL_RECT_Mn; iInitCt < iOptionCt; pSDL_RECT_Wrk++, iInitCt++) { + pSDL_RECT_Wrk->x = atoi(gstCmdLine.szWinWidth) / 2 - iMenuOptWidth; + pSDL_RECT_Wrk->y = atoi(gstCmdLine.szWinHeight) / 2 - iMenuOptHeight; + iMenuOptHeight -= 20; + pSDL_RECT_Wrk->w = 100; + pSDL_RECT_Wrk->h = 25; + } } -void vDrawMenu(SDL_Renderer *renderer, SDL_Rect *pSDL_RECT_Mn, int iOptionCt){ - int iInitCt = 0; - SDL_Rect *pSDL_RECT_Wrk; - for ( pSDL_RECT_Wrk = pSDL_RECT_Mn; - iInitCt < iOptionCt; - pSDL_RECT_Wrk++, iInitCt++) { - if (iInitCt == giMENU_SelectedItem) { - SDL_SetRenderDrawColor(renderer, 255, 0, 0, 255); +void vDrawMenu(SDL_Renderer *renderer, SDL_Rect *pSDL_RECT_Mn, char **ppszOptionTitle, int iOptionCt, TTF_Font *font) { + int iInitCt = 0; + SDL_Rect *pSDL_RECT_Wrk; + SDL_Color textColor = {0, 0, 0, 255}; + + if ( gbDrawMenu == FALSE ) + return ; + for (pSDL_RECT_Wrk = pSDL_RECT_Mn; iInitCt < iOptionCt; pSDL_RECT_Wrk++, iInitCt++) { + if (iInitCt == giMENU_SelectedItem) { + SDL_SetRenderDrawColor(renderer, 255, 0, 0, 255); + } else { + SDL_SetRenderDrawColor(renderer, 255, 255, 255, 255); + } + + SDL_RenderFillRect(renderer, pSDL_RECT_Wrk); + + // Render text on the menu option + SDL_Surface *textSurface = TTF_RenderText_Solid(font, ppszOptionTitle[iInitCt], textColor); + SDL_Texture *textTexture = SDL_CreateTextureFromSurface(renderer, textSurface); + + SDL_Rect textRect; + textRect.x = pSDL_RECT_Wrk->x + (pSDL_RECT_Wrk->w - textSurface->w) / 2; + textRect.y = pSDL_RECT_Wrk->y + (pSDL_RECT_Wrk->h - textSurface->h) / 2; + textRect.w = textSurface->w; + textRect.h = textSurface->h; + + SDL_RenderCopy(renderer, textTexture, NULL, &textRect); + + SDL_FreeSurface(textSurface); + SDL_DestroyTexture(textTexture); } - else { - SDL_SetRenderDrawColor(renderer, 255, 255, 255, 255); +} + +// Update vMENU_HandleKey function to handle text rendering +void vMENU_HandleKey(SDL_Keycode peSDL_KeyCode, char **ppszOptionTitle) { + if ( gbDrawMenu == FALSE ) + return ; + switch (peSDL_KeyCode) { + case SDLK_UP: + giMENU_SelectedItem--; + if (giMENU_SelectedItem < 0) { + giMENU_SelectedItem = MAX_MENU_OPTIONS - 1; + } + break; + case SDLK_DOWN: + giMENU_SelectedItem++; + if (giMENU_SelectedItem >= MAX_MENU_OPTIONS) { + giMENU_SelectedItem = 0; + } + break; + case SDLK_RETURN: + if (giMENU_SelectedItem >= MAX_MENU_OPTIONS || giMENU_SelectedItem < 0) + break; + + if (DEBUG_MSGS) + vTraceVarArgs("Pressed ENTER Menu Choice[%d]=[%s]", giMENU_SelectedItem, ppszOptionTitle[giMENU_SelectedItem]); + + if ( giMENU_SelectedItem == MENU_OPT_EXIT ) + gbDrawMenu = FALSE; + + // Handle menu item selection + break; } - SDL_RenderFillRect(renderer, pSDL_RECT_Wrk); - } } + +void vMENU_ToggleVisibility(){ + if ( gbDrawMenu == FALSE ) + gbDrawMenu = TRUE; + + return ; +} + diff --git a/src/cattie.c b/src/cattie.c index d63b0cb..ca7cbd4 100644 --- a/src/cattie.c +++ b/src/cattie.c @@ -48,11 +48,21 @@ STRUCT_PLAYER gstPlayer; }; #endif +char *ppszMenuOpt[MAX_MENU_OPTIONS] = { + "option 1", + "option 2", + "option 3", + "option 4", + "option 5", + "Sair" +}; + char *ppszImagePath[] = { "img/cat2.png", "img/forward.png", "img/laser.png", - "img/rotate2.png" + "img/rotate2.png", + "img/gear.png" }; /* Receive the name of program */ @@ -106,24 +116,24 @@ SDL_Surface *pSDL_SRFC_LoadImage(char *pszImgPath){ return SDL_SRFC_Img; } -SDL_Texture *pSDL_TXTR_CreateTextureFromSurface(SDL_Renderer *renderer, SDL_Surface *pSDL_SRFC_Img){ - // Create the texture from the image - SDL_Texture *SDL_TXTR_Texture = SDL_CreateTextureFromSurface(renderer, pSDL_SRFC_Img); - - if(DEBUG_MSGS) vTraceBegin(); - - if (SDL_TXTR_Texture == NULL) { - printf("Error creating texture: %s\n", SDL_GetError()); - - if(DEBUG_MORE_MSGS) vTraceVarArgs("%s - end return NULL", __func__); - - return NULL; - } - - if(DEBUG_MSGS) vTraceEnd(); - - return SDL_TXTR_Texture; -} +// SDL_Texture *pSDL_TXTR_CreateTextureFromSurface(SDL_Renderer *renderer, SDL_Surface *pSDL_SRFC_Img){ +// // Create the texture from the image +// SDL_Texture *SDL_TXTR_Texture = SDL_CreateTextureFromSurface(renderer, pSDL_SRFC_Img); +// +// if(DEBUG_MSGS) vTraceBegin(); +// +// if (SDL_TXTR_Texture == NULL) { +// printf("Error creating texture: %s\n", SDL_GetError()); +// +// if(DEBUG_MORE_MSGS) vTraceVarArgs("%s - end return NULL", __func__); +// +// return NULL; +// } +// +// if(DEBUG_MSGS) vTraceEnd(); +// +// return SDL_TXTR_Texture; +// } void vDrawSquareEdges(SDL_Renderer *renderer){ int ii; @@ -420,6 +430,10 @@ int iHandleClick(SDL_Event *pSDL_EVENT_Ev){ if ( DEBUG_MSGS ) vTraceMsg("Confirm!\n"); gbACTION_Check = TRUE; break; + case CONFIGURE: + if ( DEBUG_MSGS ) vTraceMsg("Configure!\n"); + vMENU_ToggleVisibility(); + return -10; default: break; } @@ -430,7 +444,7 @@ int iHandleClick(SDL_Event *pSDL_EVENT_Ev){ } int iHandleEventKey(SDL_Event *pSDL_EVENT_Ev){ - vMENU_HandleKey(pSDL_EVENT_Ev->key.keysym.sym); + vMENU_HandleKey(pSDL_EVENT_Ev->key.keysym.sym, ppszMenuOpt); if(DEBUG_MSGS) vTraceBegin(); @@ -495,7 +509,7 @@ int iHandleMouseMotion(SDL_Rect *pSDL_RECT_Menu, SDL_Event *pSDL_EVENT_Ev){ UNUSED(pSDL_RECT_Menu); - if(DEBUG_MORE_MSGS) vTraceBegin(); + // if(DEBUG_MORE_MSGS) vTraceBegin(); SDL_GetMouseState(&iX, &iY); @@ -506,7 +520,7 @@ int iHandleMouseMotion(SDL_Rect *pSDL_RECT_Menu, SDL_Event *pSDL_EVENT_Ev){ return REDRAW_IMAGE; } - if(DEBUG_MORE_MSGS) vTraceEnd(); + // if(DEBUG_MORE_MSGS) vTraceEnd(); return 0; } @@ -524,6 +538,7 @@ int SDL_main(int argc, char *argv[]){ SDL_Texture *pSDL_TXTR_ImageFoward; SDL_Texture *pSDL_TXTR_ImageRotate; SDL_Texture *pSDL_TXTR_ImageLaser; + SDL_Texture *pSDL_TXTR_ImageConfig; SDL_Texture *pSDL_TXTR_Hud; SDL_Texture *pSDL_TXTR_ButtonHud; SDL_Texture *pSDL_TXTR_SquareBorder; @@ -534,8 +549,10 @@ int SDL_main(int argc, char *argv[]){ SDL_Rect SDL_RECT_ButtonTurnArrow; SDL_Rect SDL_RECT_ButtonFireLaser; SDL_Rect SDL_RECT_ButtonUndoLast; - SDL_Rect SDL_RECT_ButtonConfirmAction; + SDL_Rect SDL_RECT_ButtonConfirm; + SDL_Rect SDL_RECT_ButtonConfigure; SDL_Rect *pSDL_RECT_Menu = NULL; + TTF_Font *pttf_Font; // eSDLT_Renderizable eSDLTypes; SDL_Window* window; SDL_Renderer* renderer; @@ -545,7 +562,8 @@ int SDL_main(int argc, char *argv[]){ UNUSED(SDL_RECT_ButtonUndoLast); UNUSED(SDL_RECT_ButtonFireLaser); UNUSED(SDL_RECT_ButtonTurnArrow); - UNUSED(SDL_RECT_ButtonConfirmAction); + UNUSED(SDL_RECT_ButtonConfirm); + UNUSED(SDL_RECT_ButtonConfigure); memset(&gstCmdLine, 0, sizeof(gstCmdLine)); @@ -586,7 +604,18 @@ int SDL_main(int argc, char *argv[]){ } return 1; } - + if ( (pttf_Font = ttfSDL_InitFont()) == NULL ){ + if ( DEBUG_MSGS ) { + char szMsg[256]; + sprintf(szMsg, + "Couldn't initialize Font: %s", + TTF_FONT_TITLE + ); + vTraceMsg(szMsg); + } + return 1; + } + // Create a window window = SDL_CreateWindow( WINDOW_TITLE, @@ -620,11 +649,6 @@ int SDL_main(int argc, char *argv[]){ // Set Button Sizes // Walk Forward vSetButtonDimensions(&SDL_RECT_ButtonArrowRight, iXTranslation); - { - char szMsg[256]; - sprintf(szMsg,"%d-%d-%d-%d", SDL_RECT_ButtonArrowRight.h, SDL_RECT_ButtonArrowRight.w, SDL_RECT_ButtonArrowRight.x, SDL_RECT_ButtonArrowRight.y); - vTraceMsg(szMsg); - } iXTranslation += SDL_RECT_ButtonArrowRight.w + 10; // Turn Arrow vSetButtonDimensions(&SDL_RECT_ButtonTurnArrow, iXTranslation); @@ -636,7 +660,10 @@ int SDL_main(int argc, char *argv[]){ vSetButtonDimensions(&SDL_RECT_ButtonUndoLast, iXTranslation); iXTranslation += SDL_RECT_ButtonUndoLast.w + 50; // Confirm Action - vSetButtonDimensions(&SDL_RECT_ButtonConfirmAction, iXTranslation); + vSetButtonDimensions(&SDL_RECT_ButtonConfirm, iXTranslation); + iXTranslation += SDL_RECT_ButtonConfirm.w + 100; + // Configure Action + vSetButtonDimensions(&SDL_RECT_ButtonConfigure, iXTranslation); // Square Edges vDrawSquareEdges(renderer); @@ -646,7 +673,8 @@ int SDL_main(int argc, char *argv[]){ iBUTTON_AddToList(&SDL_RECT_ButtonTurnArrow , TURN); iBUTTON_AddToList(&SDL_RECT_ButtonFireLaser , FIRE_LASER) ; iBUTTON_AddToList(&SDL_RECT_ButtonUndoLast , ERASE); - iBUTTON_AddToList(&SDL_RECT_ButtonConfirmAction, CONFIRM); + iBUTTON_AddToList(&SDL_RECT_ButtonConfirm , CONFIRM); + iBUTTON_AddToList(&SDL_RECT_ButtonConfigure , CONFIGURE); SDL_RenderPresent(renderer); /** @@ -657,7 +685,8 @@ int SDL_main(int argc, char *argv[]){ pSDL_TXTR_ImagePlayer = IMG_LoadTexture(renderer , ppszInstalledImagePath[PLAYER_IMG_PATH_IDX]); pSDL_TXTR_ImageFoward = IMG_LoadTexture(renderer , ppszInstalledImagePath[FORWARD_IMG_PATH_IDX]); pSDL_TXTR_ImageLaser = IMG_LoadTexture(renderer , ppszInstalledImagePath[LASER_IMG_PATH_IDX]); - pSDL_TXTR_ImageRotate = IMG_LoadTexture(renderer , ppszInstalledImagePath[ROTATE_IMG_PATH_IDX]); + pSDL_TXTR_ImageRotate = IMG_LoadTexture(renderer , ppszInstalledImagePath[ROTATE_IMG_PATH_IDX]); + pSDL_TXTR_ImageConfig = IMG_LoadTexture(renderer , ppszInstalledImagePath[GEAR_IMG_PATH_IDX]); } else { @@ -665,6 +694,7 @@ int SDL_main(int argc, char *argv[]){ pSDL_TXTR_ImageFoward = IMG_LoadTexture(renderer , ppszImagePath[FORWARD_IMG_PATH_IDX]); pSDL_TXTR_ImageLaser = IMG_LoadTexture(renderer , ppszImagePath[LASER_IMG_PATH_IDX]); pSDL_TXTR_ImageRotate = IMG_LoadTexture(renderer , ppszImagePath[ROTATE_IMG_PATH_IDX]); + pSDL_TXTR_ImageConfig = IMG_LoadTexture(renderer , ppszImagePath[GEAR_IMG_PATH_IDX]); } pSDL_TXTR_Hud = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_TARGET, SDL_RECT_Hud.w, SDL_RECT_Hud.h); @@ -672,12 +702,10 @@ int SDL_main(int argc, char *argv[]){ pSDL_TXTR_SquareBorder = createSquareTexture(renderer); vInitializeImagePosition(&SDL_RECT_Player); + + pSDL_RECT_Menu = (SDL_Rect *) malloc(MAX_MENU_OPTIONS*sizeof(SDL_Rect)); - // SDL_RenderCopyEx(renderer, pSDL_TXTR_ImagePlayer, NULL, &SDL_RECT_Player, giDeg, NULL, SDL_FLIP_HORIZONTAL); - - //pSDL_RECT_Menu = (SDL_Rect *) malloc(MAX_MENU_OPTIONS*sizeof(SDL_Rect)); - - // vInitMenu(pSDL_RECT_Menu, MAX_MENU_OPTIONS); + vInitMenu(pSDL_RECT_Menu, MAX_MENU_OPTIONS); gstPlayer.pSDL_RECT_Player = &SDL_RECT_Player; @@ -685,7 +713,8 @@ int SDL_main(int argc, char *argv[]){ vDrawButton(renderer, &SDL_RECT_ButtonTurnArrow, BUTTON_DIRECTION); vDrawButton(renderer, &SDL_RECT_ButtonFireLaser, BUTTON_DIRECTION); vDrawButton(renderer, &SDL_RECT_ButtonUndoLast, BUTTON_ERASE); - vDrawButton(renderer, &SDL_RECT_ButtonConfirmAction, BUTTON_CONFIRM); + vDrawButton(renderer, &SDL_RECT_ButtonConfirm, BUTTON_CONFIRM); + vDrawButton(renderer, &SDL_RECT_ButtonConfigure, BUTTON_CONFIGURE); /* iGXRF_Add2RenderList( renderer, @@ -741,9 +770,13 @@ int SDL_main(int argc, char *argv[]){ gbRunning = FALSE; break; case SDL_MOUSEBUTTONDOWN: - if ( iHandleClick(&event) ){ + if ( (iRedrawAction = iHandleClick(&event)) > 0 ){ gbRunning = FALSE; + iRedrawAction = REDRAW_NONE; + break; } + if ( iRedrawAction == -10) + iRedrawAction = REDRAW_IMAGE; break; case SDL_KEYDOWN: iHandleEventKey(&event); @@ -780,26 +813,24 @@ int SDL_main(int argc, char *argv[]){ vDrawCommandHUD(renderer, pSDL_TXTR_Hud, &SDL_RECT_Hud); vDrawButtonHUD (renderer, pSDL_TXTR_ButtonHud, &SDL_RECT_ButtonHud); - - // vDrawButtons(renderer); - - // vGXRF_RenderAll(); - // vGXRF_RenderObject(&SDL_RECT_ButtonArrowRight); + vDrawButton(renderer, &SDL_RECT_ButtonArrowRight, BUTTON_DIRECTION); vDrawButton(renderer, &SDL_RECT_ButtonTurnArrow, BUTTON_DIRECTION); vDrawButton(renderer, &SDL_RECT_ButtonFireLaser, BUTTON_DIRECTION); vDrawButton(renderer, &SDL_RECT_ButtonUndoLast, BUTTON_ERASE); - vDrawButton(renderer, &SDL_RECT_ButtonConfirmAction, BUTTON_CONFIRM); + vDrawButton(renderer, &SDL_RECT_ButtonConfirm, BUTTON_CONFIRM); + vDrawButton(renderer, &SDL_RECT_ButtonConfigure, BUTTON_CONFIGURE); SDL_RenderCopy(renderer, pSDL_TXTR_ImageFoward, NULL, &SDL_RECT_ButtonArrowRight); SDL_RenderCopy(renderer, pSDL_TXTR_ImageLaser , NULL, &SDL_RECT_ButtonFireLaser); SDL_RenderCopy(renderer, pSDL_TXTR_ImageRotate, NULL, &SDL_RECT_ButtonTurnArrow); + SDL_RenderCopy(renderer, pSDL_TXTR_ImageConfig, NULL, &SDL_RECT_ButtonConfigure); - // vDrawMenu(renderer, pSDL_RECT_Menu, MAX_MENU_OPTIONS); + vDrawMenu(renderer, pSDL_RECT_Menu, ppszMenuOpt, MAX_MENU_OPTIONS, pttf_Font); // Update the screen SDL_RenderPresent(renderer); - // Vamos sincronizar o refreshrate..d + // Vamos sincronizar o refreshrate.. ui64ElapsedTime -= SDL_GetTicks64(); if (ui64ElapsedTime <= VSYNC_TIME) SDL_Delay(VSYNC_TIME - ui64ElapsedTime); @@ -808,7 +839,7 @@ int SDL_main(int argc, char *argv[]){ } // Clean up - // iGXRF_End(); + TTF_CloseFont(pttf_Font); vBUTTON_FreeList(); // Don't forget to destroy the texture when you're done with it SDL_DestroyTexture(pSDL_TXTR_Hud); @@ -817,6 +848,7 @@ int SDL_main(int argc, char *argv[]){ SDL_DestroyTexture(pSDL_TXTR_ImageFoward); SDL_DestroyTexture(pSDL_TXTR_ImageLaser ); SDL_DestroyTexture(pSDL_TXTR_ImageRotate); + SDL_DestroyTexture(pSDL_TXTR_ImageConfig); SDL_DestroyTexture(pSDL_TXTR_SquareBorder); SDL_DestroyRenderer(renderer); SDL_DestroyWindow(window);