#include "menu.h"
#include <SDL2/SDL_image.h>
#include "renderer.h"
#include "scaller.h"

static RenderId_t menuObjects[10];
static unsigned menuObjectsSize = 0;

int menu_render(void){
    SDL_Surface* buttonImageSurface = IMG_Load("./assets/img/start.png");
    if(buttonImageSurface == NULL){
        printf("cannot load");
        return -1;
    }
    RenderObject_t buttonImage;
    float buttonScale = 0.3f;

    MonitorSize_t size = renderer_getMonitorSize();
    float aspectRatio = (float)size.width / size.height;

    buttonImage.x = 0.5f;
    buttonImage.y = 0.5f;

    scaller(buttonImageSurface, buttonScale, &buttonImage.width, &buttonImage.height);
    placer(buttonImageSurface, buttonScale, &buttonImage.x, &buttonImage.y);

    buttonImage.surface = buttonImageSurface;
    menuObjects[menuObjectsSize] = renderer_renderObject(buttonImage);
    ++menuObjectsSize;
    return 0;
}

void menu_remove(void){
    for(unsigned i = 0; i < menuObjectsSize; ++i){
        renderer_removeObject(menuObjects[i]);
    }
    menuObjectsSize = 0;
}
