~mdw
/
sgt
/
puzzles
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
GNUstep compatibility: stop using the API feature isFlipped/setFlipped
[sgt/puzzles]
/
untangle.c
diff --git
a/untangle.c
b/untangle.c
index
e74fefa
..
c07c957
100644
(file)
--- a/
untangle.c
+++ b/
untangle.c
@@
-796,7
+796,7
@@
static void mark_crossings(game_state *state)
state->completed = TRUE;
}
state->completed = TRUE;
}
-static game_state *new_game(midend
_data
*me, game_params *params, char *desc)
+static game_state *new_game(midend *me, game_params *params, char *desc)
{
int n = params->n;
game_state *state = snew(game_state);
{
int n = params->n;
game_state *state = snew(game_state);
@@
-1000,8
+1000,8
@@
static char *solve_game(game_state *state, game_state *currstate,
pts[i].d = 2;
ox *= pts[i].d;
oy *= pts[i].d;
pts[i].d = 2;
ox *= pts[i].d;
oy *= pts[i].d;
- pts[i].x =
ox + 0.5
;
- pts[i].y =
oy + 0.5
;
+ pts[i].x =
(long)(ox + 0.5F)
;
+ pts[i].y =
(long)(oy + 0.5F)
;
extra = sprintf(buf, ";P%d:%ld,%ld/%ld", i,
pts[i].x, pts[i].y, pts[i].d);
extra = sprintf(buf, ";P%d:%ld,%ld/%ld", i,
pts[i].x, pts[i].y, pts[i].d);
@@
-1018,6
+1018,11
@@
static char *solve_game(game_state *state, game_state *currstate,
return ret;
}
return ret;
}
+static int game_can_format_as_text_now(game_params *params)
+{
+ return TRUE;
+}
+
static char *game_text_format(game_state *state)
{
return NULL;
static char *game_text_format(game_state *state)
{
return NULL;
@@
-1072,7
+1077,7
@@
static char *interpret_move(game_state *state, game_ui *ui, game_drawstate *ds,
{
int n = state->params.n;
{
int n = state->params.n;
- if (
button == LEFT_BUTTON
) {
+ if (
IS_MOUSE_DOWN(button)
) {
int i, best;
long bestd;
int i, best;
long bestd;
@@
-1106,12
+1111,12
@@
static char *interpret_move(game_state *state, game_ui *ui, game_drawstate *ds,
return "";
}
return "";
}
- } else if (
button == LEFT_DRAG
&& ui->dragpoint >= 0) {
+ } else if (
IS_MOUSE_DRAG(button)
&& ui->dragpoint >= 0) {
ui->newpoint.x = x;
ui->newpoint.y = y;
ui->newpoint.d = ds->tilesize;
return "";
ui->newpoint.x = x;
ui->newpoint.y = y;
ui->newpoint.d = ds->tilesize;
return "";
- } else if (
button == LEFT_RELEASE
&& ui->dragpoint >= 0) {
+ } else if (
IS_MOUSE_RELEASE(button)
&& ui->dragpoint >= 0) {
int p = ui->dragpoint;
char buf[80];
int p = ui->dragpoint;
char buf[80];
@@
-1185,13
+1190,13
@@
static void game_compute_size(game_params *params, int tilesize,
*x = *y = COORDLIMIT(params->n) * tilesize;
}
*x = *y = COORDLIMIT(params->n) * tilesize;
}
-static void game_set_size(
game_drawstate *ds, game_params *param
s,
- int tilesize)
+static void game_set_size(
drawing *dr, game_drawstate *d
s,
+
game_params *params,
int tilesize)
{
ds->tilesize = tilesize;
}
{
ds->tilesize = tilesize;
}
-static float *game_colours(frontend *fe,
game_state *state,
int *ncolours)
+static float *game_colours(frontend *fe, int *ncolours)
{
float *ret = snewn(3 * NCOLOURS, float);
{
float *ret = snewn(3 * NCOLOURS, float);
@@
-1235,7
+1240,7
@@
static float *game_colours(frontend *fe, game_state *state, int *ncolours)
return ret;
}
return ret;
}
-static game_drawstate *game_new_drawstate(game_state *state)
+static game_drawstate *game_new_drawstate(
drawing *dr,
game_state *state)
{
struct game_drawstate *ds = snew(struct game_drawstate);
int i;
{
struct game_drawstate *ds = snew(struct game_drawstate);
int i;
@@
-1251,7
+1256,7
@@
static game_drawstate *game_new_drawstate(game_state *state)
return ds;
}
return ds;
}
-static void game_free_drawstate(game_drawstate *ds)
+static void game_free_drawstate(
drawing *dr,
game_drawstate *ds)
{
sfree(ds->y);
sfree(ds->x);
{
sfree(ds->y);
sfree(ds->x);
@@
-1263,13
+1268,13
@@
static point mix(point a, point b, float distance)
point ret;
ret.d = a.d * b.d;
point ret;
ret.d = a.d * b.d;
- ret.x =
a.x * b.d + distance * (b.x * a.d - a.x * b.d
);
- ret.y =
a.y * b.d + distance * (b.y * a.d - a.y * b.d
);
+ ret.x =
(long)(a.x * b.d + distance * (b.x * a.d - a.x * b.d)
);
+ ret.y =
(long)(a.y * b.d + distance * (b.y * a.d - a.y * b.d)
);
return ret;
}
return ret;
}
-static void game_redraw(
frontend *fe
, game_drawstate *ds, game_state *oldstate,
+static void game_redraw(
drawing *dr
, game_drawstate *ds, game_state *oldstate,
game_state *state, int dir, game_ui *ui,
float animtime, float flashtime)
{
game_state *state, int dir, game_ui *ui,
float animtime, float flashtime)
{
@@
-1329,14
+1334,14
@@
static void game_redraw(frontend *fe, game_drawstate *ds, game_state *oldstate,
ds->bg = bg;
game_compute_size(&state->params, ds->tilesize, &w, &h);
ds->bg = bg;
game_compute_size(&state->params, ds->tilesize, &w, &h);
- draw_rect(
fe
, 0, 0, w, h, bg);
+ draw_rect(
dr
, 0, 0, w, h, bg);
/*
* Draw the edges.
*/
for (i = 0; (e = index234(state->graph->edges, i)) != NULL; i++) {
/*
* Draw the edges.
*/
for (i = 0; (e = index234(state->graph->edges, i)) != NULL; i++) {
- draw_line(
fe
, ds->x[e->a], ds->y[e->a], ds->x[e->b], ds->y[e->b],
+ draw_line(
dr
, ds->x[e->a], ds->y[e->a], ds->x[e->b], ds->y[e->b],
#ifdef SHOW_CROSSINGS
(oldstate?oldstate:state)->crosses[i] ?
COL_CROSSEDLINE :
#ifdef SHOW_CROSSINGS
(oldstate?oldstate:state)->crosses[i] ?
COL_CROSSEDLINE :
@@
-1367,23
+1372,23
@@
static void game_redraw(frontend *fe, game_drawstate *ds, game_state *oldstate,
if (c == thisc) {
#ifdef VERTEX_NUMBERS
if (c == thisc) {
#ifdef VERTEX_NUMBERS
- draw_circle(
fe
, ds->x[i], ds->y[i], DRAG_THRESHOLD, bg, bg);
+ draw_circle(
dr
, ds->x[i], ds->y[i], DRAG_THRESHOLD, bg, bg);
{
char buf[80];
sprintf(buf, "%d", i);
{
char buf[80];
sprintf(buf, "%d", i);
- draw_text(
fe
, ds->x[i], ds->y[i], FONT_VARIABLE,
+ draw_text(
dr
, ds->x[i], ds->y[i], FONT_VARIABLE,
DRAG_THRESHOLD*3/2,
ALIGN_VCENTRE|ALIGN_HCENTRE, c, buf);
}
#else
DRAG_THRESHOLD*3/2,
ALIGN_VCENTRE|ALIGN_HCENTRE, c, buf);
}
#else
- draw_circle(
fe
, ds->x[i], ds->y[i], CIRCLE_RADIUS,
+ draw_circle(
dr
, ds->x[i], ds->y[i], CIRCLE_RADIUS,
c, COL_OUTLINE);
#endif
}
}
}
c, COL_OUTLINE);
#endif
}
}
}
- draw_update(
fe
, 0, 0, w, h);
+ draw_update(
dr
, 0, 0, w, h);
}
static float game_anim_length(game_state *oldstate, game_state *newstate,
}
static float game_anim_length(game_state *oldstate, game_state *newstate,
@@
-1407,9
+1412,9
@@
static float game_flash_length(game_state *oldstate, game_state *newstate,
return 0.0F;
}
return 0.0F;
}
-static int game_
wants_statusbar(void
)
+static int game_
status(game_state *state
)
{
{
- return
FALSE
;
+ return
state->completed ? +1 : 0
;
}
static int game_timing_state(game_state *state, game_ui *ui)
}
static int game_timing_state(game_state *state, game_ui *ui)
@@
-1417,12
+1422,20
@@
static int game_timing_state(game_state *state, game_ui *ui)
return TRUE;
}
return TRUE;
}
+static void game_print_size(game_params *params, float *x, float *y)
+{
+}
+
+static void game_print(drawing *dr, game_state *state, int tilesize)
+{
+}
+
#ifdef COMBINED
#define thegame untangle
#endif
const struct game thegame = {
#ifdef COMBINED
#define thegame untangle
#endif
const struct game thegame = {
- "Untangle", "games.untangle",
+ "Untangle", "games.untangle",
"untangle",
default_params,
game_fetch_preset,
decode_params,
default_params,
game_fetch_preset,
decode_params,
@@
-1437,7
+1450,7
@@
const struct game thegame = {
dup_game,
free_game,
TRUE, solve_game,
dup_game,
free_game,
TRUE, solve_game,
- FALSE, game_text_format,
+ FALSE, game_
can_format_as_text_now, game_
text_format,
new_ui,
free_ui,
encode_ui,
new_ui,
free_ui,
encode_ui,
@@
-1452,7
+1465,9
@@
const struct game thegame = {
game_redraw,
game_anim_length,
game_flash_length,
game_redraw,
game_anim_length,
game_flash_length,
- game_wants_statusbar,
+ game_status,
+ FALSE, FALSE, game_print_size, game_print,
+ FALSE, /* wants_statusbar */
FALSE, game_timing_state,
FALSE, game_timing_state,
- SOLVE_ANIMATES, /*
mouse_prioritie
s */
+ SOLVE_ANIMATES, /*
flag
s */
};
};