aboutsummaryrefslogtreecommitdiff
path: root/midend.c
diff options
context:
space:
mode:
authorSimon Tatham <anakin@pobox.com>2004-04-27 17:44:30 +0000
committerSimon Tatham <anakin@pobox.com>2004-04-27 17:44:30 +0000
commitd99e217cfb12f40dd7dbc26146ef287f9f9020fc (patch)
tree531dd9d2e94f62ba974f8a9ddab2222c2eba2d8b /midend.c
parent9867234e70002b8252a48c2bc023875ff87b8ca1 (diff)
downloadpuzzles-d99e217cfb12f40dd7dbc26146ef287f9f9020fc.zip
puzzles-d99e217cfb12f40dd7dbc26146ef287f9f9020fc.tar.gz
puzzles-d99e217cfb12f40dd7dbc26146ef287f9f9020fc.tar.bz2
puzzles-d99e217cfb12f40dd7dbc26146ef287f9f9020fc.tar.xz
Implemented Cube, in a sufficiently general way that it also handles
the tetrahedron, octahedron and icosahedron. [originally from svn r4151]
Diffstat (limited to 'midend.c')
-rw-r--r--midend.c22
1 files changed, 15 insertions, 7 deletions
diff --git a/midend.c b/midend.c
index edde2e8..d309068 100644
--- a/midend.c
+++ b/midend.c
@@ -91,16 +91,22 @@ void midend_restart_game(midend_data *me)
me->statepos = me->nstates;
}
-void midend_undo(midend_data *me)
+static int midend_undo(midend_data *me)
{
- if (me->statepos > 1)
+ if (me->statepos > 1) {
me->statepos--;
+ return 1;
+ } else
+ return 0;
}
-void midend_redo(midend_data *me)
+static int midend_redo(midend_data *me)
{
- if (me->statepos < me->nstates)
+ if (me->statepos < me->nstates) {
me->statepos++;
+ return 1;
+ } else
+ return 0;
}
int midend_process_key(midend_data *me, int x, int y, int button)
@@ -126,10 +132,12 @@ int midend_process_key(midend_data *me, int x, int y, int button)
midend_redraw(me);
return 1; /* never animate */
} else if (button == 'u' || button == 'u' ||
- button == '\x1A' || button == '\x1F') {
- midend_undo(me);
+ button == '\x1A' || button == '\x1F') {
+ if (!midend_undo(me))
+ return 1;
} else if (button == '\x12') {
- midend_redo(me);
+ if (!midend_redo(me))
+ return 1;
} else if (button == 'q' || button == 'Q' || button == '\x11') {
free_game(oldstate);
return 0;