added kubo_state_wall_new

This commit is contained in:
Luka Jankovic 2025-09-27 16:42:59 +02:00
parent fb8ff21666
commit c3973ae02b
9 changed files with 96 additions and 26 deletions

View file

@ -1,6 +1,7 @@
set(STATES_SOURCES
${CMAKE_CURRENT_SOURCE_DIR}/kubo_state_normal.c
${CMAKE_CURRENT_SOURCE_DIR}/kubo_state_command.c
${CMAKE_CURRENT_SOURCE_DIR}/kubo_state_wall_new.c
${CMAKE_CURRENT_SOURCE_DIR}/kubo_state_wall_select.c
PARENT_SCOPE
)

View file

@ -22,5 +22,4 @@
void kubo_state_command_entered(void *context_data) {
struct kubo_context *context = (struct kubo_context *)context_data;
(void)context;
printf("hello from state command\n");
}

View file

@ -17,3 +17,20 @@
*/
#include "kubo_state_normal.h"
#include "../kubo_context.h"
void kubo_state_normal_entered(void *context_data) { (void)context_data; }
void kubo_state_normal_key(void *context_data, int key_code) {
struct kubo_context *context = (struct kubo_context *)context_data;
switch (key_code) {
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;
}
}

View file

@ -23,9 +23,12 @@
#include "kubo_state_data.h"
void kubo_state_normal_entered(void *context_data);
void kubo_state_normal_key(void *context_data, int key_code);
static const struct kubo_state_data kubo_state_normal_data = {
.state_entered = NULL,
.state_key = NULL
.state_entered = kubo_state_normal_entered,
.state_key = kubo_state_normal_key
};
#endif

View file

@ -0,0 +1,36 @@
/*
* Copyright Luka Jankovic 2025
*
* This file is part of Kubo.
*
* Kubo is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* Kubo is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* Kubo. If not, see <https://www.gnu.org/licenses/>.
*/
#include "kubo_state_wall_new.h"
#include "../kubo_context.h"
extern bool kubo_mouse_snap;
void kubo_state_wall_new_entered(void *context_data) {
struct kubo_context *context = (struct kubo_context *)context_data;
(void)context;
}
void kubo_state_wall_new_key(void *context_data, int key_code) {
struct kubo_context *context = (struct kubo_context *)context_data;
(void)context;
if (key_code == KEY_S) {
kubo_mouse_snap = !kubo_mouse_snap;
}
}

View file

@ -0,0 +1,32 @@
/*
* Copyright Luka Jankovic 2025
*
* This file is part of Kubo.
*
* Kubo is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* Kubo is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* Kubo. If not, see <https://www.gnu.org/licenses/>.
*/
#ifndef KUBO_STATE_WALL_NEW_H
#define KUBO_STATE_WALL_NEW_H
#include "kubo_state_data.h"
void kubo_state_wall_new_entered(void *context_data);
void kubo_state_wall_new_key(void *context_data, int key_code);
static const struct kubo_state_data kubo_state_wall_new_data = {
.state_entered = kubo_state_wall_new_entered,
.state_key = kubo_state_wall_new_key
};
#endif

View file

@ -21,6 +21,7 @@
#include "kubo_state_command.h"
#include "kubo_state_normal.h"
#include "kubo_state_wall_new.h"
#include "kubo_state_wall_select.h"
enum kubo_context_state {
@ -38,7 +39,7 @@ 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_NEW, kubo_state_wall_select_data },
{ KUBO_CONTEXT_WALL_NEW, kubo_state_wall_new_data },
{ KUBO_CONTEXT_WALL_SELECT, kubo_state_wall_select_data }
};