(Manual conflict res on game.c) Merged main into ttm/joker-scop-1

This commit is contained in:
MeirGavish
2025-08-17 10:37:03 +03:00
9 changed files with 447 additions and 228 deletions
+14 -14
View File
@@ -3,23 +3,23 @@
#include <stdbool.h>
/* Defining an int list for simplicity
* If another list is needed, a generic void*
* list should be defined....
*/
typedef struct IntList
typedef struct List
{
int* _array;
void** _array;
int size;
int allocated_size;
} IntList;
} List;
IntList *int_list_new(int init_size);
void int_list_destroy(IntList **list);
bool int_list_append(IntList *list, int value);
bool int_list_remove_by_idx(IntList *list, int index);
int int_list_get(IntList *list, int index);
int int_list_get_size(IntList *list);
bool int_list_remove_by_value(IntList *list, int value);
List *list_new(int init_size);
void list_destroy(List **list);
bool list_append(List *list, void *value);
bool list_remove_by_idx(List *list, int index);
void* list_get(List *list, int index);
int list_get_size(List *list);
bool list_remove_by_value(List *list, void *value);
bool int_list_append(List *list, intptr_t value);
intptr_t int_list_get(List *list, int index);
bool int_list_remove_by_value(List *list, intptr_t value);
#endif
+41
View File
@@ -0,0 +1,41 @@
#ifndef SELECTION_GRID_H
#define SELECTION_GRID_H
#include <tonc.h>
typedef POINT Selection;
struct SelectionGridRow;
struct SelectionGrid;
typedef struct SelectionGridRow SelectionGridRow;
typedef struct SelectionGrid SelectionGrid;
// Called whenever there is a change in the selection cursor
// row_idx is the index of the row whose function is invoked - can be used to identify whether it is the previous or new selection row.
typedef void (*RowOnSelectionChangedFunc)(SelectionGrid* selection_grid, int row_idx, const Selection* prev_selection, const Selection* new_selection);
typedef int (*RowGetSizeFunc)();
// Called for any non-directional key hit
// The key will not be passed, the function will have to check key_hit() etc. for the key it wants to check
typedef void (*RowOnKeyHitFunc)(SelectionGrid* selection_grid, Selection* selection);
struct SelectionGridRow
{
int row_idx;
RowGetSizeFunc get_size;
RowOnSelectionChangedFunc on_selection_changed;
RowOnKeyHitFunc on_key_hit;
};
struct SelectionGrid
{
SelectionGridRow* rows;
const int num_rows;
Selection selection;
};
void selection_grid_process_input(SelectionGrid* selection_grid);
void selection_grid_move_selection_horz(SelectionGrid* selection_grid, int direction_tribool);
void selection_grid_move_selection_vert(SelectionGrid* selection_grid, int direction_tribool);
#endif
+4 -1
View File
@@ -27,6 +27,8 @@ typedef struct
FIXED rotation;
FIXED vrotation;
bool selected;
bool focused;
} SpriteObject;
// Sprite methods
@@ -58,6 +60,7 @@ void sprite_object_shake(SpriteObject* sprite_object, mm_word sound_id);
void sprite_object_set_selected(SpriteObject* sprite_object, bool selected);
bool sprite_object_is_selected(SpriteObject* sprite_object);
Sprite* sprite_object_get_sprite(SpriteObject* sprite_object);
void sprite_object_set_focus(SpriteObject* sprite_object, bool focus);
bool sprite_object_is_focused(SpriteObject* sprite_object);
#endif // SPRITE_H