#include "helper.h"
#include "resources.h"
#include "tween.h"
#include "utils.h"

typedef struct helper_s
{
    tween_param_t *hook_y;
    tween_param_t *move_y;
    bool           hook_show;
    bool           move_horizontal;
} helper_t;

static helper_t helper;

void Helper_Init(void)
{
    helper.hook_y = Tween_ParamCreate(400, APP_HEIGHT, APP_HEIGHT - 100, EASE_LINEAR);
    helper.move_y = Tween_ParamCreate(300, APP_HEIGHT, APP_HEIGHT - 100, EASE_LINEAR);

    helper.hook_show       = true;
    helper.move_horizontal = true;
}

void Helper_SetHookShow(void)
{
    helper.hook_show = true;
    Tween_ParamRun(helper.hook_y);
}

void Helper_SetHookHide(void)
{
    helper.hook_show = false;
    Tween_ParamRun(helper.hook_y);
}

void Helper_SetMoveHorizontal(void)
{
    helper.move_horizontal = true;
    Tween_ParamRun(helper.move_y);
}

void Helper_SetMoveVertical(void)
{
    helper.move_horizontal = false;
    Tween_ParamRun(helper.move_y);
}

void Helper_Draw(SDL_Renderer *renderer)
{
    /*
    SDL_Rect hook_frame_rect = Utils_GetRect(0,   0, 68,  18);
    SDL_Rect move_frame_rect = Utils_GetRect(68,  0, 39,  30);
    SDL_Rect hook_draw_rect  = Utils_GetRect(10,  0, 204, 54);
    SDL_Rect move_draw_rect  = Utils_GetRect(240, 0, 117, 90);

    if (helper.hook_show)
        hook_frame_rect.y = 18;

    if (helper.move_horizontal)
        move_frame_rect.y = 30;

    hook_draw_rect.y = (Uint32)Tween_ParamGetValue(helper.hook_y);
    move_draw_rect.y = (Uint32)Tween_ParamGetValue(helper.move_y);

    SDL_RenderCopy(renderer, helperTex, &hook_frame_rect, &hook_draw_rect);
    SDL_RenderCopy(renderer, helperTex, &move_frame_rect, &move_draw_rect);
    */
}

void Helper_Quit(void)
{
    Tween_ParamDelete(helper.hook_y);
    Tween_ParamDelete(helper.move_y);
}
