tile_group_t hand;
} player_t;
-typedef struct selection_rectangle {
- int x, y, width, height, visible;
-} selection_rectangle_t;
+typedef struct selection_box {
+ int x1, x2, y1, y2, visible;
+} selection_box_t;
#define GAME_MAX_PLAYERS 4
#define GAME_WINDOW_DEFAULT_WIDTH 800
int num_players;
board_t board;
deck_t deck;
- selection_rectangle_t selection_rectangle;
+ selection_box_t selection_box;
RsvgHandle *blanktile;
int current_tile;
int release_x, release_y; /*Currently unused*/
} game_t;
-static void selection_rectangle_init(selection_rectangle_t *rect)
+static void selection_box_init(selection_box_t *box)
{
- rect->x = 0;
- rect->y = 0;
- rect->width = 0;
- rect->height = 0;
+ box->x1 = 0;
+ box->x2 = 0;
+ box->y1 = 0;
+ box->y2 = 0;
rect->visible = 0;
}
-static void selection_rectangle_draw(selection_rectangle_t *select_rect, cairo_t *cr)
+static void selection_box_draw(selection_box_t *box, cairo_t *cr)
{
- /************Fix this***************/
- cairo_rectangle (cr, select_rect->x, select_rect->y, select_rect->width, select_rect->height);
- cairo_set_source_rgba(cr, 0.0, 0.1, 0.2, 0.0);
+ int box_x = MIN(box->x1, box->x2);
+ int box_y = MIN(box->y1, box->y2);
+ int box_width = abs(box->x2 - box->x1);
+ int box_height = abs(box->y2 - box->y1);
+ cairo_rectangle (cr, box_x, box_y, box_width, box_height);
+ cairo_set_source_rgba(cr, 0.0, 0.1, 0.2, 0.5);
cairo_fill (cr);
}
game->num_players += 1;
}
- selection_rectangle_init(&game->selection_rectangle);
+ selection_box_init(&game->selection_box);
board_init(&game->board);
deck_init(&game->deck);
deck_shuffle(&game->deck);
deck_draw(game, cr, event->region);
- selection_rectangle_draw(&game->selection_rectangle, cr);
+ if (game->selection_box.visible)
+ selection_box_draw(&game->selection_box, cr);
hand_draw(game, 0, cr, event->region);
}
if (game->current_tile == -1)
{
+ game->selection_box.visible = 1;
/*These next two lines are likely to be replaced by...*/
game->click_x = event->x;
game->click_y = event->y;
/*...these two lines*/
- game->selection_rectangle.x = event->x;
- game->selection_rectangle.y = event->y;
+ game->selection_box.x1 = event->x;
+ game->selection_box.y1 = event->y;
}
return TRUE;
}
{
if (game->current_tile == -1)
{
+ selection_box_t *box;
+ box = &game->selection_box;
+
+ box->visible = 0;
+ gtk_widget_queue_draw_area (widget, box->x, box->y, box->width, box->height);
+
tile_group_t group;
group.num_tiles = 0;
{
if (game->current_tile == -1)
{
- selection_rectangle_t *select;
- select = &game->selection_rectangle;
- select->visible = 1;
+ selection_box_t *box;
+ box = &game->selection_box;
+ box->visible = 1;
- gtk_widget_queue_draw_area (widget, select->x - 1, select->y - 1, select->width + 1, select->height + 2);
+ gtk_widget_queue_draw_area (widget, box->x - 1, box->y - 1, box->width + 1, box->height + 2);
- select->width = event->x - select->x;
- select->height = event->y - select->y;
+ box->width = event->x - box->x;
+ box->height = event->y - box->y;
- gtk_widget_queue_draw_area (widget, select->x - 1, select->y - 1, select->width + 1, select->height + 2);
+ gtk_widget_queue_draw_area (widget, box->x - 1, box->y - 1, box->width + 1, box->height + 2);
}
else
{