#include "application.h"
#include "utils.h"
#include "resources.h"

SDL_Texture *igdc_logoTex        = NULL;
SDL_Texture *start_helpTex       = NULL;
SDL_Texture *font_darkTex        = NULL;
SDL_Texture *font_lightTex       = NULL;
SDL_Texture *titleTex            = NULL;
SDL_Texture *decor_storyTex      = NULL;
SDL_Texture *storyTex            = NULL;
SDL_Texture *end_storyTex        = NULL;
SDL_Texture *developerTex        = NULL;
SDL_Texture *btn_newgameTex      = NULL;
SDL_Texture *btn_optionsTex      = NULL;
SDL_Texture *btn_quitTex         = NULL;
SDL_Texture *btn_exitTex         = NULL;
SDL_Texture *btn_backTex         = NULL;
SDL_Texture *btn_startTex        = NULL;
SDL_Texture *btn_okTex           = NULL;
SDL_Texture *btn_decTex          = NULL;
SDL_Texture *btn_incTex          = NULL;
SDL_Texture *btn_yesTex          = NULL;
SDL_Texture *btn_noTex           = NULL;
SDL_Texture *bar_volumeTex       = NULL;
SDL_Texture *label_volumeTex     = NULL;
SDL_Texture *check_fullscreenTex = NULL;
SDL_Texture *cursorTex           = NULL;
SDL_Texture *helperTex           = NULL;
SDL_Texture *tilesTex            = NULL;
SDL_Texture *fogTex              = NULL;
SDL_Texture *cloudTex            = NULL;
SDL_Texture *roboTex             = NULL;
SDL_Texture *robo_hitTex         = NULL;
SDL_Texture *hookTex             = NULL;
SDL_Texture *teleportTex         = NULL;
SDL_Texture *spawnTex            = NULL;
SDL_Texture *coinTex             = NULL;
SDL_Texture *smokeTex            = NULL;
SDL_Texture *ground_particleTex  = NULL;
SDL_Texture *giblet_particleTex  = NULL;
SDL_Texture *bulletTex           = NULL;
SDL_Texture *fireballTex         = NULL;
SDL_Texture *diamondTex          = NULL;
SDL_Texture *checkpointTex       = NULL;
SDL_Texture *wallfirerTex        = NULL;
SDL_Texture *spikesTex           = NULL;
SDL_Texture *hammerTex           = NULL;
SDL_Texture *walkerTex           = NULL;
SDL_Texture *circularsawTex      = NULL;
SDL_Texture *tankTex             = NULL;
SDL_Texture *gearTex             = NULL;
SDL_Texture *healthTex           = NULL;
SDL_Texture *hudTex              = NULL;
SDL_Texture *hud_questionTex     = NULL;
SDL_Texture *label_endgameTex    = NULL;
SDL_Texture *label_restartTex    = NULL;

Mix_Chunk *clickSnd     = NULL;
Mix_Chunk *jumpSnd      = NULL;
Mix_Chunk *on_groundSnd = NULL;
Mix_Chunk *hookSnd      = NULL;
Mix_Chunk *grabSnd      = NULL;
Mix_Chunk *bonusSnd     = NULL;
Mix_Chunk *hitSnd       = NULL;

void Resources_Init(void)
{
    SDL_Renderer *renderer = Application_GetRenderer();

    igdc_logoTex = Utils_CreateTextureFromFile("data/gfx/igdc.bmp", renderer);
}

