mirror of
git://git.tartarus.org/simon/puzzles.git
synced 2025-04-21 08:01:30 -07:00
Expose the NO_EFFECT/UNUSED distinction through midend_process_key()
This removed the "handled" pointer and instead extends the existing boolean return value (quit or don't quit) into an enumeration. One of the values still quits the program, but now there are different values for keys that had an effect, had no effect, and are not used by the puzzle at all. The mapping from interpret_move results to process_key results is roughly: move string -> PKR_SOME_EFFECT MOVE_UI_UPDATE -> PKR_SOME_EFFECT MOVE_NO_EFFECT -> PKR_NO_EFFECT MOVE_UNUSED -> PKR_UNUSED The mid-end can also generate results internally, and is the only place that PKR_QUIT can arise. For compatibility, PKR_QUIT is zero, so anything expecting a false return value to mean quit will be unsurprised. The other values are ordered so that lower values indicate a greater amount of handling of the key.
This commit is contained in:
10
nestedvm.c
10
nestedvm.c
@ -206,7 +206,7 @@ int jcallback_key_event(int x, int y, int keyval)
|
||||
if (fe->ox == -1)
|
||||
return 1;
|
||||
if (keyval >= 0 &&
|
||||
!midend_process_key(fe->me, x - fe->ox, y - fe->oy, keyval, NULL))
|
||||
midend_process_key(fe->me, x - fe->ox, y - fe->oy, keyval) == PKR_QUIT)
|
||||
return 42;
|
||||
return 1;
|
||||
}
|
||||
@ -323,7 +323,7 @@ static bool get_config(frontend *fe, int which)
|
||||
int jcallback_newgame_event(void)
|
||||
{
|
||||
frontend *fe = (frontend *)_fe;
|
||||
if (!midend_process_key(fe->me, 0, 0, UI_NEWGAME, NULL))
|
||||
if (midend_process_key(fe->me, 0, 0, UI_NEWGAME) == PKR_QUIT)
|
||||
return 42;
|
||||
return 0;
|
||||
}
|
||||
@ -331,7 +331,7 @@ int jcallback_newgame_event(void)
|
||||
int jcallback_undo_event(void)
|
||||
{
|
||||
frontend *fe = (frontend *)_fe;
|
||||
if (!midend_process_key(fe->me, 0, 0, UI_UNDO, NULL))
|
||||
if (midend_process_key(fe->me, 0, 0, UI_UNDO) == PKR_QUIT)
|
||||
return 42;
|
||||
return 0;
|
||||
}
|
||||
@ -339,7 +339,7 @@ int jcallback_undo_event(void)
|
||||
int jcallback_redo_event(void)
|
||||
{
|
||||
frontend *fe = (frontend *)_fe;
|
||||
if (!midend_process_key(fe->me, 0, 0, UI_REDO, NULL))
|
||||
if (midend_process_key(fe->me, 0, 0, UI_REDO) == PKR_QUIT)
|
||||
return 42;
|
||||
return 0;
|
||||
}
|
||||
@ -347,7 +347,7 @@ int jcallback_redo_event(void)
|
||||
int jcallback_quit_event(void)
|
||||
{
|
||||
frontend *fe = (frontend *)_fe;
|
||||
if (!midend_process_key(fe->me, 0, 0, UI_QUIT, NULL))
|
||||
if (midend_process_key(fe->me, 0, 0, UI_QUIT) == PKR_QUIT)
|
||||
return 42;
|
||||
return 0;
|
||||
}
|
||||
|
Reference in New Issue
Block a user