summaryrefslogtreecommitdiffstats
path: root/menu.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'menu.cpp')
-rwxr-xr-xmenu.cpp65
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;
+ }
+
+}
+
+
+};