void Resources_Load(void)
{
    SDL_Renderer *renderer = Application_GetRenderer();

    start_helpTex       = Utils_CreateTextureFromFile("data/gfx/start_help.bmp", renderer);
    font_darkTex        = Utils_CreateTextureFromFile("data/gfx/font_dark.bmp", renderer);
    font_lightTex       = Utils_CreateTextureFromFile("data/gfx/font_light.bmp", renderer);
    cursorTex           = Utils_CreateTextureFromFile("data/gfx/cursor.bmp", renderer);
    titleTex            = Utils_CreateTextureFromFile("data/gfx/title.bmp", renderer);
    decor_storyTex      = Utils_CreateTextureFromFile("data/gfx/decor_story.bmp", renderer);
    storyTex            = Utils_CreateTextureFromFile("data/gfx/story.bmp", renderer);
    end_storyTex        = Utils_CreateTextureFromFile("data/gfx/end_story.bmp", renderer);
    developerTex        = Utils_CreateTextureFromFile("data/gfx/developer.bmp", renderer);
    btn_newgameTex      = Utils_CreateTextureFromFile("data/gfx/btn_newgame.bmp", renderer);
    btn_optionsTex      = Utils_CreateTextureFromFile("data/gfx/btn_options.bmp", renderer);
    btn_quitTex         = Utils_CreateTextureFromFile("data/gfx/btn_quit.bmp", renderer);
    btn_exitTex         = Utils_CreateTextureFromFile("data/gfx/btn_exit.bmp", renderer);
    btn_backTex         = Utils_CreateTextureFromFile("data/gfx/btn_back.bmp", renderer);
    btn_startTex        = Utils_CreateTextureFromFile("data/gfx/btn_start.bmp", renderer);
    btn_okTex           = Utils_CreateTextureFromFile("data/gfx/btn_ok.bmp", renderer);
    btn_decTex          = Utils_CreateTextureFromFile("data/gfx/btn_dec.bmp", renderer);
    btn_incTex          = Utils_CreateTextureFromFile("data/gfx/btn_inc.bmp", renderer);
    btn_yesTex          = Utils_CreateTextureFromFile("data/gfx/btn_yes.bmp", renderer);
    btn_noTex           = Utils_CreateTextureFromFile("data/gfx/btn_no.bmp", renderer);
    bar_volumeTex       = Utils_CreateTextureFromFile("data/gfx/bar_volume.bmp", renderer);
    label_volumeTex     = Utils_CreateTextureFromFile("data/gfx/label_volume.bmp", renderer);
    check_fullscreenTex = Utils_CreateTextureFromFile("data/gfx/check_fullscreen.bmp", renderer);
    tilesTex            = Utils_CreateTextureFromFile("data/gfx/tiles.bmp", renderer);
    fogTex              = Utils_CreateTextureFromFile("data/gfx/fog.bmp", renderer);
    helperTex           = Utils_CreateTextureFromFile("data/gfx/helper.bmp", renderer);
    cloudTex            = Utils_CreateTextureFromFile("data/gfx/cloud.bmp", renderer);
    roboTex             = Utils_CreateTextureFromFile("data/gfx/robo.bmp", renderer);
    robo_hitTex         = Utils_CreateTextureFromFile("data/gfx/robo_hit.bmp", renderer);
    hookTex             = Utils_CreateTextureFromFile("data/gfx/hook.bmp", renderer);
    teleportTex         = Utils_CreateTextureFromFile("data/gfx/teleport.bmp", renderer);
    spawnTex            = Utils_CreateTextureFromFile("data/gfx/spawn.bmp", renderer);
    coinTex             = Utils_CreateTextureFromFile("data/gfx/coin.bmp", renderer);
    smokeTex            = Utils_CreateTextureFromFile("data/gfx/smoke.bmp", renderer);
    ground_particleTex  = Utils_CreateTextureFromFile("data/gfx/ground_particle.bmp", renderer);
    giblet_particleTex  = Utils_CreateTextureFromFile("data/gfx/giblet_particle.bmp", renderer);
    bulletTex           = Utils_CreateTextureFromFile("data/gfx/bullet.bmp", renderer);
    fireballTex         = Utils_CreateTextureFromFile("data/gfx/fireball.bmp", renderer);
    diamondTex          = Utils_CreateTextureFromFile("data/gfx/diamond.bmp", renderer);
    checkpointTex       = Utils_CreateTextureFromFile("data/gfx/checkpoint.bmp", renderer);
    wallfirerTex        = Utils_CreateTextureFromFile("data/gfx/wallfirer.bmp", renderer);
    spikesTex           = Utils_CreateTextureFromFile("data/gfx/spikes.bmp", renderer);
    hammerTex           = Utils_CreateTextureFromFile("data/gfx/hammer.bmp", renderer);
    walkerTex           = Utils_CreateTextureFromFile("data/gfx/walker.bmp", renderer);
    circularsawTex      = Utils_CreateTextureFromFile("data/gfx/circularsaw.bmp", renderer);
    tankTex             = Utils_CreateTextureFromFile("data/gfx/tank.bmp", renderer);
    gearTex             = Utils_CreateTextureFromFile("data/gfx/gear.bmp", renderer);
    healthTex           = Utils_CreateTextureFromFile("data/gfx/health.bmp", renderer);
    hudTex              = Utils_CreateTextureFromFile("data/gfx/hud.bmp", renderer);
    hud_questionTex     = Utils_CreateTextureFromFile("data/gfx/hud_question.bmp", renderer);
    label_endgameTex    = Utils_CreateTextureFromFile("data/gfx/label_endgame.bmp", renderer);
    label_restartTex    = Utils_CreateTextureFromFile("data/gfx/label_restart.bmp", renderer);

    clickSnd     = Mix_LoadWAV("data/sfx/click.wav");
    jumpSnd      = Mix_LoadWAV("data/sfx/jump.wav");
    on_groundSnd = Mix_LoadWAV("data/sfx/on_ground.wav");
    hookSnd      = Mix_LoadWAV("data/sfx/hook.wav");
    grabSnd      = Mix_LoadWAV("data/sfx/grab.wav");
    bonusSnd     = Mix_LoadWAV("data/sfx/bonus.wav");
    hitSnd       = Mix_LoadWAV("data/sfx/hit.wav");
}

