#include "menu.h" namespace menu { std::vector songs; SDL_Texture *background; int init_menu() { SDL_Texture *image; songs = loadSongs(); screen.state = STATE_MENU; } int update_menu() { int height = 0; for(std::vector::iterator songData = songs.begin(); songData != songs.end(); ++songData) { std::string path = songData->path + songData->background; background = loadTexture(path, screen.renderer); path = songData->path + songData->banner; image = loadTexture(path, screen.renderer); path = songData->path + songData->file; if (background == nullptr || image == nullptr) continue; SDL_RenderClear(screen.renderer); SDL_Color color={255,0,0}; SDL_Surface *text = TTF_RenderText_Blended(screen.font, path.c_str(), color); SDL_Texture* texture = SDL_CreateTextureFromSurface(screen.renderer, text); renderTexture(texture, screen.renderer, 0.5f, 0.5f); int w, h; float bW, bH; SDL_QueryTexture(background, NULL, NULL, &w, &h); bW = (float)w / (float)screen.width; bH = (float)h / (float)screen.height; float iW, iH; SDL_QueryTexture(image, NULL, NULL, &w, &h); //iW = 0.5f - ( / ( ) /2; //iH = 0.5f - ( (float)h / (float)screen.height ) /2; iW = (float)screen.width - (float)w; iH = height; renderTexture(background, renderer, bW, bH); renderTexture(image, renderer, iW, iH); SDL_RenderPresent(screen.renderer); height += height + 0.02f; } } };