#ifndef _BOARD_H_ #define _BOARD_H_ #include #include #include typedef struct _TetringoBoard TetringoBoard; typedef struct _TetringoBoardClass TetringoBoardClass; typedef struct _TetringoBoardPriv TetringoBoardPriv; typedef enum { TETRINGO_BLOCK_NORMAL = 0, TETRINGO_BLOCK_UNUSED, TETRINGO_BLOCK_USED, NUM_BLOCK_TYPES } TetringoBlockType; struct _TetringoBoard { GObject parent_object; TetringoBoardPriv *priv; }; struct _TetringoBoardClass { GObjectClass parent_class; /* Signals */ void (*block_placed)(TetringoBoard *board, TetringoBlockType type, guint row, guint col); void (*block_removed)(TetringoBoard *board, guint row, guint col); void (*area_matched)(TetringoBoard *board, guint row, guint col, guint row_span, guint col_span); void (*cleared)(TetringoBoard *board); }; #define TETRINGO_TYPE_BOARD (tetringo_board_get_type()) #define TETRINGO_BOARD(obj) \ (G_TYPE_CHECK_INSTANCE_CAST((obj), TETRINGO_TYPE_BOARD, TetringoBoard)) #define TETRINGO_BOARD_CLASS(klass) \ (G_TYPE_CHECK_CLASS_CAST((klass), TETRINGO_TYPE_BOARD, TetringoBoardClass)) #define TETRINGO_IS_BOARD(obj) \ (G_TYPE_CHECK_INSTANCE_TYPE((obj), TETRINGO_TYPE_BOARD)) #define TETRINGO_IS_BOARD_CLASS(klass) \ (G_TYPE_CHECK_CLASS_TYPE((klass), TETRINGO_TYPE_BOARD)) #define TETRINGO_BOARD_GET_CLASS(obj) \ (G_TYPE_INSTANCE_GET_CLASS ((obj), TETRINGO_TYPE_BOARD, TetringoBoardClass)) GType tetringo_board_get_type(void); TetringoBoard *tetringo_board_new(guint num_rows, guint num_cols); void tetringo_board_set_blocks_type(TetringoBoard *board, TetringoBlockType block_type); TetringoBlockType tetringo_board_get_blocks_type(const TetringoBoard *board); guint tetringo_board_get_num_rows(const TetringoBoard *board); guint tetringo_board_get_num_cols(const TetringoBoard *board); gboolean tetringo_board_get_has_block(const TetringoBoard *board, guint row, guint col); void tetringo_board_clear(TetringoBoard *board); void tetringo_board_place_piece(TetringoBoard *board, Piece piece, TetringoBlockType block_type, guint row, guint col); void tetringo_board_remove_block(TetringoBoard *board, guint row, guint col); void tetringo_board_remove_blocks(TetringoBoard *board, guint row, guint col, guint row_span, guint col_span); void tetringo_board_area_matched(TetringoBoard *board, guint row, guint col, guint row_span, guint col_span); gboolean tetringo_board_can_place_piece(const TetringoBoard *board, Piece piece, guint row, guint col); #endif /* _BOARD_H_ */