first commit
This commit is contained in:
51
src/game/ecs/component/ui/component_button.h
Normal file
51
src/game/ecs/component/ui/component_button.h
Normal file
@ -0,0 +1,51 @@
|
||||
#pragma once
|
||||
|
||||
#include "../visual/component_texture_quad.h"
|
||||
#include "../physics/component_physics.h"
|
||||
|
||||
#include "../../entity/utility/entity_timer.h"
|
||||
|
||||
#define BUTTON_STATE_COUNT BUTTON_STATE_PRESSED + 1
|
||||
typedef enum ButtonState
|
||||
{
|
||||
BUTTON_STATE_NONE,
|
||||
BUTTON_STATE_HOVER,
|
||||
BUTTON_STATE_PRESSED
|
||||
} ButtonState;
|
||||
|
||||
typedef struct ComponentButton
|
||||
{
|
||||
Component component;
|
||||
ButtonState state;
|
||||
bool isJustPressed;
|
||||
} ComponentButton;
|
||||
|
||||
void component_button_add(ComponentButton* self, ECS* ecs);
|
||||
void component_button_tick(ComponentButton* self, ECS* ecs);
|
||||
|
||||
#define COMPONENT_BUTTON_DEPENDENCY_COUNT 1
|
||||
static const ComponentType COMPONENT_BUTTON_DEPENDENCIES[COMPONENT_BUTTON_DEPENDENCY_COUNT] =
|
||||
{
|
||||
COMPONENT_TEXTURE_QUAD
|
||||
};
|
||||
|
||||
static const ComponentInfo COMPONENT_BUTTON_INFO =
|
||||
{
|
||||
.system =
|
||||
{
|
||||
.functions =
|
||||
{
|
||||
(ECSFunction)component_button_add,
|
||||
NULL,
|
||||
(ECSFunction)component_button_tick,
|
||||
NULL,
|
||||
NULL
|
||||
}
|
||||
},
|
||||
.type = COMPONENT_BUTTON,
|
||||
.size = sizeof(ComponentButton)
|
||||
};
|
||||
|
||||
static const vec4 COMPONENT_BUTTON_STATE_NONE_COLOR = {1.0f, 1.0f, 1.0f, 1.0f};
|
||||
static const vec4 COMPONENT_BUTTON_STATE_HOVER_COLOR = {0.75f, 0.75f, 0.75f, 1.0f};
|
||||
static const vec4 COMPONENT_BUTTON_STATE_PRESSED_COLOR = {0.5f, 0.5f, 0.5f, 1.0f};
|
Reference in New Issue
Block a user