enforce code style warnings

This commit is contained in:
Luka Jankovic 2025-07-02 22:53:31 +02:00
parent c72a215afb
commit 54a49c2d60
10 changed files with 47 additions and 108 deletions

View file

@ -18,14 +18,21 @@
#include "kubo_window.h"
void kubo_window_init(struct kubo_context *context) {
static void window_render(struct kubo_context *context);
static void window_left_mouse(struct kubo_context *context);
static void window_right_mouse(struct kubo_context *context);
static void new_wall_click(struct kubo_context *context);
static void new_wall_end(struct kubo_context *context);
void kubo_window_init() {
SetConfigFlags(FLAG_WINDOW_RESIZABLE);
InitWindow(KUBO_WINDOW_WIDTH, KUBO_WINDOW_HEIGHT, "Kubo");
EnableEventWaiting();
SetExitKey(0);
}
void kubo_window_cleanup(struct kubo_context *context) { CloseWindow(); }
void kubo_window_cleanup() { CloseWindow(); }
bool kubo_window_should_close(struct kubo_context *context) {
return context->exit_pending || WindowShouldClose();
@ -39,14 +46,14 @@ void kubo_window_tick(struct kubo_context *context) {
if (IsMouseButtonPressed(MOUSE_BUTTON_RIGHT)) {
window_right_mouse(context);
}
window_key_input(context);
kubo_input_handle(context);
}
static void window_render(struct kubo_context *context) {
BeginDrawing();
ClearBackground(WHITE);
for (int i = 0; i < context->walls.count; i++) {
for (size_t i = 0; i < context->walls.count; i++) {
struct kubo_wall *wall = kubo_wall_arr_get(&context->walls, i);
assert(wall != NULL);
@ -82,76 +89,6 @@ static void window_right_mouse(struct kubo_context *context) {
}
}
static void window_key_input(struct kubo_context *context) {
window_char_input(context);
int key_code = GetKeyPressed();
if (context->state.id == KUBO_CONTEXT_COMMAND) {
switch (key_code) {
case KEY_ESCAPE:
kubo_context_set_state(context, KUBO_CONTEXT_NORMAL);
break;
case KEY_ENTER:
kubo_context_accept_cmd(context);
default:
break;
}
return;
}
if (!key_code) {
return;
}
switch (key_code) {
case KEY_Q:
kubo_context_set_state(context, KUBO_CONTEXT_NORMAL);
break;
case KEY_W:
kubo_context_set_state(context, KUBO_CONTEXT_WALL_NEW);
break;
case KEY_S:
kubo_context_set_state(context, KUBO_CONTEXT_WALL_SELECT);
break;
case KEY_RIGHT:
case KEY_UP:
case KEY_L:
case KEY_K:
kubo_context_select_next_wall(context);
break;
case KEY_LEFT:
case KEY_DOWN:
case KEY_J:
case KEY_H:
kubo_context_select_prev_wall(context);
break;
default:
break;
}
}
static void window_char_input(struct kubo_context *context) {
int char_code;
do {
char_code = GetCharPressed();
if (char_code && context->state.id == KUBO_CONTEXT_COMMAND) {
kubo_char_arr_add(&context->command, char_code);
} else if (char_code == ':') {
kubo_context_set_state(context, KUBO_CONTEXT_COMMAND);
}
} while (char_code > 0);
}
static void new_wall_click(struct kubo_context *context) {
struct kubo_wall *current_wall = kubo_context_get_pending_wall(context);