#pragma once

#include "../../../GAME_COMMON.h"
#include "../../ecs_entity.h"

#include "../../entity/play/entity_streak.h"
#include "../../entity/play/entity_icon.h"
#include "../component_text.h"

#define COMPONENT_HUD_DISPLAY_TEXT_FORMAT_VALUE "%u"
#define COMPONENT_HUD_DISPLAY_TEXT_FORMAT_TIME_MM_SS "%02u:%02u"
#define COMPONENT_HUD_DISPLAY_TEXT_FORMAT_TIME_MM_SS_MS "%02u:%02u.%02u"
#define COMPONENT_HUD_DISPLAY_TEXT_FORMAT_WAVE "Wave %u"
#define COMPONENT_HUD_DISPLAY_TEXT_FORMAT_MULTIPLIER "x%u"
#define COMPONENT_HUD_DISPLAY_TEXT_MAX 32
#define COMPONENT_HUD_DISPLAY_TEXT_Z_OFFSET -0.01f
#define COMPONENT_HUD_DISPLAY_ICON_Z_OFFSET -0.02f
#define COMPONENT_HUD_DISPLAY_TEXT_X_OFFSET 24.0f
#define COMPONENT_HUD_DISPLAY_TEXT_Y_OFFSET 0.0f
#define COMPONENT_HUD_DISPLAY_ICON_X_OFFSET -64.0f

typedef enum HUDDisplayFormatType
{
	HUD_DISPLAY_FORMAT_VALUE,
	HUD_DISPLAY_FORMAT_TIME_MM_SS,
	HUD_DISPLAY_FORMAT_TIME_MM_SS_MS,
	HUD_DISPLAY_FORMAT_WAVE,
	HUD_DISPLAY_FORMAT_MULTIPLIER,
} HUDDisplayFormatType;

typedef struct HUDDisplayStat
{
	ECSComponent component;
	u32 value;
	u32 value2;
} HUDDisplayStat;

typedef struct ComponentHUDDisplay
{
	ECSComponent component;
	ECSComponentType type;
	HUDDisplayFormatType formatType;
	u32 streakID;
	u32 iconID;
	u32 id;
	u32 oldValue;
} ComponentHUDDisplay;

void component_hud_display_init
(
	ComponentHUDDisplay* self, 
	ECS* ecs,
	vec3 position,
	u32 id,
	HUDDisplayFormatType formatType,
	IconType iconType,
	ECSComponentType type
);

static const vec4 COMPONENT_HUD_DISPLAY_TEXT_COLOR = {1.0f, 1.0f, 1.0f, 1.0f};
static const vec2 COMPONENT_HUD_DISPLAY_ICON_SIZE = {64.0f, 64.0f};
static const vec2 COMPONENT_HUD_DISPLAY_STREAK_SIZE = {256.0f, 64.0f};

void component_hud_display_add(ComponentHUDDisplay* self, ECS* ecs);
void component_hud_display_delete(ComponentHUDDisplay* self, ECS* ecs);
void component_hud_display_tick(ComponentHUDDisplay* self, ECS* ecs);

static const ECSComponentInfo COMPONENT_HUD_DISPLAY_INFO = 
{
	.system = 
	{
		.functions = 
		{ 
			(ECSFunction)component_hud_display_add, 
			(ECSFunction)component_hud_display_delete, 
			(ECSFunction)component_hud_display_tick, 
			NULL
		}
	},
	.type = ECS_COMPONENT_HUD_DISPLAY,
	.size = sizeof(ComponentHUDDisplay)
};


