#pragma once

#include "component_button.h"

#include "../../entity/play/entity_icon.h"
#include "../../entity/play/entity_streak_square.h"
#include "../../entity/play/entity_streak.h"
#include "../../entity/entity_text.h"

#include "../stat/component_shop_item.h"

#define SHOP_BUTTON_TEXT_MAX 16
#define SHOP_BUTTON_SPRITE_Z_OFFSET -0.001f
#define SHOP_BUTTON_PRICE_STREAK_Z_OFFSET -0.002f
#define SHOP_BUTTON_TEXT_STREAK_Z_OFFSET -0.003f

static const vec2 SHOP_BUTTON_SIZE = {96.0f, 96.0f};
static const vec2 SHOP_BUTTON_STREAK_SQUARE_SIZE = {128.0f, 128.0f};
static const vec2 SHOP_BUTTON_STREAK_SIZE = {128.0f, 32.0f};
static const vec2 SHOP_BUTTON_ICON_SIZE = {32.0f, 32.0f};
static const vec3 SHOP_BUTTON_PRICE_STREAK_OFFSET = {0.0f, 75.0f, -0.002f};
static const vec3 SHOP_BUTTON_COUNT_STREAK_OFFSET = {0.0f, 100.0f, -0.003f};
static const vec3 SHOP_BUTTON_PRICE_ICON_OFFSET = {-32.0f, 75.0f, -0.003f};
static const vec3 SHOP_BUTTON_COUNT_ICON_OFFSET = {-32.0f, 100.0f, -0.004f};
static const vec3 SHOP_BUTTON_PRICE_TEXT_OFFSET = {0.0f, 59.0f, -0.004f};
static const vec3 SHOP_BUTTON_COUNT_TEXT_OFFSET = {0.0f, 84.0f, -0.005f};

typedef struct ComponentShopButton
{
	ECSComponent component;
	u32 shopItemID;
	u32 streakID;
	u32 priceStreakID;
	u32 countStreakID;
	u32 priceIconID;
	u32 countIconID;
	u32 priceTextID;
	u32 countTextID;
	vec4 color;
	u32 affectedID;
	bool isUpdate;
} ComponentShopButton;

void
component_shop_button_init
(
	ComponentShopButton* self, 
	ECS* ecs,
	vec3 position,
	u32 shopItemID
);

void component_shop_button_add(ComponentShopButton* self, ECS* ecs);
void component_shop_button_delete(ComponentShopButton* self, ECS* ecs);
void component_shop_button_tick(ComponentShopButton* self, ECS* ecs);
void component_shop_button_enable(ComponentShopButton* self, ECS* ecs);
void component_shop_button_disable(ComponentShopButton* self, ECS* ecs);

static const ECSComponentInfo COMPONENT_SHOP_BUTTON_INFO = 
{
	.system = 
	{
		.functions = 
		{ 
			(ECSFunction)component_shop_button_add, 
			(ECSFunction)component_shop_button_delete, 
			(ECSFunction)component_shop_button_tick, 
			NULL
		}
	},
	.type = ECS_COMPONENT_SHOP_BUTTON,
	.size = sizeof(ComponentShopButton)
};


