In progress for more type flexibilty for UI.
This commit is contained in:
parent
3df203c588
commit
305c090e31
4
game.c
4
game.c
@ -49,8 +49,8 @@ void initGame()
|
|||||||
// stdscr is screen created by initscr()
|
// stdscr is screen created by initscr()
|
||||||
getmaxyx(stdscr, height, width);
|
getmaxyx(stdscr, height, width);
|
||||||
|
|
||||||
addLinei("x:", &cursor.x);
|
addLinei("x:", &cursor.x, 1, UI_INT);
|
||||||
addLinei("y:", &cursor.y);
|
addLinei("y:", &cursor.y, 1, UI_INT);
|
||||||
|
|
||||||
grid = initGrid(width, height);
|
grid = initGrid(width, height);
|
||||||
//randomizeGrid(grid);
|
//randomizeGrid(grid);
|
||||||
|
7
ui.c
7
ui.c
@ -5,7 +5,10 @@
|
|||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char* msg;
|
char* msg;
|
||||||
int* var;
|
void* var;
|
||||||
|
size_t size;
|
||||||
|
ui_type type;
|
||||||
|
|
||||||
}Linei;
|
}Linei;
|
||||||
|
|
||||||
static unsigned int ln_count = 0;
|
static unsigned int ln_count = 0;
|
||||||
@ -14,7 +17,7 @@ static Linei* lines = NULL;
|
|||||||
|
|
||||||
static void startUI();
|
static void startUI();
|
||||||
|
|
||||||
void addLinei(char* msg, int* var)
|
void addLinei(char* msg, void* var, int size, ui_type type)
|
||||||
{
|
{
|
||||||
if (!lines) startUI();
|
if (!lines) startUI();
|
||||||
else lines = realloc(lines, sizeof(Linei) * ++ln_count);
|
else lines = realloc(lines, sizeof(Linei) * ++ln_count);
|
||||||
|
13
ui.h
13
ui.h
@ -1,9 +1,20 @@
|
|||||||
#ifndef UI_H
|
#ifndef UI_H
|
||||||
#define UI_H
|
#define UI_H
|
||||||
|
|
||||||
|
#define ui_type uint8_t
|
||||||
|
|
||||||
|
#define ui_int int
|
||||||
|
#define ui_float float
|
||||||
|
#define ui_char char
|
||||||
|
|
||||||
|
#define UI_NULL 0
|
||||||
|
#define UI_INT 1
|
||||||
|
#define UI_FLOAT 2
|
||||||
|
#define UI_CHAR 3
|
||||||
|
|
||||||
//void startUI();
|
//void startUI();
|
||||||
|
|
||||||
void addLinei(char* msg, int* var);
|
void addLinei(char* msg, void* var, int size, ui_type type);
|
||||||
|
|
||||||
void drawUI();
|
void drawUI();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user