/* Something like buff */
#define BACKGROUND_COLOR 0.89, 0.70, 0.40
+#define RED_RING_COLOR 0.8, 0.2, 0.2
+
/* Relative to a unit square. */
#define RING_OUTER_RADIUS 0.4
#define RING_INNER_RADIUS 0.2
int x, y;
char *error;
+ /* Ignore double and triple clicks. */
+ if (event->type >= GDK_2BUTTON_PRESS)
+ return TRUE;
+
+ /* Right-click means pass, (yes, it would be better to add some
+ * actual UI elements... */
+ if (event->button == 3) {
+ dvonn_board_pass (&game->board);
+ return TRUE;
+ }
+
x = event->x;
y = event->y;
layout_device_to_board (layout, &x, &y);
}
if (! game->has_selected) {
- if (game->board.cells[x][y].type == game->board.player) {
- game->has_selected = TRUE;
- game->selected_x = x;
- game->selected_y = y;
- dvonn_game_update_windows (game);
- }
+ if (game->board.cells[x][y].type == game->board.player &&
+ ! dvonn_board_cell_surrounded (&game->board, x, y))
+ {
+ game->has_selected = TRUE;
+ game->selected_x = x;
+ game->selected_y = y;
+ dvonn_game_update_windows (game);
+ }
return TRUE;
}
cairo_translate(cr,
x + (y - DVONN_BOARD_Y_SIZE/2) / 2.0,
M_SQRT1_2 * y);
+ if (cell.contains_red && cell.type != DVONN_CELL_RED) {
+ cairo_new_sub_path (cr);
+ cairo_arc (cr, 0.5, 0.5,
+ (RING_INNER_RADIUS + RING_OUTER_RADIUS)/2.0,
+ 0, 2 * M_PI);
+ cairo_set_source_rgb (cr, RED_RING_COLOR);
+ cairo_fill (cr);
+ }
ring_path (cr);
switch (cell.type) {
case DVONN_CELL_WHITE:
cairo_set_source_rgb (cr, 0.0, 0.0, 0.0); /* black */
break;
case DVONN_CELL_RED:
- cairo_set_source_rgb (cr, 0.8, 0.2, 0.2); /* red */
+ cairo_set_source_rgb (cr, RED_RING_COLOR);
break;
case DVONN_CELL_EMPTY:
default:
}
cairo_fill (cr);
- if (game->board.cells[x][y].height) {
+ if (game->board.cells[x][y].height > 1) {
PangoLayout *height;
cairo_move_to (cr,
- 0.5 - 0.8 * RING_INNER_RADIUS * cos (M_PI_4),
+ 0.5 - 0.7 * RING_INNER_RADIUS * cos (M_PI_4),
0.5 - 1.2 * RING_INNER_RADIUS * sin (M_PI_4));
height = _create_layout_printf (cr, game->font, "%d",
game->board.cells[x][y].height);