/* ************************************************************************** */
/*                                                                            */
/*                                                        :::      ::::::::   */
/*   menu.c                                             :+:      :+:    :+:   */
/*                                                    +:+ +:+         +:+     */
/*   By: bszilas <bszilas@student.42vienna.com>     +#+  +:+       +#+        */
/*                                                +#+#+#+#+#+   +#+           */
/*   Created: 2024/09/14 23:58:26 by victor            #+#    #+#             */
/*   Updated: 2025/05/30 12:48:53 by victor           ###   ########.fr       */
/*                                                                            */
/* ************************************************************************** */

#include "../../minirt.h"

int    close_window(void *data_ptr)
{
    key_press(KEY_ESCAPE, data_ptr);
    return (0);
}

void    color_dec(void *null, void *color)
{
    (void)null;
    if (*(uint8_t *)color > 15)
        *(uint8_t *)color -= 15;
    else
        *(uint8_t *)color = 0;
}

void    color_inc(void *null, void *color)
{
    (void)null;
    if (*(uint8_t *)color < 255 - 16)
        *(uint8_t *)color += 15;
    else
        *(uint8_t *)color = 255;
}

void    help_menu_draw(void *data_ptr, void *pixel)
{
    t_rect    background;
    t_data    *data;

    data = data_ptr;
    uint x = data->scene.w / 4;
    uint y = data->scene.h / 4;

    background = (t_rect){x, y, .width = data->scene.w / 2, .height = data->scene.h / 2, };
    (void)pixel;
    rt_draw_rect_blend(background, data->pixel, 0, HELP_MENU_BG);
    glyph_print(x + 2, y + 2, \
            "controls\n\n" \
            "main menu: m\n" \
            "movement: \n" \
            "move: wasdqe\n" \
            "rotate: arrow keys\n" \
            "move light: hjklio\n" \
            "toggle anti aliasing: x\n" \
            "select next light: n\n\n" \
            "drag object: lmouse\nchange object: rmouse + use menu\n\n" \
            "backsp: reset_cam\n" \
            "p: save file\nesc: exit\n", \
            data->pixel);
}