void Resources_Quit(void)
{
    SDL_DestroyTexture(igdc_logoTex);
    SDL_DestroyTexture(start_helpTex);
    SDL_DestroyTexture(font_darkTex);
    SDL_DestroyTexture(font_lightTex);
    SDL_DestroyTexture(titleTex);
    SDL_DestroyTexture(decor_storyTex);
    SDL_DestroyTexture(storyTex);
    SDL_DestroyTexture(end_storyTex);
    SDL_DestroyTexture(developerTex);
    SDL_DestroyTexture(btn_newgameTex);
    SDL_DestroyTexture(btn_optionsTex);
    SDL_DestroyTexture(btn_quitTex);
    SDL_DestroyTexture(btn_exitTex);
    SDL_DestroyTexture(btn_backTex);
    SDL_DestroyTexture(btn_startTex);
    SDL_DestroyTexture(btn_okTex);
    SDL_DestroyTexture(btn_decTex);
    SDL_DestroyTexture(btn_incTex);
    SDL_DestroyTexture(btn_yesTex);
    SDL_DestroyTexture(btn_noTex);
    SDL_DestroyTexture(bar_volumeTex);
    SDL_DestroyTexture(label_volumeTex);
    SDL_DestroyTexture(check_fullscreenTex);
    SDL_DestroyTexture(cursorTex);
    SDL_DestroyTexture(helperTex);
    SDL_DestroyTexture(tilesTex);
    SDL_DestroyTexture(fogTex);
    SDL_DestroyTexture(cloudTex);
    SDL_DestroyTexture(roboTex);
    SDL_DestroyTexture(robo_hitTex);
    SDL_DestroyTexture(hookTex);
    SDL_DestroyTexture(teleportTex);
    SDL_DestroyTexture(spawnTex);
    SDL_DestroyTexture(coinTex);
    SDL_DestroyTexture(smokeTex);
    SDL_DestroyTexture(ground_particleTex);
    SDL_DestroyTexture(giblet_particleTex);
    SDL_DestroyTexture(bulletTex);
    SDL_DestroyTexture(fireballTex);
    SDL_DestroyTexture(diamondTex);
    SDL_DestroyTexture(checkpointTex);
    SDL_DestroyTexture(wallfirerTex);
    SDL_DestroyTexture(spikesTex);
    SDL_DestroyTexture(hammerTex);
    SDL_DestroyTexture(walkerTex);
    SDL_DestroyTexture(circularsawTex);
    SDL_DestroyTexture(tankTex);
    SDL_DestroyTexture(gearTex);
    SDL_DestroyTexture(healthTex);
    SDL_DestroyTexture(hudTex);
    SDL_DestroyTexture(hud_questionTex);
    SDL_DestroyTexture(label_endgameTex);
    SDL_DestroyTexture(label_restartTex);

    Mix_FreeChunk(clickSnd);
    Mix_FreeChunk(jumpSnd);
    Mix_FreeChunk(on_groundSnd);
    Mix_FreeChunk(hookSnd);
    Mix_FreeChunk(grabSnd);
    Mix_FreeChunk(bonusSnd);
    Mix_FreeChunk(hitSnd);
}
