COL_SLANT1,
COL_SLANT2,
COL_ERROR,
+ COL_CURSOR,
+ COL_FILLEDSQUARE,
NCOLOURS
};
return ret;
}
+struct game_ui {
+ int cur_x, cur_y, cur_visible;
+};
+
static game_ui *new_ui(game_state *state)
{
- return NULL;
+ game_ui *ui = snew(game_ui);
+ ui->cur_x = ui->cur_y = ui->cur_visible = 0;
+ return ui;
}
static void free_ui(game_ui *ui)
{
+ sfree(ui);
}
static char *encode_ui(game_ui *ui)
#define ERR_TR 0x00008000L
#define ERR_BL 0x00010000L
#define ERR_BR 0x00020000L
+#define CURSOR 0x00040000L
struct game_drawstate {
int tilesize;
int x, int y, int button)
{
int w = state->p.w, h = state->p.h;
+ int v;
+ char buf[80];
+ enum { CLOCKWISE, ANTICLOCKWISE, NONE } action = NONE;
if (button == LEFT_BUTTON || button == RIGHT_BUTTON) {
- int v;
- char buf[80];
-
/*
* This is an utterly awful hack which I should really sort out
* by means of a proper configuration mechanism. One Slant
button = LEFT_BUTTON;
}
}
+ action = (button == LEFT_BUTTON) ? CLOCKWISE : ANTICLOCKWISE;
x = FROMCOORD(x);
y = FROMCOORD(y);
if (x < 0 || y < 0 || x >= w || y >= h)
return NULL;
+ } else if (IS_CURSOR_SELECT(button)) {
+ if (!ui->cur_visible) {
+ ui->cur_visible = 1;
+ return "";
+ }
+ x = ui->cur_x;
+ y = ui->cur_y;
+
+ action = (button == CURSOR_SELECT2) ? ANTICLOCKWISE : CLOCKWISE;
+ } else if (IS_CURSOR_MOVE(button)) {
+ move_cursor(button, &ui->cur_x, &ui->cur_y, w, h, 0);
+ ui->cur_visible = 1;
+ return "";
+ }
- if (button == LEFT_BUTTON) {
+ if (action != NONE) {
+ if (action == CLOCKWISE) {
/*
* Left-clicking cycles blank -> \ -> / -> blank.
*/
{
float *ret = snewn(3 * NCOLOURS, float);
- frontend_default_colour(fe, &ret[COL_BACKGROUND * 3]);
+ /* CURSOR colour is a background highlight. */
+ game_mkhighlight(fe, ret, COL_BACKGROUND, COL_CURSOR, -1);
+
+ ret[COL_FILLEDSQUARE * 3 + 0] = ret[COL_BACKGROUND * 3 + 0];
+ ret[COL_FILLEDSQUARE * 3 + 1] = ret[COL_BACKGROUND * 3 + 1];
+ ret[COL_FILLEDSQUARE * 3 + 2] = ret[COL_BACKGROUND * 3 + 2];
ret[COL_GRID * 3 + 0] = ret[COL_BACKGROUND * 3 + 0] * 0.7F;
ret[COL_GRID * 3 + 1] = ret[COL_BACKGROUND * 3 + 1] * 0.7F;
if (v < 0)
return;
- p[0] = v + '0';
+ p[0] = (char)v + '0';
p[1] = '\0';
draw_circle(dr, COORD(x), COORD(y), CLUE_RADIUS,
bg >= 0 ? bg : COL_BACKGROUND, ccol);
clip(dr, COORD(x), COORD(y), TILESIZE, TILESIZE);
draw_rect(dr, COORD(x), COORD(y), TILESIZE, TILESIZE,
- (v & FLASH) ? COL_GRID : COL_BACKGROUND);
+ (v & FLASH) ? COL_GRID :
+ (v & CURSOR) ? COL_CURSOR :
+ (v & (BACKSLASH | FORWSLASH)) ? COL_FILLEDSQUARE :
+ COL_BACKGROUND);
/*
* Draw the grid lines.
ds->todraw[(y+2)*(w+2)+(x+1)] |= ERR_T_L | ERR_C_TL;
}
}
+ if (ui->cur_visible && ui->cur_x == x && ui->cur_y == y)
+ ds->todraw[(y+1)*(w+2)+(x+1)] |= CURSOR;
}
}
* I'll use 6mm squares by default.
*/
game_compute_size(params, 600, &pw, &ph);
- *x = pw / 100.0;
- *y = ph / 100.0;
+ *x = pw / 100.0F;
+ *y = ph / 100.0F;
}
static void game_print(drawing *dr, game_state *state, int tilesize)
}
#endif
+
+/* vim: set shiftwidth=4 tabstop=8: */