From ccdd081d36d53a1d93d700fb88c9ac703b164e20 Mon Sep 17 00:00:00 2001 From: Luka Jankovic Date: Fri, 26 Sep 2025 20:33:55 +0200 Subject: [PATCH] improved formatting --- kubo_bar.h | 2 +- kubo_camera.c | 4 ++-- kubo_command.c | 7 ++++--- kubo_context.c | 29 +++++++++++++++-------------- kubo_file.c | 4 ++-- kubo_file.h | 6 ++++-- kubo_input.c | 8 ++++---- kubo_wall.c | 5 +++-- kubo_wall.h | 3 ++- kubo_window.c | 5 +++-- main.c | 2 +- states/kubo_states.h | 8 +++++--- 12 files changed, 46 insertions(+), 37 deletions(-) diff --git a/kubo_bar.h b/kubo_bar.h index db3615d..6a88cae 100644 --- a/kubo_bar.h +++ b/kubo_bar.h @@ -24,8 +24,8 @@ #include -#include "kubo_context.h" #include "kubo_command_bar.h" +#include "kubo_context.h" void kubo_bar_render(struct kubo_context *context, bool snap_enabled); diff --git a/kubo_camera.c b/kubo_camera.c index f14fbbd..33e4b84 100644 --- a/kubo_camera.c +++ b/kubo_camera.c @@ -41,7 +41,7 @@ void kubo_camera_shift(Camera2D *camera, Vector2 delta) { } void kubo_camera_reset(Camera2D *camera) { - camera->target = (Vector2){.x = 0, .y = 0}; - camera->offset = (Vector2){.x = 0, .y = 0}; + camera->target = (Vector2){ .x = 0, .y = 0 }; + camera->offset = (Vector2){ .x = 0, .y = 0 }; camera->zoom = 1.0f; } diff --git a/kubo_command.c b/kubo_command.c index 68eae67..02c323c 100644 --- a/kubo_command.c +++ b/kubo_command.c @@ -23,9 +23,10 @@ static inline void kubo_command_write(struct kubo_context *context, char *rest); 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}}; + { ":q", kubo_command_exit }, + { ":w", kubo_command_write }, + { ":e", kubo_command_read } +}; static const size_t kubo_commands_size = sizeof(kubo_commands) / sizeof(kubo_commands[0]); diff --git a/kubo_context.c b/kubo_context.c index 3b5c7a6..ef1adb3 100644 --- a/kubo_context.c +++ b/kubo_context.c @@ -19,10 +19,11 @@ #include "kubo_context.h" 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_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 } +}; 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 && diff --git a/kubo_file.c b/kubo_file.c index ccffaa8..982d3de 100644 --- a/kubo_file.c +++ b/kubo_file.c @@ -24,8 +24,8 @@ struct kubo_context kubo_file_parse(char *file_name) { struct kubo_wall *wall = malloc(sizeof(struct kubo_wall)); kubo_wall_init(wall); for (size_t j = 0; j < scene->walls[i].vertices_count; j++) { - Vector2 vertex = {.x = scene->walls[i].vertices[j][0], - .y = scene->walls[i].vertices[j][1]}; + Vector2 vertex = { .x = scene->walls[i].vertices[j][0], + .y = scene->walls[i].vertices[j][1] }; kubo_wall_add_vertex(wall, vertex); } diff --git a/kubo_file.h b/kubo_file.h index 329760c..c959f14 100644 --- a/kubo_file.h +++ b/kubo_file.h @@ -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, diff --git a/kubo_input.c b/kubo_input.c index 8f0f044..32d9f7a 100644 --- a/kubo_input.c +++ b/kubo_input.c @@ -113,25 +113,25 @@ static void handle_camera_input(int key_code, Camera2D *camera) { case KEY_RIGHT: case KEY_L: kubo_camera_shift(camera, - (Vector2){.x = -KUBO_INPUT_CAMERA_SHIFT, .y = 0}); + (Vector2){ .x = -KUBO_INPUT_CAMERA_SHIFT, .y = 0 }); break; case KEY_UP: case KEY_K: kubo_camera_shift(camera, - (Vector2){.x = 0, .y = KUBO_INPUT_CAMERA_SHIFT}); + (Vector2){ .x = 0, .y = KUBO_INPUT_CAMERA_SHIFT }); break; case KEY_LEFT: case KEY_H: kubo_camera_shift(camera, - (Vector2){.x = KUBO_INPUT_CAMERA_SHIFT, .y = 0}); + (Vector2){ .x = KUBO_INPUT_CAMERA_SHIFT, .y = 0 }); break; case KEY_DOWN: case KEY_J: kubo_camera_shift(camera, - (Vector2){.x = 0, .y = -KUBO_INPUT_CAMERA_SHIFT}); + (Vector2){ .x = 0, .y = -KUBO_INPUT_CAMERA_SHIFT }); break; default: break; diff --git a/kubo_wall.c b/kubo_wall.c index dd106d1..3d94c02 100644 --- a/kubo_wall.c +++ b/kubo_wall.c @@ -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; @@ -56,7 +57,7 @@ void kubo_wall_render(struct kubo_wall *wall, bool select, Camera2D *camera, Vec if (wall->state == KUBO_WALL_DRAWING) { // Vector2 mouse = GetScreenToWorld2D(mouse, *camera); - Vector2 mouse_points[] = {points[wall->vertices.count - 1], mouse}; + Vector2 mouse_points[] = { points[wall->vertices.count - 1], mouse }; DrawSplineLinear(mouse_points, 2, 10.f, wall_color); } diff --git a/kubo_wall.h b/kubo_wall.h index 3cec98c..aaa871d 100644 --- a/kubo_wall.h +++ b/kubo_wall.h @@ -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 diff --git a/kubo_window.c b/kubo_window.c index a5bc02b..23d0e4f 100644 --- a/kubo_window.c +++ b/kubo_window.c @@ -19,7 +19,7 @@ #include "kubo_window.h" #include "raylib.h" -Camera2D camera = {0}; +Camera2D camera = { 0 }; bool kubo_mouse_snap = false; static void window_render(struct kubo_context *context, Vector2 mouse_pos); @@ -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; } diff --git a/main.c b/main.c index 42c14dd..9f3bbb9 100644 --- a/main.c +++ b/main.c @@ -26,7 +26,7 @@ #include "kubo_file.h" int main(int argc, char *argv[]) { - + kubo_command_init(); struct kubo_context context; diff --git a/states/kubo_states.h b/states/kubo_states.h index 3525e43..19b9a41 100644 --- a/states/kubo_states.h +++ b/states/kubo_states.h @@ -36,9 +36,11 @@ 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_NORMAL, kubo_state_normal_data }, + { KUBO_CONTEXT_COMMAND, kubo_state_command_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]);