frontend.h (1282B)
1 /* frontend.h - interfaz comun de la TUI (ncurses) y la GUI (SDL). */ 2 #ifndef FRONTEND_H 3 #define FRONTEND_H 4 5 #include "form.h" 6 #include "../gfx/catan_gfx.h" 7 8 typedef struct Frontend Frontend; 9 struct Frontend { 10 void (*draw_game)(Frontend *f, const Game *g, const Ctrl *c, const UiInfo *ui); 11 void (*draw_form)(Frontend *f, const Form *form); 12 /* Espera input o actividad en fds. 1 = hay evento en ev. */ 13 int (*wait)(Frontend *f, int timeout_ms, const int *fds, int nfds, InEvent *ev); 14 void (*close)(Frontend *f); 15 /* Opcional: pide una linea de texto con un cuadro del sistema (la web, donde no hay 16 * teclado tactil para el canvas). 1 = texto en buf, 0 = cancelado, -1 = no hay 17 * cuadro (NULL o -1: se escribe con el teclado). */ 18 int (*text_input)(Frontend *f, const char *title, char *buf, int n); 19 bool is_gui; 20 bool touch; /* pantalla tactil (la web en el telefono): botones en vez de teclas */ 21 HitList hits; /* zonas clickeables del ultimo dibujo */ 22 BoardGeom geom; /* geometria del tablero en px del frontend */ 23 int board_ox, board_oy, board_sy; /* evento (x,y) -> px de tablero */ 24 void *priv; 25 }; 26 27 Frontend *tui_open(void); 28 Frontend *gui_open(int layout, int scale); 29 30 #endif