/* ************************************************************************** */
/*                                                                            */
/*                                                        :::      ::::::::   */
/*   main_menu.c                                        :+:      :+:    :+:   */
/*                                                    +:+ +:+         +:+     */
/*   By: qmennen <qmennen@student.codam.nl>         +#+  +:+       +#+        */
/*                                                +#+#+#+#+#+   +#+           */
/*   Created: 2025/05/28 14:14:11 by qmennen           #+#    #+#             */
/*   Updated: 2025/06/04 19:53:06 by qmennen          ###   ########.fr       */
/*                                                                            */
/* ************************************************************************** */

#include "game_menu.h"

static void	game_exit(struct s_menu_item *item, t_game_manager *manager)
{
	(void)item;
	game_manager_destroy(manager);
}

static void	game_start(struct s_menu_item *item, t_game_manager *manager)
{
	t_game		*game;
	t_screen	*screen;

	(void)item;
	game = manager->game;
	screen = game->screen;
	game->screen->minimap->instances[0].enabled = true;
	game->screen->hud->instances[0].enabled = true;
	menu_toggle(*(manager->active_menu), screen);
	manager->state = GAME_STATE_PLAYING;
}

t_menu	*create_main_menu(t_game_manager *manager)
{
	const t_menu_item	*menu_items[] = {
		menu_item_create(manager->game->screen, "Start Game", game_start),
		menu_item_create(manager->game->screen, "Scoreboard", NULL),
		menu_item_create(manager->game->screen, "Exit", game_exit),
		NULL
	};
	t_menu				*menu;

	menu = menu_create(manager, "./assets/menu/surveillor_background.png", menu_items);
	if (!menu)
		return (NULL);
	return (menu);
}
