improved formatting
This commit is contained in:
parent
737ba58860
commit
ccdd081d36
12 changed files with 46 additions and 37 deletions
|
|
@ -24,8 +24,8 @@
|
|||
|
||||
#include <raylib.h>
|
||||
|
||||
#include "kubo_context.h"
|
||||
#include "kubo_command_bar.h"
|
||||
#include "kubo_context.h"
|
||||
|
||||
void kubo_bar_render(struct kubo_context *context, bool snap_enabled);
|
||||
|
||||
|
|
|
|||
|
|
@ -25,7 +25,8 @@ static inline void kubo_command_read(struct kubo_context *context, char *rest);
|
|||
static const struct kubo_command_data kubo_commands[] = {
|
||||
{ ":q", kubo_command_exit },
|
||||
{ ":w", kubo_command_write },
|
||||
{":e", kubo_command_read}};
|
||||
{ ":e", kubo_command_read }
|
||||
};
|
||||
|
||||
static const size_t kubo_commands_size =
|
||||
sizeof(kubo_commands) / sizeof(kubo_commands[0]);
|
||||
|
|
|
|||
|
|
@ -22,7 +22,8 @@ static const struct kubo_context_state_data kubo_context_states[] = {
|
|||
{ .id = KUBO_CONTEXT_NORMAL, .label = "Normal", .color = BLACK },
|
||||
{ .id = KUBO_CONTEXT_COMMAND, .label = "Command", .color = RED },
|
||||
{ .id = KUBO_CONTEXT_WALL_NEW, .label = "Wall New", .color = GREEN },
|
||||
{.id = KUBO_CONTEXT_WALL_SELECT, .label = "Wall Select", .color = BLUE}};
|
||||
{ .id = KUBO_CONTEXT_WALL_SELECT, .label = "Wall Select", .color = BLUE }
|
||||
};
|
||||
|
||||
void kubo_context_init(struct kubo_context *context) {
|
||||
|
||||
|
|
@ -45,16 +46,16 @@ void kubo_context_set_state(struct kubo_context *context,
|
|||
enum kubo_context_state state) {
|
||||
context->state = kubo_context_states[state];
|
||||
|
||||
switch (context->state.id) {
|
||||
case KUBO_CONTEXT_COMMAND:
|
||||
break;
|
||||
|
||||
case KUBO_CONTEXT_WALL_NEW:
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
// switch (context->state.id) {
|
||||
// case KUBO_CONTEXT_COMMAND:
|
||||
// break;
|
||||
//
|
||||
// case KUBO_CONTEXT_WALL_NEW:
|
||||
// break;
|
||||
//
|
||||
// default:
|
||||
// break;
|
||||
// }
|
||||
|
||||
for (unsigned i = 0; i < kubo_state_data_length; i++) {
|
||||
if (context->state.id == kubo_state_data[i].id &&
|
||||
|
|
|
|||
|
|
@ -49,7 +49,8 @@ static const cyaml_schema_value_t vertex_entry = {
|
|||
static const cyaml_schema_field_t wall_fields[] = {
|
||||
CYAML_FIELD_SEQUENCE("vertices", CYAML_FLAG_POINTER, struct kubo_file_wall,
|
||||
vertices, &vertex_entry, 0, CYAML_UNLIMITED),
|
||||
CYAML_FIELD_END};
|
||||
CYAML_FIELD_END
|
||||
};
|
||||
|
||||
static const cyaml_schema_value_t wall_schema = {
|
||||
CYAML_VALUE_MAPPING(CYAML_FLAG_DEFAULT, struct kubo_file_wall, wall_fields),
|
||||
|
|
@ -58,7 +59,8 @@ static const cyaml_schema_value_t wall_schema = {
|
|||
static const cyaml_schema_field_t scene_fields[] = {
|
||||
CYAML_FIELD_SEQUENCE("walls", CYAML_FLAG_POINTER, struct kubo_file_scene,
|
||||
walls, &wall_schema, 0, CYAML_UNLIMITED),
|
||||
CYAML_FIELD_END};
|
||||
CYAML_FIELD_END
|
||||
};
|
||||
|
||||
static const cyaml_schema_value_t top_schema = {
|
||||
CYAML_VALUE_MAPPING(CYAML_FLAG_POINTER, struct kubo_file_scene,
|
||||
|
|
|
|||
|
|
@ -40,7 +40,8 @@ Vector2 kubo_wall_get_vertex(struct kubo_wall *wall, size_t index) {
|
|||
return kubo_vector2_arr_get(&wall->vertices, index);
|
||||
}
|
||||
|
||||
void kubo_wall_render(struct kubo_wall *wall, bool select, Camera2D *camera, Vector2 mouse) {
|
||||
void kubo_wall_render(struct kubo_wall *wall, bool select, Camera2D *camera,
|
||||
Vector2 mouse) {
|
||||
(void)camera;
|
||||
Color wall_color =
|
||||
(select && wall->state == KUBO_WALL_SELECTED) ? BLUE : BLACK;
|
||||
|
|
|
|||
|
|
@ -47,6 +47,7 @@ void kubo_wall_cleanup(struct kubo_wall *wall);
|
|||
bool kubo_wall_add_vertex(struct kubo_wall *wall, Vector2 vec);
|
||||
Vector2 kubo_wall_get_vertex(struct kubo_wall *wall, size_t index);
|
||||
|
||||
void kubo_wall_render(struct kubo_wall *wall, bool select, Camera2D *camera, Vector2 mouse);
|
||||
void kubo_wall_render(struct kubo_wall *wall, bool select, Camera2D *camera,
|
||||
Vector2 mouse);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -154,7 +154,8 @@ static void new_wall_end(struct kubo_context *context) {
|
|||
static Vector2 mouse_grid_snap(Vector2 mouse_pos) {
|
||||
Vector2 snap_pos = {
|
||||
.x = round(mouse_pos.x / KUBO_GRID_SIZE) * KUBO_GRID_SIZE,
|
||||
.y = round(mouse_pos.y / KUBO_GRID_SIZE) * KUBO_GRID_SIZE};
|
||||
.y = round(mouse_pos.y / KUBO_GRID_SIZE) * KUBO_GRID_SIZE
|
||||
};
|
||||
|
||||
return snap_pos;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,7 +38,9 @@ struct kubo_state_list_entry {
|
|||
static const struct kubo_state_list_entry kubo_state_data[] = {
|
||||
{ KUBO_CONTEXT_NORMAL, kubo_state_normal_data },
|
||||
{ KUBO_CONTEXT_COMMAND, kubo_state_command_data },
|
||||
{KUBO_CONTEXT_WALL_SELECT, kubo_state_wall_select_data}};
|
||||
{ KUBO_CONTEXT_WALL_NEW, kubo_state_wall_select_data },
|
||||
{ KUBO_CONTEXT_WALL_SELECT, kubo_state_wall_select_data }
|
||||
};
|
||||
|
||||
static const unsigned kubo_state_data_length =
|
||||
sizeof(kubo_state_data) / sizeof(kubo_state_data[0]);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue