reworked context state handling

This commit is contained in:
Luka Jankovic 2025-07-02 18:45:55 +02:00
parent 5eb4437ac4
commit 7528ed007e
4 changed files with 28 additions and 30 deletions

View file

@ -49,7 +49,7 @@ static void window_render(struct kubo_context *context) {
struct kubo_wall *wall = kubo_wall_arr_get(&context->walls, i);
assert(wall != NULL);
kubo_wall_render(wall, context->state == KUBO_CONTEXT_WALL_SELECT);
kubo_wall_render(wall, context->state.id == KUBO_CONTEXT_WALL_SELECT);
}
kubo_bar_render(context);
@ -58,7 +58,7 @@ static void window_render(struct kubo_context *context) {
}
static void window_left_mouse(struct kubo_context *context) {
switch (context->state) {
switch (context->state.id) {
case KUBO_CONTEXT_WALL_NEW:
new_wall_click(context);
break;
@ -70,7 +70,7 @@ static void window_left_mouse(struct kubo_context *context) {
}
static void window_right_mouse(struct kubo_context *context) {
switch (context->state) {
switch (context->state.id) {
case KUBO_CONTEXT_WALL_NEW:
new_wall_end(context);
break;
@ -87,7 +87,7 @@ static void window_key_input(struct kubo_context *context) {
int key_code = GetKeyPressed();
if (context->state == KUBO_CONTEXT_COMMAND) {
if (context->state.id == KUBO_CONTEXT_COMMAND) {
switch (key_code) {
case KEY_ESCAPE:
kubo_context_set_state(context, KUBO_CONTEXT_NORMAL);
@ -143,7 +143,7 @@ static void window_char_input(struct kubo_context *context) {
do {
char_code = GetCharPressed();
if (char_code && context->state == KUBO_CONTEXT_COMMAND) {
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);