diff options
author | piernov <piernov@piernov.org> | 2016-08-18 14:13:40 +0200 |
---|---|---|
committer | piernov <piernov@piernov.org> | 2016-08-18 14:13:40 +0200 |
commit | 823a82611d37e618a4734ea480fab4c60b73f5b7 (patch) | |
tree | ad26261abe2c2cf976f3ca38c00f0fefb4373fbd /menu.cpp | |
download | MaiMai-C++-823a82611d37e618a4734ea480fab4c60b73f5b7.tar.gz MaiMai-C++-823a82611d37e618a4734ea480fab4c60b73f5b7.tar.bz2 MaiMai-C++-823a82611d37e618a4734ea480fab4c60b73f5b7.tar.xz MaiMai-C++-823a82611d37e618a4734ea480fab4c60b73f5b7.zip |
Diffstat (limited to 'menu.cpp')
-rwxr-xr-x | menu.cpp | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/menu.cpp b/menu.cpp new file mode 100755 index 0000000..d87bbdd --- /dev/null +++ b/menu.cpp @@ -0,0 +1,65 @@ +#include "menu.h" + +namespace menu +{ + std::vector<musicfile> 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<musicfile>::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; + } + +} + + +}; |